2020-12-03 03:40:47 +01:00
|
|
|
|
using Content.Server.Administration;
|
2021-12-21 21:23:29 +01:00
|
|
|
|
using Content.Server.GameTicking.Presets;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
using Content.Shared.Administration;
|
2021-02-01 16:49:43 -08:00
|
|
|
|
using Robust.Shared.Console;
|
2021-06-20 10:09:24 +02:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-12-03 03:40:47 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Server.GameTicking.Commands
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
2021-11-29 14:40:10 -06:00
|
|
|
|
[AdminCommand(AdminFlags.Round)]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
sealed class ForcePresetCommand : IConsoleCommand
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
|
|
|
|
|
public string Command => "forcepreset";
|
|
|
|
|
|
public string Description => "Forces a specific game preset to start for the current lobby.";
|
|
|
|
|
|
public string Help => $"Usage: {Command} <preset>";
|
|
|
|
|
|
|
2021-02-01 16:49:43 -08:00
|
|
|
|
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
2021-06-20 10:09:24 +02:00
|
|
|
|
var ticker = EntitySystem.Get<GameTicker>();
|
2020-12-03 03:40:47 +01:00
|
|
|
|
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
|
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine("This can only be executed while the game is in the pre-round lobby.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (args.Length != 1)
|
|
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine("Need exactly one argument.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
var name = args[0];
|
2021-12-21 21:23:29 +01:00
|
|
|
|
if (!ticker.TryFindGamePreset(name, out var type))
|
2020-12-03 03:40:47 +01:00
|
|
|
|
{
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine($"No preset exists with name {name}.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-12-21 21:23:29 +01:00
|
|
|
|
ticker.SetGamePreset(type, true);
|
2021-02-01 16:49:43 -08:00
|
|
|
|
shell.WriteLine($"Forced the game to start with preset {name}.");
|
2020-12-03 03:40:47 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2021-02-14 15:39:24 +01:00
|
|
|
|
}
|