Seperated power into 'power provided' and 'power consumed'

This commit is contained in:
Matthew Bowra-Dean
2009-11-10 19:01:40 +13:00
parent a60be98721
commit abac3bd59d
3 changed files with 18 additions and 4 deletions

View File

@@ -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);

View File

@@ -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()

View File

@@ -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);
}
}
}