mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-21 17:09:19 +02:00
ECS System WIP
This commit is contained in:
46
entitysystem/systems/SystemManager.h
Normal file
46
entitysystem/systems/SystemManager.h
Normal file
@@ -0,0 +1,46 @@
|
||||
//
|
||||
// Created by Daniu
|
||||
//
|
||||
|
||||
#ifndef EU07_SYSTEMMANAGER_H
|
||||
#define EU07_SYSTEMMANAGER_H
|
||||
|
||||
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "BaseSystem.h"
|
||||
|
||||
#include <vector>
|
||||
#include <memory>
|
||||
|
||||
class ECWorld;
|
||||
|
||||
class SystemManager
|
||||
{
|
||||
public:
|
||||
SystemManager() = default;
|
||||
~SystemManager();
|
||||
|
||||
template<typename T, typename... Args>
|
||||
T& AddSystem(Args&&... args)
|
||||
{
|
||||
static_assert(std::is_base_of_v<BaseSystem, T>);
|
||||
auto system = std::make_unique<T>(std::forward<Args>(args)...);
|
||||
T& ref = *system;
|
||||
m_systems.emplace_back(std::move(system));
|
||||
return ref;
|
||||
}
|
||||
|
||||
void Create(ECWorld& world);
|
||||
void Destroy(ECWorld& world);
|
||||
|
||||
void Update(ECWorld& world, float dt);
|
||||
|
||||
private:
|
||||
std::vector<std::unique_ptr<BaseSystem>> m_systems;
|
||||
};
|
||||
|
||||
|
||||
|
||||
#endif //EU07_SYSTEMMANAGER_H
|
||||
Reference in New Issue
Block a user