Minor - Adds FMOD integration for audio support - V13.4.0

Initializes FMOD sound system within the application class and propagates it to the entity manager and entities. This allows for audio components to access and use the FMOD system for playing sounds.

Removes redundant FMOD system initialization from the audio component.
This commit is contained in:
2025-09-16 16:34:08 +02:00
parent 42b7ca04a4
commit f875580197
6 changed files with 44 additions and 23 deletions

View File

@@ -16,7 +16,7 @@
namespace ecs {
class AudioComponent : public Component {
public:
AudioComponent() : m_system(nullptr), m_sound(nullptr), m_channel(nullptr) {}
AudioComponent() : m_sound(nullptr), m_channel(nullptr) {}
~AudioComponent() override {
if (m_sound) m_sound->release();
// Ne pas lib<69>rer m_system ici car il peut <20>tre partag<61>
@@ -24,27 +24,12 @@ public:
void Initialize() override
{
// create FMOD system if not already created
if (!m_system)
{
FMOD_RESULT result = FMOD::System_Create(&m_system);
if (result != FMOD_OK) {
m_lastError = "<EFBFBD>chec de la cr<63>ation du syst<73>me FMOD: " + std::to_string(result);
return;
}
result = m_system->init(512, FMOD_INIT_NORMAL | FMOD_INIT_3D_RIGHTHANDED, nullptr);
if (result != FMOD_OK) {
m_lastError = "<EFBFBD>chec de l'initialisation du syst<73>me FMOD: " + std::to_string(result);
m_system->release();
m_system = nullptr;
}
}
auto parent = GetParent();
if (parent && parent->GetCamera())
{
SetCamera(parent->GetCamera());
SetSoundSystem(parent->GetSoundSystem());
}
}
@@ -392,7 +377,9 @@ public:
}
}
void SetSoundSystem(FMOD::System* system) {
m_system = system;
}
private:
FMOD::System* m_system;