64 SDL_AudioDeviceID device_ = 0;
66 std::array<SoundClip, static_cast<size_t>(
SfxId::_Count)> clips_;
71 SDL_AudioStream* stream =
nullptr;
74 float duration = 0.0f;
77 static constexpr int kMaxVoices = 32;
78 std::array<Voice, kMaxVoices> voices_{};
80 float masterVolume_ = 0.8f;
84 std::array<float, static_cast<size_t>(
SfxId::_Count)> cooldowns_{};
87 float prevHealth_ = 100.0f;
88 float prevArmor_ = 100.0f;
91 float healingSoundCooldown_ = 0.0f;
92 bool stateInitialized_ =
false;
95 bool loadClip(
SfxId id,
const char* filename,
SfxCategory cat,
float gain,
float cooldownSecs);
98 Voice* acquireVoice();
101 float effectiveGain(
SfxId id,
float extraGain)
const;
Event structs dispatched via entt::dispatcher for particle spawning.
Shared ECS registry type alias for the game engine.
entt::registry Registry
Shared ECS registry type alias.
Definition Registry.hpp:11
Sound effect identifiers, categories, and the SoundClip data type.
SfxId
Identifies a loaded sound clip.
Definition SfxTypes.hpp:13
SfxCategory
Sound category for per-category volume control.
Definition SfxTypes.hpp:48
Client-side sound effects system.
Definition SfxSystem.hpp:28
void setMasterVolume(float v)
Definition SfxSystem.hpp:51
bool init()
Initialise SDL audio subsystem, open default playback device, load all clips.
Definition SfxSystem.cpp:96
void quit()
Destroy all active streams, close the audio device, quit audio subsystem.
Definition SfxSystem.cpp:166
void setCategoryVolume(SfxCategory cat, float v)
Definition SfxSystem.cpp:253
float categoryVolume(SfxCategory cat) const
Definition SfxSystem.cpp:258
void play(SfxId id, float gain=1.0f)
Play a sound immediately.
Definition SfxSystem.cpp:188
void onExplosion(const ExplosionEvent &e)
Definition SfxSystem.cpp:286
void update(float dt, const Registry ®istry)
Per-frame update: decrement cooldowns, retire finished voices, detect state changes.
Definition SfxSystem.cpp:295
void onWeaponFired(const WeaponFiredEvent &e)
Definition SfxSystem.cpp:267
float masterVolume() const
Definition SfxSystem.hpp:53
void stop(SfxId id)
Stop all active voices playing the given sound.
Definition SfxSystem.cpp:239
bool isInitialized() const
True after a successful init().
Definition SfxSystem.hpp:61
Emitted when a rocket/grenade explodes.
Definition ParticleEvents.hpp:33
Emitted when a weapon fires (both hitscan and projectile).
Definition ParticleEvents.hpp:13