Веб-сайт самохостера Lotigara

summaryrefslogtreecommitdiff
path: root/source/game/StarNetworkedAnimator.cpp
diff options
context:
space:
mode:
authorKae <80987908+Novaenia@users.noreply.github.com>2023-07-02 03:18:35 +1000
committerKae <80987908+Novaenia@users.noreply.github.com>2023-07-02 03:18:35 +1000
commit2c43b505311b9c7f2a0ee2b798cf4c39b2b0d2b7 (patch)
tree4e25a677144b75fc4de65da99360f72f4fce4de2 /source/game/StarNetworkedAnimator.cpp
parent3c65474062486ae456f26e9a2532733b3ac03a7f (diff)
Fix immediateSound pool logic
Diffstat (limited to 'source/game/StarNetworkedAnimator.cpp')
-rw-r--r--source/game/StarNetworkedAnimator.cpp32
1 files changed, 18 insertions, 14 deletions
diff --git a/source/game/StarNetworkedAnimator.cpp b/source/game/StarNetworkedAnimator.cpp
index b679f63..f76882f 100644
--- a/source/game/StarNetworkedAnimator.cpp
+++ b/source/game/StarNetworkedAnimator.cpp
@@ -726,20 +726,22 @@ void NetworkedAnimator::update(float dt, DynamicTarget* dynamicTarget) {
if (dynamicTarget) {
dynamicTarget->clearFinishedAudio();
- Json jPersistentSound = activeState.properties.value("persistentSound", "");
+ Json persistentSound = 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 (persistentSound.isType(Json::Type::String))
+ persistentSoundFile = persistentSound.toString();
+ else if (persistentSound.isType(Json::Type::Array))
+ persistentSoundFile = Random::randValueFrom(persistentSound.toArray(), "").toString();
if (!persistentSoundFile.empty())
persistentSoundFile = AssetPath::relativeTo(m_relativePath, persistentSoundFile);
auto& activePersistentSound = dynamicTarget->statePersistentSounds[stateTypeName];
- if (persistentSoundFile != activePersistentSound.file || !activePersistentSound.audio) {
- activePersistentSound.file = persistentSoundFile;
+
+ bool changedPersistentSound = persistentSound != activePersistentSound.sound;
+ if (changedPersistentSound || !activePersistentSound.audio) {
+ activePersistentSound.sound = move(persistentSound);
if (activePersistentSound.audio)
activePersistentSound.audio->stop(activePersistentSound.stopRampTime);
@@ -755,20 +757,22 @@ void NetworkedAnimator::update(float dt, DynamicTarget* dynamicTarget) {
}
}
- Json jImmediateSound = activeState.properties.value("immediateSound", "");
+ Json immediateSound = 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 (immediateSound.isType(Json::Type::String))
+ immediateSoundFile = immediateSound.toString();
+ else if (immediateSound.isType(Json::Type::Array))
+ immediateSoundFile = Random::randValueFrom(immediateSound.toArray(), "").toString();
if (!immediateSoundFile.empty())
immediateSoundFile = AssetPath::relativeTo(m_relativePath, immediateSoundFile);
auto& activeImmediateSound = dynamicTarget->stateImmediateSounds[stateTypeName];
- if (immediateSoundFile != activeImmediateSound.file) {
- activeImmediateSound.file = immediateSoundFile;
+
+ bool changedImmediateSound = immediateSound != activeImmediateSound.sound;
+ if (changedImmediateSound) {
+ activeImmediateSound.sound = move(immediateSound);
if (!immediateSoundFile.empty()) {
activeImmediateSound.audio = make_shared<AudioInstance>(*Root::singleton().assets()->audio(immediateSoundFile));
activeImmediateSound.audio->setRangeMultiplier(activeState.properties.value("immediateSoundRangeMultiplier", 1.0f).toFloat());