Flecs v4.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs.h
Go to the documentation of this file.
1
8#ifndef FLECS_H
9#define FLECS_H
10
33/* Flecs version macros */
34#define FLECS_VERSION_MAJOR 4
35#define FLECS_VERSION_MINOR 1
36#define FLECS_VERSION_PATCH 5
39#define FLECS_VERSION FLECS_VERSION_IMPL(\
40 FLECS_VERSION_MAJOR, FLECS_VERSION_MINOR, FLECS_VERSION_PATCH)
41
45#ifdef FLECS_CONFIG_HEADER
46#include "flecs_config.h"
47#endif
48
51#ifndef ecs_float_t
52#define ecs_float_t float
53#endif
54
58#ifndef ecs_ftime_t
59#define ecs_ftime_t ecs_float_t
60#endif
61
62
68// #define FLECS_ACCURATE_COUNTERS
69
75// #define FLECS_DISABLE_COUNTERS
76
77/* Make sure provided configuration is valid */
78#if defined(FLECS_DEBUG) && defined(FLECS_NDEBUG)
79#warning "invalid configuration: cannot both define FLECS_DEBUG and FLECS_NDEBUG"
80#endif
81#if defined(FLECS_DEBUG) && defined(NDEBUG)
82#warning "invalid configuration: cannot both define FLECS_DEBUG and NDEBUG"
83#endif
84
89#if !defined(FLECS_DEBUG) && !defined(FLECS_NDEBUG)
90#if defined(NDEBUG)
91#define FLECS_NDEBUG
92#else
93#define FLECS_DEBUG
94#endif
95#endif
96
101#ifdef FLECS_SANITIZE
102#ifndef FLECS_DEBUG
103#define FLECS_DEBUG /* If sanitized mode is enabled, so is debug mode */
104#endif
105#endif
106
111#ifdef FLECS_DEBUG
112#ifndef FLECS_DEBUG_INFO
113#define FLECS_DEBUG_INFO
114#endif
115#ifndef FLECS_EXCLUSIVE_ACCESS
116#define FLECS_EXCLUSIVE_ACCESS /* Enable exclusive access checks in debug mode */
117#endif
118#endif
119
120/* Tip: if you see weird behavior that you think might be a bug, make sure to
121 * test with the FLECS_DEBUG or FLECS_SANITIZE flags enabled. There's a good
122 * chance that this gives you more information about the issue! */
123
137// #define FLECS_SOFT_ASSERT
138
144// #define FLECS_KEEP_ASSERT
145
152// #define FLECS_DEFAULT_TO_UNCACHED_QUERIES
153
166// #define FLECS_CREATE_MEMBER_ENTITIES
167
176// #define FLECS_CPP_NO_AUTO_REGISTRATION
177
185// #define FLECS_CPP_NO_ENUM_REFLECTION
186
191// #define FLECS_NO_ALWAYS_INLINE
192
220// #define FLECS_CUSTOM_BUILD
221
222#ifndef FLECS_CUSTOM_BUILD
223#define FLECS_ALERTS
224#define FLECS_APP
225// #define FLECS_C /**< C API convenience macros, always enabled. */
226#define FLECS_CPP
227#define FLECS_DOC
228// #define FLECS_EXCLUSIVE_ACCESS /**< Enable exclusive world access checks. */
229// #define FLECS_JOURNAL /**< Journaling addon. */
230#define FLECS_JSON
231#define FLECS_HTTP
232#define FLECS_LOG
233#define FLECS_META
234#define FLECS_METRICS
235#define FLECS_MODULE
236#define FLECS_OS_API_IMPL
237// #define FLECS_PERF_TRACE /**< Enable performance tracing. */
238#define FLECS_PIPELINE
239#define FLECS_REST
240#define FLECS_PARSER
241#define FLECS_QUERY_DSL
242#define FLECS_SCRIPT
243// #define FLECS_SCRIPT_MATH /**< Math functions for Flecs script (may require linking with libm). */
244#define FLECS_SYSTEM
245#define FLECS_STATS
246#define FLECS_TIMER
247#define FLECS_UNITS
248#endif // ifndef FLECS_CUSTOM_BUILD
249
253// #define FLECS_LOW_FOOTPRINT
254#ifdef FLECS_LOW_FOOTPRINT
255#define FLECS_HI_COMPONENT_ID 16
256#define FLECS_HI_ID_RECORD_ID 16
257#define FLECS_ENTITY_PAGE_BITS 6
258#define FLECS_USE_OS_ALLOC
259#define FLECS_DEFAULT_TO_UNCACHED_QUERIES
260#endif
261
276#ifndef FLECS_HI_COMPONENT_ID
277#define FLECS_HI_COMPONENT_ID 256
278#endif
279
286#ifndef FLECS_HI_ID_RECORD_ID
287#define FLECS_HI_ID_RECORD_ID 1024
288#endif
289
295#ifndef FLECS_SPARSE_PAGE_BITS
296#define FLECS_SPARSE_PAGE_BITS 6
297#endif
298
301#ifndef FLECS_ENTITY_PAGE_BITS
302#define FLECS_ENTITY_PAGE_BITS 10
303#endif
304
309// #define FLECS_USE_OS_ALLOC
310
313#ifndef FLECS_ID_DESC_MAX
314#define FLECS_ID_DESC_MAX 32
315#endif
316
319#ifndef FLECS_EVENT_DESC_MAX
320#define FLECS_EVENT_DESC_MAX 8
321#endif
322
325#define FLECS_VARIABLE_COUNT_MAX 64
326
329#ifndef FLECS_TERM_COUNT_MAX
330#define FLECS_TERM_COUNT_MAX 32
331#endif
332
335#ifndef FLECS_TERM_ARG_COUNT_MAX
336#define FLECS_TERM_ARG_COUNT_MAX 16
337#endif
338
341#ifndef FLECS_QUERY_VARIABLE_COUNT_MAX
342#define FLECS_QUERY_VARIABLE_COUNT_MAX 64
343#endif
344
347#ifndef FLECS_QUERY_SCOPE_NESTING_MAX
348#define FLECS_QUERY_SCOPE_NESTING_MAX 8
349#endif
350
355#ifndef FLECS_DAG_DEPTH_MAX
356#define FLECS_DAG_DEPTH_MAX 128
357#endif
358
363#define FLECS_TREE_SPAWNER_DEPTH_CACHE_SIZE (6)
364
367#include "flecs/private/api_defines.h"
368
378typedef uint64_t ecs_id_t;
379
386
402typedef struct {
404 int32_t count;
405} ecs_type_t;
406
430
433
436
438typedef struct ecs_term_t ecs_term_t;
439
442
461
466
471typedef struct ecs_iter_t ecs_iter_t;
472
481typedef struct ecs_ref_t ecs_ref_t;
482
487
492
495
498
518typedef void ecs_poly_t;
519
522
529
532
535#include "flecs/datastructures/vec.h" /* Vector datatype */
536#include "flecs/datastructures/sparse.h" /* Sparse set */
537#include "flecs/datastructures/block_allocator.h" /* Block allocator */
538#include "flecs/datastructures/stack_allocator.h" /* Stack allocator */
539#include "flecs/datastructures/map.h" /* Map */
540#include "flecs/datastructures/allocator.h" /* Allocator */
541#include "flecs/datastructures/strbuf.h" /* String builder */
542#include "flecs/os_api.h" /* Abstraction for operating system functions */
543
544#ifdef __cplusplus
545extern "C" {
546#endif
547
572typedef void (*ecs_run_action_t)(
573 ecs_iter_t *it);
574
581typedef void (*ecs_iter_action_t)(
582 ecs_iter_t *it);
583
592 ecs_iter_t *it);
593
600 ecs_iter_t *it);
601
604 ecs_entity_t e1,
605 const void *ptr1,
606 ecs_entity_t e2,
607 const void *ptr2);
608
611 ecs_world_t* world,
612 ecs_table_t* table,
613 ecs_entity_t* entities,
614 void* ptr,
615 int32_t size,
616 int32_t lo,
617 int32_t hi,
618 ecs_order_by_action_t order_by);
619
621typedef uint64_t (*ecs_group_by_action_t)(
622 ecs_world_t *world,
623 ecs_table_t *table,
624 ecs_id_t group_id,
625 void *ctx);
626
628typedef void* (*ecs_group_create_action_t)(
629 ecs_world_t *world,
630 uint64_t group_id,
631 void *group_by_ctx); /* from ecs_query_desc_t */
632
635 ecs_world_t *world,
636 uint64_t group_id,
637 void *group_ctx, /* return value from ecs_group_create_action_t */
638 void *group_by_ctx); /* from ecs_query_desc_t */
639
641typedef void (*ecs_module_action_t)(
642 ecs_world_t *world);
643
645typedef void (*ecs_fini_action_t)(
646 ecs_world_t *world,
647 void *ctx);
648
650typedef void (*ecs_ctx_free_t)(
651 void *ctx);
652
654typedef int (*ecs_compare_action_t)(
655 const void *ptr1,
656 const void *ptr2);
657
659typedef uint64_t (*ecs_hash_value_action_t)(
660 const void *ptr);
661
663typedef void (*ecs_xtor_t)(
664 void *ptr,
665 int32_t count,
666 const ecs_type_info_t *type_info);
667
669typedef void (*ecs_copy_t)(
670 void *dst_ptr,
671 const void *src_ptr,
672 int32_t count,
673 const ecs_type_info_t *type_info);
674
676typedef void (*ecs_move_t)(
677 void *dst_ptr,
678 void *src_ptr,
679 int32_t count,
680 const ecs_type_info_t *type_info);
681
683typedef int (*ecs_cmp_t)(
684 const void *a_ptr,
685 const void *b_ptr,
686 const ecs_type_info_t *type_info);
687
689typedef bool (*ecs_equals_t)(
690 const void *a_ptr,
691 const void *b_ptr,
692 const ecs_type_info_t *type_info);
693
695typedef void (*flecs_poly_dtor_t)(
696 ecs_poly_t *poly);
697
716
727
735
742#define EcsSelf (1llu << 63)
743
748#define EcsUp (1llu << 62)
749
754#define EcsTrav (1llu << 61)
755
760#define EcsCascade (1llu << 60)
761
766#define EcsDesc (1llu << 59)
767
772#define EcsIsVariable (1llu << 58)
773
778#define EcsIsEntity (1llu << 57)
779
784#define EcsIsName (1llu << 56)
785
790#define EcsTraverseFlags (EcsSelf|EcsUp|EcsTrav|EcsCascade|EcsDesc)
791
796#define EcsTermRefFlags (EcsTraverseFlags|EcsIsVariable|EcsIsEntity|EcsIsName)
797
812
834
875
904
912/* Flags that can be used to check which hooks a type has set */
913#define ECS_TYPE_HOOK_CTOR ECS_CAST(ecs_flags32_t, 1 << 0)
914#define ECS_TYPE_HOOK_DTOR ECS_CAST(ecs_flags32_t, 1 << 1)
915#define ECS_TYPE_HOOK_COPY ECS_CAST(ecs_flags32_t, 1 << 2)
916#define ECS_TYPE_HOOK_MOVE ECS_CAST(ecs_flags32_t, 1 << 3)
917#define ECS_TYPE_HOOK_COPY_CTOR ECS_CAST(ecs_flags32_t, 1 << 4)
918#define ECS_TYPE_HOOK_MOVE_CTOR ECS_CAST(ecs_flags32_t, 1 << 5)
919#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 6)
920#define ECS_TYPE_HOOK_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 7)
921#define ECS_TYPE_HOOK_CMP ECS_CAST(ecs_flags32_t, 1 << 8)
922#define ECS_TYPE_HOOK_EQUALS ECS_CAST(ecs_flags32_t, 1 << 9)
923
924
925/* Flags that can be used to set/check which hooks of a type are invalid */
926#define ECS_TYPE_HOOK_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 10)
927#define ECS_TYPE_HOOK_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 12)
928#define ECS_TYPE_HOOK_COPY_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 13)
929#define ECS_TYPE_HOOK_MOVE_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 14)
930#define ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 15)
931#define ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 16)
932#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 17)
933#define ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 18)
934#define ECS_TYPE_HOOK_CMP_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 19)
935#define ECS_TYPE_HOOK_EQUALS_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 20)
936
937/* Internal debug flag that indicates type hooks have been invoked */
938#define ECS_TYPE_HOOK_IN_USE ECS_CAST(ecs_flags32_t, 1 << 21)
939
940
941/* All valid hook flags */
942#define ECS_TYPE_HOOKS (ECS_TYPE_HOOK_CTOR|ECS_TYPE_HOOK_DTOR|\
943 ECS_TYPE_HOOK_COPY|ECS_TYPE_HOOK_MOVE|ECS_TYPE_HOOK_COPY_CTOR|\
944 ECS_TYPE_HOOK_MOVE_CTOR|ECS_TYPE_HOOK_CTOR_MOVE_DTOR|\
945 ECS_TYPE_HOOK_MOVE_DTOR|ECS_TYPE_HOOK_CMP|ECS_TYPE_HOOK_EQUALS)
946
947/* All invalid hook flags */
948#define ECS_TYPE_HOOKS_ILLEGAL (ECS_TYPE_HOOK_CTOR_ILLEGAL|\
949 ECS_TYPE_HOOK_DTOR_ILLEGAL|ECS_TYPE_HOOK_COPY_ILLEGAL|\
950 ECS_TYPE_HOOK_MOVE_ILLEGAL|ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL|\
951 ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL|ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL|\
952 ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL|ECS_TYPE_HOOK_CMP_ILLEGAL|\
953 ECS_TYPE_HOOK_EQUALS_ILLEGAL)
1018
1030
1031#include "flecs/private/api_types.h" /* Supporting API types */
1032#include "flecs/private/api_support.h" /* Supporting API functions */
1033#include "flecs/datastructures/hashmap.h" /* Hashmap */
1034#include "flecs/private/api_internals.h" /* Supporting API functions */
1035
1041
1046typedef struct ecs_entity_desc_t {
1047 int32_t _canary;
1053 const char *name;
1058 const char *sep;
1062 const char *root_sep;
1064 const char *symbol;
1080
1083
1085 const char *add_expr;
1087
1117
1131
1171 /* World */
1175 /* Matched data */
1176 int32_t offset;
1177 int32_t count;
1179 void **ptrs;
1181 const ecs_size_t *sizes;
1186 ecs_flags64_t constrained_vars;
1187 ecs_termset_t set_fields;
1188 ecs_termset_t ref_fields;
1189 ecs_termset_t row_fields;
1190 ecs_termset_t up_fields;
1192 /* Input information */
1196 int32_t event_cur;
1198 /* Query information */
1200 int8_t term_index;
1205 /* Context */
1206 void *param;
1207 void *ctx;
1210 void *run_ctx;
1212 /* Time */
1216 /* Iterator counters */
1219 /* Misc */
1220 ecs_flags32_t flags;
1222 ecs_iter_private_t priv_;
1224 /* Chained iterators */
1229};
1230
1231
1236#define EcsQueryMatchPrefab (1u << 1u)
1237
1242#define EcsQueryMatchDisabled (1u << 2u)
1243
1248#define EcsQueryMatchEmptyTables (1u << 3u)
1249
1254#define EcsQueryAllowUnresolvedByName (1u << 6u)
1255
1260#define EcsQueryTableOnly (1u << 7u)
1261
1272#define EcsQueryDetectChanges (1u << 8u)
1273
1282#define EcsQueryGroupByOrdered (1u << 9u)
1283
1293#define EcsQueryGroupByDesc (1u << 10u)
1294
1295
1369
1430
1435typedef struct ecs_event_desc_t {
1438
1443
1446
1450
1452 int32_t offset;
1453
1457 int32_t count;
1458
1461
1466 void *param;
1467
1471 const void *const_param;
1472
1475
1477 ecs_flags32_t flags;
1479
1480
1489typedef struct ecs_build_info_t {
1490 const char *compiler;
1491 const char **addons;
1492 const char **flags;
1493 const char *version;
1497 bool debug;
1501
1561
1569
1573typedef struct ecs_entity_range_t {
1574 uint32_t min;
1575 uint32_t max;
1576 uint32_t cur;
1577 ecs_vec_t recycled;
1579
1590typedef struct EcsIdentifier {
1591 char *value;
1592 ecs_size_t length;
1593 uint64_t hash;
1594 uint64_t index_hash;
1595 ecs_hashmap_t *index;
1597
1599typedef struct EcsComponent {
1600 ecs_size_t size;
1601 ecs_size_t alignment;
1603
1608
1617
1622
1624typedef struct {
1625 const char *child_name;
1627 uint32_t child;
1630
1632typedef struct {
1633 ecs_vec_t children;
1635
1646
1650/* Only include deprecated definitions if deprecated addon is required */
1651#ifdef FLECS_DEPRECATED
1653#endif
1654
1670FLECS_API extern const ecs_id_t ECS_PAIR;
1671
1673FLECS_API extern const ecs_id_t ECS_AUTO_OVERRIDE;
1674
1676FLECS_API extern const ecs_id_t ECS_TOGGLE;
1677
1679FLECS_API extern const ecs_id_t ECS_VALUE_PAIR;
1680
1688/* Built-in component IDs */
1689
1691FLECS_API extern const ecs_entity_t ecs_id(EcsComponent);
1692
1694FLECS_API extern const ecs_entity_t ecs_id(EcsIdentifier);
1695
1697FLECS_API extern const ecs_entity_t ecs_id(EcsPoly);
1698
1700FLECS_API extern const ecs_entity_t ecs_id(EcsParent);
1701
1703FLECS_API extern const ecs_entity_t ecs_id(EcsTreeSpawner);
1704
1706FLECS_API extern const ecs_entity_t ecs_id(EcsDefaultChildComponent);
1707
1709FLECS_API extern const ecs_entity_t EcsParentDepth;
1710
1712FLECS_API extern const ecs_entity_t EcsQuery;
1713
1715FLECS_API extern const ecs_entity_t EcsObserver;
1716
1718FLECS_API extern const ecs_entity_t EcsSystem;
1719
1721FLECS_API extern const ecs_entity_t ecs_id(EcsTickSource);
1722
1724FLECS_API extern const ecs_entity_t ecs_id(EcsPipelineQuery);
1725
1727FLECS_API extern const ecs_entity_t ecs_id(EcsTimer);
1728
1730FLECS_API extern const ecs_entity_t ecs_id(EcsRateFilter);
1731
1733FLECS_API extern const ecs_entity_t EcsFlecs;
1734
1736FLECS_API extern const ecs_entity_t EcsFlecsCore;
1737
1739FLECS_API extern const ecs_entity_t EcsWorld;
1740
1742FLECS_API extern const ecs_entity_t EcsWildcard;
1743
1745FLECS_API extern const ecs_entity_t EcsAny;
1746
1748FLECS_API extern const ecs_entity_t EcsThis;
1749
1751FLECS_API extern const ecs_entity_t EcsVariable;
1752
1760FLECS_API extern const ecs_entity_t EcsTransitive;
1761
1769FLECS_API extern const ecs_entity_t EcsReflexive;
1770
1781FLECS_API extern const ecs_entity_t EcsFinal;
1782
1788FLECS_API extern const ecs_entity_t EcsInheritable;
1789
1791FLECS_API extern const ecs_entity_t EcsOnInstantiate;
1792
1796FLECS_API extern const ecs_entity_t EcsOverride;
1797
1801FLECS_API extern const ecs_entity_t EcsInherit;
1802
1807FLECS_API extern const ecs_entity_t EcsDontInherit;
1808
1816FLECS_API extern const ecs_entity_t EcsSymmetric;
1817
1827FLECS_API extern const ecs_entity_t EcsExclusive;
1828
1830FLECS_API extern const ecs_entity_t EcsAcyclic;
1831
1834FLECS_API extern const ecs_entity_t EcsTraversable;
1835
1845FLECS_API extern const ecs_entity_t EcsWith;
1846
1856FLECS_API extern const ecs_entity_t EcsOneOf;
1857
1859FLECS_API extern const ecs_entity_t EcsCanToggle;
1860
1864FLECS_API extern const ecs_entity_t EcsTrait;
1865
1875FLECS_API extern const ecs_entity_t EcsRelationship;
1876
1886FLECS_API extern const ecs_entity_t EcsTarget;
1887
1890FLECS_API extern const ecs_entity_t EcsPairIsTag;
1891
1893FLECS_API extern const ecs_entity_t EcsName;
1894
1896FLECS_API extern const ecs_entity_t EcsSymbol;
1897
1899FLECS_API extern const ecs_entity_t EcsAlias;
1900
1902FLECS_API extern const ecs_entity_t EcsChildOf;
1903
1905FLECS_API extern const ecs_entity_t EcsIsA;
1906
1908FLECS_API extern const ecs_entity_t EcsDependsOn;
1909
1911FLECS_API extern const ecs_entity_t EcsSlotOf;
1912
1914FLECS_API extern const ecs_entity_t EcsOrderedChildren;
1915
1917FLECS_API extern const ecs_entity_t EcsModule;
1918
1921FLECS_API extern const ecs_entity_t EcsPrefab;
1922
1925FLECS_API extern const ecs_entity_t EcsDisabled;
1926
1930FLECS_API extern const ecs_entity_t EcsNotQueryable;
1931
1933FLECS_API extern const ecs_entity_t EcsOnAdd;
1934
1936FLECS_API extern const ecs_entity_t EcsOnRemove;
1937
1939FLECS_API extern const ecs_entity_t EcsOnSet;
1940
1942FLECS_API extern const ecs_entity_t EcsMonitor;
1943
1945FLECS_API extern const ecs_entity_t EcsOnTableCreate;
1946
1948FLECS_API extern const ecs_entity_t EcsOnTableDelete;
1949
1951FLECS_API extern const ecs_entity_t EcsOnDelete;
1952
1955FLECS_API extern const ecs_entity_t EcsOnDeleteTarget;
1956
1959FLECS_API extern const ecs_entity_t EcsRemove;
1960
1963FLECS_API extern const ecs_entity_t EcsDelete;
1964
1967FLECS_API extern const ecs_entity_t EcsPanic;
1968
1971FLECS_API extern const ecs_entity_t EcsSingleton;
1972
1974FLECS_API extern const ecs_entity_t EcsSparse;
1975
1977FLECS_API extern const ecs_entity_t EcsDontFragment;
1978
1980FLECS_API extern const ecs_entity_t EcsPredEq;
1981
1983FLECS_API extern const ecs_entity_t EcsPredMatch;
1984
1986FLECS_API extern const ecs_entity_t EcsPredLookup;
1987
1989FLECS_API extern const ecs_entity_t EcsScopeOpen;
1990
1992FLECS_API extern const ecs_entity_t EcsScopeClose;
1993
1998FLECS_API extern const ecs_entity_t EcsEmpty;
1999
2000FLECS_API extern const ecs_entity_t ecs_id(EcsPipeline);
2001FLECS_API extern const ecs_entity_t EcsOnStart;
2002FLECS_API extern const ecs_entity_t EcsPreFrame;
2003FLECS_API extern const ecs_entity_t EcsOnLoad;
2004FLECS_API extern const ecs_entity_t EcsPostLoad;
2005FLECS_API extern const ecs_entity_t EcsPreUpdate;
2006FLECS_API extern const ecs_entity_t EcsOnUpdate;
2007FLECS_API extern const ecs_entity_t EcsOnValidate;
2008FLECS_API extern const ecs_entity_t EcsPostUpdate;
2009FLECS_API extern const ecs_entity_t EcsPreStore;
2010FLECS_API extern const ecs_entity_t EcsOnStore;
2011FLECS_API extern const ecs_entity_t EcsPostFrame;
2012FLECS_API extern const ecs_entity_t EcsPhase;
2014FLECS_API extern const ecs_entity_t EcsConstant;
2018#define EcsLastInternalComponentId (ecs_id(EcsTreeSpawner))
2019
2022#define EcsFirstUserComponentId (8)
2023
2026#define EcsFirstUserEntityId (FLECS_HI_COMPONENT_ID + 128)
2027
2028/* When visualized, the reserved ID ranges look like this:
2029 * - [1..8]: Built-in components
2030 * - [9..FLECS_HI_COMPONENT_ID]: Low IDs reserved for application components
2031 * - [FLECS_HI_COMPONENT_ID + 1..EcsFirstUserEntityId]: Built-in entities
2032 */
2033
2055FLECS_API
2057
2064FLECS_API
2066
2076FLECS_API
2078 int argc,
2079 char *argv[]);
2080
2087FLECS_API
2089 ecs_world_t *world);
2090
2098FLECS_API
2100 const ecs_world_t *world);
2101
2110FLECS_API
2112 ecs_world_t *world,
2113 ecs_fini_action_t action,
2114 void *ctx);
2115
2122
2149FLECS_API
2151 const ecs_world_t *world);
2152
2160FLECS_API
2162 const ecs_world_t *world);
2163
2189FLECS_API
2191 ecs_world_t *world,
2192 ecs_ftime_t delta_time);
2193
2200FLECS_API
2202 ecs_world_t *world);
2203
2212FLECS_API
2214 ecs_world_t *world,
2215 ecs_fini_action_t action,
2216 void *ctx);
2217
2224FLECS_API
2226 ecs_world_t *world);
2227
2234FLECS_API
2236 const ecs_world_t *world);
2237
2250 ecs_world_t *world,
2251 bool enable);
2252
2264 ecs_world_t *world,
2265 bool enable);
2266
2282FLECS_API
2284 ecs_world_t *world,
2285 ecs_ftime_t fps);
2286
2300FLECS_API
2302 ecs_world_t *world,
2303 ecs_flags32_t flags);
2304
2381FLECS_API
2383 ecs_world_t *world,
2384 bool multi_threaded);
2385
2393FLECS_API
2395 ecs_world_t *world);
2396
2402FLECS_API
2404 ecs_world_t *stage);
2405
2422FLECS_API
2424 ecs_world_t *world);
2425
2439FLECS_API
2441 ecs_world_t *world);
2442
2457FLECS_API
2459 ecs_world_t *world);
2460
2471FLECS_API
2473 ecs_world_t *world);
2474
2486FLECS_API
2488 const ecs_world_t *world);
2489
2501FLECS_API
2503 const ecs_world_t *world);
2504
2518FLECS_API
2520 ecs_world_t *world,
2521 int32_t stages);
2522
2529FLECS_API
2531 const ecs_world_t *world);
2532
2548FLECS_API
2550 const ecs_world_t *world,
2551 int32_t stage_id);
2552
2560FLECS_API
2562 const ecs_world_t *world);
2563
2571FLECS_API
2573 ecs_world_t *world);
2574
2579FLECS_API
2581 ecs_world_t *stage);
2582
2590FLECS_API
2592 const ecs_world_t *world);
2593
2609FLECS_API
2611 ecs_world_t *world,
2612 void *ctx,
2613 ecs_ctx_free_t ctx_free);
2614
2623FLECS_API
2625 ecs_world_t *world,
2626 void *ctx,
2627 ecs_ctx_free_t ctx_free);
2628
2636FLECS_API
2638 const ecs_world_t *world);
2639
2647FLECS_API
2649 const ecs_world_t *world);
2650
2656FLECS_API
2658
2664FLECS_API
2666 const ecs_world_t *world);
2667
2676FLECS_API
2678 ecs_world_t *world,
2679 int32_t entity_count);
2680
2695FLECS_API
2697 ecs_world_t *world);
2698
2713FLECS_API
2715 ecs_world_t *world,
2716 uint32_t min,
2717 uint32_t max);
2718
2733FLECS_API
2735 ecs_world_t *world,
2736 const ecs_entity_range_t *range);
2737
2745FLECS_API
2747 const ecs_world_t *world);
2748
2754FLECS_API
2756 const ecs_world_t *world);
2757
2771FLECS_API
2773 ecs_world_t *world,
2774 ecs_flags32_t flags);
2775
2791
2827FLECS_API
2829 ecs_world_t *world,
2830 const ecs_delete_empty_tables_desc_t *desc);
2831
2837FLECS_API
2839 const ecs_poly_t *poly);
2840
2846FLECS_API
2848 const ecs_poly_t *poly);
2849
2863FLECS_API
2865 const ecs_poly_t *object,
2866 int32_t type);
2867
2871#define flecs_poly_is(object, type)\
2872 flecs_poly_is_(object, type##_magic)
2873
2882FLECS_API
2884 ecs_entity_t first,
2885 ecs_entity_t second);
2886
2909FLECS_API
2911 ecs_world_t *world,
2912 const char *thread_name);
2913
2936FLECS_API
2938 ecs_world_t *world,
2939 bool lock_world);
2940
2967FLECS_API
2969 ecs_world_t *world);
2970
2988FLECS_API
2990 ecs_world_t *world);
2991
3000FLECS_API
3002 ecs_world_t *world,
3003 ecs_id_t component);
3004
3012FLECS_API
3014 ecs_world_t *world,
3015 ecs_table_t *table);
3016
3035FLECS_API
3037 ecs_world_t *world,
3038 const ecs_entity_desc_t *desc);
3039
3066FLECS_API
3068 ecs_world_t *world,
3069 const ecs_bulk_desc_t *desc);
3070
3080FLECS_API
3082 ecs_world_t *world,
3083 ecs_id_t component,
3084 int32_t count);
3085
3101FLECS_API
3103 ecs_world_t *world,
3104 ecs_entity_t dst,
3105 ecs_entity_t src,
3106 bool copy_value);
3107
3116FLECS_API
3118 ecs_world_t *world,
3119 ecs_entity_t entity);
3120
3128FLECS_API
3130 ecs_world_t *world,
3131 ecs_id_t component);
3132
3150FLECS_API
3152 ecs_world_t *world,
3153 ecs_entity_t parent,
3154 const ecs_entity_t *children,
3155 int32_t child_count);
3156
3166FLECS_API
3168 const ecs_world_t *world,
3169 ecs_entity_t parent);
3170
3188FLECS_API
3190 ecs_world_t *world,
3191 ecs_entity_t entity,
3192 ecs_id_t component);
3193
3202FLECS_API
3204 ecs_world_t *world,
3205 ecs_entity_t entity,
3206 ecs_id_t component);
3207
3259FLECS_API
3261 ecs_world_t *world,
3262 ecs_entity_t entity,
3263 ecs_id_t component);
3264
3271FLECS_API
3273 ecs_world_t *world,
3274 ecs_entity_t entity);
3275
3283FLECS_API
3285 ecs_world_t *world,
3286 ecs_id_t component);
3287
3303FLECS_API
3305 ecs_world_t *world,
3306 ecs_id_t component);
3307
3316FLECS_API
3318 const ecs_world_t *world);
3319
3338FLECS_API
3340 ecs_world_t *world,
3341 ecs_entity_t entity,
3342 bool enabled);
3343
3357FLECS_API
3359 ecs_world_t *world,
3360 ecs_entity_t entity,
3361 ecs_id_t component,
3362 bool enable);
3363
3374FLECS_API
3376 const ecs_world_t *world,
3377 ecs_entity_t entity,
3378 ecs_id_t component);
3379
3403FLECS_API
3404FLECS_ALWAYS_INLINE const void* ecs_get_id(
3405 const ecs_world_t *world,
3406 ecs_entity_t entity,
3407 ecs_id_t component);
3408
3423FLECS_API
3424FLECS_ALWAYS_INLINE void* ecs_get_mut_id(
3425 const ecs_world_t *world,
3426 ecs_entity_t entity,
3427 ecs_id_t component);
3428
3446FLECS_API
3448 ecs_world_t *world,
3449 ecs_entity_t entity,
3450 ecs_id_t component,
3451 size_t size);
3452
3463FLECS_ALWAYS_INLINE FLECS_API
3465 const ecs_world_t *world,
3466 ecs_entity_t entity,
3467 ecs_id_t component);
3468
3479FLECS_ALWAYS_INLINE FLECS_API
3481 const ecs_world_t *world,
3482 ecs_ref_t *ref,
3483 ecs_id_t component);
3484
3492FLECS_ALWAYS_INLINE FLECS_API
3494 const ecs_world_t *world,
3495 ecs_ref_t *ref);
3496
3517FLECS_API
3519 ecs_world_t *world,
3520 ecs_entity_t entity,
3521 ecs_id_t component,
3522 size_t size,
3523 bool *is_new);
3524
3534FLECS_API
3536 ecs_world_t *world,
3537 ecs_entity_t entity,
3538 ecs_id_t component);
3539
3555FLECS_API
3557 ecs_world_t *world,
3558 ecs_entity_t entity,
3559 ecs_id_t component,
3560 size_t size,
3561 const void *ptr);
3562
3591FLECS_API
3593 const ecs_world_t *world,
3594 ecs_entity_t e);
3595
3625FLECS_API
3627 const ecs_world_t *world,
3628 ecs_entity_t e);
3629
3635FLECS_API
3637 ecs_entity_t e);
3638
3655FLECS_API
3657 const ecs_world_t *world,
3658 ecs_entity_t e);
3659
3682FLECS_API
3684 ecs_world_t *world,
3685 ecs_entity_t entity);
3686
3705FLECS_API
3707 ecs_world_t *world,
3708 ecs_id_t component);
3709
3717FLECS_API
3719 const ecs_world_t *world,
3720 ecs_entity_t entity);
3721
3736FLECS_API
3738 ecs_world_t *world,
3739 ecs_entity_t entity);
3740
3746FLECS_API
3748 ecs_entity_t entity);
3749
3765FLECS_API
3767 const ecs_world_t *world,
3768 ecs_entity_t entity);
3769
3776FLECS_API
3778 const ecs_world_t *world,
3779 ecs_entity_t entity);
3780
3788FLECS_API
3790 const ecs_world_t *world,
3791 const ecs_type_t* type);
3792
3804FLECS_API
3806 const ecs_world_t *world,
3807 const ecs_table_t *table);
3808
3823FLECS_API
3825 const ecs_world_t *world,
3826 ecs_entity_t entity);
3827
3838FLECS_API
3839FLECS_ALWAYS_INLINE bool ecs_has_id(
3840 const ecs_world_t *world,
3841 ecs_entity_t entity,
3842 ecs_id_t component);
3843
3854FLECS_API
3855FLECS_ALWAYS_INLINE bool ecs_owns_id(
3856 const ecs_world_t *world,
3857 ecs_entity_t entity,
3858 ecs_id_t component);
3859
3874FLECS_API
3876 const ecs_world_t *world,
3877 ecs_entity_t entity,
3878 ecs_entity_t rel,
3879 int32_t index);
3880
3894FLECS_API
3896 const ecs_world_t *world,
3897 ecs_entity_t entity);
3898
3912FLECS_API
3914 ecs_world_t *world,
3915 ecs_entity_t parent,
3916 const char *name);
3917
3938FLECS_API
3940 const ecs_world_t *world,
3941 ecs_entity_t entity,
3942 ecs_entity_t rel,
3943 ecs_id_t component);
3944
3955FLECS_API
3957 const ecs_world_t *world,
3958 ecs_entity_t entity,
3959 ecs_entity_t rel);
3960
3968FLECS_API
3970 const ecs_world_t *world,
3971 ecs_id_t entity);
3972
3992FLECS_API
3993const char* ecs_get_name(
3994 const ecs_world_t *world,
3995 ecs_entity_t entity);
3996
4006FLECS_API
4007const char* ecs_get_symbol(
4008 const ecs_world_t *world,
4009 ecs_entity_t entity);
4010
4024FLECS_API
4026 ecs_world_t *world,
4027 ecs_entity_t entity,
4028 const char *name);
4029
4043FLECS_API
4045 ecs_world_t *world,
4046 ecs_entity_t entity,
4047 const char *symbol);
4048
4060FLECS_API
4062 ecs_world_t *world,
4063 ecs_entity_t entity,
4064 const char *alias);
4065
4081FLECS_API
4083 const ecs_world_t *world,
4084 const char *path);
4085
4100FLECS_API
4102 const ecs_world_t *world,
4103 ecs_entity_t parent,
4104 const char *name);
4105
4128FLECS_API
4130 const ecs_world_t *world,
4131 ecs_entity_t parent,
4132 const char *path,
4133 const char *sep,
4134 const char *prefix,
4135 bool recursive);
4136
4154FLECS_API
4156 const ecs_world_t *world,
4157 const char *symbol,
4158 bool lookup_as_path,
4159 bool recursive);
4160
4182FLECS_API
4184 const ecs_world_t *world,
4185 ecs_entity_t parent,
4186 ecs_entity_t child,
4187 const char *sep,
4188 const char *prefix);
4189
4203FLECS_API
4205 const ecs_world_t *world,
4206 ecs_entity_t parent,
4207 ecs_entity_t child,
4208 const char *sep,
4209 const char *prefix,
4210 ecs_strbuf_t *buf,
4211 bool escape);
4212
4228FLECS_API
4230 ecs_world_t *world,
4231 ecs_entity_t parent,
4232 const char *path,
4233 const char *sep,
4234 const char *prefix);
4235
4250FLECS_API
4252 ecs_world_t *world,
4253 ecs_entity_t entity,
4254 ecs_entity_t parent,
4255 const char *path,
4256 const char *sep,
4257 const char *prefix);
4258
4272FLECS_API
4274 ecs_world_t *world,
4275 ecs_entity_t scope);
4276
4284FLECS_API
4286 const ecs_world_t *world);
4287
4297FLECS_API
4299 ecs_world_t *world,
4300 const char *prefix);
4301
4328FLECS_API
4330 ecs_world_t *world,
4331 const ecs_entity_t *lookup_path);
4332
4339FLECS_API
4341 const ecs_world_t *world);
4342
4367FLECS_API
4369 ecs_world_t *world,
4370 const ecs_component_desc_t *desc);
4371
4381FLECS_API
4383 const ecs_world_t *world,
4384 ecs_id_t component);
4385
4397FLECS_API
4399 ecs_world_t *world,
4400 ecs_entity_t component,
4401 const ecs_type_hooks_t *hooks);
4402
4409FLECS_API
4411 const ecs_world_t *world,
4412 ecs_entity_t component);
4413
4437FLECS_API
4439 const ecs_world_t *world,
4440 ecs_id_t component);
4441
4450FLECS_API
4452 const ecs_world_t *world,
4453 ecs_id_t component);
4454
4474FLECS_API
4476 const ecs_world_t *world,
4477 ecs_id_t component);
4478
4487FLECS_API
4489 ecs_id_t component,
4490 ecs_id_t pattern);
4491
4497FLECS_API
4499 ecs_id_t component);
4500
4506FLECS_API
4508 ecs_id_t component);
4509
4516 ecs_id_t component);
4517
4531FLECS_API
4533 const ecs_world_t *world,
4534 ecs_id_t component);
4535
4544FLECS_API
4545ecs_flags32_t ecs_id_get_flags(
4546 const ecs_world_t *world,
4547 ecs_id_t component);
4548
4559FLECS_API
4561 uint64_t component_flags);
4562
4578FLECS_API
4580 const ecs_world_t *world,
4581 ecs_id_t component);
4582
4590FLECS_API
4592 const ecs_world_t *world,
4593 ecs_id_t component,
4594 ecs_strbuf_t *buf);
4595
4604FLECS_API
4606 const ecs_world_t *world,
4607 const char *expr);
4608
4624FLECS_API
4626 const ecs_term_ref_t *ref);
4627
4639FLECS_API
4641 const ecs_term_t *term);
4642
4657FLECS_API
4659 const ecs_term_t *term);
4660
4673FLECS_API
4675 const ecs_term_t *term);
4676
4685FLECS_API
4687 const ecs_world_t *world,
4688 const ecs_term_t *term);
4689
4697FLECS_API
4699 const ecs_query_t *query);
4700
4741FLECS_API
4743 const ecs_world_t *world,
4744 ecs_id_t component);
4745
4751FLECS_API
4753 ecs_iter_t *it);
4754
4777FLECS_API
4778FLECS_ALWAYS_INLINE ecs_iter_t ecs_children(
4779 const ecs_world_t *world,
4780 ecs_entity_t parent);
4781
4789FLECS_API
4790FLECS_ALWAYS_INLINE ecs_iter_t ecs_children_w_rel(
4791 const ecs_world_t *world,
4792 ecs_entity_t relationship,
4793 ecs_entity_t parent);
4794
4800FLECS_API
4802 ecs_iter_t *it);
4803
4822FLECS_API
4824 ecs_world_t *world,
4825 const ecs_query_desc_t *desc);
4826
4837FLECS_API
4839 ecs_world_t *world,
4840 ecs_entity_t entity,
4841 const ecs_query_desc_t *desc);
4842
4847FLECS_API
4849 ecs_query_t *query);
4850
4859FLECS_API
4861 const ecs_query_t *query,
4862 const char *name);
4863
4871FLECS_API
4873 const ecs_query_t *query,
4874 int32_t var_id);
4875
4886FLECS_API
4888 const ecs_query_t *query,
4889 int32_t var_id);
4890
4959FLECS_API
4961 const ecs_world_t *world,
4962 const ecs_query_t *query);
4963
4971FLECS_API
4973 ecs_iter_t *it);
4974
4993FLECS_API
4995 const ecs_query_t *query,
4996 ecs_entity_t entity,
4997 ecs_iter_t *it);
4998
5017FLECS_API
5019 const ecs_query_t *query,
5020 ecs_table_t *table,
5021 ecs_iter_t *it);
5022
5049FLECS_API
5051 const ecs_query_t *query,
5052 ecs_table_range_t *range,
5053 ecs_iter_t *it);
5054
5062FLECS_API
5064 const ecs_query_t *query);
5065
5075FLECS_API
5077 const ecs_query_t *query);
5078
5093FLECS_API
5095 const ecs_query_t *query,
5096 const ecs_iter_t *it);
5097
5103FLECS_API
5105 const ecs_query_t *query);
5106
5124FLECS_API
5126 ecs_query_t *query,
5127 ecs_iter_t *it,
5128 const char *expr);
5129
5152FLECS_API
5154 ecs_query_t *query);
5155
5164FLECS_API
5166 const ecs_world_t *world,
5167 ecs_entity_t query);
5168
5179FLECS_API
5181 ecs_iter_t *it);
5182
5205FLECS_API
5207 ecs_iter_t *it,
5208 uint64_t group_id);
5209
5235FLECS_API
5236const ecs_map_t* ecs_query_get_groups(
5237 const ecs_query_t *query);
5238
5247FLECS_API
5249 const ecs_query_t *query,
5250 uint64_t group_id);
5251
5260FLECS_API
5262 const ecs_query_t *query,
5263 uint64_t group_id);
5264
5273
5280FLECS_API
5282 const ecs_query_t *query);
5283
5289FLECS_API
5291 const ecs_query_t *query);
5292
5301FLECS_API
5303 const ecs_query_t *query);
5304
5333FLECS_API
5335 ecs_world_t *world,
5336 ecs_event_desc_t *desc);
5337
5348FLECS_API
5350 ecs_world_t *world,
5351 ecs_event_desc_t *desc);
5352
5367FLECS_API
5369 ecs_world_t *world,
5370 const ecs_observer_desc_t *desc);
5371
5387FLECS_API
5389 ecs_world_t *world,
5390 ecs_entity_t observer,
5391 const ecs_observer_desc_t *desc);
5392
5401FLECS_API
5403 const ecs_world_t *world,
5404 ecs_entity_t observer);
5405
5428FLECS_API
5430 ecs_iter_t *it);
5431
5441FLECS_API
5443 ecs_iter_t *it);
5444
5456FLECS_API
5458 ecs_iter_t *it);
5459
5472FLECS_API
5474 ecs_iter_t *it);
5475
5483FLECS_API
5485 ecs_iter_t *it);
5486
5525FLECS_API
5527 ecs_iter_t *it,
5528 int32_t var_id,
5529 ecs_entity_t entity);
5530
5541FLECS_API
5543 ecs_iter_t *it,
5544 int32_t var_id,
5545 const ecs_table_t *table);
5546
5557FLECS_API
5559 ecs_iter_t *it,
5560 int32_t var_id,
5561 const ecs_table_range_t *range);
5562
5575FLECS_API
5577 ecs_iter_t *it,
5578 int32_t var_id);
5579
5586FLECS_API
5588 const ecs_iter_t *it,
5589 int32_t var_id);
5590
5596FLECS_API
5598 const ecs_iter_t *it);
5599
5605FLECS_API
5607 const ecs_iter_t *it);
5608
5622FLECS_API
5624 ecs_iter_t *it,
5625 int32_t var_id);
5626
5640FLECS_API
5642 ecs_iter_t *it,
5643 int32_t var_id);
5644
5656FLECS_API
5658 ecs_iter_t *it,
5659 int32_t var_id);
5660
5672FLECS_API
5674 const ecs_iter_t *it);
5675
5687FLECS_API
5689 ecs_iter_t *it);
5690
5702FLECS_API
5704 const ecs_iter_t *it);
5705
5721FLECS_API
5723 const ecs_iter_t *it,
5724 int32_t offset,
5725 int32_t limit);
5726
5733FLECS_API
5735 ecs_iter_t *it);
5736
5757FLECS_API
5759 const ecs_iter_t *it,
5760 int32_t index,
5761 int32_t count);
5762
5769FLECS_API
5771 ecs_iter_t *it);
5772
5814FLECS_API
5816 const ecs_iter_t *it,
5817 size_t size,
5818 int8_t index);
5819
5842FLECS_API
5844 const ecs_iter_t *it,
5845 size_t size,
5846 int8_t index,
5847 int32_t row);
5848
5857FLECS_API
5859 const ecs_iter_t *it,
5860 int8_t index);
5861
5872FLECS_API
5874 const ecs_iter_t *it,
5875 int8_t index);
5876
5883FLECS_API
5885 const ecs_iter_t *it,
5886 int8_t index);
5887
5894FLECS_API
5896 const ecs_iter_t *it,
5897 int8_t index);
5898
5907FLECS_API
5909 const ecs_iter_t *it,
5910 int8_t index);
5911
5919FLECS_API
5921 const ecs_iter_t *it,
5922 int8_t index);
5923
5931FLECS_API
5933 const ecs_iter_t *it,
5934 int8_t index);
5935
5949FLECS_API
5951 const ecs_iter_t *it,
5952 int8_t index);
5953
5969FLECS_API
5971 const ecs_table_t *table);
5972
5983FLECS_API
5985 const ecs_world_t *world,
5986 const ecs_table_t *table,
5987 ecs_id_t component);
5988
5998FLECS_API
6000 const ecs_world_t *world,
6001 const ecs_table_t *table,
6002 ecs_id_t component);
6003
6011FLECS_API
6013 const ecs_table_t *table);
6014
6028FLECS_API
6030 const ecs_table_t *table,
6031 int32_t index);
6032
6041FLECS_API
6043 const ecs_table_t *table,
6044 int32_t index);
6045
6054FLECS_API
6056 const ecs_table_t *table,
6057 int32_t index,
6058 int32_t offset);
6059
6069FLECS_API
6071 const ecs_world_t *world,
6072 const ecs_table_t *table,
6073 ecs_id_t component,
6074 int32_t offset);
6075
6083FLECS_API
6085 const ecs_table_t *table,
6086 int32_t index);
6087
6094FLECS_API
6096 const ecs_table_t *table);
6097
6105FLECS_API
6107 const ecs_table_t *table);
6108
6115FLECS_API
6117 const ecs_table_t *table);
6118
6129FLECS_API
6131 const ecs_world_t *world,
6132 const ecs_table_t *table,
6133 ecs_id_t component);
6134
6145FLECS_API
6147 const ecs_world_t *world,
6148 const ecs_table_t *table,
6149 ecs_entity_t relationship,
6150 int32_t index);
6151
6162FLECS_API
6164 const ecs_world_t *world,
6165 const ecs_table_t *table,
6166 ecs_entity_t rel);
6167
6177FLECS_API
6179 ecs_world_t *world,
6180 ecs_table_t *table,
6181 ecs_id_t component);
6182
6193FLECS_API
6195 ecs_world_t *world,
6196 const ecs_id_t *ids,
6197 int32_t id_count);
6198
6208FLECS_API
6210 ecs_world_t *world,
6211 ecs_table_t *table,
6212 ecs_id_t component);
6213
6229FLECS_API
6231 ecs_world_t *world,
6232 ecs_table_t *table);
6233
6240FLECS_API
6242 ecs_world_t *world,
6243 ecs_table_t *table);
6244
6254FLECS_API
6256 ecs_table_t *table,
6257 ecs_flags32_t flags);
6258
6266FLECS_API
6268 const ecs_table_t *table);
6269
6279FLECS_API
6281 ecs_world_t* world,
6282 ecs_table_t* table,
6283 int32_t row_1,
6284 int32_t row_2);
6285
6310FLECS_API
6312 ecs_world_t *world,
6313 ecs_entity_t entity,
6314 ecs_record_t *record,
6315 ecs_table_t *table,
6316 const ecs_type_t *added,
6317 const ecs_type_t *removed);
6318
6319
6339FLECS_API
6341 const ecs_world_t *world,
6342 const ecs_table_t *table,
6343 ecs_id_t component,
6344 ecs_id_t *component_out);
6345
6381FLECS_API
6383 const ecs_world_t *world,
6384 const ecs_table_t *table,
6385 int32_t offset,
6386 ecs_id_t component,
6387 ecs_id_t *component_out);
6388
6429FLECS_API
6431 const ecs_world_t *world,
6432 const ecs_table_t *table,
6433 int32_t offset,
6434 ecs_id_t component,
6435 ecs_entity_t rel,
6436 ecs_flags64_t flags, /* EcsSelf and/or EcsUp */
6437 ecs_entity_t *tgt_out,
6438 ecs_id_t *component_out,
6439 struct ecs_table_record_t **tr_out);
6440
6456FLECS_API
6458 const ecs_world_t *world,
6459 ecs_entity_t entity,
6460 ecs_id_t id,
6461 ecs_entity_t rel,
6462 bool self,
6464 ecs_entity_t *tgt_out,
6465 ecs_id_t *id_out,
6466 struct ecs_table_record_t **tr_out);
6467
6475FLECS_API
6477 ecs_world_t* world,
6478 ecs_table_t* table);
6479
6496FLECS_API
6498 const ecs_world_t *world,
6499 ecs_entity_t type,
6500 void *ptr);
6501
6509FLECS_API
6511 const ecs_world_t *world,
6512 const ecs_type_info_t *ti,
6513 void *ptr);
6514
6521FLECS_API
6523 ecs_world_t *world,
6524 ecs_entity_t type);
6525
6533 ecs_world_t *world,
6534 const ecs_type_info_t *ti);
6535
6544 const ecs_world_t *world,
6545 const ecs_type_info_t *ti,
6546 void *ptr);
6547
6555FLECS_API
6557 const ecs_world_t *world,
6558 ecs_entity_t type,
6559 void* ptr);
6560
6568FLECS_API
6570 ecs_world_t *world,
6571 ecs_entity_t type,
6572 void* ptr);
6573
6582FLECS_API
6584 const ecs_world_t *world,
6585 const ecs_type_info_t *ti,
6586 void* dst,
6587 const void *src);
6588
6597FLECS_API
6599 const ecs_world_t *world,
6600 ecs_entity_t type,
6601 void* dst,
6602 const void *src);
6603
6613 const ecs_world_t *world,
6614 const ecs_type_info_t *ti,
6615 void* dst,
6616 void *src);
6617
6627 const ecs_world_t *world,
6628 ecs_entity_t type,
6629 void* dst,
6630 void *src);
6631
6641 const ecs_world_t *world,
6642 const ecs_type_info_t *ti,
6643 void* dst,
6644 void *src);
6645
6655 const ecs_world_t *world,
6656 ecs_entity_t type,
6657 void* dst,
6658 void *src);
6659
6673#include "flecs/addons/flecs_c.h"
6674
6675#ifdef __cplusplus
6676}
6677#endif
6678
6679#include "flecs/private/addons.h"
6680
6681#endif
The deprecated addon contains deprecated operations.
Extends the core API with convenience macros for C applications.
void ecs_remove_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Remove a component from an entity.
void ecs_auto_override_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Add an auto override for a component.
void ecs_remove_all(ecs_world_t *world, ecs_id_t component)
Remove all instances of the specified component.
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 the component set with ecs_set_with().
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Add a (component) ID to an entity.
ecs_entity_t ecs_set_with(ecs_world_t *world, ecs_id_t component)
Create new entities with a specified component.
struct ecs_value_t ecs_value_t
Utility to hold a value of a dynamic type.
struct EcsIdentifier EcsIdentifier
A (string) identifier.
struct EcsTreeSpawner EcsTreeSpawner
Tree instantiation cache component.
struct EcsPoly EcsPoly
Component for storing a poly object.
struct EcsDefaultChildComponent EcsDefaultChildComponent
When added to an entity, this informs serialization formats which component to use when a value is as...
struct EcsParent EcsParent
Non-fragmenting ChildOf relationship.
struct EcsComponent EcsComponent
Component information.
const ecs_entity_t EcsScopeClose
Marker used to indicate the end of a scope (}) in queries.
const ecs_entity_t EcsOnRemove
Event that triggers when an ID is removed from an entity.
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
Mark a relationship as acyclic.
const ecs_entity_t EcsSymmetric
Mark relationship as commutative.
const ecs_entity_t EcsAlias
Tag to indicate alias identifier.
const ecs_entity_t EcsOnSet
Event that triggers when a component is set for an entity.
const ecs_entity_t EcsReflexive
Mark a relationship as reflexive.
const ecs_entity_t EcsTrait
Can be added to components to indicate it is a trait.
const ecs_entity_t EcsEmpty
Tag used to indicate a query is empty.
const ecs_entity_t EcsOneOf
Ensure that a relationship target is a child of the specified entity.
const ecs_entity_t EcsOnTableDelete
Event that triggers when a table is deleted.
const ecs_entity_t EcsOnTableCreate
Event that triggers when a table is created.
const ecs_entity_t EcsObserver
Tag added to observers.
const ecs_entity_t EcsQuery
Tag added to queries.
const ecs_entity_t EcsRelationship
Ensure that an entity is always used in a pair as a relationship.
const ecs_entity_t EcsSingleton
Mark component as singleton.
const ecs_entity_t EcsOnStart
OnStart pipeline phase.
const ecs_entity_t EcsNotQueryable
Trait added to entities that should never be returned by queries.
const ecs_entity_t EcsOnStore
OnStore pipeline phase.
const ecs_entity_t EcsOrderedChildren
Tag that, when added to a parent, ensures stable order of ecs_children() results.
const ecs_entity_t EcsDontFragment
Mark component as non-fragmenting.
const ecs_entity_t EcsTraversable
Mark a relationship as traversable.
const ecs_entity_t EcsPredLookup
Marker used to indicate $var ~= "pattern" matching in queries.
const ecs_entity_t EcsPreStore
PreStore pipeline phase.
const ecs_entity_t EcsOnLoad
OnLoad pipeline phase.
const ecs_entity_t EcsIsA
Used to express inheritance relationships.
const ecs_entity_t EcsExclusive
Can be added to a 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
Mark a relationship as transitive.
const ecs_entity_t EcsDelete
Delete cleanup policy.
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 that triggers an observer when an entity starts or stops matching a query.
const ecs_entity_t EcsCanToggle
Mark a component as toggleable with ecs_enable_id().
const ecs_entity_t EcsPredEq
Marker used to indicate $var == ... matching in queries.
const ecs_entity_t EcsPhase
Phase pipeline phase.
const ecs_entity_t EcsWorld
Entity associated with world (used for "attaching" components to world).
const ecs_entity_t EcsScopeOpen
Marker used to indicate the start of a scope ({) in queries.
const ecs_entity_t EcsPostUpdate
PostUpdate pipeline phase.
const ecs_entity_t EcsOnValidate
OnValidate pipeline phase.
const ecs_entity_t EcsRemove
Remove cleanup policy.
const ecs_entity_t EcsOverride
Override component on instantiate.
const ecs_entity_t EcsPredMatch
Marker used to indicate $var == "name" matching in queries.
const ecs_entity_t EcsInherit
Inherit component on instantiate.
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 EcsSparse
Mark component as sparse.
const ecs_entity_t EcsPreUpdate
PreUpdate pipeline phase.
const ecs_entity_t EcsOnAdd
Event that triggers when an ID is added to an entity.
const ecs_entity_t EcsPrefab
Tag added to prefab entities.
const ecs_entity_t EcsOnInstantiate
Relationship that specifies component inheritance behavior.
const ecs_entity_t EcsPostFrame
PostFrame pipeline phase.
const ecs_entity_t EcsInheritable
Mark component as inheritable.
const ecs_entity_t EcsAny
Any entity ("_").
const ecs_entity_t EcsTarget
Ensure that an entity is always used in a pair as a target.
const ecs_entity_t EcsParentDepth
Relationship storing the entity's depth in a non-fragmenting hierarchy.
const ecs_entity_t EcsWith
Ensure that a component is always added together with another component.
const ecs_entity_t EcsPostLoad
PostLoad pipeline phase.
const ecs_entity_t EcsOnDelete
Relationship used for specifying cleanup behavior.
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 EcsPreFrame
PreFrame pipeline phase.
const ecs_entity_t EcsFlecs
Root scope for built-in Flecs entities.
const ecs_entity_t EcsSystem
Tag added to systems.
const ecs_entity_t EcsOnUpdate
OnUpdate pipeline phase.
const ecs_entity_t EcsDisabled
When this tag is added to an entity, it is skipped by queries, unless EcsDisabled is explicitly queri...
const ecs_entity_t EcsDontInherit
Never inherit component on instantiate.
const ecs_entity_t EcsPairIsTag
Can be added to a relationship to indicate that it should never hold data, even when it or the relati...
const ecs_entity_t EcsPanic
Panic cleanup policy.
const ecs_entity_t EcsFinal
Ensure that an entity or component cannot be used as a target in an IsA relationship.
const ecs_entity_t EcsVariable
Variable entity ("$").
const ecs_entity_t EcsConstant
Tag added to enum or bitmask constants.
FLECS_API const ecs_entity_t ecs_id(EcsDocDescription)
Component ID for EcsDocDescription.
ecs_world_t * ecs_stage_new(ecs_world_t *world)
Create an unmanaged stage.
bool ecs_defer_end(ecs_world_t *world)
End a block of operations to defer.
bool ecs_readonly_begin(ecs_world_t *world, bool multi_threaded)
Begin readonly mode.
void ecs_defer_resume(ecs_world_t *world)
Resume deferring.
bool ecs_defer_begin(ecs_world_t *world)
Defer operations until the end of the 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 the current stage.
void ecs_stage_free(ecs_world_t *stage)
Free an unmanaged stage.
void ecs_merge(ecs_world_t *stage)
Merge a stage.
int32_t ecs_stage_get_id(const ecs_world_t *world)
Get the stage ID.
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 the number of configured stages.
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 the world to have N stages.
void ecs_readonly_end(ecs_world_t *world)
End readonly mode.
bool ecs_is_defer_suspended(const ecs_world_t *world)
Test if deferring is suspended for the current stage.
const ecs_type_hooks_t * ecs_get_hooks_id(const ecs_world_t *world, ecs_entity_t component)
Get hooks for a component.
ecs_entity_t ecs_component_init(ecs_world_t *world, const ecs_component_desc_t *desc)
Find or create a component.
const ecs_type_info_t * ecs_get_type_info(const ecs_world_t *world, ecs_id_t component)
Get the type info for a component.
struct ecs_component_desc_t ecs_component_desc_t
Used with ecs_component_init().
void ecs_set_hooks_id(ecs_world_t *world, ecs_entity_t component, const ecs_type_hooks_t *hooks)
Register hooks for a component.
struct ecs_component_record_t ecs_component_record_t
Information about a (component) ID, such as type info and tables with the ID.
Definition flecs.h:497
struct ecs_header_t ecs_header_t
Header for ecs_poly_t objects.
struct ecs_stage_t ecs_stage_t
A stage enables modification while iterating and from multiple threads.
Definition flecs.h:432
struct ecs_ref_t ecs_ref_t
A ref is a fast way to fetch a component for a specific entity.
Definition flecs.h:481
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:385
struct ecs_table_record_t ecs_table_record_t
Opaque type for table record.
Definition flecs.h:531
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:429
struct ecs_mixins_t ecs_mixins_t
Type that stores poly mixins.
Definition flecs.h:521
uint64_t ecs_id_t
IDs are the things that can be added to an entity.
Definition flecs.h:378
struct ecs_observable_t ecs_observable_t
An observable produces events that can be listened for by an observer.
Definition flecs.h:465
struct ecs_record_t ecs_record_t
Information about an entity, like its table and row.
Definition flecs.h:494
struct ecs_table_t ecs_table_t
A table stores entities and components for a specific type.
Definition flecs.h:435
void ecs_poly_t
A poly object.
Definition flecs.h:518
ecs_entity_t ecs_new_low_id(ecs_world_t *world)
Create new low ID.
void ecs_set_child_order(ecs_world_t *world, ecs_entity_t parent, const ecs_entity_t *children, int32_t child_count)
Set child order for parent with OrderedChildren.
const ecs_entity_t * ecs_bulk_init(ecs_world_t *world, const ecs_bulk_desc_t *desc)
Bulk create or 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.
ecs_entity_t ecs_new(ecs_world_t *world)
Create new entity ID.
ecs_entity_t ecs_entity_init(ecs_world_t *world, const ecs_entity_desc_t *desc)
Find or create an entity.
void ecs_delete(ecs_world_t *world, ecs_entity_t entity)
Delete an entity.
void ecs_delete_with(ecs_world_t *world, ecs_id_t component)
Delete all entities with the specified component.
ecs_entity_t ecs_new_w_id(ecs_world_t *world, ecs_id_t component)
Create new entity with (component) ID.
ecs_entity_t ecs_new_w_table(ecs_world_t *world, ecs_table_t *table)
Create new entity in table.
const ecs_entity_t * ecs_bulk_new_w_id(ecs_world_t *world, ecs_id_t component, int32_t count)
Create N new entities.
ecs_entities_t ecs_get_ordered_children(const ecs_world_t *world, ecs_entity_t parent)
Get ordered children.
bool ecs_children_next(ecs_iter_t *it)
Progress an iterator created with ecs_children().
ecs_iter_t ecs_each_id(const ecs_world_t *world, ecs_id_t component)
Iterate all entities with a specified (component ID).
bool ecs_each_next(ecs_iter_t *it)
Progress an iterator created with ecs_each_id().
ecs_iter_t ecs_children(const ecs_world_t *world, ecs_entity_t parent)
Iterate children of a parent.
ecs_iter_t ecs_children_w_rel(const ecs_world_t *world, ecs_entity_t relationship, ecs_entity_t parent)
Same as ecs_children(), but with a custom relationship argument.
void ecs_enable_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, bool enable)
Enable or disable a component.
bool ecs_is_enabled_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if a component is enabled.
void ecs_enable(ecs_world_t *world, ecs_entity_t entity, bool enabled)
Enable or disable an entity.
struct ecs_bulk_desc_t ecs_bulk_desc_t
Used with ecs_bulk_init().
struct ecs_entity_desc_t ecs_entity_desc_t
Used with ecs_entity_init().
char * ecs_entity_str(const ecs_world_t *world, ecs_entity_t entity)
Convert an entity to a 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.
ecs_entity_t ecs_get_parent(const ecs_world_t *world, ecs_entity_t entity)
Get the parent (target of the ChildOf relationship) for an entity.
ecs_entity_t ecs_get_target_for_id(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, ecs_id_t component)
Get the target of a relationship for a given component.
const ecs_type_t * ecs_get_type(const ecs_world_t *world, ecs_entity_t entity)
Get the type of an entity.
bool ecs_owns_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if an entity owns a component.
char * ecs_type_str(const ecs_world_t *world, const ecs_type_t *type)
Convert a type to a string.
char * ecs_table_str(const ecs_world_t *world, const ecs_table_t *table)
Convert a table to a 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 the depth for an entity in the tree for the specified relationship.
ecs_table_t * ecs_get_table(const ecs_world_t *world, ecs_entity_t entity)
Get the table of an entity.
ecs_entity_t ecs_new_w_parent(ecs_world_t *world, ecs_entity_t parent, const char *name)
Create child with Parent component.
bool ecs_has_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if an entity has a component.
void(* ecs_module_action_t)(ecs_world_t *world)
Initialization action for modules.
Definition flecs.h:641
uint64_t(* ecs_group_by_action_t)(ecs_world_t *world, ecs_table_t *table, ecs_id_t group_id, void *ctx)
Callback used for grouping tables in a query.
Definition flecs.h:621
int(* ecs_cmp_t)(const void *a_ptr, const void *b_ptr, const ecs_type_info_t *type_info)
Compare hook to compare component instances.
Definition flecs.h:683
uint64_t(* ecs_hash_value_action_t)(const void *ptr)
Callback used for hashing values.
Definition flecs.h:659
void(* ecs_group_delete_action_t)(ecs_world_t *world, uint64_t group_id, void *group_ctx, void *group_by_ctx)
Callback invoked when a query deletes an existing group.
Definition flecs.h:634
void(* ecs_iter_fini_action_t)(ecs_iter_t *it)
Function prototype for freeing an iterator.
Definition flecs.h:599
void *(* ecs_group_create_action_t)(ecs_world_t *world, uint64_t group_id, void *group_by_ctx)
Callback invoked when a query creates a new group.
Definition flecs.h:628
void(* ecs_sort_table_action_t)(ecs_world_t *world, ecs_table_t *table, ecs_entity_t *entities, void *ptr, int32_t size, int32_t lo, int32_t hi, ecs_order_by_action_t order_by)
Callback used for sorting the entire table of components.
Definition flecs.h:610
bool(* ecs_iter_next_action_t)(ecs_iter_t *it)
Function prototype for iterating an iterator.
Definition flecs.h:591
void(* ecs_iter_action_t)(ecs_iter_t *it)
Function prototype for iterables.
Definition flecs.h:581
void(* ecs_copy_t)(void *dst_ptr, const void *src_ptr, int32_t count, const ecs_type_info_t *type_info)
Copy is invoked when a component is copied into another component.
Definition flecs.h:669
bool(* ecs_equals_t)(const void *a_ptr, const void *b_ptr, const ecs_type_info_t *type_info)
Equals operator hook.
Definition flecs.h:689
int(* ecs_compare_action_t)(const void *ptr1, const void *ptr2)
Callback used for sorting values.
Definition flecs.h:654
void(* ecs_fini_action_t)(ecs_world_t *world, void *ctx)
Action callback on world exit.
Definition flecs.h:645
void(* ecs_move_t)(void *dst_ptr, void *src_ptr, int32_t count, const ecs_type_info_t *type_info)
Move is invoked when a component is moved to another component.
Definition flecs.h:676
void(* flecs_poly_dtor_t)(ecs_poly_t *poly)
Destructor function for poly objects.
Definition flecs.h:695
void(* ecs_run_action_t)(ecs_iter_t *it)
Function prototype for runnables (systems, observers).
Definition flecs.h:572
void(* ecs_ctx_free_t)(void *ctx)
Function to clean up context data.
Definition flecs.h:650
int(* ecs_order_by_action_t)(ecs_entity_t e1, const void *ptr1, ecs_entity_t e2, const void *ptr2)
Callback used for comparing components.
Definition flecs.h:603
void(* ecs_xtor_t)(void *ptr, int32_t count, const ecs_type_info_t *type_info)
Constructor/destructor callback.
Definition flecs.h:663
void * ecs_ref_get_id(const ecs_world_t *world, ecs_ref_t *ref, ecs_id_t component)
Get a component from a ref.
void * ecs_emplace_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size, bool *is_new)
Emplace a component.
void ecs_ref_update(const ecs_world_t *world, ecs_ref_t *ref)
Update a ref.
const void * ecs_get_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Get an immutable pointer to a component.
void ecs_modified_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Signal that a component has been modified.
ecs_ref_t ecs_ref_init_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Create a component ref.
void * ecs_get_mut_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Get a mutable pointer to a component.
void * ecs_ensure_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size)
Ensure an entity has a component and return a pointer.
void ecs_set_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size, const void *ptr)
Set the value of a component.
const ecs_id_t ECS_PAIR
Indicate that the ID is a pair.
const ecs_id_t ECS_AUTO_OVERRIDE
Automatically override component when it is inherited.
const ecs_id_t ECS_TOGGLE
Add a bitset to storage, which allows a component to be enabled or disabled.
const ecs_id_t ECS_VALUE_PAIR
Indicate that the target of a pair is an integer value.
char * ecs_id_str(const ecs_world_t *world, ecs_id_t component)
Convert a component ID to a string.
bool ecs_id_is_tag(const ecs_world_t *world, ecs_id_t component)
Return whether a specified component is a tag.
ecs_flags32_t ecs_id_get_flags(const ecs_world_t *world, ecs_id_t component)
Get flags associated with an ID.
bool ecs_id_is_valid(const ecs_world_t *world, ecs_id_t component)
Utility to check if an ID is valid.
const char * ecs_id_flag_str(uint64_t component_flags)
Convert a component flag to a string.
bool ecs_id_in_use(const ecs_world_t *world, ecs_id_t component)
Return whether a specified component is in use.
bool ecs_id_match(ecs_id_t component, ecs_id_t pattern)
Utility to match a component with a pattern.
void ecs_id_str_buf(const ecs_world_t *world, ecs_id_t component, ecs_strbuf_t *buf)
Write a component string to a buffer.
bool ecs_id_is_pair(ecs_id_t component)
Utility to check if a component is a pair.
ecs_entity_t ecs_get_typeid(const ecs_world_t *world, ecs_id_t component)
Get the type for a component.
ecs_id_t ecs_id_from_str(const ecs_world_t *world, const char *expr)
Convert a string to a component.
bool ecs_id_is_wildcard(ecs_id_t component)
Utility to check if a component is a wildcard.
bool ecs_id_is_any(ecs_id_t component)
Utility to check if a component is an any wildcard.
ecs_entity_t ecs_field_src(const ecs_iter_t *it, int8_t index)
Return the field source.
bool ecs_iter_changed(ecs_iter_t *it)
Return whether the current iterator result has changed.
bool ecs_field_is_writeonly(const ecs_iter_t *it, int8_t index)
Test whether the field is write-only.
ecs_var_t * ecs_iter_get_vars(const ecs_iter_t *it)
Get the variable array.
bool ecs_field_is_readonly(const ecs_iter_t *it, int8_t index)
Test whether the field is read-only.
const char * ecs_iter_get_var_name(const ecs_iter_t *it, int32_t var_id)
Get the variable name.
ecs_iter_t ecs_worker_iter(const ecs_iter_t *it, int32_t index, int32_t count)
Create a worker iterator.
bool ecs_iter_is_true(ecs_iter_t *it)
Test if an iterator is true.
void ecs_iter_fini(ecs_iter_t *it)
Clean up iterator resources.
char * ecs_iter_str(const ecs_iter_t *it)
Convert an iterator to a string.
bool ecs_iter_var_is_constrained(ecs_iter_t *it, int32_t var_id)
Return whether a variable is constrained.
ecs_iter_t ecs_page_iter(const ecs_iter_t *it, int32_t offset, int32_t limit)
Create a paged iterator.
int32_t ecs_iter_get_var_count(const ecs_iter_t *it)
Get the number of variables.
void * ecs_field_at_w_size(const ecs_iter_t *it, size_t size, int8_t index, int32_t row)
Get data for a field at a specified row.
ecs_id_t ecs_field_id(const ecs_iter_t *it, int8_t index)
Return the ID matched for a field.
bool ecs_field_is_set(const ecs_iter_t *it, int8_t index)
Test whether a field is set.
void ecs_iter_set_var(ecs_iter_t *it, int32_t var_id, ecs_entity_t entity)
Set the value for an iterator variable.
bool ecs_field_is_self(const ecs_iter_t *it, int8_t index)
Test whether the field is matched on self.
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 the value of an iterator variable as an entity.
bool ecs_worker_next(ecs_iter_t *it)
Progress a worker iterator.
ecs_entity_t ecs_iter_first(ecs_iter_t *it)
Get the first matching entity from an iterator.
int32_t ecs_field_column(const ecs_iter_t *it, int8_t index)
Return the index of a matched table column.
uint64_t ecs_iter_get_group(const ecs_iter_t *it)
Return the group ID for the currently iterated result.
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 the value of an iterator variable as a table.
void * ecs_field_w_size(const ecs_iter_t *it, size_t size, int8_t index)
Get data for a field.
int32_t ecs_iter_count(ecs_iter_t *it)
Count the number of matched entities in a 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.
size_t ecs_field_size(const ecs_iter_t *it, int8_t index)
Return the field type size.
ecs_table_range_t ecs_iter_get_var_as_range(ecs_iter_t *it, int32_t var_id)
Get the value of an iterator variable as a table range.
ecs_id_t ecs_strip_generation(ecs_entity_t e)
Remove the generation from an entity ID.
void ecs_make_alive_id(ecs_world_t *world, ecs_id_t component)
Same as ecs_make_alive(), but for components.
bool ecs_is_valid(const ecs_world_t *world, ecs_entity_t e)
Test whether an entity is valid.
void ecs_make_alive(ecs_world_t *world, ecs_entity_t entity)
Ensure an ID is alive.
ecs_entity_t ecs_get_alive(const ecs_world_t *world, ecs_entity_t e)
Get an alive identifier.
uint32_t ecs_get_version(ecs_entity_t entity)
Get the generation of an entity.
bool ecs_exists(const ecs_world_t *world, ecs_entity_t entity)
Test whether an entity exists.
bool ecs_is_alive(const ecs_world_t *world, ecs_entity_t e)
Test whether an entity is alive.
void ecs_set_version(ecs_world_t *world, ecs_entity_t entity)
Override the generation of an entity.
struct ecs_world_info_t ecs_world_info_t
Type that contains information about the world.
struct ecs_query_group_info_t ecs_query_group_info_t
Type that contains information about a query group.
struct ecs_entity_range_t ecs_entity_range_t
Type that stores an entity id range.
struct ecs_build_info_t ecs_build_info_t
Type with information about the current Flecs build.
ecs_entity_t ecs_observer_update(ecs_world_t *world, ecs_entity_t observer, const ecs_observer_desc_t *desc)
Update an existing observer.
void ecs_emit(ecs_world_t *world, ecs_event_desc_t *desc)
Send an event.
void ecs_enqueue(ecs_world_t *world, ecs_event_desc_t *desc)
Enqueue an event.
ecs_entity_t ecs_observer_init(ecs_world_t *world, const ecs_observer_desc_t *desc)
Create an observer.
const ecs_observer_t * ecs_observer_get(const ecs_world_t *world, ecs_entity_t observer)
Get the observer object.
struct ecs_event_desc_t ecs_event_desc_t
Used with ecs_emit().
struct ecs_observer_desc_t ecs_observer_desc_t
Used with ecs_observer_init().
#define FLECS_EVENT_DESC_MAX
Maximum number of events in ecs_observer_desc_t.
Definition flecs.h:320
#define ecs_ftime_t
Customizable precision for scalar time values.
Definition flecs.h:59
#define FLECS_ID_DESC_MAX
Maximum number of IDs to add in ecs_entity_desc_t / ecs_bulk_desc_t.
Definition flecs.h:314
#define FLECS_TERM_COUNT_MAX
Maximum number of terms in queries.
Definition flecs.h:330
#define FLECS_TREE_SPAWNER_DEPTH_CACHE_SIZE
Size of the depth cache in the tree spawner component.
Definition flecs.h:363
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 an entity from a path.
ecs_entity_t ecs_lookup_symbol(const ecs_world_t *world, const char *symbol, bool lookup_as_path, bool recursive)
Look up an entity by its symbol name.
void ecs_set_alias(ecs_world_t *world, ecs_entity_t entity, const char *alias)
Set an alias for an entity.
ecs_entity_t ecs_lookup(const ecs_world_t *world, const char *path)
Look up an entity by its path.
ecs_entity_t ecs_get_scope(const ecs_world_t *world)
Get the current scope.
void ecs_get_path_w_sep_buf(const ecs_world_t *world, ecs_entity_t parent, ecs_entity_t child, const char *sep, const char *prefix, ecs_strbuf_t *buf, bool escape)
Write a path identifier to a buffer.
ecs_entity_t * ecs_set_lookup_path(ecs_world_t *world, const ecs_entity_t *lookup_path)
Set the 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.
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)
Look up 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)
Look up 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 a specified path to an entity.
ecs_entity_t * ecs_get_lookup_path(const ecs_world_t *world)
Get the 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_iter_skip(ecs_iter_t *it)
Skip a table while iterating.
bool ecs_query_has_table(const ecs_query_t *query, ecs_table_t *table, ecs_iter_t *it)
Match a table with a query.
void ecs_iter_set_group(ecs_iter_t *it, uint64_t group_id)
Set the group to iterate for a query iterator.
const ecs_query_t * ecs_query_get(const ecs_world_t *world, ecs_entity_t query)
Get the query object.
bool ecs_query_next(ecs_iter_t *it)
Progress a query iterator.
const ecs_query_group_info_t * ecs_query_get_group_info(const ecs_query_t *query, uint64_t group_id)
Get information about a query group.
ecs_query_t * ecs_query_update(ecs_world_t *world, ecs_entity_t entity, const ecs_query_desc_t *desc)
Replace the query on an existing entity.
bool ecs_query_is_true(const ecs_query_t *query)
Test whether a query returns one or more results.
char * ecs_term_str(const ecs_world_t *world, const ecs_term_t *term)
Convert a term to a string expression.
bool ecs_query_has_range(const ecs_query_t *query, ecs_table_range_t *range, ecs_iter_t *it)
Match a range with a query.
int32_t ecs_query_find_var(const ecs_query_t *query, const char *name)
Find a variable index.
void ecs_query_fini(ecs_query_t *query)
Delete a query.
bool ecs_query_has(const ecs_query_t *query, ecs_entity_t entity, ecs_iter_t *it)
Match an entity with a query.
char * ecs_query_plan_w_profile(const ecs_query_t *query, const ecs_iter_t *it)
Convert a query to a string with a profile.
struct ecs_query_desc_t ecs_query_desc_t
Used with ecs_query_init().
const char * ecs_query_args_parse(ecs_query_t *query, ecs_iter_t *it, const char *expr)
Populate variables from a key-value string.
int32_t ecs_query_match_count(const ecs_query_t *query)
Return how often a match event happened for a cached query.
char * ecs_query_plan(const ecs_query_t *query)
Convert a query to a string.
ecs_iter_t ecs_query_iter(const ecs_world_t *world, const ecs_query_t *query)
Create a query iterator.
char * ecs_query_str(const ecs_query_t *query)
Convert a query to a string expression.
bool ecs_query_var_is_entity(const ecs_query_t *query, int32_t var_id)
Test if a variable is an entity.
ecs_query_t * ecs_query_init(ecs_world_t *world, const ecs_query_desc_t *desc)
Create a query.
bool ecs_query_changed(ecs_query_t *query)
Return whether the query data changed since the last iteration.
const char * ecs_query_var_name(const ecs_query_t *query, int32_t var_id)
Get the variable name.
bool ecs_term_match_this(const ecs_term_t *term)
Is a term matched on the $this variable.
char * ecs_query_plans(const ecs_query_t *query)
Same as ecs_query_plan(), but includes the plan for populating the cache (if any).
void * ecs_query_get_group_ctx(const ecs_query_t *query, uint64_t group_id)
Get the context of a query group.
ecs_query_count_t ecs_query_count(const ecs_query_t *query)
Return the number of entities and results the query matches with.
const ecs_map_t * ecs_query_get_groups(const ecs_query_t *query)
Return the map with query groups.
bool ecs_term_is_initialized(const ecs_term_t *term)
Test whether a term is set.
bool ecs_term_ref_is_set(const ecs_term_ref_t *ref)
Test whether a term ref is set.
struct ecs_query_count_t ecs_query_count_t
Struct returned by ecs_query_count().
bool ecs_term_match_0(const ecs_term_t *term)
Is a term matched on a 0 source.
const ecs_query_t * ecs_query_get_cache_query(const ecs_query_t *query)
Get the query used to populate the cache.
struct ecs_term_ref_t ecs_term_ref_t
Type that describes a reference to an entity or variable in a term.
ecs_query_cache_kind_t
Specify cache policy for query.
Definition flecs.h:729
ecs_inout_kind_t
Specify read/write access for term.
Definition flecs.h:708
ecs_oper_kind_t
Specify operator for term.
Definition flecs.h:718
@ EcsQueryCacheAll
Require that all query terms can be cached.
Definition flecs.h:732
@ EcsQueryCacheDefault
Behavior determined by query creation context.
Definition flecs.h:730
@ EcsQueryCacheNone
No caching.
Definition flecs.h:733
@ EcsQueryCacheAuto
Cache query terms that are cacheable.
Definition flecs.h:731
@ EcsOut
Term is only written.
Definition flecs.h:714
@ EcsInOut
Term is both read and written.
Definition flecs.h:712
@ EcsInOutFilter
Same as InOutNone + prevents term from triggering observers.
Definition flecs.h:711
@ EcsInOutDefault
InOut for regular terms, In for shared terms.
Definition flecs.h:709
@ EcsInOutNone
Term is neither read nor written.
Definition flecs.h:710
@ EcsIn
Term is only read.
Definition flecs.h:713
@ EcsNot
The term must not match.
Definition flecs.h:721
@ EcsOptional
The term may match.
Definition flecs.h:722
@ EcsOr
One of the terms in an or chain must match.
Definition flecs.h:720
@ EcsOrFrom
Term must match at least one component from term ID.
Definition flecs.h:724
@ EcsAnd
The term must match.
Definition flecs.h:719
@ EcsNotFrom
Term must match none of the components from term ID.
Definition flecs.h:725
@ EcsAndFrom
Term must match all components from term ID.
Definition flecs.h:723
ecs_table_t * ecs_table_add_id(ecs_world_t *world, ecs_table_t *table, ecs_id_t component)
Get the table that has all components of the current table plus the specified ID.
int32_t ecs_search_offset(const ecs_world_t *world, const ecs_table_t *table, int32_t offset, ecs_id_t component, ecs_id_t *component_out)
Search for a component in a table type starting from an offset.
ecs_table_t * ecs_table_remove_id(ecs_world_t *world, ecs_table_t *table, ecs_id_t component)
Get the table that has all components of the current table minus the specified component.
const ecs_type_t * ecs_table_get_type(const ecs_table_t *table)
Get the type for a table.
int32_t ecs_table_get_column_index(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component)
Get the column index for a component.
int32_t ecs_search_relation_for_entity(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, ecs_entity_t rel, bool self, ecs_component_record_t *cr, ecs_entity_t *tgt_out, ecs_id_t *id_out, struct ecs_table_record_t **tr_out)
Search for a component ID by following a relationship, starting from an entity.
void * ecs_table_get_id(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component, int32_t offset)
Get a column from a table by component.
int32_t ecs_table_size(const ecs_table_t *table)
Return the allocated size of the table.
bool ecs_table_has_flags(ecs_table_t *table, ecs_flags32_t flags)
Test a table for flags.
int32_t ecs_table_column_to_type_index(const ecs_table_t *table, int32_t index)
Convert a column index to a type index.
int32_t ecs_table_column_count(const ecs_table_t *table)
Return the number of columns in a table.
bool ecs_commit(ecs_world_t *world, ecs_entity_t entity, ecs_record_t *record, ecs_table_t *table, const ecs_type_t *added, const ecs_type_t *removed)
Commit (move) an entity to a table.
int32_t ecs_search_relation(const ecs_world_t *world, const ecs_table_t *table, int32_t offset, ecs_id_t component, ecs_entity_t rel, ecs_flags64_t flags, ecs_entity_t *tgt_out, ecs_id_t *component_out, struct ecs_table_record_t **tr_out)
Search for a component or relationship ID in a table type starting from an offset.
void * ecs_table_get_column(const ecs_table_t *table, int32_t index, int32_t offset)
Get a column from a table by column index.
int32_t ecs_search(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component, ecs_id_t *component_out)
Search for a component in a table type.
ecs_entity_t ecs_table_get_target(const ecs_world_t *world, const ecs_table_t *table, ecs_entity_t relationship, int32_t index)
Get the relationship target for a table.
int32_t ecs_table_count(const ecs_table_t *table)
Return the number of entities in the table.
const ecs_entity_t * ecs_table_entities(const ecs_table_t *table)
Return the array with entity IDs for the table.
void ecs_table_unlock(ecs_world_t *world, ecs_table_t *table)
Unlock a table.
bool ecs_table_has_traversable(const ecs_table_t *table)
Check if a table has traversable entities.
int32_t ecs_table_get_depth(const ecs_world_t *world, const ecs_table_t *table, ecs_entity_t rel)
Return the depth for a table in the tree for the specified relationship.
bool ecs_table_has_id(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component)
Test if a table has a component.
void ecs_table_swap_rows(ecs_world_t *world, ecs_table_t *table, int32_t row_1, int32_t row_2)
Swap two elements inside the table.
void ecs_table_lock(ecs_world_t *world, ecs_table_t *table)
Lock a table.
ecs_table_t * ecs_table_find(ecs_world_t *world, const ecs_id_t *ids, int32_t id_count)
Find a table from an ID array.
size_t ecs_table_get_column_size(const ecs_table_t *table, int32_t index)
Get the column size from a table.
int32_t ecs_table_get_type_index(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component)
Get the type index for a component.
void ecs_table_clear_entities(ecs_world_t *world, ecs_table_t *table)
Remove all entities in a table.
int32_t ecs_table_type_to_column_index(const ecs_table_t *table, int32_t index)
Convert a type index to a column index.
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 a value.
int ecs_value_move(const ecs_world_t *world, ecs_entity_t type, void *dst, void *src)
Move a value.
int ecs_value_move_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *dst, void *src)
Move a value.
void * ecs_value_new_w_type_info(ecs_world_t *world, const ecs_type_info_t *ti)
Construct a value in new storage.
int ecs_value_move_ctor_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *dst, void *src)
Move-construct a value.
int ecs_value_copy_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *dst, const void *src)
Copy a value.
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 and free storage.
int ecs_value_move_ctor(const ecs_world_t *world, ecs_entity_t type, void *dst, void *src)
Move-construct a value.
int ecs_value_init(const ecs_world_t *world, ecs_entity_t type, void *ptr)
Construct a value in existing storage.
struct ecs_entities_t ecs_entities_t
Type returned by ecs_get_entities().
void ecs_atfini(ecs_world_t *world, ecs_fini_action_t action, void *ctx)
Register an action to be executed when the world is destroyed.
bool ecs_is_fini(const ecs_world_t *world)
Return whether the world is being deleted.
int ecs_fini(ecs_world_t *world)
Delete a world.
ecs_flags32_t ecs_world_get_flags(const ecs_world_t *world)
Get flags set on the world.
ecs_world_t * ecs_mini(void)
Create a new world with just the core module.
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.
ecs_entities_t ecs_get_entities(const ecs_world_t *world)
Return entity identifiers in the world.
void ecs_set_target_fps(ecs_world_t *world, float fps)
Set target frames per second (FPS) for an 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 an action to be executed once after the frame.
bool ecs_should_quit(const ecs_world_t *world)
Return whether a quit has been requested.
void ecs_set_default_query_flags(ecs_world_t *world, ecs_flags32_t flags)
Set the default query flags.
void ecs_quit(ecs_world_t *world)
Signal exit.
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 the entity from a poly.
ecs_id_t ecs_make_pair(ecs_entity_t first, ecs_entity_t second)
Make a pair ID.
const ecs_build_info_t * ecs_get_build_info(void)
Get build info.
bool flecs_poly_is_(const ecs_poly_t *object, int32_t type)
Test if a pointer is of the specified type.
void ecs_entity_range_set(ecs_world_t *world, const ecs_entity_range_t *range)
Set the active entity range.
const ecs_entity_range_t * ecs_entity_range_new(ecs_world_t *world, uint32_t min, uint32_t max)
Create a new entity range.
ecs_entity_t ecs_get_max_id(const ecs_world_t *world)
Get the largest issued entity ID (not counting generation).
void ecs_run_aperiodic(ecs_world_t *world, ecs_flags32_t flags)
Force aperiodic actions.
void * ecs_get_binding_ctx(const ecs_world_t *world)
Get the world binding context.
void ecs_shrink(ecs_world_t *world)
Free unused memory.
void ecs_dim(ecs_world_t *world, int32_t entity_count)
Dimension the world for a specified number of entities.
const ecs_world_info_t * ecs_get_world_info(const ecs_world_t *world)
Get the world info.
const ecs_world_t * ecs_get_world(const ecs_poly_t *poly)
Get the world from a poly.
void ecs_set_ctx(ecs_world_t *world, void *ctx, ecs_ctx_free_t ctx_free)
Set a world context.
void ecs_exclusive_access_begin(ecs_world_t *world, const char *thread_name)
Begin exclusive thread access.
int32_t ecs_delete_empty_tables(ecs_world_t *world, const ecs_delete_empty_tables_desc_t *desc)
Clean up empty tables.
const ecs_entity_range_t * ecs_entity_range_get(const ecs_world_t *world)
Get the currently active entity id range.
void ecs_set_binding_ctx(ecs_world_t *world, void *ctx, ecs_ctx_free_t ctx_free)
Set a world binding context.
struct ecs_delete_empty_tables_desc_t ecs_delete_empty_tables_desc_t
Used with ecs_delete_empty_tables().
void ecs_exclusive_access_end(ecs_world_t *world, bool lock_world)
End exclusive thread access.
void * ecs_get_ctx(const ecs_world_t *world)
Get the world context.
Operating system abstraction API.
Component information.
Definition flecs.h:1599
ecs_size_t size
Component size.
Definition flecs.h:1600
ecs_size_t alignment
Component alignment.
Definition flecs.h:1601
When added to an entity, this informs serialization formats which component to use when a value is as...
Definition flecs.h:1614
ecs_id_t component
Default component ID.
Definition flecs.h:1615
A (string) identifier.
Definition flecs.h:1590
ecs_size_t length
Length of identifier.
Definition flecs.h:1592
char * value
Identifier string.
Definition flecs.h:1591
ecs_hashmap_t * index
Current index.
Definition flecs.h:1595
uint64_t hash
Hash of current value.
Definition flecs.h:1593
uint64_t index_hash
Hash of existing record in current index.
Definition flecs.h:1594
Non-fragmenting ChildOf relationship.
Definition flecs.h:1619
ecs_entity_t value
Parent entity.
Definition flecs.h:1620
Component for storing a poly object.
Definition flecs.h:1605
ecs_poly_t * poly
Pointer to poly object.
Definition flecs.h:1606
Apply a rate filter to a tick source.
Definition timer.h:45
Component used to provide a tick source to systems.
Definition system.h:32
Component used for one-shot and interval timer functionality.
Definition timer.h:35
Tree instantiation cache component.
Definition flecs.h:1643
ecs_tree_spawner_t data[(6)]
Cache data indexed by depth.
Definition flecs.h:1644
Type with information about the current Flecs build.
Definition flecs.h:1489
const char ** flags
Compile-time settings.
Definition flecs.h:1492
int16_t version_major
Major Flecs version.
Definition flecs.h:1494
const char ** addons
Addons included in the build.
Definition flecs.h:1491
const char * version
Stringified version.
Definition flecs.h:1493
const char * compiler
Compiler used to compile Flecs.
Definition flecs.h:1490
bool sanitize
Is this a sanitize build?
Definition flecs.h:1498
bool perf_trace
Is this a perf tracing build?
Definition flecs.h:1499
int16_t version_minor
Minor Flecs version.
Definition flecs.h:1495
bool debug
Is this a debug build?
Definition flecs.h:1497
int16_t version_patch
Patch Flecs version.
Definition flecs.h:1496
Used with ecs_bulk_init().
Definition flecs.h:1092
ecs_id_t ids[32]
IDs to create the entities with.
Definition flecs.h:1102
void ** data
Array with component data to insert.
Definition flecs.h:1104
int32_t count
Number of entities to create/populate.
Definition flecs.h:1100
int32_t _canary
Used for validity testing.
Definition flecs.h:1093
ecs_entity_t * entities
Entities to bulk insert.
Definition flecs.h:1095
ecs_table_t * table
Table to insert the entities into.
Definition flecs.h:1111
Used with ecs_component_init().
Definition flecs.h:1122
int32_t _canary
Used for validity testing.
Definition flecs.h:1123
ecs_type_info_t type
Parameters for type (size, hooks, ...).
Definition flecs.h:1129
ecs_entity_t entity
Existing entity to associate with a component (optional).
Definition flecs.h:1126
Used with ecs_delete_empty_tables().
Definition flecs.h:2777
uint16_t delete_generation
Delete table when generation > delete_generation.
Definition flecs.h:2782
double time_budget_seconds
Amount of time operation is allowed to spend.
Definition flecs.h:2785
uint16_t clear_generation
Free table data when generation > clear_generation.
Definition flecs.h:2779
int32_t offset
Table index to start scanning at.
Definition flecs.h:2789
Type returned by ecs_get_entities().
Definition flecs.h:2117
int32_t alive_count
Number of alive entity IDs.
Definition flecs.h:2120
int32_t count
Total number of entity IDs.
Definition flecs.h:2119
const ecs_entity_t * ids
Array with all entity IDs in the world.
Definition flecs.h:2118
Used with ecs_entity_init().
Definition flecs.h:1046
const char * sep
Optional custom separator for hierarchical names.
Definition flecs.h:1058
const char * root_sep
Optional, used for identifiers relative to the root.
Definition flecs.h:1062
const char * name
Name of the entity.
Definition flecs.h:1053
bool use_low_id
When set to true, a low id (typically reserved for components) will be used to create the entity,...
Definition flecs.h:1074
const char * symbol
Optional entity symbol.
Definition flecs.h:1064
int32_t _canary
Used for validity testing.
Definition flecs.h:1047
const ecs_id_t * add
0-terminated array of IDs to add to the entity.
Definition flecs.h:1079
const char * add_expr
String expression with components to add.
Definition flecs.h:1085
const ecs_value_t * set
0-terminated array of values to set on the entity.
Definition flecs.h:1082
ecs_entity_t id
Set to modify existing entity (optional).
Definition flecs.h:1049
ecs_entity_t parent
Parent entity.
Definition flecs.h:1051
Type that stores an entity id range.
Definition flecs.h:1573
uint32_t max
Last id in range (inclusive, 0 = unlimited).
Definition flecs.h:1575
uint32_t cur
Last issued id in range.
Definition flecs.h:1576
ecs_vec_t recycled
Recycled entity ids (vec<entity_t>).
Definition flecs.h:1577
uint32_t min
First id in range (inclusive).
Definition flecs.h:1574
Used with ecs_emit().
Definition flecs.h:1435
ecs_entity_t entity
Single-entity alternative to setting table / offset / count.
Definition flecs.h:1460
const void * const_param
Same as param, but with the guarantee that the value won't be modified.
Definition flecs.h:1471
ecs_table_t * table
The table for which to notify.
Definition flecs.h:1445
int32_t count
Limit number of notified entities to count.
Definition flecs.h:1457
ecs_table_t * other_table
Optional second table to notify.
Definition flecs.h:1449
int32_t offset
Limit notified entities to ones starting from offset (row) in table.
Definition flecs.h:1452
const ecs_type_t * ids
Component IDs.
Definition flecs.h:1442
ecs_poly_t * observable
Observable (usually the world).
Definition flecs.h:1474
ecs_entity_t event
The event ID.
Definition flecs.h:1437
ecs_flags32_t flags
Event flags.
Definition flecs.h:1477
void * param
Optional context.
Definition flecs.h:1466
Header for ecs_poly_t objects.
Definition flecs.h:524
int32_t type
Magic number indicating which type of Flecs object.
Definition flecs.h:525
int32_t refcount
Refcount, to enable RAII handles.
Definition flecs.h:526
ecs_mixins_t * mixins
Table with offsets to (optional) mixins.
Definition flecs.h:527
Iterator.
Definition flecs.h:1170
ecs_world_t * real_world
Actual world.
Definition flecs.h:1173
void * param
Param passed to ecs_run().
Definition flecs.h:1206
ecs_entity_t event
The event (if applicable).
Definition flecs.h:1194
int32_t frame_offset
Offset relative to the start of iteration.
Definition flecs.h:1217
ecs_flags32_t ref_fields
Bitset with fields that aren't component arrays.
Definition flecs.h:1188
ecs_entity_t interrupted_by
When set, system execution is interrupted.
Definition flecs.h:1221
ecs_flags32_t flags
Iterator flags.
Definition flecs.h:1220
ecs_iter_t * chain_it
Optional, allows for creating iterator chains.
Definition flecs.h:1228
void * ctx
System context.
Definition flecs.h:1207
void * run_ctx
Run language binding context.
Definition flecs.h:1210
ecs_table_t * table
Current table.
Definition flecs.h:1182
int32_t offset
Offset relative to the current table.
Definition flecs.h:1176
ecs_id_t event_id
The (component) ID for the event.
Definition flecs.h:1195
ecs_iter_fini_action_t fini
Function to clean up iterator resources.
Definition flecs.h:1227
ecs_iter_private_t priv_
Private data.
Definition flecs.h:1222
ecs_world_t * world
The world.
Definition flecs.h:1172
void * callback_ctx
Callback language binding context.
Definition flecs.h:1209
ecs_entity_t * sources
Entity on which the ID was matched (0 if same as entities).
Definition flecs.h:1185
void * binding_ctx
System binding context.
Definition flecs.h:1208
ecs_flags32_t row_fields
Fields that must be obtained with field_at.
Definition flecs.h:1189
float delta_system_time
Time elapsed since last system invocation.
Definition flecs.h:1214
const ecs_query_t * query
Query being evaluated.
Definition flecs.h:1203
int8_t term_index
Index of the term that emitted an event.
Definition flecs.h:1200
ecs_entity_t system
The system (if applicable).
Definition flecs.h:1193
ecs_flags32_t set_fields
Fields that are set.
Definition flecs.h:1187
const ecs_size_t * sizes
Component sizes.
Definition flecs.h:1181
float delta_time
Time elapsed since last frame.
Definition flecs.h:1213
ecs_flags32_t up_fields
Bitset with fields matched through up traversal.
Definition flecs.h:1190
ecs_iter_action_t callback
Callback of system or observer.
Definition flecs.h:1226
int8_t field_count
Number of fields in the iterator.
Definition flecs.h:1199
ecs_table_t * other_table
Previous or next table when adding or removing.
Definition flecs.h:1183
int32_t event_cur
Unique event ID.
Definition flecs.h:1196
const ecs_table_record_t ** trs
Info on where to find the field in the table.
Definition flecs.h:1180
int32_t count
Number of entities to iterate.
Definition flecs.h:1177
void ** ptrs
Component pointers.
Definition flecs.h:1179
ecs_iter_next_action_t next
Function to progress iterator.
Definition flecs.h:1225
const ecs_entity_t * entities
Entity identifiers.
Definition flecs.h:1178
ecs_id_t * ids
(Component) IDs.
Definition flecs.h:1184
ecs_flags64_t constrained_vars
Bitset that marks constrained variables.
Definition flecs.h:1186
Used with ecs_observer_init().
Definition flecs.h:1374
ecs_ctx_free_t run_ctx_free
Callback to free run ctx.
Definition flecs.h:1423
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1411
void * run_ctx
Context associated with run (for language bindings).
Definition flecs.h:1420
ecs_entity_t entity
Existing entity to associate with an observer (optional).
Definition flecs.h:1379
int32_t * last_event_id
Used for internal purposes.
Definition flecs.h:1426
void * callback_ctx
Context associated with callback (for language bindings).
Definition flecs.h:1414
void * ctx
User context to pass to callback.
Definition flecs.h:1408
ecs_query_desc_t query
Query for observer.
Definition flecs.h:1382
ecs_flags32_t flags_
Used for internal purposes.
Definition flecs.h:1428
ecs_ctx_free_t callback_ctx_free
Callback to free callback ctx.
Definition flecs.h:1417
int8_t term_index_
Used for internal purposes.
Definition flecs.h:1427
bool global_observer
Global observers are tied to the lifespan of the world.
Definition flecs.h:1394
ecs_iter_action_t callback
Callback to invoke on an event, invoked when the observer matches.
Definition flecs.h:1397
bool yield_existing
When an observer is created, generate events from existing data.
Definition flecs.h:1389
ecs_run_action_t run
Callback invoked on an event.
Definition flecs.h:1405
ecs_entity_t events[8]
Events to observe (OnAdd, OnRemove, OnSet).
Definition flecs.h:1385
int32_t _canary
Used for validity testing.
Definition flecs.h:1376
An observer reacts to events matching a query.
Definition flecs.h:879
int32_t event_count
Number of events.
Definition flecs.h:886
ecs_iter_action_t callback
See ecs_observer_desc_t::callback.
Definition flecs.h:888
ecs_entity_t entity
Entity associated with the observer.
Definition flecs.h:902
ecs_observable_t * observable
Observable for the observer.
Definition flecs.h:899
ecs_run_action_t run
See ecs_observer_desc_t::run.
Definition flecs.h:889
ecs_header_t hdr
Object header.
Definition flecs.h:880
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:895
ecs_entity_t events[8]
Observer events.
Definition flecs.h:885
void * run_ctx
Run language binding context.
Definition flecs.h:893
ecs_world_t * world
The world.
Definition flecs.h:901
ecs_ctx_free_t run_ctx_free
Callback to free run_ctx.
Definition flecs.h:897
void * callback_ctx
Callback language binding context.
Definition flecs.h:892
void * ctx
Observer context.
Definition flecs.h:891
ecs_ctx_free_t callback_ctx_free
Callback to free callback_ctx.
Definition flecs.h:896
ecs_query_t * query
Observer query.
Definition flecs.h:882
Struct returned by ecs_query_count().
Definition flecs.h:5266
int32_t entities
Number of entities returned by the query.
Definition flecs.h:5268
int32_t results
Number of results returned by the query.
Definition flecs.h:5267
int32_t tables
Number of tables returned by the query.
Definition flecs.h:5269
Used with ecs_query_init().
Definition flecs.h:1300
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1361
ecs_id_t group_by
Component ID to be used for grouping.
Definition flecs.h:1331
ecs_term_t terms[32]
Query terms.
Definition flecs.h:1305
int32_t _canary
Used for validity testing.
Definition flecs.h:1302
void * ctx
User context to pass to callback.
Definition flecs.h:1355
ecs_ctx_free_t group_by_ctx_free
Function to free group_by_ctx.
Definition flecs.h:1352
void * group_by_ctx
Context to pass to group_by.
Definition flecs.h:1349
void * binding_ctx
Context to be used for language bindings.
Definition flecs.h:1358
ecs_entity_t order_by
Component to sort on, used together with order_by_callback or order_by_table_callback.
Definition flecs.h:1327
ecs_order_by_action_t order_by_callback
Callback used for ordering query results.
Definition flecs.h:1319
ecs_group_create_action_t on_group_create
Callback that is invoked when a new group is created.
Definition flecs.h:1342
ecs_entity_t entity
Entity associated with query (optional).
Definition flecs.h:1367
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition flecs.h:1364
ecs_group_by_action_t group_by_callback
Callback used for grouping results.
Definition flecs.h:1338
ecs_group_delete_action_t on_group_delete
Callback that is invoked when an existing group is deleted.
Definition flecs.h:1346
ecs_sort_table_action_t order_by_table_callback
Callback used for ordering query results.
Definition flecs.h:1323
ecs_flags32_t flags
Flags for enabling query features.
Definition flecs.h:1314
ecs_query_cache_kind_t cache_kind
Caching policy of the query.
Definition flecs.h:1311
const char * expr
Query DSL expression (optional).
Definition flecs.h:1308
Type that contains information about a query group.
Definition flecs.h:1563
int32_t table_count
Number of tables in group.
Definition flecs.h:1566
void * ctx
Group context, returned by on_group_create.
Definition flecs.h:1567
uint64_t id
Group ID.
Definition flecs.h:1564
int32_t match_count
How often tables have been matched or unmatched.
Definition flecs.h:1565
Queries are lists of constraints (terms) that match entities.
Definition flecs.h:838
ecs_flags32_t row_fields
Fields that must be acquired with field_at.
Definition flecs.h:858
ecs_flags32_t data_fields
Fields that have data.
Definition flecs.h:855
ecs_flags32_t read_fields
Fields that read data.
Definition flecs.h:857
ecs_header_t hdr
Object header.
Definition flecs.h:839
int8_t var_count
Number of query variables.
Definition flecs.h:847
ecs_flags32_t fixed_fields
Bitmasks for quick field information lookups.
Definition flecs.h:852
ecs_flags32_t var_fields
Fields with non-$this variable source.
Definition flecs.h:853
ecs_flags32_t write_fields
Fields that write data.
Definition flecs.h:856
int32_t eval_count
Number of times the query is evaluated.
Definition flecs.h:873
ecs_world_t * world
World or stage the query was created with.
Definition flecs.h:871
ecs_flags32_t static_id_fields
Fields with a static (component) id.
Definition flecs.h:854
uint64_t bloom_filter
Bitmask used to quickly discard tables.
Definition flecs.h:845
ecs_world_t * real_world
Actual world.
Definition flecs.h:870
ecs_flags32_t set_fields
Fields that will be set.
Definition flecs.h:860
ecs_entity_t entity
Entity associated with query (optional).
Definition flecs.h:869
void * ctx
User context to pass to callback.
Definition flecs.h:866
int32_t * sizes
Component sizes.
Definition flecs.h:842
ecs_id_t * ids
Component ids.
Definition flecs.h:843
ecs_flags32_t shared_readonly_fields
Fields that don't write shared data.
Definition flecs.h:859
ecs_term_t * terms
Query terms.
Definition flecs.h:841
ecs_query_cache_kind_t cache_kind
Caching policy of the query.
Definition flecs.h:862
int8_t term_count
Number of query terms.
Definition flecs.h:848
char ** vars
Array with variable names for the iterator.
Definition flecs.h:864
int8_t field_count
Number of fields returned by the query.
Definition flecs.h:849
ecs_flags32_t flags
Query flags.
Definition flecs.h:846
void * binding_ctx
Context to be used for language bindings.
Definition flecs.h:867
Type that describes a reference to an entity or variable in a term.
Definition flecs.h:799
const char * name
Name.
Definition flecs.h:806
ecs_entity_t id
Entity ID.
Definition flecs.h:800
Type that describes a term (single element in a query).
Definition flecs.h:814
ecs_term_ref_t src
Source of term.
Definition flecs.h:820
int8_t field_index
Index of the field for the term in the iterator.
Definition flecs.h:831
ecs_id_t id
Component ID to be matched by term.
Definition flecs.h:815
int16_t oper
Operator of term.
Definition flecs.h:829
ecs_term_ref_t second
Second element of pair.
Definition flecs.h:822
ecs_flags16_t flags_
Flags that help evaluation, set by ecs_query_init().
Definition flecs.h:832
ecs_entity_t trav
Relationship to traverse when looking for the component.
Definition flecs.h:824
int16_t inout
Access to contents matched by term.
Definition flecs.h:828
ecs_term_ref_t first
Component or first element of pair.
Definition flecs.h:821
Component with data to instantiate a non-fragmenting tree.
Definition flecs.h:1624
uint32_t child
Prefab child entity (without generation).
Definition flecs.h:1627
int32_t parent_index
Index into the children vector.
Definition flecs.h:1628
const char * child_name
Name of the prefab child.
Definition flecs.h:1625
ecs_table_t * table
Table in which the child will be stored.
Definition flecs.h:1626
Tree spawner data for a single hierarchy depth.
Definition flecs.h:1632
ecs_vec_t children
vector<ecs_tree_spawner_child_t>.
Definition flecs.h:1633
ecs_copy_t copy_ctor
Ctor + copy.
Definition flecs.h:961
void * lifecycle_ctx
Component lifecycle context (see meta addon).
Definition flecs.h:1012
void * ctx
User-defined context.
Definition flecs.h:1010
ecs_iter_action_t on_remove
Callback that is invoked when an instance of the component is removed.
Definition flecs.h:1002
void * binding_ctx
Language binding context.
Definition flecs.h:1011
ecs_move_t move_dtor
Move + dtor.
Definition flecs.h:976
ecs_flags32_t flags
Hook flags.
Definition flecs.h:988
ecs_cmp_t cmp
Compare hook.
Definition flecs.h:979
ecs_copy_t copy
copy assignment.
Definition flecs.h:957
ecs_ctx_free_t lifecycle_ctx_free
Callback to free lifecycle_ctx.
Definition flecs.h:1016
ecs_iter_action_t on_set
Callback that is invoked when an instance of the component is set.
Definition flecs.h:997
ecs_move_t move
move assignment.
Definition flecs.h:958
ecs_xtor_t ctor
ctor.
Definition flecs.h:955
ecs_iter_action_t on_replace
Callback that is invoked with the existing and new value before the value is assigned.
Definition flecs.h:1008
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1014
ecs_iter_action_t on_add
Callback that is invoked when an instance of a component is added.
Definition flecs.h:992
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition flecs.h:1015
ecs_move_t move_ctor
Ctor + move.
Definition flecs.h:964
ecs_equals_t equals
Equals hook.
Definition flecs.h:982
ecs_move_t ctor_move_dtor
Ctor + move + dtor (or move_ctor + dtor).
Definition flecs.h:970
ecs_xtor_t dtor
dtor.
Definition flecs.h:956
Type that contains component information (passed to ctors/dtors/...).
Definition flecs.h:1023
ecs_size_t alignment
Alignment of the type.
Definition flecs.h:1025
ecs_size_t size
Size of the type.
Definition flecs.h:1024
const char * name
Type name.
Definition flecs.h:1028
ecs_entity_t component
Handle to component (do not set).
Definition flecs.h:1027
ecs_type_hooks_t hooks
Type hooks.
Definition flecs.h:1026
A type is a list of (component) IDs.
Definition flecs.h:402
ecs_id_t * array
Array with IDs.
Definition flecs.h:403
int32_t count
Number of elements in array.
Definition flecs.h:404
Utility to hold a value of a dynamic type.
Definition flecs.h:1037
void * ptr
Pointer to value.
Definition flecs.h:1039
ecs_entity_t type
Type of value.
Definition flecs.h:1038
Type that contains information about the world.
Definition flecs.h:1503
int64_t observers_ran_total
Total number of times an observer was invoked.
Definition flecs.h:1529
float delta_time
Time passed to or computed by ecs_progress().
Definition flecs.h:1507
int64_t systems_ran_total
Total number of systems run.
Definition flecs.h:1528
int64_t set_count
Set commands processed.
Definition flecs.h:1546
double world_time_total
Time elapsed in simulation.
Definition flecs.h:1515
int32_t tag_id_count
Number of tag (no data) IDs in the world.
Definition flecs.h:1532
int32_t component_id_count
Number of component (data) IDs in the world.
Definition flecs.h:1533
int64_t pipeline_build_count_total
Total number of pipeline builds.
Definition flecs.h:1527
int64_t eval_comp_monitors_total
Total number of monitor evaluations.
Definition flecs.h:1520
int32_t table_count
Number of tables.
Definition flecs.h:1536
float delta_time_raw
Raw delta time (no time scaling).
Definition flecs.h:1506
float frame_time_total
Total time spent processing a frame.
Definition flecs.h:1510
int64_t table_create_total
Total number of times a table was created.
Definition flecs.h:1525
float system_time_total
Total time spent in systems.
Definition flecs.h:1511
int64_t id_delete_total
Total number of times an ID was deleted.
Definition flecs.h:1524
float merge_time_total
Total time spent in merges.
Definition flecs.h:1513
struct ecs_world_info_t::@0 cmd
Command statistics.
int64_t discard_count
Commands discarded, happens when the entity is no longer alive when running the command.
Definition flecs.h:1549
int64_t clear_count
Clear commands processed.
Definition flecs.h:1545
ecs_entity_t last_component_id
Last issued component entity ID.
Definition flecs.h:1504
int64_t frame_count_total
Total number of frames.
Definition flecs.h:1518
int64_t merge_count_total
Total number of merges.
Definition flecs.h:1519
int64_t other_count
Other commands processed.
Definition flecs.h:1551
int64_t batched_command_count
Commands batched.
Definition flecs.h:1553
int64_t table_delete_total
Total number of times a table was deleted.
Definition flecs.h:1526
int64_t queries_ran_total
Total number of times a query was evaluated.
Definition flecs.h:1530
int64_t delete_count
Delete commands processed.
Definition flecs.h:1544
int64_t rematch_count_total
Total number of rematches.
Definition flecs.h:1521
int64_t id_create_total
Total number of times a new ID was created.
Definition flecs.h:1523
int64_t batched_entity_count
Entities for which commands were batched.
Definition flecs.h:1552
float time_scale
Time scale applied to delta_time.
Definition flecs.h:1508
int32_t pair_id_count
Number of pair IDs in the world.
Definition flecs.h:1534
float rematch_time_total
Time spent on query rematching.
Definition flecs.h:1514
int64_t ensure_count
Ensure or emplace commands processed.
Definition flecs.h:1547
float target_fps
Target FPS.
Definition flecs.h:1509
double world_time_total_raw
Time elapsed in simulation (no scaling).
Definition flecs.h:1516
float emit_time_total
Total time spent notifying observers.
Definition flecs.h:1512
uint32_t creation_time
Time when world was created.
Definition flecs.h:1538
int64_t modified_count
Modified commands processed.
Definition flecs.h:1548
const char * name_prefix
Value set by ecs_set_name_prefix().
Definition flecs.h:1556
int64_t event_count
Enqueued custom events.
Definition flecs.h:1550
int64_t add_count
Add commands processed.
Definition flecs.h:1542
int64_t remove_count
Remove commands processed.
Definition flecs.h:1543