From 1a2aafa17c2702f9bb434518fb25ed4bb5e13ec7 Mon Sep 17 00:00:00 2001 From: Gustas <37534529+PunkPun@users.noreply.github.com> Date: Tue, 8 Nov 2022 15:13:51 +0200 Subject: [PATCH] Fix backwards movement not canceling when BackwardDuration times out --- OpenRA.Mods.Common/Activities/Move/Move.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index dbfef381f7..44485868ab 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -484,12 +484,16 @@ namespace OpenRA.Mods.Common.Activities WRot? fromTerrainOrientation, WRot? toTerrainOrientation, int terrainOrientationMargin, int carryoverProgress, bool movingOnGroundLayer) : base(move, from, to, fromFacing, toFacing, fromTerrainOrientation, toTerrainOrientation, terrainOrientationMargin, carryoverProgress, movingOnGroundLayer) { } - static bool IsTurn(Mobile mobile, CPos nextCell, Map map) + bool IsTurn(Actor self, Mobile mobile, CPos nextCell, Map map) { // Some actors with a limited number of sprite facings should never move along curved trajectories. if (mobile.Info.AlwaysTurnInPlace) return false; + // When Backwards duration runs out, let the Move activity do the turn. + if (Move.actorFacingModifier != WAngle.Zero && self.World.WorldTick - Move.startTicks >= mobile.Info.BackwardDuration) + return false; + // Tight U-turns should be done in place instead of making silly looking loops. var nextFacing = map.FacingBetween(nextCell, mobile.ToCell, mobile.Facing); var currentFacing = map.FacingBetween(mobile.ToCell, mobile.FromCell, mobile.Facing); @@ -506,7 +510,7 @@ namespace OpenRA.Mods.Common.Activities var nextCell = parent.PopPath(self); if (nextCell != null) { - if (!mobile.IsTraitPaused && !mobile.IsTraitDisabled && IsTurn(mobile, nextCell.Value.Cell, map)) + if (!mobile.IsTraitPaused && !mobile.IsTraitDisabled && IsTurn(self, mobile, nextCell.Value.Cell, map)) { var nextSubcellOffset = map.Grid.OffsetOfSubCell(nextCell.Value.SubCell); WRot? nextToTerrainOrientation = null;