ecsnet
Loading...
Searching...
No Matches
ecs.h
1#ifndef ECS_H
2#define ECS_H
3
4#pragma once
5#include <stdint.h>
6#include <stdbool.h>
7#include "ecs_types.h"
8#include "config.h"
9#include "ecs_builtin.h"
10
11#ifdef __cplusplus
12extern "C" {
13#endif
18typedef struct {
19 component_t component_id;
20 const void *data;
22
26ECSNET_API ecs_t* ecs_create();
31ECSNET_API void ecs_destroy(ecs_t* ecs);
36ECSNET_API void ecs_init(ecs_t *ecs);
37
43ECSNET_API entity_t ecs_create_entity(ecs_t *ecs);
50ECSNET_API entity_t ecs_try_create_entity_by_id(ecs_t* ecs, entity_t id);
51
57ECSNET_API void ecs_destroy_entity(ecs_t *ecs, entity_t entity);
58
68ECSNET_API bool ecs_serialize_entity(ecs_t *ecs, entity_t entity, uint8_t *out_buffer, size_t *out_size, size_t max_out_size);
69
76ECSNET_API entity_t ecs_deserialize_entity(ecs_t *ecs, const uint8_t *in_buffer);
77
86ECSNET_API bool ecs_add_component(ecs_t *ecs, entity_t entity, component_t component, void *data);
87
95ECSNET_API void *ecs_get_component(ecs_t *ecs, entity_t entity, component_t component);
96
103ECSNET_API const char *ecs_get_component_name(ecs_t *ecs, component_t component);
104
112ECSNET_API bool ecs_has_component(ecs_t *ecs, entity_t entity, component_t component);
113
121ECSNET_API bool ecs_is_component_dirty(ecs_t* ecs, entity_t entity, component_t component);
122
130ECSNET_API bool ecs_remove_component(ecs_t *ecs, entity_t entity, component_t component);
131
139ECSNET_API void ecs_mark_component_dirty(ecs_t *ecs, entity_t entity, component_t component);
145void ecs_set_dirty_hook(void (*hook)(entity_t));
153ECSNET_API int ecs_get_dirty_components(ecs_t *ecs, entity_t entity, dirty_component_t *out_dirty_components);
154
161ECSNET_API void ecs_clear_component_dirty(ecs_t *ecs, entity_t entity, component_t component);
162
169ECSNET_API component_t ecs_register_component(ecs_t *ecs, component_descriptor_t component_descriptor);
170
176ECSNET_API void ecs_register_system(ecs_t *ecs, system_func_t func);
177
183ECSNET_API void ecs_update(ecs_t *ecs, float dt);
184
185
186// Default components.
187ECSNET_API extern component_t COMPONENT_POSITION;
188ECSNET_API extern component_t COMPONENT_ROTATION;
189ECSNET_API extern component_t COMPONENT_TRANSFORM;
190ECSNET_API extern component_t COMPONENT_VELOCITY;
191
192
197ECSNET_API void ecs_register_builtin_systems(ecs_t *ecs);
198
203ECSNET_API void ecs_register_builtin_components(ecs_t *ecs);
204
205
206
207#ifdef __cplusplus
208}
209#endif
210
211#endif
Definition ecs_types.h:77
Dirty flag used by the networking layer to sync ECS data. It marks whether an entity's component has ...
Definition ecs.h:18
Internal structure representing the ECS world state. This holds:
Definition ecs_internal.h:44