diff --git a/OpenRA.Game/Actor.cs b/OpenRA.Game/Actor.cs index e93c8cacca..bb0a5413ad 100755 --- a/OpenRA.Game/Actor.cs +++ b/OpenRA.Game/Actor.cs @@ -34,17 +34,8 @@ namespace OpenRA public IOccupySpace OccupiesSpace { get { return occupySpace.Value; } } public CPos Location { get { return occupySpace.Value.TopLeft; } } - - public PPos CenterLocation { get { return occupySpace.Value.PxPosition; } } - - public WPos CenterPosition - { - get - { - var altitude = occupySpace.Value != null ? occupySpace.Value.Altitude : 0; - return CenterLocation.ToWPos(altitude); - } - } + public PPos CenterLocation { get { return PPos.FromWPos(occupySpace.Value.CenterPosition); } } + public WPos CenterPosition { get { return occupySpace.Value.CenterPosition; } } public WRot Orientation { diff --git a/OpenRA.Game/Traits/TraitsInterfaces.cs b/OpenRA.Game/Traits/TraitsInterfaces.cs index 8ed42e5c67..8b0f1a404d 100755 --- a/OpenRA.Game/Traits/TraitsInterfaces.cs +++ b/OpenRA.Game/Traits/TraitsInterfaces.cs @@ -99,7 +99,6 @@ namespace OpenRA.Traits public interface IOccupySpace { - PPos PxPosition { get; } WPos CenterPosition { get; } CPos TopLeft { get; } IEnumerable> OccupiedCells(); @@ -143,9 +142,6 @@ namespace OpenRA.Traits { bool CanEnterCell(CPos location); 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); } diff --git a/OpenRA.Mods.RA/Activities/UnloadCargo.cs b/OpenRA.Mods.RA/Activities/UnloadCargo.cs index 946fd23dfd..1d5b7f328d 100644 --- a/OpenRA.Mods.RA/Activities/UnloadCargo.cs +++ b/OpenRA.Mods.RA/Activities/UnloadCargo.cs @@ -90,7 +90,7 @@ namespace OpenRA.Mods.RA.Activities var mobile = actor.Trait(); mobile.Facing = Util.GetFacing(exit - current, mobile.Facing ); mobile.SetPosition(actor, exitTile.Value); - mobile.AdjustPxPosition(actor, PPos.FromWPos(current)); + mobile.SetVisualPosition(actor, current); var speed = mobile.MovementSpeedForCell(actor, exitTile.Value); var length = speed > 0 ? (exit - current).Length / speed : 0; diff --git a/OpenRA.Mods.RA/Air/Aircraft.cs b/OpenRA.Mods.RA/Air/Aircraft.cs index 5e65b70eae..9a1ad6394c 100755 --- a/OpenRA.Mods.RA/Air/Aircraft.cs +++ b/OpenRA.Mods.RA/Air/Aircraft.cs @@ -101,16 +101,9 @@ namespace OpenRA.Mods.RA.Air 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) { // TODO: Handle altitude diff --git a/OpenRA.Mods.RA/Air/HeliFly.cs b/OpenRA.Mods.RA/Air/HeliFly.cs index 041edd6256..7a77667909 100755 --- a/OpenRA.Mods.RA/Air/HeliFly.cs +++ b/OpenRA.Mods.RA/Air/HeliFly.cs @@ -39,7 +39,7 @@ namespace OpenRA.Mods.RA.Air var moveDist = aircraft.MovementSpeed * 7 * 1024 / (Game.CellSize * 32); if (dist.HorizontalLengthSquared < moveDist*moveDist) { - aircraft.SubPxPosition = PPos.FromWPos(pos).ToPSubPos(); + aircraft.SetPosition(self, pos); return NextActivity; } diff --git a/OpenRA.Mods.RA/Air/Land.cs b/OpenRA.Mods.RA/Air/Land.cs index cedd99ebdb..36712ce1a4 100755 --- a/OpenRA.Mods.RA/Air/Land.cs +++ b/OpenRA.Mods.RA/Air/Land.cs @@ -35,7 +35,7 @@ namespace OpenRA.Mods.RA.Air var moveDist = aircraft.MovementSpeed * 7 * 1024 / (Game.CellSize * 32); if (d.HorizontalLengthSquared < moveDist*moveDist) { - aircraft.SetPxPosition(self, PPos.FromWPos(Target.CenterPosition)); + aircraft.SetPosition(self, Target.CenterPosition); return NextActivity; } diff --git a/OpenRA.Mods.RA/Crate.cs b/OpenRA.Mods.RA/Crate.cs index e45f56bfa4..db7de2a24b 100644 --- a/OpenRA.Mods.RA/Crate.cs +++ b/OpenRA.Mods.RA/Crate.cs @@ -89,13 +89,6 @@ namespace OpenRA.Mods.RA public PPos PxPosition { get; private 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 SetVisualPosition(Actor self, WPos pos) { SetPosition(self, pos.ToCPos()); } diff --git a/OpenRA.Mods.RA/Husk.cs b/OpenRA.Mods.RA/Husk.cs index c06a96e841..a399e3b7b2 100644 --- a/OpenRA.Mods.RA/Husk.cs +++ b/OpenRA.Mods.RA/Husk.cs @@ -25,9 +25,9 @@ namespace OpenRA.Mods.RA class Husk : IOccupySpace, IFacing, ISync { [Sync] CPos location; + [Sync] PPos PxPosition; 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/Move/Drag.cs b/OpenRA.Mods.RA/Move/Drag.cs index 154e963957..17eeb0d92e 100755 --- a/OpenRA.Mods.RA/Move/Drag.cs +++ b/OpenRA.Mods.RA/Move/Drag.cs @@ -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(); 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 GetTargets( Actor self ) + public override IEnumerable GetTargets(Actor self) { yield return Target.FromPos(end); } // Cannot be cancelled - public override void Cancel( Actor self ) { } + public override void Cancel(Actor self) { } } } diff --git a/OpenRA.Mods.RA/Move/Mobile.cs b/OpenRA.Mods.RA/Move/Mobile.cs index 6985f07c83..95d56dca94 100755 --- a/OpenRA.Mods.RA/Move/Mobile.cs +++ b/OpenRA.Mods.RA/Move/Mobile.cs @@ -205,7 +205,7 @@ namespace OpenRA.Mods.RA.Move if (init.Contains()) { this.__fromCell = this.__toCell = init.Get(); - this.PxPosition = PPos.FromWPos(fromCell.CenterPosition + MobileInfo.SubCellOffsets[fromSubCell]); + SetVisualPosition(self, fromCell.CenterPosition + MobileInfo.SubCellOffsets[fromSubCell]); } this.Facing = init.Contains() ? init.Get() : 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) diff --git a/OpenRA.Mods.RA/Move/Move.cs b/OpenRA.Mods.RA/Move/Move.cs index 744d2a7373..f8c972911c 100755 --- a/OpenRA.Mods.RA/Move/Move.cs +++ b/OpenRA.Mods.RA/Move/Move.cs @@ -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; diff --git a/OpenRA.Mods.RA/Production.cs b/OpenRA.Mods.RA/Production.cs index a87efdba94..ad6c8241e3 100755 --- a/OpenRA.Mods.RA/Production.cs +++ b/OpenRA.Mods.RA/Production.cs @@ -68,7 +68,7 @@ namespace OpenRA.Mods.RA // TODO: Move this into an *Init // TODO: We should be adjusting the actual position for aircraft, not just visuals. var teleportable = newUnit.Trait(); - teleportable.AdjustPxPosition(newUnit, PPos.FromWPos(spawn)); + teleportable.SetVisualPosition(newUnit, spawn); // TODO: Generalize this for non-mobile (e.g. aircraft) too // Remember to update the Enter activity too