1#include <setting_variables.h>
2#include <stdio.h>
3
4
5
6
7
8
9
10
11static const int PlayerCount = 100;
12static const int PlatoonsPerPlayer = 3;
13
14int main(int argc, char *argv[]) {
16
17
25
27
35
36
39
40
41 for (int p = 0; p < PlayerCount; p ++) {
43
44
45 if (p == 0) {
46 player =
ecs_entity(ecs, { .name =
"MyPlayer" });
47 } else {
49 }
50
51
53
54 for (int pl = 0; pl < PlatoonsPerPlayer; pl ++) {
56
57
59
60
63
66
69 }
70 }
71
72
73
74
75
76
77
78
80 .terms = {
81 { .first.id = RangedUnit },
82 { .first.id = Platoon, .second.name = "$platoon" },
83 { .first.id = Player, .src.name = "$platoon", .second.name = "$player" }
84 }
85 });
86
87
88
89
90
91
94
95
98
104
105 for (
int i = 0; i < it.
count; i ++) {
107 printf("Unit %s of class %s in platoon %s for player %s\n",
108 unit_str, class_str, platoon_str,
110 ecs_os_free(unit_str);
111 }
112
113 ecs_os_free(class_str);
114 ecs_os_free(platoon_str);
115 }
116
118
119
120
121
122
123
124
125
126
128}
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.
ecs_entity_t ecs_new(ecs_world_t *world)
Create new entity ID.
ecs_entity_t ecs_new_w_id(ecs_world_t *world, ecs_id_t component)
Create new entity with (component) ID.
#define ecs_add_pair(world, subject, first, second)
Add a pair to an entity.
#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_entity(world,...)
Shorthand for creating an entity with ecs_entity_init().
#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.
char * ecs_id_str(const ecs_world_t *world, ecs_id_t component)
Convert a component ID to a string.
ecs_id_t ecs_field_id(const ecs_iter_t *it, int8_t index)
Return the ID matched for a field.
void ecs_iter_set_var(ecs_iter_t *it, int32_t var_id, ecs_entity_t entity)
Set the value for an iterator variable.
ecs_entity_t ecs_iter_get_var(ecs_iter_t *it, int32_t var_id)
Get the value of an iterator variable as an entity.
ecs_entity_t ecs_lookup(const ecs_world_t *world, const char *path)
Look up an entity by its path.
const char * ecs_get_name(const ecs_world_t *world, ecs_entity_t entity)
Get the name of an entity.
bool ecs_query_next(ecs_iter_t *it)
Progress a query iterator.
int32_t ecs_query_find_var(const ecs_query_t *query, const char *name)
Find a variable index.
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.
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.