From de735fbd2716df1cfc23cd4194279476b11a5371 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Wed, 19 Mar 2014 14:21:07 +1300 Subject: [PATCH] Use MoveIntoWorld for transports. Fixes #4758. --- OpenRA.Mods.RA/Activities/UnloadCargo.cs | 33 +++++++----------------- 1 file changed, 10 insertions(+), 23 deletions(-) diff --git a/OpenRA.Mods.RA/Activities/UnloadCargo.cs b/OpenRA.Mods.RA/Activities/UnloadCargo.cs index 81a5be6796..b248603c89 100644 --- a/OpenRA.Mods.RA/Activities/UnloadCargo.cs +++ b/OpenRA.Mods.RA/Activities/UnloadCargo.cs @@ -33,20 +33,21 @@ namespace OpenRA.Mods.RA.Activities public CPos? ChooseExitCell(Actor passenger) { - var mobile = passenger.Trait(); + var pos = passenger.Trait(); return cargo.CurrentAdjacentCells .Shuffle(self.World.SharedRandom) .Cast() - .FirstOrDefault(c => mobile.CanEnterCell(c.Value)); + .FirstOrDefault(c => pos.CanEnterCell(c.Value)); } IEnumerable BlockedExitCells(Actor passenger) { - var mobile = passenger.Trait(); + var pos = passenger.Trait(); + // Find the cells that are blocked by transient actors return cargo.CurrentAdjacentCells - .Where(c => mobile.MovementSpeedForCell(passenger, c) != int.MaxValue && !mobile.CanEnterCell(c)); + .Where(c => pos.CanEnterCell(c, null, true) != pos.CanEnterCell(c, null, false)); } public override Activity Tick(Actor self) @@ -58,6 +59,7 @@ namespace OpenRA.Mods.RA.Activities cloak.Uncloak(); var actor = cargo.Peek(self); + var spawn = self.CenterPosition; var exitCell = ChooseExitCell(actor); if (exitCell == null) @@ -71,33 +73,18 @@ namespace OpenRA.Mods.RA.Activities } cargo.Unload(self); - self.World.AddFrameEndTask(w => { if (actor.Destroyed) return; - var mobile = actor.Trait(); - - var exitSubcell = mobile.GetDesiredSubcell(exitCell.Value, null); - - mobile.fromSubCell = exitSubcell; // these settings make sure that the below Set* calls - mobile.toSubCell = exitSubcell; // and the above GetDesiredSubcell call pick a good free subcell for later units being unloaded - - var exit = exitCell.Value.CenterPosition + MobileInfo.SubCellOffsets[exitSubcell]; - var current = self.Location.CenterPosition + MobileInfo.SubCellOffsets[exitSubcell]; - - mobile.Facing = Util.GetFacing(exit - current, mobile.Facing); - mobile.SetPosition(actor, exitCell.Value); - mobile.SetVisualPosition(actor, current); - var speed = mobile.MovementSpeedForCell(actor, exitCell.Value); - var length = speed > 0 ? (exit - current).Length / speed : 0; + var move = actor.Trait(); + var pos = actor.Trait(); w.Add(actor); actor.CancelActivity(); - actor.QueueActivity(new Drag(current, exit, length)); - actor.QueueActivity(mobile.MoveTo(exitCell.Value, 0)); - + pos.SetVisualPosition(actor, spawn); + actor.QueueActivity(move.MoveIntoWorld(actor, exitCell.Value)); actor.SetTargetLine(Target.FromCell(exitCell.Value), Color.Green, false); });