Struct ecs_observer_t

Synopsis

#include <include/flecs.h>

struct ecs_observer_t

Description

An observer reacts to events matching multiple filter terms

Source

Lines 500-535 in include/flecs.h.

struct ecs_observer_t {
    ecs_header_t hdr;

    ecs_filter_t filter;

    /* Observer events */
    ecs_entity_t events[ECS_OBSERVER_DESC_EVENT_COUNT_MAX];
    int32_t event_count;   

    ecs_iter_action_t callback; /* See ecs_observer_desc_t::callback */
    ecs_run_action_t run;       /* See ecs_observer_desc_t::run */

    void *ctx;                  /* Callback context */
    void *binding_ctx;          /* Binding context (for language bindings) */

    ecs_ctx_free_t ctx_free;    /* Callback to free ctx */
    ecs_ctx_free_t binding_ctx_free; /* Callback to free binding_ctx */

    ecs_observable_t *observable;  /* Observable for observer */

    int32_t *last_event_id;     /* Last handled event id */

    ecs_id_t register_id;       /* Id observer is registered with (single term observers only) */
    int32_t term_index;         /* Index of the term in parent observer (single term observers only) */

    bool is_monitor;            /* If true, the observer only triggers when the
                                 * filter did not match with the entity before
                                 * the event happened. */

    bool is_multi;              /* If true, the observer triggers on more than one term */

    /* Mixins */
    ecs_world_t *world;
    ecs_entity_t entity;
    ecs_poly_dtor_t dtor;
};