![]() |
Flecs v3.1
A fast entity component system (ECS) for C & C++
|
Get information from entity. More...
Functions | |
const ecs_type_t * | ecs_get_type (const ecs_world_t *world, ecs_entity_t entity) |
Get the type of an entity. | |
ecs_table_t * | ecs_get_table (const ecs_world_t *world, ecs_entity_t entity) |
Get the table of an entity. | |
char * | ecs_type_str (const ecs_world_t *world, const ecs_type_t *type) |
Convert type to string. | |
char * | ecs_table_str (const ecs_world_t *world, const ecs_table_t *table) |
Convert table to string. | |
char * | ecs_entity_str (const ecs_world_t *world, ecs_entity_t entity) |
Convert entity to string. | |
bool | ecs_has_id (const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id) |
Test if an entity has an entity. | |
ecs_entity_t | ecs_get_target (const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, int32_t index) |
Get the target of a relationship. | |
ecs_entity_t | ecs_get_target_for_id (const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, ecs_id_t id) |
Get the target of a relationship for a given id. | |
int32_t | ecs_get_depth (const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel) |
Return depth for entity in tree for relationship rel. | |
int32_t | ecs_count_id (const ecs_world_t *world, ecs_id_t entity) |
Count entities that have the specified id. | |
Get information from entity.
int32_t ecs_count_id | ( | const ecs_world_t * | world, |
ecs_id_t | entity | ||
) |
Count entities that have the specified id.
Returns the number of entities that have the specified id.
world | The world. |
entity | The id to search for. |
char * ecs_entity_str | ( | const ecs_world_t * | world, |
ecs_entity_t | entity | ||
) |
Convert entity to string.
Same as combining:
The result of this operation must be freed with ecs_os_free.
world | The world. |
entity | The entity. |
int32_t ecs_get_depth | ( | const ecs_world_t * | world, |
ecs_entity_t | entity, | ||
ecs_entity_t | rel | ||
) |
Return depth for entity in tree for relationship rel.
Depth is determined by counting the number of targets encountered while traversing up the relationship tree for rel. Only acyclic relationships are supported.
world | The world. |
entity | The entity. |
rel | The relationship. |
ecs_table_t * ecs_get_table | ( | const ecs_world_t * | world, |
ecs_entity_t | entity | ||
) |
Get the table of an entity.
world | The world. |
entity | The entity. |
ecs_entity_t ecs_get_target | ( | const ecs_world_t * | world, |
ecs_entity_t | entity, | ||
ecs_entity_t | rel, | ||
int32_t | index | ||
) |
Get the target of a relationship.
This will return a target (second element of a pair) of the entity for the specified relationship. The index allows for iterating through the targets, if a single entity has multiple targets for the same relationship.
If the index is larger than the total number of instances the entity has for the relationship, the operation will return 0.
world | The world. |
entity | The entity. |
rel | The relationship between the entity and the target. |
index | The index of the relationship instance. |
ecs_entity_t ecs_get_target_for_id | ( | const ecs_world_t * | world, |
ecs_entity_t | entity, | ||
ecs_entity_t | rel, | ||
ecs_id_t | id | ||
) |
Get the target of a relationship for a given id.
This operation returns the first entity that has the provided id by following the specified relationship. If the entity itself has the id then entity will be returned. If the id cannot be found on the entity or by following the relationship, the operation will return 0.
This operation can be used to lookup, for example, which prefab is providing a component by specifying the IsA relationship:
// Is Position provided by the entity or one of its base entities? ecs_get_target_for_id(world, entity, EcsIsA, ecs_id(Position))
world | The world. |
entity | The entity. |
rel | The relationship to follow. |
id | The id to lookup. |
const ecs_type_t * ecs_get_type | ( | const ecs_world_t * | world, |
ecs_entity_t | entity | ||
) |
Get the type of an entity.
world | The world. |
entity | The entity. |
bool ecs_has_id | ( | const ecs_world_t * | world, |
ecs_entity_t | entity, | ||
ecs_id_t | id | ||
) |
Test if an entity has an entity.
This operation returns true if the entity has the provided entity in its type.
world | The world. |
entity | The entity. |
id | The id to test for. |
char * ecs_table_str | ( | const ecs_world_t * | world, |
const ecs_table_t * | table | ||
) |
Convert table to string.
Same as ecs_type_str(world, ecs_table_get_type(table)). The result of this operation must be freed with ecs_os_free.
world | The world. |
table | The table. |
char * ecs_type_str | ( | const ecs_world_t * | world, |
const ecs_type_t * | type | ||
) |
Convert type to string.
The result of this operation must be freed with ecs_os_free.
world | The world. |
type | The type. |