-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSystem.hpp
More file actions
32 lines (29 loc) · 734 Bytes
/
System.hpp
File metadata and controls
32 lines (29 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include <vector>
#include "EntityManager.hpp"
#include <type_traits>
#include <memory>
class SystemBase {
public:
bool isActive = true;
virtual void Run(float deltaTime) = 0;
virtual ~SystemBase() = default;
};
template <ComponentChild T>
class System : SystemBase {
protected:
std::shared_ptr<ComponentSet<T>> data();
virtual void Execute(std::vector<uint16_t> entities, float deltatime) = 0;
public:
void Run(float deltaTime);
};
template <ComponentChild T>
std::shared_ptr<ComponentSet<T>> System<T>::data() {
return ComponentManager::GetComponentSet<T>();
};
template <ComponentChild T>
void System<T>::Run(float deltaTime) {
if (this->isActive) {
this->Execute(this->data()->entities, deltaTime);
}
}