diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index e29dd217d9..a175b27af7 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -18,6 +18,7 @@ namespace OpenRa.Game public readonly int Index; public int Cash; public int Ore; + public int OreCapacity; public int DisplayCash; public int PowerProvided; public int PowerDrained; @@ -60,10 +61,10 @@ namespace OpenRa.Game if (PowerProvided - PowerDrained != oldBalance) GiveAdvice("lopower1.aud"); } - + public float GetSiloFullness() { - return (float)Ore / GetOreCapacity(); + return (float)Ore / OreCapacity; } public PowerState GetPowerState() @@ -73,9 +74,9 @@ namespace OpenRa.Game return PowerState.Critical; } - public int GetOreCapacity() + void UpdateOreCapacity() { - return Game.world.Actors + OreCapacity = Game.world.Actors .Where(a => a.Owner == this && a.traits.Contains()) .Select(a => a.Info as BuildingInfo) .Where(b => b != null) @@ -95,11 +96,10 @@ namespace OpenRa.Game { Ore += num; - var capacity = GetOreCapacity(); - if (Ore > capacity) - Ore = capacity; // trim off the overflow. + if (Ore > OreCapacity) + Ore = OreCapacity; // trim off the overflow. - if (Ore > .8 * capacity) + if (Ore > .8 * OreCapacity) GiveAdvice("silond1.aud"); // silos needed } @@ -123,6 +123,7 @@ namespace OpenRa.Game public void Tick() { UpdatePower(); + UpdateOreCapacity(); if (this == Game.LocalPlayer) { diff --git a/OpenRa.Game/Traits/StoresOre.cs b/OpenRa.Game/Traits/StoresOre.cs index 322355e76c..cd2d5210a8 100644 --- a/OpenRa.Game/Traits/StoresOre.cs +++ b/OpenRa.Game/Traits/StoresOre.cs @@ -13,8 +13,6 @@ namespace OpenRa.Game.Traits public IEnumerable GetPips() { - if (self.Info.OrePips == 0) yield break; - for (int i = 0; i < self.Info.OrePips; i++) { if (Game.LocalPlayer.GetSiloFullness() > i * 1.0f / self.Info.OrePips)