Fix AudioSystem nullability checks for engine PR (#32233)
This commit is contained in:
@@ -306,6 +306,9 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
|
|||||||
.WithMaxDistance(comp.Range);
|
.WithMaxDistance(comp.Range);
|
||||||
|
|
||||||
var stream = _audio.PlayEntity(comp.Sound, Filter.Local(), uid, false, audioParams);
|
var stream = _audio.PlayEntity(comp.Sound, Filter.Local(), uid, false, audioParams);
|
||||||
|
if (stream == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
_playingSounds[sourceEntity] = (stream.Value.Entity, comp.Sound, key);
|
_playingSounds[sourceEntity] = (stream.Value.Entity, comp.Sound, key);
|
||||||
playingCount++;
|
playingCount++;
|
||||||
|
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
|
|||||||
if(!_adminAudioEnabled) return;
|
if(!_adminAudioEnabled) return;
|
||||||
|
|
||||||
var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
|
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)
|
private void PlayStationEventMusic(StationEventMusicEvent soundEvent)
|
||||||
@@ -76,7 +76,7 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
|
|||||||
if(!_eventAudioEnabled || _eventAudio.ContainsKey(soundEvent.Type)) return;
|
if(!_eventAudioEnabled || _eventAudio.ContainsKey(soundEvent.Type)) return;
|
||||||
|
|
||||||
var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
|
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)
|
private void PlayGameSound(GameGlobalSoundEvent soundEvent)
|
||||||
|
|||||||
@@ -213,9 +213,9 @@ public sealed partial class ContentAudioSystem
|
|||||||
false,
|
false,
|
||||||
AudioParams.Default.WithVolume(_musicProto.Sound.Params.Volume + _volumeSlider));
|
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);
|
FadeIn(_ambientMusicStream, strim.Value.Component, AmbientMusicFadeTime);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ public sealed partial class ContentAudioSystem
|
|||||||
false,
|
false,
|
||||||
_lobbySoundtrackParams.WithVolume(_lobbySoundtrackParams.Volume + SharedAudioSystem.GainToVolume(_configManager.GetCVar(CCVars.LobbyMusicVolume)))
|
_lobbySoundtrackParams.WithVolume(_lobbySoundtrackParams.Volume + SharedAudioSystem.GainToVolume(_configManager.GetCVar(CCVars.LobbyMusicVolume)))
|
||||||
);
|
);
|
||||||
if (playResult.Value.Entity == default)
|
if (playResult == null)
|
||||||
{
|
{
|
||||||
_sawmill.Warning(
|
_sawmill.Warning(
|
||||||
$"Tried to play lobby soundtrack '{{Filename}}' using {nameof(SharedAudioSystem)}.{nameof(SharedAudioSystem.PlayGlobal)} but it returned default value of EntityUid!",
|
$"Tried to play lobby soundtrack '{{Filename}}' using {nameof(SharedAudioSystem)}.{nameof(SharedAudioSystem.PlayGlobal)} but it returned default value of EntityUid!",
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ public sealed class ParacusiaSystem : SharedParacusiaSystem
|
|||||||
var newCoords = Transform(uid).Coordinates.Offset(randomOffset);
|
var newCoords = Transform(uid).Coordinates.Offset(randomOffset);
|
||||||
|
|
||||||
// Play the sound
|
// Play the sound
|
||||||
paracusia.Stream = _audio.PlayStatic(paracusia.Sounds, uid, newCoords).Value.Entity;
|
paracusia.Stream = _audio.PlayStatic(paracusia.Sounds, uid, newCoords)?.Entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,10 +47,11 @@ public sealed class WeatherSystem : SharedWeatherSystem
|
|||||||
if (!Timing.IsFirstTimePredicted || weatherProto.Sound == null)
|
if (!Timing.IsFirstTimePredicted || weatherProto.Sound == null)
|
||||||
return;
|
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;
|
var occlusion = 0f;
|
||||||
|
|
||||||
// Work out tiles nearby to determine volume.
|
// Work out tiles nearby to determine volume.
|
||||||
@@ -115,7 +116,7 @@ public sealed class WeatherSystem : SharedWeatherSystem
|
|||||||
|
|
||||||
var alpha = GetPercent(weather, uid);
|
var alpha = GetPercent(weather, uid);
|
||||||
alpha *= SharedAudioSystem.VolumeToGain(weatherProto.Sound.Params.Volume);
|
alpha *= SharedAudioSystem.VolumeToGain(weatherProto.Sound.Params.Volume);
|
||||||
_audio.SetGain(stream, alpha, comp);
|
_audio.SetGain(weather.Stream, alpha, comp);
|
||||||
comp.Occlusion = occlusion;
|
comp.Occlusion = occlusion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -112,7 +112,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
SetAppearance(ent.Owner, MicrowaveVisualState.Cooking, microwaveComponent);
|
SetAppearance(ent.Owner, MicrowaveVisualState.Cooking, microwaveComponent);
|
||||||
|
|
||||||
microwaveComponent.PlayingStream =
|
microwaveComponent.PlayingStream =
|
||||||
_audio.PlayPvs(microwaveComponent.LoopingSound, ent, AudioParams.Default.WithLoop(true).WithMaxDistance(5)).Value.Entity;
|
_audio.PlayPvs(microwaveComponent.LoopingSound, ent, AudioParams.Default.WithLoop(true).WithMaxDistance(5))?.Entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnCookStop(Entity<ActiveMicrowaveComponent> ent, ref ComponentShutdown args)
|
private void OnCookStop(Entity<ActiveMicrowaveComponent> ent, ref ComponentShutdown args)
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
active.Program = program;
|
active.Program = program;
|
||||||
|
|
||||||
reagentGrinder.AudioStream = _audioSystem.PlayPvs(sound, uid,
|
reagentGrinder.AudioStream = _audioSystem.PlayPvs(sound, uid,
|
||||||
AudioParams.Default.WithPitchScale(1 / reagentGrinder.WorkTimeMultiplier)).Value.Entity; //slightly higher pitched
|
AudioParams.Default.WithPitchScale(1 / reagentGrinder.WorkTimeMultiplier))?.Entity; //slightly higher pitched
|
||||||
_userInterfaceSystem.ServerSendUiMessage(uid, ReagentGrinderUiKey.Key,
|
_userInterfaceSystem.ServerSendUiMessage(uid, ReagentGrinderUiKey.Key,
|
||||||
new ReagentGrinderWorkStartedMessage(program));
|
new ReagentGrinderWorkStartedMessage(program));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ public sealed class MechGrabberSystem : EntitySystem
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
args.Handled = true;
|
args.Handled = true;
|
||||||
component.AudioStream = _audio.PlayPvs(component.GrabSound, uid).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)
|
var doAfterArgs = new DoAfterArgs(EntityManager, args.User, component.GrabDelay, new GrabberDoAfterEvent(), uid, target: target, used: uid)
|
||||||
{
|
{
|
||||||
BreakOnMove = true
|
BreakOnMove = true
|
||||||
|
|||||||
@@ -154,8 +154,8 @@ public sealed partial class SalvageSystem
|
|||||||
}
|
}
|
||||||
else if (comp.Stream == null && remaining < audioLength)
|
else if (comp.Stream == null && remaining < audioLength)
|
||||||
{
|
{
|
||||||
var audio = _audio.PlayPvs(comp.Sound, uid).Value;
|
var audio = _audio.PlayPvs(comp.Sound, uid);
|
||||||
comp.Stream = audio.Entity;
|
comp.Stream = audio?.Entity;
|
||||||
_audio.SetMapAudio(audio);
|
_audio.SetMapAudio(audio);
|
||||||
comp.Stage = ExpeditionStage.MusicCountdown;
|
comp.Stage = ExpeditionStage.MusicCountdown;
|
||||||
Dirty(uid, comp);
|
Dirty(uid, comp);
|
||||||
|
|||||||
@@ -397,7 +397,8 @@ public sealed partial class ShuttleSystem
|
|||||||
new EntityCoordinates(fromMapUid.Value, _mapSystem.GetGridPosition(entity.Owner)), true, startupAudio.Params);
|
new EntityCoordinates(fromMapUid.Value, _mapSystem.GetGridPosition(entity.Owner)), true, startupAudio.Params);
|
||||||
|
|
||||||
_audio.SetPlaybackPosition(clippedAudio, entity.Comp1.StartupTime);
|
_audio.SetPlaybackPosition(clippedAudio, entity.Comp1.StartupTime);
|
||||||
clippedAudio.Value.Component.Flags |= AudioFlags.NoOcclusion;
|
if (clippedAudio != null)
|
||||||
|
clippedAudio.Value.Component.Flags |= AudioFlags.NoOcclusion;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Offset the start by buffer range just to avoid overlap.
|
// Offset the start by buffer range just to avoid overlap.
|
||||||
|
|||||||
Reference in New Issue
Block a user