diff --git a/src/poc/src/main.cpp b/src/poc/src/main.cpp index 4afe56a9..f8dc7b33 100644 --- a/src/poc/src/main.cpp +++ b/src/poc/src/main.cpp @@ -1,5 +1,8 @@ #include -#include "Registry.hpp" +#include +#include "SystemManager.hpp" +#include "Collison.hpp" +#include "Movement.hpp" int main() { @@ -17,6 +20,14 @@ int main() std::cout << *begin << std::endl; } + System::SystemManager manager; + manager.addSystem(std::make_unique(registry)); + manager.addSystem(std::make_unique(registry)); + + while (1) { + manager.updateSystems(); + sleep(1); + } return 0; } diff --git a/src/poc/src/system/ASystem.cpp b/src/poc/src/system/ASystem.cpp index 2a6506b0..efed5863 100644 --- a/src/poc/src/system/ASystem.cpp +++ b/src/poc/src/system/ASystem.cpp @@ -12,7 +12,7 @@ namespace System { - ASystem::ASystem(const Registry ®istry) + ASystem::ASystem(Registry *registry) : _registry(registry) { diff --git a/src/poc/src/system/ASystem.hpp b/src/poc/src/system/ASystem.hpp index 9d168333..ed0129ca 100644 --- a/src/poc/src/system/ASystem.hpp +++ b/src/poc/src/system/ASystem.hpp @@ -16,14 +16,14 @@ namespace System { class ASystem : public ISystem { public: - ASystem(const Registry ®istry); + ASystem(Registry *registry); ~ASystem() = default; protected: + Registry *_registry; private: void clientRun() final; - Registry _registry; }; } diff --git a/src/poc/src/system/Collison.cpp b/src/poc/src/system/Collison.cpp index 6b6b7dd1..acb1b1d2 100644 --- a/src/poc/src/system/Collison.cpp +++ b/src/poc/src/system/Collison.cpp @@ -13,7 +13,7 @@ namespace System { - Collison::Collison(const Registry ®istry) + Collison::Collison(Registry *registry) : ASystem(registry) { @@ -21,21 +21,12 @@ namespace System { void Collison::run() { - std::cout << "Update Collision" << std::endl; - // get Position sparseArray with Position component type index - //h - // get Dammage sparseArray with Dammage component type index - // get Health sparse Array with Health component type index + std::cout << "Increment sparse array int of 1" << std::endl; + Registry::array arrInt = _registry->getComponents(); - // if (sparseArray.size() == 0) { - // return () - // } - // for (std::size_t i = 0, auto it = sparseArray.begin(); it != sparseArray.end(); it++) { - // Position toCheck = sparseArray[i]; - // auto tmp = it; - // for (; tmp != sparseArray.end(); tmp++) { - // if () - // } - //} + for (auto begin = arrInt->begin(); begin != arrInt->end(); begin++) { + *begin += 1; + } + std::cout << "------------------------------------" << std::endl; } } diff --git a/src/poc/src/system/Collison.hpp b/src/poc/src/system/Collison.hpp index d1dd1590..25cd55ff 100644 --- a/src/poc/src/system/Collison.hpp +++ b/src/poc/src/system/Collison.hpp @@ -15,7 +15,7 @@ namespace System { class Collison : public ASystem { public: - Collison(const Registry ®istry); + Collison(Registry *registry); void run() final; protected: diff --git a/src/poc/src/system/Movement.cpp b/src/poc/src/system/Movement.cpp index 6f9349f9..35ba0e5e 100644 --- a/src/poc/src/system/Movement.cpp +++ b/src/poc/src/system/Movement.cpp @@ -12,7 +12,7 @@ #include "Movement.hpp" namespace System { - Movement::Movement(const Registry ®istry) + Movement::Movement(Registry *registry) : ASystem(registry) { @@ -20,8 +20,12 @@ namespace System { void Movement::run() { - std::cout << "Update Movement" << std::endl; - // get Position sparseArray with Position component type index + std::cout << "Printing sparse array of int" << std::endl; + Registry::array arrInt = _registry->getComponents(); + for (auto begin = arrInt->begin(); begin != arrInt->end(); begin++) { + std::cout << *begin << std::endl; + } + std::cout << "------------------------------------" << std::endl; } } diff --git a/src/poc/src/system/Movement.hpp b/src/poc/src/system/Movement.hpp index 8848025a..d73f91a7 100644 --- a/src/poc/src/system/Movement.hpp +++ b/src/poc/src/system/Movement.hpp @@ -15,7 +15,7 @@ namespace System { class Movement : public ASystem { public: - Movement(const Registry ®istry); + Movement(Registry *registry); void run() final; protected: diff --git a/src/poc/src/system/managers/SystemManager.cpp b/src/poc/src/system/managers/SystemManager.cpp index 58a763a2..616ba4d3 100644 --- a/src/poc/src/system/managers/SystemManager.cpp +++ b/src/poc/src/system/managers/SystemManager.cpp @@ -12,7 +12,7 @@ namespace System { - SystemManager::SystemManager(Registry ®istry) + SystemManager::SystemManager() { } @@ -27,10 +27,8 @@ namespace System { } } - void addSystems(std::vector> systems) + void SystemManager::addSystem(std::unique_ptr system) { - for (auto &system: systems) { - - } + _systems.push_back(std::move(system)); } } diff --git a/src/poc/src/system/managers/SystemManager.hpp b/src/poc/src/system/managers/SystemManager.hpp index d38f4c70..028d6ea7 100644 --- a/src/poc/src/system/managers/SystemManager.hpp +++ b/src/poc/src/system/managers/SystemManager.hpp @@ -13,17 +13,16 @@ #include #include #include "ISystem.hpp" -#include "Registry.hpp" namespace System { class SystemManager { public: - SystemManager(Registry ®istry); + SystemManager(); ~SystemManager(); void updateSystems(); - void addSystems(std::vector> systems); + void addSystem(std::unique_ptr system); protected: std::vector> _systems;