diff --git a/OpenRa.Game/Graphics/WorldRenderer.cs b/OpenRa.Game/Graphics/WorldRenderer.cs index ec9ba83177..41bcfebd4e 100644 --- a/OpenRa.Game/Graphics/WorldRenderer.cs +++ b/OpenRa.Game/Graphics/WorldRenderer.cs @@ -107,7 +107,7 @@ namespace OpenRa.Game.Graphics Game.OreTime * 1000, Game.LocalPlayer.Cash, PerfHistory.items[ "nodes_expanded" ].LastValue, - Game.LocalPlayer.Power + Game.LocalPlayer.GetTotalPower() ), new int2(5, 5), Color.White); PerfHistory.Render(renderer, lineRenderer); diff --git a/OpenRa.Game/Player.cs b/OpenRa.Game/Player.cs index c3b08fdc17..76d43c7e59 100644 --- a/OpenRa.Game/Player.cs +++ b/OpenRa.Game/Player.cs @@ -11,7 +11,8 @@ namespace OpenRa.Game public Race Race; public readonly int Index; public int Cash; - public int Power; + int powerProvided; + int powerDrained; public Player( int index, int palette, string playerName, Race race ) { @@ -20,7 +21,20 @@ namespace OpenRa.Game this.PlayerName = playerName; this.Race = race; this.Cash = 10000; - this.Power = 0; + this.powerProvided = this.powerDrained = 0; + } + + public void ChangePower(int dPower) + { + if (dPower > 0) + powerProvided += dPower; + if (dPower < 0) + powerDrained -= dPower; + } + + public int GetTotalPower() + { + return powerProvided - powerDrained; } public float GetSiloFullness() diff --git a/OpenRa.Game/Traits/Building.cs b/OpenRa.Game/Traits/Building.cs index 4f1890680a..0894e00baf 100644 --- a/OpenRa.Game/Traits/Building.cs +++ b/OpenRa.Game/Traits/Building.cs @@ -26,7 +26,7 @@ namespace OpenRa.Game.Traits UnitInfo.BuildingInfo bi = self.unitInfo as UnitInfo.BuildingInfo; if (bi == null) return; - self.Owner.Power += bi.Power; + self.Owner.ChangePower(bi.Power); } } }