diff --git a/OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs b/OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs index 6cef911902..4f296b79e9 100644 --- a/OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs +++ b/OpenRA.Mods.D2k/Traits/Buildings/ProductionFromMapEdge.cs @@ -22,11 +22,18 @@ namespace OpenRA.Mods.D2k.Traits public override object Create(ActorInitializer init) { return new ProductionFromMapEdge(init, this); } } - class ProductionFromMapEdge : Production + class ProductionFromMapEdge : Production, INotifyCreated { + RallyPoint rp; + public ProductionFromMapEdge(ActorInitializer init, ProductionInfo info) : base(init, info) { } + void INotifyCreated.Created(Actor self) + { + rp = self.TraitOrDefault(); + } + public override bool Produce(Actor self, ActorInfo producee, string factionVariant) { var location = self.World.Map.ChooseClosestEdgeCell(self.Location); @@ -37,7 +44,9 @@ namespace OpenRA.Mods.D2k.Traits if (aircraftInfo != null) pos += new WVec(0, 0, aircraftInfo.CruiseAltitude.Length); - var initialFacing = self.World.Map.FacingBetween(location, self.Location, 0); + var destination = rp != null ? rp.Location : self.Location; + + var initialFacing = self.World.Map.FacingBetween(location, destination, 0); self.World.AddFrameEndTask(w => { @@ -56,13 +65,13 @@ namespace OpenRA.Mods.D2k.Traits var move = newUnit.TraitOrDefault(); if (move != null) - newUnit.QueueActivity(move.MoveIntoWorld(newUnit, self.Location)); + newUnit.QueueActivity(move.MoveIntoWorld(newUnit, destination)); - newUnit.SetTargetLine(Target.FromCell(self.World, self.Location), Color.Green, false); + newUnit.SetTargetLine(Target.FromCell(self.World, destination), Color.Green, false); if (!self.IsDead) foreach (var t in self.TraitsImplementing()) - t.UnitProduced(self, newUnit, self.Location); + t.UnitProduced(self, newUnit, destination); var notifyOthers = self.World.ActorsWithTrait(); foreach (var notify in notifyOthers)