![]() |
Flecs v3.2
A fast entity component system (ECS) for C & C++
|
Functions for adding and removing components. More...
Functions | |
void | ecs_add_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id) |
Add a (component) id to an entity. More... | |
void | ecs_remove_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id) |
Remove a (component) id from an entity. More... | |
void | ecs_override_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id) |
Add override for (component) id. More... | |
void | ecs_clear (ecs_world_t *world, ecs_entity_t entity) |
Clear all components. More... | |
void | ecs_remove_all (ecs_world_t *world, ecs_id_t id) |
Remove all instances of the specified (component) id. More... | |
ecs_entity_t | ecs_set_with (ecs_world_t *world, ecs_id_t id) |
Set current with id. More... | |
ecs_id_t | ecs_get_with (const ecs_world_t *world) |
Get current with id. More... | |
Functions for adding and removing components.
void ecs_add_id | ( | ecs_world_t * | world, |
ecs_entity_t | entity, | ||
ecs_id_t | id | ||
) |
Add a (component) id to an entity.
This operation adds a single (component) id to an entity. If the entity already has the id, this operation will have no side effects.
world | The world. |
entity | The entity. |
id | The id to add. |
void ecs_clear | ( | ecs_world_t * | world, |
ecs_entity_t | entity | ||
) |
Clear all components.
This operation will remove all components from an entity.
world | The world. |
entity | The entity. |
ecs_id_t ecs_get_with | ( | const ecs_world_t * | world | ) |
Get current with id.
Get the id set with ecs_set_with.
world | The world. |
void ecs_override_id | ( | ecs_world_t * | world, |
ecs_entity_t | entity, | ||
ecs_id_t | id | ||
) |
Add override for (component) id.
Adding an override to an entity ensures that when the entity is instantiated (by adding an IsA relationship to it) the component with the override is copied to a component that is private to the instance. By default components reachable through an IsA relationship are shared.
Adding an override does not add the component. If an override is added to an entity that does not have the component, it will still be added to the instance, but with an uninitialized value (unless the component has a ctor). When the entity does have the entity, the component of the instance will be initialized with the value of the component on the entity.
This is the same as what happens when calling ecs_add_id for an id that is inherited (reachable through an IsA relationship).
This operation is equivalent to doing: ecs_add_id(world, entity, ECS_OVERRIDE | id);
world | The world. |
entity | The entity. |
id | The id to override. |
void ecs_remove_all | ( | ecs_world_t * | world, |
ecs_id_t | id | ||
) |
Remove all instances of the specified (component) id.
This will remove the specified id from all entities (tables). The id may be a wildcard and/or a pair.
world | The world. |
id | The id. |
void ecs_remove_id | ( | ecs_world_t * | world, |
ecs_entity_t | entity, | ||
ecs_id_t | id | ||
) |
Remove a (component) id from an entity.
This operation removes a single (component) id to an entity. If the entity does not have the id, this operation will have no side effects.
world | The world. |
entity | The entity. |
id | The id to remove. |
ecs_entity_t ecs_set_with | ( | ecs_world_t * | world, |
ecs_id_t | id | ||
) |
Set current with id.
New entities are automatically created with the specified id.
world | The world. |
id | The id. |