1#include <basics.h>
2#include <stdio.h>
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26typedef struct {
27 double x, y;
28} Position;
29
32
33
35
36
38
39
41
42 for (
int i = 0; i < it->
count; i ++) {
44
46
47
48
49 printf(" - OnAdd: %s: %s\n",
52 } else {
53
54 printf(" - %s: %s: %s: {%f, %f}\n",
58 p[i].x, p[i].y);
59 }
60 }
61}
62
63int main(int argc, char *argv[]) {
65
67
68
69
71
72 .query = { .terms = {{ .id =
ecs_id(Position) }}},
73
75
76 .callback = Observer
77 });
78
79
81
82
84
85
86 ecs_set(ecs, e, Position, {10, 20});
87
88
90
91
93
95
96
97
98
99
100}
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
ecs_id_t ecs_entity_t
An entity identifier.
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
#define ecs_remove(world, entity, T)
Remove a component from an entity.
#define ecs_entity(world,...)
Shorthand for creating an entity with ecs_entity_init().
#define ECS_OBSERVER(world, id, kind,...)
Declare and define an observer.
#define ecs_observer(world,...)
Shorthand for creating an observer with ecs_observer_init().
#define ECS_COMPONENT(world, id)
Declare and define a component.
#define ecs_set(world, entity, component,...)
Set a component value.
#define ecs_field(it, T, index)
Get field data for a component.
const char * ecs_get_name(const ecs_world_t *world, ecs_entity_t entity)
Get the name of an entity.
int ecs_fini(ecs_world_t *world)
Delete a world.
ecs_world_t * ecs_init_w_args(int argc, char *argv[])
Create a new world with arguments.
ecs_entity_t event
The event (if applicable).
ecs_id_t event_id
The (component) ID for the event.
int32_t count
Number of entities to iterate.
const ecs_entity_t * entities
Entity identifiers.