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 6
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_CACHED_QUERIES
226// #define FLECS_C /**< C API convenience macros, always enabled. */
227#define FLECS_CPP
228#define FLECS_CONSTRAINT_TRAITS
229#define FLECS_DOC
230// #define FLECS_EXCLUSIVE_ACCESS /**< Enable exclusive world access checks. */
231#define FLECS_ENTITY_RANGES
232#define FLECS_FRAME
233// #define FLECS_JOURNAL /**< Journaling addon. */
234#define FLECS_JSON
235#define FLECS_HTTP
236#define FLECS_LOG
237#define FLECS_META
238#define FLECS_METRICS
239#define FLECS_MODULE
240#define FLECS_MULTI_WORLD
241#define FLECS_OS_API_IMPL
242// #define FLECS_PERF_TRACE /**< Enable performance tracing. */
243#define FLECS_PIPELINE
244#define FLECS_PREFAB
245#define FLECS_QUERY_PLANS
246#define FLECS_REST
247#define FLECS_PARSER
248#define FLECS_QUERY_DSL
249#define FLECS_SCRIPT
250// #define FLECS_SCRIPT_MATH /**< Math functions for Flecs script (may require linking with libm). */
251// #define FLECS_SCRIPT_PLATFORM /**< Platform constants for Flecs script. */
252#define FLECS_SYSTEM
253#define FLECS_STATS
254#define FLECS_TIMER
255#define FLECS_UNITS
256#endif // ifndef FLECS_CUSTOM_BUILD
257
258#include "flecs/private/addon_defines.h"
259
263// #define FLECS_LOW_FOOTPRINT
264#ifdef FLECS_LOW_FOOTPRINT
265#define FLECS_HI_COMPONENT_ID 16
266#define FLECS_HI_ID_RECORD_ID 16
267#define FLECS_ENTITY_PAGE_BITS 6
268#define FLECS_USE_OS_ALLOC
269#define FLECS_DEFAULT_TO_UNCACHED_QUERIES
270#endif
271
286#ifndef FLECS_HI_COMPONENT_ID
287#define FLECS_HI_COMPONENT_ID 256
288#endif
289
296#ifndef FLECS_HI_ID_RECORD_ID
297#define FLECS_HI_ID_RECORD_ID 1024
298#endif
299
305#ifndef FLECS_SPARSE_PAGE_BITS
306#define FLECS_SPARSE_PAGE_BITS 6
307#endif
308
311#ifndef FLECS_ENTITY_PAGE_BITS
312#define FLECS_ENTITY_PAGE_BITS 10
313#endif
314
319// #define FLECS_USE_OS_ALLOC
320
323#ifndef FLECS_ID_DESC_MAX
324#define FLECS_ID_DESC_MAX 32
325#endif
326
329#ifndef FLECS_EVENT_DESC_MAX
330#define FLECS_EVENT_DESC_MAX 8
331#endif
332
335#ifndef FLECS_TERM_COUNT_MAX
336#define FLECS_TERM_COUNT_MAX 32
337#endif
338
341#ifndef FLECS_TERM_ARG_COUNT_MAX
342#define FLECS_TERM_ARG_COUNT_MAX 16
343#endif
344
345#ifdef FLECS_QUERY_PLANS
348#ifndef FLECS_QUERY_VARIABLE_COUNT_MAX
349#define FLECS_QUERY_VARIABLE_COUNT_MAX 64
350#endif
351#endif
352
355#ifndef FLECS_QUERY_SCOPE_NESTING_MAX
356#define FLECS_QUERY_SCOPE_NESTING_MAX 8
357#endif
358
363#ifndef FLECS_DAG_DEPTH_MAX
364#define FLECS_DAG_DEPTH_MAX 128
365#endif
366
371#define FLECS_TREE_SPAWNER_DEPTH_CACHE_SIZE (6)
372
375#include "flecs/private/api_defines.h"
376
386typedef uint64_t ecs_id_t;
387
394
410typedef struct {
412 int32_t count;
413} ecs_type_t;
414
438
441
444
446typedef struct ecs_term_t ecs_term_t;
447
450
469
474
479typedef struct ecs_iter_t ecs_iter_t;
480
489typedef struct ecs_ref_t ecs_ref_t;
490
495
500
503
506
526typedef void ecs_poly_t;
527
530
537
540
543#include "flecs/datastructures/vec.h" /* Vector datatype */
544#include "flecs/datastructures/sparse.h" /* Sparse set */
545#include "flecs/datastructures/block_allocator.h" /* Block allocator */
546#include "flecs/datastructures/stack_allocator.h" /* Stack allocator */
547#include "flecs/datastructures/map.h" /* Map */
548#include "flecs/datastructures/allocator.h" /* Allocator */
549#include "flecs/datastructures/strbuf.h" /* String builder */
550#include "flecs/os_api.h" /* Abstraction for operating system functions */
551
552#ifdef __cplusplus
553extern "C" {
554#endif
555
580typedef void (*ecs_run_action_t)(
581 ecs_iter_t *it);
582
589typedef void (*ecs_iter_action_t)(
590 ecs_iter_t *it);
591
600 ecs_iter_t *it);
601
608 ecs_iter_t *it);
609
612 ecs_entity_t e1,
613 const void *ptr1,
614 ecs_entity_t e2,
615 const void *ptr2);
616
619 ecs_world_t* world,
620 ecs_table_t* table,
621 ecs_entity_t* entities,
622 void* ptr,
623 int32_t size,
624 int32_t lo,
625 int32_t hi,
626 ecs_order_by_action_t order_by);
627
629typedef uint64_t (*ecs_group_by_action_t)(
630 ecs_world_t *world,
631 ecs_table_t *table,
632 ecs_id_t group_id,
633 void *ctx);
634
636typedef void* (*ecs_group_create_action_t)(
637 ecs_world_t *world,
638 uint64_t group_id,
639 void *group_by_ctx); /* from ecs_query_desc_t */
640
643 ecs_world_t *world,
644 uint64_t group_id,
645 void *group_ctx, /* return value from ecs_group_create_action_t */
646 void *group_by_ctx); /* from ecs_query_desc_t */
647
649typedef void (*ecs_module_action_t)(
650 ecs_world_t *world);
651
653typedef void (*ecs_fini_action_t)(
654 ecs_world_t *world,
655 void *ctx);
656
658typedef void (*ecs_ctx_free_t)(
659 void *ctx);
660
662typedef int (*ecs_compare_action_t)(
663 const void *ptr1,
664 const void *ptr2);
665
667typedef uint64_t (*ecs_hash_value_action_t)(
668 const void *ptr);
669
671typedef void (*ecs_xtor_t)(
672 void *ptr,
673 int32_t count,
674 const ecs_type_info_t *type_info);
675
677typedef void (*ecs_copy_t)(
678 void *dst_ptr,
679 const void *src_ptr,
680 int32_t count,
681 const ecs_type_info_t *type_info);
682
684typedef void (*ecs_move_t)(
685 void *dst_ptr,
686 void *src_ptr,
687 int32_t count,
688 const ecs_type_info_t *type_info);
689
691typedef int (*ecs_cmp_t)(
692 const void *a_ptr,
693 const void *b_ptr,
694 const ecs_type_info_t *type_info);
695
697typedef bool (*ecs_equals_t)(
698 const void *a_ptr,
699 const void *b_ptr,
700 const ecs_type_info_t *type_info);
701
705typedef bool (*ecs_on_validate_t)(
706 ecs_world_t *world,
707 ecs_entity_t entity,
708 void *ptr);
709
711typedef void (*flecs_poly_dtor_t)(
712 ecs_poly_t *poly);
713
732
743
753
760#define EcsSelf (1llu << 63)
761
766#define EcsUp (1llu << 62)
767
772#define EcsTrav (1llu << 61)
773
778#define EcsCascade (1llu << 60)
779
784#define EcsDesc (1llu << 59)
785
790#define EcsIsVariable (1llu << 58)
791
796#define EcsIsEntity (1llu << 57)
797
802#define EcsIsName (1llu << 56)
803
808#define EcsTraverseFlags (EcsSelf|EcsUp|EcsTrav|EcsCascade|EcsDesc)
809
814#define EcsTermRefFlags (EcsTraverseFlags|EcsIsVariable|EcsIsEntity|EcsIsName)
815
830
852
860 int32_t *sizes;
863 uint64_t bloom_filter;
864 ecs_flags32_t flags;
865#ifdef FLECS_QUERY_PLANS
866 int8_t var_count;
867#endif
868 int8_t term_count;
869 int8_t field_count;
872 ecs_termset_t fixed_fields;
873 ecs_termset_t var_fields;
874 ecs_termset_t static_id_fields;
875 ecs_termset_t data_fields;
876 ecs_termset_t write_fields;
877 ecs_termset_t read_fields;
878 ecs_termset_t row_fields;
880 ecs_termset_t set_fields;
884#ifdef FLECS_QUERY_PLANS
885 char **vars;
886#endif
887
888 void *ctx;
895 int32_t eval_count;
896};
897
926
934/* Flags that can be used to check which hooks a type has set */
935#define ECS_TYPE_HOOK_CTOR ECS_CAST(ecs_flags32_t, 1 << 0)
936#define ECS_TYPE_HOOK_DTOR ECS_CAST(ecs_flags32_t, 1 << 1)
937#define ECS_TYPE_HOOK_COPY ECS_CAST(ecs_flags32_t, 1 << 2)
938#define ECS_TYPE_HOOK_MOVE ECS_CAST(ecs_flags32_t, 1 << 3)
939#define ECS_TYPE_HOOK_COPY_CTOR ECS_CAST(ecs_flags32_t, 1 << 4)
940#define ECS_TYPE_HOOK_MOVE_CTOR ECS_CAST(ecs_flags32_t, 1 << 5)
941#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 6)
942#define ECS_TYPE_HOOK_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 7)
943#define ECS_TYPE_HOOK_CMP ECS_CAST(ecs_flags32_t, 1 << 8)
944#define ECS_TYPE_HOOK_EQUALS ECS_CAST(ecs_flags32_t, 1 << 9)
945
946
947/* Flags that can be used to set/check which hooks of a type are invalid */
948#define ECS_TYPE_HOOK_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 10)
949#define ECS_TYPE_HOOK_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 12)
950#define ECS_TYPE_HOOK_COPY_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 13)
951#define ECS_TYPE_HOOK_MOVE_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 14)
952#define ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 15)
953#define ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 16)
954#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 17)
955#define ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 18)
956#define ECS_TYPE_HOOK_CMP_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 19)
957#define ECS_TYPE_HOOK_EQUALS_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 20)
958
959/* Internal debug flag that indicates type hooks have been invoked */
960#define ECS_TYPE_HOOK_IN_USE ECS_CAST(ecs_flags32_t, 1 << 21)
961
962
963/* All valid hook flags */
964#define ECS_TYPE_HOOKS (ECS_TYPE_HOOK_CTOR|ECS_TYPE_HOOK_DTOR|\
965 ECS_TYPE_HOOK_COPY|ECS_TYPE_HOOK_MOVE|ECS_TYPE_HOOK_COPY_CTOR|\
966 ECS_TYPE_HOOK_MOVE_CTOR|ECS_TYPE_HOOK_CTOR_MOVE_DTOR|\
967 ECS_TYPE_HOOK_MOVE_DTOR|ECS_TYPE_HOOK_CMP|ECS_TYPE_HOOK_EQUALS)
968
969/* All invalid hook flags */
970#define ECS_TYPE_HOOKS_ILLEGAL (ECS_TYPE_HOOK_CTOR_ILLEGAL|\
971 ECS_TYPE_HOOK_DTOR_ILLEGAL|ECS_TYPE_HOOK_COPY_ILLEGAL|\
972 ECS_TYPE_HOOK_MOVE_ILLEGAL|ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL|\
973 ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL|ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL|\
974 ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL|ECS_TYPE_HOOK_CMP_ILLEGAL|\
975 ECS_TYPE_HOOK_EQUALS_ILLEGAL)
1045
1058
1059#include "flecs/private/api_types.h" /* Supporting API types */
1060#include "flecs/private/api_support.h" /* Supporting API functions */
1061#include "flecs/datastructures/hashmap.h" /* Hashmap */
1062#include "flecs/private/api_internals.h" /* Supporting API functions */
1063
1070
1107
1137
1151
1191 /* World */
1195 /* Matched data */
1196 int32_t offset;
1197 int32_t count;
1199 void **ptrs;
1201 const int16_t *columns;
1202 const ecs_size_t *sizes;
1207#ifdef FLECS_QUERY_PLANS
1208 ecs_flags64_t constrained_vars;
1209#endif
1210 ecs_termset_t set_fields;
1211 ecs_termset_t ref_fields;
1212 ecs_termset_t row_fields;
1213 ecs_termset_t up_fields;
1215 /* Input information */
1219 int32_t event_cur;
1221 /* Query information */
1223 int8_t term_index;
1228 /* Context */
1229 void *param;
1230 void *ctx;
1233 void *run_ctx;
1235 /* Time */
1239 /* Iterator counters */
1242 /* Misc */
1243 ecs_flags32_t flags;
1245 ecs_iter_private_t priv_;
1247 /* Chained iterators */
1252};
1253
1254
1259#define EcsQueryMatchPrefab (1u << 1u)
1260
1265#define EcsQueryMatchDisabled (1u << 2u)
1266
1271#define EcsQueryMatchEmptyTables (1u << 3u)
1272
1277#define EcsQueryAllowUnresolvedByName (1u << 6u)
1278
1283#define EcsQueryTableOnly (1u << 7u)
1284
1295#define EcsQueryDetectChanges (1u << 8u)
1296
1305#define EcsQueryGroupByOrdered (1u << 9u)
1306
1316#define EcsQueryGroupByDesc (1u << 10u)
1317
1318
1392
1453
1458typedef struct ecs_event_desc_t {
1461
1466
1469
1473
1475 int32_t offset;
1476
1480 int32_t count;
1481
1484
1489 void *param;
1490
1494 const void *const_param;
1495
1500 void *set_ptr;
1501
1504
1506 ecs_flags32_t flags;
1508
1509
1518typedef struct ecs_build_info_t {
1519 const char *compiler;
1520 const char **addons;
1521 const char **flags;
1522 const char *version;
1526 bool debug;
1530
1590
1598
1609typedef struct EcsIdentifier {
1610 char *value;
1611 ecs_size_t length;
1612 uint64_t hash;
1613 uint64_t index_hash;
1614 ecs_hashmap_t *index;
1616
1618typedef struct EcsComponent {
1619 ecs_size_t size;
1620 ecs_size_t alignment;
1622
1627
1632
1634typedef struct {
1635 const char *child_name;
1637 uint32_t child;
1640
1642typedef struct {
1643 ecs_vec_t children;
1645
1656
1660/* Only include deprecated definitions if deprecated addon is required */
1661#ifdef FLECS_DEPRECATED
1663#endif
1664
1680FLECS_API extern const ecs_id_t ECS_PAIR;
1681
1683FLECS_API extern const ecs_id_t ECS_AUTO_OVERRIDE;
1684
1686FLECS_API extern const ecs_id_t ECS_TOGGLE;
1687
1689FLECS_API extern const ecs_id_t ECS_VALUE_PAIR;
1690
1698/* Built-in component IDs */
1699
1701FLECS_API extern const ecs_entity_t ecs_id(EcsComponent);
1702
1704FLECS_API extern const ecs_entity_t ecs_id(EcsIdentifier);
1705
1707FLECS_API extern const ecs_entity_t ecs_id(EcsPoly);
1708
1710FLECS_API extern const ecs_entity_t ecs_id(EcsParent);
1711
1713FLECS_API extern const ecs_entity_t ecs_id(EcsTreeSpawner);
1714
1716FLECS_API extern const ecs_entity_t EcsParentDepth;
1717
1719FLECS_API extern const ecs_entity_t EcsQuery;
1720
1722FLECS_API extern const ecs_entity_t EcsObserver;
1723
1725FLECS_API extern const ecs_entity_t EcsSystem;
1726
1728FLECS_API extern const ecs_entity_t ecs_id(EcsTickSource);
1729
1731FLECS_API extern const ecs_entity_t ecs_id(EcsPipelineQuery);
1732
1734FLECS_API extern const ecs_entity_t ecs_id(EcsTimer);
1735
1737FLECS_API extern const ecs_entity_t ecs_id(EcsRateFilter);
1738
1740FLECS_API extern const ecs_entity_t EcsFlecs;
1741
1743FLECS_API extern const ecs_entity_t EcsFlecsCore;
1744
1746FLECS_API extern const ecs_entity_t EcsWorld;
1747
1749FLECS_API extern const ecs_entity_t EcsWildcard;
1750
1752FLECS_API extern const ecs_entity_t EcsAny;
1753
1755FLECS_API extern const ecs_entity_t EcsThis;
1756
1758FLECS_API extern const ecs_entity_t EcsVariable;
1759
1767FLECS_API extern const ecs_entity_t EcsTransitive;
1768
1776FLECS_API extern const ecs_entity_t EcsReflexive;
1777
1783FLECS_API extern const ecs_entity_t EcsInheritable;
1784
1786FLECS_API extern const ecs_entity_t EcsOnInstantiate;
1787
1788#ifdef FLECS_PREFAB
1792FLECS_API extern const ecs_entity_t EcsOverride;
1793
1797FLECS_API extern const ecs_entity_t EcsInherit;
1798#endif
1799
1804FLECS_API extern const ecs_entity_t EcsDontInherit;
1805
1815FLECS_API extern const ecs_entity_t EcsExclusive;
1816
1819FLECS_API extern const ecs_entity_t EcsTraversable;
1820
1830FLECS_API extern const ecs_entity_t EcsWith;
1831
1833FLECS_API extern const ecs_entity_t EcsCanToggle;
1834
1837FLECS_API extern const ecs_entity_t EcsPairIsTag;
1838
1840FLECS_API extern const ecs_entity_t EcsName;
1841
1843FLECS_API extern const ecs_entity_t EcsSymbol;
1844
1846FLECS_API extern const ecs_entity_t EcsAlias;
1847
1849FLECS_API extern const ecs_entity_t EcsChildOf;
1850
1852FLECS_API extern const ecs_entity_t EcsIsA;
1853
1855FLECS_API extern const ecs_entity_t EcsDependsOn;
1856
1858FLECS_API extern const ecs_entity_t EcsOrderedChildren;
1859
1861FLECS_API extern const ecs_entity_t EcsModule;
1862
1865#ifdef FLECS_PREFAB
1866FLECS_API extern const ecs_entity_t EcsPrefab;
1867#endif
1868
1871FLECS_API extern const ecs_entity_t EcsDisabled;
1872
1876FLECS_API extern const ecs_entity_t EcsNotQueryable;
1877
1879FLECS_API extern const ecs_entity_t EcsOnAdd;
1880
1882FLECS_API extern const ecs_entity_t EcsOnRemove;
1883
1885FLECS_API extern const ecs_entity_t EcsOnSet;
1886
1888FLECS_API extern const ecs_entity_t EcsMonitor;
1889
1891FLECS_API extern const ecs_entity_t EcsOnTableCreate;
1892
1894FLECS_API extern const ecs_entity_t EcsOnTableDelete;
1895
1897FLECS_API extern const ecs_entity_t EcsOnDelete;
1898
1901FLECS_API extern const ecs_entity_t EcsOnDeleteTarget;
1902
1905FLECS_API extern const ecs_entity_t EcsRemove;
1906
1909FLECS_API extern const ecs_entity_t EcsDelete;
1910
1913FLECS_API extern const ecs_entity_t EcsPanic;
1914
1916FLECS_API extern const ecs_entity_t EcsSparse;
1917
1919FLECS_API extern const ecs_entity_t EcsDontFragment;
1920
1922FLECS_API extern const ecs_entity_t EcsPredEq;
1923
1925FLECS_API extern const ecs_entity_t EcsPredMatch;
1926
1928FLECS_API extern const ecs_entity_t EcsPredLookup;
1929
1931FLECS_API extern const ecs_entity_t EcsScopeOpen;
1932
1934FLECS_API extern const ecs_entity_t EcsScopeClose;
1935
1940FLECS_API extern const ecs_entity_t EcsEmpty;
1941
1942FLECS_API extern const ecs_entity_t ecs_id(EcsPipeline);
1943FLECS_API extern const ecs_entity_t EcsOnStart;
1944FLECS_API extern const ecs_entity_t EcsPreFrame;
1945FLECS_API extern const ecs_entity_t EcsOnLoad;
1946FLECS_API extern const ecs_entity_t EcsPostLoad;
1947FLECS_API extern const ecs_entity_t EcsPreUpdate;
1948FLECS_API extern const ecs_entity_t EcsOnUpdate;
1949FLECS_API extern const ecs_entity_t EcsOnValidate;
1950FLECS_API extern const ecs_entity_t EcsPostUpdate;
1951FLECS_API extern const ecs_entity_t EcsPreStore;
1952FLECS_API extern const ecs_entity_t EcsOnStore;
1953FLECS_API extern const ecs_entity_t EcsPostFrame;
1954FLECS_API extern const ecs_entity_t EcsPhase;
1956FLECS_API extern const ecs_entity_t EcsConstant;
1960#define EcsLastInternalComponentId (ecs_id(EcsTreeSpawner))
1961
1964#define EcsFirstUserComponentId (8)
1965
1968#define EcsFirstUserEntityId (FLECS_HI_COMPONENT_ID + 128)
1969
1970/* When visualized, the reserved ID ranges look like this:
1971 * - [1..8]: Built-in components
1972 * - [9..FLECS_HI_COMPONENT_ID]: Low IDs reserved for application components
1973 * - [FLECS_HI_COMPONENT_ID + 1..EcsFirstUserEntityId]: Built-in entities
1974 */
1975
1997FLECS_API
1999
2006FLECS_API
2008
2018FLECS_API
2020 int argc,
2021 char *argv[]);
2022
2029FLECS_API
2031 ecs_world_t *world);
2032
2040FLECS_API
2042 const ecs_world_t *world);
2043
2052FLECS_API
2054 ecs_world_t *world,
2055 ecs_fini_action_t action,
2056 void *ctx);
2057
2064
2091FLECS_API
2093 const ecs_world_t *world);
2094
2102FLECS_API
2104 const ecs_world_t *world);
2105
2182FLECS_API
2184 ecs_world_t *world,
2185 bool multi_threaded);
2186
2194FLECS_API
2196 ecs_world_t *world);
2197
2203FLECS_API
2205 ecs_world_t *stage);
2206
2223FLECS_API
2225 ecs_world_t *world);
2226
2240FLECS_API
2242 ecs_world_t *world);
2243
2258FLECS_API
2260 ecs_world_t *world);
2261
2272FLECS_API
2274 ecs_world_t *world);
2275
2287FLECS_API
2289 const ecs_world_t *world);
2290
2302FLECS_API
2304 const ecs_world_t *world);
2305
2319FLECS_API
2321 ecs_world_t *world,
2322 int32_t stages);
2323
2330FLECS_API
2332 const ecs_world_t *world);
2333
2349FLECS_API
2351 const ecs_world_t *world,
2352 int32_t stage_id);
2353
2361FLECS_API
2363 const ecs_world_t *world);
2364
2372FLECS_API
2374 ecs_world_t *world);
2375
2380FLECS_API
2382 ecs_world_t *stage);
2383
2391FLECS_API
2393 const ecs_world_t *world);
2394
2410FLECS_API
2412 ecs_world_t *world,
2413 void *ctx,
2414 ecs_ctx_free_t ctx_free);
2415
2424FLECS_API
2426 ecs_world_t *world,
2427 void *ctx,
2428 ecs_ctx_free_t ctx_free);
2429
2437FLECS_API
2439 const ecs_world_t *world);
2440
2448FLECS_API
2450 const ecs_world_t *world);
2451
2457FLECS_API
2459
2465FLECS_API
2467 const ecs_world_t *world);
2468
2477FLECS_API
2479 ecs_world_t *world,
2480 int32_t entity_count);
2481
2496FLECS_API
2498 ecs_world_t *world);
2499
2505FLECS_API
2507 const ecs_world_t *world);
2508
2522FLECS_API
2524 ecs_world_t *world,
2525 ecs_flags32_t flags);
2526
2542
2578FLECS_API
2580 ecs_world_t *world,
2581 const ecs_delete_empty_tables_desc_t *desc);
2582
2588FLECS_API
2590 const ecs_poly_t *poly);
2591
2597FLECS_API
2599 const ecs_poly_t *poly);
2600
2614FLECS_API
2616 const ecs_poly_t *object,
2617 int32_t type);
2618
2622#define flecs_poly_is(object, type)\
2623 flecs_poly_is_(object, type##_magic)
2624
2633FLECS_API
2635 ecs_entity_t first,
2636 ecs_entity_t second);
2637
2660FLECS_API
2662 ecs_world_t *world,
2663 const char *thread_name);
2664
2687FLECS_API
2689 ecs_world_t *world,
2690 bool lock_world);
2691
2717FLECS_API
2719 ecs_world_t *world);
2720
2738FLECS_API
2740 ecs_world_t *world);
2741
2749FLECS_API
2751 ecs_world_t *world,
2752 ecs_id_t component);
2753
2761FLECS_API
2763 ecs_world_t *world,
2764 ecs_table_t *table);
2765
2784FLECS_API
2786 ecs_world_t *world,
2787 const ecs_entity_desc_t *desc);
2788
2799FLECS_API
2801 ecs_world_t *world,
2802 const ecs_value_t *values);
2803
2830FLECS_API
2832 ecs_world_t *world,
2833 const ecs_bulk_desc_t *desc);
2834
2844FLECS_API
2846 ecs_world_t *world,
2847 ecs_id_t component,
2848 int32_t count);
2849
2865FLECS_API
2867 ecs_world_t *world,
2868 ecs_entity_t dst,
2869 ecs_entity_t src,
2870 bool copy_value);
2871
2880FLECS_API
2882 ecs_world_t *world,
2883 ecs_entity_t entity);
2884
2892FLECS_API
2894 ecs_world_t *world,
2895 ecs_id_t component);
2896
2914FLECS_API
2916 ecs_world_t *world,
2917 ecs_entity_t parent,
2918 const ecs_entity_t *children,
2919 int32_t child_count);
2920
2930FLECS_API
2932 const ecs_world_t *world,
2933 ecs_entity_t parent);
2934
2952FLECS_API
2954 ecs_world_t *world,
2955 ecs_entity_t entity,
2956 ecs_id_t component);
2957
2966FLECS_API
2968 ecs_world_t *world,
2969 ecs_entity_t entity,
2970 ecs_id_t component);
2971
3023FLECS_API
3025 ecs_world_t *world,
3026 ecs_entity_t entity,
3027 ecs_id_t component);
3028
3035FLECS_API
3037 ecs_world_t *world,
3038 ecs_entity_t entity);
3039
3047FLECS_API
3049 ecs_world_t *world,
3050 ecs_id_t component);
3051
3070FLECS_API
3072 ecs_world_t *world,
3073 ecs_entity_t entity,
3074 bool enabled);
3075
3089FLECS_API
3091 ecs_world_t *world,
3092 ecs_entity_t entity,
3093 ecs_id_t component,
3094 bool enable);
3095
3106FLECS_API
3108 const ecs_world_t *world,
3109 ecs_entity_t entity,
3110 ecs_id_t component);
3111
3135FLECS_API
3136FLECS_ALWAYS_INLINE const void* ecs_get_id(
3137 const ecs_world_t *world,
3138 ecs_entity_t entity,
3139 ecs_id_t component);
3140
3155FLECS_API
3156FLECS_ALWAYS_INLINE void* ecs_get_mut_id(
3157 const ecs_world_t *world,
3158 ecs_entity_t entity,
3159 ecs_id_t component);
3160
3175FLECS_API
3176FLECS_ALWAYS_INLINE void* ecs_get_sparse_id(
3177 const ecs_world_t *world,
3178 ecs_entity_t entity,
3179 ecs_id_t component,
3180 size_t size);
3181
3199FLECS_API
3201 ecs_world_t *world,
3202 ecs_entity_t entity,
3203 ecs_id_t component,
3204 size_t size);
3205
3216FLECS_ALWAYS_INLINE FLECS_API
3218 const ecs_world_t *world,
3219 ecs_entity_t entity,
3220 ecs_id_t component);
3221
3232FLECS_ALWAYS_INLINE FLECS_API
3234 const ecs_world_t *world,
3235 ecs_ref_t *ref,
3236 ecs_id_t component);
3237
3246FLECS_ALWAYS_INLINE FLECS_API
3248 const ecs_world_t *world,
3249 ecs_ref_t *ref,
3250 ecs_id_t component);
3251
3272FLECS_API
3274 ecs_world_t *world,
3275 ecs_entity_t entity,
3276 ecs_id_t component,
3277 size_t size,
3278 bool *is_new);
3279
3289FLECS_API
3291 ecs_world_t *world,
3292 ecs_entity_t entity,
3293 ecs_id_t component);
3294
3310FLECS_API
3312 ecs_world_t *world,
3313 ecs_entity_t entity,
3314 ecs_id_t component,
3315 size_t size,
3316 const void *ptr);
3317
3346FLECS_API
3348 const ecs_world_t *world,
3349 ecs_entity_t e);
3350
3380FLECS_API
3382 const ecs_world_t *world,
3383 ecs_entity_t e);
3384
3390FLECS_API
3392 ecs_entity_t e);
3393
3410FLECS_API
3412 const ecs_world_t *world,
3413 ecs_entity_t e);
3414
3437FLECS_API
3439 ecs_world_t *world,
3440 ecs_entity_t entity);
3441
3460FLECS_API
3462 ecs_world_t *world,
3463 ecs_id_t component);
3464
3472FLECS_API
3474 const ecs_world_t *world,
3475 ecs_entity_t entity);
3476
3491FLECS_API
3493 ecs_world_t *world,
3494 ecs_entity_t entity);
3495
3501FLECS_API
3503 ecs_entity_t entity);
3504
3520FLECS_API
3522 const ecs_world_t *world,
3523 ecs_entity_t entity);
3524
3531FLECS_API
3533 const ecs_world_t *world,
3534 ecs_entity_t entity);
3535
3543FLECS_API
3545 const ecs_world_t *world,
3546 const ecs_type_t* type);
3547
3559FLECS_API
3561 const ecs_world_t *world,
3562 const ecs_table_t *table);
3563
3578FLECS_API
3580 const ecs_world_t *world,
3581 ecs_entity_t entity);
3582
3593FLECS_API
3594FLECS_ALWAYS_INLINE bool ecs_has_id(
3595 const ecs_world_t *world,
3596 ecs_entity_t entity,
3597 ecs_id_t component);
3598
3609FLECS_API
3610FLECS_ALWAYS_INLINE bool ecs_owns_id(
3611 const ecs_world_t *world,
3612 ecs_entity_t entity,
3613 ecs_id_t component);
3614
3629FLECS_API
3631 const ecs_world_t *world,
3632 ecs_entity_t entity,
3633 ecs_entity_t rel,
3634 int32_t index);
3635
3649FLECS_API
3651 const ecs_world_t *world,
3652 ecs_entity_t entity);
3653
3667FLECS_API
3669 ecs_world_t *world,
3670 ecs_entity_t parent,
3671 const char *name);
3672
3693FLECS_API
3695 const ecs_world_t *world,
3696 ecs_entity_t entity,
3697 ecs_entity_t rel,
3698 ecs_id_t component);
3699
3710FLECS_API
3712 const ecs_world_t *world,
3713 ecs_entity_t entity,
3714 ecs_entity_t rel);
3715
3723FLECS_API
3725 const ecs_world_t *world,
3726 ecs_id_t entity);
3727
3747FLECS_API
3748const char* ecs_get_name(
3749 const ecs_world_t *world,
3750 ecs_entity_t entity);
3751
3761FLECS_API
3762const char* ecs_get_symbol(
3763 const ecs_world_t *world,
3764 ecs_entity_t entity);
3765
3779FLECS_API
3781 ecs_world_t *world,
3782 ecs_entity_t entity,
3783 const char *name);
3784
3798FLECS_API
3800 ecs_world_t *world,
3801 ecs_entity_t entity,
3802 const char *symbol);
3803
3815FLECS_API
3817 ecs_world_t *world,
3818 ecs_entity_t entity,
3819 const char *alias);
3820
3836FLECS_API
3838 const ecs_world_t *world,
3839 const char *path);
3840
3855FLECS_API
3857 const ecs_world_t *world,
3858 ecs_entity_t parent,
3859 const char *name);
3860
3883FLECS_API
3885 const ecs_world_t *world,
3886 ecs_entity_t parent,
3887 const char *path,
3888 const char *sep,
3889 const char *prefix,
3890 bool recursive);
3891
3909FLECS_API
3911 const ecs_world_t *world,
3912 const char *symbol,
3913 bool lookup_as_path,
3914 bool recursive);
3915
3937FLECS_API
3939 const ecs_world_t *world,
3940 ecs_entity_t parent,
3941 ecs_entity_t child,
3942 const char *sep,
3943 const char *prefix);
3944
3958FLECS_API
3960 const ecs_world_t *world,
3961 ecs_entity_t parent,
3962 ecs_entity_t child,
3963 const char *sep,
3964 const char *prefix,
3965 ecs_strbuf_t *buf,
3966 bool escape);
3967
3983FLECS_API
3985 ecs_world_t *world,
3986 ecs_entity_t parent,
3987 const char *path,
3988 const char *sep,
3989 const char *prefix);
3990
4005FLECS_API
4007 ecs_world_t *world,
4008 ecs_entity_t entity,
4009 ecs_entity_t parent,
4010 const char *path,
4011 const char *sep,
4012 const char *prefix);
4013
4027FLECS_API
4029 ecs_world_t *world,
4030 ecs_entity_t scope);
4031
4039FLECS_API
4041 const ecs_world_t *world);
4042
4052FLECS_API
4054 ecs_world_t *world,
4055 const char *prefix);
4056
4083FLECS_API
4085 ecs_world_t *world,
4086 const ecs_entity_t *lookup_path);
4087
4094FLECS_API
4096 const ecs_world_t *world);
4097
4122FLECS_API
4124 ecs_world_t *world,
4125 const ecs_component_desc_t *desc);
4126
4136FLECS_API
4138 const ecs_world_t *world,
4139 ecs_id_t component);
4140
4152FLECS_API
4154 ecs_world_t *world,
4155 ecs_entity_t component,
4156 const ecs_type_hooks_t *hooks);
4157
4164FLECS_API
4166 const ecs_world_t *world,
4167 ecs_entity_t component);
4168
4192FLECS_API
4194 const ecs_world_t *world,
4195 ecs_id_t component);
4196
4205FLECS_API
4207 const ecs_world_t *world,
4208 ecs_id_t component);
4209
4229FLECS_API
4231 const ecs_world_t *world,
4232 ecs_id_t component);
4233
4242FLECS_API
4244 ecs_id_t component,
4245 ecs_id_t pattern);
4246
4252FLECS_API
4254 ecs_id_t component);
4255
4261FLECS_API
4263 ecs_id_t component);
4264
4271 ecs_id_t component);
4272
4286FLECS_API
4288 const ecs_world_t *world,
4289 ecs_id_t component);
4290
4299FLECS_API
4300ecs_flags32_t ecs_id_get_flags(
4301 const ecs_world_t *world,
4302 ecs_id_t component);
4303
4314FLECS_API
4316 uint64_t component_flags);
4317
4333FLECS_API
4335 const ecs_world_t *world,
4336 ecs_id_t component);
4337
4345FLECS_API
4347 const ecs_world_t *world,
4348 ecs_id_t component,
4349 ecs_strbuf_t *buf);
4350
4359FLECS_API
4361 const ecs_world_t *world,
4362 const char *expr);
4363
4379FLECS_API
4381 const ecs_term_ref_t *ref);
4382
4394FLECS_API
4396 const ecs_term_t *term);
4397
4412FLECS_API
4414 const ecs_term_t *term);
4415
4428FLECS_API
4430 const ecs_term_t *term);
4431
4440FLECS_API
4442 const ecs_world_t *world,
4443 const ecs_term_t *term);
4444
4452FLECS_API
4454 const ecs_query_t *query);
4455
4496FLECS_API
4498 const ecs_world_t *world,
4499 ecs_id_t component);
4500
4506FLECS_API
4508 ecs_iter_t *it);
4509
4532FLECS_API
4533FLECS_ALWAYS_INLINE ecs_iter_t ecs_children(
4534 const ecs_world_t *world,
4535 ecs_entity_t parent);
4536
4544FLECS_API
4545FLECS_ALWAYS_INLINE ecs_iter_t ecs_children_w_rel(
4546 const ecs_world_t *world,
4547 ecs_entity_t relationship,
4548 ecs_entity_t parent);
4549
4555FLECS_API
4557 ecs_iter_t *it);
4558
4577FLECS_API
4579 ecs_world_t *world,
4580 const ecs_query_desc_t *desc);
4581
4592FLECS_API
4594 ecs_world_t *world,
4595 ecs_entity_t entity,
4596 const ecs_query_desc_t *desc);
4597
4602FLECS_API
4604 ecs_query_t *query);
4605
4606#ifdef FLECS_QUERY_PLANS
4607
4616FLECS_API
4618 const ecs_query_t *query,
4619 const char *name);
4620
4628FLECS_API
4630 const ecs_query_t *query,
4631 int32_t var_id);
4632
4643FLECS_API
4645 const ecs_query_t *query,
4646 int32_t var_id);
4647
4648#endif // FLECS_QUERY_PLANS
4649
4718FLECS_API
4720 const ecs_world_t *world,
4721 const ecs_query_t *query);
4722
4730FLECS_API
4732 ecs_iter_t *it);
4733
4752FLECS_API
4754 const ecs_query_t *query,
4755 ecs_entity_t entity,
4756 ecs_iter_t *it);
4757
4776FLECS_API
4778 const ecs_query_t *query,
4779 ecs_table_t *table,
4780 ecs_iter_t *it);
4781
4808FLECS_API
4810 const ecs_query_t *query,
4811 ecs_table_range_t *range,
4812 ecs_iter_t *it);
4813
4814#ifdef FLECS_CACHED_QUERIES
4815
4823FLECS_API
4825 const ecs_query_t *query);
4826
4832FLECS_API extern const ecs_entity_t EcsOnQueryCacheRevalidate;
4833
4839
4840#endif // FLECS_CACHED_QUERIES
4841
4842#ifdef FLECS_QUERY_PLANS
4843
4853FLECS_API
4855 const ecs_query_t *query);
4856
4871FLECS_API
4873 const ecs_query_t *query,
4874 const ecs_iter_t *it);
4875
4881FLECS_API
4883 const ecs_query_t *query);
4884
4902FLECS_API
4904 ecs_query_t *query,
4905 ecs_iter_t *it,
4906 const char *expr);
4907
4908#endif // FLECS_QUERY_PLANS
4909
4910#ifdef FLECS_CACHED_QUERIES
4933FLECS_API
4935 ecs_query_t *query);
4936#endif
4937
4946FLECS_API
4948 const ecs_world_t *world,
4949 ecs_entity_t query);
4950
4951#ifdef FLECS_CACHED_QUERIES
4962FLECS_API
4964 ecs_iter_t *it);
4965
4988FLECS_API
4990 ecs_iter_t *it,
4991 uint64_t group_id);
4992
5018FLECS_API
5019const ecs_map_t* ecs_query_get_groups(
5020 const ecs_query_t *query);
5021
5030FLECS_API
5032 const ecs_query_t *query,
5033 uint64_t group_id);
5034
5043FLECS_API
5045 const ecs_query_t *query,
5046 uint64_t group_id);
5047
5048#endif // FLECS_CACHED_QUERIES
5049
5058
5065FLECS_API
5067 const ecs_query_t *query);
5068
5074FLECS_API
5076 const ecs_query_t *query);
5077
5078#ifdef FLECS_CACHED_QUERIES
5079
5088FLECS_API
5090 const ecs_query_t *query);
5091
5092#endif // FLECS_CACHED_QUERIES
5093
5122FLECS_API
5124 ecs_world_t *world,
5125 ecs_event_desc_t *desc);
5126
5137FLECS_API
5139 ecs_world_t *world,
5140 ecs_event_desc_t *desc);
5141
5156FLECS_API
5158 ecs_world_t *world,
5159 const ecs_observer_desc_t *desc);
5160
5176FLECS_API
5178 ecs_world_t *world,
5179 ecs_entity_t observer,
5180 const ecs_observer_desc_t *desc);
5181
5190FLECS_API
5192 const ecs_world_t *world,
5193 ecs_entity_t observer);
5194
5217FLECS_API
5219 ecs_iter_t *it);
5220
5230FLECS_API
5232 ecs_iter_t *it);
5233
5245FLECS_API
5247 ecs_iter_t *it);
5248
5261FLECS_API
5263 ecs_iter_t *it);
5264
5272FLECS_API
5274 ecs_iter_t *it);
5275
5311FLECS_API
5313 ecs_iter_t *it,
5314 int32_t var_id,
5315 ecs_entity_t entity);
5316
5327FLECS_API
5329 ecs_iter_t *it,
5330 int32_t var_id,
5331 const ecs_table_t *table);
5332
5343FLECS_API
5345 ecs_iter_t *it,
5346 int32_t var_id,
5347 const ecs_table_range_t *range);
5348
5349#ifdef FLECS_QUERY_PLANS
5350
5363FLECS_API
5365 ecs_iter_t *it,
5366 int32_t var_id);
5367
5374FLECS_API
5376 const ecs_iter_t *it,
5377 int32_t var_id);
5378
5384FLECS_API
5386 const ecs_iter_t *it);
5387
5393FLECS_API
5395 const ecs_iter_t *it);
5396
5410FLECS_API
5412 ecs_iter_t *it,
5413 int32_t var_id);
5414
5428FLECS_API
5430 ecs_iter_t *it,
5431 int32_t var_id);
5432
5444FLECS_API
5446 ecs_iter_t *it,
5447 int32_t var_id);
5448
5449#endif // FLECS_QUERY_PLANS
5450
5451#ifdef FLECS_CACHED_QUERIES
5452
5464FLECS_API
5466 const ecs_iter_t *it);
5467
5479FLECS_API
5481 ecs_iter_t *it);
5482#endif
5483
5499FLECS_API
5501 const ecs_iter_t *it,
5502 int32_t offset,
5503 int32_t limit);
5504
5511FLECS_API
5513 ecs_iter_t *it);
5514
5535FLECS_API
5537 const ecs_iter_t *it,
5538 int32_t index,
5539 int32_t count);
5540
5547FLECS_API
5549 ecs_iter_t *it);
5550
5592FLECS_API
5594 const ecs_iter_t *it,
5595 size_t size,
5596 int8_t index);
5597
5620FLECS_API
5622 const ecs_iter_t *it,
5623 size_t size,
5624 int8_t index,
5625 int32_t row);
5626
5635FLECS_API
5637 const ecs_iter_t *it,
5638 int8_t index);
5639
5650FLECS_API
5652 const ecs_iter_t *it,
5653 int8_t index);
5654
5661FLECS_API
5663 const ecs_iter_t *it,
5664 int8_t index);
5665
5672FLECS_API
5674 const ecs_iter_t *it,
5675 int8_t index);
5676
5685FLECS_API
5687 const ecs_iter_t *it,
5688 int8_t index);
5689
5697FLECS_API
5699 const ecs_iter_t *it,
5700 int8_t index);
5701
5709FLECS_API
5711 const ecs_iter_t *it,
5712 int8_t index);
5713
5727FLECS_API
5729 const ecs_iter_t *it,
5730 int8_t index);
5731
5747FLECS_API
5749 const ecs_table_t *table);
5750
5761FLECS_API
5763 const ecs_world_t *world,
5764 const ecs_table_t *table,
5765 ecs_id_t component);
5766
5776FLECS_API
5778 const ecs_world_t *world,
5779 const ecs_table_t *table,
5780 ecs_id_t component);
5781
5789FLECS_API
5791 const ecs_table_t *table);
5792
5806FLECS_API
5808 const ecs_table_t *table,
5809 int32_t index);
5810
5819FLECS_API
5821 const ecs_table_t *table,
5822 int32_t index);
5823
5832FLECS_API
5834 const ecs_table_t *table,
5835 int32_t index,
5836 int32_t offset);
5837
5847FLECS_API
5849 const ecs_world_t *world,
5850 const ecs_table_t *table,
5851 ecs_id_t component,
5852 int32_t offset);
5853
5861FLECS_API
5863 const ecs_table_t *table,
5864 int32_t index);
5865
5872FLECS_API
5874 const ecs_table_t *table);
5875
5883FLECS_API
5885 const ecs_table_t *table);
5886
5893FLECS_API
5895 const ecs_table_t *table);
5896
5907FLECS_API
5909 const ecs_world_t *world,
5910 const ecs_table_t *table,
5911 ecs_id_t component);
5912
5923FLECS_API
5925 const ecs_world_t *world,
5926 const ecs_table_t *table,
5927 ecs_entity_t relationship,
5928 int32_t index);
5929
5940FLECS_API
5942 const ecs_world_t *world,
5943 const ecs_table_t *table,
5944 ecs_entity_t rel);
5945
5955FLECS_API
5957 ecs_world_t *world,
5958 ecs_table_t *table,
5959 ecs_id_t component);
5960
5971FLECS_API
5973 ecs_world_t *world,
5974 const ecs_id_t *ids,
5975 int32_t id_count);
5976
5986FLECS_API
5988 ecs_world_t *world,
5989 ecs_table_t *table,
5990 ecs_id_t component);
5991
6007FLECS_API
6009 ecs_world_t *world,
6010 ecs_table_t *table);
6011
6018FLECS_API
6020 ecs_world_t *world,
6021 ecs_table_t *table);
6022
6032FLECS_API
6034 ecs_table_t *table,
6035 ecs_flags32_t flags);
6036
6044FLECS_API
6046 const ecs_table_t *table);
6047
6057FLECS_API
6059 ecs_world_t* world,
6060 ecs_table_t* table,
6061 int32_t row_1,
6062 int32_t row_2);
6063
6083FLECS_API
6085 const ecs_world_t *world,
6086 const ecs_table_t *table,
6087 ecs_id_t component,
6088 ecs_id_t *component_out);
6089
6125FLECS_API
6127 const ecs_world_t *world,
6128 const ecs_table_t *table,
6129 int32_t offset,
6130 ecs_id_t component,
6131 ecs_id_t *component_out);
6132
6173FLECS_API
6175 const ecs_world_t *world,
6176 const ecs_table_t *table,
6177 int32_t offset,
6178 ecs_id_t component,
6179 ecs_entity_t rel,
6180 ecs_flags64_t flags, /* EcsSelf and/or EcsUp */
6181 ecs_entity_t *tgt_out,
6182 ecs_id_t *component_out,
6183 struct ecs_table_record_t **tr_out);
6184
6200FLECS_API
6202 const ecs_world_t *world,
6203 ecs_entity_t entity,
6204 ecs_id_t id,
6205 ecs_entity_t rel,
6206 bool self,
6208 ecs_entity_t *tgt_out,
6209 ecs_id_t *id_out,
6210 struct ecs_table_record_t **tr_out);
6211
6219FLECS_API
6221 ecs_world_t* world,
6222 ecs_table_t* table);
6223
6237#include "flecs/addons/flecs_c.h"
6238
6239#ifdef __cplusplus
6240}
6241#endif
6242
6243#include "flecs/private/addons.h"
6244
6245#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.
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Add a (component) ID to an entity.
struct ecs_value_t ecs_value_t
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 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 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 EcsEmpty
Tag used to indicate a query is empty.
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 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 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 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 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:505
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:440
struct ecs_ref_t ecs_ref_t
A ref is a fast way to fetch a component for a specific entity.
Definition flecs.h:489
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:393
struct ecs_table_record_t ecs_table_record_t
Opaque type for table record.
Definition flecs.h:539
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:437
struct ecs_mixins_t ecs_mixins_t
Type that stores poly mixins.
Definition flecs.h:529
uint64_t ecs_id_t
IDs are the things that can be added to an entity.
Definition flecs.h:386
struct ecs_observable_t ecs_observable_t
An observable produces events that can be listened for by an observer.
Definition flecs.h:473
struct ecs_record_t ecs_record_t
Information about an entity, like its table and row.
Definition flecs.h:502
struct ecs_table_t ecs_table_t
A table stores entities and components for a specific type.
Definition flecs.h:443
void ecs_poly_t
A poly object.
Definition flecs.h:526
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_insert_w_values(ecs_world_t *world, const ecs_value_t *values)
Create a new entity with a list of component values.
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:649
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:629
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:691
uint64_t(* ecs_hash_value_action_t)(const void *ptr)
Callback used for hashing values.
Definition flecs.h:667
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:642
void(* ecs_iter_fini_action_t)(ecs_iter_t *it)
Function prototype for freeing an iterator.
Definition flecs.h:607
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:636
bool(* ecs_on_validate_t)(ecs_world_t *world, ecs_entity_t entity, void *ptr)
On validate hook.
Definition flecs.h:705
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:618
bool(* ecs_iter_next_action_t)(ecs_iter_t *it)
Function prototype for iterating an iterator.
Definition flecs.h:599
void(* ecs_iter_action_t)(ecs_iter_t *it)
Function prototype for iterables.
Definition flecs.h:589
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:677
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:697
int(* ecs_compare_action_t)(const void *ptr1, const void *ptr2)
Callback used for sorting values.
Definition flecs.h:662
void(* ecs_fini_action_t)(ecs_world_t *world, void *ctx)
Action callback on world exit.
Definition flecs.h:653
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:684
void(* flecs_poly_dtor_t)(ecs_poly_t *poly)
Destructor function for poly objects.
Definition flecs.h:711
void(* ecs_run_action_t)(ecs_iter_t *it)
Function prototype for runnables (systems, observers).
Definition flecs.h:580
void(* ecs_ctx_free_t)(void *ctx)
Function to clean up context data.
Definition flecs.h:658
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:611
void(* ecs_xtor_t)(void *ptr, int32_t count, const ecs_type_info_t *type_info)
Constructor/destructor callback.
Definition flecs.h:671
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, ecs_id_t component)
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.
void * ecs_get_sparse_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size)
Get a pointer to a sparse 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.
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_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:330
#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:324
#define FLECS_TERM_COUNT_MAX
Maximum number of terms in queries.
Definition flecs.h:336
#define FLECS_TREE_SPAWNER_DEPTH_CACHE_SIZE
Size of the depth cache in the tree spawner component.
Definition flecs.h:371
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.
struct ecs_query_cache_revalidate_t ecs_query_cache_revalidate_t
Payload for EcsOnQueryCacheRevalidate event.
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.
const ecs_entity_t EcsOnQueryCacheRevalidate
Event emitted when a table needs to be revalidated for a query cache.
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:745
ecs_inout_kind_t
Specify read/write access for term.
Definition flecs.h:724
ecs_oper_kind_t
Specify operator for term.
Definition flecs.h:734
@ EcsQueryCacheAll
Require that all query terms can be cached.
Definition flecs.h:749
@ EcsQueryCacheDefault
Behavior determined by query creation context.
Definition flecs.h:746
@ EcsQueryCacheNone
No caching.
Definition flecs.h:751
@ EcsQueryCacheAuto
Cache query terms that are cacheable.
Definition flecs.h:747
@ EcsOut
Term is only written.
Definition flecs.h:730
@ EcsInOut
Term is both read and written.
Definition flecs.h:728
@ EcsInOutFilter
Same as InOutNone + prevents term from triggering observers.
Definition flecs.h:727
@ EcsInOutDefault
InOut for regular terms, In for shared terms.
Definition flecs.h:725
@ EcsInOutNone
Term is neither read nor written.
Definition flecs.h:726
@ EcsIn
Term is only read.
Definition flecs.h:729
@ EcsNot
The term must not match.
Definition flecs.h:737
@ EcsOptional
The term may match.
Definition flecs.h:738
@ EcsOr
One of the terms in an or chain must match.
Definition flecs.h:736
@ EcsOrFrom
Term must match at least one component from term ID.
Definition flecs.h:740
@ EcsAnd
The term must match.
Definition flecs.h:735
@ EcsNotFrom
Term must match none of the components from term ID.
Definition flecs.h:741
@ EcsAndFrom
Term must match all components from term ID.
Definition flecs.h:739
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.
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.
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.
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.
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.
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:1618
ecs_size_t size
Component size.
Definition flecs.h:1619
ecs_size_t alignment
Component alignment.
Definition flecs.h:1620
A (string) identifier.
Definition flecs.h:1609
ecs_size_t length
Length of identifier.
Definition flecs.h:1611
char * value
Identifier string.
Definition flecs.h:1610
ecs_hashmap_t * index
Current index.
Definition flecs.h:1614
uint64_t hash
Hash of current value.
Definition flecs.h:1612
uint64_t index_hash
Hash of existing record in current index.
Definition flecs.h:1613
Non-fragmenting ChildOf relationship.
Definition flecs.h:1629
ecs_entity_t value
Parent entity.
Definition flecs.h:1630
Component for storing a poly object.
Definition flecs.h:1624
ecs_poly_t * poly
Pointer to poly object.
Definition flecs.h:1625
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:1653
ecs_tree_spawner_t data[(6)]
Cache data indexed by depth.
Definition flecs.h:1654
Type with information about the current Flecs build.
Definition flecs.h:1518
const char ** flags
Compile-time settings.
Definition flecs.h:1521
int16_t version_major
Major Flecs version.
Definition flecs.h:1523
const char ** addons
Addons included in the build.
Definition flecs.h:1520
const char * version
Stringified version.
Definition flecs.h:1522
const char * compiler
Compiler used to compile Flecs.
Definition flecs.h:1519
bool sanitize
Is this a sanitize build?
Definition flecs.h:1527
bool perf_trace
Is this a perf tracing build?
Definition flecs.h:1528
int16_t version_minor
Minor Flecs version.
Definition flecs.h:1524
bool debug
Is this a debug build?
Definition flecs.h:1526
int16_t version_patch
Patch Flecs version.
Definition flecs.h:1525
Used with ecs_bulk_init().
Definition flecs.h:1112
ecs_id_t ids[32]
IDs to create the entities with.
Definition flecs.h:1122
void ** data
Array with component data to insert.
Definition flecs.h:1124
int32_t count
Number of entities to create/populate.
Definition flecs.h:1120
int32_t _canary
Used for validity testing.
Definition flecs.h:1113
ecs_entity_t * entities
Entities to bulk insert.
Definition flecs.h:1115
ecs_table_t * table
Table to insert the entities into.
Definition flecs.h:1131
Used with ecs_component_init().
Definition flecs.h:1142
int32_t _canary
Used for validity testing.
Definition flecs.h:1143
ecs_type_info_t type
Parameters for type (size, hooks, ...).
Definition flecs.h:1149
ecs_entity_t entity
Existing entity to associate with a component (optional).
Definition flecs.h:1146
Used with ecs_delete_empty_tables().
Definition flecs.h:2528
uint16_t delete_generation
Delete table when generation > delete_generation.
Definition flecs.h:2533
double time_budget_seconds
Amount of time operation is allowed to spend.
Definition flecs.h:2536
uint16_t clear_generation
Free table data when generation > clear_generation.
Definition flecs.h:2530
int32_t offset
Table index to start scanning at.
Definition flecs.h:2540
Type returned by ecs_get_entities().
Definition flecs.h:2059
int32_t alive_count
Number of alive entity IDs.
Definition flecs.h:2062
int32_t count
Total number of entity IDs.
Definition flecs.h:2061
const ecs_entity_t * ids
Array with all entity IDs in the world.
Definition flecs.h:2060
Used with ecs_entity_init().
Definition flecs.h:1075
const char * sep
Optional custom separator for hierarchical names.
Definition flecs.h:1087
const char * root_sep
Optional, used for identifiers relative to the root.
Definition flecs.h:1091
const char * name
Name of the entity.
Definition flecs.h:1082
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:1103
const char * symbol
Optional entity symbol.
Definition flecs.h:1093
int32_t _canary
Used for validity testing.
Definition flecs.h:1076
ecs_entity_t id
Set to modify existing entity (optional).
Definition flecs.h:1078
ecs_entity_t parent
Parent entity.
Definition flecs.h:1080
Used with ecs_emit().
Definition flecs.h:1458
ecs_entity_t entity
Single-entity alternative to setting table / offset / count.
Definition flecs.h:1483
const void * const_param
Same as param, but with the guarantee that the value won't be modified.
Definition flecs.h:1494
ecs_table_t * table
The table for which to notify.
Definition flecs.h:1468
int32_t count
Limit number of notified entities to count.
Definition flecs.h:1480
ecs_table_t * other_table
Optional second table to notify.
Definition flecs.h:1472
int32_t offset
Limit notified entities to ones starting from offset (row) in table.
Definition flecs.h:1475
const ecs_type_t * ids
Component IDs.
Definition flecs.h:1465
void * set_ptr
Optional pointer to the value of the component for which the event is emitted.
Definition flecs.h:1500
ecs_poly_t * observable
Observable (usually the world).
Definition flecs.h:1503
ecs_entity_t event
The event ID.
Definition flecs.h:1460
ecs_flags32_t flags
Event flags.
Definition flecs.h:1506
void * param
Optional context.
Definition flecs.h:1489
Header for ecs_poly_t objects.
Definition flecs.h:532
int32_t type
Magic number indicating which type of Flecs object.
Definition flecs.h:533
int32_t refcount
Refcount, to enable RAII handles.
Definition flecs.h:534
ecs_mixins_t * mixins
Table with offsets to (optional) mixins.
Definition flecs.h:535
Iterator.
Definition flecs.h:1190
ecs_world_t * real_world
Actual world.
Definition flecs.h:1193
void * param
Param passed to ecs_run().
Definition flecs.h:1229
ecs_entity_t event
The event (if applicable).
Definition flecs.h:1217
int32_t frame_offset
Offset relative to the start of iteration.
Definition flecs.h:1240
ecs_flags32_t ref_fields
Bitset with fields that aren't component arrays.
Definition flecs.h:1211
ecs_entity_t interrupted_by
When set, system execution is interrupted.
Definition flecs.h:1244
ecs_flags32_t flags
Iterator flags.
Definition flecs.h:1243
ecs_iter_t * chain_it
Optional, allows for creating iterator chains.
Definition flecs.h:1251
void * ctx
System context.
Definition flecs.h:1230
void * run_ctx
Run language binding context.
Definition flecs.h:1233
ecs_table_t * table
Current table.
Definition flecs.h:1203
int32_t offset
Offset relative to the current table.
Definition flecs.h:1196
ecs_id_t event_id
The (component) ID for the event.
Definition flecs.h:1218
ecs_iter_fini_action_t fini
Function to clean up iterator resources.
Definition flecs.h:1250
ecs_iter_private_t priv_
Private data.
Definition flecs.h:1245
ecs_world_t * world
The world.
Definition flecs.h:1192
void * callback_ctx
Callback language binding context.
Definition flecs.h:1232
ecs_entity_t * sources
Entity on which the ID was matched (0 if same as entities).
Definition flecs.h:1206
void * binding_ctx
System binding context.
Definition flecs.h:1231
ecs_flags32_t row_fields
Fields that must be obtained with field_at.
Definition flecs.h:1212
float delta_system_time
Time elapsed since last system invocation.
Definition flecs.h:1237
const ecs_query_t * query
Query being evaluated.
Definition flecs.h:1226
int8_t term_index
Index of the term that emitted an event.
Definition flecs.h:1223
ecs_entity_t system
The system (if applicable).
Definition flecs.h:1216
ecs_flags32_t set_fields
Fields that are set.
Definition flecs.h:1210
const ecs_size_t * sizes
Component sizes.
Definition flecs.h:1202
float delta_time
Time elapsed since last frame.
Definition flecs.h:1236
ecs_flags32_t up_fields
Bitset with fields matched through up traversal.
Definition flecs.h:1213
ecs_iter_action_t callback
Callback of system or observer.
Definition flecs.h:1249
int8_t field_count
Number of fields in the iterator.
Definition flecs.h:1222
ecs_table_t * other_table
Previous or next table when adding or removing.
Definition flecs.h:1204
int32_t event_cur
Unique event ID.
Definition flecs.h:1219
const ecs_table_record_t ** trs
Info on where to find the field in the table.
Definition flecs.h:1200
int32_t count
Number of entities to iterate.
Definition flecs.h:1197
void ** ptrs
Component pointers.
Definition flecs.h:1199
ecs_iter_next_action_t next
Function to progress iterator.
Definition flecs.h:1248
const ecs_entity_t * entities
Entity identifiers.
Definition flecs.h:1198
ecs_id_t * ids
(Component) IDs.
Definition flecs.h:1205
ecs_flags64_t constrained_vars
Bitset that marks constrained variables.
Definition flecs.h:1208
Used with ecs_observer_init().
Definition flecs.h:1397
ecs_ctx_free_t run_ctx_free
Callback to free run ctx.
Definition flecs.h:1446
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1434
void * run_ctx
Context associated with run (for language bindings).
Definition flecs.h:1443
ecs_entity_t entity
Existing entity to associate with an observer (optional).
Definition flecs.h:1402
int32_t * last_event_id
Used for internal purposes.
Definition flecs.h:1449
void * callback_ctx
Context associated with callback (for language bindings).
Definition flecs.h:1437
void * ctx
User context to pass to callback.
Definition flecs.h:1431
ecs_query_desc_t query
Query for observer.
Definition flecs.h:1405
ecs_flags32_t flags_
Used for internal purposes.
Definition flecs.h:1451
ecs_ctx_free_t callback_ctx_free
Callback to free callback ctx.
Definition flecs.h:1440
int8_t term_index_
Used for internal purposes.
Definition flecs.h:1450
bool global_observer
Global observers are tied to the lifespan of the world.
Definition flecs.h:1417
ecs_iter_action_t callback
Callback to invoke on an event, invoked when the observer matches.
Definition flecs.h:1420
bool yield_existing
When an observer is created, generate events from existing data.
Definition flecs.h:1412
ecs_run_action_t run
Callback invoked on an event.
Definition flecs.h:1428
ecs_entity_t events[8]
Events to observe (OnAdd, OnRemove, OnSet).
Definition flecs.h:1408
int32_t _canary
Used for validity testing.
Definition flecs.h:1399
An observer reacts to events matching a query.
Definition flecs.h:901
int32_t event_count
Number of events.
Definition flecs.h:908
ecs_iter_action_t callback
See ecs_observer_desc_t::callback.
Definition flecs.h:910
ecs_entity_t entity
Entity associated with the observer.
Definition flecs.h:924
ecs_observable_t * observable
Observable for the observer.
Definition flecs.h:921
ecs_run_action_t run
See ecs_observer_desc_t::run.
Definition flecs.h:911
ecs_header_t hdr
Object header.
Definition flecs.h:902
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:917
ecs_entity_t events[8]
Observer events.
Definition flecs.h:907
void * run_ctx
Run language binding context.
Definition flecs.h:915
ecs_world_t * world
The world.
Definition flecs.h:923
ecs_ctx_free_t run_ctx_free
Callback to free run_ctx.
Definition flecs.h:919
void * callback_ctx
Callback language binding context.
Definition flecs.h:914
void * ctx
Observer context.
Definition flecs.h:913
ecs_ctx_free_t callback_ctx_free
Callback to free callback_ctx.
Definition flecs.h:918
ecs_query_t * query
Observer query.
Definition flecs.h:904
Payload for EcsOnQueryCacheRevalidate event.
Definition flecs.h:4835
ecs_entity_t query
Query for which to revalidate table.
Definition flecs.h:4836
uint64_t table_id
Id of table to revalidate.
Definition flecs.h:4837
Struct returned by ecs_query_count().
Definition flecs.h:5051
int32_t entities
Number of entities returned by the query.
Definition flecs.h:5053
int32_t results
Number of results returned by the query.
Definition flecs.h:5052
int32_t tables
Number of tables returned by the query.
Definition flecs.h:5054
Used with ecs_query_init().
Definition flecs.h:1323
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1384
ecs_id_t group_by
Component ID to be used for grouping.
Definition flecs.h:1354
ecs_term_t terms[32]
Query terms.
Definition flecs.h:1328
int32_t _canary
Used for validity testing.
Definition flecs.h:1325
void * ctx
User context to pass to callback.
Definition flecs.h:1378
ecs_ctx_free_t group_by_ctx_free
Function to free group_by_ctx.
Definition flecs.h:1375
void * group_by_ctx
Context to pass to group_by.
Definition flecs.h:1372
void * binding_ctx
Context to be used for language bindings.
Definition flecs.h:1381
ecs_entity_t order_by
Component to sort on, used together with order_by_callback or order_by_table_callback.
Definition flecs.h:1350
ecs_order_by_action_t order_by_callback
Callback used for ordering query results.
Definition flecs.h:1342
ecs_group_create_action_t on_group_create
Callback that is invoked when a new group is created.
Definition flecs.h:1365
ecs_entity_t entity
Entity associated with query (optional).
Definition flecs.h:1390
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition flecs.h:1387
ecs_group_by_action_t group_by_callback
Callback used for grouping results.
Definition flecs.h:1361
ecs_group_delete_action_t on_group_delete
Callback that is invoked when an existing group is deleted.
Definition flecs.h:1369
ecs_sort_table_action_t order_by_table_callback
Callback used for ordering query results.
Definition flecs.h:1346
ecs_flags32_t flags
Flags for enabling query features.
Definition flecs.h:1337
ecs_query_cache_kind_t cache_kind
Caching policy of the query.
Definition flecs.h:1334
const char * expr
Query DSL expression (optional).
Definition flecs.h:1331
Type that contains information about a query group.
Definition flecs.h:1592
int32_t table_count
Number of tables in group.
Definition flecs.h:1595
void * ctx
Group context, returned by on_group_create.
Definition flecs.h:1596
uint64_t id
Group ID.
Definition flecs.h:1593
int32_t match_count
How often tables have been matched or unmatched.
Definition flecs.h:1594
Queries are lists of constraints (terms) that match entities.
Definition flecs.h:856
ecs_flags32_t row_fields
Fields that must be acquired with field_at.
Definition flecs.h:878
ecs_flags32_t data_fields
Fields that have data.
Definition flecs.h:875
ecs_flags32_t read_fields
Fields that read data.
Definition flecs.h:877
ecs_header_t hdr
Object header.
Definition flecs.h:857
int8_t var_count
Number of query variables.
Definition flecs.h:866
ecs_flags32_t fixed_fields
Bitmasks for quick field information lookups.
Definition flecs.h:872
ecs_flags32_t var_fields
Fields with non-$this variable source.
Definition flecs.h:873
ecs_flags32_t write_fields
Fields that write data.
Definition flecs.h:876
int32_t eval_count
Number of times the query is evaluated.
Definition flecs.h:895
ecs_world_t * world
World or stage the query was created with.
Definition flecs.h:893
ecs_flags32_t static_id_fields
Fields with a static (component) id.
Definition flecs.h:874
uint64_t bloom_filter
Bitmask used to quickly discard tables.
Definition flecs.h:863
ecs_world_t * real_world
Actual world.
Definition flecs.h:892
ecs_flags32_t set_fields
Fields that will be set.
Definition flecs.h:880
ecs_entity_t entity
Entity associated with query (optional).
Definition flecs.h:891
void * ctx
User context to pass to callback.
Definition flecs.h:888
int32_t * sizes
Component sizes.
Definition flecs.h:860
ecs_id_t * ids
Component ids.
Definition flecs.h:861
ecs_flags32_t shared_readonly_fields
Fields that don't write shared data.
Definition flecs.h:879
ecs_term_t * terms
Query terms.
Definition flecs.h:859
ecs_query_cache_kind_t cache_kind
Caching policy of the query.
Definition flecs.h:882
int8_t term_count
Number of query terms.
Definition flecs.h:868
char ** vars
Array with variable names for the iterator.
Definition flecs.h:885
int8_t field_count
Number of fields returned by the query.
Definition flecs.h:869
ecs_flags32_t flags
Query flags.
Definition flecs.h:864
void * binding_ctx
Context to be used for language bindings.
Definition flecs.h:889
Type that describes a reference to an entity or variable in a term.
Definition flecs.h:817
const char * name
Name.
Definition flecs.h:824
ecs_entity_t id
Entity ID.
Definition flecs.h:818
Type that describes a term (single element in a query).
Definition flecs.h:832
ecs_term_ref_t src
Source of term.
Definition flecs.h:838
int8_t field_index
Index of the field for the term in the iterator.
Definition flecs.h:849
ecs_id_t id
Component ID to be matched by term.
Definition flecs.h:833
int16_t oper
Operator of term.
Definition flecs.h:847
ecs_term_ref_t second
Second element of pair.
Definition flecs.h:840
ecs_flags16_t flags_
Flags that help evaluation, set by ecs_query_init().
Definition flecs.h:850
ecs_entity_t trav
Relationship to traverse when looking for the component.
Definition flecs.h:842
int16_t inout
Access to contents matched by term.
Definition flecs.h:846
ecs_term_ref_t first
Component or first element of pair.
Definition flecs.h:839
Component with data to instantiate a non-fragmenting tree.
Definition flecs.h:1634
uint32_t child
Prefab child entity (without generation).
Definition flecs.h:1637
int32_t parent_index
Index into the children vector.
Definition flecs.h:1638
const char * child_name
Name of the prefab child.
Definition flecs.h:1635
ecs_table_t * table
Table in which the child will be stored.
Definition flecs.h:1636
Tree spawner data for a single hierarchy depth.
Definition flecs.h:1642
ecs_vec_t children
vector<ecs_tree_spawner_child_t>.
Definition flecs.h:1643
ecs_copy_t copy_ctor
Ctor + copy.
Definition flecs.h:983
void * lifecycle_ctx
Component lifecycle context (see meta addon).
Definition flecs.h:1039
void * ctx
User-defined context.
Definition flecs.h:1037
ecs_iter_action_t on_remove
Callback that is invoked when an instance of the component is removed.
Definition flecs.h:1024
void * binding_ctx
Language binding context.
Definition flecs.h:1038
ecs_move_t move_dtor
Move + dtor.
Definition flecs.h:998
ecs_flags32_t flags
Hook flags.
Definition flecs.h:1010
ecs_cmp_t cmp
Compare hook.
Definition flecs.h:1001
ecs_copy_t copy
copy assignment.
Definition flecs.h:979
ecs_ctx_free_t lifecycle_ctx_free
Callback to free lifecycle_ctx.
Definition flecs.h:1043
ecs_on_validate_t on_validate
Callback that is invoked before the on_set/OnSet hooks and observers are invoked.
Definition flecs.h:1035
ecs_iter_action_t on_set
Callback that is invoked when an instance of the component is set.
Definition flecs.h:1019
ecs_move_t move
move assignment.
Definition flecs.h:980
ecs_xtor_t ctor
ctor.
Definition flecs.h:977
ecs_iter_action_t on_replace
Callback that is invoked with the existing and new value before the value is assigned.
Definition flecs.h:1030
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1041
ecs_iter_action_t on_add
Callback that is invoked when an instance of a component is added.
Definition flecs.h:1014
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition flecs.h:1042
ecs_move_t move_ctor
Ctor + move.
Definition flecs.h:986
ecs_equals_t equals
Equals hook.
Definition flecs.h:1004
ecs_move_t ctor_move_dtor
Ctor + move + dtor (or move_ctor + dtor).
Definition flecs.h:992
ecs_xtor_t dtor
dtor.
Definition flecs.h:978
Type that contains component information (passed to ctors/dtors/...).
Definition flecs.h:1050
ecs_size_t alignment
Alignment of the type.
Definition flecs.h:1052
ecs_size_t size
Size of the type.
Definition flecs.h:1051
const char * name
Type name.
Definition flecs.h:1055
ecs_entity_t component
Handle to component (do not set).
Definition flecs.h:1054
ecs_type_hooks_t hooks
Type hooks.
Definition flecs.h:1053
int32_t refcount
Refcount (do not set).
Definition flecs.h:1056
A type is a list of (component) IDs.
Definition flecs.h:410
ecs_id_t * array
Array with IDs.
Definition flecs.h:411
int32_t count
Number of elements in array.
Definition flecs.h:412
Value of a dynamic type.
Definition flecs.h:1066
void * ptr
Pointer to value.
Definition flecs.h:1068
ecs_entity_t type
Type of value.
Definition flecs.h:1067
Type that contains information about the world.
Definition flecs.h:1532
int64_t observers_ran_total
Total number of times an observer was invoked.
Definition flecs.h:1558
float delta_time
Time passed to or computed by ecs_progress().
Definition flecs.h:1536
int64_t systems_ran_total
Total number of systems run.
Definition flecs.h:1557
int64_t set_count
Set commands processed.
Definition flecs.h:1575
double world_time_total
Time elapsed in simulation.
Definition flecs.h:1544
int32_t tag_id_count
Number of tag (no data) IDs in the world.
Definition flecs.h:1561
int32_t component_id_count
Number of component (data) IDs in the world.
Definition flecs.h:1562
int64_t pipeline_build_count_total
Total number of pipeline builds.
Definition flecs.h:1556
int64_t eval_comp_monitors_total
Total number of monitor evaluations.
Definition flecs.h:1549
int32_t table_count
Number of tables.
Definition flecs.h:1565
float delta_time_raw
Raw delta time (no time scaling).
Definition flecs.h:1535
float frame_time_total
Total time spent processing a frame.
Definition flecs.h:1539
int64_t table_create_total
Total number of times a table was created.
Definition flecs.h:1554
float system_time_total
Total time spent in systems.
Definition flecs.h:1540
int64_t id_delete_total
Total number of times an ID was deleted.
Definition flecs.h:1553
float merge_time_total
Total time spent in merges.
Definition flecs.h:1542
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:1578
int64_t clear_count
Clear commands processed.
Definition flecs.h:1574
ecs_entity_t last_component_id
Last issued component entity ID.
Definition flecs.h:1533
int64_t frame_count_total
Total number of frames.
Definition flecs.h:1547
int64_t merge_count_total
Total number of merges.
Definition flecs.h:1548
int64_t other_count
Other commands processed.
Definition flecs.h:1580
int64_t batched_command_count
Commands batched.
Definition flecs.h:1582
int64_t table_delete_total
Total number of times a table was deleted.
Definition flecs.h:1555
int64_t queries_ran_total
Total number of times a query was evaluated.
Definition flecs.h:1559
int64_t delete_count
Delete commands processed.
Definition flecs.h:1573
int64_t rematch_count_total
Total number of rematches.
Definition flecs.h:1550
int64_t id_create_total
Total number of times a new ID was created.
Definition flecs.h:1552
int64_t batched_entity_count
Entities for which commands were batched.
Definition flecs.h:1581
float time_scale
Time scale applied to delta_time.
Definition flecs.h:1537
int32_t pair_id_count
Number of pair IDs in the world.
Definition flecs.h:1563
float rematch_time_total
Time spent on query rematching.
Definition flecs.h:1543
int64_t ensure_count
Ensure or emplace commands processed.
Definition flecs.h:1576
float target_fps
Target FPS.
Definition flecs.h:1538
double world_time_total_raw
Time elapsed in simulation (no scaling).
Definition flecs.h:1545
float emit_time_total
Total time spent notifying observers.
Definition flecs.h:1541
uint32_t creation_time
Time when world was created.
Definition flecs.h:1567
int64_t modified_count
Modified commands processed.
Definition flecs.h:1577
const char * name_prefix
Value set by ecs_set_name_prefix().
Definition flecs.h:1585
int64_t event_count
Enqueued custom events.
Definition flecs.h:1579
int64_t add_count
Add commands processed.
Definition flecs.h:1571
int64_t remove_count
Remove commands processed.
Definition flecs.h:1572