Power stat and nuke codes commands get some LEC love. (#38585)

* commit

* requested changes.
This commit is contained in:
Kyle Tyo
2025-06-29 21:41:55 -04:00
committed by GitHub
parent cd2ce56aef
commit 34825464dc
4 changed files with 57 additions and 59 deletions

View File

@@ -1,22 +1,18 @@
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
{
[UsedImplicitly]
namespace Content.Server.Nuke.Commands;
[AdminCommand(AdminFlags.Fun)]
public sealed class SendNukeCodesCommand : IConsoleCommand
public sealed class SendNukeCodesCommand : LocalizedEntityCommands
{
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)
{
@@ -24,27 +20,25 @@ namespace Content.Server.Nuke.Commands
return;
}
if (!NetEntity.TryParse(args[0], out var uidNet) || !_entityManager.TryGetEntity(uidNet, out var uid))
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);
_nukeCodeSystem.SendNukeCodes(uid.Value);
}
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
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 stationData))
var query = EntityManager.EntityQueryEnumerator<StationDataComponent>();
while (query.MoveNext(out var uid, out _))
{
var meta = _entityManager.GetComponent<MetaDataComponent>(uid);
var meta = EntityManager.GetComponent<MetaDataComponent>(uid);
stations.Add(new CompletionOption(uid.ToString(), meta.EntityName));
}
@@ -52,4 +46,3 @@ namespace Content.Server.Nuke.Commands
return CompletionResult.FromHintOptions(stations, null);
}
}
}

View File

@@ -3,25 +3,22 @@ using Content.Server.Power.EntitySystems;
using Content.Shared.Administration;
using Robust.Shared.Console;
namespace Content.Server.Power.Commands
{
namespace Content.Server.Power.Commands;
[AdminCommand(AdminFlags.Debug)]
public sealed class PowerStatCommand : IConsoleCommand
public sealed class PowerStatCommand : LocalizedEntityCommands
{
[Dependency] private readonly IEntityManager _e = default!;
[Dependency] private readonly PowerNetSystem _powerNet = default!;
public string Command => "powerstat";
public string Description => "Shows statistics for pow3r";
public string Help => "Usage: powerstat";
public override string Command => "powerstat";
public void Execute(IConsoleShell shell, string argStr, string[] args)
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
var stats = _e.System<PowerNetSystem>().GetStatistics();
shell.WriteLine($"networks: {stats.CountNetworks}");
shell.WriteLine($"loads: {stats.CountLoads}");
shell.WriteLine($"supplies: {stats.CountSupplies}");
shell.WriteLine($"batteries: {stats.CountBatteries}");
}
var stats = _powerNet.GetStatistics();
shell.WriteLine(Loc.GetString("cmd-powerstat-output",
("networks", stats.CountNetworks),
("loads", stats.CountLoads),
("supplies", stats.CountSupplies),
("batteries", stats.CountBatteries)));
}
}

View File

@@ -0,0 +1,2 @@
cmd-nukecodes-desc = Send nuke codes to a station's communication consoles.
cmd-nukecodes-help = Usage: nukecodes <entityUid>

View File

@@ -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}