From 0b0f8bc51e968dfe51a2b65cbefffad4ed7a295d Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Mon, 17 Apr 2017 21:29:28 +0000 Subject: [PATCH] Require cancelled move orders to exit tunnels before completion. --- OpenRA.Mods.Common/Activities/Move/Move.cs | 45 +++++++++++----------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index e7418d6e83..eebf40fae8 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -142,7 +142,9 @@ namespace OpenRA.Mods.Common.Activities public override Activity Tick(Actor self) { - if (IsCanceled) + // If the actor is inside a tunnel then we must let them move + // all the way through before moving to the next activity + if (IsCanceled && self.Location.Layer != CustomMovementLayerType.Tunnel) return NextActivity; if (mobile.IsTraitDisabled) @@ -277,12 +279,6 @@ namespace OpenRA.Mods.Common.Activities return Pair.New(nextCell, subCell); } - public override bool Cancel(Actor self) - { - path = NoPath; - return base.Cancel(self); - } - public override IEnumerable GetTargets(Actor self) { if (path != null) @@ -426,26 +422,29 @@ namespace OpenRA.Mods.Common.Activities var fromSubcellOffset = map.Grid.OffsetOfSubCell(mobile.FromSubCell); var toSubcellOffset = map.Grid.OffsetOfSubCell(mobile.ToSubCell); - var nextCell = parent.PopPath(self); - if (nextCell != null) + if (!IsCanceled || self.Location.Layer == CustomMovementLayerType.Tunnel) { - if (IsTurn(mobile, nextCell.Value.First)) + var nextCell = parent.PopPath(self); + if (nextCell != null) { - 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); + 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); - mobile.FinishedMoving(self); - mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, nextCell.Value.First, nextCell.Value.Second); - return ret; + mobile.FinishedMoving(self); + mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, nextCell.Value.First, nextCell.Value.Second); + return ret; + } + + parent.path.Add(nextCell.Value.First); } - - parent.path.Add(nextCell.Value.First); } var toPos = mobile.ToCell.Layer == 0 ? map.CenterOfCell(mobile.ToCell) :