Fix AudioSystem nullability checks for engine PR (#32233)

This commit is contained in:
Leon Friedrich
2024-09-18 13:43:30 +12:00
committed by GitHub
parent 675a9197f2
commit 974c08596b
11 changed files with 21 additions and 16 deletions

View File

@@ -47,10 +47,11 @@ public sealed class WeatherSystem : SharedWeatherSystem
if (!Timing.IsFirstTimePredicted || weatherProto.Sound == null)
return;
weather.Stream ??= _audio.PlayGlobal(weatherProto.Sound, Filter.Local(), true).Value.Entity;
weather.Stream ??= _audio.PlayGlobal(weatherProto.Sound, Filter.Local(), true)?.Entity;
if (!TryComp(weather.Stream, out AudioComponent? comp))
return;
var stream = weather.Stream.Value;
var comp = Comp<AudioComponent>(stream);
var occlusion = 0f;
// Work out tiles nearby to determine volume.
@@ -115,7 +116,7 @@ public sealed class WeatherSystem : SharedWeatherSystem
var alpha = GetPercent(weather, uid);
alpha *= SharedAudioSystem.VolumeToGain(weatherProto.Sound.Params.Volume);
_audio.SetGain(stream, alpha, comp);
_audio.SetGain(weather.Stream, alpha, comp);
comp.Occlusion = occlusion;
}