Fix UpdateTotals(); add debug info.

This commit is contained in:
Paul Chote
2010-09-18 14:48:37 +12:00
parent ce9caec291
commit c796e155e7
2 changed files with 8 additions and 5 deletions

View File

@@ -292,9 +292,9 @@ namespace OpenRA
public static void Exit() { quit = true; }
public static Action<Color,string,string> AddChatLine = (c,n,s) => {};
public static void Debug(string s, params object[] args)
{
{
AddChatLine(Color.White, "Debug", String.Format(s,args));
}

View File

@@ -45,7 +45,7 @@ namespace OpenRA.Traits
{
if (a.Owner != Player || !a.HasTrait<Building>())
return;
Game.Debug("Added {0}: {1}",a.Info.Name, a.Trait<Building>().GetPowerUsage());
PowerDrain.Add(a, a.Trait<Building>().GetPowerUsage());
UpdateTotals();
}
@@ -54,7 +54,7 @@ namespace OpenRA.Traits
{
if (a.Owner != Player || !a.HasTrait<Building>())
return;
Game.Debug("Updated {0}: {1}->{2}",a.Info.Name, PowerDrain[a], newPower);
PowerDrain[a] = newPower;
UpdateTotals();
}
@@ -63,13 +63,15 @@ namespace OpenRA.Traits
{
if (a.Owner != Player || !a.HasTrait<Building>())
return;
Game.Debug("Removing {0}",a.Info.Name);
PowerDrain.Remove(a);
UpdateTotals();
}
void UpdateTotals()
{
totalProvided = 0;
totalDrained = 0;
foreach (var p in PowerDrain.Values)
{
if (p > 0)
@@ -77,6 +79,7 @@ namespace OpenRA.Traits
else
totalDrained -= p;
}
Game.Debug("Provided: {0} Drained: {1}",totalProvided, totalDrained);
}
int nextPowerAdviceTime = 0;