Audio fixes (#22324)

This commit is contained in:
metalgearsloth
2023-12-11 21:26:55 +11:00
committed by GitHub
parent 26a1198d3a
commit 1bdf94da64
5 changed files with 46 additions and 5 deletions

View File

@@ -1,5 +1,6 @@
using Content.Shared.Audio;
using Content.Shared.CCVar;
using Content.Shared.GameTicking;
using Robust.Client.GameObjects;
using Robust.Shared;
using Robust.Shared.Audio;
@@ -37,6 +38,24 @@ public sealed partial class ContentAudioSystem : SharedContentAudioSystem
base.Initialize();
UpdatesOutsidePrediction = true;
InitializeAmbientMusic();
SubscribeNetworkEvent<RoundRestartCleanupEvent>(OnRoundCleanup);
}
private void OnRoundCleanup(RoundRestartCleanupEvent ev)
{
_fadingOut.Clear();
// Preserve lobby music but everything else should get dumped.
var lobbyStream = EntityManager.System<BackgroundAudioSystem>().LobbyStream;
TryComp(lobbyStream, out AudioComponent? audioComp);
var oldGain = audioComp?.Gain;
SilenceAudio();
if (oldGain != null)
{
Audio.SetGain(lobbyStream, oldGain.Value, audioComp);
}
}
public override void Shutdown()