Skip to content

Commit

Permalink
add apc power draw to stat value command (space-wizards#29701)
Browse files Browse the repository at this point in the history
add apc stat value
  • Loading branch information
EmoGarbage404 authored Jul 4, 2024
1 parent 5198c87 commit e612ccd
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 1 deletion.
46 changes: 45 additions & 1 deletion Content.Server/UserInterface/StatValuesCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
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;
Expand Down Expand Up @@ -56,6 +57,9 @@ public void Execute(IConsoleShell shell, string argStr, string[] args)
case "itemsize":
message = GetItem();
break;
case "drawrate":
message = GetDrawRateMessage();
break;
default:
shell.WriteError(Loc.GetString("stat-values-invalid", ("arg", args[0])));
return;
Expand All @@ -70,7 +74,7 @@ public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
{
if (args.Length == 1)
{
return CompletionResult.FromOptions(new[] { "cargosell", "lathesell", "melee" });
return CompletionResult.FromOptions(new[] { "cargosell", "lathesell", "melee", "itemsize", "drawrate" });
}

return CompletionResult.Empty;
Expand Down Expand Up @@ -250,4 +254,44 @@ private StatValuesEuiMessage GetLatheMessage()

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;
}
}
5 changes: 5 additions & 0 deletions Resources/Locale/en-US/commands/stat-values-command.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit e612ccd

Please sign in to comment.