diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index afa1f55024..157c4321fb 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -392,18 +392,18 @@ namespace OpenRA.Mods.Common.Activities protected readonly int ArcToLength; protected readonly WAngle ArcToAngle; - protected readonly int MoveFractionTotal; - protected int moveFraction; + protected readonly int Distance; + protected int progress; - public MovePart(Move move, WPos from, WPos to, WAngle fromFacing, WAngle toFacing, int startingFraction) + public MovePart(Move move, WPos from, WPos to, WAngle fromFacing, WAngle toFacing, int carryoverProgress) { Move = move; From = from; To = to; FromFacing = fromFacing; ToFacing = toFacing; - moveFraction = startingFraction; - MoveFractionTotal = (to - from).Length; + progress = carryoverProgress; + Distance = (to - from).Length; IsInterruptible = false; // See comments in Move.Cancel() // Calculate an elliptical arc that joins from and to @@ -436,11 +436,11 @@ namespace OpenRA.Mods.Common.Activities public override bool Tick(Actor self) { var mobile = Move.mobile; - moveFraction += mobile.MovementSpeedForCell(self, mobile.ToCell); + progress += mobile.MovementSpeedForCell(self, mobile.ToCell); - if (moveFraction >= MoveFractionTotal) + if (progress >= Distance) { - moveFraction = MoveFractionTotal; + progress = Distance; mobile.SetCenterPosition(self, To); mobile.Facing = ToFacing; @@ -451,19 +451,19 @@ namespace OpenRA.Mods.Common.Activities WPos pos; if (EnableArc) { - var angle = WAngle.Lerp(ArcFromAngle, ArcToAngle, moveFraction, MoveFractionTotal); - var length = int2.Lerp(ArcFromLength, ArcToLength, moveFraction, MoveFractionTotal); - var height = int2.Lerp(From.Z, To.Z, moveFraction, MoveFractionTotal); + var angle = WAngle.Lerp(ArcFromAngle, ArcToAngle, progress, Distance); + var length = int2.Lerp(ArcFromLength, ArcToLength, progress, Distance); + var height = int2.Lerp(From.Z, To.Z, progress, Distance); pos = ArcCenter + new WVec(0, length, height).Rotate(WRot.FromYaw(angle)); } else - pos = WPos.Lerp(From, To, moveFraction, MoveFractionTotal); + pos = WPos.Lerp(From, To, progress, Distance); if (self.Location.Layer == 0) pos -= new WVec(WDist.Zero, WDist.Zero, self.World.Map.DistanceAboveTerrain(pos)); mobile.SetCenterPosition(self, pos); - mobile.Facing = WAngle.Lerp(FromFacing, ToFacing, moveFraction, MoveFractionTotal); + mobile.Facing = WAngle.Lerp(FromFacing, ToFacing, progress, Distance); return false; } @@ -477,8 +477,8 @@ namespace OpenRA.Mods.Common.Activities class MoveFirstHalf : MovePart { - public MoveFirstHalf(Move move, WPos from, WPos to, WAngle fromFacing, WAngle toFacing, int startingFraction) - : base(move, from, to, fromFacing, toFacing, startingFraction) { } + public MoveFirstHalf(Move move, WPos from, WPos to, WAngle fromFacing, WAngle toFacing, int carryoverProgress) + : base(move, from, to, fromFacing, toFacing, carryoverProgress) { } static bool IsTurn(Mobile mobile, CPos nextCell, Map map) { @@ -511,7 +511,7 @@ namespace OpenRA.Mods.Common.Activities Util.BetweenCells(self.World, mobile.ToCell, nextCell.Value.Cell) + (toSubcellOffset + nextSubcellOffset) / 2, mobile.Facing, map.FacingBetween(mobile.ToCell, nextCell.Value.Cell, mobile.Facing), - moveFraction - MoveFractionTotal); + progress - Distance); mobile.FinishedMoving(self); mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, nextCell.Value.Cell, nextCell.Value.SubCell); @@ -530,7 +530,7 @@ namespace OpenRA.Mods.Common.Activities toPos + toSubcellOffset, mobile.Facing, mobile.Facing, - moveFraction - MoveFractionTotal); + progress - Distance); mobile.EnteringCell(self); mobile.SetLocation(mobile.ToCell, mobile.ToSubCell, mobile.ToCell, mobile.ToSubCell); @@ -540,8 +540,8 @@ namespace OpenRA.Mods.Common.Activities class MoveSecondHalf : MovePart { - public MoveSecondHalf(Move move, WPos from, WPos to, WAngle fromFacing, WAngle toFacing, int startingFraction) - : base(move, from, to, fromFacing, toFacing, startingFraction) { } + public MoveSecondHalf(Move move, WPos from, WPos to, WAngle fromFacing, WAngle toFacing, int carryoverProgress) + : base(move, from, to, fromFacing, toFacing, carryoverProgress) { } protected override MovePart OnComplete(Actor self, Mobile mobile, Move parent) {