From 6fd7cec7d4bbf5aeb361b3f1337671bb0f9af61b Mon Sep 17 00:00:00 2001 From: Loek Le Blansch Date: Thu, 28 Nov 2024 10:13:11 +0100 Subject: manager mediator refactor --- src/test/DBTest.cpp | 3 ++- src/test/ECSTest.cpp | 5 +++-- src/test/EventTest.cpp | 11 ++++++----- src/test/ParticleTest.cpp | 8 ++++---- src/test/PhysicsTest.cpp | 7 ++++--- src/test/RenderSystemTest.cpp | 9 +++++---- src/test/SceneManagerTest.cpp | 23 ++++++++++++++--------- src/test/ScriptTest.cpp | 11 ++++++----- 8 files changed, 44 insertions(+), 33 deletions(-) (limited to 'src/test') diff --git a/src/test/DBTest.cpp b/src/test/DBTest.cpp index e80814c..99dedff 100644 --- a/src/test/DBTest.cpp +++ b/src/test/DBTest.cpp @@ -1,6 +1,7 @@ -#include #include +#include + using namespace std; using namespace crepe; using namespace testing; diff --git a/src/test/ECSTest.cpp b/src/test/ECSTest.cpp index af9d6f2..22c4fe7 100644 --- a/src/test/ECSTest.cpp +++ b/src/test/ECSTest.cpp @@ -2,7 +2,7 @@ #define protected public -#include +#include #include #include #include @@ -12,8 +12,9 @@ using namespace std; using namespace crepe; class ECSTest : public ::testing::Test { + Mediator m; public: - ComponentManager mgr{}; + ComponentManager mgr{m}; }; TEST_F(ECSTest, createGameObject) { diff --git a/src/test/EventTest.cpp b/src/test/EventTest.cpp index b0e6c9c..f232027 100644 --- a/src/test/EventTest.cpp +++ b/src/test/EventTest.cpp @@ -1,10 +1,11 @@ - -#include "api/Event.h" -#include "api/EventManager.h" -#include "api/IKeyListener.h" -#include "api/IMouseListener.h" #include #include + +#include +#include +#include +#include + using namespace std; using namespace std::chrono_literals; using namespace crepe; diff --git a/src/test/ParticleTest.cpp b/src/test/ParticleTest.cpp index 8b81e74..cf43e35 100644 --- a/src/test/ParticleTest.cpp +++ b/src/test/ParticleTest.cpp @@ -1,5 +1,4 @@ -#include "api/Vector2.h" -#include +#include #include #include #include @@ -16,9 +15,10 @@ using namespace std::chrono_literals; using namespace crepe; class ParticlesTest : public ::testing::Test { + Mediator m; public: - ComponentManager component_manager; - ParticleSystem particle_system{component_manager}; + ComponentManager component_manager{m}; + ParticleSystem particle_system{m}; void SetUp() override { ComponentManager & mgr = this->component_manager; diff --git a/src/test/PhysicsTest.cpp b/src/test/PhysicsTest.cpp index 33b6020..01b7c51 100644 --- a/src/test/PhysicsTest.cpp +++ b/src/test/PhysicsTest.cpp @@ -1,4 +1,4 @@ -#include +#include #include #include #include @@ -11,9 +11,10 @@ using namespace std::chrono_literals; using namespace crepe; class PhysicsTest : public ::testing::Test { + Mediator m; public: - ComponentManager component_manager; - PhysicsSystem system{component_manager}; + ComponentManager component_manager{m}; + PhysicsSystem system{m}; void SetUp() override { ComponentManager & mgr = this->component_manager; diff --git a/src/test/RenderSystemTest.cpp b/src/test/RenderSystemTest.cpp index f37fb56..f479443 100644 --- a/src/test/RenderSystemTest.cpp +++ b/src/test/RenderSystemTest.cpp @@ -1,4 +1,3 @@ -#include "api/Camera.h" #include #include #include @@ -7,7 +6,8 @@ #define private public #define protected public -#include +#include +#include #include #include #include @@ -20,9 +20,10 @@ using namespace crepe; using namespace testing; class RenderSystemTest : public Test { + Mediator m; public: - ComponentManager mgr{}; - RenderSystem sys{mgr}; + ComponentManager mgr{m}; + RenderSystem sys{m}; GameObject entity1 = this->mgr.new_object("name"); GameObject entity2 = this->mgr.new_object("name"); GameObject entity3 = this->mgr.new_object("name"); diff --git a/src/test/SceneManagerTest.cpp b/src/test/SceneManagerTest.cpp index 62b7d33..d027d89 100644 --- a/src/test/SceneManagerTest.cpp +++ b/src/test/SceneManagerTest.cpp @@ -1,12 +1,13 @@ -#include "types.h" -#include +#include + +#include +#include +#include #include #include #include -#include #include #include -#include using namespace std; using namespace crepe; @@ -14,7 +15,8 @@ using namespace crepe; class ConcreteScene1 : public Scene { public: void load_scene() { - ComponentManager & mgr = this->component_manager; + Mediator & mediator = this->mediator; + ComponentManager & mgr = mediator.component_manager; GameObject object1 = mgr.new_object("scene_1", "tag_scene_1", vec2{0, 0}, 0, 1); GameObject object2 = mgr.new_object("scene_1", "tag_scene_1", vec2{1, 0}, 0, 1); GameObject object3 = mgr.new_object("scene_1", "tag_scene_1", vec2{2, 0}, 0, 1); @@ -26,7 +28,8 @@ public: class ConcreteScene2 : public Scene { public: void load_scene() { - ComponentManager & mgr = this->component_manager; + Mediator & mediator = this->mediator; + ComponentManager & mgr = mediator.component_manager; GameObject object1 = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 0}, 0, 1); GameObject object2 = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 1}, 0, 1); GameObject object3 = mgr.new_object("scene_2", "tag_scene_2", vec2{0, 2}, 0, 1); @@ -41,7 +44,8 @@ public: ConcreteScene3(const string & name) : name(name) {} void load_scene() { - ComponentManager & mgr = this->component_manager; + Mediator & mediator = this->mediator; + ComponentManager & mgr = mediator.component_manager; GameObject object1 = mgr.new_object("scene_3", "tag_scene_3", vec2{0, 0}, 0, 1); } @@ -52,9 +56,10 @@ private: }; class SceneManagerTest : public ::testing::Test { + Mediator m; public: - ComponentManager component_mgr{}; - SceneManager scene_mgr{component_mgr}; + ComponentManager component_mgr{m}; + SceneManager scene_mgr{m}; }; TEST_F(SceneManagerTest, loadScene) { diff --git a/src/test/ScriptTest.cpp b/src/test/ScriptTest.cpp index 78d5061..3187ed2 100644 --- a/src/test/ScriptTest.cpp +++ b/src/test/ScriptTest.cpp @@ -4,10 +4,10 @@ #define private public #define protected public -#include +#include +#include #include #include -#include #include #include #include @@ -20,10 +20,11 @@ using namespace testing; class MyEvent : public Event {}; class ScriptTest : public Test { + Mediator m; public: - ComponentManager component_manager{}; - ScriptSystem system{component_manager}; - EventManager & event_manager = EventManager::get_instance(); + ComponentManager component_manager{m}; + ScriptSystem system{m}; + EventManager & event_manager = m.event_manager; class MyScript : public Script { // NOTE: default (private) visibility of init and update shouldn't cause -- cgit v1.2.3