SendNukeCodesCommand.cs 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using Content.Server.Administration;
  2. using Content.Server.Station.Components;
  3. using Content.Shared.Administration;
  4. using JetBrains.Annotations;
  5. using Robust.Shared.Console;
  6. namespace Content.Server.Nuke.Commands
  7. {
  8. [UsedImplicitly]
  9. [AdminCommand(AdminFlags.Fun)]
  10. public sealed class SendNukeCodesCommand : IConsoleCommand
  11. {
  12. public string Command => "nukecodes";
  13. public string Description => "Send nuke codes to a station's communication consoles";
  14. public string Help => "nukecodes [station EntityUid]";
  15. [Dependency] private readonly IEntityManager _entityManager = default!;
  16. public void Execute(IConsoleShell shell, string argStr, string[] args)
  17. {
  18. if (args.Length != 1)
  19. {
  20. shell.WriteError(Loc.GetString("shell-need-exactly-one-argument"));
  21. return;
  22. }
  23. if (!NetEntity.TryParse(args[0], out var uidNet) || !_entityManager.TryGetEntity(uidNet, out var uid))
  24. {
  25. shell.WriteError(Loc.GetString("shell-entity-uid-must-be-number"));
  26. return;
  27. }
  28. _entityManager.System<NukeCodePaperSystem>().SendNukeCodes(uid.Value);
  29. }
  30. public CompletionResult GetCompletion(IConsoleShell shell, string[] args)
  31. {
  32. if (args.Length != 1)
  33. {
  34. return CompletionResult.Empty;
  35. }
  36. var stations = new List<CompletionOption>();
  37. var query = _entityManager.EntityQueryEnumerator<StationDataComponent>();
  38. while (query.MoveNext(out var uid, out var stationData))
  39. {
  40. var meta = _entityManager.GetComponent<MetaDataComponent>(uid);
  41. stations.Add(new CompletionOption(uid.ToString(), meta.EntityName));
  42. }
  43. return CompletionResult.FromHintOptions(stations, null);
  44. }
  45. }
  46. }