diff --git a/OpenRA.Mods.RA/Activities/UnloadCargo.cs b/OpenRA.Mods.RA/Activities/UnloadCargo.cs index ae2e7bcd8a..dae7003881 100644 --- a/OpenRA.Mods.RA/Activities/UnloadCargo.cs +++ b/OpenRA.Mods.RA/Activities/UnloadCargo.cs @@ -35,6 +35,19 @@ namespace OpenRA.Mods.RA.Activities return null; } + CPos? ChooseRallyPoint(Actor self) + { + var mobile = self.Trait(); + + for (var i = -1; i < 2; i++) + for (var j = -1; j < 2; j++) + if ((i != 0 || j != 0) && + mobile.CanEnterCell(self.Location + new CVec(i, j))) + return self.Location + new CVec(i, j); + + return self.Location; + } + public override Activity Tick(Actor self) { if (IsCanceled) return NextActivity; @@ -80,7 +93,10 @@ namespace OpenRA.Mods.RA.Activities actor.CancelActivity(); actor.QueueActivity(new Drag(currentPx, exitPx, length)); actor.QueueActivity(mobile.MoveTo(exitTile.Value, 0)); - actor.SetTargetLine(Target.FromCell(exitTile.Value), Color.Green, false); + + var rallyPoint = ChooseRallyPoint(actor).Value; + actor.QueueActivity(mobile.MoveTo(rallyPoint, 0)); + actor.SetTargetLine(Target.FromCell(rallyPoint), Color.Green, false); }); return this;