Remove *PxPosition from IOccupySpace/IPositionable.

This commit is contained in:
Paul Chote
2013-07-21 12:17:40 +12:00
parent 19165d259d
commit 6a435752fd
12 changed files with 19 additions and 51 deletions

View File

@@ -26,14 +26,14 @@ namespace OpenRA.Mods.RA.Move
this.length = length;
}
public override Activity Tick( Actor self )
public override Activity Tick(Actor self)
{
var mobile = self.Trait<Mobile>();
var pos = length > 1
? WPos.Lerp(start, end, ticks, length - 1)
: end;
mobile.AdjustPxPosition(self, PPos.FromWPos(pos));
mobile.SetVisualPosition(self, pos);
if (++ticks >= length)
{
mobile.IsMoving = false;
@@ -44,12 +44,12 @@ namespace OpenRA.Mods.RA.Move
return this;
}
public override IEnumerable<Target> GetTargets( Actor self )
public override IEnumerable<Target> GetTargets(Actor self)
{
yield return Target.FromPos(end);
}
// Cannot be cancelled
public override void Cancel( Actor self ) { }
public override void Cancel(Actor self) { }
}
}

View File

@@ -205,7 +205,7 @@ namespace OpenRA.Mods.RA.Move
if (init.Contains<LocationInit>())
{
this.__fromCell = this.__toCell = init.Get<LocationInit, CPos>();
this.PxPosition = PPos.FromWPos(fromCell.CenterPosition + MobileInfo.SubCellOffsets[fromSubCell]);
SetVisualPosition(self, fromCell.CenterPosition + MobileInfo.SubCellOffsets[fromSubCell]);
}
this.Facing = init.Contains<FacingInit>() ? init.Get<FacingInit, int>() : info.InitialFacing;
@@ -215,15 +215,7 @@ namespace OpenRA.Mods.RA.Move
public void SetPosition(Actor self, CPos cell)
{
SetLocation(cell,fromSubCell, cell,fromSubCell);
PxPosition = PPos.FromWPos(fromCell.CenterPosition + MobileInfo.SubCellOffsets[fromSubCell]);
FinishedMoving(self);
}
public void SetPxPosition(Actor self, PPos px)
{
var cell = px.ToCPos();
SetLocation(cell,fromSubCell, cell,fromSubCell);
PxPosition = px;
SetVisualPosition(self, fromCell.CenterPosition + MobileInfo.SubCellOffsets[fromSubCell]);
FinishedMoving(self);
}
@@ -235,7 +227,10 @@ namespace OpenRA.Mods.RA.Move
public void SetPosition(Actor self, WPos pos)
{
// TODO: Handle altitude
SetPxPosition(self, PPos.FromWPos(pos));
var cell = pos.ToCPos();
SetLocation(cell,fromSubCell, cell,fromSubCell);
PxPosition = PPos.FromWPos(pos);
FinishedMoving(self);
}
public void SetVisualPosition(Actor self, WPos pos)

View File

@@ -328,7 +328,7 @@ namespace OpenRA.Mods.RA.Move
void UpdateCenterLocation(Actor self, Mobile mobile)
{
mobile.AdjustPxPosition(self, PPos.FromWPos(WPos.Lerp(from, to, moveFraction, moveFractionTotal)));
mobile.SetVisualPosition(self, WPos.Lerp(from, to, moveFraction, moveFractionTotal));
if (moveFraction >= moveFractionTotal)
mobile.Facing = toFacing & 0xFF;