1#include <nested_prefabs.h>
2#include <stdio.h>
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18typedef struct {
19 double value;
20} TirePressure;
21
22int main(int argc, char *argv[]) {
24
26
27
30 ecs_set(ecs, Wheel, TirePressure, { 32 });
31
32
33
34
40
44
48
52
53
56
57
59
60
61
63 printf("type: [%s]\n", type);
64 ecs_os_free(type);
65
66
67 const TirePressure *p =
ecs_get(ecs, inst_front_left, TirePressure);
68 printf("pressure: %f\n", p->value);
69
70
71
72
73
75}
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Add a (component) ID to an entity.
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.
const ecs_type_t * ecs_get_type(const ecs_world_t *world, ecs_entity_t entity)
Get the type of an entity.
char * ecs_type_str(const ecs_world_t *world, const ecs_type_t *type)
Convert a type to a string.
#define ecs_add_pair(world, subject, first, second)
Add a pair to an entity.
#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_set(world, entity, component,...)
Set a component value.
#define ecs_get(world, entity, T)
Get a component.
ecs_entity_t ecs_lookup_child(const ecs_world_t *world, ecs_entity_t parent, const char *name)
Look up a child entity by name.
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.