From 3c65474062486ae456f26e9a2532733b3ac03a7f Mon Sep 17 00:00:00 2001 From: Kae <80987908+Novaenia@users.noreply.github.com> Date: Sun, 2 Jul 2023 02:26:13 +1000 Subject: [PATCH] immediateSound and persistentSound now supports random sound pools --- source/game/StarNetworkedAnimator.cpp | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/source/game/StarNetworkedAnimator.cpp b/source/game/StarNetworkedAnimator.cpp index 065ca31..b679f63 100644 --- a/source/game/StarNetworkedAnimator.cpp +++ b/source/game/StarNetworkedAnimator.cpp @@ -726,7 +726,14 @@ void NetworkedAnimator::update(float dt, DynamicTarget* dynamicTarget) { if (dynamicTarget) { dynamicTarget->clearFinishedAudio(); - String persistentSoundFile = activeState.properties.value("persistentSound", "").toString(); + Json jPersistentSound = activeState.properties.value("persistentSound", ""); + String persistentSoundFile; + + if (jPersistentSound.isType(Json::Type::String)) + persistentSoundFile = jPersistentSound.toString(); + else if (jPersistentSound.isType(Json::Type::Array)) + persistentSoundFile = Random::randValueFrom(jPersistentSound.toArray(), "").toString(); + if (!persistentSoundFile.empty()) persistentSoundFile = AssetPath::relativeTo(m_relativePath, persistentSoundFile); @@ -748,7 +755,14 @@ void NetworkedAnimator::update(float dt, DynamicTarget* dynamicTarget) { } } - String immediateSoundFile = activeState.properties.value("immediateSound", "").toString(); + Json jImmediateSound = activeState.properties.value("immediateSound", ""); + String immediateSoundFile = ""; + + if (jImmediateSound.isType(Json::Type::String)) + immediateSoundFile = jImmediateSound.toString(); + else if (jImmediateSound.isType(Json::Type::Array)) + immediateSoundFile = Random::randValueFrom(jImmediateSound.toArray(), "").toString(); + if (!immediateSoundFile.empty()) immediateSoundFile = AssetPath::relativeTo(m_relativePath, immediateSoundFile);