Add world coord overloads to IOccupySpace and IPositionable.
This commit is contained in:
@@ -100,6 +100,7 @@ namespace OpenRA.Traits
|
||||
public interface IOccupySpace
|
||||
{
|
||||
PPos PxPosition { get; }
|
||||
WPos CenterPosition { get; }
|
||||
CPos TopLeft { get; }
|
||||
IEnumerable<Pair<CPos, SubCell>> OccupiedCells();
|
||||
|
||||
@@ -144,6 +145,9 @@ namespace OpenRA.Traits
|
||||
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 SetVisualPosition(Actor self, WPos pos);
|
||||
}
|
||||
|
||||
public interface INotifyBlockingMove { void OnNotifyBlockingMove(Actor self, Actor blocking); }
|
||||
|
||||
@@ -30,6 +30,7 @@ namespace OpenRA.Traits
|
||||
public CPos TopLeft { get { return location; } }
|
||||
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield break; }
|
||||
public WPos CenterPosition { get { return location.CenterPosition; } }
|
||||
public PPos PxPosition { get { return Util.CenterOfCell(location); } }
|
||||
public int Altitude { get { return 0; } set { } }
|
||||
}
|
||||
|
||||
@@ -54,11 +54,12 @@ namespace OpenRA.Mods.RA.Air
|
||||
UnReserve();
|
||||
}
|
||||
|
||||
|
||||
protected readonly Actor self;
|
||||
[Sync] public int Facing { get; set; }
|
||||
[Sync] public int Altitude { get; set; }
|
||||
[Sync] public PSubPos SubPxPosition;
|
||||
|
||||
public WPos CenterPosition { get { return PxPosition.ToWPos(Altitude); } }
|
||||
public PPos PxPosition { get { return SubPxPosition.ToPPos(); } }
|
||||
public CPos TopLeft { get { return PxPosition.ToCPos(); } }
|
||||
|
||||
@@ -110,6 +111,14 @@ namespace OpenRA.Mods.RA.Air
|
||||
|
||||
public void AdjustPxPosition(Actor self, PPos px) { SetPxPosition(self, px); }
|
||||
|
||||
public void SetPosition(Actor self, WPos pos)
|
||||
{
|
||||
// TODO: Handle altitude
|
||||
SubPxPosition = PPos.FromWPos(pos).ToPSubPos();
|
||||
}
|
||||
|
||||
public void SetVisualPosition(Actor self, WPos pos) { SetPosition(self, pos); }
|
||||
|
||||
public bool AircraftCanEnter(Actor a)
|
||||
{
|
||||
if (self.AppearsHostileTo(a)) return false;
|
||||
|
||||
@@ -110,6 +110,7 @@ namespace OpenRA.Mods.RA.Buildings
|
||||
public void Unlock() { Locked = false; }
|
||||
|
||||
public CPos TopLeft { get { return topLeft; } }
|
||||
public WPos CenterPosition { get { return PxPosition.ToWPos(0); } }
|
||||
public PPos PxPosition { get { return pxPosition; } }
|
||||
public int Altitude { get { return 0; } set { } }
|
||||
|
||||
|
||||
@@ -85,16 +85,20 @@ namespace OpenRA.Mods.RA
|
||||
public CPos TopLeft { get { return Location; } }
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield return Pair.New( Location, SubCell.FullCell); }
|
||||
|
||||
public WPos CenterPosition { get { return PxPosition.ToWPos(Altitude); } }
|
||||
public PPos PxPosition { get; private set; }
|
||||
public int Altitude { get { return 0; } set { } }
|
||||
|
||||
public void SetPxPosition(Actor self, PPos px)
|
||||
{
|
||||
SetPosition( self, px.ToCPos() );
|
||||
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 SetVisualPosition(Actor self, WPos pos) { SetPosition(self, pos.ToCPos()); }
|
||||
|
||||
public bool CanEnterCell(CPos cell)
|
||||
{
|
||||
if (!self.World.Map.IsInMap(cell.X, cell.Y)) return false;
|
||||
|
||||
@@ -26,7 +26,8 @@ namespace OpenRA.Mods.RA
|
||||
{
|
||||
[Sync] CPos location;
|
||||
|
||||
[Sync] public PPos PxPosition { get; set; }
|
||||
public WPos CenterPosition { get { return PxPosition.ToWPos(0); } }
|
||||
[Sync] public PPos PxPosition { get; private set; }
|
||||
public int Altitude { get { return 0; } set { } }
|
||||
|
||||
[Sync] public int Facing { get; set; }
|
||||
|
||||
@@ -61,6 +61,7 @@ namespace OpenRA.Mods.RA
|
||||
public CPos TopLeft { get { return location; } }
|
||||
|
||||
public IEnumerable<Pair<CPos, SubCell>> OccupiedCells() { yield return Pair.New(TopLeft, SubCell.FullCell); }
|
||||
public WPos CenterPosition { get { return PxPosition.ToWPos(0); } }
|
||||
public PPos PxPosition { get { return Util.CenterOfCell( location ); } }
|
||||
public int Altitude { get { return 0; } set { } }
|
||||
}
|
||||
|
||||
@@ -167,6 +167,7 @@ namespace OpenRA.Mods.RA.Move
|
||||
|
||||
public int ROT { get { return Info.ROT; } }
|
||||
|
||||
public WPos CenterPosition { get { return PxPosition.ToWPos(Altitude); } }
|
||||
[Sync] public PPos PxPosition { get; private set; }
|
||||
[Sync] public CPos fromCell { get { return __fromCell; } }
|
||||
[Sync] public CPos toCell { get { return __toCell; } }
|
||||
@@ -231,6 +232,18 @@ namespace OpenRA.Mods.RA.Move
|
||||
PxPosition = px;
|
||||
}
|
||||
|
||||
public void SetPosition(Actor self, WPos pos)
|
||||
{
|
||||
// TODO: Handle altitude
|
||||
SetPxPosition(self, PPos.FromWPos(pos));
|
||||
}
|
||||
|
||||
public void SetVisualPosition(Actor self, WPos pos)
|
||||
{
|
||||
// TODO: Handle altitude
|
||||
AdjustPxPosition(self, PPos.FromWPos(pos));
|
||||
}
|
||||
|
||||
public IEnumerable<IOrderTargeter> Orders { get { yield return new MoveOrderTargeter(Info); } }
|
||||
|
||||
// Note: Returns a valid order even if the unit can't move to the target
|
||||
|
||||
Reference in New Issue
Block a user