2#include <stdio.h>
3
4typedef struct {
5 double temperature;
6 double pressure;
7 double precipitation;
8} WeatherStation;
9
11
14
15
18}
19
20int main(int argc, char *argv[]) {
22
23
25
27
28
29
31 .entity =
ecs_id(WeatherStation),
32 .members = {
33 {
34 .name = "temperature",
37 },
38 {
39 .name = "pressure",
42 },
43 {
44 .name = "precipitation",
47 },
48 }
49 });
50
52
53
54 WeatherStation *ptr =
ecs_ensure(ecs, e, WeatherStation);
56
58 print_value(ecs, &cur);
60 print_value(ecs, &cur);
62 print_value(ecs, &cur);
64
66
67
68
69
70
71}
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
#define ECS_IMPORT(world, id)
Wrapper around ecs_import().
FLECS_API ecs_entity_t EcsMilliMeters
MilliMeters unit.
FLECS_API ecs_entity_t EcsBar
Bar unit.
FLECS_API ecs_entity_t EcsCelsius
Celsius unit.
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_COMPONENT(world, id)
Declare and define a component.
#define ecs_ensure(world, entity, T)
Ensure entity has a component, return mutable pointer.
#define ecs_get(world, entity, T)
Get a component.
#define ecs_insert(world,...)
Insert a new entity with a list of component values.
#define ecs_value(T,...)
Convenience macro for creating a compound literal value literal.
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.
Component that stores unit data.
char * symbol
Unit symbol.