From ae4c9d4a8f3584043ba96b95e67c8e2d350ec6aa Mon Sep 17 00:00:00 2001 From: Vigers Ray Date: Mon, 18 Aug 2025 19:06:38 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D0=BA=D1=80=D0=B0?= =?UTF-8?q?=D1=88=D0=B0=20=D0=BB=D0=BE=D0=BA=D0=B0=D0=BB=D0=BA=D0=B8=20?= =?UTF-8?q?=D0=B8=D0=B7-=D0=B7=D0=B0=20=D0=B0=D0=B2=D1=82=D0=BE=D0=B4?= =?UTF-8?q?=D0=BE=D0=BA=20=D1=81=D0=B8=D1=81=D1=82=D0=B5=D0=BC=D1=8B.=20?= =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D0=BD=D0=B0=D0=BB=D0=BE=D0=B6=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D1=8F=20=D0=B3=D1=80=D0=B8=D0=B4=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=D1=81=D0=BF=D0=B0=D0=B2=D0=BD=D0=B5.=20?= =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81=20=D1=81=D1=82=D1=8B=D0=BA=D0=BE=D0=B2?= =?UTF-8?q?=D0=BA=D0=B8=20=D0=BD=D0=B5=D1=81=D0=BA=D0=BE=D0=BB=D1=8C=D0=BA?= =?UTF-8?q?=D0=BE=D1=85=20=D0=B3=D1=80=D0=B8=D0=B4=D0=BE=D0=B2=20=D0=BD?= =?UTF-8?q?=D0=B0=20=D0=BE=D0=B4=D0=B8=D0=BD=20=D0=B4=D0=BE=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Shuttles/Systems/DockingSystem.cs | 15 +++++- .../Systems/ShuttleSystem.FasterThanLight.cs | 2 +- .../_Sunrise/GridDock/GridDockSystem.cs | 47 +++++++++++-------- 3 files changed, 41 insertions(+), 23 deletions(-) diff --git a/Content.Server/Shuttles/Systems/DockingSystem.cs b/Content.Server/Shuttles/Systems/DockingSystem.cs index 76c0032dca..125d3b5883 100644 --- a/Content.Server/Shuttles/Systems/DockingSystem.cs +++ b/Content.Server/Shuttles/Systems/DockingSystem.cs @@ -292,8 +292,19 @@ namespace Content.Server.Shuttles.Systems // Pre-existing joint so use that. if (dockA.Comp.DockJointId != null) { - DebugTools.Assert(dockB.Comp.DockJointId == dockA.Comp.DockJointId); - joint = _jointSystem.GetOrCreateWeldJoint(gridA, gridB, dockA.Comp.DockJointId); + // Sunrise-Start + if (dockB.Comp.DockJointId != dockA.Comp.DockJointId) + { + Log.Error($"DockJointId mismatch: {dockAUid}({dockA.Comp.DockJointId}) <-> {dockBUid}({dockB.Comp.DockJointId}), recreating joint."); + dockA.Comp.DockJointId = null; + dockB.Comp.DockJointId = null; + joint = _jointSystem.GetOrCreateWeldJoint(gridA, gridB, DockingJoint + dockAUid); + } + else + { + joint = _jointSystem.GetOrCreateWeldJoint(gridA, gridB, dockA.Comp.DockJointId); + } + // Sunrise-End } else { diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index a1c9ed5538..a962612bf0 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -866,7 +866,7 @@ public sealed partial class ShuttleSystem /// /// Min offset for the final FTL. /// Max offset for the final FTL from the box we spawn. - private bool TryGetFTLProximity( + public bool TryGetFTLProximity( // Sunrise-Edit EntityUid shuttleUid, EntityCoordinates targetCoordinates, out EntityCoordinates coordinates, out Angle angle, diff --git a/Content.Server/_Sunrise/GridDock/GridDockSystem.cs b/Content.Server/_Sunrise/GridDock/GridDockSystem.cs index 85e145ee5e..8f6dc583a0 100644 --- a/Content.Server/_Sunrise/GridDock/GridDockSystem.cs +++ b/Content.Server/_Sunrise/GridDock/GridDockSystem.cs @@ -6,8 +6,9 @@ using Content.Server.Shuttles.Systems; using Content.Server.Station.Events; using Content.Server.Station.Systems; using Content.Shared.Station.Components; -using Robust.Server.GameObjects; using Robust.Shared.EntitySerialization.Systems; +using Robust.Shared.Map; +using Robust.Shared.Map.Components; namespace Content.Server._Sunrise.GridDock; @@ -17,7 +18,7 @@ public sealed class GridDockSystem : EntitySystem [Dependency] private readonly ShuttleSystem _shuttles = default!; [Dependency] private readonly StationSystem _station = default!; [Dependency] private readonly DockingSystem _dockSystem = default!; - [Dependency] private readonly MapSystem _mapSystem = default!; + [Dependency] private readonly SharedTransformSystem _transform = default!; public override void Initialize() { @@ -43,20 +44,23 @@ public sealed class GridDockSystem : EntitySystem return; } - var baseOffset = new Vector2(0, 0); - var offsetStep = new Vector2(100, 100); + var index = 0f; var usedGridDocks = new HashSet(); - var currentOffset = baseOffset; foreach (var entry in component.Grids) { if (!_loader.TryLoadGrid(xformMap.MapID, entry.GridPath, - out var rootUid, - offset: currentOffset)) - { - currentOffset += offsetStep; + out var rootUid)) continue; - } + + var grid = Comp(rootUid.Value.Owner); + var width = grid.LocalAABB.Width; + var shuttleCenter = grid.LocalAABB.Center; + + var coordinates = new EntityCoordinates(ftlMap, new Vector2(index + width / 2f, 0f) - shuttleCenter); + _transform.SetCoordinates(rootUid.Value.Owner, coordinates); + + index += width + 5f; if (!TryComp(rootUid.Value.Owner, out var shuttleComp)) continue; @@ -69,6 +73,8 @@ public sealed class GridDockSystem : EntitySystem int maxNewDocks = 0; foreach (var cfg in configs) { + if (cfg.Docks.Any(pair => usedGridDocks.Contains(pair.DockBUid))) + continue; var newDocks = cfg.Docks.Count(pair => !usedGridDocks.Contains(pair.DockBUid)); if (newDocks > maxNewDocks) { @@ -77,7 +83,7 @@ public sealed class GridDockSystem : EntitySystem } } - if (chosenConfig != null && chosenConfig.Docks.All(pair => !usedGridDocks.Contains(pair.DockBUid))) + if (chosenConfig != null) { foreach (var pair in chosenConfig.Docks) { @@ -88,21 +94,22 @@ public sealed class GridDockSystem : EntitySystem rootUid.Value.Owner, shuttleComp, chosenConfig, - 5f, + 0f, 30f, priorityTag: entry.PriorityTag, ignored: false); } else { - _shuttles.FTLToDock( - rootUid.Value.Owner, - shuttleComp, - target.Value, - 5f, - 30f, - priorityTag: entry.PriorityTag, - ignored: false); + if (_shuttles.TryGetFTLProximity(rootUid.Value.Owner, new EntityCoordinates(target.Value, Vector2.Zero), out var coords, out var targAngle)) + { + _shuttles.FTLToCoordinates(rootUid.Value.Owner, + shuttleComp, + coords, + targAngle, + 0f, + 30f); + } } } }