diff --git a/OpenRA.Mods.Common/Activities/Air/Fly.cs b/OpenRA.Mods.Common/Activities/Air/Fly.cs index acdbb9a33d..3f752626d2 100644 --- a/OpenRA.Mods.Common/Activities/Air/Fly.cs +++ b/OpenRA.Mods.Common/Activities/Air/Fly.cs @@ -166,7 +166,7 @@ namespace OpenRA.Mods.Common.Activities return true; var checkTarget = useLastVisibleTarget ? lastVisibleTarget : target; - var pos = aircraft.GetPosition(); + var pos = self.CenterPosition; var delta = checkTarget.CenterPosition - pos; // Inside the target annulus, so we're done diff --git a/OpenRA.Mods.Common/Activities/Air/Land.cs b/OpenRA.Mods.Common/Activities/Air/Land.cs index ece6ed3fc8..6376396cb3 100644 --- a/OpenRA.Mods.Common/Activities/Air/Land.cs +++ b/OpenRA.Mods.Common/Activities/Air/Land.cs @@ -104,14 +104,15 @@ namespace OpenRA.Mods.Common.Activities return true; } - var pos = aircraft.GetPosition(); + var pos = self.CenterPosition; // Reevaluate target position in case the target has moved. targetPosition = target.CenterPosition + offset; landingCell = self.World.Map.CellContaining(targetPosition); // We are already at the landing location. - if ((targetPosition - pos).LengthSquared == 0) + var delta = pos - targetPosition; + if (delta.HorizontalLengthSquared == 0 && delta.Z == aircraft.LandAltitude.Length) return true; // Look for free landing cell @@ -132,7 +133,8 @@ namespace OpenRA.Mods.Common.Activities targetPosition = target.CenterPosition + offset; landingCell = self.World.Map.CellContaining(targetPosition); - if ((targetPosition - pos).LengthSquared == 0) + delta = pos - targetPosition; + if (delta.HorizontalLengthSquared == 0 && delta.Z == aircraft.LandAltitude.Length) return true; } } diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index 104b8c15b0..978fc02fd7 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -300,7 +300,7 @@ namespace OpenRA.Mods.Common.Traits return self.CenterPosition - new WVec(WDist.Zero, WDist.Zero, self.World.Map.DistanceAboveTerrain(self.CenterPosition)); } - public bool AtLandAltitude => self.World.Map.DistanceAboveTerrain(GetPosition()) == LandAltitude; + public bool AtLandAltitude => self.World.Map.DistanceAboveTerrain(self.CenterPosition) == LandAltitude; bool airborne; bool cruising; @@ -342,15 +342,6 @@ namespace OpenRA.Mods.Common.Traits } } - public WPos GetPosition() - { - var pos = self.CenterPosition; - foreach (var offset in positionOffsets) - pos += offset.PositionOffset; - - return pos; - } - public override IEnumerable GetVariableObservers() { foreach (var observer in base.GetVariableObservers()) diff --git a/OpenRA.Mods.Common/Traits/Carryall.cs b/OpenRA.Mods.Common/Traits/Carryall.cs index edbc7fc124..0694a7102a 100644 --- a/OpenRA.Mods.Common/Traits/Carryall.cs +++ b/OpenRA.Mods.Common/Traits/Carryall.cs @@ -309,8 +309,7 @@ namespace OpenRA.Mods.Common.Traits if (IsTraitDisabled) return false; - var targetCell = self.World.Map.CellContaining(aircraft.GetPosition()); - return Carryable != null && aircraft.CanLand(targetCell, blockedByMobile: false); + return Carryable != null && aircraft.CanLand(self.Location, blockedByMobile: false); } IEnumerable IIssueOrder.Orders