From 6a2afa562554d4e9c96db10ef3a32d8321d4cfba Mon Sep 17 00:00:00 2001 From: Kyle Tyo <36606155+VerinSenpai@users.noreply.github.com> Date: Mon, 23 Jun 2025 17:25:35 -0400 Subject: [PATCH] Revisions and cleanup to dock and shuttle commands. (#38533) commit --- .../Commands/DelayShuttleRoundEndCommand.cs | 19 ++----- .../Shuttles/Commands/DockCommand.cs | 55 ++++++++----------- .../Commands/DockEmergencyShuttleCommand.cs | 14 ++--- .../Commands/LaunchEmergencyShuttleCommand.cs | 14 ++--- Resources/Locale/en-US/shuttles/docking.ftl | 3 - Resources/Locale/en-US/shuttles/emergency.ftl | 11 ++-- 6 files changed, 48 insertions(+), 68 deletions(-) diff --git a/Content.Server/Shuttles/Commands/DelayShuttleRoundEndCommand.cs b/Content.Server/Shuttles/Commands/DelayShuttleRoundEndCommand.cs index 3c881dcbb5..4750cd77c1 100644 --- a/Content.Server/Shuttles/Commands/DelayShuttleRoundEndCommand.cs +++ b/Content.Server/Shuttles/Commands/DelayShuttleRoundEndCommand.cs @@ -9,24 +9,17 @@ namespace Content.Server.Shuttles.Commands; /// Delays the round from ending via the shuttle call. Can still be ended via other means. /// [AdminCommand(AdminFlags.Fun)] -public sealed class DelayRoundEndCommand : IConsoleCommand +public sealed class DelayRoundEndCommand : LocalizedEntityCommands { - [Dependency] private readonly IEntitySystemManager _sysManager = default!; + [Dependency] private readonly EmergencyShuttleSystem _shuttleSystem = default!; - public string Command => "delayroundend"; - public string Description => Loc.GetString("emergency-shuttle-command-round-desc"); - public string Help => $"{Command}"; - public void Execute(IConsoleShell shell, string argStr, string[] args) + public override string Command => "delayroundend"; + + public override void Execute(IConsoleShell shell, string argStr, string[] args) { - var system = _sysManager.GetEntitySystem(); - - if (system.DelayEmergencyRoundEnd()) - { + if (_shuttleSystem.DelayEmergencyRoundEnd()) shell.WriteLine(Loc.GetString("emergency-shuttle-command-round-yes")); - } else - { shell.WriteLine(Loc.GetString("emergency-shuttle-command-round-no")); - } } } diff --git a/Content.Server/Shuttles/Commands/DockCommand.cs b/Content.Server/Shuttles/Commands/DockCommand.cs index 62634af2bc..14042cd953 100644 --- a/Content.Server/Shuttles/Commands/DockCommand.cs +++ b/Content.Server/Shuttles/Commands/DockCommand.cs @@ -7,70 +7,61 @@ using Robust.Shared.Console; namespace Content.Server.Shuttles.Commands; [AdminCommand(AdminFlags.Mapping)] -public sealed class DockCommand : IConsoleCommand +public sealed class DockCommand : LocalizedEntityCommands { - [Dependency] private readonly IEntityManager _entManager = default!; + [Dependency] private readonly DockingSystem _dockSystem = default!; - public string Command => "dock"; - public string Description => Loc.GetString("cmd-dock-desc"); - public string Help => Loc.GetString("cmd-dock-help"); - public void Execute(IConsoleShell shell, string argStr, string[] args) + public override string Command => "dock"; + + public override void Execute(IConsoleShell shell, string argStr, string[] args) { if (args.Length != 2) { - shell.WriteError(Loc.GetString("cmd-dock-args")); + shell.WriteError(Loc.GetString("shell-wrong-arguments-number-need-specific", + ("properAmount", 2), + ("currentAmount", args.Length))); return; } - if (!NetEntity.TryParse(args[0], out var airlock1Net) || !_entManager.TryGetEntity(airlock1Net, out var airlock1)) + if (!NetEntity.TryParse(args[0], out var airlock1Net) || !EntityManager.TryGetEntity(airlock1Net, out var airlock1)) { - shell.WriteError(Loc.GetString("cmd-dock-invalid", ("entity", args[0]))); + shell.WriteError(Loc.GetString("shell-invalid-entity-uid", ("uid", args[0]))); return; } - if (!NetEntity.TryParse(args[1], out var airlock2Net) || !_entManager.TryGetEntity(airlock2Net, out var airlock2)) + if (!NetEntity.TryParse(args[1], out var airlock2Net) || !EntityManager.TryGetEntity(airlock2Net, out var airlock2)) { - shell.WriteError(Loc.GetString("cmd-dock-invalid", ("entity", args[1]))); + shell.WriteError(Loc.GetString("shell-invalid-entity-uid", ("uid", args[1]))); return; } - if (!_entManager.TryGetComponent(airlock1, out DockingComponent? dock1)) + if (!EntityManager.TryGetComponent(airlock1, out DockingComponent? dock1)) { - shell.WriteError(Loc.GetString("cmd-dock-found", ("airlock", airlock1))); + shell.WriteError(Loc.GetString("shell-entity-with-uid-lacks-component", ("uid", args[0]), ("componentName", nameof(DockingComponent)))); return; } - if (!_entManager.TryGetComponent(airlock2, out DockingComponent? dock2)) + if (!EntityManager.TryGetComponent(airlock2, out DockingComponent? dock2)) { - shell.WriteError(Loc.GetString("cmd-dock-found", ("airlock", airlock2))); + shell.WriteError(Loc.GetString("shell-entity-with-uid-lacks-component", ("uid", args[1]), ("componentName", nameof(DockingComponent)))); return; } - var dockSystem = _entManager.System(); - dockSystem.Dock((airlock1.Value, dock1), (airlock2.Value, dock2)); + _dockSystem.Dock((airlock1.Value, dock1), (airlock2.Value, dock2)); if (dock1.DockedWith == airlock2) - { shell.WriteLine(Loc.GetString("cmd-dock-success")); - } else - { shell.WriteError(Loc.GetString("cmd-dock-fail")); - } } - public CompletionResult GetCompletion(IConsoleShell shell, string[] args) + public override CompletionResult GetCompletion(IConsoleShell shell, string[] args) { - if (args.Length == 1) + return args.Length switch { - return CompletionResult.FromOptions(CompletionHelper.Components(args[0], _entManager)); - } - - if (args.Length == 2) - { - return CompletionResult.FromOptions(CompletionHelper.Components(args[1], _entManager)); - } - - return CompletionResult.Empty; + 1 => CompletionResult.FromOptions(CompletionHelper.Components(args[0], EntityManager)), + 2 => CompletionResult.FromOptions(CompletionHelper.Components(args[1], EntityManager)), + _ => CompletionResult.Empty, + }; } } diff --git a/Content.Server/Shuttles/Commands/DockEmergencyShuttleCommand.cs b/Content.Server/Shuttles/Commands/DockEmergencyShuttleCommand.cs index f219602bcb..b95cecc894 100644 --- a/Content.Server/Shuttles/Commands/DockEmergencyShuttleCommand.cs +++ b/Content.Server/Shuttles/Commands/DockEmergencyShuttleCommand.cs @@ -9,16 +9,14 @@ namespace Content.Server.Shuttles.Commands; /// Calls in the emergency shuttle. /// [AdminCommand(AdminFlags.Fun)] -public sealed class DockEmergencyShuttleCommand : IConsoleCommand +public sealed class DockEmergencyShuttleCommand : LocalizedEntityCommands { - [Dependency] private readonly IEntitySystemManager _sysManager = default!; + [Dependency] private readonly EmergencyShuttleSystem _shuttleSystem = default!; - public string Command => "dockemergencyshuttle"; - public string Description => Loc.GetString("emergency-shuttle-command-dock-desc"); - public string Help => $"{Command}"; - public void Execute(IConsoleShell shell, string argStr, string[] args) + public override string Command => "dockemergencyshuttle"; + + public override void Execute(IConsoleShell shell, string argStr, string[] args) { - var system = _sysManager.GetEntitySystem(); - system.DockEmergencyShuttle(); + _shuttleSystem.DockEmergencyShuttle(); } } diff --git a/Content.Server/Shuttles/Commands/LaunchEmergencyShuttleCommand.cs b/Content.Server/Shuttles/Commands/LaunchEmergencyShuttleCommand.cs index b9dd9c20e9..7f129e6d20 100644 --- a/Content.Server/Shuttles/Commands/LaunchEmergencyShuttleCommand.cs +++ b/Content.Server/Shuttles/Commands/LaunchEmergencyShuttleCommand.cs @@ -9,16 +9,14 @@ namespace Content.Server.Shuttles.Commands; /// Early launches in the emergency shuttle. /// [AdminCommand(AdminFlags.Fun)] -public sealed class LaunchEmergencyShuttleCommand : IConsoleCommand +public sealed class LaunchEmergencyShuttleCommand : LocalizedEntityCommands { - [Dependency] private readonly IEntitySystemManager _sysManager = default!; + [Dependency] private readonly EmergencyShuttleSystem _shuttleSystem = default!; - public string Command => "launchemergencyshuttle"; - public string Description => Loc.GetString("emergency-shuttle-command-launch-desc"); - public string Help => $"{Command}"; - public void Execute(IConsoleShell shell, string argStr, string[] args) + public override string Command => "launchemergencyshuttle"; + + public override void Execute(IConsoleShell shell, string argStr, string[] args) { - var system = _sysManager.GetEntitySystem(); - system.EarlyLaunch(); + _shuttleSystem.EarlyLaunch(); } } diff --git a/Resources/Locale/en-US/shuttles/docking.ftl b/Resources/Locale/en-US/shuttles/docking.ftl index 0379225829..026cbb9bd0 100644 --- a/Resources/Locale/en-US/shuttles/docking.ftl +++ b/Resources/Locale/en-US/shuttles/docking.ftl @@ -4,8 +4,5 @@ docking-component-undock = Undock cmd-dock-desc = Attempts to dock 2 airlocks together. Doesn't check whether it is valid. cmd-dock-help = dock -cmd-dock-args = Invalid number of args -cmd-dock-invalid = Invalid EntityUid {$entity} -cmd-dock-found = No docking component found on {$airlock} cmd-dock-success = Successfully docked cmd-dock-fail = Unable to dock diff --git a/Resources/Locale/en-US/shuttles/emergency.ftl b/Resources/Locale/en-US/shuttles/emergency.ftl index ef3582c623..c12c6534fe 100644 --- a/Resources/Locale/en-US/shuttles/emergency.ftl +++ b/Resources/Locale/en-US/shuttles/emergency.ftl @@ -1,14 +1,17 @@ # Commands ## Delay shuttle round end -emergency-shuttle-command-round-desc = Stops the timer that ends the round when the emergency shuttle exits hyperspace. +cmd-delayroundend-desc = Stops the timer that ends the round when the emergency shuttle exits hyperspace. +cmd-delayroundend-help = Usage: delayroundend emergency-shuttle-command-round-yes = Round delayed. emergency-shuttle-command-round-no = Unable to delay round end. ## Dock emergency shuttle -emergency-shuttle-command-dock-desc = Calls the emergency shuttle and docks it to the station... if it can. +cmd-dockemergencyshuttle-desc = Calls the emergency shuttle and docks it to the station... if it can. +cmd-dockemergencyshuttle-help = Usage: dockemergencyshuttle ## Launch emergency shuttle -emergency-shuttle-command-launch-desc = Early launches the emergency shuttle if possible. +cmd-launchemergencyshuttle-desc = Early launches the emergency shuttle if possible. +cmd-launchemergencyshuttle-help = Usage: launchemergencyshuttle # Emergency shuttle emergency-shuttle-left = The Emergency Shuttle has left the station. Estimate {$transitTime} seconds until the shuttle arrives at CentComm. @@ -37,4 +40,4 @@ emergency-shuttle-ui-remaining = Remaining: {$remaining} # Map Misc. map-name-centcomm = Central Command -map-name-terminal = Arrivals Terminal \ No newline at end of file +map-name-terminal = Arrivals Terminal