GoLobbyCommand.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. using Content.Server.Administration;
  2. using Content.Server.GameTicking.Presets;
  3. using Content.Shared.Administration;
  4. using Content.Shared.CCVar;
  5. using Robust.Shared.Configuration;
  6. using Robust.Shared.Console;
  7. namespace Content.Server.GameTicking.Commands
  8. {
  9. [AdminCommand(AdminFlags.Round)]
  10. public sealed class GoLobbyCommand : IConsoleCommand
  11. {
  12. [Dependency] private readonly IEntityManager _e = default!;
  13. public string Command => "golobby";
  14. public string Description => "Enables the lobby and restarts the round.";
  15. public string Help => $"Usage: {Command} / {Command} <preset>";
  16. public void Execute(IConsoleShell shell, string argStr, string[] args)
  17. {
  18. GamePresetPrototype? preset = null;
  19. var presetName = string.Join(" ", args);
  20. var ticker = _e.System<GameTicker>();
  21. if (args.Length > 0)
  22. {
  23. if (!ticker.TryFindGamePreset(presetName, out preset))
  24. {
  25. shell.WriteLine($"No preset found with name {presetName}");
  26. return;
  27. }
  28. }
  29. var config = IoCManager.Resolve<IConfigurationManager>();
  30. config.SetCVar(CCVars.GameLobbyEnabled, true);
  31. ticker.RestartRound();
  32. if (preset != null)
  33. {
  34. ticker.SetGamePreset(preset);
  35. }
  36. shell.WriteLine($"Enabling the lobby and restarting the round.{(preset == null ? "" : $"\nPreset set to {presetName}")}");
  37. }
  38. }
  39. }