22 std::unordered_map<std::string, std::vector<std::pair<std::string, dataVector>>>
entities;
50 Environment(
const std::string& entitiesPath,
const std::string& componentsPath,
const std::string& subscriptionsPath);
56 void addManager(std::shared_ptr<ComponentManager> manager);
67 std::shared_ptr<ComponentManager>
getManager(
const std::string& name);
100 void setEntitiesState(
const std::string& prefixOrTag,
bool state,
bool share =
true,
bool isPrefix =
true);
109 void setState(
int entity,
const std::string& compName,
bool state,
bool share =
true);
118 void setState(
const std::string& name,
const std::string& compName,
bool state,
bool share =
true);
129 void setStates(
const std::string& prefixOrTag,
const std::string& compName,
bool state,
bool share =
true,
bool isPrefix =
true);
136 bool getState(
int entity,
const std::string& compName);
143 bool getState(
const std::string& name,
const std::string& compName);
164 int createEntity(
const std::string& name,
bool createFile =
false,
bool share =
true);
184 std::vector<std::shared_ptr<Component>>
getComponents(
const std::string& name);
191 std::shared_ptr<Component>
getComponent(
int entity,
const std::string& name);
198 std::shared_ptr<Component>
getComponent(
const std::string& entityName,
const std::string& name);
205 bool hasComponent(
const std::string& name,
const std::string& compName);
219 bool hasTag(
int entity,
const std::string& tagName);
226 bool hasTag(
const std::string& name,
const std::string& tagName);
234 void addTag(
int entity,
const std::string& tag,
bool share =
true);
242 void addTag(
const std::string& entity,
const std::string& tag,
bool share =
true);
256 void save(
const std::string& name);
264 void join(std::function<
void(
int)> callback,
size_t ID);
289 int copy(
const std::string& original,
const std::string&
copy,
bool createFile =
false,
bool share =
true);
299 void give(
const std::string& component,
int giver,
int receiver,
bool copy,
bool share =
true);
309 void makeSnapshot(
const std::string& snapshotName,
const std::vector<std::string>& toSave = {},
const std::vector<std::string>& components = {});
328 std::unordered_map<std::string, std::shared_ptr<ComponentManager>> mapNC;
333 std::shared_ptr<EntityManager> entityManager;
338 std::shared_ptr<Subscription> subscription;
343 std::unordered_map<size_t, std::function<void(
int)>> notifiers;
348 std::unordered_map<std::string, Snapshot> snapshots;
std::shared_ptr< Component > getComponent(int entity, const std::string &name)
Return the component of a specific entity, with its ID.
std::vector< std::shared_ptr< Component > > getComponents(int entity)
Return all the components from an entity, with its ID.
std::vector< std::shared_ptr< Component > > getComponents(const std::string &name)
Return all the components of an entity, with its name.
void save(const std::string &name)
Let you save the subscription of an entity in a file, it will preserve the current values of the comp...
const std::string & getName(int entity)
Return an entity's name from its ID.
void setEntityState(const std::string &name, bool state, bool share=true)
Let you set an entity's state with its name.
void setEntityState(int entity, bool state, bool share=true)
Let you set an entity's state with its ID.
void addTag(const std::string &entity, const std::string &tag, bool share=true)
Add a tag to an entity.
void give(const std::string &component, int giver, int receiver, bool copy, bool share=true)
Give the ownership, or make a copy, of an entity's component to another component.
std::shared_ptr< ComponentManager > getManager(const std::string &name)
Return a specific ComponentManager.
std::vector< std::shared_ptr< ComponentManager > > getManagers()
Return all the ComponentManagers.
Environment(std::shared_ptr< EntityManager > entityManager)
Constructor of an Environment without files, the only need is an EntityManager.
bool getState(const std::string &name, const std::string &compName)
Return the state of an entity's component, with its name.
std::shared_ptr< Component > getComponent(const std::string &entityName, const std::string &name)
Return the component of a specific entity, with its name.
Environment(const std::string &entitiesPath, const std::string &componentsPath, const std::string &subscriptionsPath)
Constructor which take the paths of the JSON's description of the entities, components and subscripti...
bool hasComponent(const std::string &name, const std::string &compName)
Return true if the given entity possess the given component, false otherwise.
void setState(const std::string &name, const std::string &compName, bool state, bool share=true)
Set the state of a specific component for an entity, with its name.
void save(int entity)
Let you save the subscription of an entity in a file, it will preserve the current values of the comp...
void setEntitiesState(const std::string &prefixOrTag, bool state, bool share=true, bool isPrefix=true)
Let you update the state of all entities with a certain prefix in their name or with a certain tag.
std::shared_ptr< EntityManager > getEntityManager()
Return the EntityManager.
void removeEntity(const std::string &name, bool share=true)
Remove an entity from the EntityManager.
bool hasComponent(int entity, const std::string &compName)
Return true if the given entity possess the given component, false otherwise.
void setState(int entity, const std::string &compName, bool state, bool share=true)
Set the state of a specific component for an entity, with its ID.
void addTag(int entity, const std::string &tag, bool share=true)
Add a tag to an entity.
int getEntity(const std::string &name)
Return an entity's ID from its name.
void join(std::function< void(int)> callback, size_t ID)
Let you join the Environment's update list.
int copy(const std::string &original, const std::string ©, bool createFile=false, bool share=true)
Let you create a new entity, which is a perfect copy of the original.
bool hasTag(const std::string &name, const std::string &tagName)
Return true if the entity have the given tag, false otherwise.
int createEntity(const std::string &name, bool createFile=false, bool share=true)
Create a new entity and return its ID.
void notify(size_t ID)
Will share with a specific system all the entities currently in the environment.
void makeSnapshot(const std::string &snapshotName, const std::vector< std::string > &toSave={}, const std::vector< std::string > &components={})
Make and store a snapshot of the desired entities and components.
void addManager(std::shared_ptr< ComponentManager > manager)
Let you add a ComponentManager from the environment interface.
bool hasTag(int entity, const std::string &tagName)
Return true if the entity have the given tag, false otherwise.
bool getState(int entity, const std::string &compName)
Return the state of an entity's component, with its ID.
void setStates(const std::string &prefixOrTag, const std::string &compName, bool state, bool share=true, bool isPrefix=true)
Set the state of a set of entities for a specific component.
void loadSnapshot(const std::string &snapshotName)
Load the snapshot from the given name if it exist.
void clearSnapshot(const std::string &snapshotName)
Let you clear a snapshot from its name.
void notify(int entity)
Will notify every callbacks of an update in the environment.
Structure of the Snapshot, store the data of the desired components on a subset of entities.
Definition Environment.h:20
std::unordered_map< std::string, std::vector< std::pair< std::string, dataVector > > > entities
Contain every data of the desired components for the registered entities.
Definition Environment.h:22