diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index 89c181b77a..f60ad74c2b 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -259,6 +259,14 @@ namespace OpenRA.Mods.Common.Activities return Pair.New(nextCell, subCell); } + public override void Cancel(Actor self, bool keepQueue = false) + { + if (path != null) + path.Clear(); + + base.Cancel(self, keepQueue); + } + public override IEnumerable GetTargets(Actor self) { if (path != null) @@ -401,29 +409,26 @@ namespace OpenRA.Mods.Common.Activities var fromSubcellOffset = map.Grid.OffsetOfSubCell(mobile.FromSubCell); var toSubcellOffset = map.Grid.OffsetOfSubCell(mobile.ToSubCell); - if (!IsCanceling || self.Location.Layer == CustomMovementLayerType.Tunnel) + var nextCell = parent.PopPath(self); + if (nextCell != null) { - var nextCell = parent.PopPath(self); - if (nextCell != null) + if (IsTurn(mobile, nextCell.Value.First)) { - if (IsTurn(mobile, nextCell.Value.First)) - { - var nextSubcellOffset = map.Grid.OffsetOfSubCell(nextCell.Value.Second); - var ret = new MoveFirstHalf( - Move, - Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) + (fromSubcellOffset + toSubcellOffset) / 2, - Util.BetweenCells(self.World, mobile.ToCell, nextCell.Value.First) + (toSubcellOffset + nextSubcellOffset) / 2, - mobile.Facing, - Util.GetNearestFacing(mobile.Facing, map.FacingBetween(mobile.ToCell, nextCell.Value.First, mobile.Facing)), - moveFraction - MoveFractionTotal); + var nextSubcellOffset = map.Grid.OffsetOfSubCell(nextCell.Value.Second); + var ret = new MoveFirstHalf( + Move, + Util.BetweenCells(self.World, mobile.FromCell, mobile.ToCell) + (fromSubcellOffset + toSubcellOffset) / 2, + Util.BetweenCells(self.World, mobile.ToCell, nextCell.Value.First) + (toSubcellOffset + nextSubcellOffset) / 2, + mobile.Facing, + Util.GetNearestFacing(mobile.Facing, map.FacingBetween(mobile.ToCell, nextCell.Value.First, mobile.Facing)), + moveFraction - MoveFractionTotal); - mobile.FinishedMoving(self); - mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, nextCell.Value.First, nextCell.Value.Second); - return ret; - } - - parent.path.Add(nextCell.Value.First); + mobile.FinishedMoving(self); + mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, nextCell.Value.First, nextCell.Value.Second); + return ret; } + + parent.path.Add(nextCell.Value.First); } var toPos = mobile.ToCell.Layer == 0 ? map.CenterOfCell(mobile.ToCell) :