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:
@@ -186,10 +186,10 @@ namespace Content.Client.Lobby
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Lobby!.StartTime.Text = string.Empty;
|
Lobby!.StartTime.Text = string.Empty;
|
||||||
|
Lobby!.ReadyButton.Pressed = _gameTicker.AreWeReady;
|
||||||
Lobby!.ReadyButton.Text = Loc.GetString(Lobby!.ReadyButton.Pressed ? "lobby-state-player-status-ready": "lobby-state-player-status-not-ready");
|
Lobby!.ReadyButton.Text = Loc.GetString(Lobby!.ReadyButton.Pressed ? "lobby-state-player-status-ready": "lobby-state-player-status-not-ready");
|
||||||
Lobby!.ReadyButton.ToggleMode = true;
|
Lobby!.ReadyButton.ToggleMode = true;
|
||||||
Lobby!.ReadyButton.Disabled = false;
|
Lobby!.ReadyButton.Disabled = false;
|
||||||
Lobby!.ReadyButton.Pressed = _gameTicker.AreWeReady;
|
|
||||||
Lobby!.ObserveButton.Disabled = true;
|
Lobby!.ObserveButton.Disabled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
using Content.Server.GameTicking;
|
|
||||||
using Content.Shared.Administration;
|
|
||||||
using Content.Shared.GameTicking;
|
|
||||||
using Robust.Shared.Console;
|
|
||||||
|
|
||||||
namespace Content.Server.Administration.Commands
|
|
||||||
{
|
|
||||||
[AdminCommand(AdminFlags.Round)]
|
|
||||||
public sealed class ReadyAll : IConsoleCommand
|
|
||||||
{
|
|
||||||
[Dependency] private readonly IEntityManager _e = default!;
|
|
||||||
|
|
||||||
public string Command => "readyall";
|
|
||||||
public string Description => "Readies up all players in the lobby, except for observers.";
|
|
||||||
public string Help => $"{Command} | ̣{Command} <ready>";
|
|
||||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
||||||
{
|
|
||||||
var ready = true;
|
|
||||||
|
|
||||||
if (args.Length > 0)
|
|
||||||
{
|
|
||||||
ready = bool.Parse(args[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
var gameTicker = _e.System<GameTicker>();
|
|
||||||
|
|
||||||
|
|
||||||
if (gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
|
|
||||||
{
|
|
||||||
shell.WriteLine("This command can only be ran while in the lobby!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
gameTicker.ToggleReadyAll(ready);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
32
Content.Server/Administration/Commands/ReadyAllCommand.cs
Normal file
32
Content.Server/Administration/Commands/ReadyAllCommand.cs
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
using Content.Server.GameTicking;
|
||||||
|
using Content.Shared.Administration;
|
||||||
|
using Robust.Shared.Console;
|
||||||
|
|
||||||
|
namespace Content.Server.Administration.Commands;
|
||||||
|
|
||||||
|
[AdminCommand(AdminFlags.Round)]
|
||||||
|
public sealed class ReadyAllCommand : LocalizedEntityCommands
|
||||||
|
{
|
||||||
|
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||||
|
|
||||||
|
public override string Command => "readyall";
|
||||||
|
|
||||||
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
|
{
|
||||||
|
var ready = true;
|
||||||
|
|
||||||
|
if (_gameTicker.RunLevel != GameRunLevel.PreRoundLobby)
|
||||||
|
{
|
||||||
|
shell.WriteError(Loc.GetString("shell-can-only-run-from-pre-round-lobby"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.Length > 0 && !bool.TryParse(args[0], out ready))
|
||||||
|
{
|
||||||
|
shell.WriteError(Loc.GetString("shell-argument-must-be-boolean"));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_gameTicker.ToggleReadyAll(ready);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,32 +1,41 @@
|
|||||||
using Content.Shared.Administration;
|
using Content.Shared.Administration;
|
||||||
using Robust.Shared.Console;
|
using Robust.Shared.Console;
|
||||||
|
|
||||||
namespace Content.Server.GameTicking.Commands
|
namespace Content.Server.GameTicking.Commands;
|
||||||
|
|
||||||
|
[AnyCommand]
|
||||||
|
public sealed class ToggleReadyCommand : LocalizedEntityCommands
|
||||||
{
|
{
|
||||||
[AnyCommand]
|
[Dependency] private readonly GameTicker _gameTicker = default!;
|
||||||
sealed class ToggleReadyCommand : IConsoleCommand
|
|
||||||
|
public override string Command => "toggleready";
|
||||||
|
|
||||||
|
public override void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||||
{
|
{
|
||||||
[Dependency] private readonly IEntityManager _e = default!;
|
if (args.Length != 1)
|
||||||
|
|
||||||
public string Command => "toggleready";
|
|
||||||
public string Description => "";
|
|
||||||
public string Help => "";
|
|
||||||
|
|
||||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
|
||||||
{
|
{
|
||||||
var player = shell.Player;
|
shell.WriteError(Loc.GetString("shell-need-exactly-one-argument"));
|
||||||
if (args.Length != 1)
|
return;
|
||||||
{
|
|
||||||
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]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -173,7 +173,6 @@ namespace Content.Server.GameTicking
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var status = ready ? PlayerGameStatus.ReadyToPlay : PlayerGameStatus.NotReadyToPlay;
|
|
||||||
_playerGameStatuses[player.UserId] = ready ? PlayerGameStatus.ReadyToPlay : PlayerGameStatus.NotReadyToPlay;
|
_playerGameStatuses[player.UserId] = ready ? PlayerGameStatus.ReadyToPlay : PlayerGameStatus.NotReadyToPlay;
|
||||||
RaiseNetworkEvent(GetStatusMsg(player), player.Channel);
|
RaiseNetworkEvent(GetStatusMsg(player), player.Channel);
|
||||||
// update server info to reflect new ready count
|
// update server info to reflect new ready count
|
||||||
|
|||||||
2
Resources/Locale/en-US/commands/readyall-command.ftl
Normal file
2
Resources/Locale/en-US/commands/readyall-command.ftl
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
cmd-readyall-desc = Readies up all players in the lobby, except for observers.
|
||||||
|
cmd-readyall-help = Usage: readyall [bool]
|
||||||
2
Resources/Locale/en-US/commands/toggleready-command.ftl
Normal file
2
Resources/Locale/en-US/commands/toggleready-command.ftl
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
cmd-toggleready-desc = Toggle the players ready status.
|
||||||
|
cmd-toggleready-help = Usage: toggleready <ready>
|
||||||
Reference in New Issue
Block a user