Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
impl.hpp
Go to the documentation of this file.
1
6#pragma once
7
8#include "builder.hpp"
9
10namespace flecs
11{
12
17struct observer final : entity
18{
19 using entity::entity;
20
22 explicit observer() : entity() { }
23
29
31 void ctx(void *ctx) {
32 ecs_observer_desc_t desc = {};
33 desc.entity = id_;
34 desc.ctx = ctx;
36 }
37
39 void* ctx() const {
41 }
42
47};
48
50inline observer world::observer(flecs::entity e) const {
51 return flecs::observer(world_, e);
52}
53
54template <typename... Comps, typename... Args>
55inline observer_builder<Comps...> world::observer(Args &&... args) const {
56 return flecs::observer_builder<Comps...>(world_, FLECS_FWD(args)...);
57}
58
59} // namespace flecs
ecs_world_t world_t
World type.
Definition c_types.hpp:18
flecs::observer observer(flecs::entity e) const
Observer world mixin.
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.
Observer builder.
Used with ecs_observer_init().
Definition flecs.h:1349
ecs_entity_t entity
Existing entity to associate with an observer (optional).
Definition flecs.h:1354
void * ctx
User context to pass to callback.
Definition flecs.h:1383
void * ctx
Observer context.
Definition flecs.h:887
Entity.
Definition entity.hpp:30
entity()
Default constructor.
Definition entity.hpp:32
flecs::world world() const
Get the world.
Definition impl.hpp:58
flecs::id_t id_
The raw ID value.
Definition decl.hpp:149
flecs::world_t * world_
World is optional, but guarantees that entity identifiers extracted from the ID are valid.
Definition decl.hpp:147
Observer builder.
Definition builder.hpp:24
Observer.
Definition impl.hpp:18
void * ctx() const
Get the observer context.
Definition impl.hpp:39
observer()
Default constructor.
Definition impl.hpp:22
observer(flecs::world_t *world, ecs_observer_desc_t *desc)
Construct from a world and an observer descriptor.
Definition impl.hpp:25
void ctx(void *ctx)
Set the observer context.
Definition impl.hpp:31
flecs::query query() const
Get the query for this observer.
Definition impl.hpp:44
Typed query.
Definition impl.hpp:220
The world.
Definition world.hpp:246
world_t * world_
Pointer to the underlying C world.
Definition world.hpp:1545