TailorMade 2.0
Tailor Made is a high-performance C++20 ECS library with on-the-fly entity creation and JSON-based definitions for entities, components, and their relationships.
 
Loading...
Searching...
No Matches
EntityManager.h
Go to the documentation of this file.
1
7
8#ifndef _ENTITYMANAGER_H
9#define _ENTITYMANAGER_H
10
11#include <queue>
12#include <unordered_set>
13#include <TM_Tools.h>
14
23
25public:
30
35 EntityManager(const std::string& directory);
36
41 int getEntity(const std::string& name);
42
50 std::vector<int> getEntities(const std::string& prefixOrTag, bool isPrefix = true);
51
55 std::vector<std::string> getNames();
56
61 const std::string& getName(int entity);
62
69 int createEntity(const std::string& name, bool createFile = false);
70
76 void removeEntity(const std::string& name);
77
83 void toString(std::ostream& stream);
84
90 bool hasTag(int entity, const std::string& tag);
91
97 void addTag(int entity, const std::string& tag);
98
99private:
103 std::map<std::string, int> entities;
104
109 std::vector<std::string> names;
110
115 std::queue<int> availableIDs;
116
121 int count;
122
126 std::string directory;
127
132 std::string placeholder;
133
137 std::unordered_map<std::string, std::unordered_set<int>> tags;
138};
139
140#endif //_ENTITYMANAGER_H
Project TailorMade.
void addTag(int entity, const std::string &tag)
Add a tag to an entity.
const std::string & getName(int entity)
Return the name of an entity based on its ID.
void removeEntity(const std::string &name)
Remove an entity from the EntityManager.
EntityManager()
Default constructor of the EntityManager.
int getEntity(const std::string &name)
Return the ID of an Entity based on its name.
bool hasTag(int entity, const std::string &tag)
Return true if the entity have the given tag, false otherwise.
std::vector< int > getEntities(const std::string &prefixOrTag, bool isPrefix=true)
Return every entities with a name which start by the given prefix or all the entities of a tag.
void toString(std::ostream &stream)
Append a serialized version of the EntityManager to the given stream.
EntityManager(const std::string &directory)
Constructor of the EntityManager, take the root directory with the entities as a parameter.
std::vector< std::string > getNames()
Return a vector with the names of all the entities.
int createEntity(const std::string &name, bool createFile=false)
Create a new entity and return its ID.