aboutsummaryrefslogtreecommitdiff
path: root/src/crepe
diff options
context:
space:
mode:
authorJAROWMR <jarorutjes07@gmail.com>2024-11-20 10:43:32 +0100
committerJAROWMR <jarorutjes07@gmail.com>2024-11-20 10:43:32 +0100
commit690471c7c4536c074a4dca5aab7cc618d47bfb5f (patch)
tree35dcf3858b8f86a031cf5070de9caa069af4257d /src/crepe
parentd81ecc242ff88ffd49e0b5296dfb23ab54a0cd78 (diff)
merge with maser
Diffstat (limited to 'src/crepe')
-rw-r--r--src/crepe/api/LoopManager.cpp6
-rw-r--r--src/crepe/api/LoopManager.h5
-rw-r--r--src/crepe/api/Script.h9
-rw-r--r--src/crepe/system/CollisionSystem.cpp6
-rw-r--r--src/crepe/system/CollisionSystem.h2
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;