From 827f09031e2d3cc15e956b242774a4566e1403c1 Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 7 Nov 2024 20:52:06 +0100 Subject: more WIP audio system --- src/crepe/system/AudioSystem.cpp | 24 ++++++++++++++++++++++++ src/crepe/system/AudioSystem.h | 21 +++++++++++++++++++++ src/crepe/system/CMakeLists.txt | 3 +++ src/crepe/system/ScriptSystem.cpp | 3 +-- src/crepe/system/System.cpp | 7 +++++++ src/crepe/system/System.h | 10 +++++++++- 6 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 src/crepe/system/AudioSystem.cpp create mode 100644 src/crepe/system/AudioSystem.h create mode 100644 src/crepe/system/System.cpp (limited to 'src/crepe/system') diff --git a/src/crepe/system/AudioSystem.cpp b/src/crepe/system/AudioSystem.cpp new file mode 100644 index 0000000..93c0955 --- /dev/null +++ b/src/crepe/system/AudioSystem.cpp @@ -0,0 +1,24 @@ +#pragma once + +#include "AudioSystem.h" +#include "ComponentManager.h" + +#include "../api/AudioSource.h" + +using namespace crepe; +using namespace std; + +AudioSystem::AudioSystem(SoundContext & ctx) : ctx(ctx) {} + +void AudioSystem::update() { + vector> components = this->compmgr.get_components_by_type(); + + for (auto component_ref : components) { + AudioSource & component = component_ref.get(); + if (!component.active) continue; + + // TODO: fetch Sound instance from resourcemanager + // TODO: lots of state diffing + } +} + diff --git a/src/crepe/system/AudioSystem.h b/src/crepe/system/AudioSystem.h new file mode 100644 index 0000000..8fb681f --- /dev/null +++ b/src/crepe/system/AudioSystem.h @@ -0,0 +1,21 @@ +#pragma once + +#include "../facade/SoundContext.h" + +#include "System.h" + +namespace crepe { + +class AudioSystem : public System { +public: + AudioSystem(SoundContext & ctx); + +public: + void update(); + +private: + SoundContext & ctx; +}; + +} // namespace crepe + diff --git a/src/crepe/system/CMakeLists.txt b/src/crepe/system/CMakeLists.txt index ff6f66f..ca62add 100644 --- a/src/crepe/system/CMakeLists.txt +++ b/src/crepe/system/CMakeLists.txt @@ -1,9 +1,11 @@ target_sources(crepe PUBLIC + System.cpp ParticleSystem.cpp ScriptSystem.cpp PhysicsSystem.cpp CollisionSystem.cpp RenderSystem.cpp + AudioSystem.cpp ) target_sources(crepe PUBLIC FILE_SET HEADERS FILES @@ -12,4 +14,5 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES PhysicsSystem.h CollisionSystem.h RenderSystem.h + AudioSystem.h ) diff --git a/src/crepe/system/ScriptSystem.cpp b/src/crepe/system/ScriptSystem.cpp index f2673e7..68fbb02 100644 --- a/src/crepe/system/ScriptSystem.cpp +++ b/src/crepe/system/ScriptSystem.cpp @@ -22,9 +22,8 @@ void ScriptSystem::update() { forward_list