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

@@ -37,7 +37,7 @@ namespace Content.Client.GameTicking.Managers
[ViewVariables] public TimeSpan StartTime { get; private set; }
[ViewVariables] public TimeSpan RoundStartTimeSpan { get; private set; }
[ViewVariables] public new bool Paused { get; private set; }
[ViewVariables] public Dictionary<NetUserId, LobbyPlayerStatus> Status { get; private set; } = new();
[ViewVariables] public IReadOnlyDictionary<EntityUid, Dictionary<string, uint?>> JobsAvailable => _jobsAvailable;
[ViewVariables] public IReadOnlyDictionary<EntityUid, string> StationNames => _stationNames;
@@ -66,7 +66,6 @@ namespace Content.Client.GameTicking.Managers
SubscribeNetworkEvent<TickerJobsAvailableEvent>(UpdateJobsAvailable);
SubscribeNetworkEvent<RoundRestartCleanupEvent>(RoundRestartCleanup);
Status = new Dictionary<NetUserId, LobbyPlayerStatus>();
_initialized = true;
}
@@ -97,8 +96,6 @@ namespace Content.Client.GameTicking.Managers
LobbySong = message.LobbySong;
LobbyBackground = message.LobbyBackground;
Paused = message.Paused;
if (IsGameStarted)
Status.Clear();
LobbyStatusUpdated?.Invoke();
}
@@ -123,11 +120,6 @@ namespace Content.Client.GameTicking.Managers
private void LobbyReady(TickerLobbyReadyEvent message)
{
// Merge the Dictionaries
foreach (var p in message.Status)
{
Status[p.Key] = p.Value;
}
LobbyReadyUpdated?.Invoke();
}

View File

@@ -109,7 +109,6 @@ namespace Content.Client.Lobby
_lobby.OptionsButton.OnPressed += _ => new OptionsMenu().Open();
_playerManager.PlayerListUpdated += PlayerManagerOnPlayerListUpdated;
_gameTicker.InfoBlobUpdated += UpdateLobbyUi;
_gameTicker.LobbyStatusUpdated += LobbyStatusUpdated;
_gameTicker.LobbyLateJoinStatusUpdated += LobbyLateJoinStatusUpdated;
@@ -117,7 +116,6 @@ namespace Content.Client.Lobby
public override void Shutdown()
{
_playerManager.PlayerListUpdated -= PlayerManagerOnPlayerListUpdated;
_gameTicker.InfoBlobUpdated -= UpdateLobbyUi;
_gameTicker.LobbyStatusUpdated -= LobbyStatusUpdated;
_gameTicker.LobbyLateJoinStatusUpdated -= LobbyLateJoinStatusUpdated;
@@ -164,23 +162,6 @@ namespace Content.Client.Lobby
_lobby.StartTime.Text = Loc.GetString("lobby-state-round-start-countdown-text", ("timeLeft", text));
}
private void PlayerManagerOnPlayerListUpdated(object? sender, EventArgs e)
{
var gameTicker = EntitySystem.Get<ClientGameTicker>();
// Remove disconnected sessions from the Ready Dict
foreach (var p in gameTicker.Status)
{
if (!_playerManager.SessionsDict.TryGetValue(p.Key, out _))
{
// This is a shitty fix. Observers can rejoin because they are already in the game.
// So we don't delete them, but keep them if they decide to rejoin
if (p.Value != LobbyPlayerStatus.Observer)
gameTicker.Status.Remove(p.Key);
}
}
}
private void LobbyStatusUpdated()
{
UpdateLobbyBackground();