Power stat and nuke codes commands get some LEC love. (#38585)
* commit * requested changes.
This commit is contained in:
@@ -1,55 +1,48 @@
|
||||
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
|
||||
[Dependency] private readonly NukeCodePaperSystem _nukeCodeSystem = default!;
|
||||
|
||||
public override string Command => "nukecodes";
|
||||
|
||||
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
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 void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
if (args.Length != 1)
|
||||
{
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.WriteError(Loc.GetString("shell-need-exactly-one-argument"));
|
||||
return;
|
||||
}
|
||||
|
||||
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);
|
||||
shell.WriteError(Loc.GetString("shell-need-exactly-one-argument"));
|
||||
return;
|
||||
}
|
||||
|
||||
public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
|
||||
if (!NetEntity.TryParse(args[0], out var uidNet) || !EntityManager.TryGetEntity(uidNet, out var uid))
|
||||
{
|
||||
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 meta = _entityManager.GetComponent<MetaDataComponent>(uid);
|
||||
|
||||
stations.Add(new CompletionOption(uid.ToString(), meta.EntityName));
|
||||
}
|
||||
|
||||
return CompletionResult.FromHintOptions(stations, null);
|
||||
shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
|
||||
return;
|
||||
}
|
||||
|
||||
_nukeCodeSystem.SendNukeCodes(uid.Value);
|
||||
}
|
||||
|
||||
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 meta = EntityManager.GetComponent<MetaDataComponent>(uid);
|
||||
|
||||
stations.Add(new CompletionOption(uid.ToString(), meta.EntityName));
|
||||
}
|
||||
|
||||
return CompletionResult.FromHintOptions(stations, null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user