Flecs v4.0
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. | |
void | ecs_remove_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id) |
Remove a (component) id from an entity. | |
void | ecs_auto_override_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id) |
Add auto override for (component) id. | |
void | ecs_clear (ecs_world_t *world, ecs_entity_t entity) |
Clear all components. | |
void | ecs_remove_all (ecs_world_t *world, ecs_id_t id) |
Remove all instances of the specified (component) id. | |
ecs_entity_t | ecs_set_with (ecs_world_t *world, ecs_id_t id) |
Set current with id. | |
ecs_id_t | ecs_get_with (const ecs_world_t *world) |
Get current with id. | |
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_auto_override_id | ( | ecs_world_t * | world, |
ecs_entity_t | entity, | ||
ecs_id_t | id ) |
Add auto override for (component) id.
An auto override is a component that is automatically added to an entity when it is instantiated from a prefab. Auto overrides are added to the entity that is inherited from (usually a prefab). For example:
An auto override is equivalent to a manual override:
This operation is equivalent to manually adding the id with the AUTO_OVERRIDE bit applied:
When a component is overridden and inherited from a prefab, the value from the prefab component is copied to the instance. When the component is not inherited from a prefab, it is added to the instance as if using ecs_add_id().
Overriding is the default behavior on prefab instantiation. Auto overriding is only useful for components with the (OnInstantiate, Inherit)
trait. When a component has the (OnInstantiate, DontInherit)
trait and is overridden the component is added, but the value from the prefab will not be copied.
world | The world. |
entity | The entity. |
id | The (component) id to auto override. |
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_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. |