9#include <unordered_map>
36 virtual void Update(
const float deltaT) = 0;
66 void Update(
const float deltaT);
92 template <
typename T,
typename... Args>
93 requires std::is_base_of_v<System, T>
94 T&
AddSystem(
const u32 priority = 1, Args&&... args)
96 auto ptr = std::make_unique<T>(std::forward<Args>(args)...);
99 m_systems.push_back(std::make_pair(priority, std::move(ptr)));
100 m_systemsMap.emplace(
typeid(T), ptr.get());
102 std::sort(m_systems.begin(), m_systems.end(), [](
const auto& a,
const auto& b)
104 return a.first > b.first;
110 template <
typename T>
111 requires std::is_base_of_v<System, T>
114 auto it = m_systemsMap.find(
typeid(T));
115 if (it == m_systemsMap.end())
123 for (u32 i = 0; i < m_systems.size(); ++i)
125 if (m_systems[i].second.get() == ptr)
134 m_systems.erase(m_systems.begin() + index);
146 template <
typename T>
147 requires std::is_base_of_v<System, T>
150 auto it = m_systemsMap.find(
typeid(T));
151 if (it != m_systemsMap.end())
167 std::vector<std::pair<u32, std::unique_ptr<System>>> m_systems;
168 std::unordered_map<std::type_index, System*> m_systemsMap;
Manages execution and order of systems.
Definition SystemManager.h:57
void Draw()
Renders all systems in order.
Definition SystemManager.cpp:11
T * GetSystem()
Gets a system pointer.
Definition SystemManager.h:148
T & AddSystem(const u32 priority=1, Args &&... args)
Adds a system to the manager.
Definition SystemManager.h:94
void Update(const float deltaT)
Updates all systems in order.
Definition SystemManager.cpp:3
void ClearSystems()
Clears all systems.
Definition SystemManager.cpp:19
Base class for all systems.
Definition SystemManager.h:20
virtual void Update(const float deltaT)=0
Updates the system.
virtual void Draw()=0
Renders the system.