Readyall and Toggleready commands to LEC. Fix an issue with ready button desync. (#38706)

* commit

* commit

* change lobby shell string.
This commit is contained in:
Kyle Tyo
2025-09-16 17:25:17 -04:00
committed by GitHub
parent bf18b5e26b
commit 7ff98dd94f
7 changed files with 69 additions and 62 deletions

View File

@@ -1,32 +1,41 @@
using Content.Shared.Administration;
using Robust.Shared.Console;
namespace Content.Server.GameTicking.Commands
namespace Content.Server.GameTicking.Commands;
[AnyCommand]
public sealed class ToggleReadyCommand : LocalizedEntityCommands
{
[AnyCommand]
sealed class ToggleReadyCommand : IConsoleCommand
[Dependency] private readonly GameTicker _gameTicker = default!;
public override string Command => "toggleready";
public override void Execute(IConsoleShell shell, string argStr, string[] args)
{
[Dependency] private readonly IEntityManager _e = default!;
public string Command => "toggleready";
public string Description => "";
public string Help => "";
public void Execute(IConsoleShell shell, string argStr, string[] args)
if (args.Length != 1)
{
var player = shell.Player;
if (args.Length != 1)
{
shell.WriteError(Loc.GetString("shell-wrong-arguments-number"));
return;
}
if (player == null)
{
return;
}
var ticker = _e.System<GameTicker>();
ticker.ToggleReady(player, bool.Parse(args[0]));
shell.WriteError(Loc.GetString("shell-need-exactly-one-argument"));
return;
}
if (shell.Player is not { } player)
{
shell.WriteError(Loc.GetString("shell-only-players-can-run-this-command"));
return;
}
if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
{
shell.WriteError(Loc.GetString("shell-can-only-run-from-pre-round-lobby"));
return;
}
if (!bool.TryParse(args[0], out var ready))
{
shell.WriteError(Loc.GetString("shell-argument-must-be-boolean"));
return;
}
_gameTicker.ToggleReady(player, ready);
}
}