From 52a9f9b576f5f75f4ad40c2b824b52bddf1e8825 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Tue, 14 Oct 2025 18:58:55 -0400 Subject: [PATCH] FTL Fixes (#39040) * FTL fixes * one. space. * change this too --- .../Systems/ShuttleSystem.FasterThanLight.cs | 24 ++++++++----------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index a63359077f..4ca0b53035 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -801,11 +801,7 @@ public sealed partial class ShuttleSystem while (iteration < FTLProximityIterations) { grids.Clear(); - // We pass in an expanded offset here so we can safely do a random offset later. - // We don't include this in the actual targetAABB because then we would be double-expanding it. - // Once in this loop, then again when placing the shuttle later. - // Note that targetAABB already has expansionAmount factored in already. - _mapManager.FindGridsIntersecting(mapId, targetAABB.Enlarged(maxOffset), ref grids); + _mapManager.FindGridsIntersecting(mapId, targetAABB, ref grids); foreach (var grid in grids) { @@ -838,6 +834,10 @@ public sealed partial class ShuttleSystem if (nearbyGrids.Contains(uid)) continue; + // We pass in an expanded offset here so we can safely do a random offset later. + // We don't include this in the actual targetAABB because then we would be double-expanding it. + // Once in this loop, then again when placing the shuttle later. + // Note that targetAABB already has expansionAmount factored in already. targetAABB = targetAABB.Union( _transform.GetWorldMatrix(uid) .TransformBox(Comp(uid).LocalAABB.Enlarged(expansionAmount))); @@ -857,7 +857,7 @@ public sealed partial class ShuttleSystem // TODO: This should prefer the position's angle instead. // TODO: This is pretty crude for multiple landings. - if (nearbyGrids.Count > 1 || !HasComp(targetXform.GridUid)) + if (nearbyGrids.Count >= 1) { // Pick a random angle var offsetAngle = _random.NextAngle(); @@ -866,13 +866,9 @@ public sealed partial class ShuttleSystem var minRadius = MathF.Max(targetAABB.Width / 2f, targetAABB.Height / 2f); spawnPos = targetAABB.Center + offsetAngle.RotateVec(new Vector2(_random.NextFloat(minRadius + minOffset, minRadius + maxOffset), 0f)); } - else if (shuttleBody != null) - { - (spawnPos, angle) = _transform.GetWorldPositionRotation(targetXform); - } else { - spawnPos = _transform.GetWorldPosition(targetXform); + spawnPos = _transform.ToWorldPosition(targetCoordinates); } var offset = Vector2.Zero; @@ -893,10 +889,10 @@ public sealed partial class ShuttleSystem } // Rotate our localcenter around so we spawn exactly where we "think" we should (center of grid on the dot). - var transform = new Transform(spawnPos, angle); - spawnPos = Robust.Shared.Physics.Transform.Mul(transform, offset); + var transform = new Transform(_transform.ToWorldPosition(xform.Coordinates), angle); + var adjustedOffset = Robust.Shared.Physics.Transform.Mul(transform, offset); - coordinates = new EntityCoordinates(targetXform.MapUid.Value, spawnPos - offset); + coordinates = new EntityCoordinates(targetXform.MapUid.Value, spawnPos + adjustedOffset); return true; } -- 2.51.2