]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Electrocute command cleanup and localization (#38563)
authorKyle Tyo <36606155+VerinSenpai@users.noreply.github.com>
Wed, 25 Jun 2025 02:28:13 +0000 (22:28 -0400)
committerGitHub <noreply@github.com>
Wed, 25 Jun 2025 02:28:13 +0000 (04:28 +0200)
* hey look I knocked out a todo :shockedface:

* Update Resources/Locale/en-US/electrocution/electrocute-command.ftl

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Content.Server/Electrocution/ElectrocuteCommand.cs
Resources/Locale/en-US/electrocution/electrocute-command.ftl

index 75eb64c1bb8c4b3d7d3989d542170fc082af9d6f..c0d0ecf740772e4286cc513edc70e0a273496470 100644 (file)
@@ -3,55 +3,47 @@ using Content.Shared.Administration;
 using Content.Shared.StatusEffect;
 using Robust.Shared.Console;
 
-namespace Content.Server.Electrocution
+namespace Content.Server.Electrocution;
+
+[AdminCommand(AdminFlags.Fun)]
+public sealed class ElectrocuteCommand : LocalizedEntityCommands
 {
-    [AdminCommand(AdminFlags.Fun)]
-    public sealed class ElectrocuteCommand : IConsoleCommand
-    {
-        [Dependency] private readonly IEntityManager _entManager = default!;
+    [Dependency] private readonly ElectrocutionSystem _electrocution = default!;
+    [Dependency] private readonly StatusEffectsSystem _statusEffects = default!;
+
+    public override string Command => "electrocute";
 
-        public string Command => "electrocute";
-        public string Description => Loc.GetString("electrocute-command-description");
-        public string Help => $"{Command} <uid> <seconds> <damage>";
+    [ValidatePrototypeId<StatusEffectPrototype>]
+    private const string ElectrocutionStatusEffect = "Electrocution";
+
+    public override void Execute(IConsoleShell shell, string argStr, string[] args)
+    {
+        if (args.Length is < 1 or > 3)
+        {
+            shell.WriteError(Loc.GetString($"shell-need-between-arguments",
+                ("lower", 1),
+                ("upper", 3)));
+            return;
+        }
 
-        [ValidatePrototypeId<StatusEffectPrototype>]
-        public const string ElectrocutionStatusEffect = "Electrocution";
+        if (!NetEntity.TryParse(args[0], out var uidNet) || !EntityManager.TryGetEntity(uidNet, out var uid) || !EntityManager.EntityExists(uid))
+        {
+            shell.WriteError(Loc.GetString($"shell-could-not-find-entity-with-uid", ("uid", args[0])));
+            return;
+        }
 
-        public void Execute(IConsoleShell shell, string argStr, string[] args)
+        if (!_statusEffects.CanApplyEffect(uid.Value, ElectrocutionStatusEffect))
         {
-            if (args.Length < 1)
-            {
-                // TODO: Localize this.
-                shell.WriteError("Not enough arguments!");
-                return;
-            }
-
-            if (!NetEntity.TryParse(args[0], out var uidNet) ||
-                !_entManager.TryGetEntity(uidNet, out var uid) ||
-                !_entManager.EntityExists(uid))
-            {
-                shell.WriteError($"Invalid entity specified!");
-                return;
-            }
-
-            if (!_entManager.EntitySysManager.GetEntitySystem<StatusEffectsSystem>().CanApplyEffect(uid.Value, ElectrocutionStatusEffect))
-            {
-                shell.WriteError(Loc.GetString("electrocute-command-entity-cannot-be-electrocuted"));
-                return;
-            }
-
-            if (args.Length < 2 || !int.TryParse(args[1], out var seconds))
-            {
-                seconds = 10;
-            }
-
-            if (args.Length < 3 || !int.TryParse(args[2], out var damage))
-            {
-                damage = 10;
-            }
-
-            _entManager.EntitySysManager.GetEntitySystem<ElectrocutionSystem>()
-                .TryDoElectrocution(uid.Value, null, damage, TimeSpan.FromSeconds(seconds), refresh: true, ignoreInsulation: true);
+            shell.WriteError(Loc.GetString("cmd-electrocute-entity-cannot-be-electrocuted"));
+            return;
         }
+
+        if (args.Length < 2 || !int.TryParse(args[1], out var seconds))
+            seconds = 10;
+
+        if (args.Length < 3 || !int.TryParse(args[2], out var damage))
+            damage = 10;
+
+        _electrocution.TryDoElectrocution(uid.Value, null, damage, TimeSpan.FromSeconds(seconds), refresh: true, ignoreInsulation: true);
     }
 }
index edd05f29504374f26263fa31716aa66a353d29ae..1a982b40fb7a09d2a2f31551d753b719e8c57962 100644 (file)
@@ -1,2 +1,3 @@
-electrocute-command-description = Electrocutes the specified entity, defaults to 10 seconds and 10 damage. Shocking!
-electrocute-command-entity-cannot-be-electrocuted = You cannot electrocute that entity!
+cmd-electrocute-desc = Electrocutes the specified entity, defaults to 10 seconds and 10 damage. Shocking!
+cmd-electrocute-help = Usage: electrocute <uid> [seconds] [damage]
+cmd-electrocute-entity-cannot-be-electrocuted = You cannot electrocute that entity!