Remove *PxPosition from IOccupySpace/IPositionable.
This commit is contained in:
@@ -34,17 +34,8 @@ namespace OpenRA
|
|||||||
public IOccupySpace OccupiesSpace { get { return occupySpace.Value; } }
|
public IOccupySpace OccupiesSpace { get { return occupySpace.Value; } }
|
||||||
|
|
||||||
public CPos Location { get { return occupySpace.Value.TopLeft; } }
|
public CPos Location { get { return occupySpace.Value.TopLeft; } }
|
||||||
|
public PPos CenterLocation { get { return PPos.FromWPos(occupySpace.Value.CenterPosition); } }
|
||||||
public PPos CenterLocation { get { return occupySpace.Value.PxPosition; } }
|
public WPos CenterPosition { get { return occupySpace.Value.CenterPosition; } }
|
||||||
|
|
||||||
public WPos CenterPosition
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
var altitude = occupySpace.Value != null ? occupySpace.Value.Altitude : 0;
|
|
||||||
return CenterLocation.ToWPos(altitude);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public WRot Orientation
|
public WRot Orientation
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ namespace OpenRA.Traits
|
|||||||
|
|
||||||
public interface IOccupySpace
|
public interface IOccupySpace
|
||||||
{
|
{
|
||||||
PPos PxPosition { get; }
|
|
||||||
WPos CenterPosition { get; }
|
WPos CenterPosition { get; }
|
||||||
CPos TopLeft { get; }
|
CPos TopLeft { get; }
|
||||||
IEnumerable<Pair<CPos, SubCell>> OccupiedCells();
|
IEnumerable<Pair<CPos, SubCell>> OccupiedCells();
|
||||||
@@ -143,9 +142,6 @@ namespace OpenRA.Traits
|
|||||||
{
|
{
|
||||||
bool CanEnterCell(CPos location);
|
bool CanEnterCell(CPos location);
|
||||||
void SetPosition(Actor self, CPos cell);
|
void SetPosition(Actor self, CPos cell);
|
||||||
void SetPxPosition(Actor self, PPos px);
|
|
||||||
void AdjustPxPosition(Actor self, PPos px); /* works like SetPxPosition, but visual only */
|
|
||||||
|
|
||||||
void SetPosition(Actor self, WPos pos);
|
void SetPosition(Actor self, WPos pos);
|
||||||
void SetVisualPosition(Actor self, WPos pos);
|
void SetVisualPosition(Actor self, WPos pos);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA.Activities
|
|||||||
var mobile = actor.Trait<Mobile>();
|
var mobile = actor.Trait<Mobile>();
|
||||||
mobile.Facing = Util.GetFacing(exit - current, mobile.Facing );
|
mobile.Facing = Util.GetFacing(exit - current, mobile.Facing );
|
||||||
mobile.SetPosition(actor, exitTile.Value);
|
mobile.SetPosition(actor, exitTile.Value);
|
||||||
mobile.AdjustPxPosition(actor, PPos.FromWPos(current));
|
mobile.SetVisualPosition(actor, current);
|
||||||
var speed = mobile.MovementSpeedForCell(actor, exitTile.Value);
|
var speed = mobile.MovementSpeedForCell(actor, exitTile.Value);
|
||||||
var length = speed > 0 ? (exit - current).Length / speed : 0;
|
var length = speed > 0 ? (exit - current).Length / speed : 0;
|
||||||
|
|
||||||
|
|||||||
@@ -101,16 +101,9 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
|
|
||||||
public void SetPosition(Actor self, CPos cell)
|
public void SetPosition(Actor self, CPos cell)
|
||||||
{
|
{
|
||||||
SetPxPosition(self, Util.CenterOfCell(cell));
|
SubPxPosition = Util.CenterOfCell(cell).ToPSubPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetPxPosition(Actor self, PPos px)
|
|
||||||
{
|
|
||||||
SubPxPosition = px.ToPSubPos();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AdjustPxPosition(Actor self, PPos px) { SetPxPosition(self, px); }
|
|
||||||
|
|
||||||
public void SetPosition(Actor self, WPos pos)
|
public void SetPosition(Actor self, WPos pos)
|
||||||
{
|
{
|
||||||
// TODO: Handle altitude
|
// TODO: Handle altitude
|
||||||
|
|||||||
@@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
var moveDist = aircraft.MovementSpeed * 7 * 1024 / (Game.CellSize * 32);
|
var moveDist = aircraft.MovementSpeed * 7 * 1024 / (Game.CellSize * 32);
|
||||||
if (dist.HorizontalLengthSquared < moveDist*moveDist)
|
if (dist.HorizontalLengthSquared < moveDist*moveDist)
|
||||||
{
|
{
|
||||||
aircraft.SubPxPosition = PPos.FromWPos(pos).ToPSubPos();
|
aircraft.SetPosition(self, pos);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA.Air
|
|||||||
var moveDist = aircraft.MovementSpeed * 7 * 1024 / (Game.CellSize * 32);
|
var moveDist = aircraft.MovementSpeed * 7 * 1024 / (Game.CellSize * 32);
|
||||||
if (d.HorizontalLengthSquared < moveDist*moveDist)
|
if (d.HorizontalLengthSquared < moveDist*moveDist)
|
||||||
{
|
{
|
||||||
aircraft.SetPxPosition(self, PPos.FromWPos(Target.CenterPosition));
|
aircraft.SetPosition(self, Target.CenterPosition);
|
||||||
return NextActivity;
|
return NextActivity;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,13 +89,6 @@ namespace OpenRA.Mods.RA
|
|||||||
public PPos PxPosition { get; private set; }
|
public PPos PxPosition { get; private set; }
|
||||||
public int Altitude { get { return 0; } set { } }
|
public int Altitude { get { return 0; } set { } }
|
||||||
|
|
||||||
public void SetPxPosition(Actor self, PPos px)
|
|
||||||
{
|
|
||||||
SetPosition(self, px.ToCPos());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void AdjustPxPosition(Actor self, PPos px) { SetPxPosition(self, px); }
|
|
||||||
|
|
||||||
public void SetPosition(Actor self, WPos pos) { SetPosition(self, pos.ToCPos()); }
|
public void SetPosition(Actor self, WPos pos) { SetPosition(self, pos.ToCPos()); }
|
||||||
public void SetVisualPosition(Actor self, WPos pos) { SetPosition(self, pos.ToCPos()); }
|
public void SetVisualPosition(Actor self, WPos pos) { SetPosition(self, pos.ToCPos()); }
|
||||||
|
|
||||||
|
|||||||
@@ -25,9 +25,9 @@ namespace OpenRA.Mods.RA
|
|||||||
class Husk : IOccupySpace, IFacing, ISync
|
class Husk : IOccupySpace, IFacing, ISync
|
||||||
{
|
{
|
||||||
[Sync] CPos location;
|
[Sync] CPos location;
|
||||||
|
[Sync] PPos PxPosition;
|
||||||
|
|
||||||
public WPos CenterPosition { get { return PxPosition.ToWPos(0); } }
|
public WPos CenterPosition { get { return PxPosition.ToWPos(0); } }
|
||||||
[Sync] public PPos PxPosition { get; private set; }
|
|
||||||
public int Altitude { get { return 0; } set { } }
|
public int Altitude { get { return 0; } set { } }
|
||||||
|
|
||||||
[Sync] public int Facing { get; set; }
|
[Sync] public int Facing { get; set; }
|
||||||
|
|||||||
@@ -26,14 +26,14 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
this.length = length;
|
this.length = length;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override Activity Tick( Actor self )
|
public override Activity Tick(Actor self)
|
||||||
{
|
{
|
||||||
var mobile = self.Trait<Mobile>();
|
var mobile = self.Trait<Mobile>();
|
||||||
var pos = length > 1
|
var pos = length > 1
|
||||||
? WPos.Lerp(start, end, ticks, length - 1)
|
? WPos.Lerp(start, end, ticks, length - 1)
|
||||||
: end;
|
: end;
|
||||||
|
|
||||||
mobile.AdjustPxPosition(self, PPos.FromWPos(pos));
|
mobile.SetVisualPosition(self, pos);
|
||||||
if (++ticks >= length)
|
if (++ticks >= length)
|
||||||
{
|
{
|
||||||
mobile.IsMoving = false;
|
mobile.IsMoving = false;
|
||||||
@@ -44,12 +44,12 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override IEnumerable<Target> GetTargets( Actor self )
|
public override IEnumerable<Target> GetTargets(Actor self)
|
||||||
{
|
{
|
||||||
yield return Target.FromPos(end);
|
yield return Target.FromPos(end);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Cannot be cancelled
|
// Cannot be cancelled
|
||||||
public override void Cancel( Actor self ) { }
|
public override void Cancel(Actor self) { }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,7 +205,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
if (init.Contains<LocationInit>())
|
if (init.Contains<LocationInit>())
|
||||||
{
|
{
|
||||||
this.__fromCell = this.__toCell = init.Get<LocationInit, CPos>();
|
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;
|
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)
|
public void SetPosition(Actor self, CPos cell)
|
||||||
{
|
{
|
||||||
SetLocation(cell,fromSubCell, cell,fromSubCell);
|
SetLocation(cell,fromSubCell, cell,fromSubCell);
|
||||||
PxPosition = PPos.FromWPos(fromCell.CenterPosition + MobileInfo.SubCellOffsets[fromSubCell]);
|
SetVisualPosition(self, 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;
|
|
||||||
FinishedMoving(self);
|
FinishedMoving(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +227,10 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
public void SetPosition(Actor self, WPos pos)
|
public void SetPosition(Actor self, WPos pos)
|
||||||
{
|
{
|
||||||
// TODO: Handle altitude
|
// 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)
|
public void SetVisualPosition(Actor self, WPos pos)
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ namespace OpenRA.Mods.RA.Move
|
|||||||
|
|
||||||
void UpdateCenterLocation(Actor self, Mobile mobile)
|
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)
|
if (moveFraction >= moveFractionTotal)
|
||||||
mobile.Facing = toFacing & 0xFF;
|
mobile.Facing = toFacing & 0xFF;
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA
|
|||||||
// TODO: Move this into an *Init
|
// TODO: Move this into an *Init
|
||||||
// TODO: We should be adjusting the actual position for aircraft, not just visuals.
|
// TODO: We should be adjusting the actual position for aircraft, not just visuals.
|
||||||
var teleportable = newUnit.Trait<IPositionable>();
|
var teleportable = newUnit.Trait<IPositionable>();
|
||||||
teleportable.AdjustPxPosition(newUnit, PPos.FromWPos(spawn));
|
teleportable.SetVisualPosition(newUnit, spawn);
|
||||||
|
|
||||||
// TODO: Generalize this for non-mobile (e.g. aircraft) too
|
// TODO: Generalize this for non-mobile (e.g. aircraft) too
|
||||||
// Remember to update the Enter activity too
|
// Remember to update the Enter activity too
|
||||||
|
|||||||
Reference in New Issue
Block a user