![]() |
Flecs v4.1
A fast entity component system (ECS) for C & C++
|
Functions for working with events and observers. More...
Classes | |
| struct | ecs_observer_desc_t |
| Used with ecs_observer_init(). More... | |
| struct | ecs_event_desc_t |
| Used with ecs_emit(). More... | |
Typedefs | |
| typedef struct ecs_observer_desc_t | ecs_observer_desc_t |
| Used with ecs_observer_init(). | |
| typedef struct ecs_event_desc_t | ecs_event_desc_t |
| Used with ecs_emit(). | |
Functions | |
| void | ecs_emit (ecs_world_t *world, ecs_event_desc_t *desc) |
| Send an event. | |
| void | ecs_enqueue (ecs_world_t *world, ecs_event_desc_t *desc) |
| Enqueue an event. | |
| ecs_entity_t | ecs_observer_init (ecs_world_t *world, const ecs_observer_desc_t *desc) |
| Create an observer. | |
| const ecs_observer_t * | ecs_observer_get (const ecs_world_t *world, ecs_entity_t observer) |
| Get the observer object. | |
Functions for working with events and observers.
| void ecs_emit | ( | ecs_world_t * | world, |
| ecs_event_desc_t * | desc ) |
Send an event.
This sends an event to matching observers and 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 built-in Flecs events, as this may violate assumptions the code makes about the conditions under which those events are sent.
Observers 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 | The event parameters. |
| void ecs_enqueue | ( | ecs_world_t * | world, |
| ecs_event_desc_t * | desc ) |
Enqueue an event.
Same as ecs_emit(), but enqueues an event in the command queue instead. The event will be emitted when ecs_defer_end() is called.
If this operation is called when the provided world is not in deferred mode, it behaves just like ecs_emit().
| world | The world. |
| desc | The event parameters. |
| const ecs_observer_t * ecs_observer_get | ( | const ecs_world_t * | world, |
| ecs_entity_t | observer ) |
Get the observer object.
Return the observer object. Can be used to access various information about the observer, like the query and context.
| world | The world. |
| observer | The observer. |
| ecs_entity_t ecs_observer_init | ( | ecs_world_t * | world, |
| const ecs_observer_desc_t * | desc ) |
Create an observer.
Observers can subscribe for one or more 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. |