diff options
Diffstat (limited to 'src/crepe/system')
-rw-r--r-- | src/crepe/system/AnimatorSystem.cpp | 12 | ||||
-rw-r--r-- | src/crepe/system/AnimatorSystem.h | 17 | ||||
-rw-r--r-- | src/crepe/system/CMakeLists.txt | 12 | ||||
-rw-r--r-- | src/crepe/system/CollisionSystem.cpp | 3 | ||||
-rw-r--r-- | src/crepe/system/CollisionSystem.h | 8 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.cpp | 14 | ||||
-rw-r--r-- | src/crepe/system/RenderSystem.h | 13 | ||||
-rw-r--r-- | src/crepe/system/System.cpp | 6 |
8 files changed, 24 insertions, 61 deletions
diff --git a/src/crepe/system/AnimatorSystem.cpp b/src/crepe/system/AnimatorSystem.cpp index bf45362..9d18873 100644 --- a/src/crepe/system/AnimatorSystem.cpp +++ b/src/crepe/system/AnimatorSystem.cpp @@ -1,27 +1,17 @@ - #include <cstdint> #include <functional> #include <vector> #include "api/Animator.h" #include "facade/SDLContext.h" -#include "util/log.h" #include "AnimatorSystem.h" #include "ComponentManager.h" using namespace crepe; -AnimatorSystem::AnimatorSystem() { dbg_trace(); } -AnimatorSystem::~AnimatorSystem() { dbg_trace(); } - -AnimatorSystem & AnimatorSystem::get_instance() { - static AnimatorSystem instance; - return instance; -} - void AnimatorSystem::update() { - ComponentManager & mgr = ComponentManager::get_instance(); + ComponentManager & mgr = this->component_manager; std::vector<std::reference_wrapper<Animator>> animations = mgr.get_components_by_type<Animator>(); diff --git a/src/crepe/system/AnimatorSystem.h b/src/crepe/system/AnimatorSystem.h index 969e9d1..aa97084 100644 --- a/src/crepe/system/AnimatorSystem.h +++ b/src/crepe/system/AnimatorSystem.h @@ -17,16 +17,7 @@ namespace crepe { class AnimatorSystem : public System { public: - /** - * \brief Retrieves the singleton instance of the AnimatorSystem. - * - * \return A reference to the single instance of the AnimatorSystem. - * - * This method ensures that there is only one instance of the AnimatorSystem, following the - * singleton design pattern. It can be used to access the system globally. - */ - static AnimatorSystem & get_instance(); - + using System::System; /** * \brief Updates the Animator components. * @@ -34,11 +25,7 @@ public: * Animator components, moving the animations forward and managing their behavior (e.g., looping). */ void update() override; - -private: - // private because singleton - AnimatorSystem(); // dbg_trace - ~AnimatorSystem(); // dbg_trace + // FIXME: never say "likely" in the documentation lmao }; } // namespace crepe diff --git a/src/crepe/system/CMakeLists.txt b/src/crepe/system/CMakeLists.txt index 2fb58dc..d658b25 100644 --- a/src/crepe/system/CMakeLists.txt +++ b/src/crepe/system/CMakeLists.txt @@ -3,16 +3,16 @@ target_sources(crepe PUBLIC ParticleSystem.cpp ScriptSystem.cpp PhysicsSystem.cpp - # CollisionSystem.cpp - # RenderSystem.cpp - # AnimatorSystem.cpp + CollisionSystem.cpp + RenderSystem.cpp + AnimatorSystem.cpp ) target_sources(crepe PUBLIC FILE_SET HEADERS FILES System.h ScriptSystem.h PhysicsSystem.h - # CollisionSystem.h - # RenderSystem.h - # AnimatorSystem.h + CollisionSystem.h + RenderSystem.h + AnimatorSystem.h ) diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp index 55e0fdc..67f535a 100644 --- a/src/crepe/system/CollisionSystem.cpp +++ b/src/crepe/system/CollisionSystem.cpp @@ -2,6 +2,5 @@ using namespace crepe; -CollisionSystem::CollisionSystem() {} - void CollisionSystem::update() {} + diff --git a/src/crepe/system/CollisionSystem.h b/src/crepe/system/CollisionSystem.h index 1e9f1aa..c1a70d8 100644 --- a/src/crepe/system/CollisionSystem.h +++ b/src/crepe/system/CollisionSystem.h @@ -1,11 +1,13 @@ #pragma once +#include "System.h" + namespace crepe { -class CollisionSystem { +class CollisionSystem : public System { public: - CollisionSystem(); - void update(); + using System::System; + void update() override; }; } // namespace crepe diff --git a/src/crepe/system/RenderSystem.cpp b/src/crepe/system/RenderSystem.cpp index 10211a3..3e6360c 100644 --- a/src/crepe/system/RenderSystem.cpp +++ b/src/crepe/system/RenderSystem.cpp @@ -11,15 +11,6 @@ using namespace crepe; -RenderSystem::RenderSystem() { dbg_trace(); } - -RenderSystem::~RenderSystem() { dbg_trace(); } - -RenderSystem & RenderSystem::get_instance() { - static RenderSystem instance; - return instance; -} - void RenderSystem::clear_screen() const { SDLContext::get_instance().clear_screen(); } @@ -28,7 +19,7 @@ void RenderSystem::present_screen() const { SDLContext::get_instance().present_screen(); } void RenderSystem::update_camera() { - ComponentManager & mgr = ComponentManager::get_instance(); + ComponentManager & mgr = this->component_manager; std::vector<std::reference_wrapper<Camera>> cameras = mgr.get_components_by_type<Camera>(); @@ -39,8 +30,7 @@ void RenderSystem::update_camera() { } } void RenderSystem::render_sprites() const { - - ComponentManager & mgr = ComponentManager::get_instance(); + ComponentManager & mgr = this->component_manager; std::vector<std::reference_wrapper<Sprite>> sprites = mgr.get_components_by_type<Sprite>(); diff --git a/src/crepe/system/RenderSystem.h b/src/crepe/system/RenderSystem.h index 70db21a..da4e910 100644 --- a/src/crepe/system/RenderSystem.h +++ b/src/crepe/system/RenderSystem.h @@ -15,14 +15,8 @@ namespace crepe { * rendering services for the application. */ class RenderSystem : public System { - public: - /** - * \brief Gets the singleton instance of RenderSystem. - * \return Reference to the RenderSystem instance. - */ - static RenderSystem & get_instance(); - + using System::System; /** * \brief Updates the RenderSystem for the current frame. * This method is called to perform all rendering operations for the current game frame. @@ -30,10 +24,6 @@ public: void update() override; private: - // Private constructor to enforce singleton pattern. - RenderSystem(); - ~RenderSystem(); - //! Clears the screen in preparation for rendering. void clear_screen() const; @@ -61,4 +51,5 @@ private: Camera * curr_cam = nullptr; // TODO: needs a better solution }; + } // namespace crepe diff --git a/src/crepe/system/System.cpp b/src/crepe/system/System.cpp index 296f1ed..31b1337 100644 --- a/src/crepe/system/System.cpp +++ b/src/crepe/system/System.cpp @@ -1,6 +1,10 @@ +#include "../util/log.h" + #include "System.h" using namespace crepe; -System::System(ComponentManager & mgr) : component_manager(mgr) {} +System::System(ComponentManager & mgr) : component_manager(mgr) { + dbg_trace(); +} |