Fix Move regression
If progress == Distance, we must not move again on the same tick, but still 'return true' to avoid losing a tick in the case when this is the last Move tick followed by a different activity (or a new queued Move, for example via waypoints).
This commit is contained in:
@@ -39,6 +39,7 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
};
|
};
|
||||||
|
|
||||||
int carryoverProgress;
|
int carryoverProgress;
|
||||||
|
int lastMovePartCompletedTick;
|
||||||
|
|
||||||
List<CPos> path;
|
List<CPos> path;
|
||||||
CPos? destination;
|
CPos? destination;
|
||||||
@@ -397,8 +398,6 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
protected readonly int Distance;
|
protected readonly int Distance;
|
||||||
protected int progress;
|
protected int progress;
|
||||||
|
|
||||||
protected bool firstTick = true;
|
|
||||||
|
|
||||||
public MovePart(Move move, WPos from, WPos to, WAngle fromFacing, WAngle toFacing, int carryoverProgress)
|
public MovePart(Move move, WPos from, WPos to, WAngle fromFacing, WAngle toFacing, int carryoverProgress)
|
||||||
{
|
{
|
||||||
Move = move;
|
Move = move;
|
||||||
@@ -442,19 +441,17 @@ namespace OpenRA.Mods.Common.Activities
|
|||||||
{
|
{
|
||||||
var mobile = Move.mobile;
|
var mobile = Move.mobile;
|
||||||
|
|
||||||
// Having non-zero progress in the first tick means that this MovePart is following on from
|
// Only move by a full speed step if we didn't already move this tick.
|
||||||
// a previous MovePart that has just completed during the same tick. In this case, we want to
|
// If we did, we limit the move to any carried-over leftover progress.
|
||||||
// apply the carried over progress but not evaluate a full new step until the next tick.
|
if (Move.lastMovePartCompletedTick < self.World.WorldTick)
|
||||||
if (!firstTick || progress == 0)
|
|
||||||
progress += mobile.MovementSpeedForCell(self, mobile.ToCell);
|
progress += mobile.MovementSpeedForCell(self, mobile.ToCell);
|
||||||
|
|
||||||
firstTick = false;
|
|
||||||
|
|
||||||
if (progress >= Distance)
|
if (progress >= Distance)
|
||||||
{
|
{
|
||||||
mobile.SetCenterPosition(self, To);
|
mobile.SetCenterPosition(self, To);
|
||||||
mobile.Facing = ToFacing;
|
mobile.Facing = ToFacing;
|
||||||
|
|
||||||
|
Move.lastMovePartCompletedTick = self.World.WorldTick;
|
||||||
Queue(OnComplete(self, mobile, Move));
|
Queue(OnComplete(self, mobile, Move));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user