add apc power draw to stat value command (#29701)

add apc stat value
This commit is contained in:
Nemanja
2024-07-03 21:13:49 -04:00
committed by GitHub
parent 5198c87597
commit e612ccda92
2 changed files with 50 additions and 1 deletions

View 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;
}
}

View 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)