From 7a0013696b3fa3c25346877d9743f7791be01f4e Mon Sep 17 00:00:00 2001 From: Aaron Kimbrell Date: Thu, 1 Oct 2026 08:10:56 -0500 Subject: [PATCH] refactor(component): the sound trigger reads its level config in LoadConfigData Co-Authored-By: Claude Opus 5.5 --- dGame/dComponents/SoundTriggerComponent.cpp | 17 ++++++++++------- dGame/dComponents/SoundTriggerComponent.h | 2 ++ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/dGame/dComponents/SoundTriggerComponent.cpp b/dGame/dComponents/SoundTriggerComponent.cpp index 384aeae2b..ef7aa8f64 100644 --- a/dGame/dComponents/SoundTriggerComponent.cpp +++ b/dGame/dComponents/SoundTriggerComponent.cpp @@ -26,32 +26,35 @@ void MixerProgram::Serialize(RakNet::BitStream& outBitStream){ outBitStream.Write(result); } SoundTriggerComponent::SoundTriggerComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) { +} - const auto musicCueName = parent->GetVar(u"NDAudioMusicCue_Name"); +// The level config: music cues and parameters, ambient sounds and mixer programs +void SoundTriggerComponent::LoadConfigData() { + const auto musicCueName = m_Parent->GetVar(u"NDAudioMusicCue_Name"); if (!musicCueName.empty()) { auto newCue = MusicCue(musicCueName); - const auto musicCueBoredomTime = parent->GetVar(u"NDAudioMusicCue_BoredomTime"); + const auto musicCueBoredomTime = m_Parent->GetVar(u"NDAudioMusicCue_BoredomTime"); if (musicCueBoredomTime) newCue.boredomTime = musicCueBoredomTime; this->m_MusicCues.push_back(newCue); } - const auto musicParameterName = parent->GetVar(u"NDAudioMusicParameter_Name"); + const auto musicParameterName = m_Parent->GetVar(u"NDAudioMusicParameter_Name"); if (!musicParameterName.empty()) { auto newParams = MusicParameter(musicParameterName); - const auto musicParameterValue = parent->GetVar(u"NDAudioMusicParameter_Value"); + const auto musicParameterValue = m_Parent->GetVar(u"NDAudioMusicParameter_Value"); if (musicParameterValue) newParams.value = musicParameterValue; this->m_MusicParameters.push_back(newParams); } - const auto guidString = parent->GetVar(u"NDAudioEventGUID"); + const auto guidString = m_Parent->GetVar(u"NDAudioEventGUID"); if (!guidString.empty()) this->m_2DAmbientSounds.push_back(GUIDResults(guidString)); - const auto guid2String = parent->GetVar(u"NDAudioEventGUID2"); + const auto guid2String = m_Parent->GetVar(u"NDAudioEventGUID2"); if (!guid2String.empty()) this->m_3DAmbientSounds.push_back(GUIDResults(guid2String)); - const auto mixerName = parent->GetVar(u"NDAudioMixerProgram_Name"); + const auto mixerName = m_Parent->GetVar(u"NDAudioMixerProgram_Name"); if (!mixerName.empty()) this->m_MixerPrograms.push_back(MixerProgram(mixerName)); } diff --git a/dGame/dComponents/SoundTriggerComponent.h b/dGame/dComponents/SoundTriggerComponent.h index 3089784bb..a05ea0914 100644 --- a/dGame/dComponents/SoundTriggerComponent.h +++ b/dGame/dComponents/SoundTriggerComponent.h @@ -61,6 +61,8 @@ class SoundTriggerComponent : public Component { public: static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SOUND_TRIGGER; explicit SoundTriggerComponent(Entity* parent, const int32_t componentID); + + void LoadConfigData() override; void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override; void ActivateMusicCue(const std::string& name, float bordemTime = -1.0); void DeactivateMusicCue(const std::string& name);