From a4f0a4ebfa99d37a96b2eabf0cee7a33beaf616d Mon Sep 17 00:00:00 2001 From: Whatstone Date: Wed, 22 Jan 2025 11:36:40 -0500 Subject: [PATCH 1/3] DockingSystem: check dockTypes in FTLDock --- .../Shuttles/Systems/DockingSystem.Shuttle.cs | 38 ++++++++++++++++--- .../Systems/ShuttleSystem.FasterThanLight.cs | 10 +++-- 2 files changed, 39 insertions(+), 9 deletions(-) diff --git a/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs b/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs index aabfaa31dd8..ad5f0441a3c 100644 --- a/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs +++ b/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs @@ -1,6 +1,7 @@ using System.Linq; using System.Numerics; using Content.Server.Shuttles.Components; +using Content.Shared.Shuttles.Components; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Physics; @@ -62,6 +63,11 @@ private bool CanDock( return false; } + // Frontier: check dock types + if (shuttleDock.DockType & gridDock.DockType == DockType.None) + return false; + // End Frontier + // First, get the station dock's position relative to the shuttle, this is where we rotate it around var stationDockPos = shuttleDockXform.LocalPosition + shuttleDockXform.LocalRotation.RotateVec(new Vector2(0f, -1f)); @@ -111,12 +117,12 @@ private bool CanDock( /// Tries to get a valid docking configuration for the shuttle to the target grid. /// /// Priority docking tag to prefer, e.g. for emergency shuttle - public DockingConfig? GetDockingConfig(EntityUid shuttleUid, EntityUid targetGrid, string? priorityTag = null) + public DockingConfig? GetDockingConfig(EntityUid shuttleUid, EntityUid targetGrid, string? priorityTag = null, DockType dockType = DockType.Airlock) // Frontier: add dockType { var gridDocks = GetDocks(targetGrid); var shuttleDocks = GetDocks(shuttleUid); - return GetDockingConfigPrivate(shuttleUid, targetGrid, shuttleDocks, gridDocks, priorityTag); + return GetDockingConfigPrivate(shuttleUid, targetGrid, shuttleDocks, gridDocks, priorityTag, dockType); // Frontier: add dockType } /// @@ -150,7 +156,8 @@ private List GetDockingConfigs( EntityUid shuttleUid, EntityUid targetGrid, List> shuttleDocks, - List> gridDocks) + List> gridDocks, + DockType dockType) // Frontier: add dockType { var validDockConfigs = new List(); @@ -173,10 +180,20 @@ private List GetDockingConfigs( { var shuttleDockXform = _xformQuery.GetComponent(dockUid); + // Frontier: skip docks that don't match type + if ((shuttleDock.DockType & dockType) == DockType.None) + continue; + // End Frontier + foreach (var (gridDockUid, gridDock) in gridDocks) { var gridXform = _xformQuery.GetComponent(gridDockUid); + // Frontier: skip docks that don't match type + if ((gridDock.DockType & dockType) == DockType.None) + continue; + // End Frontier + if (!CanDock( shuttleDock, shuttleDockXform, gridDock, gridXform, @@ -223,11 +240,21 @@ private List GetDockingConfigs( if (other == shuttleDock) continue; + // Frontier: skip docks that don't match type + if ((other.DockType & dockType) == DockType.None) + continue; + // End Frontier + foreach (var (otherGridUid, otherGrid) in gridDocks) { if (otherGrid == gridDock) continue; + // Frontier: skip docks that don't match type + if ((otherGrid.DockType & dockType) == DockType.None) + continue; + // End Frontier + if (!CanDock( other, _xformQuery.GetComponent(otherUid), @@ -277,9 +304,10 @@ private List GetDockingConfigs( EntityUid targetGrid, List> shuttleDocks, List> gridDocks, - string? priorityTag = null) + string? priorityTag = null, + DockType dockType = DockType.Airlock) // Frontier { - var validDockConfigs = GetDockingConfigs(shuttleUid, targetGrid, shuttleDocks, gridDocks); + var validDockConfigs = GetDockingConfigs(shuttleUid, targetGrid, shuttleDocks, gridDocks, dockType); // Frontier: add dockType if (validDockConfigs.Count <= 0) return null; diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index 2d7a64cf9e3..bcfc62f39e9 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -712,9 +712,10 @@ public bool TryFTLDock( EntityUid shuttleUid, ShuttleComponent component, EntityUid targetUid, - string? priorityTag = null) + string? priorityTag = null, + DockType dockType = DockType.Airlock) // Frontier { - return TryFTLDock(shuttleUid, component, targetUid, out _, priorityTag); + return TryFTLDock(shuttleUid, component, targetUid, out _, priorityTag, dockType); } /// @@ -726,7 +727,8 @@ public bool TryFTLDock( ShuttleComponent component, EntityUid targetUid, [NotNullWhen(true)] out DockingConfig? config, - string? priorityTag = null) + string? priorityTag = null, + DockType dockType = DockType.Airlock) // Frontier { config = null; @@ -738,7 +740,7 @@ public bool TryFTLDock( return false; } - config = _dockSystem.GetDockingConfig(shuttleUid, targetUid, priorityTag); + config = _dockSystem.GetDockingConfig(shuttleUid, targetUid, priorityTag, dockType); if (config != null) { From af3ea665199703e24803639ae4eb42681de9c963 Mon Sep 17 00:00:00 2001 From: Whatstone Date: Wed, 22 Jan 2025 11:47:40 -0500 Subject: [PATCH 2/3] A few missing dock type uses --- Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs b/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs index ad5f0441a3c..f8184a4bb36 100644 --- a/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs +++ b/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs @@ -64,7 +64,7 @@ private bool CanDock( } // Frontier: check dock types - if (shuttleDock.DockType & gridDock.DockType == DockType.None) + if ((shuttleDock.DockType & gridDock.DockType) == DockType.None) return false; // End Frontier @@ -131,12 +131,13 @@ private bool CanDock( public DockingConfig? GetDockingConfigAt(EntityUid shuttleUid, EntityUid targetGrid, EntityCoordinates coordinates, - Angle angle) + Angle angle, + DockType dockType = DockType.Airlock) // Frontier { var gridDocks = GetDocks(targetGrid); var shuttleDocks = GetDocks(shuttleUid); - var configs = GetDockingConfigs(shuttleUid, targetGrid, shuttleDocks, gridDocks); + var configs = GetDockingConfigs(shuttleUid, targetGrid, shuttleDocks, gridDocks, dockType); // Frontier: add dockType foreach (var config in configs) { From 1a6658a2e277256783d247a80d1813692e2e52e4 Mon Sep 17 00:00:00 2001 From: Whatstone Date: Wed, 22 Jan 2025 12:19:32 -0500 Subject: [PATCH 3/3] Add missing Frontier comments --- Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs | 2 +- .../Shuttles/Systems/ShuttleSystem.FasterThanLight.cs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs b/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs index f8184a4bb36..7c3b2f710ee 100644 --- a/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs +++ b/Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs @@ -1,12 +1,12 @@ using System.Linq; using System.Numerics; using Content.Server.Shuttles.Components; -using Content.Shared.Shuttles.Components; using Robust.Shared.Map; using Robust.Shared.Map.Components; using Robust.Shared.Physics; using Robust.Shared.Physics.Collision.Shapes; using Robust.Shared.Physics.Components; +using Content.Shared.Shuttles.Components; // Frontier namespace Content.Server.Shuttles.Systems; diff --git a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs index bcfc62f39e9..f876ffd3e43 100644 --- a/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs +++ b/Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs @@ -715,7 +715,7 @@ public bool TryFTLDock( string? priorityTag = null, DockType dockType = DockType.Airlock) // Frontier { - return TryFTLDock(shuttleUid, component, targetUid, out _, priorityTag, dockType); + return TryFTLDock(shuttleUid, component, targetUid, out _, priorityTag, dockType); // Frontier: add dockType } /// @@ -740,7 +740,7 @@ public bool TryFTLDock( return false; } - config = _dockSystem.GetDockingConfig(shuttleUid, targetUid, priorityTag, dockType); + config = _dockSystem.GetDockingConfig(shuttleUid, targetUid, priorityTag, dockType); // Frontier: add dockType if (config != null) {