Fix bogus cached PowerState for map placed actors.

This commit is contained in:
Paul Chote
2017-11-24 21:46:35 +00:00
committed by reaperrr
parent 5ec3ad0957
commit 855042894c

View File

@@ -25,7 +25,7 @@ namespace OpenRA.Mods.Common.Traits
public object Create(ActorInitializer init) { return new PowerManager(init.Self, this); }
}
public class PowerManager : ITick, ISync, IResolveOrder
public class PowerManager : INotifyCreated, ITick, ISync, IResolveOrder
{
readonly Actor self;
readonly PowerManagerInfo info;
@@ -58,6 +58,14 @@ namespace OpenRA.Mods.Common.Traits
wasHackEnabled = devMode.UnlimitedPower;
}
void INotifyCreated.Created(Actor self)
{
// Map placed actors will query an inconsistent power state when they are created
// (it will depend on the order that they are spawned by the world)
// Tell them to query the correct state once the world has been fully created
self.World.AddFrameEndTask(w => UpdatePowerRequiringActors());
}
public void UpdateActor(Actor a)
{
int old;