resources moved off player onto a synced trait

This commit is contained in:
Chris Forbes
2010-05-12 18:29:25 +12:00
parent a4592e7019
commit 46e465cf33
24 changed files with 186 additions and 152 deletions

View File

@@ -47,7 +47,7 @@ namespace OpenRA.Traits
{
while( p.Value.Count > 0 && !Rules.TechTree.BuildableItems( self.Owner, p.Key ).Contains( p.Value[ 0 ].Item ) )
{
self.Owner.GiveCash(p.Value[0].TotalCost - p.Value[0].RemainingCost); // refund what's been paid so far.
self.Owner.PlayerActor.traits.Get<PlayerResources>().GiveCash(p.Value[0].TotalCost - p.Value[0].RemainingCost); // refund what's been paid so far.
FinishProduction(p.Key);
}
if( p.Value.Count > 0 )
@@ -137,7 +137,7 @@ namespace OpenRA.Traits
else if( lastIndex == 0 )
{
var item = queue[0];
self.Owner.GiveCash(item.TotalCost - item.RemainingCost); // refund what's been paid so far.
self.Owner.PlayerActor.traits.Get<PlayerResources>().GiveCash(item.TotalCost - item.RemainingCost); // refund what's been paid so far.
FinishProduction(category);
}
}
@@ -232,7 +232,7 @@ namespace OpenRA.Traits
if (Paused) return;
if (player.GetPowerState() != PowerState.Normal)
if (player.PlayerActor.traits.Get<PlayerResources>().GetPowerState() != PowerState.Normal)
{
if (--slowdown <= 0)
slowdown = player.PlayerActor.Info.Traits.Get<ProductionQueueInfo>().LowPowerSlowdown;
@@ -241,7 +241,7 @@ namespace OpenRA.Traits
}
var costThisFrame = RemainingCost / RemainingTime;
if (costThisFrame != 0 && !player.TakeCash(costThisFrame)) return;
if (costThisFrame != 0 && !player.PlayerActor.traits.Get<PlayerResources>().TakeCash(costThisFrame)) return;
RemainingCost -= costThisFrame;
RemainingTime -= 1;
if (RemainingTime > 0) return;