Flecs v3.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs.h
Go to the documentation of this file.
1
8#ifndef FLECS_H
9#define FLECS_H
10
34#ifndef ecs_float_t
35#define ecs_float_t float
36#endif
37
41#ifndef ecs_ftime_t
42#define ecs_ftime_t ecs_float_t
43#endif
44
48// #define FLECS_LEGACY
49
53#define FLECS_NO_DEPRECATED_WARNINGS
54
60// #define FLECS_ACCURATE_COUNTERS
61
62/* Make sure provided configuration is valid */
63#if defined(FLECS_DEBUG) && defined(FLECS_NDEBUG)
64#error "invalid configuration: cannot both define FLECS_DEBUG and FLECS_NDEBUG"
65#endif
66#if defined(FLECS_DEBUG) && defined(NDEBUG)
67#error "invalid configuration: cannot both define FLECS_DEBUG and NDEBUG"
68#endif
69
74#if !defined(FLECS_DEBUG) && !defined(FLECS_NDEBUG)
75#if defined(NDEBUG)
76#define FLECS_NDEBUG
77#else
78#define FLECS_DEBUG
79#endif
80#endif
81
86#ifdef FLECS_SANITIZE
87#define FLECS_DEBUG /* If sanitized mode is enabled, so is debug mode */
88#endif
89
90/* Tip: if you see weird behavior that you think might be a bug, make sure to
91 * test with the FLECS_DEBUG or FLECS_SANITIZE flags enabled. There's a good
92 * chance that this gives you more information about the issue! */
93
107// #define FLECS_SOFT_ASSERT
108
114// #define FLECS_KEEP_ASSERT
115
139// #define FLECS_CUSTOM_BUILD
140
141#ifndef FLECS_CUSTOM_BUILD
142// #define FLECS_C /**< C API convenience macros, always enabled */
143#define FLECS_CPP
144#define FLECS_MODULE
145#define FLECS_PARSER
146#define FLECS_PLECS
147#define FLECS_RULES
148#define FLECS_SNAPSHOT
149#define FLECS_STATS
150#define FLECS_MONITOR
151#define FLECS_SYSTEM
152#define FLECS_PIPELINE
153#define FLECS_TIMER
154#define FLECS_META
155#define FLECS_META_C
156#define FLECS_UNITS
157#define FLECS_EXPR
158#define FLECS_JSON
159#define FLECS_DOC
160#define FLECS_COREDOC
161#define FLECS_LOG
162#define FLECS_APP
163#define FLECS_OS_API_IMPL
164#define FLECS_HTTP
165#define FLECS_REST
166// #define FLECS_JOURNAL /**< Journaling addon (disabled by default) */
167#endif // ifndef FLECS_CUSTOM_BUILD
168
171#ifndef ECS_ID_CACHE_SIZE
172#define ECS_ID_CACHE_SIZE (32)
173#endif
174
177#define ECS_TERM_DESC_CACHE_SIZE (16)
178
181#define ECS_OBSERVER_DESC_EVENT_COUNT_MAX (8)
182
185#define ECS_VARIABLE_COUNT_MAX (64)
186
189#include "flecs/private/api_defines.h"
190#include "flecs/private/vector.h" /* Vector datatype */
191#include "flecs/private/vec.h" /* Vector datatype */
192#include "flecs/private/sparse.h" /* Sparse set */
193#include "flecs/private/block_allocator.h" /* Block allocator */
194#include "flecs/private/map.h" /* Map */
195#include "flecs/private/allocator.h" /* Allocator */
196#include "flecs/private/strbuf.h" /* String builder */
197#include "flecs/os_api.h" /* Abstraction for operating system functions */
198
199#ifdef __cplusplus
200extern "C" {
201#endif
202
217typedef uint64_t ecs_id_t;
218
221
223typedef struct {
224 ecs_id_t *array;
225 int32_t count;
226} ecs_type_t;
227
230
233
235typedef struct ecs_term_t ecs_term_t;
236
239
242
244typedef struct ecs_rule_t ecs_rule_t;
245
248
251
252/* An iterator lets an application iterate entities across tables. */
253typedef struct ecs_iter_t ecs_iter_t;
254
256typedef struct ecs_ref_t ecs_ref_t;
257
260
263
264/* Internal index that stores tables tables for a (component) id */
265typedef struct ecs_id_record_t ecs_id_record_t;
266
267/* Internal table storage record */
268typedef struct ecs_table_record_t ecs_table_record_t;
269
292typedef void ecs_poly_t;
293
296
298typedef struct ecs_header_t {
299 int32_t magic; /* Magic number verifying it's a flecs object */
300 int32_t type; /* Magic number indicating which type of flecs object */
301 ecs_mixins_t *mixins; /* Table with offsets to (optional) mixins */
303
321typedef void (*ecs_run_action_t)(
322 ecs_iter_t *it);
323
330typedef void (*ecs_iter_action_t)(
331 ecs_iter_t *it);
332
345 const ecs_world_t *world,
346 const ecs_poly_t *iterable,
347 ecs_iter_t *it,
348 ecs_term_t *filter);
349
358 ecs_iter_t *it);
359
366 ecs_iter_t *it);
367
370 ecs_entity_t e1,
371 const void *ptr1,
372 ecs_entity_t e2,
373 const void *ptr2);
374
377 ecs_world_t* world,
378 ecs_table_t* table,
379 ecs_entity_t* entities,
380 void* ptr,
381 int32_t size,
382 int32_t lo,
383 int32_t hi,
384 ecs_order_by_action_t order_by);
385
387typedef uint64_t (*ecs_group_by_action_t)(
388 ecs_world_t *world,
389 ecs_table_t *table,
390 ecs_id_t group_id,
391 void *ctx);
392
393/* Callback invoked when a query creates a new group. */
394typedef void* (*ecs_group_create_action_t)(
395 ecs_world_t *world,
396 uint64_t group_id,
397 void *group_by_ctx); /* from ecs_query_desc_t */
398
399/* Callback invoked when a query deletes an existing group. */
400typedef void (*ecs_group_delete_action_t)(
401 ecs_world_t *world,
402 uint64_t group_id,
403 void *group_ctx, /* return value from ecs_group_create_action_t */
404 void *group_by_ctx); /* from ecs_query_desc_t */
405
407typedef void (*ecs_module_action_t)(
408 ecs_world_t *world);
409
411typedef void (*ecs_fini_action_t)(
412 ecs_world_t *world,
413 void *ctx);
414
416typedef void (*ecs_ctx_free_t)(
417 void *ctx);
418
420typedef int (*ecs_compare_action_t)(
421 const void *ptr1,
422 const void *ptr2);
423
425typedef uint64_t (*ecs_hash_value_action_t)(
426 const void *ptr);
427
429typedef void (*ecs_xtor_t)(
430 void *ptr,
431 int32_t count,
432 const ecs_type_info_t *type_info);
433
435typedef void (*ecs_copy_t)(
436 void *dst_ptr,
437 const void *src_ptr,
438 int32_t count,
439 const ecs_type_info_t *type_info);
440
442typedef void (*ecs_move_t)(
443 void *dst_ptr,
444 void *src_ptr,
445 int32_t count,
446 const ecs_type_info_t *type_info);
447
448/* Destructor function for poly objects */
449typedef void (*ecs_poly_dtor_t)(
450 ecs_poly_t *poly);
451
462typedef struct ecs_iterable_t {
465
475typedef enum ecs_inout_kind_t {
482
484typedef enum ecs_oper_kind_t {
493
494#define EcsSelf (1u << 1)
495#define EcsUp (1u << 2)
496#define EcsDown (1u << 3)
497#define EcsTraverseAll (1u << 4)
498#define EcsCascade (1u << 5)
499#define EcsParent (1u << 6)
500#define EcsIsVariable (1u << 7)
501#define EcsIsEntity (1u << 8)
502#define EcsFilter (1u << 9)
504#define EcsTraverseFlags (EcsUp|EcsDown|EcsTraverseAll|EcsSelf|EcsCascade|EcsParent)
505
507typedef struct ecs_term_id_t {
514 char *name;
525 ecs_flags32_t flags;
527
543 char *name;
545 int32_t field_index;
546 ecs_id_record_t *idr;
548 bool move;
549};
550
552FLECS_API extern ecs_filter_t ECS_FILTER_INIT;
553
556 ecs_header_t hdr;
557
559 int32_t term_count;
560 int32_t field_count;
562 bool owned;
565 ecs_flags32_t flags;
567 char *variable_names[1];
569 /* Mixins */
571 ecs_world_t *world;
573 ecs_poly_dtor_t dtor;
574};
575
576/* An observer reacts to events matching a filter */
578 ecs_header_t hdr;
579
582 /* Observer events */
584 int32_t event_count;
585
589 void *ctx;
597 int32_t *last_event_id;
598 int32_t last_event_id_storage;
599
601 int32_t term_index;
607 bool is_multi;
609 /* Mixins */
610 ecs_poly_dtor_t dtor;
611};
612
627
630
636
642
646
651
656
657 void *ctx;
662};
663
669 ecs_size_t size;
670 ecs_size_t alignment;
673 const char *name;
674};
675
676#include "flecs/private/api_types.h" /* Supporting API types */
677#include "flecs/private/api_support.h" /* Supporting API functions */
678#include "flecs/private/vec.h" /* Vector */
679#include "flecs/private/hashmap.h" /* Hashmap */
680
685typedef struct ecs_entity_desc_t {
686 int32_t _canary;
687
690 const char *name;
695 const char *sep;
699 const char *root_sep;
701 const char *symbol;
717
719 const char *add_expr;
721
726typedef struct ecs_bulk_desc_t {
727 int32_t _canary;
728
734 int32_t count;
738 void **data;
751
756typedef struct ecs_component_desc_t {
757 int32_t _canary;
758
761
765
770typedef struct ecs_filter_desc_t {
771 int32_t _canary;
772
776
779
782
785
792
794 ecs_flags32_t flags;
795
797 const char *expr;
798
802
807typedef struct ecs_query_desc_t {
808 int32_t _canary;
809
812
815
820
824
829
836
839 ecs_group_create_action_t on_group_create;
840
843 ecs_group_delete_action_t on_group_delete;
844
847
850
859
864typedef struct ecs_observer_desc_t {
865 int32_t _canary;
866
869
872
875
880
883
891
893 void *ctx;
894
897
900
903
906
910
912 int32_t term_index;
914
921/* Utility to hold a value of a dynamic type */
922typedef struct ecs_value_t {
923 ecs_entity_t type;
924 void *ptr;
926
928typedef struct ecs_world_info_t {
958 int32_t id_count;
959 int32_t tag_id_count;
964 int32_t table_count;
971 /* -- Command counts -- */
972 struct {
973 int64_t add_count;
974 int64_t remove_count;
975 int64_t delete_count;
976 int64_t clear_count;
977 int64_t set_count;
980 int64_t other_count;
984 } cmd;
985
986 const char *name_prefix;
991
994 int32_t match_count;
995 int32_t table_count;
996 void *ctx;
998
1008typedef struct EcsIdentifier {
1009 char *value;
1010 ecs_size_t length;
1011 uint64_t hash;
1012 uint64_t index_hash;
1013 ecs_hashmap_t *index;
1015
1017typedef struct EcsComponent {
1018 ecs_size_t size;
1019 ecs_size_t alignment;
1021
1023typedef struct EcsPoly {
1026
1029
1033/* Only include deprecated definitions if deprecated addon is required */
1034#ifdef FLECS_DEPRECATED
1036#endif
1037
1051#define ECS_ID_FLAG_BIT (1ull << 63)
1052
1054FLECS_API extern const ecs_id_t ECS_PAIR;
1055
1057FLECS_API extern const ecs_id_t ECS_OVERRIDE;
1058
1060FLECS_API extern const ecs_id_t ECS_TOGGLE;
1061
1063FLECS_API extern const ecs_id_t ECS_AND;
1064
1072/* Builtin component ids */
1073FLECS_API extern const ecs_entity_t ecs_id(EcsComponent);
1074FLECS_API extern const ecs_entity_t ecs_id(EcsIdentifier);
1075FLECS_API extern const ecs_entity_t ecs_id(EcsIterable);
1076FLECS_API extern const ecs_entity_t ecs_id(EcsPoly);
1077
1078FLECS_API extern const ecs_entity_t EcsQuery;
1079FLECS_API extern const ecs_entity_t EcsObserver;
1080
1081/* System module component ids */
1082FLECS_API extern const ecs_entity_t EcsSystem;
1083FLECS_API extern const ecs_entity_t ecs_id(EcsTickSource);
1084
1085/* Pipeline module component ids */
1086FLECS_API extern const ecs_entity_t ecs_id(EcsPipelineQuery);
1087
1088/* Timer module component ids */
1089FLECS_API extern const ecs_entity_t ecs_id(EcsTimer);
1090FLECS_API extern const ecs_entity_t ecs_id(EcsRateFilter);
1091
1093FLECS_API extern const ecs_entity_t EcsFlecs;
1094
1096FLECS_API extern const ecs_entity_t EcsFlecsCore;
1097
1099FLECS_API extern const ecs_entity_t EcsWorld;
1100
1102FLECS_API extern const ecs_entity_t EcsWildcard;
1103
1105FLECS_API extern const ecs_entity_t EcsAny;
1106
1108FLECS_API extern const ecs_entity_t EcsThis;
1109
1111FLECS_API extern const ecs_entity_t EcsVariable;
1112
1117FLECS_API extern const ecs_entity_t EcsTransitive;
1118
1123FLECS_API extern const ecs_entity_t EcsReflexive;
1124
1132FLECS_API extern const ecs_entity_t EcsFinal;
1133
1139FLECS_API extern const ecs_entity_t EcsDontInherit;
1140
1145FLECS_API extern const ecs_entity_t EcsSymmetric;
1146
1153FLECS_API extern const ecs_entity_t EcsExclusive;
1154
1156FLECS_API extern const ecs_entity_t EcsAcyclic;
1157
1160FLECS_API extern const ecs_entity_t EcsTraversable;
1161
1168FLECS_API extern const ecs_entity_t EcsWith;
1169
1176FLECS_API extern const ecs_entity_t EcsOneOf;
1177
1180FLECS_API extern const ecs_entity_t EcsTag;
1181
1185FLECS_API extern const ecs_entity_t EcsUnion;
1186
1188FLECS_API extern const ecs_entity_t EcsName;
1189
1191FLECS_API extern const ecs_entity_t EcsSymbol;
1192
1194FLECS_API extern const ecs_entity_t EcsAlias;
1195
1197FLECS_API extern const ecs_entity_t EcsChildOf;
1198
1200FLECS_API extern const ecs_entity_t EcsIsA;
1201
1203FLECS_API extern const ecs_entity_t EcsDependsOn;
1204
1206FLECS_API extern const ecs_entity_t EcsSlotOf;
1207
1209FLECS_API extern const ecs_entity_t EcsModule;
1210
1212FLECS_API extern const ecs_entity_t EcsPrivate;
1213
1216FLECS_API extern const ecs_entity_t EcsPrefab;
1217
1219FLECS_API extern const ecs_entity_t EcsDisabled;
1220
1222FLECS_API extern const ecs_entity_t EcsOnAdd;
1223
1225FLECS_API extern const ecs_entity_t EcsOnRemove;
1226
1228FLECS_API extern const ecs_entity_t EcsOnSet;
1229
1231FLECS_API extern const ecs_entity_t EcsUnSet;
1232
1234FLECS_API extern const ecs_entity_t EcsMonitor;
1235
1240FLECS_API extern const ecs_entity_t EcsOnDelete;
1241
1243FLECS_API extern const ecs_entity_t EcsOnTableCreate;
1244
1246FLECS_API extern const ecs_entity_t EcsOnTableDelete;
1247
1249FLECS_API extern const ecs_entity_t EcsOnTableEmpty;
1250
1252FLECS_API extern const ecs_entity_t EcsOnTableFill;
1253
1258FLECS_API extern const ecs_entity_t EcsOnDeleteTarget;
1259
1262FLECS_API extern const ecs_entity_t EcsRemove;
1263
1266FLECS_API extern const ecs_entity_t EcsDelete;
1267
1270FLECS_API extern const ecs_entity_t EcsPanic;
1271
1277FLECS_API extern const ecs_entity_t EcsDefaultChildComponent;
1278
1280FLECS_API extern const ecs_entity_t EcsEmpty;
1281
1282/* Pipeline module tags */
1283FLECS_API extern const ecs_entity_t ecs_id(EcsPipeline);
1284FLECS_API extern const ecs_entity_t EcsOnStart;
1285FLECS_API extern const ecs_entity_t EcsPreFrame;
1286FLECS_API extern const ecs_entity_t EcsOnLoad;
1287FLECS_API extern const ecs_entity_t EcsPostLoad;
1288FLECS_API extern const ecs_entity_t EcsPreUpdate;
1289FLECS_API extern const ecs_entity_t EcsOnUpdate;
1290FLECS_API extern const ecs_entity_t EcsOnValidate;
1291FLECS_API extern const ecs_entity_t EcsPostUpdate;
1292FLECS_API extern const ecs_entity_t EcsPreStore;
1293FLECS_API extern const ecs_entity_t EcsOnStore;
1294FLECS_API extern const ecs_entity_t EcsPostFrame;
1295FLECS_API extern const ecs_entity_t EcsPhase;
1296
1299#define EcsLastInternalComponentId (ecs_id(EcsPoly))
1300
1303#define EcsFirstUserComponentId (8)
1304
1307#define EcsFirstUserEntityId (ECS_HI_COMPONENT_ID + 128)
1308
1332FLECS_API
1334
1339FLECS_API
1341
1349FLECS_API
1351 int argc,
1352 char *argv[]);
1353
1360FLECS_API
1362 ecs_world_t *world);
1363
1369FLECS_API
1371 const ecs_world_t *world);
1372
1380FLECS_API
1382 ecs_world_t *world,
1383 ecs_fini_action_t action,
1384 void *ctx);
1385
1411FLECS_API
1413 ecs_world_t *world,
1414 ecs_ftime_t delta_time);
1415
1422FLECS_API
1424 ecs_world_t *world);
1425
1433FLECS_API
1435 ecs_world_t *world,
1436 ecs_fini_action_t action,
1437 void *ctx);
1438
1445FLECS_API
1447 ecs_world_t *world);
1448
1453FLECS_API
1455 const ecs_world_t *world);
1456
1469 ecs_world_t *world,
1470 bool enable);
1471
1483 ecs_world_t *world,
1484 bool enable);
1485
1501FLECS_API
1503 ecs_world_t *world,
1504 ecs_ftime_t fps);
1505
1542FLECS_API
1544 ecs_world_t *world);
1545
1553FLECS_API
1555 ecs_world_t *world);
1556
1567FLECS_API
1569 ecs_world_t *world);
1570
1580FLECS_API
1582 ecs_world_t *world);
1583
1589FLECS_API
1591 const ecs_world_t *world);
1592
1601FLECS_API
1603 ecs_world_t *world);
1604
1614FLECS_API
1616 ecs_world_t *world);
1617
1623FLECS_API
1625 ecs_world_t *world);
1626
1643FLECS_API
1645 ecs_world_t *world,
1646 bool automerge);
1647
1661FLECS_API
1663 ecs_world_t *world,
1664 int32_t stages);
1665
1672FLECS_API
1674 const ecs_world_t *world);
1675
1683FLECS_API
1685 const ecs_world_t *world);
1686
1702FLECS_API
1704 const ecs_world_t *world,
1705 int32_t stage_id);
1706
1714FLECS_API
1716 const ecs_world_t *world);
1717
1736FLECS_API
1738 ecs_world_t *world);
1739
1746FLECS_API
1748 ecs_world_t *stage);
1749
1756FLECS_API
1758 ecs_world_t *stage);
1759
1774FLECS_API
1776 ecs_world_t *world,
1777 void *ctx);
1778
1786FLECS_API
1788 const ecs_world_t *world);
1789
1796FLECS_API
1798 const ecs_world_t *world);
1799
1808FLECS_API
1810 ecs_world_t *world,
1811 int32_t entity_count);
1812
1828FLECS_API
1830 ecs_world_t *world,
1831 ecs_entity_t id_start,
1832 ecs_entity_t id_end);
1833
1844FLECS_API
1846 ecs_world_t *world,
1847 bool enable);
1848
1862FLECS_API
1864 ecs_world_t *world,
1865 ecs_flags32_t flags);
1866
1900FLECS_API
1902 ecs_world_t *world,
1903 ecs_id_t id,
1904 uint16_t clear_generation,
1905 uint16_t delete_generation,
1906 int32_t min_id_count,
1907 double time_budget_seconds);
1908
1914FLECS_API
1916 const ecs_poly_t *poly);
1917
1923FLECS_API
1925 const ecs_poly_t *poly);
1926
1937FLECS_API
1939 const ecs_poly_t *object,
1940 int32_t type);
1941
1942#define ecs_poly_is(object, type)\
1943 _ecs_poly_is(object, type##_magic)
1944
1952FLECS_API
1954 ecs_entity_t first,
1955 ecs_entity_t second);
1956
1981FLECS_API
1983 ecs_world_t *world);
1984
2002FLECS_API
2004 ecs_world_t *world);
2005
2014FLECS_API
2016 ecs_world_t *world,
2017 ecs_id_t id);
2018
2026FLECS_API
2028 ecs_world_t *world,
2029 ecs_table_t *table);
2030
2049FLECS_API
2051 ecs_world_t *world,
2052 const ecs_entity_desc_t *desc);
2053
2080FLECS_API
2082 ecs_world_t *world,
2083 const ecs_bulk_desc_t *desc);
2084
2094FLECS_API
2096 ecs_world_t *world,
2097 ecs_id_t id,
2098 int32_t count);
2099
2111FLECS_API
2113 ecs_world_t *world,
2114 ecs_entity_t dst,
2115 ecs_entity_t src,
2116 bool copy_value);
2117
2127FLECS_API
2129 ecs_world_t *world,
2130 ecs_entity_t entity);
2131
2139FLECS_API
2141 ecs_world_t *world,
2142 ecs_id_t id);
2143
2160FLECS_API
2162 ecs_world_t *world,
2163 ecs_entity_t entity,
2164 ecs_id_t id);
2165
2174FLECS_API
2176 ecs_world_t *world,
2177 ecs_entity_t entity,
2178 ecs_id_t id);
2179
2202FLECS_API
2204 ecs_world_t *world,
2205 ecs_entity_t entity,
2206 ecs_id_t id);
2207
2216FLECS_API
2218 ecs_world_t *world,
2219 ecs_entity_t entity);
2220
2221
2229FLECS_API
2231 ecs_world_t *world,
2232 ecs_id_t id);
2233
2241FLECS_API
2243 ecs_world_t *world,
2244 ecs_id_t id);
2245
2252FLECS_API
2254 const ecs_world_t *world);
2255
2273FLECS_API
2275 ecs_world_t *world,
2276 ecs_entity_t entity,
2277 bool enabled);
2278
2292FLECS_API
2294 ecs_world_t *world,
2295 ecs_entity_t entity,
2296 ecs_id_t id,
2297 bool enable);
2298
2309FLECS_API
2311 const ecs_world_t *world,
2312 ecs_entity_t entity,
2313 ecs_id_t id);
2314
2332FLECS_API
2333const void* ecs_get_id(
2334 const ecs_world_t *world,
2335 ecs_entity_t entity,
2336 ecs_id_t id);
2337
2348FLECS_API
2350 const ecs_world_t *world,
2351 ecs_entity_t entity,
2352 ecs_id_t id);
2353
2362FLECS_API
2364 const ecs_world_t *world,
2365 ecs_ref_t *ref,
2366 ecs_id_t id);
2367
2375FLECS_API
2377 const ecs_world_t *world,
2378 ecs_ref_t *ref);
2379
2394FLECS_API
2396 ecs_world_t *world,
2397 ecs_entity_t entity,
2398 ecs_id_t id);
2399
2418FLECS_API
2419ecs_record_t* ecs_write_begin(
2420 ecs_world_t *world,
2421 ecs_entity_t entity);
2422
2429FLECS_API
2431 ecs_record_t *record);
2432
2452FLECS_API
2453const ecs_record_t* ecs_read_begin(
2454 ecs_world_t *world,
2455 ecs_entity_t entity);
2456
2462FLECS_API
2464 const ecs_record_t *record);
2465
2479FLECS_API
2481 ecs_world_t *world,
2482 const ecs_record_t *record,
2483 ecs_id_t id);
2484
2493FLECS_API
2495 ecs_world_t *world,
2496 ecs_record_t *record,
2497 ecs_id_t id);
2498
2512FLECS_API
2514 ecs_world_t *world,
2515 ecs_entity_t entity,
2516 ecs_id_t id);
2517
2528FLECS_API
2530 ecs_world_t *world,
2531 ecs_entity_t entity,
2532 ecs_id_t id);
2533
2547FLECS_API
2549 ecs_world_t *world,
2550 ecs_entity_t entity,
2551 ecs_id_t id,
2552 size_t size,
2553 const void *ptr);
2554
2581FLECS_API
2583 const ecs_world_t *world,
2584 ecs_entity_t e);
2585
2594FLECS_API
2596 const ecs_world_t *world,
2597 ecs_entity_t e);
2598
2604FLECS_API
2606 ecs_entity_t e);
2607
2619FLECS_API
2621 ecs_world_t *world,
2622 ecs_entity_t entity);
2623
2640FLECS_API
2642 const ecs_world_t *world,
2643 ecs_entity_t e);
2644
2665FLECS_API
2667 ecs_world_t *world,
2668 ecs_entity_t entity);
2669
2688FLECS_API
2690 ecs_world_t *world,
2691 ecs_id_t id);
2692
2700FLECS_API
2702 const ecs_world_t *world,
2703 ecs_entity_t entity);
2704
2719FLECS_API
2721 const ecs_world_t *world,
2722 ecs_entity_t entity);
2723
2730FLECS_API
2732 const ecs_world_t *world,
2733 ecs_entity_t entity);
2734
2742FLECS_API
2744 const ecs_world_t *world,
2745 const ecs_type_t* type);
2746
2755FLECS_API
2757 const ecs_world_t *world,
2758 const ecs_table_t *table);
2759
2771FLECS_API
2773 const ecs_world_t *world,
2774 ecs_entity_t entity);
2775
2785FLECS_API
2787 const ecs_world_t *world,
2788 ecs_entity_t entity,
2789 ecs_id_t id);
2790
2805FLECS_API
2807 const ecs_world_t *world,
2808 ecs_entity_t entity,
2809 ecs_entity_t rel,
2810 int32_t index);
2811
2830FLECS_API
2832 const ecs_world_t *world,
2833 ecs_entity_t entity,
2834 ecs_entity_t rel,
2835 ecs_id_t id);
2836
2847FLECS_API
2849 const ecs_world_t *world,
2850 ecs_entity_t entity,
2851 ecs_entity_t rel);
2852
2860FLECS_API
2862 const ecs_world_t *world,
2863 ecs_id_t entity);
2864
2881FLECS_API
2882const char* ecs_get_name(
2883 const ecs_world_t *world,
2884 ecs_entity_t entity);
2885
2893FLECS_API
2894const char* ecs_get_symbol(
2895 const ecs_world_t *world,
2896 ecs_entity_t entity);
2897
2909FLECS_API
2911 ecs_world_t *world,
2912 ecs_entity_t entity,
2913 const char *name);
2914
2926FLECS_API
2928 ecs_world_t *world,
2929 ecs_entity_t entity,
2930 const char *symbol);
2931
2943FLECS_API
2945 ecs_world_t *world,
2946 ecs_entity_t entity,
2947 const char *alias);
2948
2957FLECS_API
2959 const ecs_world_t *world,
2960 const char *name);
2961
2971FLECS_API
2973 const ecs_world_t *world,
2974 ecs_entity_t parent,
2975 const char *name);
2976
2995FLECS_API
2997 const ecs_world_t *world,
2998 ecs_entity_t parent,
2999 const char *path,
3000 const char *sep,
3001 const char *prefix,
3002 bool recursive);
3003
3011FLECS_API
3013 const ecs_world_t *world,
3014 const char *symbol,
3015 bool lookup_as_path);
3016
3036FLECS_API
3038 const ecs_world_t *world,
3039 ecs_entity_t parent,
3040 ecs_entity_t child,
3041 const char *sep,
3042 const char *prefix);
3043
3055 const ecs_world_t *world,
3056 ecs_entity_t parent,
3057 ecs_entity_t child,
3058 const char *sep,
3059 const char *prefix,
3060 ecs_strbuf_t *buf);
3061
3077FLECS_API
3079 ecs_world_t *world,
3080 ecs_entity_t parent,
3081 const char *path,
3082 const char *sep,
3083 const char *prefix);
3084
3099FLECS_API
3101 ecs_world_t *world,
3102 ecs_entity_t entity,
3103 ecs_entity_t parent,
3104 const char *path,
3105 const char *sep,
3106 const char *prefix);
3107
3119FLECS_API
3121 ecs_world_t *world,
3122 ecs_entity_t scope);
3123
3131FLECS_API
3133 const ecs_world_t *world);
3134
3144FLECS_API
3146 ecs_world_t *world,
3147 const char *prefix);
3148
3173FLECS_API
3175 ecs_world_t *world,
3176 const ecs_entity_t *lookup_path);
3177
3184FLECS_API
3186 const ecs_world_t *world);
3187
3211FLECS_API
3213 ecs_world_t *world,
3214 const ecs_component_desc_t *desc);
3215
3227FLECS_API
3229 ecs_world_t *world,
3230 ecs_entity_t id,
3231 const ecs_type_hooks_t *hooks);
3232
3239FLECS_API
3241 ecs_world_t *world,
3242 ecs_entity_t id);
3243
3266FLECS_API
3268 const ecs_world_t *world,
3269 ecs_id_t id);
3270
3283FLECS_API
3285 const ecs_world_t *world,
3286 ecs_id_t id);
3287
3296FLECS_API
3298 ecs_world_t *world,
3299 ecs_id_t id);
3300
3310FLECS_API
3312 const ecs_world_t *world,
3313 ecs_id_t id);
3314
3334FLECS_API
3336 const ecs_world_t *world,
3337 ecs_id_t id);
3338
3346FLECS_API
3348 ecs_id_t id,
3349 ecs_id_t pattern);
3350
3356FLECS_API
3358 ecs_id_t id);
3359
3365FLECS_API
3367 ecs_id_t id);
3368
3382FLECS_API
3384 const ecs_world_t *world,
3385 ecs_id_t id);
3386
3395FLECS_API
3396ecs_flags32_t ecs_id_get_flags(
3397 const ecs_world_t *world,
3398 ecs_id_t id);
3399
3406FLECS_API
3408 ecs_id_t id_flags);
3409
3417FLECS_API
3419 const ecs_world_t *world,
3420 ecs_id_t id);
3421
3429FLECS_API
3431 const ecs_world_t *world,
3432 ecs_id_t id,
3433 ecs_strbuf_t *buf);
3434
3452FLECS_API
3453ecs_iter_t ecs_term_iter(
3454 const ecs_world_t *world,
3455 ecs_term_t *term);
3456
3465FLECS_API
3467 const ecs_iter_t *it,
3468 ecs_term_t *term);
3469
3479FLECS_API
3481 ecs_iter_t *it);
3482
3491FLECS_API
3492ecs_iter_t ecs_children(
3493 const ecs_world_t *world,
3494 ecs_entity_t parent);
3495
3502FLECS_API
3504 ecs_iter_t *it);
3505
3511FLECS_API
3513 const ecs_term_id_t *id);
3514
3526FLECS_API
3528 const ecs_term_t *term);
3529
3530FLECS_API
3531bool ecs_term_match_this(
3532 const ecs_term_t *term);
3533
3534FLECS_API
3535bool ecs_term_match_0(
3536 const ecs_term_t *term);
3537
3556FLECS_API
3558 const ecs_world_t *world,
3559 ecs_term_t *term);
3560
3569FLECS_API
3571 const ecs_term_t *src);
3572
3583FLECS_API
3585 ecs_term_t *src);
3586
3593FLECS_API
3595 ecs_term_t *term);
3596
3620FLECS_API
3622 ecs_world_t *world,
3623 const ecs_filter_desc_t *desc);
3624
3630FLECS_API
3632 ecs_filter_t *filter);
3633
3647FLECS_API
3649 const ecs_world_t *world,
3650 ecs_filter_t *filter);
3651
3663FLECS_API
3665 const ecs_filter_t *filter);
3666
3671FLECS_API
3673 const ecs_world_t *world,
3674 const ecs_term_t *term);
3675
3680FLECS_API
3682 const ecs_world_t *world,
3683 const ecs_filter_t *filter);
3684
3694FLECS_API
3696 const ecs_world_t *world,
3697 const ecs_filter_t *filter);
3698
3707FLECS_API
3709 const ecs_iter_t *it,
3710 const ecs_filter_t *filter);
3711
3731FLECS_API
3733 const ecs_world_t *world,
3734 const ecs_filter_t *filter);
3735
3745FLECS_API
3747 ecs_iter_t *it);
3748
3752FLECS_API
3754 ecs_iter_t *it);
3755
3757FLECS_API
3759 ecs_filter_t *dst,
3760 ecs_filter_t *src);
3761
3763FLECS_API
3765 ecs_filter_t *dst,
3766 const ecs_filter_t *src);
3767
3810FLECS_API
3812 ecs_world_t *world,
3813 const ecs_query_desc_t *desc);
3814
3822FLECS_API
3825
3832FLECS_API
3834 ecs_query_t *query);
3835
3863FLECS_API
3865 const ecs_world_t *world,
3867
3877FLECS_API
3879 ecs_iter_t *iter);
3880
3884FLECS_API
3886 ecs_iter_t *iter);
3887
3898FLECS_API
3900 ecs_iter_t *iter);
3901
3919FLECS_API
3921 ecs_iter_t *iter);
3922
3952FLECS_API
3955 const ecs_iter_t *it);
3956
3967FLECS_API
3969 ecs_iter_t *it);
3970
3993FLECS_API
3995 ecs_iter_t *it,
3996 uint64_t group_id);
3997
4006FLECS_API
4009 uint64_t group_id);
4010
4019FLECS_API
4022 uint64_t group_id);
4023
4032FLECS_API
4035
4041FLECS_API
4043 const ecs_query_t *query);
4044
4050FLECS_API
4052 const ecs_query_t *query);
4053
4059FLECS_API
4061 const ecs_query_t *query);
4062
4070FLECS_API
4072 const ecs_query_t *query);
4073
4082typedef struct ecs_event_desc_t {
4085
4090
4093
4097
4099 int32_t offset;
4100
4104 int32_t count;
4105
4108
4110 const void *param;
4111
4114
4116 ecs_flags32_t flags;
4118
4148FLECS_API
4150 ecs_world_t *world,
4151 ecs_event_desc_t *desc);
4152
4162FLECS_API
4164 ecs_world_t *world,
4165 const ecs_observer_desc_t *desc);
4166
4176FLECS_API
4178 ecs_iter_t *it);
4179
4180FLECS_API
4181void* ecs_get_observer_ctx(
4182 const ecs_world_t *world,
4184
4185FLECS_API
4186void* ecs_get_observer_binding_ctx(
4187 const ecs_world_t *world,
4189
4219FLECS_API
4221 const ecs_world_t *world,
4222 const ecs_poly_t *poly,
4223 ecs_iter_t *iter,
4224 ecs_term_t *filter);
4225
4239FLECS_API
4241 ecs_iter_t *it);
4242
4252FLECS_API
4254 ecs_iter_t *it);
4255
4267FLECS_API
4269 ecs_iter_t *it);
4270
4283FLECS_API
4285 ecs_iter_t *it);
4286
4294FLECS_API
4296 ecs_iter_t *it);
4297
4331FLECS_API
4333 ecs_iter_t *it,
4334 int32_t var_id,
4335 ecs_entity_t entity);
4336
4344FLECS_API
4346 ecs_iter_t *it,
4347 int32_t var_id,
4348 const ecs_table_t *table);
4349
4357FLECS_API
4359 ecs_iter_t *it,
4360 int32_t var_id,
4361 const ecs_table_range_t *range);
4362
4374FLECS_API
4376 ecs_iter_t *it,
4377 int32_t var_id);
4378
4391FLECS_API
4393 ecs_iter_t *it,
4394 int32_t var_id);
4395
4408FLECS_API
4410 ecs_iter_t *it,
4411 int32_t var_id);
4412
4413
4425FLECS_API
4427 ecs_iter_t *it,
4428 int32_t var_id);
4429
4445FLECS_API
4446ecs_iter_t ecs_page_iter(
4447 const ecs_iter_t *it,
4448 int32_t offset,
4449 int32_t limit);
4450
4457FLECS_API
4459 ecs_iter_t *it);
4460
4481FLECS_API
4483 const ecs_iter_t *it,
4484 int32_t index,
4485 int32_t count);
4486
4493FLECS_API
4495 ecs_iter_t *it);
4496
4520FLECS_API
4522 const ecs_iter_t *it,
4523 size_t size,
4524 int32_t index);
4525
4534FLECS_API
4536 const ecs_iter_t *it,
4537 int32_t index);
4538
4549FLECS_API
4551 const ecs_iter_t *it,
4552 int32_t index);
4553
4560FLECS_API
4562 const ecs_iter_t *it,
4563 int32_t index);
4564
4571FLECS_API
4573 const ecs_iter_t *it,
4574 int32_t index);
4575
4583FLECS_API
4585 const ecs_iter_t *it,
4586 int32_t index);
4587
4596FLECS_API
4598 const ecs_iter_t *it,
4599 int32_t index);
4600
4614FLECS_API
4616 const ecs_iter_t *it,
4617 int32_t index);
4618
4630FLECS_API
4632 const ecs_iter_t *it);
4633
4634
4648FLECS_API
4650 const ecs_table_t *table);
4651
4660FLECS_API
4662 const ecs_table_t *table,
4663 int32_t index,
4664 int32_t offset);
4665
4674FLECS_API
4676 const ecs_world_t *world,
4677 const ecs_table_t *table,
4678 ecs_id_t id);
4679
4688FLECS_API
4690 const ecs_world_t *world,
4691 const ecs_table_t *table,
4692 ecs_id_t id,
4693 int32_t offset);
4694
4705FLECS_API
4707 const ecs_world_t *world,
4708 const ecs_table_t *table,
4709 ecs_entity_t rel);
4710
4716FLECS_API
4718 const ecs_table_t *table);
4719
4721FLECS_API
4723 const ecs_table_t *table,
4724 int32_t index);
4725
4727FLECS_API
4729 const ecs_table_t *table,
4730 int32_t index);
4731
4740FLECS_API
4742 const ecs_table_t *table);
4743
4753FLECS_API
4755 ecs_world_t *world,
4756 ecs_table_t *table,
4757 ecs_id_t id);
4758
4769FLECS_API
4771 ecs_world_t *world,
4772 const ecs_id_t *ids,
4773 int32_t id_count);
4774
4784FLECS_API
4786 ecs_world_t *world,
4787 ecs_table_t *table,
4788 ecs_id_t id);
4789
4805FLECS_API
4807 ecs_world_t *world,
4808 ecs_table_t *table);
4809
4816FLECS_API
4818 ecs_world_t *world,
4819 ecs_table_t *table);
4820
4828FLECS_API
4830 ecs_table_t *table);
4831
4839FLECS_API
4841 ecs_world_t* world,
4842 ecs_table_t* table,
4843 int32_t row_1,
4844 int32_t row_2);
4845
4868FLECS_API
4870 ecs_world_t *world,
4871 ecs_entity_t entity,
4872 ecs_record_t *record,
4873 ecs_table_t *table,
4874 const ecs_type_t *added,
4875 const ecs_type_t *removed);
4876
4878FLECS_API
4879ecs_record_t* ecs_record_find(
4880 const ecs_world_t *world,
4881 ecs_entity_t entity);
4882
4884FLECS_API
4886 const ecs_record_t *r,
4887 int32_t column,
4888 size_t c_size);
4889
4905FLECS_API
4907 const ecs_world_t *world,
4908 const ecs_table_t *table,
4909 ecs_id_t id,
4910 ecs_id_t *id_out);
4911
4942FLECS_API
4944 const ecs_world_t *world,
4945 const ecs_table_t *table,
4946 int32_t offset,
4947 ecs_id_t id,
4948 ecs_id_t *id_out);
4949
4986FLECS_API
4988 const ecs_world_t *world,
4989 const ecs_table_t *table,
4990 int32_t offset,
4991 ecs_id_t id,
4992 ecs_entity_t rel,
4993 ecs_flags32_t flags, /* EcsSelf and/or EcsUp */
4994 ecs_entity_t *subject_out,
4995 ecs_id_t *id_out,
4996 struct ecs_table_record_t **tr_out);
4997
5013FLECS_API
5015 const ecs_world_t *world,
5016 ecs_entity_t type,
5017 void *ptr);
5018
5026FLECS_API
5028 const ecs_world_t *world,
5029 const ecs_type_info_t *ti,
5030 void *ptr);
5031
5038FLECS_API
5040 ecs_world_t *world,
5041 ecs_entity_t type);
5042
5051 const ecs_world_t *world,
5052 const ecs_type_info_t *ti,
5053 void *ptr);
5054
5062FLECS_API
5064 const ecs_world_t *world,
5065 ecs_entity_t type,
5066 void* ptr);
5067
5074FLECS_API
5076 ecs_world_t *world,
5077 ecs_entity_t type,
5078 void* ptr);
5079
5088FLECS_API
5090 const ecs_world_t *world,
5091 const ecs_type_info_t *ti,
5092 void* dst,
5093 const void *src);
5094
5103FLECS_API
5105 const ecs_world_t *world,
5106 ecs_entity_t type,
5107 void* dst,
5108 const void *src);
5109
5119 const ecs_world_t *world,
5120 const ecs_type_info_t *ti,
5121 void* dst,
5122 void *src);
5123
5133 const ecs_world_t *world,
5134 ecs_entity_t type,
5135 void* dst,
5136 void *src);
5137
5147 const ecs_world_t *world,
5148 const ecs_type_info_t *ti,
5149 void* dst,
5150 void *src);
5151
5161 const ecs_world_t *world,
5162 ecs_entity_t type,
5163 void* dst,
5164 void *src);
5165
5180#include "flecs/addons/flecs_c.h"
5181
5182#ifdef __cplusplus
5183}
5184#endif
5185
5186#include "flecs/private/addons.h"
5187
5188#endif
The deprecated addon contains deprecated operations.
Extends the core API with convenience macros for C applications.
ecs_entity_t ecs_set_with(ecs_world_t *world, ecs_id_t id)
Set current with id.
void ecs_override_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Add override for (component) id.
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Add a (component) id to an entity.
void ecs_remove_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Remove a (component) id from an entity.
void ecs_clear(ecs_world_t *world, ecs_entity_t entity)
Clear all components.
ecs_id_t ecs_get_with(const ecs_world_t *world)
Get current with id.
void ecs_remove_all(ecs_world_t *world, ecs_id_t id)
Remove all instances of the specified id.
ecs_iterable_t EcsIterable
Component for iterable entities.
Definition: flecs.h:1028
const ecs_entity_t EcsOnRemove
Event.
const ecs_entity_t EcsThis
This entity.
const ecs_entity_t EcsWildcard
Wildcard entity ("*").
const ecs_entity_t EcsName
Tag to indicate name identifier.
const ecs_entity_t EcsAcyclic
Marks a relationship as acyclic.
const ecs_entity_t EcsSymmetric
Marks relationship as commutative.
const ecs_entity_t EcsAlias
Tag to indicate alias identifier.
const ecs_entity_t EcsOnSet
Event.
const ecs_entity_t EcsReflexive
Marks a relatoinship as reflexive.
const ecs_entity_t EcsEmpty
Tag used to indicate query is empty.
const ecs_entity_t EcsOneOf
Ensure that relationship target is child of specified entity.
const ecs_entity_t EcsOnTableDelete
Event.
const ecs_entity_t EcsOnTableCreate
Event.
const ecs_entity_t EcsTraversable
Marks a relationship as traversable.
const ecs_entity_t EcsUnSet
Event.
const ecs_entity_t EcsIsA
Used to express inheritance relationships.
const ecs_entity_t EcsExclusive
Can be added to relationship to indicate that the relationship can only occur once on an entity.
const ecs_entity_t EcsSymbol
Tag to indicate symbol identifier.
const ecs_entity_t EcsDependsOn
Used to express dependency relationships.
const ecs_entity_t EcsTransitive
Marks a relationship as transitive.
const ecs_entity_t EcsDelete
Delete cleanup policy.
const ecs_entity_t EcsOnTableFill
Event.
const ecs_entity_t EcsChildOf
Used to express parent-child relationships.
const ecs_entity_t EcsFlecsCore
Core module scope.
const ecs_entity_t EcsMonitor
Event.
const ecs_entity_t EcsOnTableEmpty
Event.
const ecs_entity_t EcsWorld
Entity associated with world (used for "attaching" components to world)
const ecs_entity_t EcsPrivate
Tag to indicate an entity/component/system is private to a module.
const ecs_entity_t EcsRemove
Remove cleanup policy.
const ecs_entity_t EcsSlotOf
Used to express a slot (used with prefab inheritance)
const ecs_entity_t EcsModule
Tag added to module entities.
const ecs_entity_t EcsOnAdd
Event.
const ecs_entity_t EcsPrefab
Tag added to prefab entities.
const ecs_entity_t EcsUnion
Tag to indicate that relationship is stored as union.
const ecs_entity_t EcsAny
Any entity ("_").
const ecs_entity_t EcsWith
Ensure that a component always is added together with another component.
const ecs_entity_t EcsTag
Can be added to relationship to indicate that it should never hold data, even when it or the relation...
const ecs_entity_t EcsOnDelete
Event.
const ecs_entity_t EcsOnDeleteTarget
Relationship used to define what should happen when a target entity (second element of a pair) is del...
const ecs_entity_t EcsFlecs
Root scope for builtin flecs entities.
const ecs_entity_t EcsDisabled
When this tag is added to an entity it is skipped by all queries/filters.
const ecs_entity_t EcsDontInherit
Ensures that component is never inherited from an IsA target.
const ecs_entity_t EcsPanic
Panic cleanup policy.
const ecs_entity_t EcsDefaultChildComponent
Used like (EcsDefaultChildComponent, Component).
const ecs_entity_t EcsFinal
Ensures that entity/component cannot be used as target in IsA relationship.
const ecs_entity_t EcsVariable
Variable entity ("$").
bool ecs_defer_end(ecs_world_t *world)
End block of operations to defer.
void ecs_defer_resume(ecs_world_t *world)
Resume deferring.
bool ecs_defer_begin(ecs_world_t *world)
Defer operations until end of frame.
void ecs_defer_suspend(ecs_world_t *world)
Suspend deferring but do not flush queue.
bool ecs_is_deferred(const ecs_world_t *world)
Test if deferring is enabled for current stage.
bool ecs_stage_is_async(ecs_world_t *stage)
Test whether provided stage is asynchronous.
void ecs_merge(ecs_world_t *world)
Merge world or stage.
void ecs_async_stage_free(ecs_world_t *stage)
Free asynchronous stage.
void ecs_set_automerge(ecs_world_t *world, bool automerge)
Enable/disable automerging for world or stage.
ecs_world_t * ecs_async_stage_new(ecs_world_t *world)
Create asynchronous stage.
bool ecs_stage_is_readonly(const ecs_world_t *world)
Test whether the current world is readonly.
int32_t ecs_get_stage_count(const ecs_world_t *world)
Get number of configured stages.
bool ecs_readonly_begin(ecs_world_t *world)
Begin readonly mode.
ecs_world_t * ecs_get_stage(const ecs_world_t *world, int32_t stage_id)
Get stage-specific world pointer.
void ecs_set_stage_count(ecs_world_t *world, int32_t stages)
Configure world to have N stages.
void ecs_readonly_end(ecs_world_t *world)
End readonly mode.
int32_t ecs_get_stage_id(const ecs_world_t *world)
Get current stage id.
const ecs_type_hooks_t * ecs_get_hooks_id(ecs_world_t *world, ecs_entity_t id)
Get hooks for component.
ecs_entity_t ecs_component_init(ecs_world_t *world, const ecs_component_desc_t *desc)
Find or create a component.
void ecs_set_hooks_id(ecs_world_t *world, ecs_entity_t id, const ecs_type_hooks_t *hooks)
Register hooks for component.
struct ecs_ref_t ecs_ref_t
Refs cache data that lets them access components faster than ecs_get.
Definition: flecs.h:256
ecs_id_t ecs_entity_t
An entity identifier.
Definition: flecs.h:220
struct ecs_rule_t ecs_rule_t
A rule implements a non-trivial filter.
Definition: flecs.h:244
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition: flecs.h:229
struct ecs_mixins_t ecs_mixins_t
Type that stores poly mixins.
Definition: flecs.h:295
uint64_t ecs_id_t
An id.
Definition: flecs.h:217
struct ecs_query_t ecs_query_t
A query allows for cached iteration over ECS data.
Definition: flecs.h:238
struct ecs_observable_t ecs_observable_t
An observable contains lists of triggers for specific events/components.
Definition: flecs.h:250
struct ecs_table_t ecs_table_t
A table is where entities and components are stored.
Definition: flecs.h:232
void ecs_poly_t
A poly object.
Definition: flecs.h:292
ecs_entity_t ecs_new_low_id(ecs_world_t *world)
Create new low id.
ecs_entity_t ecs_new_w_id(ecs_world_t *world, ecs_id_t id)
Create new entity with (component) id.
ecs_entity_t ecs_new_id(ecs_world_t *world)
Create new entity id.
const ecs_entity_t * ecs_bulk_init(ecs_world_t *world, const ecs_bulk_desc_t *desc)
Bulk create/populate new entities.
ecs_entity_t ecs_clone(ecs_world_t *world, ecs_entity_t dst, ecs_entity_t src, bool copy_value)
Clone an entity This operation clones the components of one entity into another entity.
const ecs_entity_t * ecs_bulk_new_w_id(ecs_world_t *world, ecs_id_t id, int32_t count)
Create N new entities.
ecs_entity_t ecs_entity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)
Find or create an entity.
void ecs_delete_with(ecs_world_t *world, ecs_id_t id)
Delete all entities with the specified id.
void ecs_delete(ecs_world_t *world, ecs_entity_t entity)
Delete an entity.
ecs_entity_t ecs_new_w_table(ecs_world_t *world, ecs_table_t *table)
Create new entity in table.
bool ecs_is_enabled_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Test if component is enabled.
void ecs_enable_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, bool enable)
Enable or disable component.
void ecs_enable(ecs_world_t *world, ecs_entity_t entity, bool enabled)
Enable or disable entity.
char * ecs_entity_str(const ecs_world_t *world, ecs_entity_t entity)
Convert entity to string.
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.
const ecs_type_t * ecs_get_type(const ecs_world_t *world, ecs_entity_t entity)
Get the type of an entity.
bool ecs_has_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Test if an entity has an entity.
char * ecs_type_str(const ecs_world_t *world, const ecs_type_t *type)
Convert type to string.
char * ecs_table_str(const ecs_world_t *world, const ecs_table_t *table)
Convert table to string.
int32_t ecs_count_id(const ecs_world_t *world, ecs_id_t entity)
Count entities that have the specified id.
int32_t ecs_get_depth(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel)
Return depth for entity in tree for relationship rel.
ecs_entity_t ecs_get_target_for_id(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, ecs_id_t id)
Get the target of a relationship for a given id.
ecs_table_t * ecs_get_table(const ecs_world_t *world, ecs_entity_t entity)
Get the table of an entity.
bool ecs_children_next(ecs_iter_t *it)
Progress a children iterator.
ecs_term_t ecs_term_copy(const ecs_term_t *src)
Copy resources of a term to another term.
ecs_iter_t ecs_term_chain_iter(const ecs_iter_t *it, ecs_term_t *term)
Return a chained term iterator.
void ecs_term_fini(ecs_term_t *term)
Free resources of term.
ecs_filter_t * ecs_filter_init(ecs_world_t *world, const ecs_filter_desc_t *desc)
Initialize filter A filter is a lightweight object that can be used to query for entities in a world.
bool ecs_filter_next(ecs_iter_t *it)
Iterate tables matched by filter.
ecs_iter_t ecs_filter_iter(const ecs_world_t *world, const ecs_filter_t *filter)
Return a filter iterator.
char * ecs_term_str(const ecs_world_t *world, const ecs_term_t *term)
Convert ter, to string expression.
int ecs_filter_finalize(const ecs_world_t *world, ecs_filter_t *filter)
Finalize filter.
char * ecs_filter_str(const ecs_world_t *world, const ecs_filter_t *filter)
Convert filter to string expression.
void ecs_filter_fini(ecs_filter_t *filter)
Deinitialize filter.
bool ecs_filter_next_instanced(ecs_iter_t *it)
Same as ecs_filter_next, but always instanced.
bool ecs_term_next(ecs_iter_t *it)
Progress a term iterator.
int32_t ecs_filter_pivot_term(const ecs_world_t *world, const ecs_filter_t *filter)
Get pivot term for filter.
ecs_iter_t ecs_children(const ecs_world_t *world, ecs_entity_t parent)
Iterator for a parent's children.
int32_t ecs_filter_find_this_var(const ecs_filter_t *filter)
Find index for This variable.
int ecs_term_finalize(const ecs_world_t *world, ecs_term_t *term)
Finalize term.
bool ecs_term_id_is_set(const ecs_term_id_t *id)
Test whether term id is set.
void ecs_filter_move(ecs_filter_t *dst, ecs_filter_t *src)
Move resources of one filter to another.
bool ecs_term_is_initialized(const ecs_term_t *term)
Test whether a term is set.
ecs_term_t ecs_term_move(ecs_term_t *src)
Move resources of a term to another term.
void ecs_filter_copy(ecs_filter_t *dst, const ecs_filter_t *src)
Copy resources of one filter to another.
ecs_iter_t ecs_filter_chain_iter(const ecs_iter_t *it, const ecs_filter_t *filter)
Return a chained filter iterator.
ecs_iter_t ecs_term_iter(const ecs_world_t *world, ecs_term_t *term)
Iterator for a single (component) id.
void(* ecs_module_action_t)(ecs_world_t *world)
Initialization action for modules.
Definition: flecs.h:407
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:387
uint64_t(* ecs_hash_value_action_t)(const void *ptr)
Callback used for hashing values.
Definition: flecs.h:425
void(* ecs_iter_fini_action_t)(ecs_iter_t *it)
Function prototype for freeing an iterator.
Definition: flecs.h:365
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:376
bool(* ecs_iter_next_action_t)(ecs_iter_t *it)
Function prototype for iterating an iterator.
Definition: flecs.h:357
void(* ecs_iter_action_t)(ecs_iter_t *it)
Function prototype for iterables.
Definition: flecs.h:330
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:435
int(* ecs_compare_action_t)(const void *ptr1, const void *ptr2)
Callback used for sorting values.
Definition: flecs.h:420
void(* ecs_fini_action_t)(ecs_world_t *world, void *ctx)
Action callback on world exit.
Definition: flecs.h:411
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:442
void(* ecs_run_action_t)(ecs_iter_t *it)
Function prototype for runnables (systems, observers).
Definition: flecs.h:321
void(* ecs_ctx_free_t)(void *ctx)
Function to cleanup context data.
Definition: flecs.h:416
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:369
void(* ecs_iter_init_action_t)(const ecs_world_t *world, const ecs_poly_t *iterable, ecs_iter_t *it, ecs_term_t *filter)
Function prototype for creating an iterator from a poly.
Definition: flecs.h:344
void(* ecs_xtor_t)(void *ptr, int32_t count, const ecs_type_info_t *type_info)
Constructor/destructor callback.
Definition: flecs.h:429
void * ecs_emplace_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Emplace a component.
ecs_ref_t ecs_ref_init_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Create a component ref.
void * ecs_record_get_mut_id(ecs_world_t *world, ecs_record_t *record, ecs_id_t id)
Same as ecs_record_get_id, but returns a mutable pointer.
void ecs_ref_update(const ecs_world_t *world, ecs_ref_t *ref)
Update ref.
void ecs_read_end(const ecs_record_t *record)
End read access to entity.
void ecs_write_end(ecs_record_t *record)
End exclusive write access to entity.
void * ecs_ref_get_id(const ecs_world_t *world, ecs_ref_t *ref, ecs_id_t id)
Get component from ref.
const void * ecs_record_get_id(ecs_world_t *world, const ecs_record_t *record, ecs_id_t id)
Get component from entity record.
ecs_entity_t ecs_set_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, size_t size, const void *ptr)
Set the value of a component.
const void * ecs_get_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Get an immutable pointer to a component.
ecs_record_t * ecs_write_begin(ecs_world_t *world, ecs_entity_t entity)
Begin exclusive write access to entity.
void ecs_modified_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Signal that a component has been modified.
const ecs_record_t * ecs_read_begin(ecs_world_t *world, ecs_entity_t entity)
Begin read access to entity.
void * ecs_get_mut_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Get a mutable pointer to a component.
const ecs_id_t ECS_PAIR
Indicates that the id is a pair.
const ecs_id_t ECS_OVERRIDE
Automatically override component when it is inherited.
const ecs_id_t ECS_AND
Include all components from entity to which AND is applied.
const ecs_id_t ECS_TOGGLE
Adds bitset to storage which allows component to be enabled/disabled.
bool ecs_id_is_union(const ecs_world_t *world, ecs_id_t id)
Return whether represents a union.
bool ecs_id_is_valid(const ecs_world_t *world, ecs_id_t id)
Utility to check if id is valid.
bool ecs_id_is_pair(ecs_id_t id)
Utility to check if id is a pair.
ecs_entity_t ecs_get_typeid(const ecs_world_t *world, ecs_id_t id)
Get the type for an id.
bool ecs_id_match(ecs_id_t id, ecs_id_t pattern)
Utility to match an id with a pattern.
const char * ecs_id_flag_str(ecs_id_t id_flags)
Convert id flag to string.
const ecs_type_info_t * ecs_get_type_info(const ecs_world_t *world, ecs_id_t id)
Get the type for an id.
bool ecs_id_is_tag(const ecs_world_t *world, ecs_id_t id)
Returns whether specified id a tag.
void ecs_id_str_buf(const ecs_world_t *world, ecs_id_t id, ecs_strbuf_t *buf)
Write id string to buffer.
char * ecs_id_str(const ecs_world_t *world, ecs_id_t id)
Convert id to string.
bool ecs_id_in_use(ecs_world_t *world, ecs_id_t id)
Returns whether specified id is in use.
bool ecs_id_is_wildcard(ecs_id_t id)
Utility to check if id is a wildcard.
ecs_flags32_t ecs_id_get_flags(const ecs_world_t *world, ecs_id_t id)
Get flags associated with id.
bool ecs_field_is_set(const ecs_iter_t *it, int32_t index)
Test whether field is set.
bool ecs_field_is_writeonly(const ecs_iter_t *it, int32_t index)
Test whether the field is writeonly.
bool ecs_field_is_self(const ecs_iter_t *it, int32_t index)
Test whether the field is matched on self.
void * ecs_field_w_size(const ecs_iter_t *it, size_t size, int32_t index)
Obtain data for a query field.
ecs_iter_t ecs_worker_iter(const ecs_iter_t *it, int32_t index, int32_t count)
Create a worker iterator.
size_t ecs_field_size(const ecs_iter_t *it, int32_t index)
Return field type size.
bool ecs_iter_is_true(ecs_iter_t *it)
Test if iterator is true.
void ecs_iter_fini(ecs_iter_t *it)
Cleanup iterator resources.
char * ecs_iter_str(const ecs_iter_t *it)
Convert iterator to string.
bool ecs_iter_var_is_constrained(ecs_iter_t *it, int32_t var_id)
Returns whether variable is constrained.
ecs_iter_t ecs_page_iter(const ecs_iter_t *it, int32_t offset, int32_t limit)
Create a paged iterator.
void ecs_iter_poly(const ecs_world_t *world, const ecs_poly_t *poly, ecs_iter_t *iter, ecs_term_t *filter)
Create iterator from poly object.
ecs_id_t ecs_field_id(const ecs_iter_t *it, int32_t index)
Return id matched for field.
bool ecs_field_is_readonly(const ecs_iter_t *it, int32_t index)
Test whether the field is readonly.
void ecs_iter_set_var(ecs_iter_t *it, int32_t var_id, ecs_entity_t entity)
Set value for iterator variable.
bool ecs_iter_next(ecs_iter_t *it)
Progress any iterator.
ecs_entity_t ecs_iter_get_var(ecs_iter_t *it, int32_t var_id)
Get value of iterator variable as entity.
bool ecs_worker_next(ecs_iter_t *it)
Progress a worker iterator.
ecs_entity_t ecs_iter_first(ecs_iter_t *it)
Get first matching entity from iterator.
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_table_t * ecs_iter_get_var_as_table(ecs_iter_t *it, int32_t var_id)
Get value of iterator variable as table.
ecs_entity_t ecs_field_src(const ecs_iter_t *it, int32_t index)
Return field source.
int32_t ecs_iter_count(ecs_iter_t *it)
Count number of matched entities in query.
bool ecs_page_next(ecs_iter_t *it)
Progress a paged iterator.
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 This constrains the variable to a range of enti...
ecs_table_range_t ecs_iter_get_var_as_range(ecs_iter_t *it, int32_t var_id)
Get value of iterator variable as table range.
ecs_id_t ecs_strip_generation(ecs_entity_t e)
Remove generation from entity id.
void ecs_ensure(ecs_world_t *world, ecs_entity_t entity)
Ensure id is alive.
bool ecs_is_valid(const ecs_world_t *world, ecs_entity_t e)
Test whether an entity is valid.
void ecs_set_entity_generation(ecs_world_t *world, ecs_entity_t entity)
Override the generation of an entity.
ecs_entity_t ecs_get_alive(const ecs_world_t *world, ecs_entity_t e)
Get alive identifier.
bool ecs_exists(const ecs_world_t *world, ecs_entity_t entity)
Test whether an entity exists.
void ecs_ensure_id(ecs_world_t *world, ecs_id_t id)
Same as ecs_ensure, but for (component) ids.
bool ecs_is_alive(const ecs_world_t *world, ecs_entity_t e)
Test whether an entity is alive.
void ecs_emit(ecs_world_t *world, ecs_event_desc_t *desc)
Send event.
ecs_entity_t ecs_observer_init(ecs_world_t *world, const ecs_observer_desc_t *desc)
Create observer.
bool ecs_observer_default_run_action(ecs_iter_t *it)
Default run action for observer.
#define ECS_TERM_DESC_CACHE_SIZE
Maximum number of terms in desc (larger, as these are temp objects)
Definition: flecs.h:177
#define ECS_ID_CACHE_SIZE
Maximum number of components to add/remove in a single operation.
Definition: flecs.h:172
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition: flecs.h:42
#define ECS_OBSERVER_DESC_EVENT_COUNT_MAX
Maximum number of events to set in static array of observer descriptor.
Definition: flecs.h:181
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_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 entity from path.
ecs_entity_t ecs_lookup(const ecs_world_t *world, const char *name)
Lookup an entity by name.
void ecs_set_alias(ecs_world_t *world, ecs_entity_t entity, const char *alias)
Set alias for entity.
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)
Write path identifier to buffer.
ecs_entity_t ecs_get_scope(const ecs_world_t *world)
Get the current scope.
ecs_entity_t * ecs_set_lookup_path(ecs_world_t *world, const ecs_entity_t *lookup_path)
Set search path for lookup operations.
ecs_entity_t ecs_set_name(ecs_world_t *world, ecs_entity_t entity, const char *name)
Set the name of an entity.
ecs_entity_t ecs_lookup_symbol(const ecs_world_t *world, const char *symbol, bool lookup_as_path)
Lookup an entity by its symbol name.
const char * ecs_get_symbol(const ecs_world_t *world, ecs_entity_t entity)
Get the symbol of an entity.
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)
Lookup an entity from a path.
ecs_entity_t ecs_set_symbol(ecs_world_t *world, ecs_entity_t entity, const char *symbol)
Set the symbol of an entity.
ecs_entity_t ecs_lookup_child(const ecs_world_t *world, ecs_entity_t parent, const char *name)
Lookup a child entity by name.
const char * ecs_get_name(const ecs_world_t *world, ecs_entity_t entity)
Get the name of an entity.
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 specified path to entity.
ecs_entity_t * ecs_get_lookup_path(const ecs_world_t *world)
Get current lookup path.
ecs_entity_t ecs_set_scope(ecs_world_t *world, ecs_entity_t scope)
Set the current scope.
const char * ecs_set_name_prefix(ecs_world_t *world, const char *prefix)
Set a name prefix for newly created entities.
void ecs_query_populate(ecs_iter_t *iter)
Populate iterator fields.
bool ecs_query_next_instanced(ecs_iter_t *iter)
Same as ecs_query_next, but always instanced.
const ecs_query_group_info_t * ecs_query_get_group_info(ecs_query_t *query, uint64_t group_id)
Get information about query group.
void ecs_query_fini(ecs_query_t *query)
Destroy a query.
void ecs_query_skip(ecs_iter_t *it)
Skip a table while iterating.
int32_t ecs_query_table_count(const ecs_query_t *query)
Returns number of tables query matched with.
bool ecs_query_next_table(ecs_iter_t *iter)
Fast alternative to ecs_query_next that only returns matched tables.
int32_t ecs_query_entity_count(const ecs_query_t *query)
Returns number of entities query matched with.
void * ecs_query_get_group_ctx(ecs_query_t *query, uint64_t group_id)
Get context of query group.
char * ecs_query_str(const ecs_query_t *query)
Convert query to string.
ecs_query_t * ecs_query_init(ecs_world_t *world, const ecs_query_desc_t *desc)
Create a query.
bool ecs_query_orphaned(ecs_query_t *query)
Returns whether query is orphaned.
void ecs_query_set_group(ecs_iter_t *it, uint64_t group_id)
Set group to iterate for query iterator.
ecs_iter_t ecs_query_iter(const ecs_world_t *world, ecs_query_t *query)
Return a query iterator.
bool ecs_query_next(ecs_iter_t *iter)
Progress the query iterator.
const ecs_filter_t * ecs_query_get_filter(ecs_query_t *query)
Get filter from a query.
int32_t ecs_query_empty_table_count(const ecs_query_t *query)
Returns number of empty tables query matched with.
bool ecs_query_changed(ecs_query_t *query, const ecs_iter_t *it)
Returns whether the query data changed since the last iteration.
ecs_inout_kind_t
Specify read/write access for term.
Definition: flecs.h:475
ecs_oper_kind_t
Specify operator for term.
Definition: flecs.h:484
ecs_filter_t ECS_FILTER_INIT
Use this variable to initialize user-allocated filter object.
@ EcsOut
Term is only written.
Definition: flecs.h:480
@ EcsInOut
Term is both read and written.
Definition: flecs.h:478
@ EcsInOutDefault
InOut for regular terms, In for shared terms.
Definition: flecs.h:476
@ EcsInOutNone
Term is neither read nor written.
Definition: flecs.h:477
@ EcsIn
Term is only read.
Definition: flecs.h:479
@ EcsNot
The term must not match.
Definition: flecs.h:487
@ EcsOptional
The term may match.
Definition: flecs.h:488
@ EcsOr
One of the terms in an or chain must match.
Definition: flecs.h:486
@ EcsOrFrom
Term must match at least one component from term id.
Definition: flecs.h:490
@ EcsAnd
The term must match.
Definition: flecs.h:485
@ EcsNotFrom
Term must match none of the components from term id.
Definition: flecs.h:491
@ EcsAndFrom
Term must match all components from term id.
Definition: flecs.h:489
int32_t ecs_table_get_index(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t id)
Get column index for id.
ecs_table_t * ecs_table_add_id(ecs_world_t *world, ecs_table_t *table, ecs_id_t id)
Get table that has all components of current table plus the specified id.
int32_t ecs_search(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t id, ecs_id_t *id_out)
Search for component id in table type.
const ecs_type_t * ecs_table_get_type(const ecs_table_t *table)
Get type for table.
int32_t ecs_search_offset(const ecs_world_t *world, const ecs_table_t *table, int32_t offset, ecs_id_t id, ecs_id_t *id_out)
Search for component id in table type starting from an offset.
int32_t ecs_table_storage_to_type_index(const ecs_table_t *table, int32_t index)
Convert index in table storage type to index in table type.
int32_t ecs_search_relation(const ecs_world_t *world, const ecs_table_t *table, int32_t offset, ecs_id_t id, ecs_entity_t rel, ecs_flags32_t flags, ecs_entity_t *subject_out, ecs_id_t *id_out, struct ecs_table_record_t **tr_out)
Search for component/relationship id in table type starting from an offset.
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) entity to a table.
ecs_table_t * ecs_table_get_storage_table(const ecs_table_t *table)
Get storage type for table.
void * ecs_table_get_column(const ecs_table_t *table, int32_t index, int32_t offset)
Get column from table.
ecs_table_t * ecs_table_remove_id(ecs_world_t *world, ecs_table_t *table, ecs_id_t id)
Get table that has all components of current table minus the specified id.
int32_t ecs_table_type_to_storage_index(const ecs_table_t *table, int32_t index)
Convert index in table type to index in table storage type.
int32_t ecs_table_count(const ecs_table_t *table)
Returns the number of records in the table.
void ecs_table_unlock(ecs_world_t *world, ecs_table_t *table)
Unlock a table.
bool ecs_table_has_module(ecs_table_t *table)
Returns whether table is a module or contains module contents Returns true for tables that have modul...
int32_t ecs_table_get_depth(const ecs_world_t *world, const ecs_table_t *table, ecs_entity_t rel)
Return depth for table in tree for relationship rel.
void * ecs_table_get_id(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t id, int32_t offset)
Get column from table by component id.
void ecs_table_swap_rows(ecs_world_t *world, ecs_table_t *table, int32_t row_1, int32_t row_2)
Swaps two elements inside the table.
void ecs_table_lock(ecs_world_t *world, ecs_table_t *table)
Lock or unlock table.
void * ecs_record_get_column(const ecs_record_t *r, int32_t column, size_t c_size)
Get component pointer from column/record.
ecs_table_t * ecs_table_find(ecs_world_t *world, const ecs_id_t *ids, int32_t id_count)
Find table from id array.
ecs_record_t * ecs_record_find(const ecs_world_t *world, ecs_entity_t entity)
Find record for entity.
int ecs_value_fini_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *ptr)
Destruct a value.
int ecs_value_fini(const ecs_world_t *world, ecs_entity_t type, void *ptr)
Destruct a value.
int ecs_value_copy(const ecs_world_t *world, ecs_entity_t type, void *dst, const void *src)
Copy value.
int ecs_value_move(const ecs_world_t *world, ecs_entity_t type, void *dst, void *src)
Move value.
int ecs_value_move_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *dst, void *src)
Move value.
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 value.
int ecs_value_copy_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *dst, const void *src)
Copy value.
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.
void * ecs_value_new(ecs_world_t *world, ecs_entity_t type)
Construct a value in new storage.
int ecs_value_free(ecs_world_t *world, ecs_entity_t type, void *ptr)
Destruct a value, free storage.
int ecs_value_move_ctor(const ecs_world_t *world, ecs_entity_t type, void *dst, void *src)
Move construct value.
int ecs_value_init(const ecs_world_t *world, ecs_entity_t type, void *ptr)
Construct a value in existing storage.
void ecs_atfini(ecs_world_t *world, ecs_fini_action_t action, void *ctx)
Register action to be executed when world is destroyed.
bool ecs_is_fini(const ecs_world_t *world)
Returns whether the world is being deleted.
int ecs_fini(ecs_world_t *world)
Delete a world.
ecs_world_t * ecs_mini(void)
Same as ecs_init, but with minimal set of modules loaded.
ecs_world_t * ecs_init(void)
Create a new world.
ecs_world_t * ecs_init_w_args(int argc, char *argv[])
Create a new world with arguments.
void ecs_set_target_fps(ecs_world_t *world, float fps)
Set target frames per second (FPS) for application.
void ecs_measure_system_time(ecs_world_t *world, bool enable)
Measure system time.
float ecs_frame_begin(ecs_world_t *world, float delta_time)
Begin frame.
void ecs_run_post_frame(ecs_world_t *world, ecs_fini_action_t action, void *ctx)
Register action to be executed once after frame.
bool ecs_should_quit(const ecs_world_t *world)
Return whether a quit has been signaled.
void ecs_quit(ecs_world_t *world)
Signal exit This operation signals that the application should quit.
void ecs_measure_frame_time(ecs_world_t *world, bool enable)
Measure frame time.
void ecs_frame_end(ecs_world_t *world)
End frame.
ecs_entity_t ecs_get_entity(const ecs_poly_t *poly)
Get entity from poly.
ecs_id_t ecs_make_pair(ecs_entity_t first, ecs_entity_t second)
Make a pair id.
void ecs_set_context(ecs_world_t *world, void *ctx)
Set a world context.
void ecs_run_aperiodic(ecs_world_t *world, ecs_flags32_t flags)
Force aperiodic actions.
void ecs_dim(ecs_world_t *world, int32_t entity_count)
Dimension the world for a specified number of entities.
void ecs_set_entity_range(ecs_world_t *world, ecs_entity_t id_start, ecs_entity_t id_end)
Set a range for issueing new entity ids.
const ecs_world_info_t * ecs_get_world_info(const ecs_world_t *world)
Get world info.
const ecs_world_t * ecs_get_world(const ecs_poly_t *poly)
Get world from poly.
bool _ecs_poly_is(const ecs_poly_t *object, int32_t type)
Test if pointer is of specified type.
void * ecs_get_context(const ecs_world_t *world)
Get the world context.
int32_t ecs_delete_empty_tables(ecs_world_t *world, ecs_id_t id, uint16_t clear_generation, uint16_t delete_generation, int32_t min_id_count, double time_budget_seconds)
Cleanup empty tables.
bool ecs_enable_range_check(ecs_world_t *world, bool enable)
Enable/disable range limits.
flecs::observer_builder< Components... > observer(Args &&... args) const
Create a new observer.
Operating system abstraction API.
flecs::query< Comps... > query(flecs::query_base &parent, Args &&... args) const
Create a subquery.
Component information.
Definition: flecs.h:1017
ecs_size_t size
Component size.
Definition: flecs.h:1018
ecs_size_t alignment
Component alignment.
Definition: flecs.h:1019
A (string) identifier.
Definition: flecs.h:1008
ecs_size_t length
Length of identifier.
Definition: flecs.h:1010
char * value
Identifier string.
Definition: flecs.h:1009
ecs_hashmap_t * index
Current index.
Definition: flecs.h:1013
uint64_t hash
Hash of current value.
Definition: flecs.h:1011
uint64_t index_hash
Hash of existing record in current index.
Definition: flecs.h:1012
Component for storing a poly object.
Definition: flecs.h:1023
ecs_poly_t * poly
Pointer to poly object.
Definition: flecs.h:1024
Apply a rate filter to a tick source.
Definition: timer.h:44
Component used to provide a tick source to systems.
Definition: system.h:32
Component used for one shot/interval timer functionality.
Definition: timer.h:35
Used with ecs_bulk_init.
Definition: flecs.h:726
void ** data
Array with component data to insert.
Definition: flecs.h:738
ecs_id_t ids[(32)]
Ids to create the entities with.
Definition: flecs.h:736
int32_t count
Number of entities to create/populate.
Definition: flecs.h:734
ecs_entity_t * entities
Entities to bulk insert.
Definition: flecs.h:729
ecs_table_t * table
Table to insert the entities into.
Definition: flecs.h:745
Used with ecs_component_init.
Definition: flecs.h:756
ecs_type_info_t type
Parameters for type (size, hooks, ...)
Definition: flecs.h:763
ecs_entity_t entity
Existing entity to associate with observer (optional)
Definition: flecs.h:760
Used with ecs_entity_init.
Definition: flecs.h:685
const char * sep
Optional custom separator for hierarchical names.
Definition: flecs.h:695
const char * root_sep
Optional, used for identifiers relative to root.
Definition: flecs.h:699
const char * name
Name of the entity.
Definition: flecs.h:690
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:711
ecs_id_t add[(32)]
Array of ids to add to the new or existing entity.
Definition: flecs.h:716
const char * symbol
Optional entity symbol.
Definition: flecs.h:701
const char * add_expr
String expression with components to add.
Definition: flecs.h:719
ecs_entity_t id
Set to modify existing entity (optional)
Definition: flecs.h:688
ecs_entity_t entity
Single-entity alternative to setting table / offset / count.
Definition: flecs.h:4107
ecs_table_t * table
The table for which to notify.
Definition: flecs.h:4092
int32_t count
Limit number of notified entities to count.
Definition: flecs.h:4104
ecs_table_t * other_table
Optional 2nd table to notify.
Definition: flecs.h:4096
const void * param
Optional context.
Definition: flecs.h:4110
int32_t offset
Limit notified entities to ones starting from offset (row) in table.
Definition: flecs.h:4099
const ecs_type_t * ids
Component ids.
Definition: flecs.h:4089
ecs_poly_t * observable
Observable (usually the world)
Definition: flecs.h:4113
ecs_entity_t event
The event id.
Definition: flecs.h:4084
ecs_flags32_t flags
Event flags.
Definition: flecs.h:4116
Used with ecs_filter_init.
Definition: flecs.h:770
ecs_term_t * terms_buffer
For filters with lots of terms an outside array can be provided.
Definition: flecs.h:778
bool instanced
When true, terms returned by an iterator may either contain 1 or N elements, where terms with N eleme...
Definition: flecs.h:791
ecs_term_t terms[(16)]
Terms of the filter.
Definition: flecs.h:775
int32_t terms_buffer_count
Number of terms in array provided in terms_buffer.
Definition: flecs.h:781
ecs_entity_t entity
Entity associated with query (optional)
Definition: flecs.h:800
ecs_flags32_t flags
Flags for advanced usage.
Definition: flecs.h:794
ecs_filter_t * storage
External storage to prevent allocation of the filter object.
Definition: flecs.h:784
const char * expr
Filter expression.
Definition: flecs.h:797
Filters alllow for ad-hoc quick filtering of entity tables.
Definition: flecs.h:555
ecs_term_t * terms
Array containing terms for filter.
Definition: flecs.h:558
bool owned
Is filter object owned by filter.
Definition: flecs.h:562
int32_t field_count
Number of fields in iterator for filter.
Definition: flecs.h:560
int32_t term_count
Number of elements in terms array.
Definition: flecs.h:559
ecs_flags32_t flags
Filter flags.
Definition: flecs.h:565
bool terms_owned
Is terms array owned by filter.
Definition: flecs.h:563
char * variable_names[1]
Array with variable names.
Definition: flecs.h:567
ecs_poly_dtor_t dtor
Dtor mixin.
Definition: flecs.h:573
ecs_entity_t entity
Entity associated with filter (optional)
Definition: flecs.h:570
ecs_iterable_t iterable
Iterable mixin.
Definition: flecs.h:572
Header for ecs_poly_t objects.
Definition: flecs.h:298
Iterable mixin.
Definition: flecs.h:462
ecs_iter_init_action_t init
Callback that creates iterator.
Definition: flecs.h:463
Used with ecs_observer_init.
Definition: flecs.h:864
void * binding_ctx
Context to be used for language bindings.
Definition: flecs.h:896
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition: flecs.h:899
ecs_entity_t entity
Existing entity to associate with observer (optional)
Definition: flecs.h:868
ecs_filter_desc_t filter
Filter for observer.
Definition: flecs.h:871
int32_t term_index
Used for internal purposes.
Definition: flecs.h:912
ecs_entity_t events[(8)]
Events to observe (OnAdd, OnRemove, OnSet, UnSet)
Definition: flecs.h:874
int32_t * last_event_id
Optional shared last event id for multiple observers.
Definition: flecs.h:909
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition: flecs.h:902
void * ctx
User context to pass to callback.
Definition: flecs.h:893
ecs_poly_t * observable
Observable with which to register the observer.
Definition: flecs.h:905
ecs_iter_action_t callback
Callback to invoke on an event, invoked when the observer matches.
Definition: flecs.h:882
bool yield_existing
When observer is created, generate events from existing data.
Definition: flecs.h:879
ecs_run_action_t run
Callback invoked on an event.
Definition: flecs.h:890
ecs_iter_action_t callback
See ecs_observer_desc_t::callback.
Definition: flecs.h:586
int32_t term_index
Index of the term in parent observer (single term observers only)
Definition: flecs.h:601
ecs_observable_t * observable
Observable for observer.
Definition: flecs.h:595
ecs_run_action_t run
See ecs_observer_desc_t::run.
Definition: flecs.h:587
int32_t * last_event_id
Last handled event id.
Definition: flecs.h:597
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition: flecs.h:592
ecs_filter_t filter
Query for observer.
Definition: flecs.h:580
void * ctx
Callback context.
Definition: flecs.h:589
ecs_id_t register_id
Id observer is registered with (single term observers only)
Definition: flecs.h:600
void * binding_ctx
Binding context (for language bindings)
Definition: flecs.h:590
bool is_monitor
If true, the observer only triggers when the filter did not match with the entity before the event ha...
Definition: flecs.h:603
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition: flecs.h:593
bool is_multi
If true, the observer triggers on more than one term.
Definition: flecs.h:607
Used with ecs_query_init.
Definition: flecs.h:807
ecs_order_by_action_t order_by
Callback used for ordering query results.
Definition: flecs.h:819
ecs_id_t group_by_id
Id to be used by group_by.
Definition: flecs.h:828
ecs_group_by_action_t group_by
Callback used for grouping results.
Definition: flecs.h:835
ecs_ctx_free_t group_by_ctx_free
Function to free group_by_ctx.
Definition: flecs.h:849
void * group_by_ctx
Context to pass to group_by.
Definition: flecs.h:846
ecs_group_create_action_t on_group_create
Callback that is invoked when a new group is created.
Definition: flecs.h:839
ecs_query_t * parent
If set, the query will be created as a subquery.
Definition: flecs.h:857
ecs_entity_t order_by_component
Component to be used by order_by.
Definition: flecs.h:814
ecs_filter_desc_t filter
Filter for the query.
Definition: flecs.h:811
ecs_group_delete_action_t on_group_delete
Callback that is invoked when an existing group is deleted.
Definition: flecs.h:843
ecs_sort_table_action_t sort_table
Callback used for ordering query results.
Definition: flecs.h:823
Type that contains information about a query group.
Definition: flecs.h:993
int32_t table_count
Number of tables in group.
Definition: flecs.h:995
void * ctx
Group context, returned by on_group_create.
Definition: flecs.h:996
int32_t match_count
How often tables have been matched/unmatched.
Definition: flecs.h:994
Type that describes a single identifier in a term.
Definition: flecs.h:507
ecs_flags32_t flags
Term flags.
Definition: flecs.h:525
ecs_entity_t trav
Relationship to traverse when looking for the component.
Definition: flecs.h:521
char * name
Name.
Definition: flecs.h:514
ecs_entity_t id
Entity id.
Definition: flecs.h:508
Type that describes a term (single element in a query)
Definition: flecs.h:529
ecs_term_id_t second
Second element of pair.
Definition: flecs.h:537
ecs_id_t id
Component id to be matched by term.
Definition: flecs.h:530
char * name
Name of term.
Definition: flecs.h:543
ecs_term_id_t src
Source of term.
Definition: flecs.h:535
ecs_id_record_t * idr
Cached pointer to internal index.
Definition: flecs.h:546
ecs_term_id_t first
Component or first element of pair.
Definition: flecs.h:536
int32_t field_index
Index of field for term in iterator.
Definition: flecs.h:545
ecs_id_t id_flags
Id flags of term id.
Definition: flecs.h:542
bool move
Used by internals.
Definition: flecs.h:548
ecs_inout_kind_t inout
Access to contents matched by term.
Definition: flecs.h:539
ecs_oper_kind_t oper
Operator of term.
Definition: flecs.h:540
Type that contains component lifecycle callbacks.
Definition: flecs.h:619
ecs_copy_t copy_ctor
Ctor + copy.
Definition: flecs.h:626
void * ctx
User defined context.
Definition: flecs.h:657
ecs_iter_action_t on_remove
Callback that is invoked when an instance of the component is removed.
Definition: flecs.h:655
void * binding_ctx
Language binding context.
Definition: flecs.h:658
ecs_move_t move_dtor
Move + dtor.
Definition: flecs.h:641
ecs_copy_t copy
copy assignment
Definition: flecs.h:622
ecs_iter_action_t on_set
Callback that is invoked when an instance of the component is set.
Definition: flecs.h:650
ecs_move_t move
move assignment
Definition: flecs.h:623
ecs_xtor_t ctor
ctor
Definition: flecs.h:620
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition: flecs.h:660
ecs_iter_action_t on_add
Callback that is invoked when an instance of a component is added.
Definition: flecs.h:645
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition: flecs.h:661
ecs_move_t move_ctor
Ctor + move.
Definition: flecs.h:629
ecs_move_t ctor_move_dtor
Ctor + move + dtor (or move_ctor + dtor).
Definition: flecs.h:635
ecs_xtor_t dtor
dtor
Definition: flecs.h:621
Type that contains component information (passed to ctors/dtors/...)
Definition: flecs.h:668
ecs_size_t alignment
Alignment of type.
Definition: flecs.h:670
ecs_size_t size
Size of type.
Definition: flecs.h:669
const char * name
Type name.
Definition: flecs.h:673
ecs_entity_t component
Handle to component (do not set)
Definition: flecs.h:672
ecs_type_hooks_t hooks
Type hooks.
Definition: flecs.h:671
An array with (component) ids.
Definition: flecs.h:223
Type that contains information about the world.
Definition: flecs.h:928
int64_t get_mut_count
get_mut/emplace commands processed
Definition: flecs.h:978
float delta_time
Time passed to or computed by ecs_progress.
Definition: flecs.h:935
int32_t id_count
Number of ids in the world (excluding wildcards)
Definition: flecs.h:958
ecs_entity_t min_id
First allowed entity id.
Definition: flecs.h:931
int32_t trivial_table_count
Number of tables with trivial components (no lifecycle callbacks)
Definition: flecs.h:966
int64_t set_count
set commands processed
Definition: flecs.h:977
float world_time_total
Time elapsed in simulation.
Definition: flecs.h:942
int32_t tag_id_count
Number of tag (no data) ids in the world.
Definition: flecs.h:959
int32_t tag_table_count
Number of tag-only tables.
Definition: flecs.h:965
int32_t component_id_count
Number of component (data) ids in the world.
Definition: flecs.h:960
int32_t table_record_count
Total number of table records (entries in table caches)
Definition: flecs.h:968
int64_t pipeline_build_count_total
Total number of pipeline builds.
Definition: flecs.h:954
int32_t table_count
Number of tables.
Definition: flecs.h:964
float delta_time_raw
Raw delta time (no time scaling)
Definition: flecs.h:934
float frame_time_total
Total time spent processing a frame.
Definition: flecs.h:938
ecs_entity_t last_id
Last issued entity id.
Definition: flecs.h:930
float world_time_total_raw
Time elapsed in simulation (no scaling)
Definition: flecs.h:943
int64_t table_create_total
Total number of times a table was created.
Definition: flecs.h:952
int64_t observers_ran_frame
Total number of times observer was invoked.
Definition: flecs.h:956
float system_time_total
Total time spent in systems.
Definition: flecs.h:939
int64_t id_delete_total
Total number of times an id was deleted.
Definition: flecs.h:951
int64_t systems_ran_frame
Total number of systems ran in last frame.
Definition: flecs.h:955
float merge_time_total
Total time spent in merges.
Definition: flecs.h:941
int64_t discard_count
commands discarded, happens when entity is no longer alive when running the command
Definition: flecs.h:981
int64_t clear_count
clear commands processed
Definition: flecs.h:976
ecs_entity_t last_component_id
Last issued component entity id.
Definition: flecs.h:929
int32_t empty_table_count
Number of tables without entities.
Definition: flecs.h:967
int64_t frame_count_total
Total number of frames.
Definition: flecs.h:946
ecs_entity_t max_id
Last allowed entity id.
Definition: flecs.h:932
int64_t merge_count_total
Total number of merges.
Definition: flecs.h:947
int64_t other_count
other commands processed
Definition: flecs.h:980
int64_t batched_command_count
commands batched
Definition: flecs.h:983
int64_t table_delete_total
Total number of times a table was deleted.
Definition: flecs.h:953
int64_t delete_count
delete commands processed
Definition: flecs.h:975
int64_t rematch_count_total
Total number of rematches.
Definition: flecs.h:948
int64_t id_create_total
Total number of times a new id was created.
Definition: flecs.h:950
int64_t batched_entity_count
entities for which commands were batched
Definition: flecs.h:982
float time_scale
Time scale applied to delta_time.
Definition: flecs.h:936
int32_t pair_id_count
Number of pair ids in the world.
Definition: flecs.h:961
float rematch_time_total
Time spent on query rematching.
Definition: flecs.h:944
float target_fps
Target fps.
Definition: flecs.h:937
int32_t wildcard_id_count
Number of wildcard ids.
Definition: flecs.h:962
int32_t table_storage_count
Total number of table storages.
Definition: flecs.h:969
float emit_time_total
Total time spent notifying observers.
Definition: flecs.h:940
int64_t modified_count
modified commands processed
Definition: flecs.h:979
const char * name_prefix
Value set by ecs_set_name_prefix.
Definition: flecs.h:986
int64_t add_count
add commands processed
Definition: flecs.h:973
int64_t remove_count
remove commands processed
Definition: flecs.h:974
flecs::term term() const
Create a term for a (component) type.