Skip to content

Commit

Permalink
Add: first version of poc
Browse files Browse the repository at this point in the history
  • Loading branch information
KitetsuK committed Sep 20, 2023
1 parent 2a114a3 commit e5c0ac9
Show file tree
Hide file tree
Showing 9 changed files with 36 additions and 33 deletions.
13 changes: 12 additions & 1 deletion src/poc/src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
#include <iostream>
#include "Registry.hpp"
#include <unistd.h>
#include "SystemManager.hpp"
#include "Collison.hpp"
#include "Movement.hpp"

int main()
{
Expand All @@ -17,6 +20,14 @@ int main()
std::cout << *begin << std::endl;
}

System::SystemManager manager;

manager.addSystem(std::make_unique<System::Collison>(registry));
manager.addSystem(std::make_unique<System::Movement>(registry));

while (1) {
manager.updateSystems();
sleep(1);
}
return 0;
}
2 changes: 1 addition & 1 deletion src/poc/src/system/ASystem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

namespace System {

ASystem::ASystem(const Registry &registry)
ASystem::ASystem(Registry *registry)
: _registry(registry)
{

Expand Down
4 changes: 2 additions & 2 deletions src/poc/src/system/ASystem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
namespace System {
class ASystem : public ISystem {
public:
ASystem(const Registry &registry);
ASystem(Registry *registry);
~ASystem() = default;

protected:
Registry *_registry;
private:
void clientRun() final;

Registry _registry;

};
}
23 changes: 7 additions & 16 deletions src/poc/src/system/Collison.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,29 +13,20 @@

namespace System {

Collison::Collison(const Registry &registry)
Collison::Collison(Registry *registry)
: ASystem(registry)
{

}

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<int> arrInt = _registry->getComponents<int>();

// 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;
}
}
2 changes: 1 addition & 1 deletion src/poc/src/system/Collison.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace System {
class Collison : public ASystem {
public:
Collison(const Registry &registry);
Collison(Registry *registry);

void run() final;
protected:
Expand Down
10 changes: 7 additions & 3 deletions src/poc/src/system/Movement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,20 @@
#include "Movement.hpp"

namespace System {
Movement::Movement(const Registry &registry)
Movement::Movement(Registry *registry)
: ASystem(registry)
{

}

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<int> arrInt = _registry->getComponents<int>();

for (auto begin = arrInt->begin(); begin != arrInt->end(); begin++) {
std::cout << *begin << std::endl;
}
std::cout << "------------------------------------" << std::endl;
}
}
2 changes: 1 addition & 1 deletion src/poc/src/system/Movement.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
namespace System {
class Movement : public ASystem {
public:
Movement(const Registry &registry);
Movement(Registry *registry);

void run() final;
protected:
Expand Down
8 changes: 3 additions & 5 deletions src/poc/src/system/managers/SystemManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@


namespace System {
SystemManager::SystemManager(Registry &registry)
SystemManager::SystemManager()
{
}

Expand All @@ -27,10 +27,8 @@ namespace System {
}
}

void addSystems(std::vector<std::unique_ptr<ISystem>> systems)
void SystemManager::addSystem(std::unique_ptr<ISystem> system)
{
for (auto &system: systems) {

}
_systems.push_back(std::move(system));
}
}
5 changes: 2 additions & 3 deletions src/poc/src/system/managers/SystemManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,16 @@
#include <memory>
#include <vector>
#include "ISystem.hpp"
#include "Registry.hpp"

namespace System {
class SystemManager {
public:
SystemManager(Registry &registry);
SystemManager();
~SystemManager();

void updateSystems();

void addSystems(std::vector<std::unique_ptr<ISystem>> systems);
void addSystem(std::unique_ptr<ISystem> system);

protected:
std::vector<std::unique_ptr<ISystem>> _systems;
Expand Down

0 comments on commit e5c0ac9

Please sign in to comment.