Unrevert audio (#21330)
Co-authored-by: Pieter-Jan Briers <pieterjan.briers@gmail.com>
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.GameTicking;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Audio.Systems;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
@@ -14,11 +15,11 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
|
||||
|
||||
// Admin music
|
||||
private bool _adminAudioEnabled = true;
|
||||
private List<IPlayingAudioStream?> _adminAudio = new(1);
|
||||
private List<EntityUid?> _adminAudio = new(1);
|
||||
|
||||
// Event sounds (e.g. nuke timer)
|
||||
private bool _eventAudioEnabled = true;
|
||||
private Dictionary<StationEventMusicType, IPlayingAudioStream?> _eventAudio = new(1);
|
||||
private Dictionary<StationEventMusicType, EntityUid?> _eventAudio = new(1);
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -49,13 +50,13 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
|
||||
{
|
||||
foreach (var stream in _adminAudio)
|
||||
{
|
||||
stream?.Stop();
|
||||
_audio.Stop(stream);
|
||||
}
|
||||
_adminAudio.Clear();
|
||||
|
||||
foreach (var (_, stream) in _eventAudio)
|
||||
foreach (var stream in _eventAudio.Values)
|
||||
{
|
||||
stream?.Stop();
|
||||
_audio.Stop(stream);
|
||||
}
|
||||
|
||||
_eventAudio.Clear();
|
||||
@@ -66,7 +67,7 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
|
||||
if(!_adminAudioEnabled) return;
|
||||
|
||||
var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
|
||||
_adminAudio.Add(stream);
|
||||
_adminAudio.Add(stream.Value.Entity);
|
||||
}
|
||||
|
||||
private void PlayStationEventMusic(StationEventMusicEvent soundEvent)
|
||||
@@ -75,7 +76,7 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
|
||||
if(!_eventAudioEnabled || _eventAudio.ContainsKey(soundEvent.Type)) return;
|
||||
|
||||
var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
|
||||
_eventAudio.Add(soundEvent.Type, stream);
|
||||
_eventAudio.Add(soundEvent.Type, stream.Value.Entity);
|
||||
}
|
||||
|
||||
private void PlayGameSound(GameGlobalSoundEvent soundEvent)
|
||||
@@ -85,8 +86,10 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
|
||||
|
||||
private void StopStationEventMusic(StopStationEventMusic soundEvent)
|
||||
{
|
||||
if (!_eventAudio.TryGetValue(soundEvent.Type, out var stream)) return;
|
||||
stream?.Stop();
|
||||
if (!_eventAudio.TryGetValue(soundEvent.Type, out var stream))
|
||||
return;
|
||||
|
||||
_audio.Stop(stream);
|
||||
_eventAudio.Remove(soundEvent.Type);
|
||||
}
|
||||
|
||||
@@ -96,7 +99,7 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
|
||||
if (_adminAudioEnabled) return;
|
||||
foreach (var stream in _adminAudio)
|
||||
{
|
||||
stream?.Stop();
|
||||
_audio.Stop(stream);
|
||||
}
|
||||
_adminAudio.Clear();
|
||||
}
|
||||
@@ -107,7 +110,7 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
|
||||
if (_eventAudioEnabled) return;
|
||||
foreach (var stream in _eventAudio)
|
||||
{
|
||||
stream.Value?.Stop();
|
||||
_audio.Stop(stream.Value);
|
||||
}
|
||||
_eventAudio.Clear();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user