44 template <
typename Func>
47 typename std::decay<Func>::type>;
48 auto ctx = FLECS_NEW(Delegate)(FLECS_FWD(func));
50 desc.
run = Delegate::run;
58 template <
typename Func>
60 using CallbackComponents =
62 return each_callback(CallbackComponents{}, FLECS_FWD(func));
67 template <
typename Func>
69 using CallbackComponents =
71 return run_each_callback(CallbackComponents{}, FLECS_FWD(func));
80 template <
typename ... CallbackComponents,
typename Func>
81 observer& each_callback(_::arg_list<CallbackComponents...>, Func&& func) {
83 typename std::decay<Func>::type, CallbackComponents...>;
84 auto ctx = FLECS_NEW(Delegate)(FLECS_FWD(func));
93 template <
typename ... CallbackComponents,
typename Func>
94 observer& run_each_callback(_::arg_list<CallbackComponents...>, Func&& func) {
95 using Delegate =
typename _::each_delegate<
96 typename std::decay<Func>::type, CallbackComponents...>;
97 auto ctx = FLECS_NEW(Delegate)(FLECS_FWD(func));
99 desc.
run = Delegate::run_each;
112template <
typename... Comps,
typename... Args>
113inline observer_builder<Comps...>
world::observer(Args &&... args)
const {
ecs_world_t world_t
World type.
flecs::observer observer(flecs::entity e) const
Observer world mixin.
ecs_entity_t ecs_observer_update(ecs_world_t *world, ecs_entity_t observer, const ecs_observer_desc_t *desc)
Update an existing observer.
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.
Used with ecs_observer_init().
ecs_ctx_free_t run_ctx_free
Callback to free run ctx.
void * run_ctx
Context associated with run (for language bindings).
void * callback_ctx
Context associated with callback (for language bindings).
void * ctx
User context to pass to callback.
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_run_action_t run
Callback invoked on an event.
void * ctx
Observer context.
Extract the component argument list from an each-callback signature.
flecs::type type() const
Get the entity's type.
entity()
Default constructor.
flecs::world world() const
Get the world.
flecs::id_t id_
The raw ID value.
flecs::world_t * world_
World is optional, but guarantees that entity identifiers extracted from the ID are valid.
void * ctx() const
Get the observer context.
observer()
Default constructor.
observer & run_each(Func &&func)
Replace the observer's run callback and use an each callback for iteration.
observer(flecs::world_t *world, ecs_observer_desc_t *desc)
Construct from a world and an observer descriptor.
observer & ctx(void *ctx)
Set the observer context.
observer & run(Func &&func)
Replace the observer's run callback.
observer & each(Func &&func)
Replace the observer's each callback.
flecs::query query() const
Get the query for this observer.
world_t * world_
Pointer to the underlying C world.