Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ShuttleSystem: FTL docking functions accept and check docking types #2764

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 36 additions & 7 deletions Content.Server/Shuttles/Systems/DockingSystem.Shuttle.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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;

Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -111,12 +117,12 @@ private bool CanDock(
/// Tries to get a valid docking configuration for the shuttle to the target grid.
/// </summary>
/// <param name="priorityTag">Priority docking tag to prefer, e.g. for emergency shuttle</param>
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
}

/// <summary>
Expand All @@ -125,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)
{
Expand All @@ -150,7 +157,8 @@ private List<DockingConfig> GetDockingConfigs(
EntityUid shuttleUid,
EntityUid targetGrid,
List<Entity<DockingComponent>> shuttleDocks,
List<Entity<DockingComponent>> gridDocks)
List<Entity<DockingComponent>> gridDocks,
DockType dockType) // Frontier: add dockType
{
var validDockConfigs = new List<DockingConfig>();

Expand All @@ -173,10 +181,20 @@ private List<DockingConfig> 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,
Expand Down Expand Up @@ -223,11 +241,21 @@ private List<DockingConfig> 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),
Expand Down Expand Up @@ -277,9 +305,10 @@ private List<DockingConfig> GetDockingConfigs(
EntityUid targetGrid,
List<Entity<DockingComponent>> shuttleDocks,
List<Entity<DockingComponent>> 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;
Expand Down
10 changes: 6 additions & 4 deletions Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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); // Frontier: add dockType
}

/// <summary>
Expand All @@ -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;

Expand All @@ -738,7 +740,7 @@ public bool TryFTLDock(
return false;
}

config = _dockSystem.GetDockingConfig(shuttleUid, targetUid, priorityTag);
config = _dockSystem.GetDockingConfig(shuttleUid, targetUid, priorityTag, dockType); // Frontier: add dockType

if (config != null)
{
Expand Down
Loading