Flecs v3.1
A fast entity component system (ECS) for C & C++
No Matches

Functions for registering and working with components. More...


struct  ecs_type_hooks_t
 Type that contains component lifecycle callbacks. More...
struct  ecs_type_info_t
 Type that contains component information (passed to ctors/dtors/...) More...
struct  ecs_component_desc_t
 Used with ecs_component_init. More...


typedef struct ecs_component_desc_t ecs_component_desc_t
 Used with ecs_component_init.


ecs_entity_t ecs_component_init (ecs_world_t *world, const ecs_component_desc_t *desc)
 Find or create a component. More...
void ecs_set_hooks_id (ecs_world_t *world, ecs_entity_t id, const ecs_type_hooks_t *hooks)
 Register hooks for component. More...
const ecs_type_hooks_tecs_get_hooks_id (ecs_world_t *world, ecs_entity_t id)
 Get hooks for component. More...

Detailed Description

Functions for registering and working with components.

Function Documentation

◆ ecs_component_init()

ecs_entity_t ecs_component_init ( ecs_world_t world,
const ecs_component_desc_t desc 

Find or create a component.

This operation creates a new component, or finds an existing one. The find or create behavior is the same as ecs_entity_init.

When an existing component is found, the size and alignment are verified with the provided values. If the values do not match, the operation will fail.

See the documentation of ecs_component_desc_t for more details.

worldThe world.
descComponent init parameters.
A handle to the new or existing component, or 0 if failed.

◆ ecs_get_hooks_id()

const ecs_type_hooks_t * ecs_get_hooks_id ( ecs_world_t world,
ecs_entity_t  id 

Get hooks for component.

worldThe world.
idThe component id for which to retrieve the hooks.
The hooks for the component, or NULL if not registered.

◆ ecs_set_hooks_id()

void ecs_set_hooks_id ( ecs_world_t world,
ecs_entity_t  id,
const ecs_type_hooks_t hooks 

Register hooks for component.

Hooks allow for the execution of user code when components are constructed, copied, moved, destructed, added, removed or set. Hooks can be assigned as as long as a component has not yet been used (added to an entity).

The hooks that are currently set can be accessed with ecs_get_type_info.

worldThe world.
idThe component id for which to register the actions
hooksType that contains the component actions.