Explosion SFX juicing + higher persistence (#22544)

This commit is contained in:
Kara
2023-12-16 20:31:21 +01:00
committed by Debug
parent 5f40220304
commit 276af8dc9b
40 changed files with 154 additions and 20 deletions
@@ -63,7 +63,7 @@ public sealed partial class ExplosionSystem : EntitySystem
/// </summary>
public const ushort DefaultTileSize = 1;
private AudioParams _audioParams = AudioParams.Default.WithVolume(-3f);
public const int MaxExplosionAudioRange = 30;
/// <summary>
/// The "default" explosion prototype.
@@ -328,15 +328,33 @@ public sealed partial class ExplosionSystem : EntitySystem
var visualEnt = CreateExplosionVisualEntity(epicenter, type.ID, spaceMatrix, spaceData, gridData.Values, iterationIntensity);
// camera shake
CameraShake(iterationIntensity.Count * 2.5f, epicenter, totalIntensity);
CameraShake(iterationIntensity.Count * 4f, epicenter, totalIntensity);
//For whatever bloody reason, sound system requires ENTITY coordinates.
var mapEntityCoords = EntityCoordinates.FromMap(EntityManager, _mapManager.GetMapEntityId(epicenter.MapId), epicenter);
// play sound.
var audioRange = iterationIntensity.Count * 5;
// for the normal audio, we want everyone in pvs range
// + 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
var audioRange = Math.Min(iterationIntensity.Count * 2, MaxExplosionAudioRange);
var filter = Filter.Pvs(epicenter).AddInRange(epicenter, audioRange);
_audio.PlayStatic(type.Sound.GetSound(), filter, mapEntityCoords, true, _audioParams);
var sound = iterationIntensity.Count < type.SmallSoundIterationThreshold
? type.SmallSound
: type.Sound;
_audio.PlayStatic(sound, filter, mapEntityCoords, true, sound.Params);
// play far sound
// far sound should play for anyone who wasn't in range of any of the effects of the bomb
var farAudioRange = iterationIntensity.Count * 5;
var farFilter = Filter.Empty().AddInRange(epicenter, farAudioRange).RemoveInRange(epicenter, audioRange);
var farSound = iterationIntensity.Count < type.SmallSoundIterationThreshold
? type.SmallSoundFar
: type.SoundFar;
_audio.PlayGlobal(farSound, farFilter, true, farSound.Params);
return new Explosion(this,
type,