Flecs v4.0
A fast entity component system (ECS) for C & C++
|
Functions for registering and working with components. More...
Classes | |
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... | |
Typedefs | |
typedef struct ecs_component_desc_t | ecs_component_desc_t |
Used with ecs_component_init(). | |
Functions | |
ecs_entity_t | ecs_component_init (ecs_world_t *world, const ecs_component_desc_t *desc) |
Find or create a component. | |
const ecs_type_info_t * | ecs_get_type_info (const ecs_world_t *world, ecs_id_t id) |
Get the type for an id. | |
void | ecs_set_hooks_id (ecs_world_t *world, ecs_entity_t id, const ecs_type_hooks_t *hooks) |
Register hooks for component. | |
const ecs_type_hooks_t * | ecs_get_hooks_id (const ecs_world_t *world, ecs_entity_t id) |
Get hooks for component. | |
Functions for registering and working with components.
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.
world | The world. |
desc | Component init parameters. |
const ecs_type_hooks_t * ecs_get_hooks_id | ( | const ecs_world_t * | world, |
ecs_entity_t | id ) |
Get hooks for component.
world | The world. |
id | The component id for which to retrieve the hooks. |
const ecs_type_info_t * ecs_get_type_info | ( | const ecs_world_t * | world, |
ecs_id_t | id ) |
Get the type for an id.
This function returns the type information for an id. The specified id can be any valid id. For the rules on how type information is determined based on id, see ecs_get_typeid().
world | The world. |
id | The 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().
world | The world. |
id | The component id for which to register the actions |
hooks | Type that contains the component actions. |