diff --git a/Robust.Server/Audio/AudioSystem.cs b/Robust.Server/Audio/AudioSystem.cs index bc91a0466db..6d5bcc274eb 100644 --- a/Robust.Server/Audio/AudioSystem.cs +++ b/Robust.Server/Audio/AudioSystem.cs @@ -186,7 +186,7 @@ public override (EntityUid Entity, AudioComponent Component)? PlayPredicted(Soun if (sound == null) return null; - var audio = PlayPvs(GetSound(sound), source, audioParams ?? sound.Params); + var audio = PlayPvs(ResolveSound(sound), source, audioParams ?? sound.Params); if (audio == null) return null; @@ -201,7 +201,7 @@ public override (EntityUid Entity, AudioComponent Component)? PlayPredicted(Soun if (sound == null) return null; - var audio = PlayPvs(GetSound(sound), coordinates, audioParams ?? sound.Params); + var audio = PlayPvs(ResolveSound(sound), coordinates, audioParams ?? sound.Params); if (audio == null) return null; diff --git a/Robust.Shared/Audio/Systems/SharedAudioSystem.cs b/Robust.Shared/Audio/Systems/SharedAudioSystem.cs index 5fd14a2a90c..327417df6f1 100644 --- a/Robust.Shared/Audio/Systems/SharedAudioSystem.cs +++ b/Robust.Shared/Audio/Systems/SharedAudioSystem.cs @@ -271,9 +271,9 @@ public float GetAudioDistance(float length) } /// - /// Resolves the filepath to a sound file. + /// Resolve a sound specifier so it can be consistently played back on all clients. /// - public ResolvedSoundSpecifier GetSound(SoundSpecifier specifier) + public ResolvedSoundSpecifier ResolveSound(SoundSpecifier specifier) { switch (specifier) { @@ -294,8 +294,19 @@ public ResolvedSoundSpecifier GetSound(SoundSpecifier specifier) return new ResolvedPathSpecifier(string.Empty); } + /// + /// Resolves the filepath to a sound file. + /// + [Obsolete("Use ResolveSound() and pass around resolved sound specifiers instead.")] + public string GetSound(SoundSpecifier specifier) + { + var resolved = ResolveSound(specifier); + return GetAudioPath(resolved); + } + #region AudioParams + [return: NotNullIfNotNull(nameof(specifier))] public string? GetAudioPath(ResolvedSoundSpecifier? specifier) { return specifier switch { @@ -442,7 +453,7 @@ public TimeSpan GetAudioLength(ResolvedSoundSpecifier specifier) /// The set of players that will hear the sound. public (EntityUid Entity, Components.AudioComponent Component)? PlayGlobal(SoundSpecifier? sound, Filter playerFilter, bool recordReplay, AudioParams? audioParams = null) { - return sound == null ? null : PlayGlobal(GetSound(sound), playerFilter, recordReplay, audioParams ?? sound.Params); + return sound == null ? null : PlayGlobal(ResolveSound(sound), playerFilter, recordReplay, audioParams ?? sound.Params); } /// @@ -459,7 +470,7 @@ public TimeSpan GetAudioLength(ResolvedSoundSpecifier specifier) /// The player that will hear the sound. public (EntityUid Entity, Components.AudioComponent Component)? PlayGlobal(SoundSpecifier? sound, ICommonSession recipient, AudioParams? audioParams = null) { - return sound == null ? null : PlayGlobal(GetSound(sound), recipient, audioParams ?? sound.Params); + return sound == null ? null : PlayGlobal(ResolveSound(sound), recipient, audioParams ?? sound.Params); } public abstract void LoadStream(Entity entity, T stream); @@ -478,7 +489,7 @@ public TimeSpan GetAudioLength(ResolvedSoundSpecifier specifier) /// The player that will hear the sound. public (EntityUid Entity, Components.AudioComponent Component)? PlayGlobal(SoundSpecifier? sound, EntityUid recipient, AudioParams? audioParams = null) { - return sound == null ? null : PlayGlobal(GetSound(sound), recipient, audioParams ?? sound.Params); + return sound == null ? null : PlayGlobal(ResolveSound(sound), recipient, audioParams ?? sound.Params); } /// @@ -513,7 +524,7 @@ public TimeSpan GetAudioLength(ResolvedSoundSpecifier specifier) /// The UID of the entity "emitting" the audio. public (EntityUid Entity, Components.AudioComponent Component)? PlayEntity(SoundSpecifier? sound, Filter playerFilter, EntityUid uid, bool recordReplay, AudioParams? audioParams = null) { - return sound == null ? null : PlayEntity(GetSound(sound), playerFilter, uid, recordReplay, audioParams ?? sound.Params); + return sound == null ? null : PlayEntity(ResolveSound(sound), playerFilter, uid, recordReplay, audioParams ?? sound.Params); } /// @@ -524,7 +535,7 @@ public TimeSpan GetAudioLength(ResolvedSoundSpecifier specifier) /// The UID of the entity "emitting" the audio. public (EntityUid Entity, Components.AudioComponent Component)? PlayEntity(SoundSpecifier? sound, ICommonSession recipient, EntityUid uid, AudioParams? audioParams = null) { - return sound == null ? null : PlayEntity(GetSound(sound), recipient, uid, audioParams ?? sound.Params); + return sound == null ? null : PlayEntity(ResolveSound(sound), recipient, uid, audioParams ?? sound.Params); } /// @@ -535,7 +546,7 @@ public TimeSpan GetAudioLength(ResolvedSoundSpecifier specifier) /// The UID of the entity "emitting" the audio. public (EntityUid Entity, Components.AudioComponent Component)? PlayEntity(SoundSpecifier? sound, EntityUid recipient, EntityUid uid, AudioParams? audioParams = null) { - return sound == null ? null : PlayEntity(GetSound(sound), recipient, uid, audioParams ?? sound.Params); + return sound == null ? null : PlayEntity(ResolveSound(sound), recipient, uid, audioParams ?? sound.Params); } /// @@ -545,7 +556,7 @@ public TimeSpan GetAudioLength(ResolvedSoundSpecifier specifier) /// The UID of the entity "emitting" the audio. public (EntityUid Entity, Components.AudioComponent Component)? PlayPvs(SoundSpecifier? sound, EntityUid uid, AudioParams? audioParams = null) { - return sound == null ? null : PlayPvs(GetSound(sound), uid, audioParams ?? sound.Params); + return sound == null ? null : PlayPvs(ResolveSound(sound), uid, audioParams ?? sound.Params); } /// @@ -555,7 +566,7 @@ public TimeSpan GetAudioLength(ResolvedSoundSpecifier specifier) /// The EntityCoordinates to attach the audio source to. public (EntityUid Entity, Components.AudioComponent Component)? PlayPvs(SoundSpecifier? sound, EntityCoordinates coordinates, AudioParams? audioParams = null) { - return sound == null ? null : PlayPvs(GetSound(sound), coordinates, audioParams ?? sound.Params); + return sound == null ? null : PlayPvs(ResolveSound(sound), coordinates, audioParams ?? sound.Params); } /// @@ -634,7 +645,7 @@ public abstract (EntityUid Entity, Components.AudioComponent Component)? PlayPvs /// The coordinates at which to play the audio. public (EntityUid Entity, Components.AudioComponent Component)? PlayStatic(SoundSpecifier? sound, Filter playerFilter, EntityCoordinates coordinates, bool recordReplay, AudioParams? audioParams = null) { - return sound == null ? null : PlayStatic(GetSound(sound), playerFilter, coordinates, recordReplay, audioParams); + return sound == null ? null : PlayStatic(ResolveSound(sound), playerFilter, coordinates, recordReplay, audioParams); } /// @@ -645,7 +656,7 @@ public abstract (EntityUid Entity, Components.AudioComponent Component)? PlayPvs /// The coordinates at which to play the audio. public (EntityUid Entity, Components.AudioComponent Component)? PlayStatic(SoundSpecifier? sound, ICommonSession recipient, EntityCoordinates coordinates, AudioParams? audioParams = null) { - return sound == null ? null : PlayStatic(GetSound(sound), recipient, coordinates, audioParams ?? sound.Params); + return sound == null ? null : PlayStatic(ResolveSound(sound), recipient, coordinates, audioParams ?? sound.Params); } /// @@ -656,7 +667,7 @@ public abstract (EntityUid Entity, Components.AudioComponent Component)? PlayPvs /// The coordinates at which to play the audio. public (EntityUid Entity, Components.AudioComponent Component)? PlayStatic(SoundSpecifier? sound, EntityUid recipient, EntityCoordinates coordinates, AudioParams? audioParams = null) { - return sound == null ? null : PlayStatic(GetSound(sound), recipient, coordinates, audioParams ?? sound.Params); + return sound == null ? null : PlayStatic(ResolveSound(sound), recipient, coordinates, audioParams ?? sound.Params); } // These are just here for replays now.