Defer UpdateFrozenActor until the end of the tick.

Updating the frozen actor calls Actor.GetTargetablePositions,
and so we must guarantee that Created has been called for
the ITargetablePositions traits first.
This commit is contained in:
Paul Chote
2019-02-04 19:21:27 +00:00
parent 0ee9219df3
commit 95dc9cb1d2

View File

@@ -74,11 +74,16 @@ namespace OpenRA.Mods.Common.Traits
return new FrozenState(frozenActor) { IsVisible = startsRevealed }; return new FrozenState(frozenActor) { IsVisible = startsRevealed };
}); });
if (startsRevealed) // Defer updating the frozen actor until we are sure that the
for (var playerIndex = 0; playerIndex < frozenStates.Count; playerIndex++) // actor's ITargetablePositions traits have been initialized
UpdateFrozenActor(self, frozenStates[playerIndex].FrozenActor, playerIndex); self.World.AddFrameEndTask(w =>
{
if (startsRevealed)
for (var playerIndex = 0; playerIndex < frozenStates.Count; playerIndex++)
UpdateFrozenActor(self, frozenStates[playerIndex].FrozenActor, playerIndex);
created = true; created = true;
});
} }
void UpdateFrozenActor(Actor self, FrozenActor frozenActor, int playerIndex) void UpdateFrozenActor(Actor self, FrozenActor frozenActor, int playerIndex)