diff --git a/OpenRA.Game/OpenRA.Game.csproj b/OpenRA.Game/OpenRA.Game.csproj
index b8cc2484bc..5f95edb4db 100755
--- a/OpenRA.Game/OpenRA.Game.csproj
+++ b/OpenRA.Game/OpenRA.Game.csproj
@@ -200,6 +200,7 @@
+
@@ -238,7 +239,6 @@
-
diff --git a/OpenRA.Game/Traits/Player/PlayerResources.cs b/OpenRA.Game/Traits/Player/PlayerResources.cs
index 04f9cfda3d..0c34764472 100644
--- a/OpenRA.Game/Traits/Player/PlayerResources.cs
+++ b/OpenRA.Game/Traits/Player/PlayerResources.cs
@@ -8,6 +8,7 @@ namespace OpenRA.Traits
class PlayerResourcesInfo : ITraitInfo
{
public readonly int InitialCash = 10000;
+ public readonly int InitialOre = 0;
public readonly int AdviceInterval = 250;
public object Create(Actor self) { return new PlayerResources(self); }
}
@@ -23,15 +24,22 @@ namespace OpenRA.Traits
var p = self.Owner;
Owner = p;
Cash = self.Info.Traits.Get().InitialCash;
+ Ore = self.Info.Traits.Get().InitialOre;
AdviceInterval = self.Info.Traits.Get().AdviceInterval;
}
[Sync]
public int Cash;
[Sync]
- public int CashCapacity;
- [Sync]
public int DisplayCash;
+
+ [Sync]
+ public int Ore;
+ [Sync]
+ public int OreCapacity;
+ [Sync]
+ public int DisplayOre;
+
[Sync]
public int PowerProvided;
[Sync]
@@ -67,23 +75,36 @@ namespace OpenRA.Traits
return PowerState.Critical;
}
- public float GetSiloFullness() { return (float)Cash / CashCapacity; }
+ public float GetSiloFullness() { return (float)Ore / OreCapacity; }
+ public void GiveOre(int num)
+ {
+ Ore += num;
+
+ if (Ore > OreCapacity)
+ {
+ nextSiloAdviceTime = 0;
+ Ore = OreCapacity;
+ }
+ }
+
public void GiveCash(int num)
{
Cash += num;
-
- if (Cash > CashCapacity)
- {
- nextSiloAdviceTime = 0;
- Cash = CashCapacity;
- }
}
public bool TakeCash(int num)
{
- if (Cash < num) return false;
+ if (Cash + Ore < num) return false;
+
+ // Spend cash before spending ore
Cash -= num;
+ if (Cash < 0)
+ {
+ Ore += Cash;
+ Cash = 0;
+ }
+
return true;
}
@@ -102,12 +123,12 @@ namespace OpenRA.Traits
nextPowerAdviceTime = AdviceInterval;
}
- CashCapacity = self.World.Queries.OwnedBy[Owner].WithTrait()
- .Sum(a => a.Actor.Info.Traits.Get().Capacity);
+ OreCapacity = self.World.Queries.OwnedBy[Owner].WithTrait()
+ .Sum(a => a.Actor.Info.Traits.Get().Capacity);
if (--nextSiloAdviceTime <= 0)
{
- if (Cash > 0.8*CashCapacity)
+ if (Ore > 0.8*OreCapacity)
Owner.GiveAdvice(Owner.World.WorldActor.Info.Traits.Get().SilosNeeded);
nextSiloAdviceTime = AdviceInterval;
@@ -121,12 +142,27 @@ namespace OpenRA.Traits
if (DisplayCash < Cash)
{
DisplayCash += move;
- Sound.PlayToPlayer(self.Owner, eva.CashTickUp);
+ //Sound.PlayToPlayer(self.Owner, eva.CashTickUp);
}
else if (DisplayCash > Cash)
{
DisplayCash -= move;
- Sound.PlayToPlayer(self.Owner, eva.CashTickDown);
+ //Sound.PlayToPlayer(self.Owner, eva.CashTickDown);
+ }
+
+ diff = Math.Abs(Ore - DisplayOre);
+ move = Math.Min(Math.Max((int)(diff * displayCashFracPerFrame),
+ displayCashDeltaPerFrame), diff);
+
+ if (DisplayOre < Ore)
+ {
+ DisplayOre += move;
+ //Sound.PlayToPlayer(self.Owner, eva.CashTickUp);
+ }
+ else if (DisplayOre > Ore)
+ {
+ DisplayOre -= move;
+ //Sound.PlayToPlayer(self.Owner, eva.CashTickDown);
}
}
}
diff --git a/OpenRA.Game/Traits/StoresCash.cs b/OpenRA.Game/Traits/StoresOre.cs
similarity index 85%
rename from OpenRA.Game/Traits/StoresCash.cs
rename to OpenRA.Game/Traits/StoresOre.cs
index a234eb1069..922c540cae 100644
--- a/OpenRA.Game/Traits/StoresCash.cs
+++ b/OpenRA.Game/Traits/StoresOre.cs
@@ -22,18 +22,18 @@ using System.Collections.Generic;
namespace OpenRA.Traits
{
- class StoresCashInfo : TraitInfo
+ class StoresOreInfo : TraitInfo
{
public readonly int Pips = 0;
public readonly int Capacity = 0;
}
- class StoresCash : IPips, IAcceptThief
+ class StoresOre : IPips, IAcceptThief
{
public void OnSteal(Actor self, Actor thief)
{
// Steal half the cash the building holds
- var toSteal = self.Info.Traits.Get().Capacity / 2;
+ var toSteal = self.Info.Traits.Get().Capacity / 2;
self.Owner.PlayerActor.traits.Get().TakeCash(toSteal);
thief.Owner.PlayerActor.traits.Get().GiveCash(toSteal);
@@ -43,7 +43,7 @@ namespace OpenRA.Traits
public IEnumerable GetPips(Actor self)
{
- var numPips = self.Info.Traits.Get().Pips;
+ var numPips = self.Info.Traits.Get().Pips;
return Graphics.Util.MakeArray( numPips,
i => (self.World.LocalPlayer.PlayerActor.traits.Get().GetSiloFullness() > i * 1.0f / numPips)
diff --git a/OpenRA.Game/Widgets/MoneyBinWidget.cs b/OpenRA.Game/Widgets/MoneyBinWidget.cs
index 36cd635e83..474012cd16 100644
--- a/OpenRA.Game/Widgets/MoneyBinWidget.cs
+++ b/OpenRA.Game/Widgets/MoneyBinWidget.cs
@@ -52,10 +52,22 @@ namespace OpenRA.Widgets
ChromeProvider.GetImage(Game.chrome.renderer, chromeCollection, "moneybin"),
new float2(Bounds.Left, 0), "chrome");
- var moneyDigits = playerResources.DisplayCash.ToString();
+ // Cash
+ var cashDigits = playerResources.DisplayCash.ToString();
var x = Bounds.Right - 65;
- foreach (var d in moneyDigits.Reverse())
+ foreach (var d in cashDigits.Reverse())
+ {
+ Game.chrome.renderer.RgbaSpriteRenderer.DrawSprite(
+ ChromeProvider.GetImage(Game.chrome.renderer, digitCollection, (d - '0').ToString()),
+ new float2(x, 6), "chrome");
+ x -= 14;
+ }
+ x -= 14;
+ // Ore
+ var oreDigits = playerResources.DisplayOre.ToString();
+
+ foreach (var d in oreDigits.Reverse())
{
Game.chrome.renderer.RgbaSpriteRenderer.DrawSprite(
ChromeProvider.GetImage(Game.chrome.renderer, digitCollection, (d - '0').ToString()),
diff --git a/OpenRA.Mods.Cnc/TiberiumRefinery.cs b/OpenRA.Mods.Cnc/TiberiumRefinery.cs
index 8fddb35c4d..4a7edb3682 100644
--- a/OpenRA.Mods.Cnc/TiberiumRefinery.cs
+++ b/OpenRA.Mods.Cnc/TiberiumRefinery.cs
@@ -67,11 +67,11 @@ namespace OpenRA.Mods.Cnc
// Convert resources to cash
var pr = self.Owner.PlayerActor.traits.Get();
int amount = Math.Min(Tiberium, Info.ProcessAmount);
- amount = Math.Min(amount, pr.CashCapacity - pr.Cash);
+ amount = Math.Min(amount, pr.OreCapacity - pr.Ore);
if (amount > 0)
{
Tiberium -=amount;
- pr.GiveCash(amount);
+ pr.GiveOre(amount);
}
nextProcessTime = Info.ProcessTick;
}
diff --git a/mods/cnc/structures.yaml b/mods/cnc/structures.yaml
index ce671be095..c20c207955 100644
--- a/mods/cnc/structures.yaml
+++ b/mods/cnc/structures.yaml
@@ -89,7 +89,7 @@ SILO:
Armor: wood
Sight: 4
RenderBuildingOre:
- StoresCash:
+ StoresOre:
Pips: 5
Capacity: 5000
-RenderBuilding: