2022-05-13 00:59:03 -07:00
|
|
|
|
using Content.Server.Administration;
|
2021-12-21 21:23:29 +01:00
|
|
|
|
using Content.Server.GameTicking.Presets;
|
2020-12-20 04:48:13 +01:00
|
|
|
|
using Content.Shared.Administration;
|
2021-06-13 14:52:40 +02:00
|
|
|
|
using Content.Shared.CCVar;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.Configuration;
|
2021-02-01 16:49:43 -08:00
|
|
|
|
using Robust.Shared.Console;
|
2020-12-20 04:48:13 +01:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Server.GameTicking.Commands
|
2020-12-20 04:48:13 +01:00
|
|
|
|
{
|
2021-11-29 14:40:10 -06:00
|
|
|
|
[AdminCommand(AdminFlags.Round)]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class GoLobbyCommand : IConsoleCommand
|
2020-12-20 04:48:13 +01:00
|
|
|
|
{
|
2024-05-12 17:34:52 -07:00
|
|
|
|
[Dependency] private readonly IEntityManager _e = default!;
|
|
|
|
|
|
|
2020-12-20 04:48:13 +01:00
|
|
|
|
public string Command => "golobby";
|
|
|
|
|
|
public string Description => "Enables the lobby and restarts the round.";
|
|
|
|
|
|
public string Help => $"Usage: {Command} / {Command} <preset>";
|
2021-02-01 16:49:43 -08:00
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-12-20 04:48:13 +01:00
|
|
|
|
{
|
2021-12-21 21:23:29 +01:00
|
|
|
|
GamePresetPrototype? preset = null;
|
2020-12-20 04:48:13 +01:00
|
|
|
|
var presetName = string.Join(" ", args);
|
|
|
|
|
|
|
2024-05-12 17:34:52 -07:00
|
|
|
|
var ticker = _e.System<GameTicker>();
|
2020-12-20 04:48:13 +01:00
|
|
|
|
|
|
|
|
|
|
if (args.Length > 0)
|
|
|
|
|
|
{
|
2021-12-21 21:23:29 +01:00
|
|
|
|
if (!ticker.TryFindGamePreset(presetName, out preset))
|
2020-12-20 04:48:13 +01:00
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine($"No preset found with name {presetName}");
|
2020-12-20 04:48:13 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var config = IoCManager.Resolve<IConfigurationManager>();
|
|
|
|
|
|
config.SetCVar(CCVars.GameLobbyEnabled, true);
|
|
|
|
|
|
|
|
|
|
|
|
ticker.RestartRound();
|
|
|
|
|
|
|
|
|
|
|
|
if (preset != null)
|
|
|
|
|
|
{
|
2021-12-21 21:23:29 +01:00
|
|
|
|
ticker.SetGamePreset(preset);
|
2020-12-20 04:48:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine($"Enabling the lobby and restarting the round.{(preset == null ? "" : $"\nPreset set to {presetName}")}");
|
2020-12-20 04:48:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|