diff --git a/OpenRA.Mods.RA/Production.cs b/OpenRA.Mods.RA/Production.cs index d5918b68ca..8a03489bec 100755 --- a/OpenRA.Mods.RA/Production.cs +++ b/OpenRA.Mods.RA/Production.cs @@ -56,22 +56,25 @@ namespace OpenRA.Mods.RA var fi = producee.Traits.Get(); var initialFacing = exitinfo.Facing < 0 ? Util.GetFacing(to - spawn, fi.GetInitialFacing()) : exitinfo.Facing; - var newUnit = self.World.CreateActor(producee.Name, new TypeDictionary + self.World.AddFrameEndTask(w => { - new OwnerInit(self.Owner), - new LocationInit(exit), - new CenterPositionInit(spawn), - new FacingInit(initialFacing) + var newUnit = self.World.CreateActor(producee.Name, new TypeDictionary + { + new OwnerInit(self.Owner), + new LocationInit(exit), + new CenterPositionInit(spawn), + new FacingInit(initialFacing) + }); + + var move = newUnit.Trait(); + if (exitinfo.MoveIntoWorld) + newUnit.QueueActivity(move.MoveIntoWorld(newUnit, exit)); + + var target = MoveToRallyPoint(self, newUnit, exit); + newUnit.SetTargetLine(Target.FromCell(target), Color.Green, false); + foreach (var t in self.TraitsImplementing()) + t.UnitProduced(self, newUnit, exit); }); - - var move = newUnit.Trait(); - if (exitinfo.MoveIntoWorld) - newUnit.QueueActivity(move.MoveIntoWorld(newUnit, exit)); - - var target = MoveToRallyPoint(self, newUnit, exit); - newUnit.SetTargetLine(Target.FromCell(target), Color.Green, false); - foreach (var t in self.TraitsImplementing()) - t.UnitProduced(self, newUnit, exit); } static CPos MoveToRallyPoint(Actor self, Actor newUnit, CPos exitLocation)