diff options
Diffstat (limited to 'src/crepe')
-rw-r--r-- | src/crepe/api/LoopManager.cpp | 6 | ||||
-rw-r--r-- | src/crepe/api/LoopManager.h | 5 | ||||
-rw-r--r-- | src/crepe/api/Script.h | 9 | ||||
-rw-r--r-- | src/crepe/system/CollisionSystem.cpp | 6 | ||||
-rw-r--r-- | src/crepe/system/CollisionSystem.h | 2 |
5 files changed, 16 insertions, 12 deletions
diff --git a/src/crepe/api/LoopManager.cpp b/src/crepe/api/LoopManager.cpp index a4bc101..586919d 100644 --- a/src/crepe/api/LoopManager.cpp +++ b/src/crepe/api/LoopManager.cpp @@ -35,10 +35,8 @@ void LoopManager::start() { void LoopManager::set_running(bool running) { this->game_running = running; } void LoopManager::fixed_update() { - PhysicsSystem phys; - phys.update(); - CollisionSystem col; - col.update(); + this->get_system<PhysicsSystem>().update(); + this->get_system<CollisionSystem>().update(); } void LoopManager::loop() { diff --git a/src/crepe/api/LoopManager.h b/src/crepe/api/LoopManager.h index f6904be..37f13ac 100644 --- a/src/crepe/api/LoopManager.h +++ b/src/crepe/api/LoopManager.h @@ -4,6 +4,7 @@ #include "../ComponentManager.h" #include "../system/System.h" +#include "api/SceneManager.h" namespace crepe { @@ -71,7 +72,9 @@ private: private: //! Component manager instance ComponentManager component_manager{}; - +public: + //! Scene manager instance + SceneManager scene_manager{component_manager}; private: /** * \brief Collection of System instances diff --git a/src/crepe/api/Script.h b/src/crepe/api/Script.h index 2b70379..939d142 100644 --- a/src/crepe/api/Script.h +++ b/src/crepe/api/Script.h @@ -63,7 +63,14 @@ protected: */ template <typename T> std::vector<std::reference_wrapper<T>> get_components() const; - + + /** + * \brief Gets game object id this script is attached to + * + * \returns game object id + */ + game_object_id_t get_game_object_id() const {return this->game_object_id;}; + protected: // NOTE: Script must have a constructor without arguments so the game programmer doesn't need // to manually add `using Script::Script` to their concrete script class. diff --git a/src/crepe/system/CollisionSystem.cpp b/src/crepe/system/CollisionSystem.cpp index df0ee41..3e73b44 100644 --- a/src/crepe/system/CollisionSystem.cpp +++ b/src/crepe/system/CollisionSystem.cpp @@ -18,11 +18,9 @@ using namespace crepe; -CollisionSystem::CollisionSystem() {} - void CollisionSystem::update() { // Get collider components and keep them seperate - ComponentManager & mgr = ComponentManager::get_instance(); + ComponentManager & mgr = this->component_manager; std::vector<std::reference_wrapper<BoxCollider>> boxcolliders = mgr.get_components_by_type<BoxCollider>(); std::vector<std::reference_wrapper<CircleCollider>> circlecolliders = mgr.get_components_by_type<CircleCollider>(); @@ -185,7 +183,7 @@ void CollisionSystem::static_collision_handler(CollisionInfo& info){ } std::vector<std::pair<CollisionSystem::CollidedInfoStor,CollisionSystem::CollidedInfoStor>> CollisionSystem::check_collisions(const std::vector<std::reference_wrapper<BoxCollider>>& boxcolliders, const std::vector<std::reference_wrapper<CircleCollider>>& circlecolliders) { - ComponentManager & mgr = ComponentManager::get_instance(); + ComponentManager & mgr = this->component_manager; std::vector<std::pair<CollidedInfoStor,CollidedInfoStor>> collisions_ret; // TODO: diff --git a/src/crepe/system/CollisionSystem.h b/src/crepe/system/CollisionSystem.h index 0518b34..d94f6bc 100644 --- a/src/crepe/system/CollisionSystem.h +++ b/src/crepe/system/CollisionSystem.h @@ -70,8 +70,6 @@ public: public: - CollisionSystem(); - //! Updates the collision system by checking for collisions between colliders and handling them. void update() override; |