Function ecs_emit


#include <include/flecs.h>

FLECS_API 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.

To send a notification for a single entity, an application should set the following members in the event descriptor:

  • table: set to the table of the entity
  • offset: set to the row of the entity in the table
  • count: set to 1

The table & row of the entity can be obtained like this: ecs_record_t *r = ecs_record_find(world, e); desc.table = r->table; desc.offset = ECS_RECORD_TO_ROW(r->row);


world - The world.

desc - Event parameters.


Line 3760 in include/flecs.h.