1#include <hooks.h>
2#include <stdio.h>
3
4
5
6
7typedef struct {
8 char *value;
9} String;
10
11
12
13
14
15
18 ptr->value = NULL;
19})
20
21
24 ecs_os_free(ptr->value);
25})
26
27
30 ecs_os_free(dst->value);
31 dst->value = src->value;
32 src->value = NULL;
33
34})
35
36
39 ecs_os_free(dst->value);
40 dst->value = ecs_os_strdup(src->value);
41})
42
43
44
48
49 for (
int i = 0; i < it->
count; i ++) {
53 }
54}
55
56int main(int argc, char *argv[]) {
58
61
63
64
69
70
71 .on_add = hook_callback,
72 .on_remove = hook_callback,
73 .on_set = hook_callback
74 });
75
77
79
84
85 ecs_trace(
"ecs_set(world, e, String, {\"Hello World\"})");
87 ecs_set(world, e, String, {ECS_CONST_CAST(
char*,
"Hello World")});
89
90
95
100
102
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119}
#define ecs_log_push()
Push log indentation at the default level.
#define ecs_trace(...)
Tracing macro.
#define ecs_log_pop()
Pop log indentation at the default level.
FLECS_API int ecs_log_set_level(int level)
Enable or disable log.
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.
void ecs_delete(ecs_world_t *world, ecs_entity_t entity)
Delete an entity.
#define ecs_add(world, entity, T)
Add a component to an entity.
#define ecs_set_hooks(world, T,...)
Set component hooks.
#define ecs_move(type)
Map from typename to move function name.
#define ECS_CTOR(type, var,...)
Declare a constructor.
#define ECS_MOVE(type, dst_var, src_var,...)
Declare a move action.
#define ECS_DTOR(type, var,...)
Declare a destructor.
#define ecs_copy(type)
Map from typename to copy function name.
#define ecs_dtor(type)
Map from typename to destructor function name.
#define ECS_COPY(type, dst_var, src_var,...)
Declare a copy action.
#define ecs_ctor(type)
Map from typename to constructor function name.
#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_TAG(world, id)
Declare and define a tag.
#define ecs_set(world, entity, component,...)
Set a component value.
const char * ecs_get_name(const ecs_world_t *world, ecs_entity_t entity)
Get the name of an entity.
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.
ecs_entity_t event
The event (if applicable).
int32_t count
Number of entities to iterate.
const ecs_entity_t * entities
Entity identifiers.