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