More style fixes for Move.
This commit is contained in:
@@ -20,11 +20,13 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
{
|
{
|
||||||
class Move : Activity
|
class Move : Activity
|
||||||
{
|
{
|
||||||
|
static readonly List<CPos> NoPath = new List<CPos>();
|
||||||
|
|
||||||
CPos? destination;
|
CPos? destination;
|
||||||
WRange nearEnough;
|
WRange nearEnough;
|
||||||
public List<CPos> path;
|
List<CPos> path;
|
||||||
Func<Actor, Mobile, List<CPos>> getPath;
|
Func<Actor, Mobile, List<CPos>> getPath;
|
||||||
public Actor ignoreBuilding;
|
Actor ignoreBuilding;
|
||||||
|
|
||||||
// For dealing with blockers
|
// For dealing with blockers
|
||||||
bool hasWaited;
|
bool hasWaited;
|
||||||
@@ -49,7 +51,8 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
public Move(CPos destination, WRange nearEnough)
|
public Move(CPos destination, WRange nearEnough)
|
||||||
{
|
{
|
||||||
this.getPath = (self,mobile) => self.World.WorldActor.Trait<PathFinder>().FindUnitPath( mobile.toCell, destination, self );
|
this.getPath = (self, mobile) => self.World.WorldActor.Trait<PathFinder>()
|
||||||
|
.FindUnitPath(mobile.toCell, destination, self);
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
this.nearEnough = nearEnough;
|
this.nearEnough = nearEnough;
|
||||||
}
|
}
|
||||||
@@ -59,15 +62,13 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
this.getPath = (self, mobile) =>
|
this.getPath = (self, mobile) =>
|
||||||
self.World.WorldActor.Trait<PathFinder>().FindPath(
|
self.World.WorldActor.Trait<PathFinder>().FindPath(
|
||||||
PathSearch.FromPoint(self.World, mobile.Info, self, mobile.toCell, destination, false)
|
PathSearch.FromPoint(self.World, mobile.Info, self, mobile.toCell, destination, false)
|
||||||
.WithIgnoredBuilding(ignoreBuilding)
|
.WithIgnoredBuilding(ignoreBuilding));
|
||||||
);
|
|
||||||
|
|
||||||
this.destination = destination;
|
this.destination = destination;
|
||||||
this.nearEnough = WRange.Zero;
|
this.nearEnough = WRange.Zero;
|
||||||
this.ignoreBuilding = ignoreBuilding;
|
this.ignoreBuilding = ignoreBuilding;
|
||||||
}
|
}
|
||||||
|
|
||||||
static readonly List<CPos> NoPath = new List<CPos>();
|
|
||||||
public Move(Target target, WRange range)
|
public Move(Target target, WRange range)
|
||||||
{
|
{
|
||||||
this.getPath = (self, mobile) =>
|
this.getPath = (self, mobile) =>
|
||||||
@@ -163,8 +164,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
Util.BetweenCells(mobile.fromCell, mobile.toCell) + (MobileInfo.SubCellOffsets[mobile.fromSubCell] + MobileInfo.SubCellOffsets[mobile.toSubCell]) / 2,
|
Util.BetweenCells(mobile.fromCell, mobile.toCell) + (MobileInfo.SubCellOffsets[mobile.fromSubCell] + MobileInfo.SubCellOffsets[mobile.toSubCell]) / 2,
|
||||||
mobile.Facing,
|
mobile.Facing,
|
||||||
mobile.Facing,
|
mobile.Facing,
|
||||||
0
|
0);
|
||||||
);
|
|
||||||
|
|
||||||
return move;
|
return move;
|
||||||
}
|
}
|
||||||
@@ -257,7 +257,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
public override void Cancel(Actor self)
|
public override void Cancel(Actor self)
|
||||||
{
|
{
|
||||||
path = new List<CPos>(0);
|
path = NoPath;
|
||||||
base.Cancel(self);
|
base.Cancel(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -272,11 +272,11 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
abstract class MovePart : Activity
|
abstract class MovePart : Activity
|
||||||
{
|
{
|
||||||
public readonly Move move;
|
protected readonly Move move;
|
||||||
public readonly PPos from, to;
|
protected readonly PPos from, to;
|
||||||
public readonly int fromFacing, toFacing;
|
protected readonly int fromFacing, toFacing;
|
||||||
public int moveFraction;
|
protected readonly int moveFractionTotal;
|
||||||
public readonly int moveFractionTotal;
|
protected int moveFraction;
|
||||||
|
|
||||||
public MovePart(Move move, PPos from, PPos to, int fromFacing, int toFacing, int startingFraction)
|
public MovePart(Move move, PPos from, PPos to, int fromFacing, int toFacing, int startingFraction)
|
||||||
{
|
{
|
||||||
@@ -304,7 +304,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
{
|
{
|
||||||
var mobile = self.Trait<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
var ret = InnerTick(self, mobile);
|
var ret = InnerTick(self, mobile);
|
||||||
mobile.IsMoving = (ret is MovePart);
|
mobile.IsMoving = ret is MovePart;
|
||||||
|
|
||||||
if (moveFraction > moveFractionTotal)
|
if (moveFraction > moveFractionTotal)
|
||||||
moveFraction = moveFractionTotal;
|
moveFraction = moveFractionTotal;
|
||||||
@@ -372,8 +372,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
Util.BetweenCells(mobile.toCell, nextCell.Value.First) + (toSubcellOffset + nextSubcellOffset) / 2,
|
Util.BetweenCells(mobile.toCell, nextCell.Value.First) + (toSubcellOffset + nextSubcellOffset) / 2,
|
||||||
mobile.Facing,
|
mobile.Facing,
|
||||||
Util.GetNearestFacing(mobile.Facing, Util.GetFacing(nextCell.Value.First - mobile.toCell, mobile.Facing)),
|
Util.GetNearestFacing(mobile.Facing, Util.GetFacing(nextCell.Value.First - mobile.toCell, mobile.Facing)),
|
||||||
moveFraction - moveFractionTotal
|
moveFraction - moveFractionTotal);
|
||||||
);
|
|
||||||
|
|
||||||
mobile.SetLocation(mobile.toCell, mobile.toSubCell, nextCell.Value.First, nextCell.Value.Second);
|
mobile.SetLocation(mobile.toCell, mobile.toSubCell, nextCell.Value.First, nextCell.Value.Second);
|
||||||
return ret;
|
return ret;
|
||||||
@@ -388,8 +387,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
Util.CenterOfCell(mobile.toCell) + toSubcellOffset,
|
Util.CenterOfCell(mobile.toCell) + toSubcellOffset,
|
||||||
mobile.Facing,
|
mobile.Facing,
|
||||||
mobile.Facing,
|
mobile.Facing,
|
||||||
moveFraction - moveFractionTotal
|
moveFraction - moveFractionTotal);
|
||||||
);
|
|
||||||
|
|
||||||
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);
|
||||||
@@ -416,12 +414,10 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
{
|
{
|
||||||
public static bool IsMoving(this Actor self)
|
public static bool IsMoving(this Actor self)
|
||||||
{
|
{
|
||||||
if (self.IsIdle)
|
var a = self.GetCurrentActivity();
|
||||||
|
if (a == null)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Activity a = self.GetCurrentActivity();
|
|
||||||
Debug.Assert(a != null);
|
|
||||||
|
|
||||||
// Dirty, but it suffices until we do something better:
|
// Dirty, but it suffices until we do something better:
|
||||||
if (a.GetType() == typeof(Move)) return true;
|
if (a.GetType() == typeof(Move)) return true;
|
||||||
if (a.GetType() == typeof(MoveAdjacentTo)) return true;
|
if (a.GetType() == typeof(MoveAdjacentTo)) return true;
|
||||||
|
|||||||
Reference in New Issue
Block a user