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
2037FLECS_API
2039 ecs_world_t *world,
2040 const ecs_entity_desc_t *desc);
2041
2068FLECS_API
2070 ecs_world_t *world,
2071 const ecs_bulk_desc_t *desc);
2072
2082FLECS_API
2084 ecs_world_t *world,
2085 ecs_id_t id,
2086 int32_t count);
2087
2099FLECS_API
2101 ecs_world_t *world,
2102 ecs_entity_t dst,
2103 ecs_entity_t src,
2104 bool copy_value);
2105
2115FLECS_API
2117 ecs_world_t *world,
2118 ecs_entity_t entity);
2119
2127FLECS_API
2129 ecs_world_t *world,
2130 ecs_id_t id);
2131
2148FLECS_API
2150 ecs_world_t *world,
2151 ecs_entity_t entity,
2152 ecs_id_t id);
2153
2162FLECS_API
2164 ecs_world_t *world,
2165 ecs_entity_t entity,
2166 ecs_id_t id);
2167
2190FLECS_API
2192 ecs_world_t *world,
2193 ecs_entity_t entity,
2194 ecs_id_t id);
2195
2204FLECS_API
2206 ecs_world_t *world,
2207 ecs_entity_t entity);
2208
2209
2217FLECS_API
2219 ecs_world_t *world,
2220 ecs_id_t id);
2221
2229FLECS_API
2231 ecs_world_t *world,
2232 ecs_id_t id);
2233
2240FLECS_API
2242 const ecs_world_t *world);
2243
2261FLECS_API
2263 ecs_world_t *world,
2264 ecs_entity_t entity,
2265 bool enabled);
2266
2280FLECS_API
2282 ecs_world_t *world,
2283 ecs_entity_t entity,
2284 ecs_id_t id,
2285 bool enable);
2286
2297FLECS_API
2299 const ecs_world_t *world,
2300 ecs_entity_t entity,
2301 ecs_id_t id);
2302
2320FLECS_API
2321const void* ecs_get_id(
2322 const ecs_world_t *world,
2323 ecs_entity_t entity,
2324 ecs_id_t id);
2325
2336FLECS_API
2338 const ecs_world_t *world,
2339 ecs_entity_t entity,
2340 ecs_id_t id);
2341
2350FLECS_API
2352 const ecs_world_t *world,
2353 ecs_ref_t *ref,
2354 ecs_id_t id);
2355
2363FLECS_API
2365 const ecs_world_t *world,
2366 ecs_ref_t *ref);
2367
2382FLECS_API
2384 ecs_world_t *world,
2385 ecs_entity_t entity,
2386 ecs_id_t id);
2387
2406FLECS_API
2407ecs_record_t* ecs_write_begin(
2408 ecs_world_t *world,
2409 ecs_entity_t entity);
2410
2417FLECS_API
2419 ecs_record_t *record);
2420
2440FLECS_API
2441const ecs_record_t* ecs_read_begin(
2442 ecs_world_t *world,
2443 ecs_entity_t entity);
2444
2450FLECS_API
2452 const ecs_record_t *record);
2453
2467FLECS_API
2469 ecs_world_t *world,
2470 const ecs_record_t *record,
2471 ecs_id_t id);
2472
2481FLECS_API
2483 ecs_world_t *world,
2484 ecs_record_t *record,
2485 ecs_id_t id);
2486
2500FLECS_API
2502 ecs_world_t *world,
2503 ecs_entity_t entity,
2504 ecs_id_t id);
2505
2516FLECS_API
2518 ecs_world_t *world,
2519 ecs_entity_t entity,
2520 ecs_id_t id);
2521
2535FLECS_API
2537 ecs_world_t *world,
2538 ecs_entity_t entity,
2539 ecs_id_t id,
2540 size_t size,
2541 const void *ptr);
2542
2569FLECS_API
2571 const ecs_world_t *world,
2572 ecs_entity_t e);
2573
2582FLECS_API
2584 const ecs_world_t *world,
2585 ecs_entity_t e);
2586
2592FLECS_API
2594 ecs_entity_t e);
2595
2607FLECS_API
2609 ecs_world_t *world,
2610 ecs_entity_t entity);
2611
2628FLECS_API
2630 const ecs_world_t *world,
2631 ecs_entity_t e);
2632
2653FLECS_API
2655 ecs_world_t *world,
2656 ecs_entity_t entity);
2657
2676FLECS_API
2678 ecs_world_t *world,
2679 ecs_id_t id);
2680
2688FLECS_API
2690 const ecs_world_t *world,
2691 ecs_entity_t entity);
2692
2707FLECS_API
2709 const ecs_world_t *world,
2710 ecs_entity_t entity);
2711
2718FLECS_API
2720 const ecs_world_t *world,
2721 ecs_entity_t entity);
2722
2730FLECS_API
2732 const ecs_world_t *world,
2733 const ecs_type_t* type);
2734
2743FLECS_API
2745 const ecs_world_t *world,
2746 const ecs_table_t *table);
2747
2759FLECS_API
2761 const ecs_world_t *world,
2762 ecs_entity_t entity);
2763
2773FLECS_API
2775 const ecs_world_t *world,
2776 ecs_entity_t entity,
2777 ecs_id_t id);
2778
2793FLECS_API
2795 const ecs_world_t *world,
2796 ecs_entity_t entity,
2797 ecs_entity_t rel,
2798 int32_t index);
2799
2818FLECS_API
2820 const ecs_world_t *world,
2821 ecs_entity_t entity,
2822 ecs_entity_t rel,
2823 ecs_id_t id);
2824
2835FLECS_API
2837 const ecs_world_t *world,
2838 ecs_entity_t entity,
2839 ecs_entity_t rel);
2840
2848FLECS_API
2850 const ecs_world_t *world,
2851 ecs_id_t entity);
2852
2869FLECS_API
2870const char* ecs_get_name(
2871 const ecs_world_t *world,
2872 ecs_entity_t entity);
2873
2881FLECS_API
2882const char* ecs_get_symbol(
2883 const ecs_world_t *world,
2884 ecs_entity_t entity);
2885
2897FLECS_API
2899 ecs_world_t *world,
2900 ecs_entity_t entity,
2901 const char *name);
2902
2914FLECS_API
2916 ecs_world_t *world,
2917 ecs_entity_t entity,
2918 const char *symbol);
2919
2931FLECS_API
2933 ecs_world_t *world,
2934 ecs_entity_t entity,
2935 const char *alias);
2936
2945FLECS_API
2947 const ecs_world_t *world,
2948 const char *name);
2949
2959FLECS_API
2961 const ecs_world_t *world,
2962 ecs_entity_t parent,
2963 const char *name);
2964
2983FLECS_API
2985 const ecs_world_t *world,
2986 ecs_entity_t parent,
2987 const char *path,
2988 const char *sep,
2989 const char *prefix,
2990 bool recursive);
2991
2999FLECS_API
3001 const ecs_world_t *world,
3002 const char *symbol,
3003 bool lookup_as_path);
3004
3024FLECS_API
3026 const ecs_world_t *world,
3027 ecs_entity_t parent,
3028 ecs_entity_t child,
3029 const char *sep,
3030 const char *prefix);
3031
3043 const ecs_world_t *world,
3044 ecs_entity_t parent,
3045 ecs_entity_t child,
3046 const char *sep,
3047 const char *prefix,
3048 ecs_strbuf_t *buf);
3049
3065FLECS_API
3067 ecs_world_t *world,
3068 ecs_entity_t parent,
3069 const char *path,
3070 const char *sep,
3071 const char *prefix);
3072
3087FLECS_API
3089 ecs_world_t *world,
3090 ecs_entity_t entity,
3091 ecs_entity_t parent,
3092 const char *path,
3093 const char *sep,
3094 const char *prefix);
3095
3107FLECS_API
3109 ecs_world_t *world,
3110 ecs_entity_t scope);
3111
3119FLECS_API
3121 const ecs_world_t *world);
3122
3132FLECS_API
3134 ecs_world_t *world,
3135 const char *prefix);
3136
3161FLECS_API
3163 ecs_world_t *world,
3164 const ecs_entity_t *lookup_path);
3165
3172FLECS_API
3174 const ecs_world_t *world);
3175
3199FLECS_API
3201 ecs_world_t *world,
3202 const ecs_component_desc_t *desc);
3203
3215FLECS_API
3217 ecs_world_t *world,
3218 ecs_entity_t id,
3219 const ecs_type_hooks_t *hooks);
3220
3227FLECS_API
3229 ecs_world_t *world,
3230 ecs_entity_t id);
3231
3254FLECS_API
3256 const ecs_world_t *world,
3257 ecs_id_t id);
3258
3267FLECS_API
3269 ecs_world_t *world,
3270 ecs_id_t id);
3271
3281FLECS_API
3283 const ecs_world_t *world,
3284 ecs_id_t id);
3285
3305FLECS_API
3307 const ecs_world_t *world,
3308 ecs_id_t id);
3309
3317FLECS_API
3319 ecs_id_t id,
3320 ecs_id_t pattern);
3321
3327FLECS_API
3329 ecs_id_t id);
3330
3336FLECS_API
3338 ecs_id_t id);
3339
3353FLECS_API
3355 const ecs_world_t *world,
3356 ecs_id_t id);
3357
3366FLECS_API
3367ecs_flags32_t ecs_id_get_flags(
3368 const ecs_world_t *world,
3369 ecs_id_t id);
3370
3377FLECS_API
3379 ecs_id_t id_flags);
3380
3388FLECS_API
3390 const ecs_world_t *world,
3391 ecs_id_t id);
3392
3400FLECS_API
3402 const ecs_world_t *world,
3403 ecs_id_t id,
3404 ecs_strbuf_t *buf);
3405
3423FLECS_API
3424ecs_iter_t ecs_term_iter(
3425 const ecs_world_t *world,
3426 ecs_term_t *term);
3427
3436FLECS_API
3438 const ecs_iter_t *it,
3439 ecs_term_t *term);
3440
3450FLECS_API
3452 ecs_iter_t *it);
3453
3462FLECS_API
3463ecs_iter_t ecs_children(
3464 const ecs_world_t *world,
3465 ecs_entity_t parent);
3466
3473FLECS_API
3475 ecs_iter_t *it);
3476
3482FLECS_API
3484 const ecs_term_id_t *id);
3485
3497FLECS_API
3499 const ecs_term_t *term);
3500
3501FLECS_API
3502bool ecs_term_match_this(
3503 const ecs_term_t *term);
3504
3505FLECS_API
3506bool ecs_term_match_0(
3507 const ecs_term_t *term);
3508
3527FLECS_API
3529 const ecs_world_t *world,
3530 ecs_term_t *term);
3531
3540FLECS_API
3542 const ecs_term_t *src);
3543
3554FLECS_API
3556 ecs_term_t *src);
3557
3564FLECS_API
3566 ecs_term_t *term);
3567
3591FLECS_API
3593 ecs_world_t *world,
3594 const ecs_filter_desc_t *desc);
3595
3601FLECS_API
3603 ecs_filter_t *filter);
3604
3618FLECS_API
3620 const ecs_world_t *world,
3621 ecs_filter_t *filter);
3622
3634FLECS_API
3636 const ecs_filter_t *filter);
3637
3642FLECS_API
3644 const ecs_world_t *world,
3645 const ecs_term_t *term);
3646
3651FLECS_API
3653 const ecs_world_t *world,
3654 const ecs_filter_t *filter);
3655
3665FLECS_API
3667 const ecs_world_t *world,
3668 const ecs_filter_t *filter);
3669
3678FLECS_API
3680 const ecs_iter_t *it,
3681 const ecs_filter_t *filter);
3682
3702FLECS_API
3704 const ecs_world_t *world,
3705 const ecs_filter_t *filter);
3706
3716FLECS_API
3718 ecs_iter_t *it);
3719
3723FLECS_API
3725 ecs_iter_t *it);
3726
3728FLECS_API
3730 ecs_filter_t *dst,
3731 ecs_filter_t *src);
3732
3734FLECS_API
3736 ecs_filter_t *dst,
3737 const ecs_filter_t *src);
3738
3781FLECS_API
3783 ecs_world_t *world,
3784 const ecs_query_desc_t *desc);
3785
3793FLECS_API
3796
3803FLECS_API
3805 ecs_query_t *query);
3806
3834FLECS_API
3836 const ecs_world_t *world,
3838
3848FLECS_API
3850 ecs_iter_t *iter);
3851
3855FLECS_API
3857 ecs_iter_t *iter);
3858
3869FLECS_API
3871 ecs_iter_t *iter);
3872
3890FLECS_API
3892 ecs_iter_t *iter);
3893
3923FLECS_API
3926 const ecs_iter_t *it);
3927
3938FLECS_API
3940 ecs_iter_t *it);
3941
3964FLECS_API
3966 ecs_iter_t *it,
3967 uint64_t group_id);
3968
3977FLECS_API
3980 uint64_t group_id);
3981
3990FLECS_API
3993 uint64_t group_id);
3994
4003FLECS_API
4006
4012FLECS_API
4014 const ecs_query_t *query);
4015
4021FLECS_API
4023 const ecs_query_t *query);
4024
4030FLECS_API
4032 const ecs_query_t *query);
4033
4041FLECS_API
4043 const ecs_query_t *query);
4044
4053typedef struct ecs_event_desc_t {
4056
4061
4064
4068
4070 int32_t offset;
4071
4075 int32_t count;
4076
4079
4081 const void *param;
4082
4085
4087 ecs_flags32_t flags;
4089
4119FLECS_API
4121 ecs_world_t *world,
4122 ecs_event_desc_t *desc);
4123
4133FLECS_API
4135 ecs_world_t *world,
4136 const ecs_observer_desc_t *desc);
4137
4147FLECS_API
4149 ecs_iter_t *it);
4150
4151FLECS_API
4152void* ecs_get_observer_ctx(
4153 const ecs_world_t *world,
4155
4156FLECS_API
4157void* ecs_get_observer_binding_ctx(
4158 const ecs_world_t *world,
4160
4190FLECS_API
4192 const ecs_world_t *world,
4193 const ecs_poly_t *poly,
4194 ecs_iter_t *iter,
4195 ecs_term_t *filter);
4196
4210FLECS_API
4212 ecs_iter_t *it);
4213
4223FLECS_API
4225 ecs_iter_t *it);
4226
4238FLECS_API
4240 ecs_iter_t *it);
4241
4254FLECS_API
4256 ecs_iter_t *it);
4257
4265FLECS_API
4267 ecs_iter_t *it);
4268
4302FLECS_API
4304 ecs_iter_t *it,
4305 int32_t var_id,
4306 ecs_entity_t entity);
4307
4315FLECS_API
4317 ecs_iter_t *it,
4318 int32_t var_id,
4319 const ecs_table_t *table);
4320
4328FLECS_API
4330 ecs_iter_t *it,
4331 int32_t var_id,
4332 const ecs_table_range_t *range);
4333
4345FLECS_API
4347 ecs_iter_t *it,
4348 int32_t var_id);
4349
4362FLECS_API
4364 ecs_iter_t *it,
4365 int32_t var_id);
4366
4379FLECS_API
4381 ecs_iter_t *it,
4382 int32_t var_id);
4383
4384
4396FLECS_API
4398 ecs_iter_t *it,
4399 int32_t var_id);
4400
4416FLECS_API
4417ecs_iter_t ecs_page_iter(
4418 const ecs_iter_t *it,
4419 int32_t offset,
4420 int32_t limit);
4421
4428FLECS_API
4430 ecs_iter_t *it);
4431
4452FLECS_API
4454 const ecs_iter_t *it,
4455 int32_t index,
4456 int32_t count);
4457
4464FLECS_API
4466 ecs_iter_t *it);
4467
4491FLECS_API
4493 const ecs_iter_t *it,
4494 size_t size,
4495 int32_t index);
4496
4505FLECS_API
4507 const ecs_iter_t *it,
4508 int32_t index);
4509
4520FLECS_API
4522 const ecs_iter_t *it,
4523 int32_t index);
4524
4531FLECS_API
4533 const ecs_iter_t *it,
4534 int32_t index);
4535
4542FLECS_API
4544 const ecs_iter_t *it,
4545 int32_t index);
4546
4554FLECS_API
4556 const ecs_iter_t *it,
4557 int32_t index);
4558
4567FLECS_API
4569 const ecs_iter_t *it,
4570 int32_t index);
4571
4585FLECS_API
4587 const ecs_iter_t *it,
4588 int32_t index);
4589
4601FLECS_API
4603 const ecs_iter_t *it);
4604
4605
4619FLECS_API
4621 const ecs_table_t *table);
4622
4631FLECS_API
4633 const ecs_table_t *table,
4634 int32_t index,
4635 int32_t offset);
4636
4645FLECS_API
4647 const ecs_world_t *world,
4648 const ecs_table_t *table,
4649 ecs_id_t id);
4650
4659FLECS_API
4661 const ecs_world_t *world,
4662 const ecs_table_t *table,
4663 ecs_id_t id,
4664 int32_t offset);
4665
4676FLECS_API
4678 const ecs_world_t *world,
4679 const ecs_table_t *table,
4680 ecs_entity_t rel);
4681
4687FLECS_API
4689 const ecs_table_t *table);
4690
4692FLECS_API
4694 const ecs_table_t *table,
4695 int32_t index);
4696
4698FLECS_API
4700 const ecs_table_t *table,
4701 int32_t index);
4702
4711FLECS_API
4713 const ecs_table_t *table);
4714
4724FLECS_API
4726 ecs_world_t *world,
4727 ecs_table_t *table,
4728 ecs_id_t id);
4729
4739FLECS_API
4741 ecs_world_t *world,
4742 ecs_table_t *table,
4743 ecs_id_t id);
4744
4760FLECS_API
4762 ecs_world_t *world,
4763 ecs_table_t *table);
4764
4771FLECS_API
4773 ecs_world_t *world,
4774 ecs_table_t *table);
4775
4783FLECS_API
4785 ecs_table_t *table);
4786
4794FLECS_API
4796 ecs_world_t* world,
4797 ecs_table_t* table,
4798 int32_t row_1,
4799 int32_t row_2);
4800
4823FLECS_API
4825 ecs_world_t *world,
4826 ecs_entity_t entity,
4827 ecs_record_t *record,
4828 ecs_table_t *table,
4829 const ecs_type_t *added,
4830 const ecs_type_t *removed);
4831
4833FLECS_API
4834ecs_record_t* ecs_record_find(
4835 const ecs_world_t *world,
4836 ecs_entity_t entity);
4837
4839FLECS_API
4841 const ecs_record_t *r,
4842 int32_t column,
4843 size_t c_size);
4844
4860FLECS_API
4862 const ecs_world_t *world,
4863 const ecs_table_t *table,
4864 ecs_id_t id,
4865 ecs_id_t *id_out);
4866
4897FLECS_API
4899 const ecs_world_t *world,
4900 const ecs_table_t *table,
4901 int32_t offset,
4902 ecs_id_t id,
4903 ecs_id_t *id_out);
4904
4941FLECS_API
4943 const ecs_world_t *world,
4944 const ecs_table_t *table,
4945 int32_t offset,
4946 ecs_id_t id,
4947 ecs_entity_t rel,
4948 ecs_flags32_t flags, /* EcsSelf and/or EcsUp */
4949 ecs_entity_t *subject_out,
4950 ecs_id_t *id_out,
4951 struct ecs_table_record_t **tr_out);
4952
4968FLECS_API
4970 const ecs_world_t *world,
4971 ecs_entity_t type,
4972 void *ptr);
4973
4981FLECS_API
4983 const ecs_world_t *world,
4984 const ecs_type_info_t *ti,
4985 void *ptr);
4986
4993FLECS_API
4995 ecs_world_t *world,
4996 ecs_entity_t type);
4997
5006 const ecs_world_t *world,
5007 const ecs_type_info_t *ti,
5008 void *ptr);
5009
5017FLECS_API
5019 const ecs_world_t *world,
5020 ecs_entity_t type,
5021 void* ptr);
5022
5029FLECS_API
5031 ecs_world_t *world,
5032 ecs_entity_t type,
5033 void* ptr);
5034
5043FLECS_API
5045 const ecs_world_t *world,
5046 const ecs_type_info_t *ti,
5047 void* dst,
5048 const void *src);
5049
5058FLECS_API
5060 const ecs_world_t *world,
5061 ecs_entity_t type,
5062 void* dst,
5063 const void *src);
5064
5074 const ecs_world_t *world,
5075 const ecs_type_info_t *ti,
5076 void* dst,
5077 void *src);
5078
5088 const ecs_world_t *world,
5089 ecs_entity_t type,
5090 void* dst,
5091 void *src);
5092
5102 const ecs_world_t *world,
5103 const ecs_type_info_t *ti,
5104 void* dst,
5105 void *src);
5106
5116 const ecs_world_t *world,
5117 ecs_entity_t type,
5118 void* dst,
5119 void *src);
5120
5135#include "flecs/addons/flecs_c.h"
5136
5137#ifdef __cplusplus
5138}
5139#endif
5140
5141#include "flecs/private/addons.h"
5142
5143#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.
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_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_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:4078
ecs_table_t * table
The table for which to notify.
Definition: flecs.h:4063
int32_t count
Limit number of notified entities to count.
Definition: flecs.h:4075
ecs_table_t * other_table
Optional 2nd table to notify.
Definition: flecs.h:4067
const void * param
Optional context.
Definition: flecs.h:4081
int32_t offset
Limit notified entities to ones starting from offset (row) in table.
Definition: flecs.h:4070
const ecs_type_t * ids
Component ids.
Definition: flecs.h:4060
ecs_poly_t * observable
Observable (usually the world)
Definition: flecs.h:4084
ecs_entity_t event
The event id.
Definition: flecs.h:4055
ecs_flags32_t flags
Event flags.
Definition: flecs.h:4087
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.