]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Power stat and nuke codes commands get some LEC love. (#38585)
authorKyle Tyo <36606155+VerinSenpai@users.noreply.github.com>
Mon, 30 Jun 2025 01:41:55 +0000 (21:41 -0400)
committerGitHub <noreply@github.com>
Mon, 30 Jun 2025 01:41:55 +0000 (03:41 +0200)
* commit

* requested changes.

Content.Server/Nuke/Commands/SendNukeCodesCommand.cs
Content.Server/Power/Commands/PowerStatCommand.cs
Resources/Locale/en-US/commands/nukecodes-command.ftl [new file with mode: 0644]
Resources/Locale/en-US/commands/powerstat-command.ftl [new file with mode: 0644]

index d0e83e4f75e1a50aeec7f459f7da7cb32342b0ff..8ac4f95a972586078ee423064185b000e2b3804d 100644 (file)
@@ -1,55 +1,48 @@
 using Content.Server.Administration;
 using Content.Server.Station.Components;
 using Content.Shared.Administration;
-using JetBrains.Annotations;
 using Robust.Shared.Console;
 
-namespace Content.Server.Nuke.Commands
+namespace Content.Server.Nuke.Commands;
+
+[AdminCommand(AdminFlags.Fun)]
+public sealed class SendNukeCodesCommand : LocalizedEntityCommands
 {
-    [UsedImplicitly]
-    [AdminCommand(AdminFlags.Fun)]
-    public sealed class SendNukeCodesCommand : IConsoleCommand
-    {
-        public string Command => "nukecodes";
-        public string Description => "Send nuke codes to a station's communication consoles";
-        public string Help => "nukecodes [station EntityUid]";
+    [Dependency] private readonly NukeCodePaperSystem _nukeCodeSystem = default!;
 
-        [Dependency] private readonly IEntityManager _entityManager = default!;
+    public override string Command => "nukecodes";
 
-        public void Execute(IConsoleShell shell, string argStr, string[] args)
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        if (args.Length != 1)
         {
-            if (args.Length != 1)
-            {
-                shell.WriteError(Loc.GetString("shell-need-exactly-one-argument"));
-                return;
-            }
-
-            if (!NetEntity.TryParse(args[0], out var uidNet) || !_entityManager.TryGetEntity(uidNet, out var uid))
-            {
-                shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
-                return;
-            }
-
-            _entityManager.System<NukeCodePaperSystem>().SendNukeCodes(uid.Value);
+            shell.WriteError(Loc.GetString("shell-need-exactly-one-argument"));
+            return;
         }
 
-        public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+        if (!NetEntity.TryParse(args[0], out var uidNet) || !EntityManager.TryGetEntity(uidNet, out var uid))
         {
-            if (args.Length != 1)
-            {
-                return CompletionResult.Empty;
-            }
+            shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
+            return;
+        }
 
-            var stations = new List<CompletionOption>();
-            var query = _entityManager.EntityQueryEnumerator<StationDataComponent>();
-            while (query.MoveNext(out var uid, out var stationData))
-            {
-                var meta = _entityManager.GetComponent<MetaDataComponent>(uid);
+        _nukeCodeSystem.SendNukeCodes(uid.Value);
+    }
 
-                stations.Add(new CompletionOption(uid.ToString(), meta.EntityName));
-            }
+    public override CompletionResult GetCompletion(IConsoleShell shell, string[] args)
+    {
+        if (args.Length != 1)
+            return CompletionResult.Empty;
+
+        var stations = new List<CompletionOption>();
+        var query = EntityManager.EntityQueryEnumerator<StationDataComponent>();
+        while (query.MoveNext(out var uid, out _))
+        {
+            var meta = EntityManager.GetComponent<MetaDataComponent>(uid);
 
-            return CompletionResult.FromHintOptions(stations, null);
+            stations.Add(new CompletionOption(uid.ToString(), meta.EntityName));
         }
+
+        return CompletionResult.FromHintOptions(stations, null);
     }
 }
index 127050393aa170dd0e079dd91f4af8fc9f2f544b..b9d71ee9bce7affbf7a50405104870c1f3e25a6a 100644 (file)
@@ -3,25 +3,22 @@ using Content.Server.Power.EntitySystems;
 using Content.Shared.Administration;
 using Robust.Shared.Console;
 
-namespace Content.Server.Power.Commands
-{
-    [AdminCommand(AdminFlags.Debug)]
-    public sealed class PowerStatCommand : IConsoleCommand
-    {
-        [Dependency] private readonly IEntityManager _e = default!;
+namespace Content.Server.Power.Commands;
 
-        public string Command => "powerstat";
-        public string Description => "Shows statistics for pow3r";
-        public string Help => "Usage: powerstat";
+[AdminCommand(AdminFlags.Debug)]
+public sealed class PowerStatCommand : LocalizedEntityCommands
+{
+    [Dependency] private readonly PowerNetSystem _powerNet = default!;
 
-        public void Execute(IConsoleShell shell, string argStr, string[] args)
-        {
-            var stats = _e.System<PowerNetSystem>().GetStatistics();
+    public override string Command => "powerstat";
 
-            shell.WriteLine($"networks: {stats.CountNetworks}");
-            shell.WriteLine($"loads: {stats.CountLoads}");
-            shell.WriteLine($"supplies: {stats.CountSupplies}");
-            shell.WriteLine($"batteries: {stats.CountBatteries}");
-        }
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        var stats = _powerNet.GetStatistics();
+        shell.WriteLine(Loc.GetString("cmd-powerstat-output",
+            ("networks", stats.CountNetworks),
+            ("loads", stats.CountLoads),
+            ("supplies", stats.CountSupplies),
+            ("batteries", stats.CountBatteries)));
     }
 }
diff --git a/Resources/Locale/en-US/commands/nukecodes-command.ftl b/Resources/Locale/en-US/commands/nukecodes-command.ftl
new file mode 100644 (file)
index 0000000..50e324c
--- /dev/null
@@ -0,0 +1,2 @@
+cmd-nukecodes-desc = Send nuke codes to a station's communication consoles.
+cmd-nukecodes-help = Usage: nukecodes <entityUid>
diff --git a/Resources/Locale/en-US/commands/powerstat-command.ftl b/Resources/Locale/en-US/commands/powerstat-command.ftl
new file mode 100644 (file)
index 0000000..c22cd5e
--- /dev/null
@@ -0,0 +1,6 @@
+cmd-powerstat-desc = Shows statistics for pow3r.
+cmd-powerstat-help = Usage: powerstat
+cmd-powerstat-output = Networks:   {$networks}
+                       Loads:      {$loads}
+                       Supplies:   {$supplies}
+                       Batteries:  {$batteries}