Add delaystart and forcepreset commands (#1163)
* Add extendroundstart message to extend lobby start timer * Rename StartExtend to DelayStart * Fix delaystart amounts above 59 not working * Change delaystart seconds type from int to uint * Change delaystart wrong args amount message * Add forcegamepreset command * Rename forcegamepreset to forcepreset and merged start and forcestart preset methods * Fix index out of bounds exception when forcing suspicion to start * Change game preset to match regardless of casing * Add forcepreset unknown preset message * Add and move in lobby checks * Remove testing changes * Change delaystart to pause/resume the timer when no seconds are specified * Change pause message * Remove testing code * Change 0 seconds to not be a valid amount of seconds * Replace MsgTickerLobbyCountdown Seconds with DateTime instead of uint * Add one entire dot * Replace Math.Min + Math.Max with Math.Clamp Co-authored-by: ComicIronic <comicironic@gmail.com> Co-authored-by: ComicIronic <comicironic@gmail.com>
This commit is contained in:
@@ -9,6 +9,47 @@ using Robust.Shared.Network;
|
||||
|
||||
namespace Content.Server.GameTicking
|
||||
{
|
||||
class DelayStartCommand : IClientCommand
|
||||
{
|
||||
public string Command => "delaystart";
|
||||
public string Description => "Delays the round start.";
|
||||
public string Help => $"Usage: {Command} <seconds>\nPauses/Resumes the countdown if no argument is provided.";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
|
||||
{
|
||||
var ticker = IoCManager.Resolve<IGameTicker>();
|
||||
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
|
||||
{
|
||||
shell.SendText(player, "This can only be executed while the game is in the pre-round lobby.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length == 0)
|
||||
{
|
||||
var paused = ticker.TogglePause();
|
||||
shell.SendText(player, paused ? "Paused the countdown." : "Resumed the countdown.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.SendText(player, "Need zero or one arguments.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!uint.TryParse(args[0], out var seconds) || seconds == 0)
|
||||
{
|
||||
shell.SendText(player, $"{args[0]} isn't a valid amount of seconds.");
|
||||
return;
|
||||
}
|
||||
|
||||
var time = TimeSpan.FromSeconds(seconds);
|
||||
if (!ticker.DelayStart(time))
|
||||
{
|
||||
shell.SendText(player, "An unknown error has occurred.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class StartRoundCommand : IClientCommand
|
||||
{
|
||||
@@ -193,4 +234,37 @@ namespace Content.Server.GameTicking
|
||||
ticker.SetStartPreset(args[0]);
|
||||
}
|
||||
}
|
||||
|
||||
class ForcePresetCommand : IClientCommand
|
||||
{
|
||||
public string Command => "forcepreset";
|
||||
public string Description => "Forces a specific game preset to start for the current lobby.";
|
||||
public string Help => $"Usage: {Command} <preset>";
|
||||
|
||||
public void Execute(IConsoleShell shell, IPlayerSession player, string[] args)
|
||||
{
|
||||
var ticker = IoCManager.Resolve<IGameTicker>();
|
||||
if (ticker.RunLevel != GameRunLevel.PreRoundLobby)
|
||||
{
|
||||
shell.SendText(player, "This can only be executed while the game is in the pre-round lobby.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.Length != 1)
|
||||
{
|
||||
shell.SendText(player, "Need exactly one argument.");
|
||||
return;
|
||||
}
|
||||
|
||||
var name = args[0];
|
||||
if (!ticker.TryGetPreset(name, out var type))
|
||||
{
|
||||
shell.SendText(player, $"No preset exists with name {name}.");
|
||||
return;
|
||||
}
|
||||
|
||||
ticker.SetStartPreset(type, true);
|
||||
shell.SendText(player, $"Forced the game to start with preset {name}.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user