From 83564ecc60e6a76ec342372818bc06429f6135cf Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 8 Dec 2016 18:33:55 +0000 Subject: [PATCH] Nudge aircraft back inside the map. --- OpenRA.Mods.Common/Traits/Air/Aircraft.cs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs index c43946e7f8..e946af5f72 100644 --- a/OpenRA.Mods.Common/Traits/Air/Aircraft.cs +++ b/OpenRA.Mods.Common/Traits/Air/Aircraft.cs @@ -228,6 +228,15 @@ namespace OpenRA.Mods.Common.Traits repulsionForce += GetRepulsionForce(actor); } + // Actors outside the map bounds receive an extra nudge towards the center of the map + if (!self.World.Map.Contains(self.Location)) + { + // The map bounds are in projected coordinates, which is technically wrong for this, + // but we avoid the issues in practice by guessing the middle of the map instead of the edge + var center = WPos.Lerp(self.World.Map.ProjectedTopLeft, self.World.Map.ProjectedBottomRight, 1, 2); + repulsionForce += new WVec(1024, 0, 0).Rotate(WRot.FromYaw((self.CenterPosition - center).Yaw)); + } + if (Info.CanHover) return repulsionForce;