From 81bcff0f8a749fe01f9a83d11508c150b79e90a7 Mon Sep 17 00:00:00 2001 From: Moritz Heller Date: Thu, 18 Jul 2024 13:24:17 +0200 Subject: [PATCH] Fix movement on ramps when moving to subcell Fix movement on ramps when moving to subcell --- OpenRA.Mods.Common/Activities/Move/Move.cs | 8 +++++++- OpenRA.Mods.Common/Traits/Mobile.cs | 6 ++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/OpenRA.Mods.Common/Activities/Move/Move.cs b/OpenRA.Mods.Common/Activities/Move/Move.cs index 86c72b4504..d19e461baf 100644 --- a/OpenRA.Mods.Common/Activities/Move/Move.cs +++ b/OpenRA.Mods.Common/Activities/Move/Move.cs @@ -451,7 +451,13 @@ namespace OpenRA.Mods.Common.Activities if (progress >= Distance) { - mobile.SetCenterPosition(self, To); + var toPos = To; + + // apply ramp offset to ground units + if (MovingOnGroundLayer) + toPos -= new WVec(WDist.Zero, WDist.Zero, self.World.Map.DistanceAboveTerrain(toPos)); + mobile.SetCenterPosition(self, toPos); + mobile.Facing = TurnsWhileMoving ? Util.TickFacing(mobile.Facing, ToFacing, mobile.TurnSpeed) : ToFacing; diff --git a/OpenRA.Mods.Common/Traits/Mobile.cs b/OpenRA.Mods.Common/Traits/Mobile.cs index bca9fa82a9..68a1b3e809 100644 --- a/OpenRA.Mods.Common/Traits/Mobile.cs +++ b/OpenRA.Mods.Common/Traits/Mobile.cs @@ -471,8 +471,10 @@ namespace OpenRA.Mods.Common.Traits var position = cell.Layer == 0 ? self.World.Map.CenterOfCell(cell) : self.World.GetCustomMovementLayers()[cell.Layer].CenterOfCell(cell); - var subcellOffset = self.World.Map.Grid.OffsetOfSubCell(subCell); - SetCenterPosition(self, position + subcellOffset); + position += self.World.Map.Grid.OffsetOfSubCell(subCell); + position -= new WVec(0, 0, self.World.Map.DistanceAboveTerrain(position).Length); + + SetCenterPosition(self, position); FinishedMoving(self); }