Fix bogus cached PowerState for map placed actors.
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user