From bd69210710f231ddf1bc9af68ab7b1f13ebf7f6a Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 26 Jan 2022 10:36:19 +1100 Subject: [PATCH] Add docking command (#6303) --- Content.Server/Shuttles/DockCommand.cs | 54 +++++++++++++++++++ .../Shuttles/EntitySystems/DockingSystem.cs | 2 +- 2 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 Content.Server/Shuttles/DockCommand.cs diff --git a/Content.Server/Shuttles/DockCommand.cs b/Content.Server/Shuttles/DockCommand.cs new file mode 100644 index 0000000000..80562d5be9 --- /dev/null +++ b/Content.Server/Shuttles/DockCommand.cs @@ -0,0 +1,54 @@ +using Content.Server.Administration; +using Content.Server.Shuttles.Components; +using Content.Server.Shuttles.EntitySystems; +using Content.Shared.Administration; +using Robust.Shared.Console; +using Robust.Shared.GameObjects; +using Robust.Shared.IoC; + +namespace Content.Server.Shuttles; + +[AdminCommand(AdminFlags.Mapping)] +public sealed class DockCommand : IConsoleCommand +{ + public string Command => "dock"; + public string Description => $"Attempts to dock 2 airlocks together. Doesn't check whether it is valid."; + public string Help => $"{Command} "; + public void Execute(IConsoleShell shell, string argStr, string[] args) + { + if (args.Length != 2) + { + shell.WriteError($"Invalid number of args supplied"); + return; + } + + if (!EntityUid.TryParse(args[0], out var airlock1)) + { + shell.WriteError($"Invalid EntityUid {args[0]}"); + return; + } + + if (!EntityUid.TryParse(args[1], out var airlock2)) + { + shell.WriteError($"Invalid EntityUid {args[1]}"); + return; + } + + var entManager = IoCManager.Resolve(); + + if (!entManager.TryGetComponent(airlock1, out DockingComponent? dock1)) + { + shell.WriteError($"No docking component found on {airlock1}"); + return; + } + + if (!entManager.TryGetComponent(airlock2, out DockingComponent? dock2)) + { + shell.WriteError($"No docking component found on {airlock2}"); + return; + } + + var dockSystem = EntitySystem.Get(); + dockSystem.Dock(dock1, dock2); + } +} diff --git a/Content.Server/Shuttles/EntitySystems/DockingSystem.cs b/Content.Server/Shuttles/EntitySystems/DockingSystem.cs index 0984d3f04b..aa8d89effd 100644 --- a/Content.Server/Shuttles/EntitySystems/DockingSystem.cs +++ b/Content.Server/Shuttles/EntitySystems/DockingSystem.cs @@ -320,7 +320,7 @@ namespace Content.Server.Shuttles.EntitySystems /// /// Docks 2 ports together and assumes it is valid. /// - private void Dock(DockingComponent dockA, DockingComponent dockB) + public void Dock(DockingComponent dockA, DockingComponent dockB) { Logger.DebugS("docking", $"Docking between {dockA.Owner} and {dockB.Owner}");