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
System.h
Go to the documentation of this file.
1
7
8
9#ifndef _SYSTEM_H
10#define _SYSTEM_H
11
12#include <Environment.h>
13#include <unordered_set>
14
15class System {
16public:
21 System(std::shared_ptr<Environment> environment, bool autoUpdate = true);
22
27 void newEntity(int entity);
28
33 void changeEnvironment(std::shared_ptr<Environment> environment);
34
38 const size_t& getID();
39
43 bool getChange();
44
48 virtual void run() = 0;
49
50protected:
54 std::unordered_set<int> entities;
58 std::shared_ptr<Environment> environment;
62 std::vector<std::string> desiredComponents;
66 std::vector<std::string> rejectedComponents;
70 std::vector<std::string> desiredTags;
74 std::mutex mtx;
75
80 void addComponent(const std::string& name);
85 void addComponents(std::vector<std::string> names);
86
91 void addRejected(const std::string& name);
96 void addRejects(std::vector<std::string> names);
97
102 void addTag(const std::string& tagName);
107 void addTags(std::vector<std::string> names);
108
109private:
114 bool change;
115
119 size_t ID;
120
124 static size_t nextID;
125};
126
127inline size_t System::nextID = 0; // Initialize the nextID at 0.
128
129#endif //_SYSTEM_H
Project TailorMade.
std::vector< std::string > rejectedComponents
Represent the components this System absolutely doesn't want.
Definition System.h:66
const size_t & getID()
Return the System's ID.
virtual void run()=0
This is an abstract method which will contains the logic of the System and can be call by the user to...
bool getChange()
Return the value of change and, if change is true flipped it back to false.
std::unordered_set< int > entities
The entities of this system.
Definition System.h:54
void newEntity(int entity)
UPDATE THAT.
System(std::shared_ptr< Environment > environment, bool autoUpdate=true)
The constructor of the System, which take the Environment as a parameter.
std::vector< std::string > desiredTags
Represent the tags this System want.
Definition System.h:70
std::shared_ptr< Environment > environment
A shared_ptr towards the Environment.
Definition System.h:58
void addComponent(const std::string &name)
Let you add, inside a System, which component should be gathered from the Environment.
void changeEnvironment(std::shared_ptr< Environment > environment)
Let you change the Environment.
void addTag(const std::string &tagName)
Let you add, inside a System, which tag should be gathered from the Environment.
void addRejects(std::vector< std::string > names)
Version with a list of rejected components.
void addComponents(std::vector< std::string > names)
Version with a list of desired components.
void addTags(std::vector< std::string > names)
Version with a list of tags.
void addRejected(const std::string &name)
Let you add a components to the rejected components, if the entity possess at list one of this compon...
std::vector< std::string > desiredComponents
Represent the components this System want.
Definition System.h:62
std::mutex mtx
Mutex for the entities' vector.
Definition System.h:74