From 855042894ca7f2771165c23d960043e0236bc8f3 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Fri, 24 Nov 2017 21:46:35 +0000 Subject: [PATCH] Fix bogus cached PowerState for map placed actors. --- OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs b/OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs index a7cced655f..8f4f051a6f 100644 --- a/OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs +++ b/OpenRA.Mods.Common/Traits/Power/Player/PowerManager.cs @@ -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;