1#include <basics_bitmask.h>
2#include <stdio.h>
3
4typedef uint32_t Toppings;
5static const uint32_t Bacon = 0x1;
6static const uint32_t Lettuce = 0x2;
7static const uint32_t Tomato = 0x4;
8
9typedef struct {
10 Toppings toppings;
11} Sandwich;
12
13int main(int argc, char *argv[]) {
15
16
19
20
22 .entity =
ecs_id(Toppings),
23 .constants = {
24 { .name = "Bacon", .value = Bacon },
25 { .name = "Lettuce", .value = Lettuce },
26 { .name = "Tomato", .value = Tomato }
27 }
28 });
29
31 .entity =
ecs_id(Sandwich),
32 .members = {
33 { .name =
"toppings", .type =
ecs_id(Toppings) }
34 }
35 });
36
37
39 ecs_set(ecs, ent, Sandwich, {Bacon | Lettuce});
40
41
42 const Sandwich *ptr =
ecs_get(ecs, ent, Sandwich);
44 printf("%s\n", str);
45 ecs_os_free(str);
46
48}
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.