Add IMove.EstimatedMoveDuration.
This commit is contained in:
@@ -191,6 +191,11 @@ namespace OpenRA.Mods.Cnc.Traits
|
|||||||
public Activity MoveIntoTarget(Actor self, Target target) { return null; }
|
public Activity MoveIntoTarget(Actor self, Target target) { return null; }
|
||||||
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { return null; }
|
public Activity VisualMove(Actor self, WPos fromPos, WPos toPos) { return null; }
|
||||||
|
|
||||||
|
public int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos)
|
||||||
|
{
|
||||||
|
return (toPos - fromPos).Length / Info.Speed;
|
||||||
|
}
|
||||||
|
|
||||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
||||||
|
|
||||||
// Actors with TDGunboat always move
|
// Actors with TDGunboat always move
|
||||||
|
|||||||
@@ -624,6 +624,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
new HeliFly(self, Target.FromPos(toPos)));
|
new HeliFly(self, Target.FromPos(toPos)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos)
|
||||||
|
{
|
||||||
|
var speed = MovementSpeed;
|
||||||
|
return speed > 0 ? (toPos - fromPos).Length / speed : 0;
|
||||||
|
}
|
||||||
|
|
||||||
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
public CPos NearestMoveableCell(CPos cell) { return cell; }
|
||||||
|
|
||||||
public bool IsMoving { get { return isMoving; } set { } }
|
public bool IsMoving { get { return isMoving; } set { } }
|
||||||
|
|||||||
@@ -465,6 +465,12 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
return VisualMove(self, fromPos, toPos, self.Location);
|
return VisualMove(self, fromPos, toPos, self.Location);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos)
|
||||||
|
{
|
||||||
|
var speed = MovementSpeedForCell(self, self.Location);
|
||||||
|
return speed > 0 ? (toPos - fromPos).Length / speed : 0;
|
||||||
|
}
|
||||||
|
|
||||||
public CPos NearestMoveableCell(CPos target)
|
public CPos NearestMoveableCell(CPos target)
|
||||||
{
|
{
|
||||||
// Limit search to a radius of 10 tiles
|
// Limit search to a radius of 10 tiles
|
||||||
|
|||||||
@@ -399,6 +399,7 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
Activity MoveToTarget(Actor self, Target target);
|
Activity MoveToTarget(Actor self, Target target);
|
||||||
Activity MoveIntoTarget(Actor self, Target target);
|
Activity MoveIntoTarget(Actor self, Target target);
|
||||||
Activity VisualMove(Actor self, WPos fromPos, WPos toPos);
|
Activity VisualMove(Actor self, WPos fromPos, WPos toPos);
|
||||||
|
int EstimatedMoveDuration(Actor self, WPos fromPos, WPos toPos);
|
||||||
CPos NearestMoveableCell(CPos target);
|
CPos NearestMoveableCell(CPos target);
|
||||||
bool IsMoving { get; set; }
|
bool IsMoving { get; set; }
|
||||||
bool IsMovingVertically { get; set; }
|
bool IsMovingVertically { get; set; }
|
||||||
|
|||||||
Reference in New Issue
Block a user