diff options
Diffstat (limited to 'src/crepe/system')
-rw-r--r-- | src/crepe/system/AudioSystem.cpp | 22 | ||||
-rw-r--r-- | src/crepe/system/AudioSystem.h | 19 | ||||
-rw-r--r-- | src/crepe/system/CMakeLists.txt | 3 | ||||
-rw-r--r-- | src/crepe/system/ScriptSystem.cpp | 3 | ||||
-rw-r--r-- | src/crepe/system/System.cpp | 7 | ||||
-rw-r--r-- | src/crepe/system/System.h | 10 |
6 files changed, 61 insertions, 3 deletions
diff --git a/src/crepe/system/AudioSystem.cpp b/src/crepe/system/AudioSystem.cpp new file mode 100644 index 0000000..9fdd7eb --- /dev/null +++ b/src/crepe/system/AudioSystem.cpp @@ -0,0 +1,22 @@ +#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<reference_wrapper<AudioSource>> components = this->compmgr.get_components_by_type<AudioSource>(); + + 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..e037f51 --- /dev/null +++ b/src/crepe/system/AudioSystem.h @@ -0,0 +1,19 @@ +#pragma once + +#include "../facade/SoundContext.h" + +#include "System.h" + +namespace crepe { + +class AudioSystem : public System { +public: + using System::System; + void update() override; + +private: + SoundContext context {}; +}; + +} // namespace crepe + diff --git a/src/crepe/system/CMakeLists.txt b/src/crepe/system/CMakeLists.txt index 4c18b87..f507b90 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 AnimatorSystem.cpp ) @@ -13,5 +15,6 @@ target_sources(crepe PUBLIC FILE_SET HEADERS FILES PhysicsSystem.h CollisionSystem.h RenderSystem.h + AudioSystem.h AnimatorSystem.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<Script *> ScriptSystem::get_scripts() { forward_list<Script *> scripts = {}; - ComponentManager & mgr = ComponentManager::get_instance(); vector<reference_wrapper<BehaviorScript>> behavior_scripts - = mgr.get_components_by_type<BehaviorScript>(); + = this->compmgr.get_components_by_type<BehaviorScript>(); for (auto behavior_script_ref : behavior_scripts) { BehaviorScript & behavior_script = behavior_script_ref.get(); diff --git a/src/crepe/system/System.cpp b/src/crepe/system/System.cpp new file mode 100644 index 0000000..fa51d2f --- /dev/null +++ b/src/crepe/system/System.cpp @@ -0,0 +1,7 @@ +#include "System.h" + +using namespace crepe; + +// TODO: ComponentManager shouldn't be a singleton +System::System() : compmgr(ComponentManager::get_instance()) {} + diff --git a/src/crepe/system/System.h b/src/crepe/system/System.h index 3b81bef..5091977 100644 --- a/src/crepe/system/System.h +++ b/src/crepe/system/System.h @@ -1,14 +1,22 @@ #pragma once +#include "../ComponentManager.h" + namespace crepe { +//! ECS system base class class System { public: + //! Process components belonging to this system virtual void update() = 0; public: - System() = default; + System(); virtual ~System() = default; + +public: + //! Reference to component manager + ComponentManager & compmgr; }; } // namespace crepe |