Skip to content

Commit

Permalink
Add: System Interface and Abstract with some system class (Collison a…
Browse files Browse the repository at this point in the history
…nd Movement)

Add: SystemManager class
Modif: CMakeLists for compilation
  • Loading branch information
KitetsuK committed Sep 20, 2023
1 parent e8f4925 commit e43e63a
Show file tree
Hide file tree
Showing 12 changed files with 299 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/poc/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@

int main()
{
Registry registry;
Registry::array<int> arrInt = registry.registerComponent<int>();
Registry *registry = new Registry();
Registry::array<int> arrInt = registry->registerComponent<int>();
arrInt->add(4);
arrInt->add(69);
Registry::array<float> arrFloat = registry.registerComponent<float>();
Registry::array<float> arrFloat = registry->registerComponent<float>();
arrFloat->add(69.69);
Registry::array<float> scdContainer = registry.getComponents<float>();
Registry::array<float> scdContainer = registry->getComponents<float>();
for (auto begin = arrInt->begin(); begin != arrInt->end(); begin++) {
std::cout << *begin << std::endl;
}
for (auto begin = scdContainer->begin(); begin != scdContainer->end(); begin++) {
std::cout << *begin << std::endl;
}


return 0;
}
25 changes: 25 additions & 0 deletions src/poc/src/system/ASystem.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
** ASystem.cpp for R-Bus in /home/kitetsu/Epitech/R-Bus/src/system
**
** Made by brice
** Login <[email protected]>
**
** Started on Tue Sep 19 5:18:32 PM 2023 brice
** Last update Thu Sep 20 9:37:48 AM 2023 brice
*/

#include "ASystem.hpp"

namespace System {

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

}

void ASystem::clientRun()
{
// To fill when network is ok
}
}
29 changes: 29 additions & 0 deletions src/poc/src/system/ASystem.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
** ASystem.hpp for R-Bus in /home/kitetsu/Epitech/R-Bus/src/system
**
** Made by brice
** Login <[email protected]>
**
** Started on Tue Sep 19 5:18:35 PM 2023 brice
** Last update Thu Sep 20 9:57:34 AM 2023 brice
*/

#pragma once

#include "ISystem.hpp"
#include "Registry.hpp"

namespace System {
class ASystem : public ISystem {
public:
ASystem(const Registry &registry);
~ASystem() = default;

protected:
private:
void clientRun() final;

Registry _registry;

};
}
18 changes: 18 additions & 0 deletions src/poc/src/system/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
cmake_minimum_required(VERSION 3.27)

target_include_directories(
${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)

target_sources(
${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/Collison.cpp
${CMAKE_CURRENT_SOURCE_DIR}/Movement.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ASystem.cpp
)

add_subdirectory(managers)
41 changes: 41 additions & 0 deletions src/poc/src/system/Collison.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
** Collison.cpp for R-Bus in /home/kitetsu/Epitech/R-Bus/src/system
**
** Made by brice
** Login <[email protected]>
**
** Started on Wed Sep 20 9:36:31 AM 2023 brice
** Last update Thu Sep 20 12:03:08 PM 2023 brice
*/

#include <iostream>
#include "Collison.hpp"

namespace System {

Collison::Collison(const 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

// 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 ()
// }
//}
}
}
24 changes: 24 additions & 0 deletions src/poc/src/system/Collison.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
** Collison.hpp for R-Bus in /home/kitetsu/Epitech/R-Bus/src/system
**
** Made by brice
** Login <[email protected]>
**
** Started on Wed Sep 20 9:36:35 AM 2023 brice
** Last update Thu Sep 20 9:58:17 AM 2023 brice
*/

#pragma once

#include "ASystem.hpp"

namespace System {
class Collison : public ASystem {
public:
Collison(const Registry &registry);

void run() final;
protected:
private:
};
}
24 changes: 24 additions & 0 deletions src/poc/src/system/ISystem.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
** ISystem.hpp for R-Bus in /home/kitetsu/Epitech/R-Bus/src/system
**
** Made by brice
** Login <[email protected]>
**
** Started on Tue Sep 19 5:13:48 PM 2023 brice
** Last update Thu Sep 20 9:54:30 AM 2023 brice
*/

#pragma once

namespace System {
class ISystem {
public:
virtual ~ISystem() = default;

virtual void run() = 0;

protected:
private:
virtual void clientRun() = 0;
};
}
27 changes: 27 additions & 0 deletions src/poc/src/system/Movement.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
** Movement.cpp for R-Bus in /home/kitetsu/Epitech/R-Bus/src/system
**
** Made by brice
** Login <[email protected]>
**
** Started on Wed Sep 20 10:19:53 AM 2023 brice
** Last update Thu Sep 20 2:34:00 PM 2023 brice
*/

#include <iostream>
#include "Movement.hpp"

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

}

void Movement::run()
{
std::cout << "Update Movement" << std::endl;
// get Position sparseArray with Position component type index

}
}
24 changes: 24 additions & 0 deletions src/poc/src/system/Movement.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
** Movement.hpp for R-Bus in /home/kitetsu/Epitech/R-Bus/src/system
**
** Made by brice
** Login <[email protected]>
**
** Started on Wed Sep 20 10:19:50 AM 2023 brice
** Last update Thu Sep 20 10:28:46 AM 2023 brice
*/

#pragma once

#include "ASystem.hpp"

namespace System {
class Movement : public ASystem {
public:
Movement(const Registry &registry);

void run() final;
protected:
private:
};
}
14 changes: 14 additions & 0 deletions src/poc/src/system/managers/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
cmake_minimum_required(VERSION 3.27)

target_include_directories(
${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
)

target_sources(
${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/SystemManager.cpp
)
36 changes: 36 additions & 0 deletions src/poc/src/system/managers/SystemManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
** SystemManager.cpp for R-Bus in /home/kitetsu/Epitech/R-Bus/src/system/managers
**
** Made by brice
** Login <[email protected]>
**
** Started on Wed Sep 20 10:25:26 AM 2023 brice
** Last update Thu Sep 20 2:34:27 PM 2023 brice
*/

#include "SystemManager.hpp"


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

SystemManager::~SystemManager()
{
}

void SystemManager::updateSystems()
{
for (auto &system : _systems) {
system->run();
}
}

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

}
}
}
31 changes: 31 additions & 0 deletions src/poc/src/system/managers/SystemManager.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
** SystemManager.hpp for R-Bus in /home/kitetsu/Epitech/R-Bus/src/system/managers
**
** Made by brice
** Login <[email protected]>
**
** Started on Wed Sep 20 10:25:23 AM 2023 brice
** Last update Thu Sep 20 11:23:54 AM 2023 brice
*/

#pragma once

#include <memory>
#include <vector>
#include "ISystem.hpp"
#include "Registry.hpp"

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

void updateSystems();

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

protected:
std::vector<std::unique_ptr<ISystem>> _systems;
};
}

0 comments on commit e43e63a

Please sign in to comment.