Air-Trap 1.0.0
A multiplayer R-Type clone game engine built with C++23 and ECS architecture
Loading...
Searching...
No Matches
SystemManager.tpp
Go to the documentation of this file.
1/**
2 * File : NetworkId.hpp
3 * License: MIT
4 * Author : Elias Josué HAJJAR LLAUQUEN <elias-josue.hajjar-llauquen@epitech.eu>
5 * Date : 11/12/2025
6 */
7
8namespace rtp::ecs
9{
10 template <typename T, typename... Args>
11 T &SystemManager::add(Args &&...args)
12 {
13 auto typeName = std::type_index(typeid(T));
14 auto system = std::make_unique<T>(std::forward<Args>(args)...);
15 if constexpr (requires { T::getRequiredSignature(); }) {
16 this->_signatures[typeName] = T::getRequiredSignature();
17 }
18
19 auto &ref = *system;
20 this->_systems[typeName] = std::move(system);
21 return ref;
22 }
23
24 template <typename T>
25 T &SystemManager::getSystem()
26 {
27 auto typeName = std::type_index(typeid(T));
28 return *static_cast<T *>(this->_systems.at(typeName).get());
29 }
30}