Make lobby song update occur at round end (#19303)
This commit is contained in:
@@ -34,7 +34,7 @@ public sealed class BackgroundAudioSystem : EntitySystem
|
||||
|
||||
_client.PlayerLeaveServer += OnLeave;
|
||||
|
||||
_gameTicker.LobbyStatusUpdated += LobbySongReceived;
|
||||
_gameTicker.LobbySongUpdated += LobbySongUpdated;
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
@@ -48,7 +48,7 @@ public sealed class BackgroundAudioSystem : EntitySystem
|
||||
|
||||
_client.PlayerLeaveServer -= OnLeave;
|
||||
|
||||
_gameTicker.LobbyStatusUpdated -= LobbySongReceived;
|
||||
_gameTicker.LobbySongUpdated -= LobbySongUpdated;
|
||||
|
||||
EndLobbyMusic();
|
||||
}
|
||||
@@ -95,17 +95,9 @@ public sealed class BackgroundAudioSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
private void LobbySongReceived()
|
||||
private void LobbySongUpdated()
|
||||
{
|
||||
if (_lobbyStream != null) //Toggling Ready status fires this method. This check ensures we only start the lobby music if it's not playing.
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (_stateManager.CurrentState is LobbyState)
|
||||
{
|
||||
StartLobbyMusic();
|
||||
}
|
||||
RestartLobbyMusic();
|
||||
}
|
||||
|
||||
public void RestartLobbyMusic()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Content.Client.Audio;
|
||||
using Content.Client.Gameplay;
|
||||
using Content.Client.Lobby;
|
||||
using Content.Client.RoundEnd;
|
||||
@@ -8,7 +7,6 @@ using Content.Shared.GameWindow;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.State;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -21,7 +19,6 @@ namespace Content.Client.GameTicking.Managers
|
||||
[Dependency] private readonly IStateManager _stateManager = default!;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IConfigurationManager _configManager = default!;
|
||||
[Dependency] private readonly BackgroundAudioSystem _backgroundAudio = default!;
|
||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
||||
|
||||
[ViewVariables] private bool _initialized;
|
||||
@@ -49,6 +46,7 @@ namespace Content.Client.GameTicking.Managers
|
||||
|
||||
public event Action? InfoBlobUpdated;
|
||||
public event Action? LobbyStatusUpdated;
|
||||
public event Action? LobbySongUpdated;
|
||||
public event Action? LobbyLateJoinStatusUpdated;
|
||||
public event Action<IReadOnlyDictionary<EntityUid, Dictionary<string, uint?>>>? LobbyJobsAvailableUpdated;
|
||||
|
||||
@@ -73,6 +71,16 @@ namespace Content.Client.GameTicking.Managers
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
public void SetLobbySong(string? song, bool forceUpdate = false)
|
||||
{
|
||||
var updated = song != LobbySong;
|
||||
|
||||
LobbySong = song;
|
||||
|
||||
if (updated || forceUpdate)
|
||||
LobbySongUpdated?.Invoke();
|
||||
}
|
||||
|
||||
private void LateJoinStatus(TickerLateJoinStatusEvent message)
|
||||
{
|
||||
DisallowedLateJoin = message.Disallowed;
|
||||
@@ -97,7 +105,7 @@ namespace Content.Client.GameTicking.Managers
|
||||
RoundStartTimeSpan = message.RoundStartTimeSpan;
|
||||
IsGameStarted = message.IsRoundStarted;
|
||||
AreWeReady = message.YouAreReady;
|
||||
LobbySong = message.LobbySong;
|
||||
SetLobbySong(message.LobbySong);
|
||||
LobbyBackground = message.LobbyBackground;
|
||||
Paused = message.Paused;
|
||||
|
||||
@@ -124,12 +132,8 @@ namespace Content.Client.GameTicking.Managers
|
||||
|
||||
private void RoundEnd(RoundEndMessageEvent message)
|
||||
{
|
||||
if (message.LobbySong != null)
|
||||
{
|
||||
LobbySong = message.LobbySong;
|
||||
_backgroundAudio.StartLobbyMusic();
|
||||
}
|
||||
|
||||
// Force an update in the event of this song being the same as the last.
|
||||
SetLobbySong(message.LobbySong, true);
|
||||
RestartSound = message.RestartSound;
|
||||
|
||||
// Don't open duplicate windows (mainly for replays).
|
||||
|
||||
@@ -323,6 +323,12 @@ namespace Content.Server.GameTicking
|
||||
|
||||
RunLevel = GameRunLevel.PostRound;
|
||||
|
||||
// The lobby song is set here instead of in RestartRound,
|
||||
// because ShowRoundEndScoreboard triggers the start of the music playing
|
||||
// at the end of a round, and this needs to be set before RestartRound
|
||||
// in order for the lobby song status display to be accurate.
|
||||
LobbySong = _robustRandom.Pick(_lobbyMusicCollection.PickFiles).ToString();
|
||||
|
||||
ShowRoundEndScoreboard(text);
|
||||
}
|
||||
|
||||
@@ -453,7 +459,6 @@ namespace Content.Server.GameTicking
|
||||
PlayersJoinedRoundNormally = 0;
|
||||
|
||||
RunLevel = GameRunLevel.PreRoundLobby;
|
||||
LobbySong = _robustRandom.Pick(_lobbyMusicCollection.PickFiles).ToString();
|
||||
RandomizeLobbyBackground();
|
||||
ResettingCleanup();
|
||||
IncrementRoundNumber();
|
||||
|
||||
Reference in New Issue
Block a user