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.Administration;
|
||||||
using Content.Server.Station.Components;
|
using Content.Server.Station.Components;
|
||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using JetBrains.Annotations;
|
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
|
|
||||||
namespace Content.Server.Nuke.Commands
|
namespace Content.Server.Nuke.Commands;
|
||||||
|
|
||||||
|
[AdminCommand(AdminFlags.Fun)]
|
||||||
|
public sealed class SendNukeCodesCommand : LocalizedEntityCommands
|
||||||
{
|
{
|
||||||
[UsedImplicitly]
|
[Dependency] private readonly NukeCodePaperSystem _nukeCodeSystem = default!;
|
||||||
[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 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)
|
if (args.Length != 1)
|
||||||
{
|
{
|
||||||
@@ -24,32 +20,29 @@ namespace Content.Server.Nuke.Commands
|
|||||||
return;
|
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"));
|
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||||
return;
|
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)
|
if (args.Length != 1)
|
||||||
{
|
|
||||||
return CompletionResult.Empty;
|
return CompletionResult.Empty;
|
||||||
}
|
|
||||||
|
|
||||||
var stations = new List<CompletionOption>();
|
var stations = new List<CompletionOption>();
|
||||||
var query = _entityManager.EntityQueryEnumerator<StationDataComponent>();
|
var query = EntityManager.EntityQueryEnumerator<StationDataComponent>();
|
||||||
while (query.MoveNext(out var uid, out var stationData))
|
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));
|
stations.Add(new CompletionOption(uid.ToString(), meta.EntityName));
|
||||||
}
|
}
|
||||||
|
|
||||||
return CompletionResult.FromHintOptions(stations, null);
|
return CompletionResult.FromHintOptions(stations, null);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,25 +3,22 @@ using Content.Server.Power.EntitySystems;
|
|||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Robust.Shared.Console;
|
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)]
|
[Dependency] private readonly PowerNetSystem _powerNet = default!;
|
||||||
public sealed class PowerStatCommand : IConsoleCommand
|
|
||||||
|
public override string Command => "powerstat";
|
||||||
|
|
||||||
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityManager _e = default!;
|
var stats = _powerNet.GetStatistics();
|
||||||
|
shell.WriteLine(Loc.GetString("cmd-powerstat-output",
|
||||||
public string Command => "powerstat";
|
("networks", stats.CountNetworks),
|
||||||
public string Description => "Shows statistics for pow3r";
|
("loads", stats.CountLoads),
|
||||||
public string Help => "Usage: powerstat";
|
("supplies", stats.CountSupplies),
|
||||||
|
("batteries", stats.CountBatteries)));
|
||||||
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}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
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