mirror of
https://github.com/DarkflameUniverse/DarkflameServer.git
synced 2026-11-20 10:45:27 +00:00
refactor(component): the sound trigger reads its level config in LoadConfigData
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -26,32 +26,35 @@ void MixerProgram::Serialize(RakNet::BitStream& outBitStream){
|
|||||||
outBitStream.Write(result);
|
outBitStream.Write(result);
|
||||||
}
|
}
|
||||||
SoundTriggerComponent::SoundTriggerComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
|
SoundTriggerComponent::SoundTriggerComponent(Entity* parent, const int32_t componentID) : Component(parent, componentID) {
|
||||||
|
}
|
||||||
|
|
||||||
const auto musicCueName = parent->GetVar<std::string>(u"NDAudioMusicCue_Name");
|
// The level config: music cues and parameters, ambient sounds and mixer programs
|
||||||
|
void SoundTriggerComponent::LoadConfigData() {
|
||||||
|
const auto musicCueName = m_Parent->GetVar<std::string>(u"NDAudioMusicCue_Name");
|
||||||
if (!musicCueName.empty()) {
|
if (!musicCueName.empty()) {
|
||||||
auto newCue = MusicCue(musicCueName);
|
auto newCue = MusicCue(musicCueName);
|
||||||
const auto musicCueBoredomTime = parent->GetVar<float>(u"NDAudioMusicCue_BoredomTime");
|
const auto musicCueBoredomTime = m_Parent->GetVar<float>(u"NDAudioMusicCue_BoredomTime");
|
||||||
if (musicCueBoredomTime) newCue.boredomTime = musicCueBoredomTime;
|
if (musicCueBoredomTime) newCue.boredomTime = musicCueBoredomTime;
|
||||||
this->m_MusicCues.push_back(newCue);
|
this->m_MusicCues.push_back(newCue);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto musicParameterName = parent->GetVar<std::string>(u"NDAudioMusicParameter_Name");
|
const auto musicParameterName = m_Parent->GetVar<std::string>(u"NDAudioMusicParameter_Name");
|
||||||
if (!musicParameterName.empty()) {
|
if (!musicParameterName.empty()) {
|
||||||
auto newParams = MusicParameter(musicParameterName);
|
auto newParams = MusicParameter(musicParameterName);
|
||||||
const auto musicParameterValue = parent->GetVar<float>(u"NDAudioMusicParameter_Value");
|
const auto musicParameterValue = m_Parent->GetVar<float>(u"NDAudioMusicParameter_Value");
|
||||||
if (musicParameterValue) newParams.value = musicParameterValue;
|
if (musicParameterValue) newParams.value = musicParameterValue;
|
||||||
this->m_MusicParameters.push_back(newParams);
|
this->m_MusicParameters.push_back(newParams);
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto guidString = parent->GetVar<std::string>(u"NDAudioEventGUID");
|
const auto guidString = m_Parent->GetVar<std::string>(u"NDAudioEventGUID");
|
||||||
if (!guidString.empty())
|
if (!guidString.empty())
|
||||||
this->m_2DAmbientSounds.push_back(GUIDResults(guidString));
|
this->m_2DAmbientSounds.push_back(GUIDResults(guidString));
|
||||||
|
|
||||||
const auto guid2String = parent->GetVar<std::string>(u"NDAudioEventGUID2");
|
const auto guid2String = m_Parent->GetVar<std::string>(u"NDAudioEventGUID2");
|
||||||
if (!guid2String.empty())
|
if (!guid2String.empty())
|
||||||
this->m_3DAmbientSounds.push_back(GUIDResults(guid2String));
|
this->m_3DAmbientSounds.push_back(GUIDResults(guid2String));
|
||||||
|
|
||||||
const auto mixerName = parent->GetVar<std::string>(u"NDAudioMixerProgram_Name");
|
const auto mixerName = m_Parent->GetVar<std::string>(u"NDAudioMixerProgram_Name");
|
||||||
if (!mixerName.empty()) this->m_MixerPrograms.push_back(MixerProgram(mixerName));
|
if (!mixerName.empty()) this->m_MixerPrograms.push_back(MixerProgram(mixerName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -61,6 +61,8 @@ class SoundTriggerComponent : public Component {
|
|||||||
public:
|
public:
|
||||||
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SOUND_TRIGGER;
|
static constexpr eReplicaComponentType ComponentType = eReplicaComponentType::SOUND_TRIGGER;
|
||||||
explicit SoundTriggerComponent(Entity* parent, const int32_t componentID);
|
explicit SoundTriggerComponent(Entity* parent, const int32_t componentID);
|
||||||
|
|
||||||
|
void LoadConfigData() override;
|
||||||
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
void Serialize(RakNet::BitStream& outBitStream, bool bIsInitialUpdate) override;
|
||||||
void ActivateMusicCue(const std::string& name, float bordemTime = -1.0);
|
void ActivateMusicCue(const std::string& name, float bordemTime = -1.0);
|
||||||
void DeactivateMusicCue(const std::string& name);
|
void DeactivateMusicCue(const std::string& name);
|
||||||
|
|||||||
Reference in New Issue
Block a user