Function ecs_search_relation


#include <include/flecs.h>

FLECS_API int32_t ecs_search_relation(const ecs_world_t *world, const ecs_table_t *table, int32_t offset, ecs_id_t id, ecs_entity_t rel, ecs_flags32_t flags, ecs_entity_t *subject_out, ecs_id_t *id_out, struct ecs_table_record_t **tr_out)


Search for component/relationship id in table type starting from an offset. This operation is the same as ecs_search_offset, but has the additional capability of traversing relationships to find a component. For example, if an application wants to find a component for either the provided table or a prefab (using the IsA relationship) of that table, it could use the operation like this:

int32_t index = ecs_search_relation( world, // the world table, // the table 0, // offset 0 ecs_id(Position), // the component id EcsIsA, // the relationship to traverse 0, // start at depth 0 (the table itself) 0, // no depth limit NULL, // (optional) entity on which component was found NULL, // see above NULL); // internal type with information about matched id

The operation searches depth first. If a table type has 2 IsA relationships, the operation will first search the IsA tree of the first relationship.

When choosing betwen ecs_search, ecs_search_offset and ecs_search_relation, the simpler the function the better its performance.


world - The world.

table - The table.

offset - Offset from where to start searching.

id - The id to search for.

rel - The relationship to traverse (optional).

flags - Whether to search EcsSelf and/or EcsUp.

subject_out - If provided, it will be set to the matched entity.

id_out - If provided, it will be set to the found id (optional).

tr_out - Internal datatype.

The index of the id in the table type.


Line 4538 in include/flecs.h.