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:
@@ -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)
|
||||||
|
|||||||
Reference in New Issue
Block a user