-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEntityManager.h
More file actions
54 lines (36 loc) · 1.39 KB
/
EntityManager.h
File metadata and controls
54 lines (36 loc) · 1.39 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#ifndef _ENTITYMANAGER_H_
#define _ENTITYMANAGER_H_
#include <map>
#include <vector>
#include "ComponentType.h"
#include "Entity.h"
#include "IComponent.h"
class EntityManager
{
public:
EntityManager();
~EntityManager();
IComponent* GetComponent(const unsigned int &entity, std::type_index type);
// Returns vector of pointers to IComponents of all components
std::vector<IComponent*> GetAllComponentsOfType(std::type_index type);
// Grabs all entities with components
std::vector<unsigned int> GetAllEntitiesPossessingComponents(std::initializer_list<std::type_index> types);
// Adds component to given entity
void AddComponent(const unsigned int entityID, IComponent* component, std::type_index type, const bool replace = false);
// Removes component from given entity
void RemoveComponent(const unsigned int entityID, std::type_index type);
// Creates and returns pointer to entity
unsigned int CreateEntity();
// Destroys entity
void DestroyEntity(unsigned int entityID);
//TODO: Finds and returns entity by name
//Entity* FindWithName(std::string name);
//TODO: Finds and returns a vector of entities with tag, returns null if none are found
//std::vector<Entity*> FindEntitiesWithTag(std::string tag);
void Update();
private:
std::map<unsigned int, Entity> entities;
unsigned int lastID{ 1 };
std::map <std::initializer_list<IComponent>, unsigned int> component;
};
#endif