diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 4d37136723..8ed42e5c67 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -100,6 +100,7 @@ namespace OpenRA.Traits public interface IOccupySpace { PPos PxPosition { get; } + WPos CenterPosition { get; } CPos TopLeft { get; } IEnumerable> 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); } diff --git a/OpenRA.Game/Traits/Waypoint.cs b/OpenRA.Game/Traits/Waypoint.cs index d60b8079cd..0223fa9fda 100644 --- a/OpenRA.Game/Traits/Waypoint.cs +++ b/OpenRA.Game/Traits/Waypoint.cs @@ -30,6 +30,7 @@ namespace OpenRA.Traits public CPos TopLeft { get { return location; } } public IEnumerable> 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 { } } } diff --git a/OpenRA.Mods.RA/Air/Aircraft.cs b/OpenRA.Mods.RA/Air/Aircraft.cs index 74ed1da009..5e65b70eae 100755 --- a/OpenRA.Mods.RA/Air/Aircraft.cs +++ b/OpenRA.Mods.RA/Air/Aircraft.cs @@ -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; diff --git a/OpenRA.Mods.RA/Buildings/Building.cs b/OpenRA.Mods.RA/Buildings/Building.cs index 3beb58e7f6..114809e683 100755 --- a/OpenRA.Mods.RA/Buildings/Building.cs +++ b/OpenRA.Mods.RA/Buildings/Building.cs @@ -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 { } } diff --git a/OpenRA.Mods.RA/Crate.cs b/OpenRA.Mods.RA/Crate.cs index fde9751988..e45f56bfa4 100644 --- a/OpenRA.Mods.RA/Crate.cs +++ b/OpenRA.Mods.RA/Crate.cs @@ -85,16 +85,20 @@ namespace OpenRA.Mods.RA public CPos TopLeft { get { return Location; } } public IEnumerable> 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; diff --git a/OpenRA.Mods.RA/Husk.cs b/OpenRA.Mods.RA/Husk.cs index 9da6ce0153..c06a96e841 100644 --- a/OpenRA.Mods.RA/Husk.cs +++ b/OpenRA.Mods.RA/Husk.cs @@ -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; } diff --git a/OpenRA.Mods.RA/Mine.cs b/OpenRA.Mods.RA/Mine.cs index c2589b877e..9b34282c07 100644 --- a/OpenRA.Mods.RA/Mine.cs +++ b/OpenRA.Mods.RA/Mine.cs @@ -61,6 +61,7 @@ namespace OpenRA.Mods.RA public CPos TopLeft { get { return location; } } public IEnumerable> 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 { } } } diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index 3d36a3816f..6985f07c83 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -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 Orders { get { yield return new MoveOrderTargeter(Info); } } // Note: Returns a valid order even if the unit can't move to the target