Actually fix round restart audio this time (#24754)

In which I'm a goober and don't clean up after
myself and accientally don't fix the issue I tried
to fix in my last round restart PR.

The audio is now maintained just like music during
restarts (yippee to ContentAudioSystem::OnRoundRestart)

This needs a refactor but at least the defect is fixed now.
This commit is contained in:
Hannah Giovanna Dawson
2024-02-03 02:11:53 +00:00
committed by GitHub
parent e7ee364af3
commit 2e7d23674e
4 changed files with 28 additions and 19 deletions

View File

@@ -26,7 +26,8 @@ public sealed class BackgroundAudioSystem : EntitySystem
private readonly AudioParams _lobbyParams = new(-5f, 1, "Master", 0, 0, 0, true, 0f);
public EntityUid? LobbyStream;
public EntityUid? LobbyMusicStream;
public EntityUid? LobbyRoundRestartAudioStream;
public override void Initialize()
{
@@ -115,7 +116,7 @@ public sealed class BackgroundAudioSystem : EntitySystem
public void StartLobbyMusic()
{
if (LobbyStream != null || !_configManager.GetCVar(CCVars.LobbyMusicEnabled))
if (LobbyMusicStream != null || !_configManager.GetCVar(CCVars.LobbyMusicEnabled))
return;
var file = _gameTicker.LobbySong;
@@ -124,13 +125,16 @@ public sealed class BackgroundAudioSystem : EntitySystem
return;
}
LobbyStream = _audio.PlayGlobal(file, Filter.Local(), false,
LobbyMusicStream = _audio.PlayGlobal(
file,
Filter.Local(),
false,
_lobbyParams.WithVolume(_lobbyParams.Volume + SharedAudioSystem.GainToVolume(_configManager.GetCVar(CCVars.LobbyMusicVolume))))?.Entity;
}
private void EndLobbyMusic()
{
LobbyStream = _audio.Stop(LobbyStream);
LobbyMusicStream = _audio.Stop(LobbyMusicStream);
}
private void PlayRestartSound(RoundRestartCleanupEvent ev)
@@ -144,10 +148,11 @@ public sealed class BackgroundAudioSystem : EntitySystem
return;
}
var volume = _lobbyParams.WithVolume(_lobbyParams.Volume +
SharedAudioSystem.GainToVolume(
_configManager.GetCVar(CCVars.LobbyMusicVolume)));
_audio.PlayGlobal(file, Filter.Local(), false, volume);
LobbyRoundRestartAudioStream = _audio.PlayGlobal(
file,
Filter.Local(),
false,
_lobbyParams.WithVolume(_lobbyParams.Volume + SharedAudioSystem.GainToVolume(_configManager.GetCVar(CCVars.LobbyMusicVolume)))
)?.Entity;
}
}