![]() |
Flecs v3.2
A fast entity component system (ECS) for C & C++
|
Functions for working with events and observers. More...
Functions | |
void | ecs_emit (ecs_world_t *world, ecs_event_desc_t *desc) |
Send event. More... | |
void | ecs_enqueue (ecs_world_t *world, ecs_event_desc_t *desc) |
ecs_entity_t | ecs_observer_init (ecs_world_t *world, const ecs_observer_desc_t *desc) |
Create observer. More... | |
bool | ecs_observer_default_run_action (ecs_iter_t *it) |
Default run action for observer. More... | |
void * | ecs_observer_get_ctx (const ecs_world_t *world, ecs_entity_t observer) |
Get observer ctx. More... | |
void * | ecs_observer_get_binding_ctx (const ecs_world_t *world, ecs_entity_t observer) |
Get observer binding ctx. More... | |
Functions for working with events and observers.
void ecs_emit | ( | ecs_world_t * | world, |
ecs_event_desc_t * | desc | ||
) |
Send event.
This sends an event to matching triggers & is the mechanism used by flecs itself to send OnAdd, OnRemove, etc events.
Applications can use this function to send custom events, where a custom event can be any regular entity.
Applications should not send builtin flecs events, as this may violate assumptions the code makes about the conditions under which those events are sent.
Triggers are invoked synchronously. It is therefore safe to use stack-based data as event context, which can be set in the "param" member.
world | The world. |
desc | Event parameters. |
bool ecs_observer_default_run_action | ( | ecs_iter_t * | it | ) |
Default run action for observer.
This function can be called from a custom observer run action (see ecs_observer_desc_t::run for more details). This function ensures that the observer's filter is applied to the iterator's table, filters out duplicate events and implements EcsMonitor logic.
it | The iterator. |
void * ecs_observer_get_binding_ctx | ( | const ecs_world_t * | world, |
ecs_entity_t | observer | ||
) |
Get observer binding ctx.
Return the value set in ecs_observer_desc_t::binding_ctx.
world | The world. |
observer | The observer. |
void * ecs_observer_get_ctx | ( | const ecs_world_t * | world, |
ecs_entity_t | observer | ||
) |
Get observer ctx.
Return the value set in ecs_observer_desc_t::ctx.
world | The world. |
observer | The observer. |
ecs_entity_t ecs_observer_init | ( | ecs_world_t * | world, |
const ecs_observer_desc_t * | desc | ||
) |
Create observer.
Observers are like triggers, but can subscribe for multiple terms. An observer only triggers when the source of the event meets all terms.
See the documentation for ecs_observer_desc_t for more details.
world | The world. |
desc | The observer creation parameters. |