25 inline void entity_observer_create(
27 flecs::entity_t event,
45 template <
typename Func>
47 template <typename Evt, if_t<is_empty<Evt>::value> = 0>
49 flecs::world_t *
world,
54 auto ctx = FLECS_NEW(Delegate)(FLECS_FWD(f));
58 template <typename Evt, if_not_t<is_empty<Evt>::value> = 0>
60 flecs::world_t *
world,
65 auto ctx = FLECS_NEW(Delegate)(FLECS_FWD(f));
71template <
typename Self>
72template <
typename Func>
75 auto ctx = FLECS_NEW(Delegate)(FLECS_FWD(f));
77 _::entity_observer_create(world_, evt, id_, Delegate::run, ctx, _::free_obj<Delegate>);
82template <
typename Self>
83template <
typename Evt,
typename Func>
86 world_, id_, FLECS_FWD(f));
90template <
typename Self>
91template <
typename Func>
93 return this->observe<_::event_from_func_t<Func>>(FLECS_FWD(f));
flecs::event_builder_typed< E > event() const
Create a new event.
void(* ecs_iter_action_t)(ecs_iter_t *it)
Function prototype for iterables.
void(* ecs_ctx_free_t)(void *ctx)
Function to cleanup context data.
ecs_entity_t ecs_observer_init(ecs_world_t *world, const ecs_observer_desc_t *desc)
Create observer.
Used with ecs_observer_init().
ecs_entity_t events[(8)]
Events to observe (OnAdd, OnRemove, OnSet)
void * callback_ctx
Context associated with callback (for language bindings).
ecs_query_desc_t query
Query for observer.
ecs_ctx_free_t callback_ctx_free
Callback to free callback ctx.
ecs_iter_action_t callback
Callback to invoke on an event, invoked when the observer matches.
ecs_term_t terms[32]
Query terms.
ecs_entity_t id
Entity id.
ecs_term_ref_t src
Source of term.
ecs_id_t id
Component id to be matched by term.
const Self & observe(flecs::entity_t evt, Func &&callback) const
Observe event on entity.
void enqueue() const
Enqueue event for entity.
void emit() const
Emit event for entity.
entity_t id() const
Get entity id.