]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Revisions and cleanup to dock and shuttle commands. (#38533)
authorKyle Tyo <36606155+VerinSenpai@users.noreply.github.com>
Mon, 23 Jun 2025 21:25:35 +0000 (17:25 -0400)
committerGitHub <noreply@github.com>
Mon, 23 Jun 2025 21:25:35 +0000 (23:25 +0200)
commit

Content.Server/Shuttles/Commands/DelayShuttleRoundEndCommand.cs
Content.Server/Shuttles/Commands/DockCommand.cs
Content.Server/Shuttles/Commands/DockEmergencyShuttleCommand.cs
Content.Server/Shuttles/Commands/LaunchEmergencyShuttleCommand.cs
Resources/Locale/en-US/shuttles/docking.ftl
Resources/Locale/en-US/shuttles/emergency.ftl

index 3c881dcbb5b45ba9f870abaabbe787c6b97121ad..4750cd77c11d3266ca26881b94b0faf866490e88 100644 (file)
@@ -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.
 /// </summary>
 [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)
-    {
-        var system = _sysManager.GetEntitySystem<EmergencyShuttleSystem>();
+    public override string Command => "delayroundend";
 
-        if (system.DelayEmergencyRoundEnd())
-        {
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        if (_shuttleSystem.DelayEmergencyRoundEnd())
             shell.WriteLine(Loc.GetString("emergency-shuttle-command-round-yes"));
-        }
         else
-        {
             shell.WriteLine(Loc.GetString("emergency-shuttle-command-round-no"));
-        }
     }
 }
index 62634af2bcd566d23d209df2178ce56f2e7a7710..14042cd95303fdda9169371022d42a6b1271aebc 100644 (file)
@@ -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<DockingSystem>();
-        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<DockingComponent>(args[0], _entManager));
-        }
-
-        if (args.Length == 2)
-        {
-            return CompletionResult.FromOptions(CompletionHelper.Components<DockingComponent>(args[1], _entManager));
-        }
-
-        return CompletionResult.Empty;
+            1 => CompletionResult.FromOptions(CompletionHelper.Components<DockingComponent>(args[0], EntityManager)),
+            2 => CompletionResult.FromOptions(CompletionHelper.Components<DockingComponent>(args[1], EntityManager)),
+            _ => CompletionResult.Empty,
+        };
     }
 }
index f219602bcb6c88e264e58df6a42c4621ee8b635d..b95cecc894e259f835fa4725e8d4930bad2da5a7 100644 (file)
@@ -9,16 +9,14 @@ namespace Content.Server.Shuttles.Commands;
 /// Calls in the emergency shuttle.
 /// </summary>
 [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<EmergencyShuttleSystem>();
-        system.DockEmergencyShuttle();
+        _shuttleSystem.DockEmergencyShuttle();
     }
 }
index b9dd9c20e95e1e713d8cffb5186803190fac17c2..7f129e6d2097ac50878ac9c9db7c89ef7e50248d 100644 (file)
@@ -9,16 +9,14 @@ namespace Content.Server.Shuttles.Commands;
 /// Early launches in the emergency shuttle.
 /// </summary>
 [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<EmergencyShuttleSystem>();
-        system.EarlyLaunch();
+        _shuttleSystem.EarlyLaunch();
     }
 }
index 037922582941cd4919bcb16fea074b4055def347..026cbb9bd05d4bc8d5a9da63eb19081f25fce857 100644 (file)
@@ -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 <airlock entityuid1> <airlock entityuid2>
 
-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
index ef3582c623c4ac7e5ccd0dd5a28227900f22f5c6..c12c6534fef2a66cbaba728892b4b7b4c2eb7c7f 100644 (file)
@@ -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