From 85a26adcd651b58a81070fcb1dde51e9990d8c4f Mon Sep 17 00:00:00 2001 From: Matthias <32034333+DerSheppard@users.noreply.github.com> Date: Mon, 17 Oct 2022 06:56:10 +0200 Subject: [PATCH] Ambience no longer plays in the lobby (#11416) Co-authored-by: matthst <32034333+matthst@users.noreply.github.com> Co-authored-by: Matthias Steinletzberger --- Content.Client/Audio/BackgroundAudioSystem.cs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/Content.Client/Audio/BackgroundAudioSystem.cs b/Content.Client/Audio/BackgroundAudioSystem.cs index 8e5d856b73..d71eef1b88 100644 --- a/Content.Client/Audio/BackgroundAudioSystem.cs +++ b/Content.Client/Audio/BackgroundAudioSystem.cs @@ -135,7 +135,8 @@ namespace Content.Client.Audio private void EntParentChanged(ref EntParentChangedMessage message) { if(_playMan.LocalPlayer is null || _playMan.LocalPlayer.ControlledEntity != message.Entity || - !_timing.IsFirstTimePredicted) return; + !_timing.IsFirstTimePredicted) + return; // Check if we traversed to grid. CheckAmbience(message.Transform); @@ -143,15 +144,17 @@ namespace Content.Client.Audio private void ChangeAmbience(SoundCollectionPrototype newAmbience) { - if (_currentCollection == newAmbience) return; + if (_currentCollection == newAmbience) + return; _timerCancelTokenSource.Cancel(); _currentCollection = newAmbience; _timerCancelTokenSource = new(); Timer.Spawn(1500, () => { // If we traverse a few times then don't interrupt an existing song. - if (_playingCollection == _currentCollection) return; - EndAmbience(); + // If we are not in gameplay, don't call StartAmbience because of player movement + if (_playingCollection == _currentCollection || _stateManager.CurrentState is not GameplayState) + return; StartAmbience(); }, _timerCancelTokenSource.Token); } @@ -299,7 +302,8 @@ namespace Content.Client.Audio public void StartLobbyMusic() { - if (_lobbyStream != null || !_configManager.GetCVar(CCVars.LobbyMusicEnabled)) return; + if (_lobbyStream != null || !_configManager.GetCVar(CCVars.LobbyMusicEnabled)) + return; var file = _gameTicker.LobbySong; if (file == null) // We have not received the lobby song yet.