Line |
Branch |
Exec |
Source |
1 |
|
|
#pragma once |
2 |
|
|
|
3 |
|
|
#include "Types.hpp" |
4 |
|
|
#include "EntityManager.hpp" |
5 |
|
|
#include "ComponentManager.hpp" |
6 |
|
|
|
7 |
|
|
namespace ECS { |
8 |
|
|
class World { |
9 |
|
|
private: |
10 |
|
|
EntityManager m_entityManager; |
11 |
|
|
ComponentManager m_componentManager; |
12 |
|
|
|
13 |
|
|
public: |
14 |
|
6 |
World() = default; |
15 |
|
6 |
~World() = default; |
16 |
|
|
|
17 |
|
|
// Entity operations |
18 |
|
|
EntityID CreateEntity(); |
19 |
|
|
void DestroyEntity(EntityID entity); |
20 |
|
|
bool IsEntityAlive(EntityID entity) const; |
21 |
|
|
|
22 |
|
|
// Component operations |
23 |
|
|
template<typename T, typename... Args> |
24 |
|
20 |
T* AddComponent(EntityID entity, Args&&... args) { |
25 |
|
20 |
return m_componentManager.AddComponent<T>(entity, std::forward<Args>(args)...); |
26 |
|
|
} |
27 |
|
|
|
28 |
|
|
template<typename T> |
29 |
|
6 |
T* GetComponent(EntityID entity) { |
30 |
|
6 |
return m_componentManager.GetComponent<T>(entity); |
31 |
|
|
} |
32 |
|
|
|
33 |
|
|
template<typename T> |
34 |
|
1 |
void RemoveComponent(EntityID entity) { |
35 |
|
1 |
m_componentManager.RemoveComponent<T>(entity); |
36 |
|
1 |
} |
37 |
|
|
|
38 |
|
|
template<typename T> |
39 |
|
5 |
bool HasComponent(EntityID entity) const { |
40 |
|
5 |
return m_componentManager.HasComponent<T>(entity); |
41 |
|
|
} |
42 |
|
|
|
43 |
|
|
template<typename T> |
44 |
|
✗ |
ComponentArray<T>* GetAllComponents() { |
45 |
|
✗ |
return m_componentManager.GetAllComponents<T>(); |
46 |
|
|
} |
47 |
|
|
|
48 |
|
|
// Utility |
49 |
|
|
void Clear(); |
50 |
|
|
size_t GetAliveEntityCount() const; |
51 |
|
|
}; |
52 |
|
|
} |
53 |
|
|
|