Power stat and nuke codes commands get some LEC love. (#38585)
* commit * requested changes.
This commit is contained in:
@@ -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
|
||||
namespace Content.Server.Nuke.Commands;
|
||||
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public sealed class SendNukeCodesCommand : LocalizedEntityCommands
|
||||
{
|
||||
[UsedImplicitly]
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public sealed class SendNukeCodesCommand : IConsoleCommand
|
||||
{
|
||||
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,32 +20,29 @@ 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));
|
||||
}
|
||||
|
||||
return CompletionResult.FromHintOptions(stations, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 : LocalizedEntityCommands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Debug)]
|
||||
public sealed class PowerStatCommand : IConsoleCommand
|
||||
[Dependency] private readonly PowerNetSystem _powerNet = default!;
|
||||
|
||||
public override string Command => "powerstat";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
[Dependency] private readonly IEntityManager _e = default!;
|
||||
|
||||
public string Command => "powerstat";
|
||||
public string Description => "Shows statistics for pow3r";
|
||||
public string Help => "Usage: powerstat";
|
||||
|
||||
public 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)));
|
||||
}
|
||||
}
|
||||
|
||||
2
Resources/Locale/en-US/commands/nukecodes-command.ftl
Normal file
2
Resources/Locale/en-US/commands/nukecodes-command.ftl
Normal file
@@ -0,0 +1,2 @@
|
||||
cmd-nukecodes-desc = Send nuke codes to a station's communication consoles.
|
||||
cmd-nukecodes-help = Usage: nukecodes <entityUid>
|
||||
6
Resources/Locale/en-US/commands/powerstat-command.ftl
Normal file
6
Resources/Locale/en-US/commands/powerstat-command.ftl
Normal 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}
|
||||
Reference in New Issue
Block a user