Fix some more cases of stale Player references after capture.

This commit is contained in:
Paul Chote
2011-01-30 17:14:00 +13:00
parent 7f3f783187
commit ccf04240cf
3 changed files with 27 additions and 8 deletions

View File

@@ -31,12 +31,12 @@ namespace OpenRA.Mods.RA
public virtual object Create(ActorInitializer init) { return new ProductionQueue(init.self, init.self.Owner.PlayerActor, this); }
}
public class ProductionQueue : IResolveOrder, ITick, ITechTreeElement
public class ProductionQueue : IResolveOrder, ITick, ITechTreeElement, INotifyCapture
{
public readonly Actor self;
public ProductionQueueInfo Info;
readonly PowerManager PlayerPower;
readonly PlayerResources PlayerResources;
PowerManager PlayerPower;
PlayerResources PlayerResources;
// TODO: sync these
// A list of things we are currently building
@@ -65,6 +65,14 @@ namespace OpenRA.Mods.RA
}
}
public void OnCapture(Actor self, Actor captor, Player oldOwner, Player newOwner)
{
PlayerPower = newOwner.PlayerActor.Trait<PowerManager>();
PlayerResources = newOwner.PlayerActor.Trait<PlayerResources>();
Queue.Clear();
// Produceable contains the tech from the original owner - this is desired so we don't clear it.
}
IEnumerable<ActorInfo> AllBuildables(string category)
{
return Rules.Info.Values