DelayStartCommand.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. using Content.Server.Administration;
  2. using Content.Shared.Administration;
  3. using Robust.Shared.Console;
  4. namespace Content.Server.GameTicking.Commands
  5. {
  6. [AdminCommand(AdminFlags.Round)]
  7. sealed class DelayStartCommand : IConsoleCommand
  8. {
  9. [Dependency] private readonly IEntityManager _e = default!;
  10. public string Command => "delaystart";
  11. public string Description => "Delays the round start.";
  12. public string Help => $"Usage: {Command} <seconds>\nPauses/Resumes the countdown if no argument is provided.";
  13. public void Execute(IConsoleShell shell, string argStr, string[] args)
  14. {
  15. var ticker = _e.System<GameTicker>();
  16. if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
  17. {
  18. shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
  19. return;
  20. }
  21. if (args.Length == 0)
  22. {
  23. var paused = ticker.TogglePause();
  24. shell.WriteLine(paused ? "Paused the countdown." : "Resumed the countdown.");
  25. return;
  26. }
  27. if (args.Length != 1)
  28. {
  29. shell.WriteLine("Need zero or one arguments.");
  30. return;
  31. }
  32. if (!uint.TryParse(args[0], out var seconds) || seconds == 0)
  33. {
  34. shell.WriteLine($"{args[0]} isn't a valid amount of seconds.");
  35. return;
  36. }
  37. var time = TimeSpan.FromSeconds(seconds);
  38. if (!ticker.DelayStart(time))
  39. {
  40. shell.WriteLine("An unknown error has occurred.");
  41. }
  42. }
  43. }
  44. }