1#include <basics_enum.h>
2#include <stdio.h>
3
4typedef enum {
5 Red,
6 Green,
7 Blue
8} Color;
9
10typedef struct {
11 Color color;
12} TypeWithEnum;
13
14int main(int argc, char *argv[]) {
16
17
20
21
24 .constants = {
25 { .name = "Red", .value = Red },
26 { .name = "Green", .value = Green },
27 { .name = "Blue", .value = Blue }
28 }
29 });
30
32 .entity =
ecs_id(TypeWithEnum),
33 .members = {
34 { .name =
"color", .type =
ecs_id(Color) }
35 }
36 });
37
38
40 ecs_set(ecs, ent, TypeWithEnum, {Green});
41
42
43 const TypeWithEnum *ptr =
ecs_get(ecs, ent, TypeWithEnum);
45 printf("%s\n", str);
46 ecs_os_free(str);
47
49}
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
FLECS_API char * ecs_ptr_to_expr(const ecs_world_t *world, ecs_entity_t type, const void *data)
Serialize value into expression string.
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.
#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.
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.