]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
add apc power draw to stat value command (#29701)
authorNemanja <98561806+EmoGarbage404@users.noreply.github.com>
Thu, 4 Jul 2024 01:13:49 +0000 (21:13 -0400)
committerGitHub <noreply@github.com>
Thu, 4 Jul 2024 01:13:49 +0000 (11:13 +1000)
add apc stat value

Content.Server/UserInterface/StatValuesCommand.cs
Resources/Locale/en-US/commands/stat-values-command.ftl

index f0c4f531d0183ec2e8e3e16c18182637ab5df130..cb599f7b09f75b4f78508f338d7d93aa84288426 100644 (file)
@@ -4,6 +4,7 @@ using Content.Server.Administration;
 using Content.Server.Cargo.Systems;
 using Content.Server.EUI;
 using Content.Server.Item;
+using Content.Server.Power.Components;
 using Content.Shared.Administration;
 using Content.Shared.Item;
 using Content.Shared.Materials;
@@ -56,6 +57,9 @@ public sealed class StatValuesCommand : IConsoleCommand
             case "itemsize":
                 message = GetItem();
                 break;
+            case "drawrate":
+                message = GetDrawRateMessage();
+                break;
             default:
                 shell.WriteError(Loc.GetString("stat-values-invalid", ("arg", args[0])));
                 return;
@@ -70,7 +74,7 @@ public sealed class StatValuesCommand : IConsoleCommand
     {
         if (args.Length == 1)
         {
-            return CompletionResult.FromOptions(new[] { "cargosell", "lathesell", "melee" });
+            return CompletionResult.FromOptions(new[] { "cargosell", "lathesell", "melee", "itemsize", "drawrate" });
         }
 
         return CompletionResult.Empty;
@@ -250,4 +254,44 @@ public sealed class StatValuesCommand : IConsoleCommand
 
         return state;
     }
+
+    private StatValuesEuiMessage GetDrawRateMessage()
+    {
+        var values = new List<string[]>();
+        var powerName = _factory.GetComponentName(typeof(ApcPowerReceiverComponent));
+
+        foreach (var proto in _proto.EnumeratePrototypes<EntityPrototype>())
+        {
+            if (proto.Abstract ||
+                !proto.Components.TryGetValue(powerName,
+                    out var powerConsumer))
+            {
+                continue;
+            }
+
+            var comp = (ApcPowerReceiverComponent) powerConsumer.Component;
+
+            if (comp.Load == 0)
+                continue;
+
+            values.Add(new[]
+            {
+                proto.ID,
+                comp.Load.ToString(CultureInfo.InvariantCulture),
+            });
+        }
+
+        var state = new StatValuesEuiMessage
+        {
+            Title = Loc.GetString("stat-drawrate-values"),
+            Headers = new List<string>
+            {
+                Loc.GetString("stat-drawrate-id"),
+                Loc.GetString("stat-drawrate-rate"),
+            },
+            Values = values,
+        };
+
+        return state;
+    }
 }
index 99c6bd194e3c27631dfd4b5d8a985c5b09c0f70d..67a211adabe5e310be2aa9cf4ed0707cc6e46872 100644 (file)
@@ -18,3 +18,8 @@ stat-lathe-sell = Sell price
 stat-item-values = Item sizes
 stat-item-id = ID
 stat-item-price = Size
+
+# Draw Rate
+stat-drawrate-values = APC draw rate
+stat-drawrate-id = ID
+stat-drawrate-rate = Draw Rate (W)