Flecs: include/flecs.h Source File
Description: A fast entity component system (ECS) for C & C++

| Flecs v4.1 A fast entity component system (ECS) for C & C++

Loading...
Searching...
No Matches
flecs.h
Go to the documentation of this file.
1
7
8#ifndef FLECS_H
9#define FLECS_H
10
17
25
32
33/* Flecs version macros */
34#define FLECS_VERSION_MAJOR 4
35#define FLECS_VERSION_MINOR 1
36#define FLECS_VERSION_PATCH 5
37
39#define FLECS_VERSION FLECS_VERSION_IMPL(\
40 FLECS_VERSION_MAJOR, FLECS_VERSION_MINOR, FLECS_VERSION_PATCH)
41
45#ifdef FLECS_CONFIG_HEADER
46#include "flecs_config.h"
47#endif
48
51#ifndef ecs_float_t
52#define ecs_float_t float
53#endif
54
58#ifndef ecs_ftime_t
59#define ecs_ftime_t ecs_float_t
60#endif
61
62
68// #define FLECS_ACCURATE_COUNTERS
69
75// #define FLECS_DISABLE_COUNTERS
76
77/* Make sure provided configuration is valid */
78#if defined(FLECS_DEBUG) && defined(FLECS_NDEBUG)
79#warning "invalid configuration: cannot both define FLECS_DEBUG and FLECS_NDEBUG"
80#endif
81#if defined(FLECS_DEBUG) && defined(NDEBUG)
82#warning "invalid configuration: cannot both define FLECS_DEBUG and NDEBUG"
83#endif
84
89#if !defined(FLECS_DEBUG) && !defined(FLECS_NDEBUG)
90#if defined(NDEBUG)
91#define FLECS_NDEBUG
92#else
93#define FLECS_DEBUG
94#endif
95#endif
96
101#ifdef FLECS_SANITIZE
102#ifndef FLECS_DEBUG
103#define FLECS_DEBUG /* If sanitized mode is enabled, so is debug mode */
104#endif
105#endif
106
111#ifdef FLECS_DEBUG
112#ifndef FLECS_DEBUG_INFO
113#define FLECS_DEBUG_INFO
114#endif
115#endif
116
117/* Tip: if you see weird behavior that you think might be a bug, make sure to
118 * test with the FLECS_DEBUG or FLECS_SANITIZE flags enabled. There's a good
119 * chance that this gives you more information about the issue! */
120
134// #define FLECS_SOFT_ASSERT
135
141// #define FLECS_KEEP_ASSERT
142
149// #define FLECS_DEFAULT_TO_UNCACHED_QUERIES
150
163// #define FLECS_CREATE_MEMBER_ENTITIES
164
173// #define FLECS_CPP_NO_AUTO_REGISTRATION
174
182// #define FLECS_CPP_NO_ENUM_REFLECTION
183
188// #define FLECS_NO_ALWAYS_INLINE
189
217// #define FLECS_CUSTOM_BUILD
218
219#ifndef FLECS_CUSTOM_BUILD
220#define FLECS_ALERTS
221#define FLECS_APP
222// #define FLECS_C /**< C API convenience macros, always enabled. */
223#define FLECS_CPP
224#define FLECS_DOC
225// #define FLECS_JOURNAL /**< Journaling addon. */
226#define FLECS_JSON
227#define FLECS_HTTP
228#define FLECS_LOG
229#define FLECS_META
230#define FLECS_METRICS
231#define FLECS_MODULE
232#define FLECS_OS_API_IMPL
233// #define FLECS_PERF_TRACE /**< Enable performance tracing. */
234#define FLECS_PIPELINE
235#define FLECS_REST
236#define FLECS_PARSER
237#define FLECS_QUERY_DSL
238#define FLECS_SCRIPT
239// #define FLECS_SCRIPT_MATH /**< Math functions for Flecs script (may require linking with libm). */
240#define FLECS_SYSTEM
241#define FLECS_STATS
242#define FLECS_TIMER
243#define FLECS_UNITS
244#endif // ifndef FLECS_CUSTOM_BUILD
245
249// #define FLECS_LOW_FOOTPRINT
250#ifdef FLECS_LOW_FOOTPRINT
251#define FLECS_HI_COMPONENT_ID 16
252#define FLECS_HI_ID_RECORD_ID 16
253#define FLECS_ENTITY_PAGE_BITS 6
254#define FLECS_USE_OS_ALLOC
255#define FLECS_DEFAULT_TO_UNCACHED_QUERIES
256#endif
257
272#ifndef FLECS_HI_COMPONENT_ID
273#define FLECS_HI_COMPONENT_ID 256
274#endif
275
282#ifndef FLECS_HI_ID_RECORD_ID
283#define FLECS_HI_ID_RECORD_ID 1024
284#endif
285
291#ifndef FLECS_SPARSE_PAGE_BITS
292#define FLECS_SPARSE_PAGE_BITS 6
293#endif
294
297#ifndef FLECS_ENTITY_PAGE_BITS
298#define FLECS_ENTITY_PAGE_BITS 10
299#endif
300
305// #define FLECS_USE_OS_ALLOC
306
309#ifndef FLECS_ID_DESC_MAX
310#define FLECS_ID_DESC_MAX 32
311#endif
312
315#ifndef FLECS_EVENT_DESC_MAX
316#define FLECS_EVENT_DESC_MAX 8
317#endif
318
321#define FLECS_VARIABLE_COUNT_MAX 64
322
325#ifndef FLECS_TERM_COUNT_MAX
326#define FLECS_TERM_COUNT_MAX 32
327#endif
328
331#ifndef FLECS_TERM_ARG_COUNT_MAX
332#define FLECS_TERM_ARG_COUNT_MAX 16
333#endif
334
337#ifndef FLECS_QUERY_VARIABLE_COUNT_MAX
338#define FLECS_QUERY_VARIABLE_COUNT_MAX 64
339#endif
340
343#ifndef FLECS_QUERY_SCOPE_NESTING_MAX
344#define FLECS_QUERY_SCOPE_NESTING_MAX 8
345#endif
346
351#ifndef FLECS_DAG_DEPTH_MAX
352#define FLECS_DAG_DEPTH_MAX 128
353#endif
354
359#define FLECS_TREE_SPAWNER_DEPTH_CACHE_SIZE (6)
360
362
363#include "flecs/private/api_defines.h"
364
371
374 typedef uint64_t ecs_id_t;
375
381 typedef ecs_id_t ecs_entity_t;
382
398 typedef struct {
399 ecs_id_t *array;
400 int32_t count;
401} ecs_type_t;
402
425 typedef struct ecs_world_t ecs_world_t;
426
428 typedef struct ecs_stage_t ecs_stage_t;
429
431 typedef struct ecs_table_t ecs_table_t;
432
434 typedef struct ecs_term_t ecs_term_t;
435
437 typedef struct ecs_query_t ecs_query_t;
438
456 typedef struct ecs_observer_t ecs_observer_t;
457
461 typedef struct ecs_observable_t ecs_observable_t;
462
467 typedef struct ecs_iter_t ecs_iter_t;
468
477 typedef struct ecs_ref_t ecs_ref_t;
478
482 typedef struct ecs_type_hooks_t ecs_type_hooks_t;
483
487 typedef struct ecs_type_info_t ecs_type_info_t;
488
490 typedef struct ecs_record_t ecs_record_t;
491
493 typedef struct ecs_component_record_t ecs_component_record_t;
494
514 typedef void ecs_poly_t;
515
517 typedef struct ecs_mixins_t ecs_mixins_t;
518
520 typedef struct ecs_header_t {
521 int32_t type;
522 int32_t refcount;
523 ecs_mixins_t *mixins;
524} ecs_header_t;
525
527 typedef struct ecs_table_record_t ecs_table_record_t;
528
530
531#include "flecs/datastructures/vec.h" /* Vector datatype */
532#include "flecs/datastructures/sparse.h" /* Sparse set */
533#include "flecs/datastructures/block_allocator.h" /* Block allocator */
534#include "flecs/datastructures/stack_allocator.h" /* Stack allocator */
535#include "flecs/datastructures/map.h" /* Map */
536#include "flecs/datastructures/allocator.h" /* Allocator */
537#include "flecs/datastructures/strbuf.h" /* String builder */
538#include "flecs/os_api.h" /* Abstraction for operating system functions */
539
540#ifdef __cplusplus
541extern "C" {
542#endif
543
550
551
558
568 typedef void (*ecs_run_action_t)(
569 ecs_iter_t *it);
570
577 typedef void (*ecs_iter_action_t)(
578 ecs_iter_t *it);
579
587 typedef bool (*ecs_iter_next_action_t)(
588 ecs_iter_t *it);
589
595 typedef void (*ecs_iter_fini_action_t)(
596 ecs_iter_t *it);
597
599 typedef int (*ecs_order_by_action_t)(
600 ecs_entity_t e1,
601 const void *ptr1,
602 ecs_entity_t e2,
603 const void *ptr2);
604
606 typedef void (*ecs_sort_table_action_t)(
607 ecs_world_t* world,
608 ecs_table_t* table,
609 ecs_entity_t* entities,
610 void* ptr,
611 int32_t size,
612 int32_t lo,
613 int32_t hi,
614 ecs_order_by_action_t order_by);
615
617 typedef uint64_t (*ecs_group_by_action_t)(
618 ecs_world_t *world,
619 ecs_table_t *table,
620 ecs_id_t group_id,
621 void *ctx);
622
624 typedef void* (*ecs_group_create_action_t)(
625 ecs_world_t *world,
626 uint64_t group_id,
627 void *group_by_ctx); /* from ecs_query_desc_t */
628
630 typedef void (*ecs_group_delete_action_t)(
631 ecs_world_t *world,
632 uint64_t group_id,
633 void *group_ctx, /* return value from ecs_group_create_action_t */
634 void *group_by_ctx); /* from ecs_query_desc_t */
635
637 typedef void (*ecs_module_action_t)(
638 ecs_world_t *world);
639
641 typedef void (*ecs_fini_action_t)(
642 ecs_world_t *world,
643 void *ctx);
644
646 typedef void (*ecs_ctx_free_t)(
647 void *ctx);
648
650 typedef int (*ecs_compare_action_t)(
651 const void *ptr1,
652 const void *ptr2);
653
655 typedef uint64_t (*ecs_hash_value_action_t)(
656 const void *ptr);
657
659 typedef void (*ecs_xtor_t)(
660 void *ptr,
661 int32_t count,
662 const ecs_type_info_t *type_info);
663
665 typedef void (*ecs_copy_t)(
666 void *dst_ptr,
667 const void *src_ptr,
668 int32_t count,
669 const ecs_type_info_t *type_info);
670
672 typedef void (*ecs_move_t)(
673 void *dst_ptr,
674 void *src_ptr,
675 int32_t count,
676 const ecs_type_info_t *type_info);
677
679 typedef int (*ecs_cmp_t)(
680 const void *a_ptr,
681 const void *b_ptr,
682 const ecs_type_info_t *type_info);
683
685 typedef bool (*ecs_equals_t)(
686 const void *a_ptr,
687 const void *b_ptr,
688 const ecs_type_info_t *type_info);
689
691 typedef void (*flecs_poly_dtor_t)(
692 ecs_poly_t *poly);
693
695
702
704 typedef enum ecs_inout_kind_t {
705 EcsInOutDefault,
706 EcsInOutNone,
707 EcsInOutFilter,
708 EcsInOut,
709 EcsIn,
710 EcsOut,
711} ecs_inout_kind_t;
712
714 typedef enum ecs_oper_kind_t {
715 EcsAnd,
716 EcsOr,
717 EcsNot,
718 EcsOptional,
719 EcsAndFrom,
720 EcsOrFrom,
721 EcsNotFrom,
722} ecs_oper_kind_t;
723
725 typedef enum ecs_query_cache_kind_t {
726 EcsQueryCacheDefault,
727 EcsQueryCacheAuto,
728 EcsQueryCacheAll,
729 EcsQueryCacheNone,
730} ecs_query_cache_kind_t;
731
733
738#define EcsSelf (1llu << 63)
739
744#define EcsUp (1llu << 62)
745
750#define EcsTrav (1llu << 61)
751
756#define EcsCascade (1llu << 60)
757
762#define EcsDesc (1llu << 59)
763
768#define EcsIsVariable (1llu << 58)
769
774#define EcsIsEntity (1llu << 57)
775
780#define EcsIsName (1llu << 56)
781
786#define EcsTraverseFlags (EcsSelf|EcsUp|EcsTrav|EcsCascade|EcsDesc)
787
792#define EcsTermRefFlags (EcsTraverseFlags|EcsIsVariable|EcsIsEntity|EcsIsName)
793
795 typedef struct ecs_term_ref_t {
796 ecs_entity_t id;
801
802 const char *name;
807} ecs_term_ref_t;
808
810 struct ecs_term_t {
811 ecs_id_t id;
815
816 ecs_term_ref_t src;
817 ecs_term_ref_t first;
818 ecs_term_ref_t second;
819
820 ecs_entity_t trav;
823
824 int16_t inout;
825 int16_t oper;
826
827 int8_t field_index;
828 ecs_flags16_t flags_;
829};
830
834 struct ecs_query_t {
835 ecs_header_t hdr;
836
837 ecs_term_t *terms;
838 int32_t *sizes;
839 ecs_id_t *ids;
840
841 uint64_t bloom_filter;
842 ecs_flags32_t flags;
843 int8_t var_count;
844 int8_t term_count;
845 int8_t field_count;
846
848 ecs_termset_t fixed_fields;
849 ecs_termset_t var_fields;
850 ecs_termset_t static_id_fields;
851 ecs_termset_t data_fields;
852 ecs_termset_t write_fields;
853 ecs_termset_t read_fields;
854 ecs_termset_t row_fields;
855 ecs_termset_t shared_readonly_fields;
856 ecs_termset_t set_fields;
857
858 ecs_query_cache_kind_t cache_kind;
859
860 char **vars;
861
862 void *ctx;
863 void *binding_ctx;
864
865 ecs_entity_t entity;
866 ecs_world_t *real_world;
867 ecs_world_t *world;
868
869 int32_t eval_count;
870};
871
875 struct ecs_observer_t {
876 ecs_header_t hdr;
877
878 ecs_query_t *query;
879
881 ecs_entity_t events[FLECS_EVENT_DESC_MAX];
882 int32_t event_count;
883
884 ecs_iter_action_t callback;
885 ecs_run_action_t run;
886
887 void *ctx;
888 void *callback_ctx;
889 void *run_ctx;
890
891 ecs_ctx_free_t ctx_free;
892 ecs_ctx_free_t callback_ctx_free;
893 ecs_ctx_free_t run_ctx_free;
894
895 ecs_observable_t *observable;
896
897 ecs_world_t *world;
898 ecs_entity_t entity;
899};
900
902
907
908/* Flags that can be used to check which hooks a type has set */
909#define ECS_TYPE_HOOK_CTOR ECS_CAST(ecs_flags32_t, 1 << 0)
910#define ECS_TYPE_HOOK_DTOR ECS_CAST(ecs_flags32_t, 1 << 1)
911#define ECS_TYPE_HOOK_COPY ECS_CAST(ecs_flags32_t, 1 << 2)
912#define ECS_TYPE_HOOK_MOVE ECS_CAST(ecs_flags32_t, 1 << 3)
913#define ECS_TYPE_HOOK_COPY_CTOR ECS_CAST(ecs_flags32_t, 1 << 4)
914#define ECS_TYPE_HOOK_MOVE_CTOR ECS_CAST(ecs_flags32_t, 1 << 5)
915#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 6)
916#define ECS_TYPE_HOOK_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 7)
917#define ECS_TYPE_HOOK_CMP ECS_CAST(ecs_flags32_t, 1 << 8)
918#define ECS_TYPE_HOOK_EQUALS ECS_CAST(ecs_flags32_t, 1 << 9)
919
920
921/* Flags that can be used to set/check which hooks of a type are invalid */
922#define ECS_TYPE_HOOK_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 10)
923#define ECS_TYPE_HOOK_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 12)
924#define ECS_TYPE_HOOK_COPY_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 13)
925#define ECS_TYPE_HOOK_MOVE_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 14)
926#define ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 15)
927#define ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 16)
928#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 17)
929#define ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 18)
930#define ECS_TYPE_HOOK_CMP_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 19)
931#define ECS_TYPE_HOOK_EQUALS_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 20)
932
933/* Internal debug flag that indicates type hooks have been invoked */
934#define ECS_TYPE_HOOK_IN_USE ECS_CAST(ecs_flags32_t, 1 << 21)
935
936
937/* All valid hook flags */
938#define ECS_TYPE_HOOKS (ECS_TYPE_HOOK_CTOR|ECS_TYPE_HOOK_DTOR|\
939 ECS_TYPE_HOOK_COPY|ECS_TYPE_HOOK_MOVE|ECS_TYPE_HOOK_COPY_CTOR|\
940 ECS_TYPE_HOOK_MOVE_CTOR|ECS_TYPE_HOOK_CTOR_MOVE_DTOR|\
941 ECS_TYPE_HOOK_MOVE_DTOR|ECS_TYPE_HOOK_CMP|ECS_TYPE_HOOK_EQUALS)
942
943/* All invalid hook flags */
944#define ECS_TYPE_HOOKS_ILLEGAL (ECS_TYPE_HOOK_CTOR_ILLEGAL|\
945 ECS_TYPE_HOOK_DTOR_ILLEGAL|ECS_TYPE_HOOK_COPY_ILLEGAL|\
946 ECS_TYPE_HOOK_MOVE_ILLEGAL|ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL|\
947 ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL|ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL|\
948 ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL|ECS_TYPE_HOOK_CMP_ILLEGAL|\
949 ECS_TYPE_HOOK_EQUALS_ILLEGAL)
950 struct ecs_type_hooks_t {
951 ecs_xtor_t ctor;
952 ecs_xtor_t dtor;
953 ecs_copy_t copy;
954 ecs_move_t move;
955
957 ecs_copy_t copy_ctor;
958
960 ecs_move_t move_ctor;
961
966 ecs_move_t ctor_move_dtor;
967
972 ecs_move_t move_dtor;
973
975 ecs_cmp_t cmp;
976
978 ecs_equals_t equals;
979
984 ecs_flags32_t flags;
985
988 ecs_iter_action_t on_add;
989
993 ecs_iter_action_t on_set;
994
998 ecs_iter_action_t on_remove;
999
1004 ecs_iter_action_t on_replace;
1005
1006 void *ctx;
1007 void *binding_ctx;
1008 void *lifecycle_ctx;
1009
1010 ecs_ctx_free_t ctx_free;
1011 ecs_ctx_free_t binding_ctx_free;
1012 ecs_ctx_free_t lifecycle_ctx_free;
1013};
1014
1019 struct ecs_type_info_t {
1020 ecs_size_t size;
1021 ecs_size_t alignment;
1022 ecs_type_hooks_t hooks;
1023 ecs_entity_t component;
1024 const char *name;
1025};
1026
1027#include "flecs/private/api_types.h" /* Supporting API types */
1028#include "flecs/private/api_support.h" /* Supporting API functions */
1029#include "flecs/datastructures/hashmap.h" /* Hashmap */
1030#include "flecs/private/api_internals.h" /* Supporting API functions */
1031
1033 typedef struct ecs_value_t {
1034 ecs_entity_t type;
1035 void *ptr;
1036} ecs_value_t;
1037
1042 typedef struct ecs_entity_desc_t {
1043 int32_t _canary;
1044
1045 ecs_entity_t id;
1046
1047 ecs_entity_t parent;
1048
1049 const char *name;
1053
1054 const char *sep;
1057
1058 const char *root_sep;
1059
1060 const char *symbol;
1069
1070 bool use_low_id;
1073
1075 const ecs_id_t *add;
1076
1078 const ecs_value_t *set;
1079
1081 const char *add_expr;
1082} ecs_entity_desc_t;
1083
1088 typedef struct ecs_bulk_desc_t {
1089 int32_t _canary;
1090
1091 ecs_entity_t *entities;
1095
1096 int32_t count;
1097
1098 ecs_id_t ids[FLECS_ID_DESC_MAX];
1099
1100 void **data;
1106
1107 ecs_table_t *table;
1111
1112} ecs_bulk_desc_t;
1113
1118 typedef struct ecs_component_desc_t {
1119 int32_t _canary;
1120
1122 ecs_entity_t entity;
1123
1125 ecs_type_info_t type;
1126} ecs_component_desc_t;
1127
1166 struct ecs_iter_t {
1167 /* World */
1168 ecs_world_t *world;
1169 ecs_world_t *real_world;
1170
1171 /* Matched data */
1172 int32_t offset;
1173 int32_t count;
1174 const ecs_entity_t *entities;
1175 void **ptrs;
1176 const ecs_table_record_t **trs;
1177 const ecs_size_t *sizes;
1178 ecs_table_t *table;
1179 ecs_table_t *other_table;
1180 ecs_id_t *ids;
1181 ecs_entity_t *sources;
1182 ecs_flags64_t constrained_vars;
1183 ecs_termset_t set_fields;
1184 ecs_termset_t ref_fields;
1185 ecs_termset_t row_fields;
1186 ecs_termset_t up_fields;
1187
1188 /* Input information */
1189 ecs_entity_t system;
1190 ecs_entity_t event;
1191 ecs_id_t event_id;
1192 int32_t event_cur;
1193
1194 /* Query information */
1195 int8_t field_count;
1196 int8_t term_index;
1199 const ecs_query_t *query;
1200
1201 /* Context */
1202 void *param;
1203 void *ctx;
1204 void *binding_ctx;
1205 void *callback_ctx;
1206 void *run_ctx;
1207
1208 /* Time */
1209 ecs_ftime_t delta_time;
1210 ecs_ftime_t delta_system_time;
1211
1212 /* Iterator counters */
1213 int32_t frame_offset;
1214
1215 /* Misc */
1216 ecs_flags32_t flags;
1217 ecs_entity_t interrupted_by;
1218 ecs_iter_private_t priv_;
1219
1220 /* Chained iterators */
1221 ecs_iter_next_action_t next;
1222 ecs_iter_action_t callback;
1223 ecs_iter_fini_action_t fini;
1224 ecs_iter_t *chain_it;
1225};
1226
1227
1232#define EcsQueryMatchPrefab (1u << 1u)
1233
1238#define EcsQueryMatchDisabled (1u << 2u)
1239
1244#define EcsQueryMatchEmptyTables (1u << 3u)
1245
1250#define EcsQueryAllowUnresolvedByName (1u << 6u)
1251
1256#define EcsQueryTableOnly (1u << 7u)
1257
1268#define EcsQueryDetectChanges (1u << 8u)
1269
1270
1275 typedef struct ecs_query_desc_t {
1277 int32_t _canary;
1278
1280 ecs_term_t terms[FLECS_TERM_COUNT_MAX];
1281
1283 const char *expr;
1284
1286 ecs_query_cache_kind_t cache_kind;
1287
1289 ecs_flags32_t flags;
1290
1294 ecs_order_by_action_t order_by_callback;
1295
1298 ecs_sort_table_action_t order_by_table_callback;
1299
1302 ecs_entity_t order_by;
1303
1306 ecs_id_t group_by;
1307
1313 ecs_group_by_action_t group_by_callback;
1314
1317 ecs_group_create_action_t on_group_create;
1318
1321 ecs_group_delete_action_t on_group_delete;
1322
1324 void *group_by_ctx;
1325
1327 ecs_ctx_free_t group_by_ctx_free;
1328
1330 void *ctx;
1331
1333 void *binding_ctx;
1334
1336 ecs_ctx_free_t ctx_free;
1337
1339 ecs_ctx_free_t binding_ctx_free;
1340
1342 ecs_entity_t entity;
1343} ecs_query_desc_t;
1344
1349 typedef struct ecs_observer_desc_t {
1351 int32_t _canary;
1352
1354 ecs_entity_t entity;
1355
1357 ecs_query_desc_t query;
1358
1360 ecs_entity_t events[FLECS_EVENT_DESC_MAX];
1361
1364 bool yield_existing;
1365
1369 bool global_observer;
1370
1372 ecs_iter_action_t callback;
1373
1380 ecs_run_action_t run;
1381
1383 void *ctx;
1384
1386 ecs_ctx_free_t ctx_free;
1387
1389 void *callback_ctx;
1390
1392 ecs_ctx_free_t callback_ctx_free;
1393
1395 void *run_ctx;
1396
1398 ecs_ctx_free_t run_ctx_free;
1399
1401 int32_t *last_event_id;
1402 int8_t term_index_;
1403 ecs_flags32_t flags_;
1404} ecs_observer_desc_t;
1405
1410 typedef struct ecs_event_desc_t {
1412 ecs_entity_t event;
1413
1417 const ecs_type_t *ids;
1418
1420 ecs_table_t *table;
1421
1424 ecs_table_t *other_table;
1425
1427 int32_t offset;
1428
1432 int32_t count;
1433
1435 ecs_entity_t entity;
1436
1441 void *param;
1442
1446 const void *const_param;
1447
1449 ecs_poly_t *observable;
1450
1452 ecs_flags32_t flags;
1453} ecs_event_desc_t;
1454
1455
1462
1464 typedef struct ecs_build_info_t {
1465 const char *compiler;
1466 const char **addons;
1467 const char **flags;
1468 const char *version;
1469 int16_t version_major;
1470 int16_t version_minor;
1471 int16_t version_patch;
1472 bool debug;
1473 bool sanitize;
1474 bool perf_trace;
1475} ecs_build_info_t;
1476
1478 typedef struct ecs_world_info_t {
1479 ecs_entity_t last_component_id;
1480 ecs_entity_t min_id;
1481 ecs_entity_t max_id;
1482
1483 ecs_ftime_t delta_time_raw;
1484 ecs_ftime_t delta_time;
1485 ecs_ftime_t time_scale;
1486 ecs_ftime_t target_fps;
1487 ecs_ftime_t frame_time_total;
1488 ecs_ftime_t system_time_total;
1489 ecs_ftime_t emit_time_total;
1490 ecs_ftime_t merge_time_total;
1491 ecs_ftime_t rematch_time_total;
1492 double world_time_total;
1493 double world_time_total_raw;
1494
1495 int64_t frame_count_total;
1496 int64_t merge_count_total;
1497 int64_t eval_comp_monitors_total;
1498 int64_t rematch_count_total;
1499
1500 int64_t id_create_total;
1501 int64_t id_delete_total;
1502 int64_t table_create_total;
1503 int64_t table_delete_total;
1504 int64_t pipeline_build_count_total;
1505 int64_t systems_ran_total;
1506 int64_t observers_ran_total;
1507 int64_t queries_ran_total;
1508
1509 int32_t tag_id_count;
1510 int32_t component_id_count;
1511 int32_t pair_id_count;
1512
1513 int32_t table_count;
1514
1515 uint32_t creation_time;
1516
1517 /* -- Command counts -- */
1518 struct {
1519 int64_t add_count;
1520 int64_t remove_count;
1521 int64_t delete_count;
1522 int64_t clear_count;
1523 int64_t set_count;
1524 int64_t ensure_count;
1525 int64_t modified_count;
1526 int64_t discard_count;
1527 int64_t event_count;
1528 int64_t other_count;
1529 int64_t batched_entity_count;
1530 int64_t batched_command_count;
1531 } cmd;
1532
1533 const char *name_prefix;
1537} ecs_world_info_t;
1538
1540 typedef struct ecs_query_group_info_t {
1541 uint64_t id;
1542 int32_t match_count;
1543 int32_t table_count;
1544 void *ctx;
1545} ecs_query_group_info_t;
1546
1548
1555
1557 typedef struct EcsIdentifier {
1558 char *value;
1559 ecs_size_t length;
1560 uint64_t hash;
1561 uint64_t index_hash;
1562 ecs_hashmap_t *index;
1563} EcsIdentifier;
1564
1566 typedef struct EcsComponent {
1567 ecs_size_t size;
1568 ecs_size_t alignment;
1569} EcsComponent;
1570
1572 typedef struct EcsPoly {
1573 ecs_poly_t *poly;
1574} EcsPoly;
1575
1581 typedef struct EcsDefaultChildComponent {
1582 ecs_id_t component;
1583} EcsDefaultChildComponent;
1584
1586 typedef struct EcsParent {
1587 ecs_entity_t value;
1588} EcsParent;
1589
1591 typedef struct {
1592 const char *child_name;
1593 ecs_table_t *table;
1594 uint32_t child;
1595 int32_t parent_index;
1596} ecs_tree_spawner_child_t;
1597
1599 typedef struct {
1600 ecs_vec_t children;
1601} ecs_tree_spawner_t;
1602
1610 typedef struct EcsTreeSpawner {
1611 ecs_tree_spawner_t data[FLECS_TREE_SPAWNER_DEPTH_CACHE_SIZE];
1612} EcsTreeSpawner;
1613
1616
1617/* Only include deprecated definitions if deprecated addon is required */
1618#ifdef FLECS_DEPRECATED
1619#include "flecs/addons/deprecated.h"
1620#endif
1621
1628
1635
1637FLECS_API extern const ecs_id_t ECS_PAIR;
1638
1640FLECS_API extern const ecs_id_t ECS_AUTO_OVERRIDE;
1641
1643FLECS_API extern const ecs_id_t ECS_TOGGLE;
1644
1646FLECS_API extern const ecs_id_t ECS_VALUE_PAIR;
1647
1649
1654
1655/* Built-in component IDs */
1656
1658FLECS_API extern const ecs_entity_t ecs_id(EcsComponent);
1659
1661FLECS_API extern const ecs_entity_t ecs_id(EcsIdentifier);
1662
1664FLECS_API extern const ecs_entity_t ecs_id(EcsPoly);
1665
1667FLECS_API extern const ecs_entity_t ecs_id(EcsParent);
1668
1670FLECS_API extern const ecs_entity_t ecs_id(EcsTreeSpawner);
1671
1673FLECS_API extern const ecs_entity_t ecs_id(EcsDefaultChildComponent);
1674
1676FLECS_API extern const ecs_entity_t EcsParentDepth;
1677
1679FLECS_API extern const ecs_entity_t EcsQuery;
1680
1682FLECS_API extern const ecs_entity_t EcsObserver;
1683
1685FLECS_API extern const ecs_entity_t EcsSystem;
1686
1688FLECS_API extern const ecs_entity_t ecs_id(EcsTickSource);
1689
1691FLECS_API extern const ecs_entity_t ecs_id(EcsPipelineQuery);
1692
1694FLECS_API extern const ecs_entity_t ecs_id(EcsTimer);
1695
1697FLECS_API extern const ecs_entity_t ecs_id(EcsRateFilter);
1698
1700FLECS_API extern const ecs_entity_t EcsFlecs;
1701
1703FLECS_API extern const ecs_entity_t EcsFlecsCore;
1704
1706FLECS_API extern const ecs_entity_t EcsWorld;
1707
1709FLECS_API extern const ecs_entity_t EcsWildcard;
1710
1712FLECS_API extern const ecs_entity_t EcsAny;
1713
1715FLECS_API extern const ecs_entity_t EcsThis;
1716
1718FLECS_API extern const ecs_entity_t EcsVariable;
1719
1727FLECS_API extern const ecs_entity_t EcsTransitive;
1728
1736FLECS_API extern const ecs_entity_t EcsReflexive;
1737
1748FLECS_API extern const ecs_entity_t EcsFinal;
1749
1755FLECS_API extern const ecs_entity_t EcsInheritable;
1756
1758FLECS_API extern const ecs_entity_t EcsOnInstantiate;
1759
1763FLECS_API extern const ecs_entity_t EcsOverride;
1764
1768FLECS_API extern const ecs_entity_t EcsInherit;
1769
1774FLECS_API extern const ecs_entity_t EcsDontInherit;
1775
1783FLECS_API extern const ecs_entity_t EcsSymmetric;
1784
1794FLECS_API extern const ecs_entity_t EcsExclusive;
1795
1797FLECS_API extern const ecs_entity_t EcsAcyclic;
1798
1801FLECS_API extern const ecs_entity_t EcsTraversable;
1802
1812FLECS_API extern const ecs_entity_t EcsWith;
1813
1823FLECS_API extern const ecs_entity_t EcsOneOf;
1824
1826FLECS_API extern const ecs_entity_t EcsCanToggle;
1827
1831FLECS_API extern const ecs_entity_t EcsTrait;
1832
1842FLECS_API extern const ecs_entity_t EcsRelationship;
1843
1853FLECS_API extern const ecs_entity_t EcsTarget;
1854
1857FLECS_API extern const ecs_entity_t EcsPairIsTag;
1858
1860FLECS_API extern const ecs_entity_t EcsName;
1861
1863FLECS_API extern const ecs_entity_t EcsSymbol;
1864
1866FLECS_API extern const ecs_entity_t EcsAlias;
1867
1869FLECS_API extern const ecs_entity_t EcsChildOf;
1870
1872FLECS_API extern const ecs_entity_t EcsIsA;
1873
1875FLECS_API extern const ecs_entity_t EcsDependsOn;
1876
1878FLECS_API extern const ecs_entity_t EcsSlotOf;
1879
1881FLECS_API extern const ecs_entity_t EcsOrderedChildren;
1882
1884FLECS_API extern const ecs_entity_t EcsModule;
1885
1888FLECS_API extern const ecs_entity_t EcsPrefab;
1889
1892FLECS_API extern const ecs_entity_t EcsDisabled;
1893
1897FLECS_API extern const ecs_entity_t EcsNotQueryable;
1898
1900FLECS_API extern const ecs_entity_t EcsOnAdd;
1901
1903FLECS_API extern const ecs_entity_t EcsOnRemove;
1904
1906FLECS_API extern const ecs_entity_t EcsOnSet;
1907
1909FLECS_API extern const ecs_entity_t EcsMonitor;
1910
1912FLECS_API extern const ecs_entity_t EcsOnTableCreate;
1913
1915FLECS_API extern const ecs_entity_t EcsOnTableDelete;
1916
1918FLECS_API extern const ecs_entity_t EcsOnDelete;
1919
1922FLECS_API extern const ecs_entity_t EcsOnDeleteTarget;
1923
1926FLECS_API extern const ecs_entity_t EcsRemove;
1927
1930FLECS_API extern const ecs_entity_t EcsDelete;
1931
1934FLECS_API extern const ecs_entity_t EcsPanic;
1935
1938FLECS_API extern const ecs_entity_t EcsSingleton;
1939
1941FLECS_API extern const ecs_entity_t EcsSparse;
1942
1944FLECS_API extern const ecs_entity_t EcsDontFragment;
1945
1947FLECS_API extern const ecs_entity_t EcsPredEq;
1948
1950FLECS_API extern const ecs_entity_t EcsPredMatch;
1951
1953FLECS_API extern const ecs_entity_t EcsPredLookup;
1954
1956FLECS_API extern const ecs_entity_t EcsScopeOpen;
1957
1959FLECS_API extern const ecs_entity_t EcsScopeClose;
1960
1965FLECS_API extern const ecs_entity_t EcsEmpty;
1966
1967FLECS_API extern const ecs_entity_t ecs_id(EcsPipeline);
1968FLECS_API extern const ecs_entity_t EcsOnStart;
1969FLECS_API extern const ecs_entity_t EcsPreFrame;
1970FLECS_API extern const ecs_entity_t EcsOnLoad;
1971FLECS_API extern const ecs_entity_t EcsPostLoad;
1972FLECS_API extern const ecs_entity_t EcsPreUpdate;
1973FLECS_API extern const ecs_entity_t EcsOnUpdate;
1974FLECS_API extern const ecs_entity_t EcsOnValidate;
1975FLECS_API extern const ecs_entity_t EcsPostUpdate;
1976FLECS_API extern const ecs_entity_t EcsPreStore;
1977FLECS_API extern const ecs_entity_t EcsOnStore;
1978FLECS_API extern const ecs_entity_t EcsPostFrame;
1979FLECS_API extern const ecs_entity_t EcsPhase;
1980
1981FLECS_API extern const ecs_entity_t EcsConstant;
1982
1985#define EcsLastInternalComponentId (ecs_id(EcsTreeSpawner))
1986
1989#define EcsFirstUserComponentId (8)
1990
1993#define EcsFirstUserEntityId (FLECS_HI_COMPONENT_ID + 128)
1994
1995/* When visualized, the reserved ID ranges look like this:
1996 * - [1..8]: Built-in components
1997 * - [9..FLECS_HI_COMPONENT_ID]: Low IDs reserved for application components
1998 * - [FLECS_HI_COMPONENT_ID + 1..EcsFirstUserEntityId]: Built-in entities
1999 */
2000
2003
2010
2015
2022FLECS_API
2023 ecs_world_t* ecs_init(void);
2024
2031FLECS_API
2032 ecs_world_t* ecs_mini(void);
2033
2043FLECS_API
2044 ecs_world_t* ecs_init_w_args(
2045 int argc,
2046 char *argv[]);
2047
2054FLECS_API
2055 int ecs_fini(
2056 ecs_world_t *world);
2057
2065FLECS_API
2066 bool ecs_is_fini(
2067 const ecs_world_t *world);
2068
2077FLECS_API
2078 void ecs_atfini(
2079 ecs_world_t *world,
2080 ecs_fini_action_t action,
2081 void *ctx);
2082
2084 typedef struct ecs_entities_t {
2085 const ecs_entity_t *ids;
2086 int32_t count;
2087 int32_t alive_count;
2088} ecs_entities_t;
2089
2116FLECS_API
2117 ecs_entities_t ecs_get_entities(
2118 const ecs_world_t *world);
2119
2127FLECS_API
2128ecs_flags32_t ecs_world_get_flags(
2129 const ecs_world_t *world);
2130
2132
2137
2156FLECS_API
2157 ecs_ftime_t ecs_frame_begin(
2158 ecs_world_t *world,
2159 ecs_ftime_t delta_time);
2160
2167FLECS_API
2168 void ecs_frame_end(
2169 ecs_world_t *world);
2170
2179FLECS_API
2180 void ecs_run_post_frame(
2181 ecs_world_t *world,
2182 ecs_fini_action_t action,
2183 void *ctx);
2184
2191FLECS_API
2192 void ecs_quit(
2193 ecs_world_t *world);
2194
2201FLECS_API
2202 bool ecs_should_quit(
2203 const ecs_world_t *world);
2204
2216FLECS_API void ecs_measure_frame_time(
2217 ecs_world_t *world,
2218 bool enable);
2219
2230FLECS_API void ecs_measure_system_time(
2231 ecs_world_t *world,
2232 bool enable);
2233
2249FLECS_API
2250 void ecs_set_target_fps(
2251 ecs_world_t *world,
2252 ecs_ftime_t fps);
2253
2267FLECS_API
2268 void ecs_set_default_query_flags(
2269 ecs_world_t *world,
2270 ecs_flags32_t flags);
2271
2273
2278
2348FLECS_API
2349 bool ecs_readonly_begin(
2350 ecs_world_t *world,
2351 bool multi_threaded);
2352
2360FLECS_API
2361 void ecs_readonly_end(
2362 ecs_world_t *world);
2363
2369FLECS_API
2370 void ecs_merge(
2371 ecs_world_t *stage);
2372
2389FLECS_API
2390 bool ecs_defer_begin(
2391 ecs_world_t *world);
2392
2406FLECS_API
2407 bool ecs_defer_end(
2408 ecs_world_t *world);
2409
2424FLECS_API
2425 void ecs_defer_suspend(
2426 ecs_world_t *world);
2427
2438FLECS_API
2439 void ecs_defer_resume(
2440 ecs_world_t *world);
2441
2453FLECS_API
2454 bool ecs_is_deferred(
2455 const ecs_world_t *world);
2456
2468FLECS_API
2469 bool ecs_is_defer_suspended(
2470 const ecs_world_t *world);
2471
2485FLECS_API
2486 void ecs_set_stage_count(
2487 ecs_world_t *world,
2488 int32_t stages);
2489
2496FLECS_API
2497int32_t ecs_get_stage_count(
2498 const ecs_world_t *world);
2499
2515FLECS_API
2516 ecs_world_t* ecs_get_stage(
2517 const ecs_world_t *world,
2518 int32_t stage_id);
2519
2527FLECS_API
2528 bool ecs_stage_is_readonly(
2529 const ecs_world_t *world);
2530
2538FLECS_API
2539 ecs_world_t* ecs_stage_new(
2540 ecs_world_t *world);
2541
2546FLECS_API
2547 void ecs_stage_free(
2548 ecs_world_t *stage);
2549
2557FLECS_API
2558int32_t ecs_stage_get_id(
2559 const ecs_world_t *world);
2560
2562
2567
2576FLECS_API
2577 void ecs_set_ctx(
2578 ecs_world_t *world,
2579 void *ctx,
2580 ecs_ctx_free_t ctx_free);
2581
2590FLECS_API
2591 void ecs_set_binding_ctx(
2592 ecs_world_t *world,
2593 void *ctx,
2594 ecs_ctx_free_t ctx_free);
2595
2603FLECS_API
2604 void* ecs_get_ctx(
2605 const ecs_world_t *world);
2606
2614FLECS_API
2615 void* ecs_get_binding_ctx(
2616 const ecs_world_t *world);
2617
2623FLECS_API
2624 const ecs_build_info_t* ecs_get_build_info(void);
2625
2631FLECS_API
2632 const ecs_world_info_t* ecs_get_world_info(
2633 const ecs_world_t *world);
2634
2643FLECS_API
2644 void ecs_dim(
2645 ecs_world_t *world,
2646 int32_t entity_count);
2647
2662FLECS_API
2663 void ecs_shrink(
2664 ecs_world_t *world);
2665
2681FLECS_API
2682 void ecs_set_entity_range(
2683 ecs_world_t *world,
2684 ecs_entity_t id_start,
2685 ecs_entity_t id_end);
2686
2697FLECS_API
2698 bool ecs_enable_range_check(
2699 ecs_world_t *world,
2700 bool enable);
2701
2707FLECS_API
2708 ecs_entity_t ecs_get_max_id(
2709 const ecs_world_t *world);
2710
2724FLECS_API
2725 void ecs_run_aperiodic(
2726 ecs_world_t *world,
2727 ecs_flags32_t flags);
2728
2730 typedef struct ecs_delete_empty_tables_desc_t {
2732 uint16_t clear_generation;
2733
2735 uint16_t delete_generation;
2736
2738 double time_budget_seconds;
2739} ecs_delete_empty_tables_desc_t;
2740
2770FLECS_API
2771int32_t ecs_delete_empty_tables(
2772 ecs_world_t *world,
2773 const ecs_delete_empty_tables_desc_t *desc);
2774
2780FLECS_API
2781 const ecs_world_t* ecs_get_world(
2782 const ecs_poly_t *poly);
2783
2789FLECS_API
2790 ecs_entity_t ecs_get_entity(
2791 const ecs_poly_t *poly);
2792
2806FLECS_API
2807 bool flecs_poly_is_(
2808 const ecs_poly_t *object,
2809 int32_t type);
2810
2814#define flecs_poly_is(object, type)\
2815 flecs_poly_is_(object, type##_magic)
2816
2825FLECS_API
2826 ecs_id_t ecs_make_pair(
2827 ecs_entity_t first,
2828 ecs_entity_t second);
2829
2852FLECS_API
2853 void ecs_exclusive_access_begin(
2854 ecs_world_t *world,
2855 const char *thread_name);
2856
2879FLECS_API
2880 void ecs_exclusive_access_end(
2881 ecs_world_t *world,
2882 bool lock_world);
2883
2885
2887
2894
2901
2910FLECS_API
2911 ecs_entity_t ecs_new(
2912 ecs_world_t *world);
2913
2931FLECS_API
2932 ecs_entity_t ecs_new_low_id(
2933 ecs_world_t *world);
2934
2943FLECS_API
2944 ecs_entity_t ecs_new_w_id(
2945 ecs_world_t *world,
2946 ecs_id_t component);
2947
2955FLECS_API
2956 ecs_entity_t ecs_new_w_table(
2957 ecs_world_t *world,
2958 ecs_table_t *table);
2959
2978FLECS_API
2979 ecs_entity_t ecs_entity_init(
2980 ecs_world_t *world,
2981 const ecs_entity_desc_t *desc);
2982
3009FLECS_API
3010 const ecs_entity_t* ecs_bulk_init(
3011 ecs_world_t *world,
3012 const ecs_bulk_desc_t *desc);
3013
3023FLECS_API
3024 const ecs_entity_t* ecs_bulk_new_w_id(
3025 ecs_world_t *world,
3026 ecs_id_t component,
3027 int32_t count);
3028
3044FLECS_API
3045 ecs_entity_t ecs_clone(
3046 ecs_world_t *world,
3047 ecs_entity_t dst,
3048 ecs_entity_t src,
3049 bool copy_value);
3050
3059FLECS_API
3060 void ecs_delete(
3061 ecs_world_t *world,
3062 ecs_entity_t entity);
3063
3071FLECS_API
3072 void ecs_delete_with(
3073 ecs_world_t *world,
3074 ecs_id_t component);
3075
3093FLECS_API
3094 void ecs_set_child_order(
3095 ecs_world_t *world,
3096 ecs_entity_t parent,
3097 const ecs_entity_t *children,
3098 int32_t child_count);
3099
3109FLECS_API
3110 ecs_entities_t ecs_get_ordered_children(
3111 const ecs_world_t *world,
3112 ecs_entity_t parent);
3113
3115
3122
3131FLECS_API
3132 void ecs_add_id(
3133 ecs_world_t *world,
3134 ecs_entity_t entity,
3135 ecs_id_t component);
3136
3145FLECS_API
3146 void ecs_remove_id(
3147 ecs_world_t *world,
3148 ecs_entity_t entity,
3149 ecs_id_t component);
3150
3202FLECS_API
3203 void ecs_auto_override_id(
3204 ecs_world_t *world,
3205 ecs_entity_t entity,
3206 ecs_id_t component);
3207
3214FLECS_API
3215 void ecs_clear(
3216 ecs_world_t *world,
3217 ecs_entity_t entity);
3218
3226FLECS_API
3227 void ecs_remove_all(
3228 ecs_world_t *world,
3229 ecs_id_t component);
3230
3246FLECS_API
3247 ecs_entity_t ecs_set_with(
3248 ecs_world_t *world,
3249 ecs_id_t component);
3250
3259FLECS_API
3260 ecs_id_t ecs_get_with(
3261 const ecs_world_t *world);
3262
3264
3271
3281FLECS_API
3282 void ecs_enable(
3283 ecs_world_t *world,
3284 ecs_entity_t entity,
3285 bool enabled);
3286
3300FLECS_API
3301 void ecs_enable_id(
3302 ecs_world_t *world,
3303 ecs_entity_t entity,
3304 ecs_id_t component,
3305 bool enable);
3306
3317FLECS_API
3318 bool ecs_is_enabled_id(
3319 const ecs_world_t *world,
3320 ecs_entity_t entity,
3321 ecs_id_t component);
3322
3324
3331
3346FLECS_API
3347FLECS_ALWAYS_INLINE const void* ecs_get_id(
3348 const ecs_world_t *world,
3349 ecs_entity_t entity,
3350 ecs_id_t component);
3351
3366FLECS_API
3367FLECS_ALWAYS_INLINE void* ecs_get_mut_id(
3368 const ecs_world_t *world,
3369 ecs_entity_t entity,
3370 ecs_id_t component);
3371
3389FLECS_API
3390 void* ecs_ensure_id(
3391 ecs_world_t *world,
3392 ecs_entity_t entity,
3393 ecs_id_t component,
3394 size_t size);
3395
3406FLECS_ALWAYS_INLINE FLECS_API
3407 ecs_ref_t ecs_ref_init_id(
3408 const ecs_world_t *world,
3409 ecs_entity_t entity,
3410 ecs_id_t component);
3411
3422FLECS_ALWAYS_INLINE FLECS_API
3423 void* ecs_ref_get_id(
3424 const ecs_world_t *world,
3425 ecs_ref_t *ref,
3426 ecs_id_t component);
3427
3435FLECS_ALWAYS_INLINE FLECS_API
3436 void ecs_ref_update(
3437 const ecs_world_t *world,
3438 ecs_ref_t *ref);
3439
3460FLECS_API
3461 void* ecs_emplace_id(
3462 ecs_world_t *world,
3463 ecs_entity_t entity,
3464 ecs_id_t component,
3465 size_t size,
3466 bool *is_new);
3467
3477FLECS_API
3478 void ecs_modified_id(
3479 ecs_world_t *world,
3480 ecs_entity_t entity,
3481 ecs_id_t component);
3482
3498FLECS_API
3499 void ecs_set_id(
3500 ecs_world_t *world,
3501 ecs_entity_t entity,
3502 ecs_id_t component,
3503 size_t size,
3504 const void *ptr);
3505
3507
3514
3534FLECS_API
3535 bool ecs_is_valid(
3536 const ecs_world_t *world,
3537 ecs_entity_t e);
3538
3568FLECS_API
3569 bool ecs_is_alive(
3570 const ecs_world_t *world,
3571 ecs_entity_t e);
3572
3578FLECS_API
3579 ecs_id_t ecs_strip_generation(
3580 ecs_entity_t e);
3581
3598FLECS_API
3599 ecs_entity_t ecs_get_alive(
3600 const ecs_world_t *world,
3601 ecs_entity_t e);
3602
3625FLECS_API
3626 void ecs_make_alive(
3627 ecs_world_t *world,
3628 ecs_entity_t entity);
3629
3648FLECS_API
3649 void ecs_make_alive_id(
3650 ecs_world_t *world,
3651 ecs_id_t component);
3652
3660FLECS_API
3661 bool ecs_exists(
3662 const ecs_world_t *world,
3663 ecs_entity_t entity);
3664
3679FLECS_API
3680 void ecs_set_version(
3681 ecs_world_t *world,
3682 ecs_entity_t entity);
3683
3689FLECS_API
3690uint32_t ecs_get_version(
3691 ecs_entity_t entity);
3692
3694
3701
3708FLECS_API
3709 const ecs_type_t* ecs_get_type(
3710 const ecs_world_t *world,
3711 ecs_entity_t entity);
3712
3719FLECS_API
3720 ecs_table_t* ecs_get_table(
3721 const ecs_world_t *world,
3722 ecs_entity_t entity);
3723
3731FLECS_API
3732 char* ecs_type_str(
3733 const ecs_world_t *world,
3734 const ecs_type_t* type);
3735
3747FLECS_API
3748 char* ecs_table_str(
3749 const ecs_world_t *world,
3750 const ecs_table_t *table);
3751
3766FLECS_API
3767 char* ecs_entity_str(
3768 const ecs_world_t *world,
3769 ecs_entity_t entity);
3770
3781FLECS_API
3782FLECS_ALWAYS_INLINE bool ecs_has_id(
3783 const ecs_world_t *world,
3784 ecs_entity_t entity,
3785 ecs_id_t component);
3786
3797FLECS_API
3798FLECS_ALWAYS_INLINE bool ecs_owns_id(
3799 const ecs_world_t *world,
3800 ecs_entity_t entity,
3801 ecs_id_t component);
3802
3817FLECS_API
3818 ecs_entity_t ecs_get_target(
3819 const ecs_world_t *world,
3820 ecs_entity_t entity,
3821 ecs_entity_t rel,
3822 int32_t index);
3823
3837FLECS_API
3838 ecs_entity_t ecs_get_parent(
3839 const ecs_world_t *world,
3840 ecs_entity_t entity);
3841
3855FLECS_API
3856 ecs_entity_t ecs_new_w_parent(
3857 ecs_world_t *world,
3858 ecs_entity_t parent,
3859 const char *name);
3860
3881FLECS_API
3882 ecs_entity_t ecs_get_target_for_id(
3883 const ecs_world_t *world,
3884 ecs_entity_t entity,
3885 ecs_entity_t rel,
3886 ecs_id_t component);
3887
3898FLECS_API
3899int32_t ecs_get_depth(
3900 const ecs_world_t *world,
3901 ecs_entity_t entity,
3902 ecs_entity_t rel);
3903
3911FLECS_API
3912int32_t ecs_count_id(
3913 const ecs_world_t *world,
3914 ecs_id_t entity);
3915
3917
3918
3925
3935FLECS_API
3936 const char* ecs_get_name(
3937 const ecs_world_t *world,
3938 ecs_entity_t entity);
3939
3949FLECS_API
3950 const char* ecs_get_symbol(
3951 const ecs_world_t *world,
3952 ecs_entity_t entity);
3953
3967FLECS_API
3968 ecs_entity_t ecs_set_name(
3969 ecs_world_t *world,
3970 ecs_entity_t entity,
3971 const char *name);
3972
3986FLECS_API
3987 ecs_entity_t ecs_set_symbol(
3988 ecs_world_t *world,
3989 ecs_entity_t entity,
3990 const char *symbol);
3991
4003FLECS_API
4004 void ecs_set_alias(
4005 ecs_world_t *world,
4006 ecs_entity_t entity,
4007 const char *alias);
4008
4024FLECS_API
4025 ecs_entity_t ecs_lookup(
4026 const ecs_world_t *world,
4027 const char *path);
4028
4043FLECS_API
4044 ecs_entity_t ecs_lookup_child(
4045 const ecs_world_t *world,
4046 ecs_entity_t parent,
4047 const char *name);
4048
4071FLECS_API
4072 ecs_entity_t ecs_lookup_path_w_sep(
4073 const ecs_world_t *world,
4074 ecs_entity_t parent,
4075 const char *path,
4076 const char *sep,
4077 const char *prefix,
4078 bool recursive);
4079
4097FLECS_API
4098 ecs_entity_t ecs_lookup_symbol(
4099 const ecs_world_t *world,
4100 const char *symbol,
4101 bool lookup_as_path,
4102 bool recursive);
4103
4125FLECS_API
4126 char* ecs_get_path_w_sep(
4127 const ecs_world_t *world,
4128 ecs_entity_t parent,
4129 ecs_entity_t child,
4130 const char *sep,
4131 const char *prefix);
4132
4146FLECS_API
4147 void ecs_get_path_w_sep_buf(
4148 const ecs_world_t *world,
4149 ecs_entity_t parent,
4150 ecs_entity_t child,
4151 const char *sep,
4152 const char *prefix,
4153 ecs_strbuf_t *buf,
4154 bool escape);
4155
4171FLECS_API
4172 ecs_entity_t ecs_new_from_path_w_sep(
4173 ecs_world_t *world,
4174 ecs_entity_t parent,
4175 const char *path,
4176 const char *sep,
4177 const char *prefix);
4178
4193FLECS_API
4194 ecs_entity_t ecs_add_path_w_sep(
4195 ecs_world_t *world,
4196 ecs_entity_t entity,
4197 ecs_entity_t parent,
4198 const char *path,
4199 const char *sep,
4200 const char *prefix);
4201
4215FLECS_API
4216 ecs_entity_t ecs_set_scope(
4217 ecs_world_t *world,
4218 ecs_entity_t scope);
4219
4227FLECS_API
4228 ecs_entity_t ecs_get_scope(
4229 const ecs_world_t *world);
4230
4240FLECS_API
4241 const char* ecs_set_name_prefix(
4242 ecs_world_t *world,
4243 const char *prefix);
4244
4271FLECS_API
4272 ecs_entity_t* ecs_set_lookup_path(
4273 ecs_world_t *world,
4274 const ecs_entity_t *lookup_path);
4275
4282FLECS_API
4283 ecs_entity_t* ecs_get_lookup_path(
4284 const ecs_world_t *world);
4285
4287
4289
4296
4310FLECS_API
4311 ecs_entity_t ecs_component_init(
4312 ecs_world_t *world,
4313 const ecs_component_desc_t *desc);
4314
4324FLECS_API
4325 const ecs_type_info_t* ecs_get_type_info(
4326 const ecs_world_t *world,
4327 ecs_id_t component);
4328
4340FLECS_API
4341 void ecs_set_hooks_id(
4342 ecs_world_t *world,
4343 ecs_entity_t component,
4344 const ecs_type_hooks_t *hooks);
4345
4352FLECS_API
4353 const ecs_type_hooks_t* ecs_get_hooks_id(
4354 const ecs_world_t *world,
4355 ecs_entity_t component);
4356
4358
4365
4380FLECS_API
4381 bool ecs_id_is_tag(
4382 const ecs_world_t *world,
4383 ecs_id_t component);
4384
4393FLECS_API
4394 bool ecs_id_in_use(
4395 const ecs_world_t *world,
4396 ecs_id_t component);
4397
4417FLECS_API
4418 ecs_entity_t ecs_get_typeid(
4419 const ecs_world_t *world,
4420 ecs_id_t component);
4421
4430FLECS_API
4431 bool ecs_id_match(
4432 ecs_id_t component,
4433 ecs_id_t pattern);
4434
4440FLECS_API
4441 bool ecs_id_is_pair(
4442 ecs_id_t component);
4443
4449FLECS_API
4450 bool ecs_id_is_wildcard(
4451 ecs_id_t component);
4452
4458 bool ecs_id_is_any(
4459 ecs_id_t component);
4460
4474FLECS_API
4475 bool ecs_id_is_valid(
4476 const ecs_world_t *world,
4477 ecs_id_t component);
4478
4487FLECS_API
4488ecs_flags32_t ecs_id_get_flags(
4489 const ecs_world_t *world,
4490 ecs_id_t component);
4491
4502FLECS_API
4503 const char* ecs_id_flag_str(
4504 uint64_t component_flags);
4505
4521FLECS_API
4522 char* ecs_id_str(
4523 const ecs_world_t *world,
4524 ecs_id_t component);
4525
4533FLECS_API
4534 void ecs_id_str_buf(
4535 const ecs_world_t *world,
4536 ecs_id_t component,
4537 ecs_strbuf_t *buf);
4538
4547FLECS_API
4548 ecs_id_t ecs_id_from_str(
4549 const ecs_world_t *world,
4550 const char *expr);
4551
4553
4559
4567FLECS_API
4568 bool ecs_term_ref_is_set(
4569 const ecs_term_ref_t *ref);
4570
4582FLECS_API
4583 bool ecs_term_is_initialized(
4584 const ecs_term_t *term);
4585
4600FLECS_API
4601 bool ecs_term_match_this(
4602 const ecs_term_t *term);
4603
4616FLECS_API
4617 bool ecs_term_match_0(
4618 const ecs_term_t *term);
4619
4628FLECS_API
4629 char* ecs_term_str(
4630 const ecs_world_t *world,
4631 const ecs_term_t *term);
4632
4640FLECS_API
4641 char* ecs_query_str(
4642 const ecs_query_t *query);
4643
4645
4651
4684FLECS_API
4685 ecs_iter_t ecs_each_id(
4686 const ecs_world_t *world,
4687 ecs_id_t component);
4688
4694FLECS_API
4695 bool ecs_each_next(
4696 ecs_iter_t *it);
4697
4720FLECS_API
4721FLECS_ALWAYS_INLINE ecs_iter_t ecs_children(
4722 const ecs_world_t *world,
4723 ecs_entity_t parent);
4724
4732FLECS_API
4733FLECS_ALWAYS_INLINE ecs_iter_t ecs_children_w_rel(
4734 const ecs_world_t *world,
4735 ecs_entity_t relationship,
4736 ecs_entity_t parent);
4737
4743FLECS_API
4744 bool ecs_children_next(
4745 ecs_iter_t *it);
4746
4748
4755
4762FLECS_API
4763 ecs_query_t* ecs_query_init(
4764 ecs_world_t *world,
4765 const ecs_query_desc_t *desc);
4766
4771FLECS_API
4772 void ecs_query_fini(
4773 ecs_query_t *query);
4774
4783FLECS_API
4784int32_t ecs_query_find_var(
4785 const ecs_query_t *query,
4786 const char *name);
4787
4795FLECS_API
4796 const char* ecs_query_var_name(
4797 const ecs_query_t *query,
4798 int32_t var_id);
4799
4810FLECS_API
4811 bool ecs_query_var_is_entity(
4812 const ecs_query_t *query,
4813 int32_t var_id);
4814
4883FLECS_API
4884 ecs_iter_t ecs_query_iter(
4885 const ecs_world_t *world,
4886 const ecs_query_t *query);
4887
4895FLECS_API
4896 bool ecs_query_next(
4897 ecs_iter_t *it);
4898
4917FLECS_API
4918 bool ecs_query_has(
4919 const ecs_query_t *query,
4920 ecs_entity_t entity,
4921 ecs_iter_t *it);
4922
4941FLECS_API
4942 bool ecs_query_has_table(
4943 const ecs_query_t *query,
4944 ecs_table_t *table,
4945 ecs_iter_t *it);
4946
4973FLECS_API
4974 bool ecs_query_has_range(
4975 const ecs_query_t *query,
4976 ecs_table_range_t *range,
4977 ecs_iter_t *it);
4978
4986FLECS_API
4987int32_t ecs_query_match_count(
4988 const ecs_query_t *query);
4989
4999FLECS_API
5000 char* ecs_query_plan(
5001 const ecs_query_t *query);
5002
5017FLECS_API
5018 char* ecs_query_plan_w_profile(
5019 const ecs_query_t *query,
5020 const ecs_iter_t *it);
5021
5027FLECS_API
5028 char* ecs_query_plans(
5029 const ecs_query_t *query);
5030
5048FLECS_API
5049 const char* ecs_query_args_parse(
5050 ecs_query_t *query,
5051 ecs_iter_t *it,
5052 const char *expr);
5053
5076FLECS_API
5077 bool ecs_query_changed(
5078 ecs_query_t *query);
5079
5088FLECS_API
5089 const ecs_query_t* ecs_query_get(
5090 const ecs_world_t *world,
5091 ecs_entity_t query);
5092
5103FLECS_API
5104 void ecs_iter_skip(
5105 ecs_iter_t *it);
5106
5129FLECS_API
5130 void ecs_iter_set_group(
5131 ecs_iter_t *it,
5132 uint64_t group_id);
5133
5159FLECS_API
5160 const ecs_map_t* ecs_query_get_groups(
5161 const ecs_query_t *query);
5162
5171FLECS_API
5172 void* ecs_query_get_group_ctx(
5173 const ecs_query_t *query,
5174 uint64_t group_id);
5175
5184FLECS_API
5185 const ecs_query_group_info_t* ecs_query_get_group_info(
5186 const ecs_query_t *query,
5187 uint64_t group_id);
5188
5190 typedef struct ecs_query_count_t {
5191 int32_t results;
5192 int32_t entities;
5193 int32_t tables;
5196} ecs_query_count_t;
5197
5204FLECS_API
5205 ecs_query_count_t ecs_query_count(
5206 const ecs_query_t *query);
5207
5213FLECS_API
5214 bool ecs_query_is_true(
5215 const ecs_query_t *query);
5216
5225FLECS_API
5226 const ecs_query_t* ecs_query_get_cache_query(
5227 const ecs_query_t *query);
5228
5230
5237
5257FLECS_API
5258 void ecs_emit(
5259 ecs_world_t *world,
5260 ecs_event_desc_t *desc);
5261
5272FLECS_API
5273 void ecs_enqueue(
5274 ecs_world_t *world,
5275 ecs_event_desc_t *desc);
5276
5287FLECS_API
5288 ecs_entity_t ecs_observer_init(
5289 ecs_world_t *world,
5290 const ecs_observer_desc_t *desc);
5291
5300FLECS_API
5301 const ecs_observer_t* ecs_observer_get(
5302 const ecs_world_t *world,
5303 ecs_entity_t observer);
5304
5306
5313
5327FLECS_API
5328 bool ecs_iter_next(
5329 ecs_iter_t *it);
5330
5340FLECS_API
5341 void ecs_iter_fini(
5342 ecs_iter_t *it);
5343
5355FLECS_API
5356int32_t ecs_iter_count(
5357 ecs_iter_t *it);
5358
5371FLECS_API
5372 bool ecs_iter_is_true(
5373 ecs_iter_t *it);
5374
5382FLECS_API
5383 ecs_entity_t ecs_iter_first(
5384 ecs_iter_t *it);
5385
5424FLECS_API
5425 void ecs_iter_set_var(
5426 ecs_iter_t *it,
5427 int32_t var_id,
5428 ecs_entity_t entity);
5429
5440FLECS_API
5441 void ecs_iter_set_var_as_table(
5442 ecs_iter_t *it,
5443 int32_t var_id,
5444 const ecs_table_t *table);
5445
5456FLECS_API
5457 void ecs_iter_set_var_as_range(
5458 ecs_iter_t *it,
5459 int32_t var_id,
5460 const ecs_table_range_t *range);
5461
5474FLECS_API
5475 ecs_entity_t ecs_iter_get_var(
5476 ecs_iter_t *it,
5477 int32_t var_id);
5478
5485FLECS_API
5486 const char* ecs_iter_get_var_name(
5487 const ecs_iter_t *it,
5488 int32_t var_id);
5489
5495FLECS_API
5496int32_t ecs_iter_get_var_count(
5497 const ecs_iter_t *it);
5498
5504FLECS_API
5505ecs_var_t* ecs_iter_get_vars(
5506 const ecs_iter_t *it);
5507
5521FLECS_API
5522 ecs_table_t* ecs_iter_get_var_as_table(
5523 ecs_iter_t *it,
5524 int32_t var_id);
5525
5539FLECS_API
5540ecs_table_range_t ecs_iter_get_var_as_range(
5541 ecs_iter_t *it,
5542 int32_t var_id);
5543
5555FLECS_API
5556 bool ecs_iter_var_is_constrained(
5557 ecs_iter_t *it,
5558 int32_t var_id);
5559
5571FLECS_API
5572uint64_t ecs_iter_get_group(
5573 const ecs_iter_t *it);
5574
5586FLECS_API
5587 bool ecs_iter_changed(
5588 ecs_iter_t *it);
5589
5601FLECS_API
5602 char* ecs_iter_str(
5603 const ecs_iter_t *it);
5604
5620FLECS_API
5621 ecs_iter_t ecs_page_iter(
5622 const ecs_iter_t *it,
5623 int32_t offset,
5624 int32_t limit);
5625
5632FLECS_API
5633 bool ecs_page_next(
5634 ecs_iter_t *it);
5635
5656FLECS_API
5657 ecs_iter_t ecs_worker_iter(
5658 const ecs_iter_t *it,
5659 int32_t index,
5660 int32_t count);
5661
5668FLECS_API
5669 bool ecs_worker_next(
5670 ecs_iter_t *it);
5671
5713FLECS_API
5714 void* ecs_field_w_size(
5715 const ecs_iter_t *it,
5716 size_t size,
5717 int8_t index);
5718
5741FLECS_API
5742 void* ecs_field_at_w_size(
5743 const ecs_iter_t *it,
5744 size_t size,
5745 int8_t index,
5746 int32_t row);
5747
5756FLECS_API
5757 bool ecs_field_is_readonly(
5758 const ecs_iter_t *it,
5759 int8_t index);
5760
5771FLECS_API
5772 bool ecs_field_is_writeonly(
5773 const ecs_iter_t *it,
5774 int8_t index);
5775
5782FLECS_API
5783 bool ecs_field_is_set(
5784 const ecs_iter_t *it,
5785 int8_t index);
5786
5793FLECS_API
5794 ecs_id_t ecs_field_id(
5795 const ecs_iter_t *it,
5796 int8_t index);
5797
5806FLECS_API
5807int32_t ecs_field_column(
5808 const ecs_iter_t *it,
5809 int8_t index);
5810
5818FLECS_API
5819 ecs_entity_t ecs_field_src(
5820 const ecs_iter_t *it,
5821 int8_t index);
5822
5830FLECS_API
5831 size_t ecs_field_size(
5832 const ecs_iter_t *it,
5833 int8_t index);
5834
5848FLECS_API
5849 bool ecs_field_is_self(
5850 const ecs_iter_t *it,
5851 int8_t index);
5852
5854
5861
5868FLECS_API
5869 const ecs_type_t* ecs_table_get_type(
5870 const ecs_table_t *table);
5871
5882FLECS_API
5883int32_t ecs_table_get_type_index(
5884 const ecs_world_t *world,
5885 const ecs_table_t *table,
5886 ecs_id_t component);
5887
5897FLECS_API
5898int32_t ecs_table_get_column_index(
5899 const ecs_world_t *world,
5900 const ecs_table_t *table,
5901 ecs_id_t component);
5902
5910FLECS_API
5911int32_t ecs_table_column_count(
5912 const ecs_table_t *table);
5913
5927FLECS_API
5928int32_t ecs_table_type_to_column_index(
5929 const ecs_table_t *table,
5930 int32_t index);
5931
5940FLECS_API
5941int32_t ecs_table_column_to_type_index(
5942 const ecs_table_t *table,
5943 int32_t index);
5944
5953FLECS_API
5954 void* ecs_table_get_column(
5955 const ecs_table_t *table,
5956 int32_t index,
5957 int32_t offset);
5958
5968FLECS_API
5969 void* ecs_table_get_id(
5970 const ecs_world_t *world,
5971 const ecs_table_t *table,
5972 ecs_id_t component,
5973 int32_t offset);
5974
5982FLECS_API
5983 size_t ecs_table_get_column_size(
5984 const ecs_table_t *table,
5985 int32_t index);
5986
5993FLECS_API
5994int32_t ecs_table_count(
5995 const ecs_table_t *table);
5996
6004FLECS_API
6005int32_t ecs_table_size(
6006 const ecs_table_t *table);
6007
6014FLECS_API
6015 const ecs_entity_t* ecs_table_entities(
6016 const ecs_table_t *table);
6017
6028FLECS_API
6029 bool ecs_table_has_id(
6030 const ecs_world_t *world,
6031 const ecs_table_t *table,
6032 ecs_id_t component);
6033
6044FLECS_API
6045 ecs_entity_t ecs_table_get_target(
6046 const ecs_world_t *world,
6047 const ecs_table_t *table,
6048 ecs_entity_t relationship,
6049 int32_t index);
6050
6061FLECS_API
6062int32_t ecs_table_get_depth(
6063 const ecs_world_t *world,
6064 const ecs_table_t *table,
6065 ecs_entity_t rel);
6066
6076FLECS_API
6077 ecs_table_t* ecs_table_add_id(
6078 ecs_world_t *world,
6079 ecs_table_t *table,
6080 ecs_id_t component);
6081
6092FLECS_API
6093 ecs_table_t* ecs_table_find(
6094 ecs_world_t *world,
6095 const ecs_id_t *ids,
6096 int32_t id_count);
6097
6107FLECS_API
6108 ecs_table_t* ecs_table_remove_id(
6109 ecs_world_t *world,
6110 ecs_table_t *table,
6111 ecs_id_t component);
6112
6128FLECS_API
6129 void ecs_table_lock(
6130 ecs_world_t *world,
6131 ecs_table_t *table);
6132
6139FLECS_API
6140 void ecs_table_unlock(
6141 ecs_world_t *world,
6142 ecs_table_t *table);
6143
6153FLECS_API
6154 bool ecs_table_has_flags(
6155 ecs_table_t *table,
6156 ecs_flags32_t flags);
6157
6165FLECS_API
6166 bool ecs_table_has_traversable(
6167 const ecs_table_t *table);
6168
6178FLECS_API
6179 void ecs_table_swap_rows(
6180 ecs_world_t* world,
6181 ecs_table_t* table,
6182 int32_t row_1,
6183 int32_t row_2);
6184
6209FLECS_API
6210 bool ecs_commit(
6211 ecs_world_t *world,
6212 ecs_entity_t entity,
6213 ecs_record_t *record,
6214 ecs_table_t *table,
6215 const ecs_type_t *added,
6216 const ecs_type_t *removed);
6217
6218
6238FLECS_API
6239int32_t ecs_search(
6240 const ecs_world_t *world,
6241 const ecs_table_t *table,
6242 ecs_id_t component,
6243 ecs_id_t *component_out);
6244
6280FLECS_API
6281int32_t ecs_search_offset(
6282 const ecs_world_t *world,
6283 const ecs_table_t *table,
6284 int32_t offset,
6285 ecs_id_t component,
6286 ecs_id_t *component_out);
6287
6328FLECS_API
6329int32_t ecs_search_relation(
6330 const ecs_world_t *world,
6331 const ecs_table_t *table,
6332 int32_t offset,
6333 ecs_id_t component,
6334 ecs_entity_t rel,
6335 ecs_flags64_t flags, /* EcsSelf and/or EcsUp */
6336 ecs_entity_t *tgt_out,
6337 ecs_id_t *component_out,
6338 struct ecs_table_record_t **tr_out);
6339
6355FLECS_API
6356int32_t ecs_search_relation_for_entity(
6357 const ecs_world_t *world,
6358 ecs_entity_t entity,
6359 ecs_id_t id,
6360 ecs_entity_t rel,
6361 bool self,
6362 ecs_component_record_t *cr,
6363 ecs_entity_t *tgt_out,
6364 ecs_id_t *id_out,
6365 struct ecs_table_record_t **tr_out);
6366
6374FLECS_API
6375 void ecs_table_clear_entities(
6376 ecs_world_t* world,
6377 ecs_table_t* table);
6378
6380
6387
6395FLECS_API
6396 int ecs_value_init(
6397 const ecs_world_t *world,
6398 ecs_entity_t type,
6399 void *ptr);
6400
6408FLECS_API
6409 int ecs_value_init_w_type_info(
6410 const ecs_world_t *world,
6411 const ecs_type_info_t *ti,
6412 void *ptr);
6413
6420FLECS_API
6421 void* ecs_value_new(
6422 ecs_world_t *world,
6423 ecs_entity_t type);
6424
6431 void* ecs_value_new_w_type_info(
6432 ecs_world_t *world,
6433 const ecs_type_info_t *ti);
6434
6442 int ecs_value_fini_w_type_info(
6443 const ecs_world_t *world,
6444 const ecs_type_info_t *ti,
6445 void *ptr);
6446
6454FLECS_API
6455 int ecs_value_fini(
6456 const ecs_world_t *world,
6457 ecs_entity_t type,
6458 void* ptr);
6459
6467FLECS_API
6468 int ecs_value_free(
6469 ecs_world_t *world,
6470 ecs_entity_t type,
6471 void* ptr);
6472
6481FLECS_API
6482 int ecs_value_copy_w_type_info(
6483 const ecs_world_t *world,
6484 const ecs_type_info_t *ti,
6485 void* dst,
6486 const void *src);
6487
6496FLECS_API
6497 int ecs_value_copy(
6498 const ecs_world_t *world,
6499 ecs_entity_t type,
6500 void* dst,
6501 const void *src);
6502
6511 int ecs_value_move_w_type_info(
6512 const ecs_world_t *world,
6513 const ecs_type_info_t *ti,
6514 void* dst,
6515 void *src);
6516
6525 int ecs_value_move(
6526 const ecs_world_t *world,
6527 ecs_entity_t type,
6528 void* dst,
6529 void *src);
6530
6539 int ecs_value_move_ctor_w_type_info(
6540 const ecs_world_t *world,
6541 const ecs_type_info_t *ti,
6542 void* dst,
6543 void *src);
6544
6553 int ecs_value_move_ctor(
6554 const ecs_world_t *world,
6555 ecs_entity_t type,
6556 void* dst,
6557 void *src);
6558
6560
6562
6571
6572#include "flecs/addons/flecs_c.h"
6573
6574#ifdef __cplusplus
6575}
6576#endif
6577
6578#include "flecs/private/addons.h"
6579
6580#endif
deprecated.h
The deprecated addon contains deprecated operations.
flecs_c.h
Extends the core API with convenience macros for C applications.
ecs_remove_id
void ecs_remove_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Remove a component from an entity.
ecs_auto_override_id
void ecs_auto_override_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Add an auto override for a component.
ecs_remove_all
void ecs_remove_all(ecs_world_t *world, ecs_id_t component)
Remove all instances of the specified component.
ecs_clear
void ecs_clear(ecs_world_t *world, ecs_entity_t entity)
Clear all components.
ecs_get_with
ecs_id_t ecs_get_with(const ecs_world_t *world)
Get the component set with ecs_set_with().
ecs_add_id
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Add a (component) ID to an entity.
ecs_set_with
ecs_entity_t ecs_set_with(ecs_world_t *world, ecs_id_t component)
Create new entities with a specified component.
EcsScopeClose
const ecs_entity_t EcsScopeClose
Marker used to indicate the end of a scope (}) in queries.
EcsOnRemove
const ecs_entity_t EcsOnRemove
Event that triggers when an ID is removed from an entity.
EcsThis
const ecs_entity_t EcsThis
This entity.
EcsWildcard
const ecs_entity_t EcsWildcard
Wildcard entity ("*").
EcsName
const ecs_entity_t EcsName
Tag to indicate name identifier.
EcsAcyclic
const ecs_entity_t EcsAcyclic
Mark a relationship as acyclic.
EcsSymmetric
const ecs_entity_t EcsSymmetric
Mark relationship as commutative.
EcsAlias
const ecs_entity_t EcsAlias
Tag to indicate alias identifier.
EcsOnSet
const ecs_entity_t EcsOnSet
Event that triggers when a component is set for an entity.
EcsReflexive
const ecs_entity_t EcsReflexive
Mark a relationship as reflexive.
EcsTrait
const ecs_entity_t EcsTrait
Can be added to components to indicate it is a trait.
EcsEmpty
const ecs_entity_t EcsEmpty
Tag used to indicate a query is empty.
EcsOneOf
const ecs_entity_t EcsOneOf
Ensure that a relationship target is a child of the specified entity.
EcsOnTableDelete
const ecs_entity_t EcsOnTableDelete
Event that triggers when a table is deleted.
EcsOnTableCreate
const ecs_entity_t EcsOnTableCreate
Event that triggers when a table is created.
EcsObserver
const ecs_entity_t EcsObserver
Tag added to observers.
EcsQuery
const ecs_entity_t EcsQuery
Tag added to queries.
EcsRelationship
const ecs_entity_t EcsRelationship
Ensure that an entity is always used in a pair as a relationship.
EcsSingleton
const ecs_entity_t EcsSingleton
Mark component as singleton.
EcsOnStart
const ecs_entity_t EcsOnStart
OnStart pipeline phase.
EcsNotQueryable
const ecs_entity_t EcsNotQueryable
Trait added to entities that should never be returned by queries.
EcsOnStore
const ecs_entity_t EcsOnStore
OnStore pipeline phase.
EcsOrderedChildren
const ecs_entity_t EcsOrderedChildren
Tag that, when added to a parent, ensures stable order of ecs_children() results.
EcsDontFragment
const ecs_entity_t EcsDontFragment
Mark component as non-fragmenting.
EcsTraversable
const ecs_entity_t EcsTraversable
Mark a relationship as traversable.
EcsPredLookup
const ecs_entity_t EcsPredLookup
Marker used to indicate $var ~= "pattern" matching in queries.
EcsPreStore
const ecs_entity_t EcsPreStore
PreStore pipeline phase.
EcsOnLoad
const ecs_entity_t EcsOnLoad
OnLoad pipeline phase.
EcsIsA
const ecs_entity_t EcsIsA
Used to express inheritance relationships.
EcsExclusive
const ecs_entity_t EcsExclusive
Can be added to a relationship to indicate that the relationship can only occur once on an entity.
EcsSymbol
const ecs_entity_t EcsSymbol
Tag to indicate symbol identifier.
EcsDependsOn
const ecs_entity_t EcsDependsOn
Used to express dependency relationships.
EcsTransitive
const ecs_entity_t EcsTransitive
Mark a relationship as transitive.
EcsDelete
const ecs_entity_t EcsDelete
Delete cleanup policy.
EcsChildOf
const ecs_entity_t EcsChildOf
Used to express parent-child relationships.
EcsFlecsCore
const ecs_entity_t EcsFlecsCore
Core module scope.
EcsMonitor
const ecs_entity_t EcsMonitor
Event that triggers an observer when an entity starts or stops matching a query.
EcsCanToggle
const ecs_entity_t EcsCanToggle
Mark a component as toggleable with ecs_enable_id().
EcsPredEq
const ecs_entity_t EcsPredEq
Marker used to indicate $var == ... matching in queries.
EcsPhase
const ecs_entity_t EcsPhase
Phase pipeline phase.
EcsWorld
const ecs_entity_t EcsWorld
Entity associated with world (used for "attaching" components to world).
EcsScopeOpen
const ecs_entity_t EcsScopeOpen
Marker used to indicate the start of a scope ({) in queries.
EcsPostUpdate
const ecs_entity_t EcsPostUpdate
PostUpdate pipeline phase.
EcsOnValidate
const ecs_entity_t EcsOnValidate
OnValidate pipeline phase.
EcsRemove
const ecs_entity_t EcsRemove
Remove cleanup policy.
EcsOverride
const ecs_entity_t EcsOverride
Override component on instantiate.
EcsPredMatch
const ecs_entity_t EcsPredMatch
Marker used to indicate $var == "name" matching in queries.
EcsInherit
const ecs_entity_t EcsInherit
Inherit component on instantiate.
EcsSlotOf
const ecs_entity_t EcsSlotOf
Used to express a slot (used with prefab inheritance).
EcsModule
const ecs_entity_t EcsModule
Tag added to module entities.
EcsSparse
const ecs_entity_t EcsSparse
Mark component as sparse.
EcsPreUpdate
const ecs_entity_t EcsPreUpdate
PreUpdate pipeline phase.
EcsOnAdd
const ecs_entity_t EcsOnAdd
Event that triggers when an ID is added to an entity.
EcsPrefab
const ecs_entity_t EcsPrefab
Tag added to prefab entities.
EcsOnInstantiate
const ecs_entity_t EcsOnInstantiate
Relationship that specifies component inheritance behavior.
EcsPostFrame
const ecs_entity_t EcsPostFrame
PostFrame pipeline phase.
EcsInheritable
const ecs_entity_t EcsInheritable
Mark component as inheritable.
EcsAny
const ecs_entity_t EcsAny
Any entity ("_").
EcsTarget
const ecs_entity_t EcsTarget
Ensure that an entity is always used in a pair as a target.
EcsParentDepth
const ecs_entity_t EcsParentDepth
Relationship storing the entity's depth in a non-fragmenting hierarchy.
EcsWith
const ecs_entity_t EcsWith
Ensure that a component is always added together with another component.
EcsPostLoad
const ecs_entity_t EcsPostLoad
PostLoad pipeline phase.
EcsOnDelete
const ecs_entity_t EcsOnDelete
Relationship used for specifying cleanup behavior.
EcsOnDeleteTarget
const ecs_entity_t EcsOnDeleteTarget
Relationship used to define what should happen when a target entity (second element of a pair) is del...
EcsPreFrame
const ecs_entity_t EcsPreFrame
PreFrame pipeline phase.
EcsFlecs
const ecs_entity_t EcsFlecs
Root scope for built-in Flecs entities.
EcsSystem
const ecs_entity_t EcsSystem
Tag added to systems.
EcsOnUpdate
const ecs_entity_t EcsOnUpdate
OnUpdate pipeline phase.
EcsDisabled
const ecs_entity_t EcsDisabled
When this tag is added to an entity, it is skipped by queries, unless EcsDisabled is explicitly queri...
EcsDontInherit
const ecs_entity_t EcsDontInherit
Never inherit component on instantiate.
EcsPairIsTag
const ecs_entity_t EcsPairIsTag
Can be added to a relationship to indicate that it should never hold data, even when it or the relati...
EcsPanic
const ecs_entity_t EcsPanic
Panic cleanup policy.
EcsFinal
const ecs_entity_t EcsFinal
Ensure that an entity or component cannot be used as a target in an IsA relationship.
EcsVariable
const ecs_entity_t EcsVariable
Variable entity ("$").
EcsConstant
const ecs_entity_t EcsConstant
Tag added to enum or bitmask constants.
ecs_id
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
ecs_stage_new
ecs_world_t * ecs_stage_new(ecs_world_t *world)
Create an unmanaged stage.
ecs_defer_end
bool ecs_defer_end(ecs_world_t *world)
End a block of operations to defer.
ecs_readonly_begin
bool ecs_readonly_begin(ecs_world_t *world, bool multi_threaded)
Begin readonly mode.
ecs_defer_resume
void ecs_defer_resume(ecs_world_t *world)
Resume deferring.
ecs_defer_begin
bool ecs_defer_begin(ecs_world_t *world)
Defer operations until the end of the frame.
ecs_defer_suspend
void ecs_defer_suspend(ecs_world_t *world)
Suspend deferring but do not flush queue.
ecs_is_deferred
bool ecs_is_deferred(const ecs_world_t *world)
Test if deferring is enabled for the current stage.
ecs_stage_free
void ecs_stage_free(ecs_world_t *stage)
Free an unmanaged stage.
ecs_merge
void ecs_merge(ecs_world_t *stage)
Merge a stage.
ecs_stage_get_id
int32_t ecs_stage_get_id(const ecs_world_t *world)
Get the stage ID.
ecs_stage_is_readonly
bool ecs_stage_is_readonly(const ecs_world_t *world)
Test whether the current world is readonly.
ecs_get_stage_count
int32_t ecs_get_stage_count(const ecs_world_t *world)
Get the number of configured stages.
ecs_get_stage
ecs_world_t * ecs_get_stage(const ecs_world_t *world, int32_t stage_id)
Get stage-specific world pointer.
ecs_set_stage_count
void ecs_set_stage_count(ecs_world_t *world, int32_t stages)
Configure the world to have N stages.
ecs_readonly_end
void ecs_readonly_end(ecs_world_t *world)
End readonly mode.
ecs_is_defer_suspended
bool ecs_is_defer_suspended(const ecs_world_t *world)
Test if deferring is suspended for the current stage.
ecs_get_hooks_id
const ecs_type_hooks_t * ecs_get_hooks_id(const ecs_world_t *world, ecs_entity_t component)
Get hooks for a component.
ecs_component_init
ecs_entity_t ecs_component_init(ecs_world_t *world, const ecs_component_desc_t *desc)
Find or create a component.
ecs_get_type_info
const ecs_type_info_t * ecs_get_type_info(const ecs_world_t *world, ecs_id_t component)
Get the type info for a component.
ecs_set_hooks_id
void ecs_set_hooks_id(ecs_world_t *world, ecs_entity_t component, const ecs_type_hooks_t *hooks)
Register hooks for a component.
ecs_component_record_t
struct ecs_component_record_t ecs_component_record_t
Information about a (component) ID, such as type info and tables with the ID.
Definition flecs.h:493
ecs_stage_t
struct ecs_stage_t ecs_stage_t
A stage enables modification while iterating and from multiple threads.
Definition flecs.h:428
ecs_ref_t
struct ecs_ref_t ecs_ref_t
A ref is a fast way to fetch a component for a specific entity.
Definition flecs.h:477
ecs_entity_t
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:381
ecs_table_record_t
struct ecs_table_record_t ecs_table_record_t
Opaque type for table record.
Definition flecs.h:527
ecs_world_t
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:425
ecs_mixins_t
struct ecs_mixins_t ecs_mixins_t
Type that stores poly mixins.
Definition flecs.h:517
ecs_id_t
uint64_t ecs_id_t
IDs are the things that can be added to an entity.
Definition flecs.h:374
ecs_observable_t
struct ecs_observable_t ecs_observable_t
An observable produces events that can be listened for by an observer.
Definition flecs.h:461
ecs_record_t
struct ecs_record_t ecs_record_t
Information about an entity, like its table and row.
Definition flecs.h:490
ecs_table_t
struct ecs_table_t ecs_table_t
A table stores entities and components for a specific type.
Definition flecs.h:431
ecs_poly_t
void ecs_poly_t
A poly object.
Definition flecs.h:514
ecs_new_low_id
ecs_entity_t ecs_new_low_id(ecs_world_t *world)
Create new low ID.
ecs_set_child_order
void ecs_set_child_order(ecs_world_t *world, ecs_entity_t parent, const ecs_entity_t *children, int32_t child_count)
Set child order for parent with OrderedChildren.
ecs_bulk_init
const ecs_entity_t * ecs_bulk_init(ecs_world_t *world, const ecs_bulk_desc_t *desc)
Bulk create or populate new entities.
ecs_clone
ecs_entity_t ecs_clone(ecs_world_t *world, ecs_entity_t dst, ecs_entity_t src, bool copy_value)
Clone an entity.
ecs_new
ecs_entity_t ecs_new(ecs_world_t *world)
Create new entity ID.
ecs_entity_init
ecs_entity_t ecs_entity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)
Find or create an entity.
ecs_delete
void ecs_delete(ecs_world_t *world, ecs_entity_t entity)
Delete an entity.
ecs_delete_with
void ecs_delete_with(ecs_world_t *world, ecs_id_t component)
Delete all entities with the specified component.
ecs_new_w_id
ecs_entity_t ecs_new_w_id(ecs_world_t *world, ecs_id_t component)
Create new entity with (component) ID.
ecs_new_w_table
ecs_entity_t ecs_new_w_table(ecs_world_t *world, ecs_table_t *table)
Create new entity in table.
ecs_bulk_new_w_id
const ecs_entity_t * ecs_bulk_new_w_id(ecs_world_t *world, ecs_id_t component, int32_t count)
Create N new entities.
ecs_get_ordered_children
ecs_entities_t ecs_get_ordered_children(const ecs_world_t *world, ecs_entity_t parent)
Get ordered children.
ecs_children_next
bool ecs_children_next(ecs_iter_t *it)
Progress an iterator created with ecs_children().
ecs_each_id
ecs_iter_t ecs_each_id(const ecs_world_t *world, ecs_id_t component)
Iterate all entities with a specified (component ID).
ecs_each_next
bool ecs_each_next(ecs_iter_t *it)
Progress an iterator created with ecs_each_id().
ecs_children
ecs_iter_t ecs_children(const ecs_world_t *world, ecs_entity_t parent)
Iterate children of a parent.
ecs_children_w_rel
ecs_iter_t ecs_children_w_rel(const ecs_world_t *world, ecs_entity_t relationship, ecs_entity_t parent)
Same as ecs_children(), but with a custom relationship argument.
ecs_enable_id
void ecs_enable_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, bool enable)
Enable or disable a component.
ecs_is_enabled_id
bool ecs_is_enabled_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if a component is enabled.
ecs_enable
void ecs_enable(ecs_world_t *world, ecs_entity_t entity, bool enabled)
Enable or disable an entity.
ecs_entity_str
char * ecs_entity_str(const ecs_world_t *world, ecs_entity_t entity)
Convert an entity to a string.
ecs_get_target
ecs_entity_t ecs_get_target(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, int32_t index)
Get the target of a relationship.
ecs_get_parent
ecs_entity_t ecs_get_parent(const ecs_world_t *world, ecs_entity_t entity)
Get the parent (target of the ChildOf relationship) for an entity.
ecs_get_target_for_id
ecs_entity_t ecs_get_target_for_id(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, ecs_id_t component)
Get the target of a relationship for a given component.
ecs_get_type
const ecs_type_t * ecs_get_type(const ecs_world_t *world, ecs_entity_t entity)
Get the type of an entity.
ecs_owns_id
bool ecs_owns_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if an entity owns a component.
ecs_type_str
char * ecs_type_str(const ecs_world_t *world, const ecs_type_t *type)
Convert a type to a string.
ecs_table_str
char * ecs_table_str(const ecs_world_t *world, const ecs_table_t *table)
Convert a table to a string.
ecs_count_id
int32_t ecs_count_id(const ecs_world_t *world, ecs_id_t entity)
Count entities that have the specified ID.
ecs_get_depth
int32_t ecs_get_depth(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel)
Return the depth for an entity in the tree for the specified relationship.
ecs_get_table
ecs_table_t * ecs_get_table(const ecs_world_t *world, ecs_entity_t entity)
Get the table of an entity.
ecs_new_w_parent
ecs_entity_t ecs_new_w_parent(ecs_world_t *world, ecs_entity_t parent, const char *name)
Create child with Parent component.
ecs_has_id
bool ecs_has_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if an entity has a component.
ecs_module_action_t
void(* ecs_module_action_t)(ecs_world_t *world)
Initialization action for modules.
Definition flecs.h:637
ecs_group_by_action_t
uint64_t(* ecs_group_by_action_t)(ecs_world_t *world, ecs_table_t *table, ecs_id_t group_id, void *ctx)
Callback used for grouping tables in a query.
Definition flecs.h:617
ecs_cmp_t
int(* ecs_cmp_t)(const void *a_ptr, const void *b_ptr, const ecs_type_info_t *type_info)
Compare hook to compare component instances.
Definition flecs.h:679
ecs_hash_value_action_t
uint64_t(* ecs_hash_value_action_t)(const void *ptr)
Callback used for hashing values.
Definition flecs.h:655
ecs_group_delete_action_t
void(* ecs_group_delete_action_t)(ecs_world_t *world, uint64_t group_id, void *group_ctx, void *group_by_ctx)
Callback invoked when a query deletes an existing group.
Definition flecs.h:630
ecs_iter_fini_action_t
void(* ecs_iter_fini_action_t)(ecs_iter_t *it)
Function prototype for freeing an iterator.
Definition flecs.h:595
ecs_group_create_action_t
void *(* ecs_group_create_action_t)(ecs_world_t *world, uint64_t group_id, void *group_by_ctx)
Callback invoked when a query creates a new group.
Definition flecs.h:624
ecs_sort_table_action_t
void(* ecs_sort_table_action_t)(ecs_world_t *world, ecs_table_t *table, ecs_entity_t *entities, void *ptr, int32_t size, int32_t lo, int32_t hi, ecs_order_by_action_t order_by)
Callback used for sorting the entire table of components.
Definition flecs.h:606
ecs_iter_next_action_t
bool(* ecs_iter_next_action_t)(ecs_iter_t *it)
Function prototype for iterating an iterator.
Definition flecs.h:587
ecs_iter_action_t
void(* ecs_iter_action_t)(ecs_iter_t *it)
Function prototype for iterables.
Definition flecs.h:577
ecs_copy_t
void(* ecs_copy_t)(void *dst_ptr, const void *src_ptr, int32_t count, const ecs_type_info_t *type_info)
Copy is invoked when a component is copied into another component.
Definition flecs.h:665
ecs_equals_t
bool(* ecs_equals_t)(const void *a_ptr, const void *b_ptr, const ecs_type_info_t *type_info)
Equals operator hook.
Definition flecs.h:685
ecs_compare_action_t
int(* ecs_compare_action_t)(const void *ptr1, const void *ptr2)
Callback used for sorting values.
Definition flecs.h:650
ecs_fini_action_t
void(* ecs_fini_action_t)(ecs_world_t *world, void *ctx)
Action callback on world exit.
Definition flecs.h:641
ecs_move_t
void(* ecs_move_t)(void *dst_ptr, void *src_ptr, int32_t count, const ecs_type_info_t *type_info)
Move is invoked when a component is moved to another component.
Definition flecs.h:672
flecs_poly_dtor_t
void(* flecs_poly_dtor_t)(ecs_poly_t *poly)
Destructor function for poly objects.
Definition flecs.h:691
ecs_run_action_t
void(* ecs_run_action_t)(ecs_iter_t *it)
Function prototype for runnables (systems, observers).
Definition flecs.h:568
ecs_ctx_free_t
void(* ecs_ctx_free_t)(void *ctx)
Function to clean up context data.
Definition flecs.h:646
ecs_order_by_action_t
int(* ecs_order_by_action_t)(ecs_entity_t e1, const void *ptr1, ecs_entity_t e2, const void *ptr2)
Callback used for comparing components.
Definition flecs.h:599
ecs_xtor_t
void(* ecs_xtor_t)(void *ptr, int32_t count, const ecs_type_info_t *type_info)
Constructor/destructor callback.
Definition flecs.h:659
ecs_ref_get_id
void * ecs_ref_get_id(const ecs_world_t *world, ecs_ref_t *ref, ecs_id_t component)
Get a component from a ref.
ecs_emplace_id
void * ecs_emplace_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size, bool *is_new)
Emplace a component.
ecs_ref_update
void ecs_ref_update(const ecs_world_t *world, ecs_ref_t *ref)
Update a ref.
ecs_get_id
const void * ecs_get_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Get an immutable pointer to a component.
ecs_modified_id
void ecs_modified_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Signal that a component has been modified.
ecs_ref_init_id
ecs_ref_t ecs_ref_init_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Create a component ref.
ecs_get_mut_id
void * ecs_get_mut_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Get a mutable pointer to a component.
ecs_ensure_id
void * ecs_ensure_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size)
Ensure an entity has a component and return a pointer.
ecs_set_id
void ecs_set_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size, const void *ptr)
Set the value of a component.
ECS_PAIR
const ecs_id_t ECS_PAIR
Indicate that the ID is a pair.
ECS_AUTO_OVERRIDE
const ecs_id_t ECS_AUTO_OVERRIDE
Automatically override component when it is inherited.
ECS_TOGGLE
const ecs_id_t ECS_TOGGLE
Add a bitset to storage, which allows a component to be enabled or disabled.
ECS_VALUE_PAIR
const ecs_id_t ECS_VALUE_PAIR
Indicate that the target of a pair is an integer value.
ecs_id_str
char * ecs_id_str(const ecs_world_t *world, ecs_id_t component)
Convert a component ID to a string.
ecs_id_is_tag
bool ecs_id_is_tag(const ecs_world_t *world, ecs_id_t component)
Return whether a specified component is a tag.
ecs_id_get_flags
ecs_flags32_t ecs_id_get_flags(const ecs_world_t *world, ecs_id_t component)
Get flags associated with an ID.
ecs_id_is_valid
bool ecs_id_is_valid(const ecs_world_t *world, ecs_id_t component)
Utility to check if an ID is valid.
ecs_id_flag_str
const char * ecs_id_flag_str(uint64_t component_flags)
Convert a component flag to a string.
ecs_id_in_use
bool ecs_id_in_use(const ecs_world_t *world, ecs_id_t component)
Return whether a specified component is in use.
ecs_id_match
bool ecs_id_match(ecs_id_t component, ecs_id_t pattern)
Utility to match a component with a pattern.
ecs_id_str_buf
void ecs_id_str_buf(const ecs_world_t *world, ecs_id_t component, ecs_strbuf_t *buf)
Write a component string to a buffer.
ecs_id_is_pair
bool ecs_id_is_pair(ecs_id_t component)
Utility to check if a component is a pair.
ecs_get_typeid
ecs_entity_t ecs_get_typeid(const ecs_world_t *world, ecs_id_t component)
Get the type for a component.
ecs_id_from_str
ecs_id_t ecs_id_from_str(const ecs_world_t *world, const char *expr)
Convert a string to a component.
ecs_id_is_wildcard
bool ecs_id_is_wildcard(ecs_id_t component)
Utility to check if a component is a wildcard.
ecs_id_is_any
bool ecs_id_is_any(ecs_id_t component)
Utility to check if a component is an any wildcard.
ecs_field_src
ecs_entity_t ecs_field_src(const ecs_iter_t *it, int8_t index)
Return the field source.
ecs_iter_changed
bool ecs_iter_changed(ecs_iter_t *it)
Return whether the current iterator result has changed.
ecs_field_is_writeonly
bool ecs_field_is_writeonly(const ecs_iter_t *it, int8_t index)
Test whether the field is write-only.
ecs_iter_get_vars
ecs_var_t * ecs_iter_get_vars(const ecs_iter_t *it)
Get the variable array.
ecs_field_is_readonly
bool ecs_field_is_readonly(const ecs_iter_t *it, int8_t index)
Test whether the field is read-only.
ecs_iter_get_var_name
const char * ecs_iter_get_var_name(const ecs_iter_t *it, int32_t var_id)
Get the variable name.
ecs_worker_iter
ecs_iter_t ecs_worker_iter(const ecs_iter_t *it, int32_t index, int32_t count)
Create a worker iterator.
ecs_iter_is_true
bool ecs_iter_is_true(ecs_iter_t *it)
Test if an iterator is true.
ecs_iter_fini
void ecs_iter_fini(ecs_iter_t *it)
Clean up iterator resources.
ecs_iter_str
char * ecs_iter_str(const ecs_iter_t *it)
Convert an iterator to a string.
ecs_iter_var_is_constrained
bool ecs_iter_var_is_constrained(ecs_iter_t *it, int32_t var_id)
Return whether a variable is constrained.
ecs_page_iter
ecs_iter_t ecs_page_iter(const ecs_iter_t *it, int32_t offset, int32_t limit)
Create a paged iterator.
ecs_iter_get_var_count
int32_t ecs_iter_get_var_count(const ecs_iter_t *it)
Get the number of variables.
ecs_field_at_w_size
void * ecs_field_at_w_size(const ecs_iter_t *it, size_t size, int8_t index, int32_t row)
Get data for a field at a specified row.
ecs_field_id
ecs_id_t ecs_field_id(const ecs_iter_t *it, int8_t index)
Return the ID matched for a field.
ecs_field_is_set
bool ecs_field_is_set(const ecs_iter_t *it, int8_t index)
Test whether a field is set.
ecs_iter_set_var
void ecs_iter_set_var(ecs_iter_t *it, int32_t var_id, ecs_entity_t entity)
Set the value for an iterator variable.
ecs_field_is_self
bool ecs_field_is_self(const ecs_iter_t *it, int8_t index)
Test whether the field is matched on self.
ecs_iter_next
bool ecs_iter_next(ecs_iter_t *it)
Progress any iterator.
ecs_iter_get_var
ecs_entity_t ecs_iter_get_var(ecs_iter_t *it, int32_t var_id)
Get the value of an iterator variable as an entity.
ecs_worker_next
bool ecs_worker_next(ecs_iter_t *it)
Progress a worker iterator.
ecs_iter_first
ecs_entity_t ecs_iter_first(ecs_iter_t *it)
Get the first matching entity from an iterator.
ecs_field_column
int32_t ecs_field_column(const ecs_iter_t *it, int8_t index)
Return the index of a matched table column.
ecs_iter_get_group
uint64_t ecs_iter_get_group(const ecs_iter_t *it)
Return the group ID for the currently iterated result.
ecs_iter_set_var_as_table
void ecs_iter_set_var_as_table(ecs_iter_t *it, int32_t var_id, const ecs_table_t *table)
Same as ecs_iter_set_var(), but for a table.
ecs_iter_get_var_as_table
ecs_table_t * ecs_iter_get_var_as_table(ecs_iter_t *it, int32_t var_id)
Get the value of an iterator variable as a table.
ecs_field_w_size
void * ecs_field_w_size(const ecs_iter_t *it, size_t size, int8_t index)
Get data for a field.
ecs_iter_count
int32_t ecs_iter_count(ecs_iter_t *it)
Count the number of matched entities in a query.
ecs_page_next
bool ecs_page_next(ecs_iter_t *it)
Progress a paged iterator.
ecs_iter_set_var_as_range
void ecs_iter_set_var_as_range(ecs_iter_t *it, int32_t var_id, const ecs_table_range_t *range)
Same as ecs_iter_set_var(), but for a range of entities.
ecs_field_size
size_t ecs_field_size(const ecs_iter_t *it, int8_t index)
Return the field type size.
ecs_iter_get_var_as_range
ecs_table_range_t ecs_iter_get_var_as_range(ecs_iter_t *it, int32_t var_id)
Get the value of an iterator variable as a table range.
ecs_strip_generation
ecs_id_t ecs_strip_generation(ecs_entity_t e)
Remove the generation from an entity ID.
ecs_make_alive_id
void ecs_make_alive_id(ecs_world_t *world, ecs_id_t component)
Same as ecs_make_alive(), but for components.
ecs_is_valid
bool ecs_is_valid(const ecs_world_t *world, ecs_entity_t e)
Test whether an entity is valid.
ecs_make_alive
void ecs_make_alive(ecs_world_t *world, ecs_entity_t entity)
Ensure an ID is alive.
ecs_get_alive
ecs_entity_t ecs_get_alive(const ecs_world_t *world, ecs_entity_t e)
Get an alive identifier.
ecs_get_version
uint32_t ecs_get_version(ecs_entity_t entity)
Get the generation of an entity.
ecs_exists
bool ecs_exists(const ecs_world_t *world, ecs_entity_t entity)
Test whether an entity exists.
ecs_is_alive
bool ecs_is_alive(const ecs_world_t *world, ecs_entity_t e)
Test whether an entity is alive.
ecs_set_version
void ecs_set_version(ecs_world_t *world, ecs_entity_t entity)
Override the generation of an entity.
ecs_emit
void ecs_emit(ecs_world_t *world, ecs_event_desc_t *desc)
Send an event.
ecs_enqueue
void ecs_enqueue(ecs_world_t *world, ecs_event_desc_t *desc)
Enqueue an event.
ecs_observer_init
ecs_entity_t ecs_observer_init(ecs_world_t *world, const ecs_observer_desc_t *desc)
Create an observer.
ecs_observer_get
const ecs_observer_t * ecs_observer_get(const ecs_world_t *world, ecs_entity_t observer)
Get the observer object.
FLECS_EVENT_DESC_MAX
#define FLECS_EVENT_DESC_MAX
Maximum number of events in ecs_observer_desc_t.
Definition flecs.h:316
ecs_ftime_t
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:59
FLECS_ID_DESC_MAX
#define FLECS_ID_DESC_MAX
Maximum number of IDs to add in ecs_entity_desc_t / ecs_bulk_desc_t.
Definition flecs.h:310
FLECS_TERM_COUNT_MAX
#define FLECS_TERM_COUNT_MAX
Maximum number of terms in queries.
Definition flecs.h:326
FLECS_TREE_SPAWNER_DEPTH_CACHE_SIZE
#define FLECS_TREE_SPAWNER_DEPTH_CACHE_SIZE
Size of the depth cache in the tree spawner component.
Definition flecs.h:359
ecs_get_path_w_sep
char * ecs_get_path_w_sep(const ecs_world_t *world, ecs_entity_t parent, ecs_entity_t child, const char *sep, const char *prefix)
Get a path identifier for an entity.
ecs_new_from_path_w_sep
ecs_entity_t ecs_new_from_path_w_sep(ecs_world_t *world, ecs_entity_t parent, const char *path, const char *sep, const char *prefix)
Find or create an entity from a path.
ecs_lookup_symbol
ecs_entity_t ecs_lookup_symbol(const ecs_world_t *world, const char *symbol, bool lookup_as_path, bool recursive)
Look up an entity by its symbol name.
ecs_set_alias
void ecs_set_alias(ecs_world_t *world, ecs_entity_t entity, const char *alias)
Set an alias for an entity.
ecs_lookup
ecs_entity_t ecs_lookup(const ecs_world_t *world, const char *path)
Look up an entity by its path.
ecs_get_scope
ecs_entity_t ecs_get_scope(const ecs_world_t *world)
Get the current scope.
ecs_get_path_w_sep_buf
void ecs_get_path_w_sep_buf(const ecs_world_t *world, ecs_entity_t parent, ecs_entity_t child, const char *sep, const char *prefix, ecs_strbuf_t *buf, bool escape)
Write a path identifier to a buffer.
ecs_set_lookup_path
ecs_entity_t * ecs_set_lookup_path(ecs_world_t *world, const ecs_entity_t *lookup_path)
Set the search path for lookup operations.
ecs_set_name
ecs_entity_t ecs_set_name(ecs_world_t *world, ecs_entity_t entity, const char *name)
Set the name of an entity.
ecs_get_symbol
const char * ecs_get_symbol(const ecs_world_t *world, ecs_entity_t entity)
Get the symbol of an entity.
ecs_lookup_path_w_sep
ecs_entity_t ecs_lookup_path_w_sep(const ecs_world_t *world, ecs_entity_t parent, const char *path, const char *sep, const char *prefix, bool recursive)
Look up an entity from a path.
ecs_set_symbol
ecs_entity_t ecs_set_symbol(ecs_world_t *world, ecs_entity_t entity, const char *symbol)
Set the symbol of an entity.
ecs_lookup_child
ecs_entity_t ecs_lookup_child(const ecs_world_t *world, ecs_entity_t parent, const char *name)
Look up a child entity by name.
ecs_get_name
const char * ecs_get_name(const ecs_world_t *world, ecs_entity_t entity)
Get the name of an entity.
ecs_add_path_w_sep
ecs_entity_t ecs_add_path_w_sep(ecs_world_t *world, ecs_entity_t entity, ecs_entity_t parent, const char *path, const char *sep, const char *prefix)
Add a specified path to an entity.
ecs_get_lookup_path
ecs_entity_t * ecs_get_lookup_path(const ecs_world_t *world)
Get the current lookup path.
ecs_set_scope
ecs_entity_t ecs_set_scope(ecs_world_t *world, ecs_entity_t scope)
Set the current scope.
ecs_set_name_prefix
const char * ecs_set_name_prefix(ecs_world_t *world, const char *prefix)
Set a name prefix for newly created entities.
ecs_iter_skip
void ecs_iter_skip(ecs_iter_t *it)
Skip a table while iterating.
ecs_query_has_table
bool ecs_query_has_table(const ecs_query_t *query, ecs_table_t *table, ecs_iter_t *it)
Match a table with a query.
ecs_iter_set_group
void ecs_iter_set_group(ecs_iter_t *it, uint64_t group_id)
Set the group to iterate for a query iterator.
ecs_query_get
const ecs_query_t * ecs_query_get(const ecs_world_t *world, ecs_entity_t query)
Get the query object.
ecs_query_next
bool ecs_query_next(ecs_iter_t *it)
Progress a query iterator.
ecs_query_get_group_info
const ecs_query_group_info_t * ecs_query_get_group_info(const ecs_query_t *query, uint64_t group_id)
Get information about a query group.
ecs_query_is_true
bool ecs_query_is_true(const ecs_query_t *query)
Test whether a query returns one or more results.
ecs_term_str
char * ecs_term_str(const ecs_world_t *world, const ecs_term_t *term)
Convert a term to a string expression.
ecs_query_has_range
bool ecs_query_has_range(const ecs_query_t *query, ecs_table_range_t *range, ecs_iter_t *it)
Match a range with a query.
ecs_query_find_var
int32_t ecs_query_find_var(const ecs_query_t *query, const char *name)
Find a variable index.
ecs_query_fini
void ecs_query_fini(ecs_query_t *query)
Delete a query.
ecs_query_has
bool ecs_query_has(const ecs_query_t *query, ecs_entity_t entity, ecs_iter_t *it)
Match an entity with a query.
ecs_query_plan_w_profile
char * ecs_query_plan_w_profile(const ecs_query_t *query, const ecs_iter_t *it)
Convert a query to a string with a profile.
ecs_query_args_parse
const char * ecs_query_args_parse(ecs_query_t *query, ecs_iter_t *it, const char *expr)
Populate variables from a key-value string.
ecs_query_match_count
int32_t ecs_query_match_count(const ecs_query_t *query)
Return how often a match event happened for a cached query.
ecs_query_plan
char * ecs_query_plan(const ecs_query_t *query)
Convert a query to a string.
ecs_query_iter
ecs_iter_t ecs_query_iter(const ecs_world_t *world, const ecs_query_t *query)
Create a query iterator.
ecs_query_str
char * ecs_query_str(const ecs_query_t *query)
Convert a query to a string expression.
ecs_query_var_is_entity
bool ecs_query_var_is_entity(const ecs_query_t *query, int32_t var_id)
Test if a variable is an entity.
ecs_query_init
ecs_query_t * ecs_query_init(ecs_world_t *world, const ecs_query_desc_t *desc)
Create a query.
ecs_query_changed
bool ecs_query_changed(ecs_query_t *query)
Return whether the query data changed since the last iteration.
ecs_query_var_name
const char * ecs_query_var_name(const ecs_query_t *query, int32_t var_id)
Get the variable name.
ecs_term_match_this
bool ecs_term_match_this(const ecs_term_t *term)
Is a term matched on the $this variable.
ecs_query_plans
char * ecs_query_plans(const ecs_query_t *query)
Same as ecs_query_plan(), but includes the plan for populating the cache (if any).
ecs_query_get_group_ctx
void * ecs_query_get_group_ctx(const ecs_query_t *query, uint64_t group_id)
Get the context of a query group.
ecs_query_count
ecs_query_count_t ecs_query_count(const ecs_query_t *query)
Return the number of entities and results the query matches with.
ecs_query_get_groups
const ecs_map_t * ecs_query_get_groups(const ecs_query_t *query)
Return the map with query groups.
ecs_term_is_initialized
bool ecs_term_is_initialized(const ecs_term_t *term)
Test whether a term is set.
ecs_term_ref_is_set
bool ecs_term_ref_is_set(const ecs_term_ref_t *ref)
Test whether a term ref is set.
ecs_term_match_0
bool ecs_term_match_0(const ecs_term_t *term)
Is a term matched on a 0 source.
ecs_query_get_cache_query
const ecs_query_t * ecs_query_get_cache_query(const ecs_query_t *query)
Get the query used to populate the cache.
ecs_query_cache_kind_t
ecs_query_cache_kind_t
Specify cache policy for query.
Definition flecs.h:725
ecs_inout_kind_t
ecs_inout_kind_t
Specify read/write access for term.
Definition flecs.h:704
ecs_oper_kind_t
ecs_oper_kind_t
Specify operator for term.
Definition flecs.h:714
EcsQueryCacheAll
@ EcsQueryCacheAll
Require that all query terms can be cached.
Definition flecs.h:728
EcsQueryCacheDefault
@ EcsQueryCacheDefault
Behavior determined by query creation context.
Definition flecs.h:726
EcsQueryCacheNone
@ EcsQueryCacheNone
No caching.
Definition flecs.h:729
EcsQueryCacheAuto
@ EcsQueryCacheAuto
Cache query terms that are cacheable.
Definition flecs.h:727
EcsOut
@ EcsOut
Term is only written.
Definition flecs.h:710
EcsInOut
@ EcsInOut
Term is both read and written.
Definition flecs.h:708
EcsInOutFilter
@ EcsInOutFilter
Same as InOutNone + prevents term from triggering observers.
Definition flecs.h:707
EcsInOutDefault
@ EcsInOutDefault
InOut for regular terms, In for shared terms.
Definition flecs.h:705
EcsInOutNone
@ EcsInOutNone
Term is neither read nor written.
Definition flecs.h:706
EcsIn
@ EcsIn
Term is only read.
Definition flecs.h:709
EcsNot
@ EcsNot
The term must not match.
Definition flecs.h:717
EcsOptional
@ EcsOptional
The term may match.
Definition flecs.h:718
EcsOr
@ EcsOr
One of the terms in an or chain must match.
Definition flecs.h:716
EcsOrFrom
@ EcsOrFrom
Term must match at least one component from term ID.
Definition flecs.h:720
EcsAnd
@ EcsAnd
The term must match.
Definition flecs.h:715
EcsNotFrom
@ EcsNotFrom
Term must match none of the components from term ID.
Definition flecs.h:721
EcsAndFrom
@ EcsAndFrom
Term must match all components from term ID.
Definition flecs.h:719
ecs_table_add_id
ecs_table_t * ecs_table_add_id(ecs_world_t *world, ecs_table_t *table, ecs_id_t component)
Get the table that has all components of the current table plus the specified ID.
ecs_search_offset
int32_t ecs_search_offset(const ecs_world_t *world, const ecs_table_t *table, int32_t offset, ecs_id_t component, ecs_id_t *component_out)
Search for a component in a table type starting from an offset.
ecs_table_remove_id
ecs_table_t * ecs_table_remove_id(ecs_world_t *world, ecs_table_t *table, ecs_id_t component)
Get the table that has all components of the current table minus the specified component.
ecs_table_get_type
const ecs_type_t * ecs_table_get_type(const ecs_table_t *table)
Get the type for a table.
ecs_table_get_column_index
int32_t ecs_table_get_column_index(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component)
Get the column index for a component.
ecs_search_relation_for_entity
int32_t ecs_search_relation_for_entity(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, ecs_entity_t rel, bool self, ecs_component_record_t *cr, ecs_entity_t *tgt_out, ecs_id_t *id_out, struct ecs_table_record_t **tr_out)
Search for a component ID by following a relationship, starting from an entity.
ecs_table_get_id
void * ecs_table_get_id(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component, int32_t offset)
Get a column from a table by component.
ecs_table_size
int32_t ecs_table_size(const ecs_table_t *table)
Return the allocated size of the table.
ecs_table_has_flags
bool ecs_table_has_flags(ecs_table_t *table, ecs_flags32_t flags)
Test a table for flags.
ecs_table_column_to_type_index
int32_t ecs_table_column_to_type_index(const ecs_table_t *table, int32_t index)
Convert a column index to a type index.
ecs_table_column_count
int32_t ecs_table_column_count(const ecs_table_t *table)
Return the number of columns in a table.
ecs_commit
bool ecs_commit(ecs_world_t *world, ecs_entity_t entity, ecs_record_t *record, ecs_table_t *table, const ecs_type_t *added, const ecs_type_t *removed)
Commit (move) an entity to a table.
ecs_search_relation
int32_t ecs_search_relation(const ecs_world_t *world, const ecs_table_t *table, int32_t offset, ecs_id_t component, ecs_entity_t rel, ecs_flags64_t flags, ecs_entity_t *tgt_out, ecs_id_t *component_out, struct ecs_table_record_t **tr_out)
Search for a component or relationship ID in a table type starting from an offset.
ecs_table_get_column
void * ecs_table_get_column(const ecs_table_t *table, int32_t index, int32_t offset)
Get a column from a table by column index.
ecs_search
int32_t ecs_search(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component, ecs_id_t *component_out)
Search for a component in a table type.
ecs_table_get_target
ecs_entity_t ecs_table_get_target(const ecs_world_t *world, const ecs_table_t *table, ecs_entity_t relationship, int32_t index)
Get the relationship target for a table.
ecs_table_count
int32_t ecs_table_count(const ecs_table_t *table)
Return the number of entities in the table.
ecs_table_entities
const ecs_entity_t * ecs_table_entities(const ecs_table_t *table)
Return the array with entity IDs for the table.
ecs_table_unlock
void ecs_table_unlock(ecs_world_t *world, ecs_table_t *table)
Unlock a table.
ecs_table_has_traversable
bool ecs_table_has_traversable(const ecs_table_t *table)
Check if a table has traversable entities.
ecs_table_get_depth
int32_t ecs_table_get_depth(const ecs_world_t *world, const ecs_table_t *table, ecs_entity_t rel)
Return the depth for a table in the tree for the specified relationship.
ecs_table_has_id
bool ecs_table_has_id(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component)
Test if a table has a component.
ecs_table_swap_rows
void ecs_table_swap_rows(ecs_world_t *world, ecs_table_t *table, int32_t row_1, int32_t row_2)
Swap two elements inside the table.
ecs_table_lock
void ecs_table_lock(ecs_world_t *world, ecs_table_t *table)
Lock a table.
ecs_table_find
ecs_table_t * ecs_table_find(ecs_world_t *world, const ecs_id_t *ids, int32_t id_count)
Find a table from an ID array.
ecs_table_get_column_size
size_t ecs_table_get_column_size(const ecs_table_t *table, int32_t index)
Get the column size from a table.
ecs_table_get_type_index
int32_t ecs_table_get_type_index(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component)
Get the type index for a component.
ecs_table_clear_entities
void ecs_table_clear_entities(ecs_world_t *world, ecs_table_t *table)
Remove all entities in a table.
ecs_table_type_to_column_index
int32_t ecs_table_type_to_column_index(const ecs_table_t *table, int32_t index)
Convert a type index to a column index.
ecs_value_fini_w_type_info
int ecs_value_fini_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *ptr)
Destruct a value.
ecs_value_fini
int ecs_value_fini(const ecs_world_t *world, ecs_entity_t type, void *ptr)
Destruct a value.
ecs_value_copy
int ecs_value_copy(const ecs_world_t *world, ecs_entity_t type, void *dst, const void *src)
Copy a value.
ecs_value_move
int ecs_value_move(const ecs_world_t *world, ecs_entity_t type, void *dst, void *src)
Move a value.
ecs_value_move_w_type_info
int ecs_value_move_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *dst, void *src)
Move a value.
ecs_value_new_w_type_info
void * ecs_value_new_w_type_info(ecs_world_t *world, const ecs_type_info_t *ti)
Construct a value in new storage.
ecs_value_move_ctor_w_type_info
int ecs_value_move_ctor_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *dst, void *src)
Move-construct a value.
ecs_value_copy_w_type_info
int ecs_value_copy_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *dst, const void *src)
Copy a value.
ecs_value_init_w_type_info
int ecs_value_init_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *ptr)
Construct a value in existing storage.
ecs_value_new
void * ecs_value_new(ecs_world_t *world, ecs_entity_t type)
Construct a value in new storage.
ecs_value_free
int ecs_value_free(ecs_world_t *world, ecs_entity_t type, void *ptr)
Destruct a value and free storage.
ecs_value_move_ctor
int ecs_value_move_ctor(const ecs_world_t *world, ecs_entity_t type, void *dst, void *src)
Move-construct a value.
ecs_value_init
int ecs_value_init(const ecs_world_t *world, ecs_entity_t type, void *ptr)
Construct a value in existing storage.
ecs_atfini
void ecs_atfini(ecs_world_t *world, ecs_fini_action_t action, void *ctx)
Register an action to be executed when the world is destroyed.
ecs_is_fini
bool ecs_is_fini(const ecs_world_t *world)
Return whether the world is being deleted.
ecs_fini
int ecs_fini(ecs_world_t *world)
Delete a world.
ecs_world_get_flags
ecs_flags32_t ecs_world_get_flags(const ecs_world_t *world)
Get flags set on the world.
ecs_mini
ecs_world_t * ecs_mini(void)
Create a new world with just the core module.
ecs_init
ecs_world_t * ecs_init(void)
Create a new world.
ecs_init_w_args
ecs_world_t * ecs_init_w_args(int argc, char *argv[])
Create a new world with arguments.
ecs_get_entities
ecs_entities_t ecs_get_entities(const ecs_world_t *world)
Return entity identifiers in the world.
ecs_set_target_fps
void ecs_set_target_fps(ecs_world_t *world, float fps)
Set target frames per second (FPS) for an application.
ecs_measure_system_time
void ecs_measure_system_time(ecs_world_t *world, bool enable)
Measure system time.
ecs_frame_begin
float ecs_frame_begin(ecs_world_t *world, float delta_time)
Begin frame.
ecs_run_post_frame
void ecs_run_post_frame(ecs_world_t *world, ecs_fini_action_t action, void *ctx)
Register an action to be executed once after the frame.
ecs_should_quit
bool ecs_should_quit(const ecs_world_t *world)
Return whether a quit has been requested.
ecs_set_default_query_flags
void ecs_set_default_query_flags(ecs_world_t *world, ecs_flags32_t flags)
Set the default query flags.
ecs_quit
void ecs_quit(ecs_world_t *world)
Signal exit.
ecs_measure_frame_time
void ecs_measure_frame_time(ecs_world_t *world, bool enable)
Measure frame time.
ecs_frame_end
void ecs_frame_end(ecs_world_t *world)
End frame.
ecs_get_entity
ecs_entity_t ecs_get_entity(const ecs_poly_t *poly)
Get the entity from a poly.
ecs_make_pair
ecs_id_t ecs_make_pair(ecs_entity_t first, ecs_entity_t second)
Make a pair ID.
ecs_get_build_info
const ecs_build_info_t * ecs_get_build_info(void)
Get build info.
flecs_poly_is_
bool flecs_poly_is_(const ecs_poly_t *object, int32_t type)
Test if a pointer is of the specified type.
ecs_get_max_id
ecs_entity_t ecs_get_max_id(const ecs_world_t *world)
Get the largest issued entity ID (not counting generation).
ecs_run_aperiodic
void ecs_run_aperiodic(ecs_world_t *world, ecs_flags32_t flags)
Force aperiodic actions.
ecs_get_binding_ctx
void * ecs_get_binding_ctx(const ecs_world_t *world)
Get the world binding context.
ecs_shrink
void ecs_shrink(ecs_world_t *world)
Free unused memory.
ecs_dim
void ecs_dim(ecs_world_t *world, int32_t entity_count)
Dimension the world for a specified number of entities.
ecs_set_entity_range
void ecs_set_entity_range(ecs_world_t *world, ecs_entity_t id_start, ecs_entity_t id_end)
Set a range for issuing new entity IDs.
ecs_get_world_info
const ecs_world_info_t * ecs_get_world_info(const ecs_world_t *world)
Get the world info.
ecs_get_world
const ecs_world_t * ecs_get_world(const ecs_poly_t *poly)
Get the world from a poly.
ecs_set_ctx
void ecs_set_ctx(ecs_world_t *world, void *ctx, ecs_ctx_free_t ctx_free)
Set a world context.
ecs_exclusive_access_begin
void ecs_exclusive_access_begin(ecs_world_t *world, const char *thread_name)
Begin exclusive thread access.
ecs_delete_empty_tables
int32_t ecs_delete_empty_tables(ecs_world_t *world, const ecs_delete_empty_tables_desc_t *desc)
Clean up empty tables.
ecs_set_binding_ctx
void ecs_set_binding_ctx(ecs_world_t *world, void *ctx, ecs_ctx_free_t ctx_free)
Set a world binding context.
ecs_enable_range_check
bool ecs_enable_range_check(ecs_world_t *world, bool enable)
Enable or disable range limits.
ecs_exclusive_access_end
void ecs_exclusive_access_end(ecs_world_t *world, bool lock_world)
End exclusive thread access.
ecs_get_ctx
void * ecs_get_ctx(const ecs_world_t *world)
Get the world context.
os_api.h
Operating system abstraction API.
EcsComponent
Component information.
Definition flecs.h:1566
EcsComponent::size
ecs_size_t size
Component size.
Definition flecs.h:1567
EcsComponent::alignment
ecs_size_t alignment
Component alignment.
Definition flecs.h:1568
EcsDefaultChildComponent
When added to an entity, this informs serialization formats which component to use when a value is as...
Definition flecs.h:1581
EcsDefaultChildComponent::component
ecs_id_t component
Default component ID.
Definition flecs.h:1582
EcsIdentifier
A (string) identifier.
Definition flecs.h:1557
EcsIdentifier::length
ecs_size_t length
Length of identifier.
Definition flecs.h:1559
EcsIdentifier::value
char * value
Identifier string.
Definition flecs.h:1558
EcsIdentifier::index
ecs_hashmap_t * index
Current index.
Definition flecs.h:1562
EcsIdentifier::hash
uint64_t hash
Hash of current value.
Definition flecs.h:1560
EcsIdentifier::index_hash
uint64_t index_hash
Hash of existing record in current index.
Definition flecs.h:1561
EcsParent
Non-fragmenting ChildOf relationship.
Definition flecs.h:1586
EcsParent::value
ecs_entity_t value
Parent entity.
Definition flecs.h:1587
EcsPoly
Component for storing a poly object.
Definition flecs.h:1572
EcsPoly::poly
ecs_poly_t * poly
Pointer to poly object.
Definition flecs.h:1573
EcsRateFilter
Apply a rate filter to a tick source.
Definition timer.h:45
EcsTickSource
Component used to provide a tick source to systems.
Definition system.h:32
EcsTimer
Component used for one-shot and interval timer functionality.
Definition timer.h:35
EcsTreeSpawner
Tree instantiation cache component.
Definition flecs.h:1610
EcsTreeSpawner::data
ecs_tree_spawner_t data[(6)]
Cache data indexed by depth.
Definition flecs.h:1611
ecs_build_info_t
Type with information about the current Flecs build.
Definition flecs.h:1464
ecs_build_info_t::flags
const char ** flags
Compile-time settings.
Definition flecs.h:1467
ecs_build_info_t::version_major
int16_t version_major
Major Flecs version.
Definition flecs.h:1469
ecs_build_info_t::addons
const char ** addons
Addons included in the build.
Definition flecs.h:1466
ecs_build_info_t::version
const char * version
Stringified version.
Definition flecs.h:1468
ecs_build_info_t::compiler
const char * compiler
Compiler used to compile Flecs.
Definition flecs.h:1465
ecs_build_info_t::sanitize
bool sanitize
Is this a sanitize build?
Definition flecs.h:1473
ecs_build_info_t::perf_trace
bool perf_trace
Is this a perf tracing build?
Definition flecs.h:1474
ecs_build_info_t::version_minor
int16_t version_minor
Minor Flecs version.
Definition flecs.h:1470
ecs_build_info_t::debug
bool debug
Is this a debug build?
Definition flecs.h:1472
ecs_build_info_t::version_patch
int16_t version_patch
Patch Flecs version.
Definition flecs.h:1471
ecs_bulk_desc_t
Used with ecs_bulk_init().
Definition flecs.h:1088
ecs_bulk_desc_t::ids
ecs_id_t ids[32]
IDs to create the entities with.
Definition flecs.h:1098
ecs_bulk_desc_t::data
void ** data
Array with component data to insert.
Definition flecs.h:1100
ecs_bulk_desc_t::count
int32_t count
Number of entities to create/populate.
Definition flecs.h:1096
ecs_bulk_desc_t::_canary
int32_t _canary
Used for validity testing.
Definition flecs.h:1089
ecs_bulk_desc_t::entities
ecs_entity_t * entities
Entities to bulk insert.
Definition flecs.h:1091
ecs_bulk_desc_t::table
ecs_table_t * table
Table to insert the entities into.
Definition flecs.h:1107
ecs_component_desc_t
Used with ecs_component_init().
Definition flecs.h:1118
ecs_component_desc_t::_canary
int32_t _canary
Used for validity testing.
Definition flecs.h:1119
ecs_component_desc_t::type
ecs_type_info_t type
Parameters for type (size, hooks, ...).
Definition flecs.h:1125
ecs_component_desc_t::entity
ecs_entity_t entity
Existing entity to associate with a component (optional).
Definition flecs.h:1122
ecs_delete_empty_tables_desc_t
Used with ecs_delete_empty_tables().
Definition flecs.h:2730
ecs_delete_empty_tables_desc_t::delete_generation
uint16_t delete_generation
Delete table when generation > delete_generation.
Definition flecs.h:2735
ecs_delete_empty_tables_desc_t::time_budget_seconds
double time_budget_seconds
Amount of time operation is allowed to spend.
Definition flecs.h:2738
ecs_delete_empty_tables_desc_t::clear_generation
uint16_t clear_generation
Free table data when generation > clear_generation.
Definition flecs.h:2732
ecs_entities_t
Type returned by ecs_get_entities().
Definition flecs.h:2084
ecs_entities_t::alive_count
int32_t alive_count
Number of alive entity IDs.
Definition flecs.h:2087
ecs_entities_t::count
int32_t count
Total number of entity IDs.
Definition flecs.h:2086
ecs_entities_t::ids
const ecs_entity_t * ids
Array with all entity IDs in the world.
Definition flecs.h:2085
ecs_entity_desc_t
Used with ecs_entity_init().
Definition flecs.h:1042
ecs_entity_desc_t::sep
const char * sep
Optional custom separator for hierarchical names.
Definition flecs.h:1054
ecs_entity_desc_t::root_sep
const char * root_sep
Optional, used for identifiers relative to the root.
Definition flecs.h:1058
ecs_entity_desc_t::name
const char * name
Name of the entity.
Definition flecs.h:1049
ecs_entity_desc_t::use_low_id
bool use_low_id
When set to true, a low id (typically reserved for components) will be used to create the entity,...
Definition flecs.h:1070
ecs_entity_desc_t::symbol
const char * symbol
Optional entity symbol.
Definition flecs.h:1060
ecs_entity_desc_t::_canary
int32_t _canary
Used for validity testing.
Definition flecs.h:1043
ecs_entity_desc_t::add
const ecs_id_t * add
0-terminated array of IDs to add to the entity.
Definition flecs.h:1075
ecs_entity_desc_t::add_expr
const char * add_expr
String expression with components to add.
Definition flecs.h:1081
ecs_entity_desc_t::set
const ecs_value_t * set
0-terminated array of values to set on the entity.
Definition flecs.h:1078
ecs_entity_desc_t::id
ecs_entity_t id
Set to modify existing entity (optional).
Definition flecs.h:1045
ecs_entity_desc_t::parent
ecs_entity_t parent
Parent entity.
Definition flecs.h:1047
ecs_event_desc_t
Used with ecs_emit().
Definition flecs.h:1410
ecs_event_desc_t::entity
ecs_entity_t entity
Single-entity alternative to setting table / offset / count.
Definition flecs.h:1435
ecs_event_desc_t::const_param
const void * const_param
Same as param, but with the guarantee that the value won't be modified.
Definition flecs.h:1446
ecs_event_desc_t::table
ecs_table_t * table
The table for which to notify.
Definition flecs.h:1420
ecs_event_desc_t::count
int32_t count
Limit number of notified entities to count.
Definition flecs.h:1432
ecs_event_desc_t::other_table
ecs_table_t * other_table
Optional second table to notify.
Definition flecs.h:1424
ecs_event_desc_t::offset
int32_t offset
Limit notified entities to ones starting from offset (row) in table.
Definition flecs.h:1427
ecs_event_desc_t::ids
const ecs_type_t * ids
Component IDs.
Definition flecs.h:1417
ecs_event_desc_t::observable
ecs_poly_t * observable
Observable (usually the world).
Definition flecs.h:1449
ecs_event_desc_t::event
ecs_entity_t event
The event ID.
Definition flecs.h:1412
ecs_event_desc_t::flags
ecs_flags32_t flags
Event flags.
Definition flecs.h:1452
ecs_event_desc_t::param
void * param
Optional context.
Definition flecs.h:1441
ecs_header_t
Header for ecs_poly_t objects.
Definition flecs.h:520
ecs_header_t::type
int32_t type
Magic number indicating which type of Flecs object.
Definition flecs.h:521
ecs_header_t::refcount
int32_t refcount
Refcount, to enable RAII handles.
Definition flecs.h:522
ecs_header_t::mixins
ecs_mixins_t * mixins
Table with offsets to (optional) mixins.
Definition flecs.h:523
ecs_iter_t
Iterator.
Definition flecs.h:1166
ecs_iter_t::real_world
ecs_world_t * real_world
Actual world.
Definition flecs.h:1169
ecs_iter_t::param
void * param
Param passed to ecs_run().
Definition flecs.h:1202
ecs_iter_t::event
ecs_entity_t event
The event (if applicable).
Definition flecs.h:1190
ecs_iter_t::frame_offset
int32_t frame_offset
Offset relative to the start of iteration.
Definition flecs.h:1213
ecs_iter_t::ref_fields
ecs_flags32_t ref_fields
Bitset with fields that aren't component arrays.
Definition flecs.h:1184
ecs_iter_t::interrupted_by
ecs_entity_t interrupted_by
When set, system execution is interrupted.
Definition flecs.h:1217
ecs_iter_t::flags
ecs_flags32_t flags
Iterator flags.
Definition flecs.h:1216
ecs_iter_t::chain_it
ecs_iter_t * chain_it
Optional, allows for creating iterator chains.
Definition flecs.h:1224
ecs_iter_t::ctx
void * ctx
System context.
Definition flecs.h:1203
ecs_iter_t::run_ctx
void * run_ctx
Run language binding context.
Definition flecs.h:1206
ecs_iter_t::table
ecs_table_t * table
Current table.
Definition flecs.h:1178
ecs_iter_t::offset
int32_t offset
Offset relative to the current table.
Definition flecs.h:1172
ecs_iter_t::event_id
ecs_id_t event_id
The (component) ID for the event.
Definition flecs.h:1191
ecs_iter_t::fini
ecs_iter_fini_action_t fini
Function to clean up iterator resources.
Definition flecs.h:1223
ecs_iter_t::priv_
ecs_iter_private_t priv_
Private data.
Definition flecs.h:1218
ecs_iter_t::world
ecs_world_t * world
The world.
Definition flecs.h:1168
ecs_iter_t::callback_ctx
void * callback_ctx
Callback language binding context.
Definition flecs.h:1205
ecs_iter_t::sources
ecs_entity_t * sources
Entity on which the ID was matched (0 if same as entities).
Definition flecs.h:1181
ecs_iter_t::binding_ctx
void * binding_ctx
System binding context.
Definition flecs.h:1204
ecs_iter_t::row_fields
ecs_flags32_t row_fields
Fields that must be obtained with field_at.
Definition flecs.h:1185
ecs_iter_t::delta_system_time
float delta_system_time
Time elapsed since last system invocation.
Definition flecs.h:1210
ecs_iter_t::query
const ecs_query_t * query
Query being evaluated.
Definition flecs.h:1199
ecs_iter_t::term_index
int8_t term_index
Index of the term that emitted an event.
Definition flecs.h:1196
ecs_iter_t::system
ecs_entity_t system
The system (if applicable).
Definition flecs.h:1189
ecs_iter_t::set_fields
ecs_flags32_t set_fields
Fields that are set.
Definition flecs.h:1183
ecs_iter_t::sizes
const ecs_size_t * sizes
Component sizes.
Definition flecs.h:1177
ecs_iter_t::delta_time
float delta_time
Time elapsed since last frame.
Definition flecs.h:1209
ecs_iter_t::up_fields
ecs_flags32_t up_fields
Bitset with fields matched through up traversal.
Definition flecs.h:1186
ecs_iter_t::callback
ecs_iter_action_t callback
Callback of system or observer.
Definition flecs.h:1222
ecs_iter_t::field_count
int8_t field_count
Number of fields in the iterator.
Definition flecs.h:1195
ecs_iter_t::other_table
ecs_table_t * other_table
Previous or next table when adding or removing.
Definition flecs.h:1179
ecs_iter_t::event_cur
int32_t event_cur
Unique event ID.
Definition flecs.h:1192
ecs_iter_t::trs
const ecs_table_record_t ** trs
Info on where to find the field in the table.
Definition flecs.h:1176
ecs_iter_t::count
int32_t count
Number of entities to iterate.
Definition flecs.h:1173
ecs_iter_t::ptrs
void ** ptrs
Component pointers.
Definition flecs.h:1175
ecs_iter_t::next
ecs_iter_next_action_t next
Function to progress iterator.
Definition flecs.h:1221
ecs_iter_t::entities
const ecs_entity_t * entities
Entity identifiers.
Definition flecs.h:1174
ecs_iter_t::ids
ecs_id_t * ids
(Component) IDs.
Definition flecs.h:1180
ecs_iter_t::constrained_vars
ecs_flags64_t constrained_vars
Bitset that marks constrained variables.
Definition flecs.h:1182
ecs_observer_desc_t
Used with ecs_observer_init().
Definition flecs.h:1349
ecs_observer_desc_t::run_ctx_free
ecs_ctx_free_t run_ctx_free
Callback to free run ctx.
Definition flecs.h:1398
ecs_observer_desc_t::ctx_free
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1386
ecs_observer_desc_t::run_ctx
void * run_ctx
Context associated with run (for language bindings).
Definition flecs.h:1395
ecs_observer_desc_t::entity
ecs_entity_t entity
Existing entity to associate with an observer (optional).
Definition flecs.h:1354
ecs_observer_desc_t::last_event_id
int32_t * last_event_id
Used for internal purposes.
Definition flecs.h:1401
ecs_observer_desc_t::callback_ctx
void * callback_ctx
Context associated with callback (for language bindings).
Definition flecs.h:1389
ecs_observer_desc_t::ctx
void * ctx
User context to pass to callback.
Definition flecs.h:1383
ecs_observer_desc_t::query
ecs_query_desc_t query
Query for observer.
Definition flecs.h:1357
ecs_observer_desc_t::flags_
ecs_flags32_t flags_
Used for internal purposes.
Definition flecs.h:1403
ecs_observer_desc_t::callback_ctx_free
ecs_ctx_free_t callback_ctx_free
Callback to free callback ctx.
Definition flecs.h:1392
ecs_observer_desc_t::term_index_
int8_t term_index_
Used for internal purposes.
Definition flecs.h:1402
ecs_observer_desc_t::global_observer
bool global_observer
Global observers are tied to the lifespan of the world.
Definition flecs.h:1369
ecs_observer_desc_t::callback
ecs_iter_action_t callback
Callback to invoke on an event, invoked when the observer matches.
Definition flecs.h:1372
ecs_observer_desc_t::yield_existing
bool yield_existing
When an observer is created, generate events from existing data.
Definition flecs.h:1364
ecs_observer_desc_t::run
ecs_run_action_t run
Callback invoked on an event.
Definition flecs.h:1380
ecs_observer_desc_t::events
ecs_entity_t events[8]
Events to observe (OnAdd, OnRemove, OnSet).
Definition flecs.h:1360
ecs_observer_desc_t::_canary
int32_t _canary
Used for validity testing.
Definition flecs.h:1351
ecs_observer_t
An observer reacts to events matching a query.
Definition flecs.h:875
ecs_observer_t::event_count
int32_t event_count
Number of events.
Definition flecs.h:882
ecs_observer_t::callback
ecs_iter_action_t callback
See ecs_observer_desc_t::callback.
Definition flecs.h:884
ecs_observer_t::entity
ecs_entity_t entity
Entity associated with the observer.
Definition flecs.h:898
ecs_observer_t::observable
ecs_observable_t * observable
Observable for the observer.
Definition flecs.h:895
ecs_observer_t::run
ecs_run_action_t run
See ecs_observer_desc_t::run.
Definition flecs.h:885
ecs_observer_t::hdr
ecs_header_t hdr
Object header.
Definition flecs.h:876
ecs_observer_t::ctx_free
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:891
ecs_observer_t::events
ecs_entity_t events[8]
Observer events.
Definition flecs.h:881
ecs_observer_t::run_ctx
void * run_ctx
Run language binding context.
Definition flecs.h:889
ecs_observer_t::world
ecs_world_t * world
The world.
Definition flecs.h:897
ecs_observer_t::run_ctx_free
ecs_ctx_free_t run_ctx_free
Callback to free run_ctx.
Definition flecs.h:893
ecs_observer_t::callback_ctx
void * callback_ctx
Callback language binding context.
Definition flecs.h:888
ecs_observer_t::ctx
void * ctx
Observer context.
Definition flecs.h:887
ecs_observer_t::callback_ctx_free
ecs_ctx_free_t callback_ctx_free
Callback to free callback_ctx.
Definition flecs.h:892
ecs_observer_t::query
ecs_query_t * query
Observer query.
Definition flecs.h:878
ecs_query_count_t
Struct returned by ecs_query_count().
Definition flecs.h:5190
ecs_query_count_t::entities
int32_t entities
Number of entities returned by the query.
Definition flecs.h:5192
ecs_query_count_t::results
int32_t results
Number of results returned by the query.
Definition flecs.h:5191
ecs_query_count_t::tables
int32_t tables
Number of tables returned by the query.
Definition flecs.h:5193
ecs_query_desc_t
Used with ecs_query_init().
Definition flecs.h:1275
ecs_query_desc_t::ctx_free
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1336
ecs_query_desc_t::group_by
ecs_id_t group_by
Component ID to be used for grouping.
Definition flecs.h:1306
ecs_query_desc_t::terms
ecs_term_t terms[32]
Query terms.
Definition flecs.h:1280
ecs_query_desc_t::_canary
int32_t _canary
Used for validity testing.
Definition flecs.h:1277
ecs_query_desc_t::ctx
void * ctx
User context to pass to callback.
Definition flecs.h:1330
ecs_query_desc_t::group_by_ctx_free
ecs_ctx_free_t group_by_ctx_free
Function to free group_by_ctx.
Definition flecs.h:1327
ecs_query_desc_t::group_by_ctx
void * group_by_ctx
Context to pass to group_by.
Definition flecs.h:1324
ecs_query_desc_t::binding_ctx
void * binding_ctx
Context to be used for language bindings.
Definition flecs.h:1333
ecs_query_desc_t::order_by
ecs_entity_t order_by
Component to sort on, used together with order_by_callback or order_by_table_callback.
Definition flecs.h:1302
ecs_query_desc_t::order_by_callback
ecs_order_by_action_t order_by_callback
Callback used for ordering query results.
Definition flecs.h:1294
ecs_query_desc_t::on_group_create
ecs_group_create_action_t on_group_create
Callback that is invoked when a new group is created.
Definition flecs.h:1317
ecs_query_desc_t::entity
ecs_entity_t entity
Entity associated with query (optional).
Definition flecs.h:1342
ecs_query_desc_t::binding_ctx_free
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition flecs.h:1339
ecs_query_desc_t::group_by_callback
ecs_group_by_action_t group_by_callback
Callback used for grouping results.
Definition flecs.h:1313
ecs_query_desc_t::on_group_delete
ecs_group_delete_action_t on_group_delete
Callback that is invoked when an existing group is deleted.
Definition flecs.h:1321
ecs_query_desc_t::order_by_table_callback
ecs_sort_table_action_t order_by_table_callback
Callback used for ordering query results.
Definition flecs.h:1298
ecs_query_desc_t::flags
ecs_flags32_t flags
Flags for enabling query features.
Definition flecs.h:1289
ecs_query_desc_t::cache_kind
ecs_query_cache_kind_t cache_kind
Caching policy of the query.
Definition flecs.h:1286
ecs_query_desc_t::expr
const char * expr
Query DSL expression (optional).
Definition flecs.h:1283
ecs_query_group_info_t
Type that contains information about a query group.
Definition flecs.h:1540
ecs_query_group_info_t::table_count
int32_t table_count
Number of tables in group.
Definition flecs.h:1543
ecs_query_group_info_t::ctx
void * ctx
Group context, returned by on_group_create.
Definition flecs.h:1544
ecs_query_group_info_t::id
uint64_t id
Group ID.
Definition flecs.h:1541
ecs_query_group_info_t::match_count
int32_t match_count
How often tables have been matched or unmatched.
Definition flecs.h:1542
ecs_query_t
Queries are lists of constraints (terms) that match entities.
Definition flecs.h:834
ecs_query_t::row_fields
ecs_flags32_t row_fields
Fields that must be acquired with field_at.
Definition flecs.h:854
ecs_query_t::data_fields
ecs_flags32_t data_fields
Fields that have data.
Definition flecs.h:851
ecs_query_t::read_fields
ecs_flags32_t read_fields
Fields that read data.
Definition flecs.h:853
ecs_query_t::hdr
ecs_header_t hdr
Object header.
Definition flecs.h:835
ecs_query_t::var_count
int8_t var_count
Number of query variables.
Definition flecs.h:843
ecs_query_t::fixed_fields
ecs_flags32_t fixed_fields
Bitmasks for quick field information lookups.
Definition flecs.h:848
ecs_query_t::var_fields
ecs_flags32_t var_fields
Fields with non-$this variable source.
Definition flecs.h:849
ecs_query_t::write_fields
ecs_flags32_t write_fields
Fields that write data.
Definition flecs.h:852
ecs_query_t::eval_count
int32_t eval_count
Number of times the query is evaluated.
Definition flecs.h:869
ecs_query_t::world
ecs_world_t * world
World or stage the query was created with.
Definition flecs.h:867
ecs_query_t::static_id_fields
ecs_flags32_t static_id_fields
Fields with a static (component) id.
Definition flecs.h:850
ecs_query_t::bloom_filter
uint64_t bloom_filter
Bitmask used to quickly discard tables.
Definition flecs.h:841
ecs_query_t::real_world
ecs_world_t * real_world
Actual world.
Definition flecs.h:866
ecs_query_t::set_fields
ecs_flags32_t set_fields
Fields that will be set.
Definition flecs.h:856
ecs_query_t::entity
ecs_entity_t entity
Entity associated with query (optional).
Definition flecs.h:865
ecs_query_t::ctx
void * ctx
User context to pass to callback.
Definition flecs.h:862
ecs_query_t::sizes
int32_t * sizes
Component sizes.
Definition flecs.h:838
ecs_query_t::ids
ecs_id_t * ids
Component ids.
Definition flecs.h:839
ecs_query_t::shared_readonly_fields
ecs_flags32_t shared_readonly_fields
Fields that don't write shared data.
Definition flecs.h:855
ecs_query_t::terms
ecs_term_t * terms
Query terms.
Definition flecs.h:837
ecs_query_t::cache_kind
ecs_query_cache_kind_t cache_kind
Caching policy of the query.
Definition flecs.h:858
ecs_query_t::term_count
int8_t term_count
Number of query terms.
Definition flecs.h:844
ecs_query_t::vars
char ** vars
Array with variable names for the iterator.
Definition flecs.h:860
ecs_query_t::field_count
int8_t field_count
Number of fields returned by the query.
Definition flecs.h:845
ecs_query_t::flags
ecs_flags32_t flags
Query flags.
Definition flecs.h:842
ecs_query_t::binding_ctx
void * binding_ctx
Context to be used for language bindings.
Definition flecs.h:863
ecs_term_ref_t
Type that describes a reference to an entity or variable in a term.
Definition flecs.h:795
ecs_term_ref_t::name
const char * name
Name.
Definition flecs.h:802
ecs_term_ref_t::id
ecs_entity_t id
Entity ID.
Definition flecs.h:796
ecs_term_t
Type that describes a term (single element in a query).
Definition flecs.h:810
ecs_term_t::src
ecs_term_ref_t src
Source of term.
Definition flecs.h:816
ecs_term_t::field_index
int8_t field_index
Index of the field for the term in the iterator.
Definition flecs.h:827
ecs_term_t::id
ecs_id_t id
Component ID to be matched by term.
Definition flecs.h:811
ecs_term_t::oper
int16_t oper
Operator of term.
Definition flecs.h:825
ecs_term_t::second
ecs_term_ref_t second
Second element of pair.
Definition flecs.h:818
ecs_term_t::flags_
ecs_flags16_t flags_
Flags that help evaluation, set by ecs_query_init().
Definition flecs.h:828
ecs_term_t::trav
ecs_entity_t trav
Relationship to traverse when looking for the component.
Definition flecs.h:820
ecs_term_t::inout
int16_t inout
Access to contents matched by term.
Definition flecs.h:824
ecs_term_t::first
ecs_term_ref_t first
Component or first element of pair.
Definition flecs.h:817
ecs_tree_spawner_child_t
Component with data to instantiate a non-fragmenting tree.
Definition flecs.h:1591
ecs_tree_spawner_child_t::child
uint32_t child
Prefab child entity (without generation).
Definition flecs.h:1594
ecs_tree_spawner_child_t::parent_index
int32_t parent_index
Index into the children vector.
Definition flecs.h:1595
ecs_tree_spawner_child_t::child_name
const char * child_name
Name of the prefab child.
Definition flecs.h:1592
ecs_tree_spawner_child_t::table
ecs_table_t * table
Table in which the child will be stored.
Definition flecs.h:1593
ecs_tree_spawner_t
Tree spawner data for a single hierarchy depth.
Definition flecs.h:1599
ecs_tree_spawner_t::children
ecs_vec_t children
vector<ecs_tree_spawner_child_t>.
Definition flecs.h:1600
ecs_type_hooks_t
Definition flecs.h:950
ecs_type_hooks_t::copy_ctor
ecs_copy_t copy_ctor
Ctor + copy.
Definition flecs.h:957
ecs_type_hooks_t::lifecycle_ctx
void * lifecycle_ctx
Component lifecycle context (see meta addon).
Definition flecs.h:1008
ecs_type_hooks_t::ctx
void * ctx
User-defined context.
Definition flecs.h:1006
ecs_type_hooks_t::on_remove
ecs_iter_action_t on_remove
Callback that is invoked when an instance of the component is removed.
Definition flecs.h:998
ecs_type_hooks_t::binding_ctx
void * binding_ctx
Language binding context.
Definition flecs.h:1007
ecs_type_hooks_t::move_dtor
ecs_move_t move_dtor
Move + dtor.
Definition flecs.h:972
ecs_type_hooks_t::flags
ecs_flags32_t flags
Hook flags.
Definition flecs.h:984
ecs_type_hooks_t::cmp
ecs_cmp_t cmp
Compare hook.
Definition flecs.h:975
ecs_type_hooks_t::copy
ecs_copy_t copy
copy assignment.
Definition flecs.h:953
ecs_type_hooks_t::lifecycle_ctx_free
ecs_ctx_free_t lifecycle_ctx_free
Callback to free lifecycle_ctx.
Definition flecs.h:1012
ecs_type_hooks_t::on_set
ecs_iter_action_t on_set
Callback that is invoked when an instance of the component is set.
Definition flecs.h:993
ecs_type_hooks_t::move
ecs_move_t move
move assignment.
Definition flecs.h:954
ecs_type_hooks_t::ctor
ecs_xtor_t ctor
ctor.
Definition flecs.h:951
ecs_type_hooks_t::on_replace
ecs_iter_action_t on_replace
Callback that is invoked with the existing and new value before the value is assigned.
Definition flecs.h:1004
ecs_type_hooks_t::ctx_free
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1010
ecs_type_hooks_t::on_add
ecs_iter_action_t on_add
Callback that is invoked when an instance of a component is added.
Definition flecs.h:988
ecs_type_hooks_t::binding_ctx_free
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition flecs.h:1011
ecs_type_hooks_t::move_ctor
ecs_move_t move_ctor
Ctor + move.
Definition flecs.h:960
ecs_type_hooks_t::equals
ecs_equals_t equals
Equals hook.
Definition flecs.h:978
ecs_type_hooks_t::ctor_move_dtor
ecs_move_t ctor_move_dtor
Ctor + move + dtor (or move_ctor + dtor).
Definition flecs.h:966
ecs_type_hooks_t::dtor
ecs_xtor_t dtor
dtor.
Definition flecs.h:952
ecs_type_info_t
Type that contains component information (passed to ctors/dtors/...).
Definition flecs.h:1019
ecs_type_info_t::alignment
ecs_size_t alignment
Alignment of the type.
Definition flecs.h:1021
ecs_type_info_t::size
ecs_size_t size
Size of the type.
Definition flecs.h:1020
ecs_type_info_t::name
const char * name
Type name.
Definition flecs.h:1024
ecs_type_info_t::component
ecs_entity_t component
Handle to component (do not set).
Definition flecs.h:1023
ecs_type_info_t::hooks
ecs_type_hooks_t hooks
Type hooks.
Definition flecs.h:1022
ecs_type_t
A type is a list of (component) IDs.
Definition flecs.h:398
ecs_type_t::array
ecs_id_t * array
Array with IDs.
Definition flecs.h:399
ecs_type_t::count
int32_t count
Number of elements in array.
Definition flecs.h:400
ecs_value_t
Utility to hold a value of a dynamic type.
Definition flecs.h:1033
ecs_value_t::ptr
void * ptr
Pointer to value.
Definition flecs.h:1035
ecs_value_t::type
ecs_entity_t type
Type of value.
Definition flecs.h:1034
ecs_world_info_t
Type that contains information about the world.
Definition flecs.h:1478
ecs_world_info_t::observers_ran_total
int64_t observers_ran_total
Total number of times an observer was invoked.
Definition flecs.h:1506
ecs_world_info_t::delta_time
float delta_time
Time passed to or computed by ecs_progress().
Definition flecs.h:1484
ecs_world_info_t::min_id
ecs_entity_t min_id
First allowed entity ID.
Definition flecs.h:1480
ecs_world_info_t::systems_ran_total
int64_t systems_ran_total
Total number of systems run.
Definition flecs.h:1505
ecs_world_info_t::set_count
int64_t set_count
Set commands processed.
Definition flecs.h:1523
ecs_world_info_t::world_time_total
double world_time_total
Time elapsed in simulation.
Definition flecs.h:1492
ecs_world_info_t::tag_id_count
int32_t tag_id_count
Number of tag (no data) IDs in the world.
Definition flecs.h:1509
ecs_world_info_t::component_id_count
int32_t component_id_count
Number of component (data) IDs in the world.
Definition flecs.h:1510
ecs_world_info_t::pipeline_build_count_total
int64_t pipeline_build_count_total
Total number of pipeline builds.
Definition flecs.h:1504
ecs_world_info_t::eval_comp_monitors_total
int64_t eval_comp_monitors_total
Total number of monitor evaluations.
Definition flecs.h:1497
ecs_world_info_t::table_count
int32_t table_count
Number of tables.
Definition flecs.h:1513
ecs_world_info_t::delta_time_raw
float delta_time_raw
Raw delta time (no time scaling).
Definition flecs.h:1483
ecs_world_info_t::frame_time_total
float frame_time_total
Total time spent processing a frame.
Definition flecs.h:1487
ecs_world_info_t::table_create_total
int64_t table_create_total
Total number of times a table was created.
Definition flecs.h:1502
ecs_world_info_t::system_time_total
float system_time_total
Total time spent in systems.
Definition flecs.h:1488
ecs_world_info_t::id_delete_total
int64_t id_delete_total
Total number of times an ID was deleted.
Definition flecs.h:1501
ecs_world_info_t::cmd
struct ecs_world_info_t::@354013130002221015352342176135321160002353227336 cmd
Command statistics.
ecs_world_info_t::merge_time_total
float merge_time_total
Total time spent in merges.
Definition flecs.h:1490
ecs_world_info_t::discard_count
int64_t discard_count
Commands discarded, happens when the entity is no longer alive when running the command.
Definition flecs.h:1526
ecs_world_info_t::clear_count
int64_t clear_count
Clear commands processed.
Definition flecs.h:1522
ecs_world_info_t::last_component_id
ecs_entity_t last_component_id
Last issued component entity ID.
Definition flecs.h:1479
ecs_world_info_t::frame_count_total
int64_t frame_count_total
Total number of frames.
Definition flecs.h:1495
ecs_world_info_t::max_id
ecs_entity_t max_id
Last allowed entity ID.
Definition flecs.h:1481
ecs_world_info_t::merge_count_total
int64_t merge_count_total
Total number of merges.
Definition flecs.h:1496
ecs_world_info_t::other_count
int64_t other_count
Other commands processed.
Definition flecs.h:1528
ecs_world_info_t::batched_command_count
int64_t batched_command_count
Commands batched.
Definition flecs.h:1530
ecs_world_info_t::table_delete_total
int64_t table_delete_total
Total number of times a table was deleted.
Definition flecs.h:1503
ecs_world_info_t::queries_ran_total
int64_t queries_ran_total
Total number of times a query was evaluated.
Definition flecs.h:1507
ecs_world_info_t::delete_count
int64_t delete_count
Delete commands processed.
Definition flecs.h:1521
ecs_world_info_t::rematch_count_total
int64_t rematch_count_total
Total number of rematches.
Definition flecs.h:1498
ecs_world_info_t::id_create_total
int64_t id_create_total
Total number of times a new ID was created.
Definition flecs.h:1500
ecs_world_info_t::batched_entity_count
int64_t batched_entity_count
Entities for which commands were batched.
Definition flecs.h:1529
ecs_world_info_t::time_scale
float time_scale
Time scale applied to delta_time.
Definition flecs.h:1485
ecs_world_info_t::pair_id_count
int32_t pair_id_count
Number of pair IDs in the world.
Definition flecs.h:1511
ecs_world_info_t::rematch_time_total
float rematch_time_total
Time spent on query rematching.
Definition flecs.h:1491
ecs_world_info_t::ensure_count
int64_t ensure_count
Ensure or emplace commands processed.
Definition flecs.h:1524
ecs_world_info_t::target_fps
float target_fps
Target FPS.
Definition flecs.h:1486
ecs_world_info_t::world_time_total_raw
double world_time_total_raw
Time elapsed in simulation (no scaling).
Definition flecs.h:1493
ecs_world_info_t::emit_time_total
float emit_time_total
Total time spent notifying observers.
Definition flecs.h:1489
ecs_world_info_t::creation_time
uint32_t creation_time
Time when world was created.
Definition flecs.h:1515
ecs_world_info_t::modified_count
int64_t modified_count
Modified commands processed.
Definition flecs.h:1525
ecs_world_info_t::name_prefix
const char * name_prefix
Value set by ecs_set_name_prefix().
Definition flecs.h:1533
ecs_world_info_t::event_count
int64_t event_count
Enqueued custom events.
Definition flecs.h:1527
ecs_world_info_t::add_count
int64_t add_count
Add commands processed.
Definition flecs.h:1519
ecs_world_info_t::remove_count
int64_t remove_count
Remove commands processed.
Definition flecs.h:1520