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:
committed by
GitHub
parent
e7ee364af3
commit
2e7d23674e
@@ -26,7 +26,8 @@ public sealed class BackgroundAudioSystem : EntitySystem
|
|||||||
|
|
||||||
private readonly AudioParams _lobbyParams = new(-5f, 1, "Master", 0, 0, 0, true, 0f);
|
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()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -115,7 +116,7 @@ public sealed class BackgroundAudioSystem : EntitySystem
|
|||||||
|
|
||||||
public void StartLobbyMusic()
|
public void StartLobbyMusic()
|
||||||
{
|
{
|
||||||
if (LobbyStream != null || !_configManager.GetCVar(CCVars.LobbyMusicEnabled))
|
if (LobbyMusicStream != null || !_configManager.GetCVar(CCVars.LobbyMusicEnabled))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var file = _gameTicker.LobbySong;
|
var file = _gameTicker.LobbySong;
|
||||||
@@ -124,13 +125,16 @@ public sealed class BackgroundAudioSystem : EntitySystem
|
|||||||
return;
|
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;
|
_lobbyParams.WithVolume(_lobbyParams.Volume + SharedAudioSystem.GainToVolume(_configManager.GetCVar(CCVars.LobbyMusicVolume))))?.Entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void EndLobbyMusic()
|
private void EndLobbyMusic()
|
||||||
{
|
{
|
||||||
LobbyStream = _audio.Stop(LobbyStream);
|
LobbyMusicStream = _audio.Stop(LobbyMusicStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void PlayRestartSound(RoundRestartCleanupEvent ev)
|
private void PlayRestartSound(RoundRestartCleanupEvent ev)
|
||||||
@@ -144,10 +148,11 @@ public sealed class BackgroundAudioSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var volume = _lobbyParams.WithVolume(_lobbyParams.Volume +
|
LobbyRoundRestartAudioStream = _audio.PlayGlobal(
|
||||||
SharedAudioSystem.GainToVolume(
|
file,
|
||||||
_configManager.GetCVar(CCVars.LobbyMusicVolume)));
|
Filter.Local(),
|
||||||
|
false,
|
||||||
_audio.PlayGlobal(file, Filter.Local(), false, volume);
|
_lobbyParams.WithVolume(_lobbyParams.Volume + SharedAudioSystem.GainToVolume(_configManager.GetCVar(CCVars.LobbyMusicVolume)))
|
||||||
|
)?.Entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,15 +50,24 @@ public sealed partial class ContentAudioSystem : SharedContentAudioSystem
|
|||||||
_fadingOut.Clear();
|
_fadingOut.Clear();
|
||||||
|
|
||||||
// Preserve lobby music but everything else should get dumped.
|
// Preserve lobby music but everything else should get dumped.
|
||||||
var lobbyStream = EntityManager.System<BackgroundAudioSystem>().LobbyStream;
|
var lobbyMusic = EntityManager.System<BackgroundAudioSystem>().LobbyMusicStream;
|
||||||
TryComp(lobbyStream, out AudioComponent? audioComp);
|
TryComp(lobbyMusic, out AudioComponent? lobbyMusicComp);
|
||||||
var oldGain = audioComp?.Gain;
|
var oldMusicGain = lobbyMusicComp?.Gain;
|
||||||
|
|
||||||
|
var restartAudio = EntityManager.System<BackgroundAudioSystem>().LobbyRoundRestartAudioStream;
|
||||||
|
TryComp(restartAudio, out AudioComponent? restartComp);
|
||||||
|
var oldAudioGain = restartComp?.Gain;
|
||||||
|
|
||||||
SilenceAudio();
|
SilenceAudio();
|
||||||
|
|
||||||
if (oldGain != null)
|
if (oldMusicGain != null)
|
||||||
{
|
{
|
||||||
Audio.SetGain(lobbyStream, oldGain.Value, audioComp);
|
Audio.SetGain(lobbyMusic, oldMusicGain.Value, lobbyMusicComp);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (oldAudioGain != null)
|
||||||
|
{
|
||||||
|
Audio.SetGain(restartAudio, oldAudioGain.Value, restartComp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,8 +20,6 @@ namespace Content.Client.GameTicking.Managers
|
|||||||
{
|
{
|
||||||
[Dependency] private readonly IStateManager _stateManager = default!;
|
[Dependency] private readonly IStateManager _stateManager = default!;
|
||||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||||
[Dependency] private readonly IConfigurationManager _configManager = default!;
|
|
||||||
[Dependency] private readonly SharedAudioSystem _audio = default!;
|
|
||||||
|
|
||||||
[ViewVariables] private bool _initialized;
|
[ViewVariables] private bool _initialized;
|
||||||
private Dictionary<NetEntity, Dictionary<string, uint?>> _jobsAvailable = new();
|
private Dictionary<NetEntity, Dictionary<string, uint?>> _jobsAvailable = new();
|
||||||
|
|||||||
@@ -525,9 +525,6 @@ namespace Content.Server.GameTicking
|
|||||||
{
|
{
|
||||||
_playerGameStatuses[session.UserId] = LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay;
|
_playerGameStatuses[session.UserId] = LobbyEnabled ? PlayerGameStatus.NotReadyToPlay : PlayerGameStatus.ReadyToPlay;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Put a bangin' donk on it.
|
|
||||||
_audio.PlayGlobal(_audio.GetSound(new SoundCollectionSpecifier("RoundEnd")), Filter.Broadcast(), true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool DelayStart(TimeSpan time)
|
public bool DelayStart(TimeSpan time)
|
||||||
|
|||||||
Reference in New Issue
Block a user