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 6
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#ifndef FLECS_EXCLUSIVE_ACCESS
116#define FLECS_EXCLUSIVE_ACCESS /* Enable exclusive access checks in debug mode */
117#endif
118#endif
119
120/* Tip: if you see weird behavior that you think might be a bug, make sure to
121 * test with the FLECS_DEBUG or FLECS_SANITIZE flags enabled. There's a good
122 * chance that this gives you more information about the issue! */
123
137// #define FLECS_SOFT_ASSERT
138
144// #define FLECS_KEEP_ASSERT
145
152// #define FLECS_DEFAULT_TO_UNCACHED_QUERIES
153
166// #define FLECS_CREATE_MEMBER_ENTITIES
167
176// #define FLECS_CPP_NO_AUTO_REGISTRATION
177
185// #define FLECS_CPP_NO_ENUM_REFLECTION
186
191// #define FLECS_NO_ALWAYS_INLINE
192
220// #define FLECS_CUSTOM_BUILD
221
222#ifndef FLECS_CUSTOM_BUILD
223#define FLECS_ALERTS
224#define FLECS_APP
225// #define FLECS_C /**< C API convenience macros, always enabled. */
226#define FLECS_CPP
227#define FLECS_DOC
228// #define FLECS_EXCLUSIVE_ACCESS /**< Enable exclusive world access checks. */
229// #define FLECS_JOURNAL /**< Journaling addon. */
230#define FLECS_JSON
231#define FLECS_HTTP
232#define FLECS_LOG
233#define FLECS_META
234#define FLECS_METRICS
235#define FLECS_MODULE
236#define FLECS_OS_API_IMPL
237// #define FLECS_PERF_TRACE /**< Enable performance tracing. */
238#define FLECS_PIPELINE
239#define FLECS_REST
240#define FLECS_PARSER
241#define FLECS_QUERY_DSL
242#define FLECS_SCRIPT
243// #define FLECS_SCRIPT_MATH /**< Math functions for Flecs script (may require linking with libm). */
244#define FLECS_SYSTEM
245#define FLECS_STATS
246#define FLECS_TIMER
247#define FLECS_UNITS
248#endif // ifndef FLECS_CUSTOM_BUILD
249
253// #define FLECS_LOW_FOOTPRINT
254#ifdef FLECS_LOW_FOOTPRINT
255#define FLECS_HI_COMPONENT_ID 16
256#define FLECS_HI_ID_RECORD_ID 16
257#define FLECS_ENTITY_PAGE_BITS 6
258#define FLECS_USE_OS_ALLOC
259#define FLECS_DEFAULT_TO_UNCACHED_QUERIES
260#endif
261
276#ifndef FLECS_HI_COMPONENT_ID
277#define FLECS_HI_COMPONENT_ID 256
278#endif
279
286#ifndef FLECS_HI_ID_RECORD_ID
287#define FLECS_HI_ID_RECORD_ID 1024
288#endif
289
295#ifndef FLECS_SPARSE_PAGE_BITS
296#define FLECS_SPARSE_PAGE_BITS 6
297#endif
298
301#ifndef FLECS_ENTITY_PAGE_BITS
302#define FLECS_ENTITY_PAGE_BITS 10
303#endif
304
309// #define FLECS_USE_OS_ALLOC
310
313#ifndef FLECS_ID_DESC_MAX
314#define FLECS_ID_DESC_MAX 32
315#endif
316
319#ifndef FLECS_EVENT_DESC_MAX
320#define FLECS_EVENT_DESC_MAX 8
321#endif
322
325#define FLECS_VARIABLE_COUNT_MAX 64
326
329#ifndef FLECS_TERM_COUNT_MAX
330#define FLECS_TERM_COUNT_MAX 32
331#endif
332
335#ifndef FLECS_TERM_ARG_COUNT_MAX
336#define FLECS_TERM_ARG_COUNT_MAX 16
337#endif
338
341#ifndef FLECS_QUERY_VARIABLE_COUNT_MAX
342#define FLECS_QUERY_VARIABLE_COUNT_MAX 64
343#endif
344
347#ifndef FLECS_QUERY_SCOPE_NESTING_MAX
348#define FLECS_QUERY_SCOPE_NESTING_MAX 8
349#endif
350
355#ifndef FLECS_DAG_DEPTH_MAX
356#define FLECS_DAG_DEPTH_MAX 128
357#endif
358
363#define FLECS_TREE_SPAWNER_DEPTH_CACHE_SIZE (6)
364
366
367#include "flecs/private/api_defines.h"
368
375
378 typedef uint64_t ecs_id_t;
379
385 typedef ecs_id_t ecs_entity_t;
386
402 typedef struct {
403 ecs_id_t *array;
404 int32_t count;
405} ecs_type_t;
406
429 typedef struct ecs_world_t ecs_world_t;
430
432 typedef struct ecs_stage_t ecs_stage_t;
433
435 typedef struct ecs_table_t ecs_table_t;
436
438 typedef struct ecs_term_t ecs_term_t;
439
441 typedef struct ecs_query_t ecs_query_t;
442
460 typedef struct ecs_observer_t ecs_observer_t;
461
465 typedef struct ecs_observable_t ecs_observable_t;
466
471 typedef struct ecs_iter_t ecs_iter_t;
472
481 typedef struct ecs_ref_t ecs_ref_t;
482
486 typedef struct ecs_type_hooks_t ecs_type_hooks_t;
487
491 typedef struct ecs_type_info_t ecs_type_info_t;
492
494 typedef struct ecs_record_t ecs_record_t;
495
497 typedef struct ecs_component_record_t ecs_component_record_t;
498
518 typedef void ecs_poly_t;
519
521 typedef struct ecs_mixins_t ecs_mixins_t;
522
524 typedef struct ecs_header_t {
525 int32_t type;
526 int32_t refcount;
527 ecs_mixins_t *mixins;
528} ecs_header_t;
529
531 typedef struct ecs_table_record_t ecs_table_record_t;
532
534
535#include "flecs/datastructures/vec.h" /* Vector datatype */
536#include "flecs/datastructures/sparse.h" /* Sparse set */
537#include "flecs/datastructures/block_allocator.h" /* Block allocator */
538#include "flecs/datastructures/stack_allocator.h" /* Stack allocator */
539#include "flecs/datastructures/map.h" /* Map */
540#include "flecs/datastructures/allocator.h" /* Allocator */
541#include "flecs/datastructures/strbuf.h" /* String builder */
542#include "flecs/os_api.h" /* Abstraction for operating system functions */
543
544#ifdef __cplusplus
545extern "C" {
546#endif
547
554
555
562
572 typedef void (*ecs_run_action_t)(
573 ecs_iter_t *it);
574
581 typedef void (*ecs_iter_action_t)(
582 ecs_iter_t *it);
583
591 typedef bool (*ecs_iter_next_action_t)(
592 ecs_iter_t *it);
593
599 typedef void (*ecs_iter_fini_action_t)(
600 ecs_iter_t *it);
601
603 typedef int (*ecs_order_by_action_t)(
604 ecs_entity_t e1,
605 const void *ptr1,
606 ecs_entity_t e2,
607 const void *ptr2);
608
610 typedef void (*ecs_sort_table_action_t)(
611 ecs_world_t* world,
612 ecs_table_t* table,
613 ecs_entity_t* entities,
614 void* ptr,
615 int32_t size,
616 int32_t lo,
617 int32_t hi,
618 ecs_order_by_action_t order_by);
619
621 typedef uint64_t (*ecs_group_by_action_t)(
622 ecs_world_t *world,
623 ecs_table_t *table,
624 ecs_id_t group_id,
625 void *ctx);
626
628 typedef void* (*ecs_group_create_action_t)(
629 ecs_world_t *world,
630 uint64_t group_id,
631 void *group_by_ctx); /* from ecs_query_desc_t */
632
634 typedef void (*ecs_group_delete_action_t)(
635 ecs_world_t *world,
636 uint64_t group_id,
637 void *group_ctx, /* return value from ecs_group_create_action_t */
638 void *group_by_ctx); /* from ecs_query_desc_t */
639
641 typedef void (*ecs_module_action_t)(
642 ecs_world_t *world);
643
645 typedef void (*ecs_fini_action_t)(
646 ecs_world_t *world,
647 void *ctx);
648
650 typedef void (*ecs_ctx_free_t)(
651 void *ctx);
652
654 typedef int (*ecs_compare_action_t)(
655 const void *ptr1,
656 const void *ptr2);
657
659 typedef uint64_t (*ecs_hash_value_action_t)(
660 const void *ptr);
661
663 typedef void (*ecs_xtor_t)(
664 void *ptr,
665 int32_t count,
666 const ecs_type_info_t *type_info);
667
669 typedef void (*ecs_copy_t)(
670 void *dst_ptr,
671 const void *src_ptr,
672 int32_t count,
673 const ecs_type_info_t *type_info);
674
676 typedef void (*ecs_move_t)(
677 void *dst_ptr,
678 void *src_ptr,
679 int32_t count,
680 const ecs_type_info_t *type_info);
681
683 typedef int (*ecs_cmp_t)(
684 const void *a_ptr,
685 const void *b_ptr,
686 const ecs_type_info_t *type_info);
687
689 typedef bool (*ecs_equals_t)(
690 const void *a_ptr,
691 const void *b_ptr,
692 const ecs_type_info_t *type_info);
693
695 typedef void (*flecs_poly_dtor_t)(
696 ecs_poly_t *poly);
697
699
706
708 typedef enum ecs_inout_kind_t {
709 EcsInOutDefault,
710 EcsInOutNone,
711 EcsInOutFilter,
712 EcsInOut,
713 EcsIn,
714 EcsOut,
715} ecs_inout_kind_t;
716
718 typedef enum ecs_oper_kind_t {
719 EcsAnd,
720 EcsOr,
721 EcsNot,
722 EcsOptional,
723 EcsAndFrom,
724 EcsOrFrom,
725 EcsNotFrom,
726} ecs_oper_kind_t;
727
729 typedef enum ecs_query_cache_kind_t {
730 EcsQueryCacheDefault,
731 EcsQueryCacheAuto,
732 EcsQueryCacheAll,
733 EcsQueryCacheNone,
734} ecs_query_cache_kind_t;
735
737
742#define EcsSelf (1llu << 63)
743
748#define EcsUp (1llu << 62)
749
754#define EcsTrav (1llu << 61)
755
760#define EcsCascade (1llu << 60)
761
766#define EcsDesc (1llu << 59)
767
772#define EcsIsVariable (1llu << 58)
773
778#define EcsIsEntity (1llu << 57)
779
784#define EcsIsName (1llu << 56)
785
790#define EcsTraverseFlags (EcsSelf|EcsUp|EcsTrav|EcsCascade|EcsDesc)
791
796#define EcsTermRefFlags (EcsTraverseFlags|EcsIsVariable|EcsIsEntity|EcsIsName)
797
799 typedef struct ecs_term_ref_t {
800 ecs_entity_t id;
805
806 const char *name;
811} ecs_term_ref_t;
812
814 struct ecs_term_t {
815 ecs_id_t id;
819
820 ecs_term_ref_t src;
821 ecs_term_ref_t first;
822 ecs_term_ref_t second;
823
824 ecs_entity_t trav;
827
828 int16_t inout;
829 int16_t oper;
830
831 int8_t field_index;
832 ecs_flags16_t flags_;
833};
834
838 struct ecs_query_t {
839 ecs_header_t hdr;
840
841 ecs_term_t *terms;
842 int32_t *sizes;
843 ecs_id_t *ids;
844
845 uint64_t bloom_filter;
846 ecs_flags32_t flags;
847 int8_t var_count;
848 int8_t term_count;
849 int8_t field_count;
850
852 ecs_termset_t fixed_fields;
853 ecs_termset_t var_fields;
854 ecs_termset_t static_id_fields;
855 ecs_termset_t data_fields;
856 ecs_termset_t write_fields;
857 ecs_termset_t read_fields;
858 ecs_termset_t row_fields;
859 ecs_termset_t shared_readonly_fields;
860 ecs_termset_t set_fields;
861
862 ecs_query_cache_kind_t cache_kind;
863
864 char **vars;
865
866 void *ctx;
867 void *binding_ctx;
868
869 ecs_entity_t entity;
870 ecs_world_t *real_world;
871 ecs_world_t *world;
872
873 int32_t eval_count;
874};
875
879 struct ecs_observer_t {
880 ecs_header_t hdr;
881
882 ecs_query_t *query;
883
885 ecs_entity_t events[FLECS_EVENT_DESC_MAX];
886 int32_t event_count;
887
888 ecs_iter_action_t callback;
889 ecs_run_action_t run;
890
891 void *ctx;
892 void *callback_ctx;
893 void *run_ctx;
894
895 ecs_ctx_free_t ctx_free;
896 ecs_ctx_free_t callback_ctx_free;
897 ecs_ctx_free_t run_ctx_free;
898
899 ecs_observable_t *observable;
900
901 ecs_world_t *world;
902 ecs_entity_t entity;
903};
904
906
911
912/* Flags that can be used to check which hooks a type has set */
913#define ECS_TYPE_HOOK_CTOR ECS_CAST(ecs_flags32_t, 1 << 0)
914#define ECS_TYPE_HOOK_DTOR ECS_CAST(ecs_flags32_t, 1 << 1)
915#define ECS_TYPE_HOOK_COPY ECS_CAST(ecs_flags32_t, 1 << 2)
916#define ECS_TYPE_HOOK_MOVE ECS_CAST(ecs_flags32_t, 1 << 3)
917#define ECS_TYPE_HOOK_COPY_CTOR ECS_CAST(ecs_flags32_t, 1 << 4)
918#define ECS_TYPE_HOOK_MOVE_CTOR ECS_CAST(ecs_flags32_t, 1 << 5)
919#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 6)
920#define ECS_TYPE_HOOK_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 7)
921#define ECS_TYPE_HOOK_CMP ECS_CAST(ecs_flags32_t, 1 << 8)
922#define ECS_TYPE_HOOK_EQUALS ECS_CAST(ecs_flags32_t, 1 << 9)
923
924
925/* Flags that can be used to set/check which hooks of a type are invalid */
926#define ECS_TYPE_HOOK_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 10)
927#define ECS_TYPE_HOOK_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 12)
928#define ECS_TYPE_HOOK_COPY_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 13)
929#define ECS_TYPE_HOOK_MOVE_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 14)
930#define ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 15)
931#define ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 16)
932#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 17)
933#define ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 18)
934#define ECS_TYPE_HOOK_CMP_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 19)
935#define ECS_TYPE_HOOK_EQUALS_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 20)
936
937/* Internal debug flag that indicates type hooks have been invoked */
938#define ECS_TYPE_HOOK_IN_USE ECS_CAST(ecs_flags32_t, 1 << 21)
939
940
941/* All valid hook flags */
942#define ECS_TYPE_HOOKS (ECS_TYPE_HOOK_CTOR|ECS_TYPE_HOOK_DTOR|\
943 ECS_TYPE_HOOK_COPY|ECS_TYPE_HOOK_MOVE|ECS_TYPE_HOOK_COPY_CTOR|\
944 ECS_TYPE_HOOK_MOVE_CTOR|ECS_TYPE_HOOK_CTOR_MOVE_DTOR|\
945 ECS_TYPE_HOOK_MOVE_DTOR|ECS_TYPE_HOOK_CMP|ECS_TYPE_HOOK_EQUALS)
946
947/* All invalid hook flags */
948#define ECS_TYPE_HOOKS_ILLEGAL (ECS_TYPE_HOOK_CTOR_ILLEGAL|\
949 ECS_TYPE_HOOK_DTOR_ILLEGAL|ECS_TYPE_HOOK_COPY_ILLEGAL|\
950 ECS_TYPE_HOOK_MOVE_ILLEGAL|ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL|\
951 ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL|ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL|\
952 ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL|ECS_TYPE_HOOK_CMP_ILLEGAL|\
953 ECS_TYPE_HOOK_EQUALS_ILLEGAL)
954 struct ecs_type_hooks_t {
955 ecs_xtor_t ctor;
956 ecs_xtor_t dtor;
957 ecs_copy_t copy;
958 ecs_move_t move;
959
961 ecs_copy_t copy_ctor;
962
964 ecs_move_t move_ctor;
965
970 ecs_move_t ctor_move_dtor;
971
976 ecs_move_t move_dtor;
977
979 ecs_cmp_t cmp;
980
982 ecs_equals_t equals;
983
988 ecs_flags32_t flags;
989
992 ecs_iter_action_t on_add;
993
997 ecs_iter_action_t on_set;
998
1002 ecs_iter_action_t on_remove;
1003
1008 ecs_iter_action_t on_replace;
1009
1010 void *ctx;
1011 void *binding_ctx;
1012 void *lifecycle_ctx;
1013
1014 ecs_ctx_free_t ctx_free;
1015 ecs_ctx_free_t binding_ctx_free;
1016 ecs_ctx_free_t lifecycle_ctx_free;
1017};
1018
1023 struct ecs_type_info_t {
1024 ecs_size_t size;
1025 ecs_size_t alignment;
1026 ecs_type_hooks_t hooks;
1027 ecs_entity_t component;
1028 const char *name;
1029};
1030
1031#include "flecs/private/api_types.h" /* Supporting API types */
1032#include "flecs/private/api_support.h" /* Supporting API functions */
1033#include "flecs/datastructures/hashmap.h" /* Hashmap */
1034#include "flecs/private/api_internals.h" /* Supporting API functions */
1035
1037 typedef struct ecs_value_t {
1038 ecs_entity_t type;
1039 void *ptr;
1040} ecs_value_t;
1041
1046 typedef struct ecs_entity_desc_t {
1047 int32_t _canary;
1048
1049 ecs_entity_t id;
1050
1051 ecs_entity_t parent;
1052
1053 const char *name;
1057
1058 const char *sep;
1061
1062 const char *root_sep;
1063
1064 const char *symbol;
1073
1074 bool use_low_id;
1077
1079 const ecs_id_t *add;
1080
1082 const ecs_value_t *set;
1083
1085 const char *add_expr;
1086} ecs_entity_desc_t;
1087
1092 typedef struct ecs_bulk_desc_t {
1093 int32_t _canary;
1094
1095 ecs_entity_t *entities;
1099
1100 int32_t count;
1101
1102 ecs_id_t ids[FLECS_ID_DESC_MAX];
1103
1104 void **data;
1110
1111 ecs_table_t *table;
1115
1116} ecs_bulk_desc_t;
1117
1122 typedef struct ecs_component_desc_t {
1123 int32_t _canary;
1124
1126 ecs_entity_t entity;
1127
1129 ecs_type_info_t type;
1130} ecs_component_desc_t;
1131
1170 struct ecs_iter_t {
1171 /* World */
1172 ecs_world_t *world;
1173 ecs_world_t *real_world;
1174
1175 /* Matched data */
1176 int32_t offset;
1177 int32_t count;
1178 const ecs_entity_t *entities;
1179 void **ptrs;
1180 const ecs_table_record_t **trs;
1181 const int16_t *columns;
1182 const ecs_size_t *sizes;
1183 ecs_table_t *table;
1184 ecs_table_t *other_table;
1185 ecs_id_t *ids;
1186 ecs_entity_t *sources;
1187 ecs_flags64_t constrained_vars;
1188 ecs_termset_t set_fields;
1189 ecs_termset_t ref_fields;
1190 ecs_termset_t row_fields;
1191 ecs_termset_t up_fields;
1192
1193 /* Input information */
1194 ecs_entity_t system;
1195 ecs_entity_t event;
1196 ecs_id_t event_id;
1197 int32_t event_cur;
1198
1199 /* Query information */
1200 int8_t field_count;
1201 int8_t term_index;
1204 const ecs_query_t *query;
1205
1206 /* Context */
1207 void *param;
1208 void *ctx;
1209 void *binding_ctx;
1210 void *callback_ctx;
1211 void *run_ctx;
1212
1213 /* Time */
1214 ecs_ftime_t delta_time;
1215 ecs_ftime_t delta_system_time;
1216
1217 /* Iterator counters */
1218 int32_t frame_offset;
1219
1220 /* Misc */
1221 ecs_flags32_t flags;
1222 ecs_entity_t interrupted_by;
1223 ecs_iter_private_t priv_;
1224
1225 /* Chained iterators */
1226 ecs_iter_next_action_t next;
1227 ecs_iter_action_t callback;
1228 ecs_iter_fini_action_t fini;
1229 ecs_iter_t *chain_it;
1230};
1231
1232
1237#define EcsQueryMatchPrefab (1u << 1u)
1238
1243#define EcsQueryMatchDisabled (1u << 2u)
1244
1249#define EcsQueryMatchEmptyTables (1u << 3u)
1250
1255#define EcsQueryAllowUnresolvedByName (1u << 6u)
1256
1261#define EcsQueryTableOnly (1u << 7u)
1262
1273#define EcsQueryDetectChanges (1u << 8u)
1274
1283#define EcsQueryGroupByOrdered (1u << 9u)
1284
1294#define EcsQueryGroupByDesc (1u << 10u)
1295
1296
1301 typedef struct ecs_query_desc_t {
1303 int32_t _canary;
1304
1306 ecs_term_t terms[FLECS_TERM_COUNT_MAX];
1307
1309 const char *expr;
1310
1312 ecs_query_cache_kind_t cache_kind;
1313
1315 ecs_flags32_t flags;
1316
1320 ecs_order_by_action_t order_by_callback;
1321
1324 ecs_sort_table_action_t order_by_table_callback;
1325
1328 ecs_entity_t order_by;
1329
1332 ecs_id_t group_by;
1333
1339 ecs_group_by_action_t group_by_callback;
1340
1343 ecs_group_create_action_t on_group_create;
1344
1347 ecs_group_delete_action_t on_group_delete;
1348
1350 void *group_by_ctx;
1351
1353 ecs_ctx_free_t group_by_ctx_free;
1354
1356 void *ctx;
1357
1359 void *binding_ctx;
1360
1362 ecs_ctx_free_t ctx_free;
1363
1365 ecs_ctx_free_t binding_ctx_free;
1366
1368 ecs_entity_t entity;
1369} ecs_query_desc_t;
1370
1375 typedef struct ecs_observer_desc_t {
1377 int32_t _canary;
1378
1380 ecs_entity_t entity;
1381
1383 ecs_query_desc_t query;
1384
1386 ecs_entity_t events[FLECS_EVENT_DESC_MAX];
1387
1390 bool yield_existing;
1391
1395 bool global_observer;
1396
1398 ecs_iter_action_t callback;
1399
1406 ecs_run_action_t run;
1407
1409 void *ctx;
1410
1412 ecs_ctx_free_t ctx_free;
1413
1415 void *callback_ctx;
1416
1418 ecs_ctx_free_t callback_ctx_free;
1419
1421 void *run_ctx;
1422
1424 ecs_ctx_free_t run_ctx_free;
1425
1427 int32_t *last_event_id;
1428 int8_t term_index_;
1429 ecs_flags32_t flags_;
1430} ecs_observer_desc_t;
1431
1436 typedef struct ecs_event_desc_t {
1438 ecs_entity_t event;
1439
1443 const ecs_type_t *ids;
1444
1446 ecs_table_t *table;
1447
1450 ecs_table_t *other_table;
1451
1453 int32_t offset;
1454
1458 int32_t count;
1459
1461 ecs_entity_t entity;
1462
1467 void *param;
1468
1472 const void *const_param;
1473
1475 ecs_poly_t *observable;
1476
1478 ecs_flags32_t flags;
1479} ecs_event_desc_t;
1480
1481
1488
1490 typedef struct ecs_build_info_t {
1491 const char *compiler;
1492 const char **addons;
1493 const char **flags;
1494 const char *version;
1495 int16_t version_major;
1496 int16_t version_minor;
1497 int16_t version_patch;
1498 bool debug;
1499 bool sanitize;
1500 bool perf_trace;
1501} ecs_build_info_t;
1502
1504 typedef struct ecs_world_info_t {
1505 ecs_entity_t last_component_id;
1506
1507 ecs_ftime_t delta_time_raw;
1508 ecs_ftime_t delta_time;
1509 ecs_ftime_t time_scale;
1510 ecs_ftime_t target_fps;
1511 ecs_ftime_t frame_time_total;
1512 ecs_ftime_t system_time_total;
1513 ecs_ftime_t emit_time_total;
1514 ecs_ftime_t merge_time_total;
1515 ecs_ftime_t rematch_time_total;
1516 double world_time_total;
1517 double world_time_total_raw;
1518
1519 int64_t frame_count_total;
1520 int64_t merge_count_total;
1521 int64_t eval_comp_monitors_total;
1522 int64_t rematch_count_total;
1523
1524 int64_t id_create_total;
1525 int64_t id_delete_total;
1526 int64_t table_create_total;
1527 int64_t table_delete_total;
1528 int64_t pipeline_build_count_total;
1529 int64_t systems_ran_total;
1530 int64_t observers_ran_total;
1531 int64_t queries_ran_total;
1532
1533 int32_t tag_id_count;
1534 int32_t component_id_count;
1535 int32_t pair_id_count;
1536
1537 int32_t table_count;
1538
1539 uint32_t creation_time;
1540
1541 /* -- Command counts -- */
1542 struct {
1543 int64_t add_count;
1544 int64_t remove_count;
1545 int64_t delete_count;
1546 int64_t clear_count;
1547 int64_t set_count;
1548 int64_t ensure_count;
1549 int64_t modified_count;
1550 int64_t discard_count;
1551 int64_t event_count;
1552 int64_t other_count;
1553 int64_t batched_entity_count;
1554 int64_t batched_command_count;
1555 } cmd;
1556
1557 const char *name_prefix;
1561} ecs_world_info_t;
1562
1564 typedef struct ecs_query_group_info_t {
1565 uint64_t id;
1566 int32_t match_count;
1567 int32_t table_count;
1568 void *ctx;
1569} ecs_query_group_info_t;
1570
1574 typedef struct ecs_entity_range_t {
1575 uint32_t min;
1576 uint32_t max;
1577 uint32_t cur;
1578 ecs_vec_t recycled;
1579} ecs_entity_range_t;
1580
1582
1589
1591 typedef struct EcsIdentifier {
1592 char *value;
1593 ecs_size_t length;
1594 uint64_t hash;
1595 uint64_t index_hash;
1596 ecs_hashmap_t *index;
1597} EcsIdentifier;
1598
1600 typedef struct EcsComponent {
1601 ecs_size_t size;
1602 ecs_size_t alignment;
1603} EcsComponent;
1604
1606 typedef struct EcsPoly {
1607 ecs_poly_t *poly;
1608} EcsPoly;
1609
1615 typedef struct EcsDefaultChildComponent {
1616 ecs_id_t component;
1617} EcsDefaultChildComponent;
1618
1620 typedef struct EcsParent {
1621 ecs_entity_t value;
1622} EcsParent;
1623
1625 typedef struct {
1626 const char *child_name;
1627 ecs_table_t *table;
1628 uint32_t child;
1629 int32_t parent_index;
1630} ecs_tree_spawner_child_t;
1631
1633 typedef struct {
1634 ecs_vec_t children;
1635} ecs_tree_spawner_t;
1636
1644 typedef struct EcsTreeSpawner {
1645 ecs_tree_spawner_t data[FLECS_TREE_SPAWNER_DEPTH_CACHE_SIZE];
1646} EcsTreeSpawner;
1647
1650
1651/* Only include deprecated definitions if deprecated addon is required */
1652#ifdef FLECS_DEPRECATED
1653#include "flecs/addons/deprecated.h"
1654#endif
1655
1662
1669
1671FLECS_API extern const ecs_id_t ECS_PAIR;
1672
1674FLECS_API extern const ecs_id_t ECS_AUTO_OVERRIDE;
1675
1677FLECS_API extern const ecs_id_t ECS_TOGGLE;
1678
1680FLECS_API extern const ecs_id_t ECS_VALUE_PAIR;
1681
1683
1688
1689/* Built-in component IDs */
1690
1692FLECS_API extern const ecs_entity_t ecs_id(EcsComponent);
1693
1695FLECS_API extern const ecs_entity_t ecs_id(EcsIdentifier);
1696
1698FLECS_API extern const ecs_entity_t ecs_id(EcsPoly);
1699
1701FLECS_API extern const ecs_entity_t ecs_id(EcsParent);
1702
1704FLECS_API extern const ecs_entity_t ecs_id(EcsTreeSpawner);
1705
1707FLECS_API extern const ecs_entity_t ecs_id(EcsDefaultChildComponent);
1708
1710FLECS_API extern const ecs_entity_t EcsParentDepth;
1711
1713FLECS_API extern const ecs_entity_t EcsQuery;
1714
1716FLECS_API extern const ecs_entity_t EcsObserver;
1717
1719FLECS_API extern const ecs_entity_t EcsSystem;
1720
1722FLECS_API extern const ecs_entity_t ecs_id(EcsTickSource);
1723
1725FLECS_API extern const ecs_entity_t ecs_id(EcsPipelineQuery);
1726
1728FLECS_API extern const ecs_entity_t ecs_id(EcsTimer);
1729
1731FLECS_API extern const ecs_entity_t ecs_id(EcsRateFilter);
1732
1734FLECS_API extern const ecs_entity_t EcsFlecs;
1735
1737FLECS_API extern const ecs_entity_t EcsFlecsCore;
1738
1740FLECS_API extern const ecs_entity_t EcsWorld;
1741
1743FLECS_API extern const ecs_entity_t EcsWildcard;
1744
1746FLECS_API extern const ecs_entity_t EcsAny;
1747
1749FLECS_API extern const ecs_entity_t EcsThis;
1750
1752FLECS_API extern const ecs_entity_t EcsVariable;
1753
1761FLECS_API extern const ecs_entity_t EcsTransitive;
1762
1770FLECS_API extern const ecs_entity_t EcsReflexive;
1771
1782FLECS_API extern const ecs_entity_t EcsFinal;
1783
1789FLECS_API extern const ecs_entity_t EcsInheritable;
1790
1792FLECS_API extern const ecs_entity_t EcsOnInstantiate;
1793
1797FLECS_API extern const ecs_entity_t EcsOverride;
1798
1802FLECS_API extern const ecs_entity_t EcsInherit;
1803
1808FLECS_API extern const ecs_entity_t EcsDontInherit;
1809
1817FLECS_API extern const ecs_entity_t EcsSymmetric;
1818
1828FLECS_API extern const ecs_entity_t EcsExclusive;
1829
1831FLECS_API extern const ecs_entity_t EcsAcyclic;
1832
1835FLECS_API extern const ecs_entity_t EcsTraversable;
1836
1846FLECS_API extern const ecs_entity_t EcsWith;
1847
1857FLECS_API extern const ecs_entity_t EcsOneOf;
1858
1860FLECS_API extern const ecs_entity_t EcsCanToggle;
1861
1865FLECS_API extern const ecs_entity_t EcsTrait;
1866
1876FLECS_API extern const ecs_entity_t EcsRelationship;
1877
1887FLECS_API extern const ecs_entity_t EcsTarget;
1888
1891FLECS_API extern const ecs_entity_t EcsPairIsTag;
1892
1894FLECS_API extern const ecs_entity_t EcsName;
1895
1897FLECS_API extern const ecs_entity_t EcsSymbol;
1898
1900FLECS_API extern const ecs_entity_t EcsAlias;
1901
1903FLECS_API extern const ecs_entity_t EcsChildOf;
1904
1906FLECS_API extern const ecs_entity_t EcsIsA;
1907
1909FLECS_API extern const ecs_entity_t EcsDependsOn;
1910
1912FLECS_API extern const ecs_entity_t EcsSlotOf;
1913
1915FLECS_API extern const ecs_entity_t EcsOrderedChildren;
1916
1918FLECS_API extern const ecs_entity_t EcsModule;
1919
1922FLECS_API extern const ecs_entity_t EcsPrefab;
1923
1926FLECS_API extern const ecs_entity_t EcsDisabled;
1927
1931FLECS_API extern const ecs_entity_t EcsNotQueryable;
1932
1934FLECS_API extern const ecs_entity_t EcsOnAdd;
1935
1937FLECS_API extern const ecs_entity_t EcsOnRemove;
1938
1940FLECS_API extern const ecs_entity_t EcsOnSet;
1941
1943FLECS_API extern const ecs_entity_t EcsMonitor;
1944
1946FLECS_API extern const ecs_entity_t EcsOnTableCreate;
1947
1949FLECS_API extern const ecs_entity_t EcsOnTableDelete;
1950
1952FLECS_API extern const ecs_entity_t EcsOnDelete;
1953
1956FLECS_API extern const ecs_entity_t EcsOnDeleteTarget;
1957
1960FLECS_API extern const ecs_entity_t EcsRemove;
1961
1964FLECS_API extern const ecs_entity_t EcsDelete;
1965
1968FLECS_API extern const ecs_entity_t EcsPanic;
1969
1972FLECS_API extern const ecs_entity_t EcsSingleton;
1973
1975FLECS_API extern const ecs_entity_t EcsSparse;
1976
1978FLECS_API extern const ecs_entity_t EcsDontFragment;
1979
1981FLECS_API extern const ecs_entity_t EcsPredEq;
1982
1984FLECS_API extern const ecs_entity_t EcsPredMatch;
1985
1987FLECS_API extern const ecs_entity_t EcsPredLookup;
1988
1990FLECS_API extern const ecs_entity_t EcsScopeOpen;
1991
1993FLECS_API extern const ecs_entity_t EcsScopeClose;
1994
1999FLECS_API extern const ecs_entity_t EcsEmpty;
2000
2001FLECS_API extern const ecs_entity_t ecs_id(EcsPipeline);
2002FLECS_API extern const ecs_entity_t EcsOnStart;
2003FLECS_API extern const ecs_entity_t EcsPreFrame;
2004FLECS_API extern const ecs_entity_t EcsOnLoad;
2005FLECS_API extern const ecs_entity_t EcsPostLoad;
2006FLECS_API extern const ecs_entity_t EcsPreUpdate;
2007FLECS_API extern const ecs_entity_t EcsOnUpdate;
2008FLECS_API extern const ecs_entity_t EcsOnValidate;
2009FLECS_API extern const ecs_entity_t EcsPostUpdate;
2010FLECS_API extern const ecs_entity_t EcsPreStore;
2011FLECS_API extern const ecs_entity_t EcsOnStore;
2012FLECS_API extern const ecs_entity_t EcsPostFrame;
2013FLECS_API extern const ecs_entity_t EcsPhase;
2014
2015FLECS_API extern const ecs_entity_t EcsConstant;
2016
2019#define EcsLastInternalComponentId (ecs_id(EcsTreeSpawner))
2020
2023#define EcsFirstUserComponentId (8)
2024
2027#define EcsFirstUserEntityId (FLECS_HI_COMPONENT_ID + 128)
2028
2029/* When visualized, the reserved ID ranges look like this:
2030 * - [1..8]: Built-in components
2031 * - [9..FLECS_HI_COMPONENT_ID]: Low IDs reserved for application components
2032 * - [FLECS_HI_COMPONENT_ID + 1..EcsFirstUserEntityId]: Built-in entities
2033 */
2034
2037
2044
2049
2056FLECS_API
2057 ecs_world_t* ecs_init(void);
2058
2065FLECS_API
2066 ecs_world_t* ecs_mini(void);
2067
2077FLECS_API
2078 ecs_world_t* ecs_init_w_args(
2079 int argc,
2080 char *argv[]);
2081
2088FLECS_API
2089 int ecs_fini(
2090 ecs_world_t *world);
2091
2099FLECS_API
2100 bool ecs_is_fini(
2101 const ecs_world_t *world);
2102
2111FLECS_API
2112 void ecs_atfini(
2113 ecs_world_t *world,
2114 ecs_fini_action_t action,
2115 void *ctx);
2116
2118 typedef struct ecs_entities_t {
2119 const ecs_entity_t *ids;
2120 int32_t count;
2121 int32_t alive_count;
2122} ecs_entities_t;
2123
2150FLECS_API
2151 ecs_entities_t ecs_get_entities(
2152 const ecs_world_t *world);
2153
2161FLECS_API
2162ecs_flags32_t ecs_world_get_flags(
2163 const ecs_world_t *world);
2164
2166
2171
2190FLECS_API
2191 ecs_ftime_t ecs_frame_begin(
2192 ecs_world_t *world,
2193 ecs_ftime_t delta_time);
2194
2201FLECS_API
2202 void ecs_frame_end(
2203 ecs_world_t *world);
2204
2213FLECS_API
2214 void ecs_run_post_frame(
2215 ecs_world_t *world,
2216 ecs_fini_action_t action,
2217 void *ctx);
2218
2225FLECS_API
2226 void ecs_quit(
2227 ecs_world_t *world);
2228
2235FLECS_API
2236 bool ecs_should_quit(
2237 const ecs_world_t *world);
2238
2250FLECS_API void ecs_measure_frame_time(
2251 ecs_world_t *world,
2252 bool enable);
2253
2264FLECS_API void ecs_measure_system_time(
2265 ecs_world_t *world,
2266 bool enable);
2267
2283FLECS_API
2284 void ecs_set_target_fps(
2285 ecs_world_t *world,
2286 ecs_ftime_t fps);
2287
2301FLECS_API
2302 void ecs_set_default_query_flags(
2303 ecs_world_t *world,
2304 ecs_flags32_t flags);
2305
2307
2312
2382FLECS_API
2383 bool ecs_readonly_begin(
2384 ecs_world_t *world,
2385 bool multi_threaded);
2386
2394FLECS_API
2395 void ecs_readonly_end(
2396 ecs_world_t *world);
2397
2403FLECS_API
2404 void ecs_merge(
2405 ecs_world_t *stage);
2406
2423FLECS_API
2424 bool ecs_defer_begin(
2425 ecs_world_t *world);
2426
2440FLECS_API
2441 bool ecs_defer_end(
2442 ecs_world_t *world);
2443
2458FLECS_API
2459 void ecs_defer_suspend(
2460 ecs_world_t *world);
2461
2472FLECS_API
2473 void ecs_defer_resume(
2474 ecs_world_t *world);
2475
2487FLECS_API
2488 bool ecs_is_deferred(
2489 const ecs_world_t *world);
2490
2502FLECS_API
2503 bool ecs_is_defer_suspended(
2504 const ecs_world_t *world);
2505
2519FLECS_API
2520 void ecs_set_stage_count(
2521 ecs_world_t *world,
2522 int32_t stages);
2523
2530FLECS_API
2531int32_t ecs_get_stage_count(
2532 const ecs_world_t *world);
2533
2549FLECS_API
2550 ecs_world_t* ecs_get_stage(
2551 const ecs_world_t *world,
2552 int32_t stage_id);
2553
2561FLECS_API
2562 bool ecs_stage_is_readonly(
2563 const ecs_world_t *world);
2564
2572FLECS_API
2573 ecs_world_t* ecs_stage_new(
2574 ecs_world_t *world);
2575
2580FLECS_API
2581 void ecs_stage_free(
2582 ecs_world_t *stage);
2583
2591FLECS_API
2592int32_t ecs_stage_get_id(
2593 const ecs_world_t *world);
2594
2596
2601
2610FLECS_API
2611 void ecs_set_ctx(
2612 ecs_world_t *world,
2613 void *ctx,
2614 ecs_ctx_free_t ctx_free);
2615
2624FLECS_API
2625 void ecs_set_binding_ctx(
2626 ecs_world_t *world,
2627 void *ctx,
2628 ecs_ctx_free_t ctx_free);
2629
2637FLECS_API
2638 void* ecs_get_ctx(
2639 const ecs_world_t *world);
2640
2648FLECS_API
2649 void* ecs_get_binding_ctx(
2650 const ecs_world_t *world);
2651
2657FLECS_API
2658 const ecs_build_info_t* ecs_get_build_info(void);
2659
2665FLECS_API
2666 const ecs_world_info_t* ecs_get_world_info(
2667 const ecs_world_t *world);
2668
2677FLECS_API
2678 void ecs_dim(
2679 ecs_world_t *world,
2680 int32_t entity_count);
2681
2696FLECS_API
2697 void ecs_shrink(
2698 ecs_world_t *world);
2699
2714FLECS_API
2715 const ecs_entity_range_t* ecs_entity_range_new(
2716 ecs_world_t *world,
2717 uint32_t min,
2718 uint32_t max);
2719
2734FLECS_API
2735 void ecs_entity_range_set(
2736 ecs_world_t *world,
2737 const ecs_entity_range_t *range);
2738
2746FLECS_API
2747 const ecs_entity_range_t* ecs_entity_range_get(
2748 const ecs_world_t *world);
2749
2755FLECS_API
2756 ecs_entity_t ecs_get_max_id(
2757 const ecs_world_t *world);
2758
2772FLECS_API
2773 void ecs_run_aperiodic(
2774 ecs_world_t *world,
2775 ecs_flags32_t flags);
2776
2778 typedef struct ecs_delete_empty_tables_desc_t {
2780 uint16_t clear_generation;
2781
2783 uint16_t delete_generation;
2784
2786 double time_budget_seconds;
2787
2790 int32_t offset;
2791} ecs_delete_empty_tables_desc_t;
2792
2828FLECS_API
2829int32_t ecs_delete_empty_tables(
2830 ecs_world_t *world,
2831 const ecs_delete_empty_tables_desc_t *desc);
2832
2838FLECS_API
2839 const ecs_world_t* ecs_get_world(
2840 const ecs_poly_t *poly);
2841
2847FLECS_API
2848 ecs_entity_t ecs_get_entity(
2849 const ecs_poly_t *poly);
2850
2864FLECS_API
2865 bool flecs_poly_is_(
2866 const ecs_poly_t *object,
2867 int32_t type);
2868
2872#define flecs_poly_is(object, type)\
2873 flecs_poly_is_(object, type##_magic)
2874
2883FLECS_API
2884 ecs_id_t ecs_make_pair(
2885 ecs_entity_t first,
2886 ecs_entity_t second);
2887
2910FLECS_API
2911 void ecs_exclusive_access_begin(
2912 ecs_world_t *world,
2913 const char *thread_name);
2914
2937FLECS_API
2938 void ecs_exclusive_access_end(
2939 ecs_world_t *world,
2940 bool lock_world);
2941
2943
2945
2952
2959
2968FLECS_API
2969 ecs_entity_t ecs_new(
2970 ecs_world_t *world);
2971
2989FLECS_API
2990 ecs_entity_t ecs_new_low_id(
2991 ecs_world_t *world);
2992
3000FLECS_API
3001 ecs_entity_t ecs_new_w_id(
3002 ecs_world_t *world,
3003 ecs_id_t component);
3004
3012FLECS_API
3013 ecs_entity_t ecs_new_w_table(
3014 ecs_world_t *world,
3015 ecs_table_t *table);
3016
3035FLECS_API
3036 ecs_entity_t ecs_entity_init(
3037 ecs_world_t *world,
3038 const ecs_entity_desc_t *desc);
3039
3066FLECS_API
3067 const ecs_entity_t* ecs_bulk_init(
3068 ecs_world_t *world,
3069 const ecs_bulk_desc_t *desc);
3070
3080FLECS_API
3081 const ecs_entity_t* ecs_bulk_new_w_id(
3082 ecs_world_t *world,
3083 ecs_id_t component,
3084 int32_t count);
3085
3101FLECS_API
3102 ecs_entity_t ecs_clone(
3103 ecs_world_t *world,
3104 ecs_entity_t dst,
3105 ecs_entity_t src,
3106 bool copy_value);
3107
3116FLECS_API
3117 void ecs_delete(
3118 ecs_world_t *world,
3119 ecs_entity_t entity);
3120
3128FLECS_API
3129 void ecs_delete_with(
3130 ecs_world_t *world,
3131 ecs_id_t component);
3132
3150FLECS_API
3151 void ecs_set_child_order(
3152 ecs_world_t *world,
3153 ecs_entity_t parent,
3154 const ecs_entity_t *children,
3155 int32_t child_count);
3156
3166FLECS_API
3167 ecs_entities_t ecs_get_ordered_children(
3168 const ecs_world_t *world,
3169 ecs_entity_t parent);
3170
3172
3179
3188FLECS_API
3189 void ecs_add_id(
3190 ecs_world_t *world,
3191 ecs_entity_t entity,
3192 ecs_id_t component);
3193
3202FLECS_API
3203 void ecs_remove_id(
3204 ecs_world_t *world,
3205 ecs_entity_t entity,
3206 ecs_id_t component);
3207
3259FLECS_API
3260 void ecs_auto_override_id(
3261 ecs_world_t *world,
3262 ecs_entity_t entity,
3263 ecs_id_t component);
3264
3271FLECS_API
3272 void ecs_clear(
3273 ecs_world_t *world,
3274 ecs_entity_t entity);
3275
3283FLECS_API
3284 void ecs_remove_all(
3285 ecs_world_t *world,
3286 ecs_id_t component);
3287
3303FLECS_API
3304 ecs_entity_t ecs_set_with(
3305 ecs_world_t *world,
3306 ecs_id_t component);
3307
3316FLECS_API
3317 ecs_id_t ecs_get_with(
3318 const ecs_world_t *world);
3319
3321
3328
3338FLECS_API
3339 void ecs_enable(
3340 ecs_world_t *world,
3341 ecs_entity_t entity,
3342 bool enabled);
3343
3357FLECS_API
3358 void ecs_enable_id(
3359 ecs_world_t *world,
3360 ecs_entity_t entity,
3361 ecs_id_t component,
3362 bool enable);
3363
3374FLECS_API
3375 bool ecs_is_enabled_id(
3376 const ecs_world_t *world,
3377 ecs_entity_t entity,
3378 ecs_id_t component);
3379
3381
3388
3403FLECS_API
3404FLECS_ALWAYS_INLINE const void* ecs_get_id(
3405 const ecs_world_t *world,
3406 ecs_entity_t entity,
3407 ecs_id_t component);
3408
3423FLECS_API
3424FLECS_ALWAYS_INLINE void* ecs_get_mut_id(
3425 const ecs_world_t *world,
3426 ecs_entity_t entity,
3427 ecs_id_t component);
3428
3446FLECS_API
3447 void* ecs_ensure_id(
3448 ecs_world_t *world,
3449 ecs_entity_t entity,
3450 ecs_id_t component,
3451 size_t size);
3452
3463FLECS_ALWAYS_INLINE FLECS_API
3464 ecs_ref_t ecs_ref_init_id(
3465 const ecs_world_t *world,
3466 ecs_entity_t entity,
3467 ecs_id_t component);
3468
3479FLECS_ALWAYS_INLINE FLECS_API
3480 void* ecs_ref_get_id(
3481 const ecs_world_t *world,
3482 ecs_ref_t *ref,
3483 ecs_id_t component);
3484
3493FLECS_ALWAYS_INLINE FLECS_API
3494 void ecs_ref_update(
3495 const ecs_world_t *world,
3496 ecs_ref_t *ref,
3497 ecs_id_t component);
3498
3519FLECS_API
3520 void* ecs_emplace_id(
3521 ecs_world_t *world,
3522 ecs_entity_t entity,
3523 ecs_id_t component,
3524 size_t size,
3525 bool *is_new);
3526
3536FLECS_API
3537 void ecs_modified_id(
3538 ecs_world_t *world,
3539 ecs_entity_t entity,
3540 ecs_id_t component);
3541
3557FLECS_API
3558 void ecs_set_id(
3559 ecs_world_t *world,
3560 ecs_entity_t entity,
3561 ecs_id_t component,
3562 size_t size,
3563 const void *ptr);
3564
3566
3573
3593FLECS_API
3594 bool ecs_is_valid(
3595 const ecs_world_t *world,
3596 ecs_entity_t e);
3597
3627FLECS_API
3628 bool ecs_is_alive(
3629 const ecs_world_t *world,
3630 ecs_entity_t e);
3631
3637FLECS_API
3638 ecs_id_t ecs_strip_generation(
3639 ecs_entity_t e);
3640
3657FLECS_API
3658 ecs_entity_t ecs_get_alive(
3659 const ecs_world_t *world,
3660 ecs_entity_t e);
3661
3684FLECS_API
3685 void ecs_make_alive(
3686 ecs_world_t *world,
3687 ecs_entity_t entity);
3688
3707FLECS_API
3708 void ecs_make_alive_id(
3709 ecs_world_t *world,
3710 ecs_id_t component);
3711
3719FLECS_API
3720 bool ecs_exists(
3721 const ecs_world_t *world,
3722 ecs_entity_t entity);
3723
3738FLECS_API
3739 void ecs_set_version(
3740 ecs_world_t *world,
3741 ecs_entity_t entity);
3742
3748FLECS_API
3749uint32_t ecs_get_version(
3750 ecs_entity_t entity);
3751
3753
3760
3767FLECS_API
3768 const ecs_type_t* ecs_get_type(
3769 const ecs_world_t *world,
3770 ecs_entity_t entity);
3771
3778FLECS_API
3779 ecs_table_t* ecs_get_table(
3780 const ecs_world_t *world,
3781 ecs_entity_t entity);
3782
3790FLECS_API
3791 char* ecs_type_str(
3792 const ecs_world_t *world,
3793 const ecs_type_t* type);
3794
3806FLECS_API
3807 char* ecs_table_str(
3808 const ecs_world_t *world,
3809 const ecs_table_t *table);
3810
3825FLECS_API
3826 char* ecs_entity_str(
3827 const ecs_world_t *world,
3828 ecs_entity_t entity);
3829
3840FLECS_API
3841FLECS_ALWAYS_INLINE bool ecs_has_id(
3842 const ecs_world_t *world,
3843 ecs_entity_t entity,
3844 ecs_id_t component);
3845
3856FLECS_API
3857FLECS_ALWAYS_INLINE bool ecs_owns_id(
3858 const ecs_world_t *world,
3859 ecs_entity_t entity,
3860 ecs_id_t component);
3861
3876FLECS_API
3877 ecs_entity_t ecs_get_target(
3878 const ecs_world_t *world,
3879 ecs_entity_t entity,
3880 ecs_entity_t rel,
3881 int32_t index);
3882
3896FLECS_API
3897 ecs_entity_t ecs_get_parent(
3898 const ecs_world_t *world,
3899 ecs_entity_t entity);
3900
3914FLECS_API
3915 ecs_entity_t ecs_new_w_parent(
3916 ecs_world_t *world,
3917 ecs_entity_t parent,
3918 const char *name);
3919
3940FLECS_API
3941 ecs_entity_t ecs_get_target_for_id(
3942 const ecs_world_t *world,
3943 ecs_entity_t entity,
3944 ecs_entity_t rel,
3945 ecs_id_t component);
3946
3957FLECS_API
3958int32_t ecs_get_depth(
3959 const ecs_world_t *world,
3960 ecs_entity_t entity,
3961 ecs_entity_t rel);
3962
3970FLECS_API
3971int32_t ecs_count_id(
3972 const ecs_world_t *world,
3973 ecs_id_t entity);
3974
3976
3977
3984
3994FLECS_API
3995 const char* ecs_get_name(
3996 const ecs_world_t *world,
3997 ecs_entity_t entity);
3998
4008FLECS_API
4009 const char* ecs_get_symbol(
4010 const ecs_world_t *world,
4011 ecs_entity_t entity);
4012
4026FLECS_API
4027 ecs_entity_t ecs_set_name(
4028 ecs_world_t *world,
4029 ecs_entity_t entity,
4030 const char *name);
4031
4045FLECS_API
4046 ecs_entity_t ecs_set_symbol(
4047 ecs_world_t *world,
4048 ecs_entity_t entity,
4049 const char *symbol);
4050
4062FLECS_API
4063 void ecs_set_alias(
4064 ecs_world_t *world,
4065 ecs_entity_t entity,
4066 const char *alias);
4067
4083FLECS_API
4084 ecs_entity_t ecs_lookup(
4085 const ecs_world_t *world,
4086 const char *path);
4087
4102FLECS_API
4103 ecs_entity_t ecs_lookup_child(
4104 const ecs_world_t *world,
4105 ecs_entity_t parent,
4106 const char *name);
4107
4130FLECS_API
4131 ecs_entity_t ecs_lookup_path_w_sep(
4132 const ecs_world_t *world,
4133 ecs_entity_t parent,
4134 const char *path,
4135 const char *sep,
4136 const char *prefix,
4137 bool recursive);
4138
4156FLECS_API
4157 ecs_entity_t ecs_lookup_symbol(
4158 const ecs_world_t *world,
4159 const char *symbol,
4160 bool lookup_as_path,
4161 bool recursive);
4162
4184FLECS_API
4185 char* ecs_get_path_w_sep(
4186 const ecs_world_t *world,
4187 ecs_entity_t parent,
4188 ecs_entity_t child,
4189 const char *sep,
4190 const char *prefix);
4191
4205FLECS_API
4206 void ecs_get_path_w_sep_buf(
4207 const ecs_world_t *world,
4208 ecs_entity_t parent,
4209 ecs_entity_t child,
4210 const char *sep,
4211 const char *prefix,
4212 ecs_strbuf_t *buf,
4213 bool escape);
4214
4230FLECS_API
4231 ecs_entity_t ecs_new_from_path_w_sep(
4232 ecs_world_t *world,
4233 ecs_entity_t parent,
4234 const char *path,
4235 const char *sep,
4236 const char *prefix);
4237
4252FLECS_API
4253 ecs_entity_t ecs_add_path_w_sep(
4254 ecs_world_t *world,
4255 ecs_entity_t entity,
4256 ecs_entity_t parent,
4257 const char *path,
4258 const char *sep,
4259 const char *prefix);
4260
4274FLECS_API
4275 ecs_entity_t ecs_set_scope(
4276 ecs_world_t *world,
4277 ecs_entity_t scope);
4278
4286FLECS_API
4287 ecs_entity_t ecs_get_scope(
4288 const ecs_world_t *world);
4289
4299FLECS_API
4300 const char* ecs_set_name_prefix(
4301 ecs_world_t *world,
4302 const char *prefix);
4303
4330FLECS_API
4331 ecs_entity_t* ecs_set_lookup_path(
4332 ecs_world_t *world,
4333 const ecs_entity_t *lookup_path);
4334
4341FLECS_API
4342 ecs_entity_t* ecs_get_lookup_path(
4343 const ecs_world_t *world);
4344
4346
4348
4355
4369FLECS_API
4370 ecs_entity_t ecs_component_init(
4371 ecs_world_t *world,
4372 const ecs_component_desc_t *desc);
4373
4383FLECS_API
4384 const ecs_type_info_t* ecs_get_type_info(
4385 const ecs_world_t *world,
4386 ecs_id_t component);
4387
4399FLECS_API
4400 void ecs_set_hooks_id(
4401 ecs_world_t *world,
4402 ecs_entity_t component,
4403 const ecs_type_hooks_t *hooks);
4404
4411FLECS_API
4412 const ecs_type_hooks_t* ecs_get_hooks_id(
4413 const ecs_world_t *world,
4414 ecs_entity_t component);
4415
4417
4424
4439FLECS_API
4440 bool ecs_id_is_tag(
4441 const ecs_world_t *world,
4442 ecs_id_t component);
4443
4452FLECS_API
4453 bool ecs_id_in_use(
4454 const ecs_world_t *world,
4455 ecs_id_t component);
4456
4476FLECS_API
4477 ecs_entity_t ecs_get_typeid(
4478 const ecs_world_t *world,
4479 ecs_id_t component);
4480
4489FLECS_API
4490 bool ecs_id_match(
4491 ecs_id_t component,
4492 ecs_id_t pattern);
4493
4499FLECS_API
4500 bool ecs_id_is_pair(
4501 ecs_id_t component);
4502
4508FLECS_API
4509 bool ecs_id_is_wildcard(
4510 ecs_id_t component);
4511
4517 bool ecs_id_is_any(
4518 ecs_id_t component);
4519
4533FLECS_API
4534 bool ecs_id_is_valid(
4535 const ecs_world_t *world,
4536 ecs_id_t component);
4537
4546FLECS_API
4547ecs_flags32_t ecs_id_get_flags(
4548 const ecs_world_t *world,
4549 ecs_id_t component);
4550
4561FLECS_API
4562 const char* ecs_id_flag_str(
4563 uint64_t component_flags);
4564
4580FLECS_API
4581 char* ecs_id_str(
4582 const ecs_world_t *world,
4583 ecs_id_t component);
4584
4592FLECS_API
4593 void ecs_id_str_buf(
4594 const ecs_world_t *world,
4595 ecs_id_t component,
4596 ecs_strbuf_t *buf);
4597
4606FLECS_API
4607 ecs_id_t ecs_id_from_str(
4608 const ecs_world_t *world,
4609 const char *expr);
4610
4612
4618
4626FLECS_API
4627 bool ecs_term_ref_is_set(
4628 const ecs_term_ref_t *ref);
4629
4641FLECS_API
4642 bool ecs_term_is_initialized(
4643 const ecs_term_t *term);
4644
4659FLECS_API
4660 bool ecs_term_match_this(
4661 const ecs_term_t *term);
4662
4675FLECS_API
4676 bool ecs_term_match_0(
4677 const ecs_term_t *term);
4678
4687FLECS_API
4688 char* ecs_term_str(
4689 const ecs_world_t *world,
4690 const ecs_term_t *term);
4691
4699FLECS_API
4700 char* ecs_query_str(
4701 const ecs_query_t *query);
4702
4704
4710
4743FLECS_API
4744 ecs_iter_t ecs_each_id(
4745 const ecs_world_t *world,
4746 ecs_id_t component);
4747
4753FLECS_API
4754 bool ecs_each_next(
4755 ecs_iter_t *it);
4756
4779FLECS_API
4780FLECS_ALWAYS_INLINE ecs_iter_t ecs_children(
4781 const ecs_world_t *world,
4782 ecs_entity_t parent);
4783
4791FLECS_API
4792FLECS_ALWAYS_INLINE ecs_iter_t ecs_children_w_rel(
4793 const ecs_world_t *world,
4794 ecs_entity_t relationship,
4795 ecs_entity_t parent);
4796
4802FLECS_API
4803 bool ecs_children_next(
4804 ecs_iter_t *it);
4805
4807
4814
4824FLECS_API
4825 ecs_query_t* ecs_query_init(
4826 ecs_world_t *world,
4827 const ecs_query_desc_t *desc);
4828
4839FLECS_API
4840 ecs_query_t* ecs_query_update(
4841 ecs_world_t *world,
4842 ecs_entity_t entity,
4843 const ecs_query_desc_t *desc);
4844
4849FLECS_API
4850 void ecs_query_fini(
4851 ecs_query_t *query);
4852
4861FLECS_API
4862int32_t ecs_query_find_var(
4863 const ecs_query_t *query,
4864 const char *name);
4865
4873FLECS_API
4874 const char* ecs_query_var_name(
4875 const ecs_query_t *query,
4876 int32_t var_id);
4877
4888FLECS_API
4889 bool ecs_query_var_is_entity(
4890 const ecs_query_t *query,
4891 int32_t var_id);
4892
4961FLECS_API
4962 ecs_iter_t ecs_query_iter(
4963 const ecs_world_t *world,
4964 const ecs_query_t *query);
4965
4973FLECS_API
4974 bool ecs_query_next(
4975 ecs_iter_t *it);
4976
4995FLECS_API
4996 bool ecs_query_has(
4997 const ecs_query_t *query,
4998 ecs_entity_t entity,
4999 ecs_iter_t *it);
5000
5019FLECS_API
5020 bool ecs_query_has_table(
5021 const ecs_query_t *query,
5022 ecs_table_t *table,
5023 ecs_iter_t *it);
5024
5051FLECS_API
5052 bool ecs_query_has_range(
5053 const ecs_query_t *query,
5054 ecs_table_range_t *range,
5055 ecs_iter_t *it);
5056
5064FLECS_API
5065int32_t ecs_query_match_count(
5066 const ecs_query_t *query);
5067
5077FLECS_API
5078 char* ecs_query_plan(
5079 const ecs_query_t *query);
5080
5095FLECS_API
5096 char* ecs_query_plan_w_profile(
5097 const ecs_query_t *query,
5098 const ecs_iter_t *it);
5099
5105FLECS_API
5106 char* ecs_query_plans(
5107 const ecs_query_t *query);
5108
5126FLECS_API
5127 const char* ecs_query_args_parse(
5128 ecs_query_t *query,
5129 ecs_iter_t *it,
5130 const char *expr);
5131
5154FLECS_API
5155 bool ecs_query_changed(
5156 ecs_query_t *query);
5157
5166FLECS_API
5167 const ecs_query_t* ecs_query_get(
5168 const ecs_world_t *world,
5169 ecs_entity_t query);
5170
5181FLECS_API
5182 void ecs_iter_skip(
5183 ecs_iter_t *it);
5184
5207FLECS_API
5208 void ecs_iter_set_group(
5209 ecs_iter_t *it,
5210 uint64_t group_id);
5211
5237FLECS_API
5238 const ecs_map_t* ecs_query_get_groups(
5239 const ecs_query_t *query);
5240
5249FLECS_API
5250 void* ecs_query_get_group_ctx(
5251 const ecs_query_t *query,
5252 uint64_t group_id);
5253
5262FLECS_API
5263 const ecs_query_group_info_t* ecs_query_get_group_info(
5264 const ecs_query_t *query,
5265 uint64_t group_id);
5266
5268 typedef struct ecs_query_count_t {
5269 int32_t results;
5270 int32_t entities;
5271 int32_t tables;
5274} ecs_query_count_t;
5275
5282FLECS_API
5283 ecs_query_count_t ecs_query_count(
5284 const ecs_query_t *query);
5285
5291FLECS_API
5292 bool ecs_query_is_true(
5293 const ecs_query_t *query);
5294
5303FLECS_API
5304 const ecs_query_t* ecs_query_get_cache_query(
5305 const ecs_query_t *query);
5306
5308
5315
5335FLECS_API
5336 void ecs_emit(
5337 ecs_world_t *world,
5338 ecs_event_desc_t *desc);
5339
5350FLECS_API
5351 void ecs_enqueue(
5352 ecs_world_t *world,
5353 ecs_event_desc_t *desc);
5354
5369FLECS_API
5370 ecs_entity_t ecs_observer_init(
5371 ecs_world_t *world,
5372 const ecs_observer_desc_t *desc);
5373
5389FLECS_API
5390 ecs_entity_t ecs_observer_update(
5391 ecs_world_t *world,
5392 ecs_entity_t observer,
5393 const ecs_observer_desc_t *desc);
5394
5403FLECS_API
5404 const ecs_observer_t* ecs_observer_get(
5405 const ecs_world_t *world,
5406 ecs_entity_t observer);
5407
5409
5416
5430FLECS_API
5431 bool ecs_iter_next(
5432 ecs_iter_t *it);
5433
5443FLECS_API
5444 void ecs_iter_fini(
5445 ecs_iter_t *it);
5446
5458FLECS_API
5459int32_t ecs_iter_count(
5460 ecs_iter_t *it);
5461
5474FLECS_API
5475 bool ecs_iter_is_true(
5476 ecs_iter_t *it);
5477
5485FLECS_API
5486 ecs_entity_t ecs_iter_first(
5487 ecs_iter_t *it);
5488
5527FLECS_API
5528 void ecs_iter_set_var(
5529 ecs_iter_t *it,
5530 int32_t var_id,
5531 ecs_entity_t entity);
5532
5543FLECS_API
5544 void ecs_iter_set_var_as_table(
5545 ecs_iter_t *it,
5546 int32_t var_id,
5547 const ecs_table_t *table);
5548
5559FLECS_API
5560 void ecs_iter_set_var_as_range(
5561 ecs_iter_t *it,
5562 int32_t var_id,
5563 const ecs_table_range_t *range);
5564
5577FLECS_API
5578 ecs_entity_t ecs_iter_get_var(
5579 ecs_iter_t *it,
5580 int32_t var_id);
5581
5588FLECS_API
5589 const char* ecs_iter_get_var_name(
5590 const ecs_iter_t *it,
5591 int32_t var_id);
5592
5598FLECS_API
5599int32_t ecs_iter_get_var_count(
5600 const ecs_iter_t *it);
5601
5607FLECS_API
5608ecs_var_t* ecs_iter_get_vars(
5609 const ecs_iter_t *it);
5610
5624FLECS_API
5625 ecs_table_t* ecs_iter_get_var_as_table(
5626 ecs_iter_t *it,
5627 int32_t var_id);
5628
5642FLECS_API
5643ecs_table_range_t ecs_iter_get_var_as_range(
5644 ecs_iter_t *it,
5645 int32_t var_id);
5646
5658FLECS_API
5659 bool ecs_iter_var_is_constrained(
5660 ecs_iter_t *it,
5661 int32_t var_id);
5662
5674FLECS_API
5675uint64_t ecs_iter_get_group(
5676 const ecs_iter_t *it);
5677
5689FLECS_API
5690 bool ecs_iter_changed(
5691 ecs_iter_t *it);
5692
5704FLECS_API
5705 char* ecs_iter_str(
5706 const ecs_iter_t *it);
5707
5723FLECS_API
5724 ecs_iter_t ecs_page_iter(
5725 const ecs_iter_t *it,
5726 int32_t offset,
5727 int32_t limit);
5728
5735FLECS_API
5736 bool ecs_page_next(
5737 ecs_iter_t *it);
5738
5759FLECS_API
5760 ecs_iter_t ecs_worker_iter(
5761 const ecs_iter_t *it,
5762 int32_t index,
5763 int32_t count);
5764
5771FLECS_API
5772 bool ecs_worker_next(
5773 ecs_iter_t *it);
5774
5816FLECS_API
5817 void* ecs_field_w_size(
5818 const ecs_iter_t *it,
5819 size_t size,
5820 int8_t index);
5821
5844FLECS_API
5845 void* ecs_field_at_w_size(
5846 const ecs_iter_t *it,
5847 size_t size,
5848 int8_t index,
5849 int32_t row);
5850
5859FLECS_API
5860 bool ecs_field_is_readonly(
5861 const ecs_iter_t *it,
5862 int8_t index);
5863
5874FLECS_API
5875 bool ecs_field_is_writeonly(
5876 const ecs_iter_t *it,
5877 int8_t index);
5878
5885FLECS_API
5886 bool ecs_field_is_set(
5887 const ecs_iter_t *it,
5888 int8_t index);
5889
5896FLECS_API
5897 ecs_id_t ecs_field_id(
5898 const ecs_iter_t *it,
5899 int8_t index);
5900
5909FLECS_API
5910int32_t ecs_field_column(
5911 const ecs_iter_t *it,
5912 int8_t index);
5913
5921FLECS_API
5922 ecs_entity_t ecs_field_src(
5923 const ecs_iter_t *it,
5924 int8_t index);
5925
5933FLECS_API
5934 size_t ecs_field_size(
5935 const ecs_iter_t *it,
5936 int8_t index);
5937
5951FLECS_API
5952 bool ecs_field_is_self(
5953 const ecs_iter_t *it,
5954 int8_t index);
5955
5957
5964
5971FLECS_API
5972 const ecs_type_t* ecs_table_get_type(
5973 const ecs_table_t *table);
5974
5985FLECS_API
5986int32_t ecs_table_get_type_index(
5987 const ecs_world_t *world,
5988 const ecs_table_t *table,
5989 ecs_id_t component);
5990
6000FLECS_API
6001int32_t ecs_table_get_column_index(
6002 const ecs_world_t *world,
6003 const ecs_table_t *table,
6004 ecs_id_t component);
6005
6013FLECS_API
6014int32_t ecs_table_column_count(
6015 const ecs_table_t *table);
6016
6030FLECS_API
6031int32_t ecs_table_type_to_column_index(
6032 const ecs_table_t *table,
6033 int32_t index);
6034
6043FLECS_API
6044int32_t ecs_table_column_to_type_index(
6045 const ecs_table_t *table,
6046 int32_t index);
6047
6056FLECS_API
6057 void* ecs_table_get_column(
6058 const ecs_table_t *table,
6059 int32_t index,
6060 int32_t offset);
6061
6071FLECS_API
6072 void* ecs_table_get_id(
6073 const ecs_world_t *world,
6074 const ecs_table_t *table,
6075 ecs_id_t component,
6076 int32_t offset);
6077
6085FLECS_API
6086 size_t ecs_table_get_column_size(
6087 const ecs_table_t *table,
6088 int32_t index);
6089
6096FLECS_API
6097int32_t ecs_table_count(
6098 const ecs_table_t *table);
6099
6107FLECS_API
6108int32_t ecs_table_size(
6109 const ecs_table_t *table);
6110
6117FLECS_API
6118 const ecs_entity_t* ecs_table_entities(
6119 const ecs_table_t *table);
6120
6131FLECS_API
6132 bool ecs_table_has_id(
6133 const ecs_world_t *world,
6134 const ecs_table_t *table,
6135 ecs_id_t component);
6136
6147FLECS_API
6148 ecs_entity_t ecs_table_get_target(
6149 const ecs_world_t *world,
6150 const ecs_table_t *table,
6151 ecs_entity_t relationship,
6152 int32_t index);
6153
6164FLECS_API
6165int32_t ecs_table_get_depth(
6166 const ecs_world_t *world,
6167 const ecs_table_t *table,
6168 ecs_entity_t rel);
6169
6179FLECS_API
6180 ecs_table_t* ecs_table_add_id(
6181 ecs_world_t *world,
6182 ecs_table_t *table,
6183 ecs_id_t component);
6184
6195FLECS_API
6196 ecs_table_t* ecs_table_find(
6197 ecs_world_t *world,
6198 const ecs_id_t *ids,
6199 int32_t id_count);
6200
6210FLECS_API
6211 ecs_table_t* ecs_table_remove_id(
6212 ecs_world_t *world,
6213 ecs_table_t *table,
6214 ecs_id_t component);
6215
6231FLECS_API
6232 void ecs_table_lock(
6233 ecs_world_t *world,
6234 ecs_table_t *table);
6235
6242FLECS_API
6243 void ecs_table_unlock(
6244 ecs_world_t *world,
6245 ecs_table_t *table);
6246
6256FLECS_API
6257 bool ecs_table_has_flags(
6258 ecs_table_t *table,
6259 ecs_flags32_t flags);
6260
6268FLECS_API
6269 bool ecs_table_has_traversable(
6270 const ecs_table_t *table);
6271
6281FLECS_API
6282 void ecs_table_swap_rows(
6283 ecs_world_t* world,
6284 ecs_table_t* table,
6285 int32_t row_1,
6286 int32_t row_2);
6287
6312FLECS_API
6313 bool ecs_commit(
6314 ecs_world_t *world,
6315 ecs_entity_t entity,
6316 ecs_record_t *record,
6317 ecs_table_t *table,
6318 const ecs_type_t *added,
6319 const ecs_type_t *removed);
6320
6321
6341FLECS_API
6342int32_t ecs_search(
6343 const ecs_world_t *world,
6344 const ecs_table_t *table,
6345 ecs_id_t component,
6346 ecs_id_t *component_out);
6347
6383FLECS_API
6384int32_t ecs_search_offset(
6385 const ecs_world_t *world,
6386 const ecs_table_t *table,
6387 int32_t offset,
6388 ecs_id_t component,
6389 ecs_id_t *component_out);
6390
6431FLECS_API
6432int32_t ecs_search_relation(
6433 const ecs_world_t *world,
6434 const ecs_table_t *table,
6435 int32_t offset,
6436 ecs_id_t component,
6437 ecs_entity_t rel,
6438 ecs_flags64_t flags, /* EcsSelf and/or EcsUp */
6439 ecs_entity_t *tgt_out,
6440 ecs_id_t *component_out,
6441 struct ecs_table_record_t **tr_out);
6442
6458FLECS_API
6459int32_t ecs_search_relation_for_entity(
6460 const ecs_world_t *world,
6461 ecs_entity_t entity,
6462 ecs_id_t id,
6463 ecs_entity_t rel,
6464 bool self,
6465 ecs_component_record_t *cr,
6466 ecs_entity_t *tgt_out,
6467 ecs_id_t *id_out,
6468 struct ecs_table_record_t **tr_out);
6469
6477FLECS_API
6478 void ecs_table_clear_entities(
6479 ecs_world_t* world,
6480 ecs_table_t* table);
6481
6483
6490
6498FLECS_API
6499 int ecs_value_init(
6500 const ecs_world_t *world,
6501 ecs_entity_t type,
6502 void *ptr);
6503
6511FLECS_API
6512 int ecs_value_init_w_type_info(
6513 const ecs_world_t *world,
6514 const ecs_type_info_t *ti,
6515 void *ptr);
6516
6523FLECS_API
6524 void* ecs_value_new(
6525 ecs_world_t *world,
6526 ecs_entity_t type);
6527
6534 void* ecs_value_new_w_type_info(
6535 ecs_world_t *world,
6536 const ecs_type_info_t *ti);
6537
6545 int ecs_value_fini_w_type_info(
6546 const ecs_world_t *world,
6547 const ecs_type_info_t *ti,
6548 void *ptr);
6549
6557FLECS_API
6558 int ecs_value_fini(
6559 const ecs_world_t *world,
6560 ecs_entity_t type,
6561 void* ptr);
6562
6570FLECS_API
6571 int ecs_value_free(
6572 ecs_world_t *world,
6573 ecs_entity_t type,
6574 void* ptr);
6575
6584FLECS_API
6585 int ecs_value_copy_w_type_info(
6586 const ecs_world_t *world,
6587 const ecs_type_info_t *ti,
6588 void* dst,
6589 const void *src);
6590
6599FLECS_API
6600 int ecs_value_copy(
6601 const ecs_world_t *world,
6602 ecs_entity_t type,
6603 void* dst,
6604 const void *src);
6605
6614FLECS_API
6615 int ecs_value_move_w_type_info(
6616 const ecs_world_t *world,
6617 const ecs_type_info_t *ti,
6618 void* dst,
6619 void *src);
6620
6629FLECS_API
6630 int ecs_value_move(
6631 const ecs_world_t *world,
6632 ecs_entity_t type,
6633 void* dst,
6634 void *src);
6635
6644FLECS_API
6645 int ecs_value_move_ctor_w_type_info(
6646 const ecs_world_t *world,
6647 const ecs_type_info_t *ti,
6648 void* dst,
6649 void *src);
6650
6659FLECS_API
6660 int ecs_value_move_ctor(
6661 const ecs_world_t *world,
6662 ecs_entity_t type,
6663 void* dst,
6664 void *src);
6665
6667
6669
6678
6679#include "flecs/addons/flecs_c.h"
6680
6681#ifdef __cplusplus
6682}
6683#endif
6684
6685#include "flecs/private/addons.h"
6686
6687#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:497
ecs_stage_t
struct ecs_stage_t ecs_stage_t
A stage enables modification while iterating and from multiple threads.
Definition flecs.h:432
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:481
ecs_entity_t
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:385
ecs_table_record_t
struct ecs_table_record_t ecs_table_record_t
Opaque type for table record.
Definition flecs.h:531
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:429
ecs_mixins_t
struct ecs_mixins_t ecs_mixins_t
Type that stores poly mixins.
Definition flecs.h:521
ecs_id_t
uint64_t ecs_id_t
IDs are the things that can be added to an entity.
Definition flecs.h:378
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:465
ecs_record_t
struct ecs_record_t ecs_record_t
Information about an entity, like its table and row.
Definition flecs.h:494
ecs_table_t
struct ecs_table_t ecs_table_t
A table stores entities and components for a specific type.
Definition flecs.h:435
ecs_poly_t
void ecs_poly_t
A poly object.
Definition flecs.h:518
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:641
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:621
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:683
ecs_hash_value_action_t
uint64_t(* ecs_hash_value_action_t)(const void *ptr)
Callback used for hashing values.
Definition flecs.h:659
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:634
ecs_iter_fini_action_t
void(* ecs_iter_fini_action_t)(ecs_iter_t *it)
Function prototype for freeing an iterator.
Definition flecs.h:599
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:628
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:610
ecs_iter_next_action_t
bool(* ecs_iter_next_action_t)(ecs_iter_t *it)
Function prototype for iterating an iterator.
Definition flecs.h:591
ecs_iter_action_t
void(* ecs_iter_action_t)(ecs_iter_t *it)
Function prototype for iterables.
Definition flecs.h:581
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:669
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:689
ecs_compare_action_t
int(* ecs_compare_action_t)(const void *ptr1, const void *ptr2)
Callback used for sorting values.
Definition flecs.h:654
ecs_fini_action_t
void(* ecs_fini_action_t)(ecs_world_t *world, void *ctx)
Action callback on world exit.
Definition flecs.h:645
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:676
flecs_poly_dtor_t
void(* flecs_poly_dtor_t)(ecs_poly_t *poly)
Destructor function for poly objects.
Definition flecs.h:695
ecs_run_action_t
void(* ecs_run_action_t)(ecs_iter_t *it)
Function prototype for runnables (systems, observers).
Definition flecs.h:572
ecs_ctx_free_t
void(* ecs_ctx_free_t)(void *ctx)
Function to clean up context data.
Definition flecs.h:650
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:603
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:663
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, ecs_id_t component)
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_observer_update
ecs_entity_t ecs_observer_update(ecs_world_t *world, ecs_entity_t observer, const ecs_observer_desc_t *desc)
Update an existing observer.
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:320
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:314
FLECS_TERM_COUNT_MAX
#define FLECS_TERM_COUNT_MAX
Maximum number of terms in queries.
Definition flecs.h:330
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:363
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_update
ecs_query_t * ecs_query_update(ecs_world_t *world, ecs_entity_t entity, const ecs_query_desc_t *desc)
Replace the query on an existing entity.
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:729
ecs_inout_kind_t
ecs_inout_kind_t
Specify read/write access for term.
Definition flecs.h:708
ecs_oper_kind_t
ecs_oper_kind_t
Specify operator for term.
Definition flecs.h:718
EcsQueryCacheAll
@ EcsQueryCacheAll
Require that all query terms can be cached.
Definition flecs.h:732
EcsQueryCacheDefault
@ EcsQueryCacheDefault
Behavior determined by query creation context.
Definition flecs.h:730
EcsQueryCacheNone
@ EcsQueryCacheNone
No caching.
Definition flecs.h:733
EcsQueryCacheAuto
@ EcsQueryCacheAuto
Cache query terms that are cacheable.
Definition flecs.h:731
EcsOut
@ EcsOut
Term is only written.
Definition flecs.h:714
EcsInOut
@ EcsInOut
Term is both read and written.
Definition flecs.h:712
EcsInOutFilter
@ EcsInOutFilter
Same as InOutNone + prevents term from triggering observers.
Definition flecs.h:711
EcsInOutDefault
@ EcsInOutDefault
InOut for regular terms, In for shared terms.
Definition flecs.h:709
EcsInOutNone
@ EcsInOutNone
Term is neither read nor written.
Definition flecs.h:710
EcsIn
@ EcsIn
Term is only read.
Definition flecs.h:713
EcsNot
@ EcsNot
The term must not match.
Definition flecs.h:721
EcsOptional
@ EcsOptional
The term may match.
Definition flecs.h:722
EcsOr
@ EcsOr
One of the terms in an or chain must match.
Definition flecs.h:720
EcsOrFrom
@ EcsOrFrom
Term must match at least one component from term ID.
Definition flecs.h:724
EcsAnd
@ EcsAnd
The term must match.
Definition flecs.h:719
EcsNotFrom
@ EcsNotFrom
Term must match none of the components from term ID.
Definition flecs.h:725
EcsAndFrom
@ EcsAndFrom
Term must match all components from term ID.
Definition flecs.h:723
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_entity_range_set
void ecs_entity_range_set(ecs_world_t *world, const ecs_entity_range_t *range)
Set the active entity range.
ecs_entity_range_new
const ecs_entity_range_t * ecs_entity_range_new(ecs_world_t *world, uint32_t min, uint32_t max)
Create a new entity range.
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_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_entity_range_get
const ecs_entity_range_t * ecs_entity_range_get(const ecs_world_t *world)
Get the currently active entity id range.
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_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:1600
EcsComponent::size
ecs_size_t size
Component size.
Definition flecs.h:1601
EcsComponent::alignment
ecs_size_t alignment
Component alignment.
Definition flecs.h:1602
EcsDefaultChildComponent
When added to an entity, this informs serialization formats which component to use when a value is as...
Definition flecs.h:1615
EcsDefaultChildComponent::component
ecs_id_t component
Default component ID.
Definition flecs.h:1616
EcsIdentifier
A (string) identifier.
Definition flecs.h:1591
EcsIdentifier::length
ecs_size_t length
Length of identifier.
Definition flecs.h:1593
EcsIdentifier::value
char * value
Identifier string.
Definition flecs.h:1592
EcsIdentifier::index
ecs_hashmap_t * index
Current index.
Definition flecs.h:1596
EcsIdentifier::hash
uint64_t hash
Hash of current value.
Definition flecs.h:1594
EcsIdentifier::index_hash
uint64_t index_hash
Hash of existing record in current index.
Definition flecs.h:1595
EcsParent
Non-fragmenting ChildOf relationship.
Definition flecs.h:1620
EcsParent::value
ecs_entity_t value
Parent entity.
Definition flecs.h:1621
EcsPoly
Component for storing a poly object.
Definition flecs.h:1606
EcsPoly::poly
ecs_poly_t * poly
Pointer to poly object.
Definition flecs.h:1607
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:1644
EcsTreeSpawner::data
ecs_tree_spawner_t data[(6)]
Cache data indexed by depth.
Definition flecs.h:1645
ecs_build_info_t
Type with information about the current Flecs build.
Definition flecs.h:1490
ecs_build_info_t::flags
const char ** flags
Compile-time settings.
Definition flecs.h:1493
ecs_build_info_t::version_major
int16_t version_major
Major Flecs version.
Definition flecs.h:1495
ecs_build_info_t::addons
const char ** addons
Addons included in the build.
Definition flecs.h:1492
ecs_build_info_t::version
const char * version
Stringified version.
Definition flecs.h:1494
ecs_build_info_t::compiler
const char * compiler
Compiler used to compile Flecs.
Definition flecs.h:1491
ecs_build_info_t::sanitize
bool sanitize
Is this a sanitize build?
Definition flecs.h:1499
ecs_build_info_t::perf_trace
bool perf_trace
Is this a perf tracing build?
Definition flecs.h:1500
ecs_build_info_t::version_minor
int16_t version_minor
Minor Flecs version.
Definition flecs.h:1496
ecs_build_info_t::debug
bool debug
Is this a debug build?
Definition flecs.h:1498
ecs_build_info_t::version_patch
int16_t version_patch
Patch Flecs version.
Definition flecs.h:1497
ecs_bulk_desc_t
Used with ecs_bulk_init().
Definition flecs.h:1092
ecs_bulk_desc_t::ids
ecs_id_t ids[32]
IDs to create the entities with.
Definition flecs.h:1102
ecs_bulk_desc_t::data
void ** data
Array with component data to insert.
Definition flecs.h:1104
ecs_bulk_desc_t::count
int32_t count
Number of entities to create/populate.
Definition flecs.h:1100
ecs_bulk_desc_t::_canary
int32_t _canary
Used for validity testing.
Definition flecs.h:1093
ecs_bulk_desc_t::entities
ecs_entity_t * entities
Entities to bulk insert.
Definition flecs.h:1095
ecs_bulk_desc_t::table
ecs_table_t * table
Table to insert the entities into.
Definition flecs.h:1111
ecs_component_desc_t
Used with ecs_component_init().
Definition flecs.h:1122
ecs_component_desc_t::_canary
int32_t _canary
Used for validity testing.
Definition flecs.h:1123
ecs_component_desc_t::type
ecs_type_info_t type
Parameters for type (size, hooks, ...).
Definition flecs.h:1129
ecs_component_desc_t::entity
ecs_entity_t entity
Existing entity to associate with a component (optional).
Definition flecs.h:1126
ecs_delete_empty_tables_desc_t
Used with ecs_delete_empty_tables().
Definition flecs.h:2778
ecs_delete_empty_tables_desc_t::delete_generation
uint16_t delete_generation
Delete table when generation > delete_generation.
Definition flecs.h:2783
ecs_delete_empty_tables_desc_t::time_budget_seconds
double time_budget_seconds
Amount of time operation is allowed to spend.
Definition flecs.h:2786
ecs_delete_empty_tables_desc_t::clear_generation
uint16_t clear_generation
Free table data when generation > clear_generation.
Definition flecs.h:2780
ecs_delete_empty_tables_desc_t::offset
int32_t offset
Table index to start scanning at.
Definition flecs.h:2790
ecs_entities_t
Type returned by ecs_get_entities().
Definition flecs.h:2118
ecs_entities_t::alive_count
int32_t alive_count
Number of alive entity IDs.
Definition flecs.h:2121
ecs_entities_t::count
int32_t count
Total number of entity IDs.
Definition flecs.h:2120
ecs_entities_t::ids
const ecs_entity_t * ids
Array with all entity IDs in the world.
Definition flecs.h:2119
ecs_entity_desc_t
Used with ecs_entity_init().
Definition flecs.h:1046
ecs_entity_desc_t::sep
const char * sep
Optional custom separator for hierarchical names.
Definition flecs.h:1058
ecs_entity_desc_t::root_sep
const char * root_sep
Optional, used for identifiers relative to the root.
Definition flecs.h:1062
ecs_entity_desc_t::name
const char * name
Name of the entity.
Definition flecs.h:1053
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:1074
ecs_entity_desc_t::symbol
const char * symbol
Optional entity symbol.
Definition flecs.h:1064
ecs_entity_desc_t::_canary
int32_t _canary
Used for validity testing.
Definition flecs.h:1047
ecs_entity_desc_t::add
const ecs_id_t * add
0-terminated array of IDs to add to the entity.
Definition flecs.h:1079
ecs_entity_desc_t::add_expr
const char * add_expr
String expression with components to add.
Definition flecs.h:1085
ecs_entity_desc_t::set
const ecs_value_t * set
0-terminated array of values to set on the entity.
Definition flecs.h:1082
ecs_entity_desc_t::id
ecs_entity_t id
Set to modify existing entity (optional).
Definition flecs.h:1049
ecs_entity_desc_t::parent
ecs_entity_t parent
Parent entity.
Definition flecs.h:1051
ecs_entity_range_t
Type that stores an entity id range.
Definition flecs.h:1574
ecs_entity_range_t::max
uint32_t max
Last id in range (inclusive, 0 = unlimited).
Definition flecs.h:1576
ecs_entity_range_t::cur
uint32_t cur
Last issued id in range.
Definition flecs.h:1577
ecs_entity_range_t::recycled
ecs_vec_t recycled
Recycled entity ids (vec<entity_t>).
Definition flecs.h:1578
ecs_entity_range_t::min
uint32_t min
First id in range (inclusive).
Definition flecs.h:1575
ecs_event_desc_t
Used with ecs_emit().
Definition flecs.h:1436
ecs_event_desc_t::entity
ecs_entity_t entity
Single-entity alternative to setting table / offset / count.
Definition flecs.h:1461
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:1472
ecs_event_desc_t::table
ecs_table_t * table
The table for which to notify.
Definition flecs.h:1446
ecs_event_desc_t::count
int32_t count
Limit number of notified entities to count.
Definition flecs.h:1458
ecs_event_desc_t::other_table
ecs_table_t * other_table
Optional second table to notify.
Definition flecs.h:1450
ecs_event_desc_t::offset
int32_t offset
Limit notified entities to ones starting from offset (row) in table.
Definition flecs.h:1453
ecs_event_desc_t::ids
const ecs_type_t * ids
Component IDs.
Definition flecs.h:1443
ecs_event_desc_t::observable
ecs_poly_t * observable
Observable (usually the world).
Definition flecs.h:1475
ecs_event_desc_t::event
ecs_entity_t event
The event ID.
Definition flecs.h:1438
ecs_event_desc_t::flags
ecs_flags32_t flags
Event flags.
Definition flecs.h:1478
ecs_event_desc_t::param
void * param
Optional context.
Definition flecs.h:1467
ecs_header_t
Header for ecs_poly_t objects.
Definition flecs.h:524
ecs_header_t::type
int32_t type
Magic number indicating which type of Flecs object.
Definition flecs.h:525
ecs_header_t::refcount
int32_t refcount
Refcount, to enable RAII handles.
Definition flecs.h:526
ecs_header_t::mixins
ecs_mixins_t * mixins
Table with offsets to (optional) mixins.
Definition flecs.h:527
ecs_iter_t
Iterator.
Definition flecs.h:1170
ecs_iter_t::real_world
ecs_world_t * real_world
Actual world.
Definition flecs.h:1173
ecs_iter_t::param
void * param
Param passed to ecs_run().
Definition flecs.h:1207
ecs_iter_t::event
ecs_entity_t event
The event (if applicable).
Definition flecs.h:1195
ecs_iter_t::frame_offset
int32_t frame_offset
Offset relative to the start of iteration.
Definition flecs.h:1218
ecs_iter_t::ref_fields
ecs_flags32_t ref_fields
Bitset with fields that aren't component arrays.
Definition flecs.h:1189
ecs_iter_t::interrupted_by
ecs_entity_t interrupted_by
When set, system execution is interrupted.
Definition flecs.h:1222
ecs_iter_t::flags
ecs_flags32_t flags
Iterator flags.
Definition flecs.h:1221
ecs_iter_t::chain_it
ecs_iter_t * chain_it
Optional, allows for creating iterator chains.
Definition flecs.h:1229
ecs_iter_t::ctx
void * ctx
System context.
Definition flecs.h:1208
ecs_iter_t::run_ctx
void * run_ctx
Run language binding context.
Definition flecs.h:1211
ecs_iter_t::table
ecs_table_t * table
Current table.
Definition flecs.h:1183
ecs_iter_t::offset
int32_t offset
Offset relative to the current table.
Definition flecs.h:1176
ecs_iter_t::event_id
ecs_id_t event_id
The (component) ID for the event.
Definition flecs.h:1196
ecs_iter_t::fini
ecs_iter_fini_action_t fini
Function to clean up iterator resources.
Definition flecs.h:1228
ecs_iter_t::priv_
ecs_iter_private_t priv_
Private data.
Definition flecs.h:1223
ecs_iter_t::world
ecs_world_t * world
The world.
Definition flecs.h:1172
ecs_iter_t::callback_ctx
void * callback_ctx
Callback language binding context.
Definition flecs.h:1210
ecs_iter_t::sources
ecs_entity_t * sources
Entity on which the ID was matched (0 if same as entities).
Definition flecs.h:1186
ecs_iter_t::binding_ctx
void * binding_ctx
System binding context.
Definition flecs.h:1209
ecs_iter_t::row_fields
ecs_flags32_t row_fields
Fields that must be obtained with field_at.
Definition flecs.h:1190
ecs_iter_t::delta_system_time
float delta_system_time
Time elapsed since last system invocation.
Definition flecs.h:1215
ecs_iter_t::query
const ecs_query_t * query
Query being evaluated.
Definition flecs.h:1204
ecs_iter_t::term_index
int8_t term_index
Index of the term that emitted an event.
Definition flecs.h:1201
ecs_iter_t::system
ecs_entity_t system
The system (if applicable).
Definition flecs.h:1194
ecs_iter_t::set_fields
ecs_flags32_t set_fields
Fields that are set.
Definition flecs.h:1188
ecs_iter_t::sizes
const ecs_size_t * sizes
Component sizes.
Definition flecs.h:1182
ecs_iter_t::delta_time
float delta_time
Time elapsed since last frame.
Definition flecs.h:1214
ecs_iter_t::up_fields
ecs_flags32_t up_fields
Bitset with fields matched through up traversal.
Definition flecs.h:1191
ecs_iter_t::callback
ecs_iter_action_t callback
Callback of system or observer.
Definition flecs.h:1227
ecs_iter_t::field_count
int8_t field_count
Number of fields in the iterator.
Definition flecs.h:1200
ecs_iter_t::other_table
ecs_table_t * other_table
Previous or next table when adding or removing.
Definition flecs.h:1184
ecs_iter_t::event_cur
int32_t event_cur
Unique event ID.
Definition flecs.h:1197
ecs_iter_t::trs
const ecs_table_record_t ** trs
Info on where to find the field in the table.
Definition flecs.h:1180
ecs_iter_t::count
int32_t count
Number of entities to iterate.
Definition flecs.h:1177
ecs_iter_t::ptrs
void ** ptrs
Component pointers.
Definition flecs.h:1179
ecs_iter_t::next
ecs_iter_next_action_t next
Function to progress iterator.
Definition flecs.h:1226
ecs_iter_t::entities
const ecs_entity_t * entities
Entity identifiers.
Definition flecs.h:1178
ecs_iter_t::ids
ecs_id_t * ids
(Component) IDs.
Definition flecs.h:1185
ecs_iter_t::constrained_vars
ecs_flags64_t constrained_vars
Bitset that marks constrained variables.
Definition flecs.h:1187
ecs_observer_desc_t
Used with ecs_observer_init().
Definition flecs.h:1375
ecs_observer_desc_t::run_ctx_free
ecs_ctx_free_t run_ctx_free
Callback to free run ctx.
Definition flecs.h:1424
ecs_observer_desc_t::ctx_free
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1412
ecs_observer_desc_t::run_ctx
void * run_ctx
Context associated with run (for language bindings).
Definition flecs.h:1421
ecs_observer_desc_t::entity
ecs_entity_t entity
Existing entity to associate with an observer (optional).
Definition flecs.h:1380
ecs_observer_desc_t::last_event_id
int32_t * last_event_id
Used for internal purposes.
Definition flecs.h:1427
ecs_observer_desc_t::callback_ctx
void * callback_ctx
Context associated with callback (for language bindings).
Definition flecs.h:1415
ecs_observer_desc_t::ctx
void * ctx
User context to pass to callback.
Definition flecs.h:1409
ecs_observer_desc_t::query
ecs_query_desc_t query
Query for observer.
Definition flecs.h:1383
ecs_observer_desc_t::flags_
ecs_flags32_t flags_
Used for internal purposes.
Definition flecs.h:1429
ecs_observer_desc_t::callback_ctx_free
ecs_ctx_free_t callback_ctx_free
Callback to free callback ctx.
Definition flecs.h:1418
ecs_observer_desc_t::term_index_
int8_t term_index_
Used for internal purposes.
Definition flecs.h:1428
ecs_observer_desc_t::global_observer
bool global_observer
Global observers are tied to the lifespan of the world.
Definition flecs.h:1395
ecs_observer_desc_t::callback
ecs_iter_action_t callback
Callback to invoke on an event, invoked when the observer matches.
Definition flecs.h:1398
ecs_observer_desc_t::yield_existing
bool yield_existing
When an observer is created, generate events from existing data.
Definition flecs.h:1390
ecs_observer_desc_t::run
ecs_run_action_t run
Callback invoked on an event.
Definition flecs.h:1406
ecs_observer_desc_t::events
ecs_entity_t events[8]
Events to observe (OnAdd, OnRemove, OnSet).
Definition flecs.h:1386
ecs_observer_desc_t::_canary
int32_t _canary
Used for validity testing.
Definition flecs.h:1377
ecs_observer_t
An observer reacts to events matching a query.
Definition flecs.h:879
ecs_observer_t::event_count
int32_t event_count
Number of events.
Definition flecs.h:886
ecs_observer_t::callback
ecs_iter_action_t callback
See ecs_observer_desc_t::callback.
Definition flecs.h:888
ecs_observer_t::entity
ecs_entity_t entity
Entity associated with the observer.
Definition flecs.h:902
ecs_observer_t::observable
ecs_observable_t * observable
Observable for the observer.
Definition flecs.h:899
ecs_observer_t::run
ecs_run_action_t run
See ecs_observer_desc_t::run.
Definition flecs.h:889
ecs_observer_t::hdr
ecs_header_t hdr
Object header.
Definition flecs.h:880
ecs_observer_t::ctx_free
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:895
ecs_observer_t::events
ecs_entity_t events[8]
Observer events.
Definition flecs.h:885
ecs_observer_t::run_ctx
void * run_ctx
Run language binding context.
Definition flecs.h:893
ecs_observer_t::world
ecs_world_t * world
The world.
Definition flecs.h:901
ecs_observer_t::run_ctx_free
ecs_ctx_free_t run_ctx_free
Callback to free run_ctx.
Definition flecs.h:897
ecs_observer_t::callback_ctx
void * callback_ctx
Callback language binding context.
Definition flecs.h:892
ecs_observer_t::ctx
void * ctx
Observer context.
Definition flecs.h:891
ecs_observer_t::callback_ctx_free
ecs_ctx_free_t callback_ctx_free
Callback to free callback_ctx.
Definition flecs.h:896
ecs_observer_t::query
ecs_query_t * query
Observer query.
Definition flecs.h:882
ecs_query_count_t
Struct returned by ecs_query_count().
Definition flecs.h:5268
ecs_query_count_t::entities
int32_t entities
Number of entities returned by the query.
Definition flecs.h:5270
ecs_query_count_t::results
int32_t results
Number of results returned by the query.
Definition flecs.h:5269
ecs_query_count_t::tables
int32_t tables
Number of tables returned by the query.
Definition flecs.h:5271
ecs_query_desc_t
Used with ecs_query_init().
Definition flecs.h:1301
ecs_query_desc_t::ctx_free
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1362
ecs_query_desc_t::group_by
ecs_id_t group_by
Component ID to be used for grouping.
Definition flecs.h:1332
ecs_query_desc_t::terms
ecs_term_t terms[32]
Query terms.
Definition flecs.h:1306
ecs_query_desc_t::_canary
int32_t _canary
Used for validity testing.
Definition flecs.h:1303
ecs_query_desc_t::ctx
void * ctx
User context to pass to callback.
Definition flecs.h:1356
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:1353
ecs_query_desc_t::group_by_ctx
void * group_by_ctx
Context to pass to group_by.
Definition flecs.h:1350
ecs_query_desc_t::binding_ctx
void * binding_ctx
Context to be used for language bindings.
Definition flecs.h:1359
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:1328
ecs_query_desc_t::order_by_callback
ecs_order_by_action_t order_by_callback
Callback used for ordering query results.
Definition flecs.h:1320
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:1343
ecs_query_desc_t::entity
ecs_entity_t entity
Entity associated with query (optional).
Definition flecs.h:1368
ecs_query_desc_t::binding_ctx_free
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition flecs.h:1365
ecs_query_desc_t::group_by_callback
ecs_group_by_action_t group_by_callback
Callback used for grouping results.
Definition flecs.h:1339
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:1347
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:1324
ecs_query_desc_t::flags
ecs_flags32_t flags
Flags for enabling query features.
Definition flecs.h:1315
ecs_query_desc_t::cache_kind
ecs_query_cache_kind_t cache_kind
Caching policy of the query.
Definition flecs.h:1312
ecs_query_desc_t::expr
const char * expr
Query DSL expression (optional).
Definition flecs.h:1309
ecs_query_group_info_t
Type that contains information about a query group.
Definition flecs.h:1564
ecs_query_group_info_t::table_count
int32_t table_count
Number of tables in group.
Definition flecs.h:1567
ecs_query_group_info_t::ctx
void * ctx
Group context, returned by on_group_create.
Definition flecs.h:1568
ecs_query_group_info_t::id
uint64_t id
Group ID.
Definition flecs.h:1565
ecs_query_group_info_t::match_count
int32_t match_count
How often tables have been matched or unmatched.
Definition flecs.h:1566
ecs_query_t
Queries are lists of constraints (terms) that match entities.
Definition flecs.h:838
ecs_query_t::row_fields
ecs_flags32_t row_fields
Fields that must be acquired with field_at.
Definition flecs.h:858
ecs_query_t::data_fields
ecs_flags32_t data_fields
Fields that have data.
Definition flecs.h:855
ecs_query_t::read_fields
ecs_flags32_t read_fields
Fields that read data.
Definition flecs.h:857
ecs_query_t::hdr
ecs_header_t hdr
Object header.
Definition flecs.h:839
ecs_query_t::var_count
int8_t var_count
Number of query variables.
Definition flecs.h:847
ecs_query_t::fixed_fields
ecs_flags32_t fixed_fields
Bitmasks for quick field information lookups.
Definition flecs.h:852
ecs_query_t::var_fields
ecs_flags32_t var_fields
Fields with non-$this variable source.
Definition flecs.h:853
ecs_query_t::write_fields
ecs_flags32_t write_fields
Fields that write data.
Definition flecs.h:856
ecs_query_t::eval_count
int32_t eval_count
Number of times the query is evaluated.
Definition flecs.h:873
ecs_query_t::world
ecs_world_t * world
World or stage the query was created with.
Definition flecs.h:871
ecs_query_t::static_id_fields
ecs_flags32_t static_id_fields
Fields with a static (component) id.
Definition flecs.h:854
ecs_query_t::bloom_filter
uint64_t bloom_filter
Bitmask used to quickly discard tables.
Definition flecs.h:845
ecs_query_t::real_world
ecs_world_t * real_world
Actual world.
Definition flecs.h:870
ecs_query_t::set_fields
ecs_flags32_t set_fields
Fields that will be set.
Definition flecs.h:860
ecs_query_t::entity
ecs_entity_t entity
Entity associated with query (optional).
Definition flecs.h:869
ecs_query_t::ctx
void * ctx
User context to pass to callback.
Definition flecs.h:866
ecs_query_t::sizes
int32_t * sizes
Component sizes.
Definition flecs.h:842
ecs_query_t::ids
ecs_id_t * ids
Component ids.
Definition flecs.h:843
ecs_query_t::shared_readonly_fields
ecs_flags32_t shared_readonly_fields
Fields that don't write shared data.
Definition flecs.h:859
ecs_query_t::terms
ecs_term_t * terms
Query terms.
Definition flecs.h:841
ecs_query_t::cache_kind
ecs_query_cache_kind_t cache_kind
Caching policy of the query.
Definition flecs.h:862
ecs_query_t::term_count
int8_t term_count
Number of query terms.
Definition flecs.h:848
ecs_query_t::vars
char ** vars
Array with variable names for the iterator.
Definition flecs.h:864
ecs_query_t::field_count
int8_t field_count
Number of fields returned by the query.
Definition flecs.h:849
ecs_query_t::flags
ecs_flags32_t flags
Query flags.
Definition flecs.h:846
ecs_query_t::binding_ctx
void * binding_ctx
Context to be used for language bindings.
Definition flecs.h:867
ecs_term_ref_t
Type that describes a reference to an entity or variable in a term.
Definition flecs.h:799
ecs_term_ref_t::name
const char * name
Name.
Definition flecs.h:806
ecs_term_ref_t::id
ecs_entity_t id
Entity ID.
Definition flecs.h:800
ecs_term_t
Type that describes a term (single element in a query).
Definition flecs.h:814
ecs_term_t::src
ecs_term_ref_t src
Source of term.
Definition flecs.h:820
ecs_term_t::field_index
int8_t field_index
Index of the field for the term in the iterator.
Definition flecs.h:831
ecs_term_t::id
ecs_id_t id
Component ID to be matched by term.
Definition flecs.h:815
ecs_term_t::oper
int16_t oper
Operator of term.
Definition flecs.h:829
ecs_term_t::second
ecs_term_ref_t second
Second element of pair.
Definition flecs.h:822
ecs_term_t::flags_
ecs_flags16_t flags_
Flags that help evaluation, set by ecs_query_init().
Definition flecs.h:832
ecs_term_t::trav
ecs_entity_t trav
Relationship to traverse when looking for the component.
Definition flecs.h:824
ecs_term_t::inout
int16_t inout
Access to contents matched by term.
Definition flecs.h:828
ecs_term_t::first
ecs_term_ref_t first
Component or first element of pair.
Definition flecs.h:821
ecs_tree_spawner_child_t
Component with data to instantiate a non-fragmenting tree.
Definition flecs.h:1625
ecs_tree_spawner_child_t::child
uint32_t child
Prefab child entity (without generation).
Definition flecs.h:1628
ecs_tree_spawner_child_t::parent_index
int32_t parent_index
Index into the children vector.
Definition flecs.h:1629
ecs_tree_spawner_child_t::child_name
const char * child_name
Name of the prefab child.
Definition flecs.h:1626
ecs_tree_spawner_child_t::table
ecs_table_t * table
Table in which the child will be stored.
Definition flecs.h:1627
ecs_tree_spawner_t
Tree spawner data for a single hierarchy depth.
Definition flecs.h:1633
ecs_tree_spawner_t::children
ecs_vec_t children
vector<ecs_tree_spawner_child_t>.
Definition flecs.h:1634
ecs_type_hooks_t
Definition flecs.h:954
ecs_type_hooks_t::copy_ctor
ecs_copy_t copy_ctor
Ctor + copy.
Definition flecs.h:961
ecs_type_hooks_t::lifecycle_ctx
void * lifecycle_ctx
Component lifecycle context (see meta addon).
Definition flecs.h:1012
ecs_type_hooks_t::ctx
void * ctx
User-defined context.
Definition flecs.h:1010
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:1002
ecs_type_hooks_t::binding_ctx
void * binding_ctx
Language binding context.
Definition flecs.h:1011
ecs_type_hooks_t::move_dtor
ecs_move_t move_dtor
Move + dtor.
Definition flecs.h:976
ecs_type_hooks_t::flags
ecs_flags32_t flags
Hook flags.
Definition flecs.h:988
ecs_type_hooks_t::cmp
ecs_cmp_t cmp
Compare hook.
Definition flecs.h:979
ecs_type_hooks_t::copy
ecs_copy_t copy
copy assignment.
Definition flecs.h:957
ecs_type_hooks_t::lifecycle_ctx_free
ecs_ctx_free_t lifecycle_ctx_free
Callback to free lifecycle_ctx.
Definition flecs.h:1016
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:997
ecs_type_hooks_t::move
ecs_move_t move
move assignment.
Definition flecs.h:958
ecs_type_hooks_t::ctor
ecs_xtor_t ctor
ctor.
Definition flecs.h:955
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:1008
ecs_type_hooks_t::ctx_free
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1014
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:992
ecs_type_hooks_t::binding_ctx_free
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition flecs.h:1015
ecs_type_hooks_t::move_ctor
ecs_move_t move_ctor
Ctor + move.
Definition flecs.h:964
ecs_type_hooks_t::equals
ecs_equals_t equals
Equals hook.
Definition flecs.h:982
ecs_type_hooks_t::ctor_move_dtor
ecs_move_t ctor_move_dtor
Ctor + move + dtor (or move_ctor + dtor).
Definition flecs.h:970
ecs_type_hooks_t::dtor
ecs_xtor_t dtor
dtor.
Definition flecs.h:956
ecs_type_info_t
Type that contains component information (passed to ctors/dtors/...).
Definition flecs.h:1023
ecs_type_info_t::alignment
ecs_size_t alignment
Alignment of the type.
Definition flecs.h:1025
ecs_type_info_t::size
ecs_size_t size
Size of the type.
Definition flecs.h:1024
ecs_type_info_t::name
const char * name
Type name.
Definition flecs.h:1028
ecs_type_info_t::component
ecs_entity_t component
Handle to component (do not set).
Definition flecs.h:1027
ecs_type_info_t::hooks
ecs_type_hooks_t hooks
Type hooks.
Definition flecs.h:1026
ecs_type_t
A type is a list of (component) IDs.
Definition flecs.h:402
ecs_type_t::array
ecs_id_t * array
Array with IDs.
Definition flecs.h:403
ecs_type_t::count
int32_t count
Number of elements in array.
Definition flecs.h:404
ecs_value_t
Utility to hold a value of a dynamic type.
Definition flecs.h:1037
ecs_value_t::ptr
void * ptr
Pointer to value.
Definition flecs.h:1039
ecs_value_t::type
ecs_entity_t type
Type of value.
Definition flecs.h:1038
ecs_world_info_t
Type that contains information about the world.
Definition flecs.h:1504
ecs_world_info_t::observers_ran_total
int64_t observers_ran_total
Total number of times an observer was invoked.
Definition flecs.h:1530
ecs_world_info_t::delta_time
float delta_time
Time passed to or computed by ecs_progress().
Definition flecs.h:1508
ecs_world_info_t::systems_ran_total
int64_t systems_ran_total
Total number of systems run.
Definition flecs.h:1529
ecs_world_info_t::set_count
int64_t set_count
Set commands processed.
Definition flecs.h:1547
ecs_world_info_t::world_time_total
double world_time_total
Time elapsed in simulation.
Definition flecs.h:1516
ecs_world_info_t::tag_id_count
int32_t tag_id_count
Number of tag (no data) IDs in the world.
Definition flecs.h:1533
ecs_world_info_t::component_id_count
int32_t component_id_count
Number of component (data) IDs in the world.
Definition flecs.h:1534
ecs_world_info_t::pipeline_build_count_total
int64_t pipeline_build_count_total
Total number of pipeline builds.
Definition flecs.h:1528
ecs_world_info_t::eval_comp_monitors_total
int64_t eval_comp_monitors_total
Total number of monitor evaluations.
Definition flecs.h:1521
ecs_world_info_t::table_count
int32_t table_count
Number of tables.
Definition flecs.h:1537
ecs_world_info_t::delta_time_raw
float delta_time_raw
Raw delta time (no time scaling).
Definition flecs.h:1507
ecs_world_info_t::frame_time_total
float frame_time_total
Total time spent processing a frame.
Definition flecs.h:1511
ecs_world_info_t::table_create_total
int64_t table_create_total
Total number of times a table was created.
Definition flecs.h:1526
ecs_world_info_t::system_time_total
float system_time_total
Total time spent in systems.
Definition flecs.h:1512
ecs_world_info_t::id_delete_total
int64_t id_delete_total
Total number of times an ID was deleted.
Definition flecs.h:1525
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:1514
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:1550
ecs_world_info_t::clear_count
int64_t clear_count
Clear commands processed.
Definition flecs.h:1546
ecs_world_info_t::last_component_id
ecs_entity_t last_component_id
Last issued component entity ID.
Definition flecs.h:1505
ecs_world_info_t::frame_count_total
int64_t frame_count_total
Total number of frames.
Definition flecs.h:1519
ecs_world_info_t::merge_count_total
int64_t merge_count_total
Total number of merges.
Definition flecs.h:1520
ecs_world_info_t::other_count
int64_t other_count
Other commands processed.
Definition flecs.h:1552
ecs_world_info_t::batched_command_count
int64_t batched_command_count
Commands batched.
Definition flecs.h:1554
ecs_world_info_t::table_delete_total
int64_t table_delete_total
Total number of times a table was deleted.
Definition flecs.h:1527
ecs_world_info_t::queries_ran_total
int64_t queries_ran_total
Total number of times a query was evaluated.
Definition flecs.h:1531
ecs_world_info_t::delete_count
int64_t delete_count
Delete commands processed.
Definition flecs.h:1545
ecs_world_info_t::rematch_count_total
int64_t rematch_count_total
Total number of rematches.
Definition flecs.h:1522
ecs_world_info_t::id_create_total
int64_t id_create_total
Total number of times a new ID was created.
Definition flecs.h:1524
ecs_world_info_t::batched_entity_count
int64_t batched_entity_count
Entities for which commands were batched.
Definition flecs.h:1553
ecs_world_info_t::time_scale
float time_scale
Time scale applied to delta_time.
Definition flecs.h:1509
ecs_world_info_t::pair_id_count
int32_t pair_id_count
Number of pair IDs in the world.
Definition flecs.h:1535
ecs_world_info_t::rematch_time_total
float rematch_time_total
Time spent on query rematching.
Definition flecs.h:1515
ecs_world_info_t::ensure_count
int64_t ensure_count
Ensure or emplace commands processed.
Definition flecs.h:1548
ecs_world_info_t::target_fps
float target_fps
Target FPS.
Definition flecs.h:1510
ecs_world_info_t::world_time_total_raw
double world_time_total_raw
Time elapsed in simulation (no scaling).
Definition flecs.h:1517
ecs_world_info_t::emit_time_total
float emit_time_total
Total time spent notifying observers.
Definition flecs.h:1513
ecs_world_info_t::creation_time
uint32_t creation_time
Time when world was created.
Definition flecs.h:1539
ecs_world_info_t::modified_count
int64_t modified_count
Modified commands processed.
Definition flecs.h:1549
ecs_world_info_t::name_prefix
const char * name_prefix
Value set by ecs_set_name_prefix().
Definition flecs.h:1557
ecs_world_info_t::event_count
int64_t event_count
Enqueued custom events.
Definition flecs.h:1551
ecs_world_info_t::add_count
int64_t add_count
Add commands processed.
Definition flecs.h:1543
ecs_world_info_t::remove_count
int64_t remove_count
Remove commands processed.
Definition flecs.h:1544