1#include <group_by.h>
2#include <stdio.h>
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22typedef struct {
23 double x, y;
24} Position;
25
26int main(int argc, char *argv[]) {
28
31
32
33
35
36
40
41
43 .terms = {
45 },
46
47
48
49 .group_by = Group
50 });
51
52
54 ecs_set(ecs, e1, Position, {1, 1});
55
57 ecs_set(ecs, e2, Position, {2, 2});
58
60 ecs_set(ecs, e3, Position, {3, 3});
61
63 ecs_set(ecs, e4, Position, {4, 4});
65
67 ecs_set(ecs, e5, Position, {5, 5});
69
71 ecs_set(ecs, e6, Position, {6, 6});
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
91 Position *p =
ecs_field(&it, Position, 0);
94
95 printf(" - group %s: table [%s]\n", group_str, table_str);
96
97 for (
int i = 0; i < it.
count; i ++) {
98 printf(" {%f, %f}\n", p[i].x, p[i].y);
99 }
100
101 ecs_os_free(group_str);
102 ecs_os_free(table_str);
103 printf("\n");
104 }
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
126}
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.
char * ecs_table_str(const ecs_world_t *world, const ecs_table_t *table)
Convert a table to a string.
#define ecs_add(world, entity, T)
Add a component to an entity.
#define ecs_new_w_pair(world, first, second)
Create a new entity with a pair.
#define ECS_COMPONENT(world, id)
Declare and define a component.
#define ECS_TAG(world, id)
Declare and define a tag.
#define ecs_query(world,...)
Shorthand for creating a query with ecs_query_init().
#define ecs_get_path(world, child)
Get path from root.
#define ecs_set(world, entity, component,...)
Set a component value.
#define ecs_field(it, T, index)
Get field data for a component.
uint64_t ecs_iter_get_group(const ecs_iter_t *it)
Return the group ID for the currently iterated result.
bool ecs_query_next(ecs_iter_t *it)
Progress a query iterator.
ecs_iter_t ecs_query_iter(const ecs_world_t *world, const ecs_query_t *query)
Create a query iterator.
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_table_t * table
Current table.
int32_t count
Number of entities to iterate.
Queries are lists of constraints (terms) that match entities.