Fix a few warnings (#11576)

This commit is contained in:
metalgearsloth
2022-10-04 14:24:19 +11:00
committed by GitHub
parent a6d20803a6
commit 600c0e3255
43 changed files with 185 additions and 167 deletions

View File

@@ -24,7 +24,8 @@ namespace Content.Client.Audio
/// </summary>
public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
{
[Dependency] private EntityLookupSystem _lookup = default!;
[Dependency] private readonly EntityLookupSystem _lookup = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
@@ -43,7 +44,7 @@ namespace Content.Client.Audio
/// </summary>
private int MaxSingleSound => (int) (_maxAmbientCount / (16.0f / 6.0f));
private Dictionary<AmbientSoundComponent, (IPlayingAudioStream? Stream, string Sound)> _playingSounds = new();
private readonly Dictionary<AmbientSoundComponent, (IPlayingAudioStream? Stream, string Sound)> _playingSounds = new();
private const float RangeBuffer = 3f;
@@ -58,7 +59,7 @@ namespace Content.Client.Audio
if (_overlayEnabled)
{
_overlay = new AmbientSoundOverlay(EntityManager, this, Get<EntityLookupSystem>());
_overlay = new AmbientSoundOverlay(EntityManager, this, EntityManager.System<EntityLookupSystem>());
overlayManager.AddOverlay(_overlay);
}
else
@@ -119,7 +120,8 @@ namespace Content.Client.Audio
foreach (var (_, (_, sound)) in _playingSounds)
{
if (sound.Equals(countSound)) count++;
if (sound.Equals(countSound))
count++;
}
return count;
@@ -180,7 +182,7 @@ namespace Content.Client.Audio
continue;
}
var key = ambientComp.Sound.GetSound();
var key = _audio.GetSound(ambientComp.Sound);
if (!sourceDict.ContainsKey(key))
sourceDict[key] = new List<AmbientSoundComponent>(MaxSingleSound);
@@ -188,6 +190,7 @@ namespace Content.Client.Audio
sourceDict[key].Add(ambientComp);
}
// TODO: Just store the distance from above...
foreach (var (key, val) in sourceDict)
{
sourceDict[key] = val.OrderByDescending(x =>
@@ -236,7 +239,7 @@ namespace Content.Client.Audio
if (_playingSounds.ContainsKey(comp))
continue;
var sound = comp.Sound.GetSound();
var sound = _audio.GetSound(comp.Sound);
if (PlayingCount(sound) >= MaxSingleSound)
{
@@ -250,7 +253,7 @@ namespace Content.Client.Audio
continue;
}
var audioParams = AudioHelpers
var audioParams = AudioParams.Default
.WithVariation(0.01f)
.WithVolume(comp.Volume + _ambienceVolume)
.WithLoop(true)
@@ -259,9 +262,7 @@ namespace Content.Client.Audio
.WithPlayOffset(_random.NextFloat(0.0f, 100.0f))
.WithMaxDistance(comp.Range);
var stream = SoundSystem.Play(sound,
Filter.Local(),
comp.Owner, audioParams);
var stream = _audio.PlayPvs(comp.Sound, comp.Owner, audioParams);
if (stream == null) continue;

View File

@@ -30,6 +30,7 @@ namespace Content.Client.Audio
[Dependency] private readonly IRobustRandom _robustRandom = default!;
[Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly ClientGameTicker _gameTicker = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
private readonly AudioParams _ambientParams = new(-10f, 1, "Master", 0, 0, 0, true, 0f);
private readonly AudioParams _lobbyParams = new(-5f, 1, "Master", 0, 0, 0, true, 0f);
@@ -211,7 +212,8 @@ namespace Content.Client.Audio
return;
_playingCollection = _currentCollection;
var file = _robustRandom.Pick(_currentCollection.PickFiles).ToString();
_ambientStream = SoundSystem.Play(file, Filter.Local(), _ambientParams.WithVolume(_ambientParams.Volume + _configManager.GetCVar(CCVars.AmbienceVolume)));
_ambientStream = _audio.PlayGlobal(file, Filter.Local(),
_ambientParams.WithVolume(_ambientParams.Volume + _configManager.GetCVar(CCVars.AmbienceVolume)));
}
private void EndAmbience()
@@ -304,7 +306,8 @@ namespace Content.Client.Audio
{
return;
}
_lobbyStream = SoundSystem.Play(file, Filter.Local(), _lobbyParams);
_lobbyStream = _audio.PlayGlobal(file, Filter.Local(), _lobbyParams);
}
private void EndLobbyMusic()

View File

@@ -10,6 +10,7 @@ namespace Content.Client.Audio;
public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
{
[Dependency] private readonly IConfigurationManager _cfg = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
// Admin music
private bool _adminAudioEnabled = true;
@@ -64,7 +65,7 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
{
if(!_adminAudioEnabled) return;
var stream = SoundSystem.Play(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams);
var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams);
_adminAudio.Add(stream);
}
@@ -73,13 +74,13 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
// Either the cvar is disabled or it's already playing
if(!_eventAudioEnabled || _eventAudio.ContainsKey(soundEvent.Type)) return;
var stream = SoundSystem.Play(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams);
var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams);
_eventAudio.Add(soundEvent.Type, stream);
}
private void PlayGameSound(GameGlobalSoundEvent soundEvent)
{
SoundSystem.Play(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams);
_audio.PlayGlobal(soundEvent.Filename, Filter.Local(), soundEvent.AudioParams);
}
private void StopStationEventMusic(StopStationEventMusic soundEvent)