1#include <group_iter_all.h>
2#include <stdio.h>
3
4
5
6
7
8
9
10typedef struct {
11 double x, y;
12} Position;
13
14int main(int argc, char *argv[]) {
16
18
22
29
30
31
33 .terms = {{ .id =
ecs_id(Position) }},
35 });
36
37
38
40 ecs_map_iter_t mit = ecs_map_iter(groups);
41 while (ecs_map_next(&mit)) {
42 uint64_t group_id = ecs_map_key(&mit);
44 printf("Group %s:\n", group_str);
45 ecs_os_free(group_str);
46
47
51 Position *p =
ecs_field(&it, Position, 0);
52 for (
int i = 0; i < it.
count; i ++) {
54 printf(" - %s: {%.0f, %.0f}\n", e_str, p[i].x, p[i].y);
55 ecs_os_free(e_str);
56 }
57 }
58 }
59
61
62
63
64
65
66
67
68
69
70
71
72
74}
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_new_w_pair(world, first, second)
Create a new entity with a pair.
#define ecs_entity(world,...)
Shorthand for creating an entity with ecs_entity_init().
#define ECS_COMPONENT(world, id)
Declare and define a component.
#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.
void ecs_iter_set_group(ecs_iter_t *it, uint64_t group_id)
Set the group to iterate for a query iterator.
bool ecs_query_next(ecs_iter_t *it)
Progress a query iterator.
void ecs_query_fini(ecs_query_t *query)
Delete a query.
ecs_iter_t ecs_query_iter(const ecs_world_t *world, const ecs_query_t *query)
Create a query iterator.
const ecs_map_t * ecs_query_get_groups(const ecs_query_t *query)
Return the map with query groups.
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.
int32_t count
Number of entities to iterate.
const ecs_entity_t * entities
Entity identifiers.
Queries are lists of constraints (terms) that match entities.