diff --git a/Content.Client/Audio/AmbientSoundSystem.cs b/Content.Client/Audio/AmbientSoundSystem.cs index ca6336b91b..b525747aa9 100644 --- a/Content.Client/Audio/AmbientSoundSystem.cs +++ b/Content.Client/Audio/AmbientSoundSystem.cs @@ -306,6 +306,9 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem .WithMaxDistance(comp.Range); var stream = _audio.PlayEntity(comp.Sound, Filter.Local(), uid, false, audioParams); + if (stream == null) + continue; + _playingSounds[sourceEntity] = (stream.Value.Entity, comp.Sound, key); playingCount++; diff --git a/Content.Client/Audio/ClientGlobalSoundSystem.cs b/Content.Client/Audio/ClientGlobalSoundSystem.cs index 6619285a96..50c3971d95 100644 --- a/Content.Client/Audio/ClientGlobalSoundSystem.cs +++ b/Content.Client/Audio/ClientGlobalSoundSystem.cs @@ -67,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!.Value.Entity); + _adminAudio.Add(stream?.Entity); } private void PlayStationEventMusic(StationEventMusicEvent soundEvent) @@ -76,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!.Value.Entity); + _eventAudio.Add(soundEvent.Type, stream?.Entity); } private void PlayGameSound(GameGlobalSoundEvent soundEvent) diff --git a/Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs b/Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs index 6a1606ad71..22b138594a 100644 --- a/Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs +++ b/Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs @@ -213,9 +213,9 @@ public sealed partial class ContentAudioSystem false, AudioParams.Default.WithVolume(_musicProto.Sound.Params.Volume + _volumeSlider))!; - _ambientMusicStream = strim.Value.Entity; + _ambientMusicStream = strim?.Entity; - if (_musicProto.FadeIn) + if (_musicProto.FadeIn && strim != null) { FadeIn(_ambientMusicStream, strim.Value.Component, AmbientMusicFadeTime); } diff --git a/Content.Client/Audio/ContentAudioSystem.LobbyMusic.cs b/Content.Client/Audio/ContentAudioSystem.LobbyMusic.cs index 60b81b1c2d..9864dbcb2a 100644 --- a/Content.Client/Audio/ContentAudioSystem.LobbyMusic.cs +++ b/Content.Client/Audio/ContentAudioSystem.LobbyMusic.cs @@ -185,11 +185,7 @@ public sealed partial class ContentAudioSystem false, _lobbySoundtrackParams.WithVolume(_lobbySoundtrackParams.Volume + SharedAudioSystem.GainToVolume(_configManager.GetCVar(CCVars.LobbyMusicVolume))) ); - if (playResult == null) - return; - - if (playResult!.Value.Entity == default) { _sawmill.Warning( $"Tried to play lobby soundtrack '{{Filename}}' using {nameof(SharedAudioSystem)}.{nameof(SharedAudioSystem.PlayGlobal)} but it returned default value of EntityUid!", diff --git a/Content.Client/Traits/ParacusiaSystem.cs b/Content.Client/Traits/ParacusiaSystem.cs index da60f1d65e..c516f3e7ea 100644 --- a/Content.Client/Traits/ParacusiaSystem.cs +++ b/Content.Client/Traits/ParacusiaSystem.cs @@ -1,4 +1,5 @@ using System.Numerics; +using Content.Shared.Traits.Assorted.Components; using Content.Shared.Traits.Assorted.Systems; using Robust.Shared.Random; using Robust.Client.Player; @@ -6,7 +7,6 @@ using Robust.Shared.Player; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; using Robust.Shared.Timing; -using Content.Shared.Traits.Assorted.Components; namespace Content.Client.Traits; @@ -68,13 +68,9 @@ public sealed class ParacusiaSystem : SharedParacusiaSystem ); var newCoords = Transform(uid).Coordinates.Offset(randomOffset); - var sound = _audio.PlayStatic(paracusia.Sounds, uid, newCoords); - - if (sound == null) - return; // Play the sound - paracusia.Stream = sound!.Value.Entity; + paracusia.Stream = _audio.PlayStatic(paracusia.Sounds, uid, newCoords)?.Entity; } } diff --git a/Content.Client/Weather/WeatherSystem.cs b/Content.Client/Weather/WeatherSystem.cs index 07523c1291..975831392c 100644 --- a/Content.Client/Weather/WeatherSystem.cs +++ b/Content.Client/Weather/WeatherSystem.cs @@ -44,11 +44,11 @@ public sealed class WeatherSystem : SharedWeatherSystem return; } - if (!Timing.IsFirstTimePredicted || weatherProto.Sound == null - || weather.Stream is not null) // Don't ever generate more than one weather sound. + if (!Timing.IsFirstTimePredicted || weatherProto.Sound == null) return; weather.Stream ??= _audio.PlayGlobal(weatherProto.Sound, Filter.Local(), true)?.Entity; + if (!TryComp(weather.Stream, out AudioComponent? comp)) return; diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index bad2a9e3f9..e8750fcec5 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -113,12 +113,8 @@ namespace Content.Server.Kitchen.EntitySystems return; SetAppearance(ent.Owner, MicrowaveVisualState.Cooking, microwaveComponent); - var audio = _audio.PlayPvs(microwaveComponent.LoopingSound, ent, AudioParams.Default.WithLoop(true).WithMaxDistance(5)); - - if (audio == null) - return; - - microwaveComponent.PlayingStream = audio!.Value.Entity; + microwaveComponent.PlayingStream = + _audio.PlayPvs(microwaveComponent.LoopingSound, ent, AudioParams.Default.WithLoop(true).WithMaxDistance(5))?.Entity; } private void OnCookStop(Entity ent, ref ComponentShutdown args) diff --git a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs index e7fc9f519d..223e45252c 100644 --- a/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs @@ -325,14 +325,8 @@ namespace Content.Server.Kitchen.EntitySystems active.EndTime = _timing.CurTime + reagentGrinder.WorkTime * reagentGrinder.WorkTimeMultiplier; active.Program = program; - // slightly higher pitched - var audio = _audioSystem.PlayPvs(sound, uid, - AudioParams.Default.WithPitchScale(1 / reagentGrinder.WorkTimeMultiplier)); - - if (audio == null) - return; - - reagentGrinder.AudioStream = audio!.Value.Entity; + reagentGrinder.AudioStream = _audioSystem.PlayPvs(sound, uid, + AudioParams.Default.WithPitchScale(1 / reagentGrinder.WorkTimeMultiplier))?.Entity; //slightly higher pitched _userInterfaceSystem.ServerSendUiMessage(uid, ReagentGrinderUiKey.Key, new ReagentGrinderWorkStartedMessage(program)); } diff --git a/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs b/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs index 76af41b2be..08120f5c29 100644 --- a/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs +++ b/Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs @@ -155,12 +155,7 @@ public sealed class MechGrabberSystem : EntitySystem return; args.Handled = true; - var audio = _audio.PlayPvs(component.GrabSound, uid); - - if (audio == null) - return; - - component.AudioStream = audio!.Value.Entity; + component.AudioStream = _audio.PlayPvs(component.GrabSound, uid)?.Entity; var doAfterArgs = new DoAfterArgs(EntityManager, args.User, component.GrabDelay, new GrabberDoAfterEvent(), uid, target: target, used: uid) { BreakOnMove = true diff --git a/Content.Server/Salvage/SalvageSystem.Runner.cs b/Content.Server/Salvage/SalvageSystem.Runner.cs index 19dd685d02..921d966709 100644 --- a/Content.Server/Salvage/SalvageSystem.Runner.cs +++ b/Content.Server/Salvage/SalvageSystem.Runner.cs @@ -155,11 +155,7 @@ public sealed partial class SalvageSystem else if (comp.Stream == null && remaining < audioLength) { var audio = _audio.PlayPvs(comp.Sound, uid); - - if (audio == null) - continue; - - comp.Stream = audio!.Value.Entity; + comp.Stream = audio?.Entity; _audio.SetMapAudio(audio); comp.Stage = ExpeditionStage.MusicCountdown; Dirty(uid, comp);