More style fixes for Move.

This commit is contained in:
Paul Chote
2013-07-21 11:19:26 +12:00
parent 048bed0a5e
commit abdfac6e85

View File

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