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 314-343 in include/flecs.h.

struct ecs_observer_t {
    ecs_filter_t filter;

    /* Triggers created by observer (array size same as number of terms) */
    ecs_entity_t *triggers;

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

    ecs_iter_action_t action;   /* Callback */

    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_entity_t entity;        /* Observer entity */
    ecs_entity_t self;          /* Entity associated with observer */

    ecs_observable_t *observable;  /* Observable for observer */

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

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