Refactor lobby status (#10550)

This commit is contained in:
wrexbe
2022-08-14 12:54:49 -07:00
committed by GitHub
parent c535214aa2
commit c4d135e253
15 changed files with 126 additions and 108 deletions

View File

@@ -1,11 +1,12 @@
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
namespace Content.Server.GameTicking
{
public sealed partial class GameTicker
{
[ViewVariables]
public bool LobbyEnabled { get; private set; } = false;
public bool LobbyEnabled { get; private set; }
[ViewVariables]
public bool DummyTicker { get; private set; } = false;
@@ -32,7 +33,17 @@ namespace Content.Server.GameTicking
private void InitializeCVars()
{
_configurationManager.OnValueChanged(CCVars.GameLobbyEnabled, value => LobbyEnabled = value, true);
_configurationManager.OnValueChanged(CCVars.GameLobbyEnabled, value =>
{
LobbyEnabled = value;
foreach (var (userId, status) in _playerGameStatuses)
{
if (status == PlayerGameStatus.JoinedGame)
continue;
_playerGameStatuses[userId] =
LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay;
}
}, true);
_configurationManager.OnValueChanged(CCVars.GameDummyTicker, value => DummyTicker = value, true);
_configurationManager.OnValueChanged(CCVars.GameLobbyDuration, value => LobbyDuration = TimeSpan.FromSeconds(value), true);
_configurationManager.OnValueChanged(CCVars.GameDisallowLateJoins,