// + if the bomb is big enough, people outside of it too
// this is capped to 30 because otherwise really huge bombs
// will attempt to play regular audio for people who can't hear it anyway because the epicenter is so far away
+ //
+ // TODO EXPLOSION redo this.
+ // Use the Filter.Pvs range-multiplier option instead of AddInRange.
+ // Also the default PVS range is 25*2 = 50. So capping it at 30 makes no sense here.
+ // So actually maybe don't use Filter.Pvs at all and only use AddInRange?
var audioRange = Math.Min(iterationIntensity.Count * 2, MaxExplosionAudioRange);
var filter = Filter.Pvs(pos).AddInRange(pos, audioRange);
var sound = iterationIntensity.Count < queued.Proto.SmallSoundIterationThreshold
QueueDel(gib);
}
- _audio.PlayEntity(component.SpikeSound, Filter.Pvs(uid), uid, true);
+ _audio.PlayPvs(component.SpikeSound, uid);
}
private bool TryGetPiece(EntityUid uid, EntityUid user, EntityUid used,
if (time > light.LastThunk + ThunkDelay)
{
light.LastThunk = time;
- _audio.PlayEntity(light.TurnOnSound, Filter.Pvs(uid), uid, true, AudioParams.Default.WithVolume(-10f));
+ _audio.PlayPvs(light.TurnOnSound, uid, light.TurnOnSound.Params.AddVolume(-10f));
}
}
else
private void OnClearButtonPressed(EntityUid uid, NukeComponent component, NukeKeypadClearMessage args)
{
- _audio.PlayEntity(component.KeypadPressSound, Filter.Pvs(uid), uid, true);
+ _audio.PlayPvs(component.KeypadPressSound, uid);
if (component.Status != NukeStatus.AWAIT_CODE)
return;
{
component.Status = NukeStatus.AWAIT_ARM;
component.RemainingTime = component.Timer;
- _audio.PlayEntity(component.AccessGrantedSound, Filter.Pvs(uid), uid, true);
+ _audio.PlayPvs(component.AccessGrantedSound, uid);
}
else
{
component.EnteredCode = "";
- _audio.PlayEntity(component.AccessDeniedSound, Filter.Pvs(uid), uid, true);
+ _audio.PlayPvs(component.AccessDeniedSound, uid);
}
break;
// Don't double-dip on the octave shifting
component.LastPlayedKeypadSemitones = number == 0 ? component.LastPlayedKeypadSemitones : semitoneShift;
- _audio.PlayEntity(component.KeypadPressSound, Filter.Pvs(uid), uid, true, AudioHelpers.ShiftSemitone(semitoneShift).WithVolume(-5f));
+ var opts = component.KeypadPressSound.Params;
+ opts = AudioHelpers.ShiftSemitone(opts, semitoneShift).AddVolume(-5f);
+ _audio.PlayPvs(component.KeypadPressSound, uid, opts);
}
public string GenerateRandomNumberString(int length)
var clogged = _generator.GetIsClogged(uid);
var sound = empty ? component.StartSoundEmpty : component.StartSound;
- _audio.PlayEntity(sound, Filter.Pvs(uid), uid, true);
+ _audio.PlayPvs(sound, uid);
if (!clogged && !empty && _random.Prob(component.StartChance))
{
namespace Content.Shared.Audio
{
- public static class AudioHelpers{
+ public static class AudioHelpers
+ {
/// <summary>
/// Returns a random pitch.
/// </summary>
- [Obsolete("Use variation datafield.")]
+ [Obsolete("Use AudioParams.Variation data-field")]
public static AudioParams WithVariation(float amplitude)
{
return WithVariation(amplitude, null);
/// <summary>
/// Returns a random pitch.
/// </summary>
+ [Obsolete("Use AudioParams.Variation data-field")]
public static AudioParams WithVariation(float amplitude, IRobustRandom? rand)
{
IoCManager.Resolve(ref rand);
/// </summary>
/// <param name="shift">Number of semitones to shift, positive or negative. Clamped between -12 and 12
/// which correspond to a pitch multiplier of 0.5 and 2.0 respectively.</param>
- public static AudioParams ShiftSemitone(int shift)
+ public static AudioParams ShiftSemitone(AudioParams @params, int shift)
{
shift = MathHelper.Clamp(shift, -12, 12);
float pitchMult = SemitoneMultipliers[shift + 12];
- return AudioParams.Default.WithPitchScale(pitchMult);
+ return @params.WithPitchScale(pitchMult);
}
/// <summary>
/// Returns a pitch multiplier shifted by a random number of semitones within variation.
/// </summary>
/// <param name="variation">Max number of semitones to shift in either direction. Values above 12 have no effect.</param>
- public static AudioParams WithSemitoneVariation(int variation, IRobustRandom? rand)
+ public static AudioParams WithSemitoneVariation(AudioParams @params, int variation, IRobustRandom rand)
{
IoCManager.Resolve(ref rand);
variation = Math.Clamp(variation, 0, 12);
- return ShiftSemitone(rand.Next(-variation, variation));
+ return ShiftSemitone(@params, rand.Next(-variation, variation));
}
}
}