aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/system/AudioSystem.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-29 16:23:52 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-29 16:23:52 +0100
commitc59d460f12e1393e0ddbaaa1c6f5522eb12f8ff9 (patch)
treee7d7ceabbb5b538b8fc57704750ccae9135be735 /src/crepe/system/AudioSystem.cpp
parentc2ef6a36532c8c078fd7836325d6be277b946cbf (diff)
more utility classes for Audio system
Diffstat (limited to 'src/crepe/system/AudioSystem.cpp')
-rw-r--r--src/crepe/system/AudioSystem.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/crepe/system/AudioSystem.cpp b/src/crepe/system/AudioSystem.cpp
index 97cf966..0f943be 100644
--- a/src/crepe/system/AudioSystem.cpp
+++ b/src/crepe/system/AudioSystem.cpp
@@ -1,6 +1,5 @@
#include "AudioSystem.h"
-#include "../api/AudioSource.h"
#include "../manager/ComponentManager.h"
#include "../manager/ResourceManager.h"
#include "../types.h"
@@ -13,12 +12,24 @@ void AudioSystem::update() {
ResourceManager & resource_manager = this->mediator.resource_manager;
RefVector<AudioSource> components = component_manager.get_components_by_type<AudioSource>();
- for (auto component_ref : components) {
- AudioSource & component = component_ref.get();
+ for (AudioSource & component : components) {
if (!component.active) continue;
Sound & sound = resource_manager.get<Sound>(component.source);
+ if (component.private_data.empty())
+ component.private_data.set<ComponentPrivate>();
+ auto & data = component.private_data.get<ComponentPrivate>();
// TODO: lots of state diffing
+
+
+ this->update_private(component, data);
}
}
+void AudioSystem::update_private(const AudioSource & component, ComponentPrivate & data) {
+ data.last_active = component.active;
+ data.last_loop = component.loop;
+ data.last_playing = component.playing;
+ data.last_volume = component.volume;
+}
+