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 4
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#endif
116
117/* Tip: if you see weird behavior that you think might be a bug, make sure to
118 * test with the FLECS_DEBUG or FLECS_SANITIZE flags enabled. There's a good
119 * chance that this gives you more information about the issue! */
120
134// #define FLECS_SOFT_ASSERT
135
141// #define FLECS_KEEP_ASSERT
142
149// #define FLECS_DEFAULT_TO_UNCACHED_QUERIES
150
163// #define FLECS_CREATE_MEMBER_ENTITIES
164
173// #define FLECS_CPP_NO_AUTO_REGISTRATION
174
182// #define FLECS_CPP_NO_ENUM_REFLECTION
183
188// #define FLECS_NO_ALWAYS_INLINE
189
217// #define FLECS_CUSTOM_BUILD
218
219#ifndef FLECS_CUSTOM_BUILD
220#define FLECS_ALERTS
221#define FLECS_APP
222// #define FLECS_C /**< C API convenience macros, always enabled */
223#define FLECS_CPP
224#define FLECS_DOC
225// #define FLECS_JOURNAL /**< Journaling addon */
226#define FLECS_JSON
227#define FLECS_HTTP
228#define FLECS_LOG
229#define FLECS_META
230#define FLECS_METRICS
231#define FLECS_MODULE
232#define FLECS_OS_API_IMPL
233// #define FLECS_PERF_TRACE /**< Enable performance tracing */
234#define FLECS_PIPELINE
235#define FLECS_REST
236#define FLECS_PARSER
237#define FLECS_QUERY_DSL
238#define FLECS_SCRIPT
239// #define FLECS_SCRIPT_MATH /**< Math functions for flecs script (may require linking with libm) */
240#define FLECS_SYSTEM
241#define FLECS_STATS
242#define FLECS_TIMER
243#define FLECS_UNITS
244#endif // ifndef FLECS_CUSTOM_BUILD
245
249// #define FLECS_LOW_FOOTPRINT
250#ifdef FLECS_LOW_FOOTPRINT
251#define FLECS_HI_COMPONENT_ID 16
252#define FLECS_HI_ID_RECORD_ID 16
253#define FLECS_ENTITY_PAGE_BITS 6
254#define FLECS_USE_OS_ALLOC
255#define FLECS_DEFAULT_TO_UNCACHED_QUERIES
256#endif
257
272#ifndef FLECS_HI_COMPONENT_ID
273#define FLECS_HI_COMPONENT_ID 256
274#endif
275
282#ifndef FLECS_HI_ID_RECORD_ID
283#define FLECS_HI_ID_RECORD_ID 1024
284#endif
285
291#ifndef FLECS_SPARSE_PAGE_BITS
292#define FLECS_SPARSE_PAGE_BITS 6
293#endif
294
297#ifndef FLECS_ENTITY_PAGE_BITS
298#define FLECS_ENTITY_PAGE_BITS 10
299#endif
300
305// #define FLECS_USE_OS_ALLOC
306
309#ifndef FLECS_ID_DESC_MAX
310#define FLECS_ID_DESC_MAX 32
311#endif
312
315#ifndef FLECS_EVENT_DESC_MAX
316#define FLECS_EVENT_DESC_MAX 8
317#endif
318
321#define FLECS_VARIABLE_COUNT_MAX 64
322
325#ifndef FLECS_TERM_COUNT_MAX
326#define FLECS_TERM_COUNT_MAX 32
327#endif
328
331#ifndef FLECS_TERM_ARG_COUNT_MAX
332#define FLECS_TERM_ARG_COUNT_MAX 16
333#endif
334
337#ifndef FLECS_QUERY_VARIABLE_COUNT_MAX
338#define FLECS_QUERY_VARIABLE_COUNT_MAX 64
339#endif
340
343#ifndef FLECS_QUERY_SCOPE_NESTING_MAX
344#define FLECS_QUERY_SCOPE_NESTING_MAX 8
345#endif
346
351#ifndef FLECS_DAG_DEPTH_MAX
352#define FLECS_DAG_DEPTH_MAX 128
353#endif
354
359#define FLECS_TREE_SPAWNER_DEPTH_CACHE_SIZE (6)
360
363#include "flecs/private/api_defines.h"
364
374typedef uint64_t ecs_id_t;
375
382
398typedef struct {
400 int32_t count;
401} ecs_type_t;
402
426
429
432
434typedef struct ecs_term_t ecs_term_t;
435
438
457
462
467typedef struct ecs_iter_t ecs_iter_t;
468
477typedef struct ecs_ref_t ecs_ref_t;
478
483
488
491
494
514typedef void ecs_poly_t;
515
518
525
526typedef struct ecs_table_record_t ecs_table_record_t;
527
530#include "flecs/datastructures/vec.h" /* Vector datatype */
531#include "flecs/datastructures/sparse.h" /* Sparse set */
532#include "flecs/datastructures/block_allocator.h" /* Block allocator */
533#include "flecs/datastructures/stack_allocator.h" /* Stack allocator */
534#include "flecs/datastructures/map.h" /* Map */
535#include "flecs/datastructures/allocator.h" /* Allocator */
536#include "flecs/datastructures/strbuf.h" /* String builder */
537#include "flecs/os_api.h" /* Abstraction for operating system functions */
538
539#ifdef __cplusplus
540extern "C" {
541#endif
542
567typedef void (*ecs_run_action_t)(
568 ecs_iter_t *it);
569
576typedef void (*ecs_iter_action_t)(
577 ecs_iter_t *it);
578
587 ecs_iter_t *it);
588
595 ecs_iter_t *it);
596
599 ecs_entity_t e1,
600 const void *ptr1,
601 ecs_entity_t e2,
602 const void *ptr2);
603
606 ecs_world_t* world,
607 ecs_table_t* table,
608 ecs_entity_t* entities,
609 void* ptr,
610 int32_t size,
611 int32_t lo,
612 int32_t hi,
613 ecs_order_by_action_t order_by);
614
616typedef uint64_t (*ecs_group_by_action_t)(
617 ecs_world_t *world,
618 ecs_table_t *table,
619 ecs_id_t group_id,
620 void *ctx);
621
623typedef void* (*ecs_group_create_action_t)(
624 ecs_world_t *world,
625 uint64_t group_id,
626 void *group_by_ctx); /* from ecs_query_desc_t */
627
630 ecs_world_t *world,
631 uint64_t group_id,
632 void *group_ctx, /* return value from ecs_group_create_action_t */
633 void *group_by_ctx); /* from ecs_query_desc_t */
634
636typedef void (*ecs_module_action_t)(
637 ecs_world_t *world);
638
640typedef void (*ecs_fini_action_t)(
641 ecs_world_t *world,
642 void *ctx);
643
645typedef void (*ecs_ctx_free_t)(
646 void *ctx);
647
649typedef int (*ecs_compare_action_t)(
650 const void *ptr1,
651 const void *ptr2);
652
654typedef uint64_t (*ecs_hash_value_action_t)(
655 const void *ptr);
656
658typedef void (*ecs_xtor_t)(
659 void *ptr,
660 int32_t count,
661 const ecs_type_info_t *type_info);
662
664typedef void (*ecs_copy_t)(
665 void *dst_ptr,
666 const void *src_ptr,
667 int32_t count,
668 const ecs_type_info_t *type_info);
669
671typedef void (*ecs_move_t)(
672 void *dst_ptr,
673 void *src_ptr,
674 int32_t count,
675 const ecs_type_info_t *type_info);
676
678typedef int (*ecs_cmp_t)(
679 const void *a_ptr,
680 const void *b_ptr,
681 const ecs_type_info_t *type_info);
682
684typedef bool (*ecs_equals_t)(
685 const void *a_ptr,
686 const void *b_ptr,
687 const ecs_type_info_t *type_info);
688
690typedef void (*flecs_poly_dtor_t)(
691 ecs_poly_t *poly);
692
711
722
730
731/* Term id flags */
732
737#define EcsSelf (1llu << 63)
738
743#define EcsUp (1llu << 62)
744
749#define EcsTrav (1llu << 61)
750
755#define EcsCascade (1llu << 60)
756
761#define EcsDesc (1llu << 59)
762
767#define EcsIsVariable (1llu << 58)
768
773#define EcsIsEntity (1llu << 57)
774
779#define EcsIsName (1llu << 56)
780
785#define EcsTraverseFlags (EcsSelf|EcsUp|EcsTrav|EcsCascade|EcsDesc)
786
791#define EcsTermRefFlags (EcsTraverseFlags|EcsIsVariable|EcsIsEntity|EcsIsName)
792
807
829
837 int32_t *sizes;
840 uint64_t bloom_filter;
841 ecs_flags32_t flags;
842 int8_t var_count;
843 int8_t term_count;
844 int8_t field_count;
846 /* Bitmasks for quick field information lookups */
847 ecs_termset_t fixed_fields;
848 ecs_termset_t var_fields;
849 ecs_termset_t static_id_fields;
850 ecs_termset_t data_fields;
851 ecs_termset_t write_fields;
852 ecs_termset_t read_fields;
853 ecs_termset_t row_fields;
855 ecs_termset_t set_fields;
859 char **vars;
861 void *ctx;
868 int32_t eval_count;
869};
870
899
907/* Flags that can be used to check which hooks a type has set */
908#define ECS_TYPE_HOOK_CTOR ECS_CAST(ecs_flags32_t, 1 << 0)
909#define ECS_TYPE_HOOK_DTOR ECS_CAST(ecs_flags32_t, 1 << 1)
910#define ECS_TYPE_HOOK_COPY ECS_CAST(ecs_flags32_t, 1 << 2)
911#define ECS_TYPE_HOOK_MOVE ECS_CAST(ecs_flags32_t, 1 << 3)
912#define ECS_TYPE_HOOK_COPY_CTOR ECS_CAST(ecs_flags32_t, 1 << 4)
913#define ECS_TYPE_HOOK_MOVE_CTOR ECS_CAST(ecs_flags32_t, 1 << 5)
914#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 6)
915#define ECS_TYPE_HOOK_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 7)
916#define ECS_TYPE_HOOK_CMP ECS_CAST(ecs_flags32_t, 1 << 8)
917#define ECS_TYPE_HOOK_EQUALS ECS_CAST(ecs_flags32_t, 1 << 9)
918
919
920/* Flags that can be used to set/check which hooks of a type are invalid */
921#define ECS_TYPE_HOOK_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 10)
922#define ECS_TYPE_HOOK_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 12)
923#define ECS_TYPE_HOOK_COPY_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 13)
924#define ECS_TYPE_HOOK_MOVE_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 14)
925#define ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 15)
926#define ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 16)
927#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 17)
928#define ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 18)
929#define ECS_TYPE_HOOK_CMP_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 19)
930#define ECS_TYPE_HOOK_EQUALS_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 20)
931
932
933/* All valid hook flags */
934#define ECS_TYPE_HOOKS (ECS_TYPE_HOOK_CTOR|ECS_TYPE_HOOK_DTOR|\
935 ECS_TYPE_HOOK_COPY|ECS_TYPE_HOOK_MOVE|ECS_TYPE_HOOK_COPY_CTOR|\
936 ECS_TYPE_HOOK_MOVE_CTOR|ECS_TYPE_HOOK_CTOR_MOVE_DTOR|\
937 ECS_TYPE_HOOK_MOVE_DTOR|ECS_TYPE_HOOK_CMP|ECS_TYPE_HOOK_EQUALS)
938
939/* All invalid hook flags */
940#define ECS_TYPE_HOOKS_ILLEGAL (ECS_TYPE_HOOK_CTOR_ILLEGAL|\
941 ECS_TYPE_HOOK_DTOR_ILLEGAL|ECS_TYPE_HOOK_COPY_ILLEGAL|\
942 ECS_TYPE_HOOK_MOVE_ILLEGAL|ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL|\
943 ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL|ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL|\
944 ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL|ECS_TYPE_HOOK_CMP_ILLEGAL|\
945 ECS_TYPE_HOOK_EQUALS_ILLEGAL)
1010
1022
1023#include "flecs/private/api_types.h" /* Supporting API types */
1024#include "flecs/private/api_support.h" /* Supporting API functions */
1025#include "flecs/datastructures/hashmap.h" /* Hashmap */
1026#include "flecs/private/api_internals.h" /* Supporting API functions */
1027
1033
1038typedef struct ecs_entity_desc_t {
1039 int32_t _canary;
1045 const char *name;
1050 const char *sep;
1054 const char *root_sep;
1056 const char *symbol;
1072
1075
1077 const char *add_expr;
1079
1109
1123
1163 /* World */
1167 /* Matched data */
1168 int32_t offset;
1169 int32_t count;
1171 void **ptrs;
1172 const ecs_table_record_t **trs;
1173 const ecs_size_t *sizes;
1178 ecs_flags64_t constrained_vars;
1179 ecs_termset_t set_fields;
1180 ecs_termset_t ref_fields;
1181 ecs_termset_t row_fields;
1182 ecs_termset_t up_fields;
1184 /* Input information */
1188 int32_t event_cur;
1190 /* Query information */
1192 int8_t term_index;
1197 /* Context */
1198 void *param;
1199 void *ctx;
1202 void *run_ctx;
1204 /* Time */
1208 /* Iterator counters */
1211 /* Misc */
1212 ecs_flags32_t flags;
1214 ecs_iter_private_t priv_;
1216 /* Chained iterators */
1221};
1222
1223
1228#define EcsQueryMatchPrefab (1u << 1u)
1229
1234#define EcsQueryMatchDisabled (1u << 2u)
1235
1240#define EcsQueryMatchEmptyTables (1u << 3u)
1241
1246#define EcsQueryAllowUnresolvedByName (1u << 6u)
1247
1252#define EcsQueryTableOnly (1u << 7u)
1253
1264#define EcsQueryDetectChanges (1u << 8u)
1265
1266
1340
1401
1406typedef struct ecs_event_desc_t {
1409
1414
1417
1421
1423 int32_t offset;
1424
1428 int32_t count;
1429
1432
1437 void *param;
1438
1442 const void *const_param;
1443
1446
1448 ecs_flags32_t flags;
1450
1451
1460typedef struct ecs_build_info_t {
1461 const char *compiler;
1462 const char **addons;
1463 const char **flags;
1464 const char *version;
1468 bool debug;
1472
1534
1537 uint64_t id;
1538 int32_t match_count;
1539 int32_t table_count;
1540 void *ctx;
1542
1553typedef struct EcsIdentifier {
1554 char *value;
1555 ecs_size_t length;
1556 uint64_t hash;
1557 uint64_t index_hash;
1558 ecs_hashmap_t *index;
1560
1562typedef struct EcsComponent {
1563 ecs_size_t size;
1564 ecs_size_t alignment;
1566
1571
1580
1581/* Non-fragmenting ChildOf relationship. */
1582typedef struct EcsParent {
1583 ecs_entity_t value;
1584} EcsParent;
1585
1586/* Component with data to instantiate a non-fragmenting tree. */
1587typedef struct {
1588 const char *child_name; /* Name of prefab child */
1589 ecs_table_t *table; /* Table in which child will be stored */
1590 uint32_t child; /* Prefab child entity (without generation) */
1591 int32_t parent_index; /* Index into children vector */
1593
1594typedef struct {
1595 ecs_vec_t children; /* vector<ecs_tree_spawner_child_t> */
1597
1598typedef struct EcsTreeSpawner {
1599 /* Tree instantiation cache, indexed by depth. Tables will have a
1600 * (ParentDepth, depth) pair indicating the hierarchy depth. This means that
1601 * for different depths, the tables the children are created in will also be
1602 * different. Caching tables for different depths therefore speeds up
1603 * instantiating trees even when the top level entity is not at the root. */
1606
1610/* Only include deprecated definitions if deprecated addon is required */
1611#ifdef FLECS_DEPRECATED
1613#endif
1614
1630FLECS_API extern const ecs_id_t ECS_PAIR;
1631
1633FLECS_API extern const ecs_id_t ECS_AUTO_OVERRIDE;
1634
1636FLECS_API extern const ecs_id_t ECS_TOGGLE;
1637
1639FLECS_API extern const ecs_id_t ECS_VALUE_PAIR;
1640
1648/* Builtin component ids */
1649
1651FLECS_API extern const ecs_entity_t ecs_id(EcsComponent);
1652
1654FLECS_API extern const ecs_entity_t ecs_id(EcsIdentifier);
1655
1657FLECS_API extern const ecs_entity_t ecs_id(EcsPoly);
1658
1660FLECS_API extern const ecs_entity_t ecs_id(EcsParent);
1661
1663FLECS_API extern const ecs_entity_t ecs_id(EcsTreeSpawner);
1664
1666FLECS_API extern const ecs_entity_t ecs_id(EcsDefaultChildComponent);
1667
1669FLECS_API extern const ecs_entity_t EcsParentDepth;
1670
1672FLECS_API extern const ecs_entity_t EcsQuery;
1673
1675FLECS_API extern const ecs_entity_t EcsObserver;
1676
1678FLECS_API extern const ecs_entity_t EcsSystem;
1679
1681FLECS_API extern const ecs_entity_t ecs_id(EcsTickSource);
1682
1684FLECS_API extern const ecs_entity_t ecs_id(EcsPipelineQuery);
1685
1687FLECS_API extern const ecs_entity_t ecs_id(EcsTimer);
1688
1690FLECS_API extern const ecs_entity_t ecs_id(EcsRateFilter);
1691
1693FLECS_API extern const ecs_entity_t EcsFlecs;
1694
1696FLECS_API extern const ecs_entity_t EcsFlecsCore;
1697
1699FLECS_API extern const ecs_entity_t EcsWorld;
1700
1702FLECS_API extern const ecs_entity_t EcsWildcard;
1703
1705FLECS_API extern const ecs_entity_t EcsAny;
1706
1708FLECS_API extern const ecs_entity_t EcsThis;
1709
1711FLECS_API extern const ecs_entity_t EcsVariable;
1712
1720FLECS_API extern const ecs_entity_t EcsTransitive;
1721
1729FLECS_API extern const ecs_entity_t EcsReflexive;
1730
1741FLECS_API extern const ecs_entity_t EcsFinal;
1742
1748FLECS_API extern const ecs_entity_t EcsInheritable;
1749
1751FLECS_API extern const ecs_entity_t EcsOnInstantiate;
1752
1756FLECS_API extern const ecs_entity_t EcsOverride;
1757
1761FLECS_API extern const ecs_entity_t EcsInherit;
1762
1767FLECS_API extern const ecs_entity_t EcsDontInherit;
1768
1776FLECS_API extern const ecs_entity_t EcsSymmetric;
1777
1787FLECS_API extern const ecs_entity_t EcsExclusive;
1788
1790FLECS_API extern const ecs_entity_t EcsAcyclic;
1791
1794FLECS_API extern const ecs_entity_t EcsTraversable;
1795
1805FLECS_API extern const ecs_entity_t EcsWith;
1806
1816FLECS_API extern const ecs_entity_t EcsOneOf;
1817
1819FLECS_API extern const ecs_entity_t EcsCanToggle;
1820
1824FLECS_API extern const ecs_entity_t EcsTrait;
1825
1835FLECS_API extern const ecs_entity_t EcsRelationship;
1836
1846FLECS_API extern const ecs_entity_t EcsTarget;
1847
1850FLECS_API extern const ecs_entity_t EcsPairIsTag;
1851
1853FLECS_API extern const ecs_entity_t EcsName;
1854
1856FLECS_API extern const ecs_entity_t EcsSymbol;
1857
1859FLECS_API extern const ecs_entity_t EcsAlias;
1860
1862FLECS_API extern const ecs_entity_t EcsChildOf;
1863
1865FLECS_API extern const ecs_entity_t EcsIsA;
1866
1868FLECS_API extern const ecs_entity_t EcsDependsOn;
1869
1871FLECS_API extern const ecs_entity_t EcsSlotOf;
1872
1874FLECS_API extern const ecs_entity_t EcsOrderedChildren;
1875
1877FLECS_API extern const ecs_entity_t EcsModule;
1878
1881FLECS_API extern const ecs_entity_t EcsPrefab;
1882
1885FLECS_API extern const ecs_entity_t EcsDisabled;
1886
1890FLECS_API extern const ecs_entity_t EcsNotQueryable;
1891
1893FLECS_API extern const ecs_entity_t EcsOnAdd;
1894
1896FLECS_API extern const ecs_entity_t EcsOnRemove;
1897
1899FLECS_API extern const ecs_entity_t EcsOnSet;
1900
1902FLECS_API extern const ecs_entity_t EcsMonitor;
1903
1905FLECS_API extern const ecs_entity_t EcsOnTableCreate;
1906
1908FLECS_API extern const ecs_entity_t EcsOnTableDelete;
1909
1911FLECS_API extern const ecs_entity_t EcsOnDelete;
1912
1915FLECS_API extern const ecs_entity_t EcsOnDeleteTarget;
1916
1919FLECS_API extern const ecs_entity_t EcsRemove;
1920
1923FLECS_API extern const ecs_entity_t EcsDelete;
1924
1927FLECS_API extern const ecs_entity_t EcsPanic;
1928
1931FLECS_API extern const ecs_entity_t EcsSingleton;
1932
1934FLECS_API extern const ecs_entity_t EcsSparse;
1935
1937FLECS_API extern const ecs_entity_t EcsDontFragment;
1938
1940FLECS_API extern const ecs_entity_t EcsPredEq;
1941
1943FLECS_API extern const ecs_entity_t EcsPredMatch;
1944
1946FLECS_API extern const ecs_entity_t EcsPredLookup;
1947
1949FLECS_API extern const ecs_entity_t EcsScopeOpen;
1950
1952FLECS_API extern const ecs_entity_t EcsScopeClose;
1953
1958FLECS_API extern const ecs_entity_t EcsEmpty;
1959
1960FLECS_API extern const ecs_entity_t ecs_id(EcsPipeline);
1961FLECS_API extern const ecs_entity_t EcsOnStart;
1962FLECS_API extern const ecs_entity_t EcsPreFrame;
1963FLECS_API extern const ecs_entity_t EcsOnLoad;
1964FLECS_API extern const ecs_entity_t EcsPostLoad;
1965FLECS_API extern const ecs_entity_t EcsPreUpdate;
1966FLECS_API extern const ecs_entity_t EcsOnUpdate;
1967FLECS_API extern const ecs_entity_t EcsOnValidate;
1968FLECS_API extern const ecs_entity_t EcsPostUpdate;
1969FLECS_API extern const ecs_entity_t EcsPreStore;
1970FLECS_API extern const ecs_entity_t EcsOnStore;
1971FLECS_API extern const ecs_entity_t EcsPostFrame;
1972FLECS_API extern const ecs_entity_t EcsPhase;
1974FLECS_API extern const ecs_entity_t EcsConstant;
1978#define EcsLastInternalComponentId (ecs_id(EcsTreeSpawner))
1979
1982#define EcsFirstUserComponentId (8)
1983
1986#define EcsFirstUserEntityId (FLECS_HI_COMPONENT_ID + 128)
1987
1988/* When visualized the reserved id ranges look like this:
1989 * - [1..8]: Builtin components
1990 * - [9..FLECS_HI_COMPONENT_ID]: Low ids reserved for application components
1991 * - [FLECS_HI_COMPONENT_ID + 1..EcsFirstUserEntityId]: Builtin entities
1992 */
1993
2015FLECS_API
2017
2024FLECS_API
2026
2034FLECS_API
2036 int argc,
2037 char *argv[]);
2038
2045FLECS_API
2047 ecs_world_t *world);
2048
2056FLECS_API
2058 const ecs_world_t *world);
2059
2067FLECS_API
2069 ecs_world_t *world,
2070 ecs_fini_action_t action,
2071 void *ctx);
2072
2079
2106FLECS_API
2108 const ecs_world_t *world);
2109
2117FLECS_API
2119 const ecs_world_t *world);
2120
2146FLECS_API
2148 ecs_world_t *world,
2149 ecs_ftime_t delta_time);
2150
2157FLECS_API
2159 ecs_world_t *world);
2160
2168FLECS_API
2170 ecs_world_t *world,
2171 ecs_fini_action_t action,
2172 void *ctx);
2173
2180FLECS_API
2182 ecs_world_t *world);
2183
2190FLECS_API
2192 const ecs_world_t *world);
2193
2206 ecs_world_t *world,
2207 bool enable);
2208
2220 ecs_world_t *world,
2221 bool enable);
2222
2238FLECS_API
2240 ecs_world_t *world,
2241 ecs_ftime_t fps);
2242
2256FLECS_API
2258 ecs_world_t *world,
2259 ecs_flags32_t flags);
2260
2337FLECS_API
2339 ecs_world_t *world,
2340 bool multi_threaded);
2341
2349FLECS_API
2351 ecs_world_t *world);
2352
2358FLECS_API
2360 ecs_world_t *stage);
2361
2378FLECS_API
2380 ecs_world_t *world);
2381
2395FLECS_API
2397 ecs_world_t *world);
2398
2413FLECS_API
2415 ecs_world_t *world);
2416
2427FLECS_API
2429 ecs_world_t *world);
2430
2442FLECS_API
2444 const ecs_world_t *world);
2445
2457FLECS_API
2459 const ecs_world_t *world);
2460
2474FLECS_API
2476 ecs_world_t *world,
2477 int32_t stages);
2478
2485FLECS_API
2487 const ecs_world_t *world);
2488
2504FLECS_API
2506 const ecs_world_t *world,
2507 int32_t stage_id);
2508
2516FLECS_API
2518 const ecs_world_t *world);
2519
2527FLECS_API
2529 ecs_world_t *world);
2530
2535FLECS_API
2537 ecs_world_t *stage);
2538
2546FLECS_API
2548 const ecs_world_t *world);
2549
2565FLECS_API
2567 ecs_world_t *world,
2568 void *ctx,
2569 ecs_ctx_free_t ctx_free);
2570
2579FLECS_API
2581 ecs_world_t *world,
2582 void *ctx,
2583 ecs_ctx_free_t ctx_free);
2584
2592FLECS_API
2594 const ecs_world_t *world);
2595
2603FLECS_API
2605 const ecs_world_t *world);
2606
2612FLECS_API
2614
2620FLECS_API
2622 const ecs_world_t *world);
2623
2632FLECS_API
2634 ecs_world_t *world,
2635 int32_t entity_count);
2636
2651FLECS_API
2653 ecs_world_t *world);
2654
2670FLECS_API
2672 ecs_world_t *world,
2673 ecs_entity_t id_start,
2674 ecs_entity_t id_end);
2675
2686FLECS_API
2688 ecs_world_t *world,
2689 bool enable);
2690
2696FLECS_API
2698 const ecs_world_t *world);
2699
2713FLECS_API
2715 ecs_world_t *world,
2716 ecs_flags32_t flags);
2717
2729
2759FLECS_API
2761 ecs_world_t *world,
2762 const ecs_delete_empty_tables_desc_t *desc);
2763
2769FLECS_API
2771 const ecs_poly_t *poly);
2772
2778FLECS_API
2780 const ecs_poly_t *poly);
2781
2795FLECS_API
2797 const ecs_poly_t *object,
2798 int32_t type);
2799
2803#define flecs_poly_is(object, type)\
2804 flecs_poly_is_(object, type##_magic)
2805
2814FLECS_API
2816 ecs_entity_t first,
2817 ecs_entity_t second);
2818
2841FLECS_API
2843 ecs_world_t *world,
2844 const char *thread_name);
2845
2868FLECS_API
2870 ecs_world_t *world,
2871 bool lock_world);
2872
2899FLECS_API
2901 ecs_world_t *world);
2902
2920FLECS_API
2922 ecs_world_t *world);
2923
2932FLECS_API
2934 ecs_world_t *world,
2935 ecs_id_t component);
2936
2944FLECS_API
2946 ecs_world_t *world,
2947 ecs_table_t *table);
2948
2967FLECS_API
2969 ecs_world_t *world,
2970 const ecs_entity_desc_t *desc);
2971
2998FLECS_API
3000 ecs_world_t *world,
3001 const ecs_bulk_desc_t *desc);
3002
3012FLECS_API
3014 ecs_world_t *world,
3015 ecs_id_t component,
3016 int32_t count);
3017
3033FLECS_API
3035 ecs_world_t *world,
3036 ecs_entity_t dst,
3037 ecs_entity_t src,
3038 bool copy_value);
3039
3048FLECS_API
3050 ecs_world_t *world,
3051 ecs_entity_t entity);
3052
3060FLECS_API
3062 ecs_world_t *world,
3063 ecs_id_t component);
3064
3082FLECS_API
3084 ecs_world_t *world,
3085 ecs_entity_t parent,
3086 const ecs_entity_t *children,
3087 int32_t child_count);
3088
3098FLECS_API
3100 const ecs_world_t *world,
3101 ecs_entity_t parent);
3102
3120FLECS_API
3122 ecs_world_t *world,
3123 ecs_entity_t entity,
3124 ecs_id_t component);
3125
3134FLECS_API
3136 ecs_world_t *world,
3137 ecs_entity_t entity,
3138 ecs_id_t component);
3139
3191FLECS_API
3193 ecs_world_t *world,
3194 ecs_entity_t entity,
3195 ecs_id_t component);
3196
3203FLECS_API
3205 ecs_world_t *world,
3206 ecs_entity_t entity);
3207
3215FLECS_API
3217 ecs_world_t *world,
3218 ecs_id_t component);
3219
3234FLECS_API
3236 ecs_world_t *world,
3237 ecs_id_t component);
3238
3246FLECS_API
3248 const ecs_world_t *world);
3249
3268FLECS_API
3270 ecs_world_t *world,
3271 ecs_entity_t entity,
3272 bool enabled);
3273
3287FLECS_API
3289 ecs_world_t *world,
3290 ecs_entity_t entity,
3291 ecs_id_t component,
3292 bool enable);
3293
3304FLECS_API
3306 const ecs_world_t *world,
3307 ecs_entity_t entity,
3308 ecs_id_t component);
3309
3333FLECS_API
3334FLECS_ALWAYS_INLINE const void* ecs_get_id(
3335 const ecs_world_t *world,
3336 ecs_entity_t entity,
3337 ecs_id_t component);
3338
3353FLECS_API
3354FLECS_ALWAYS_INLINE void* ecs_get_mut_id(
3355 const ecs_world_t *world,
3356 ecs_entity_t entity,
3357 ecs_id_t component);
3358
3375FLECS_API
3377 ecs_world_t *world,
3378 ecs_entity_t entity,
3379 ecs_id_t component,
3380 size_t size);
3381
3392FLECS_ALWAYS_INLINE FLECS_API
3394 const ecs_world_t *world,
3395 ecs_entity_t entity,
3396 ecs_id_t component);
3397
3408FLECS_ALWAYS_INLINE FLECS_API
3410 const ecs_world_t *world,
3411 ecs_ref_t *ref,
3412 ecs_id_t component);
3413
3421FLECS_ALWAYS_INLINE FLECS_API
3423 const ecs_world_t *world,
3424 ecs_ref_t *ref);
3425
3446FLECS_API
3448 ecs_world_t *world,
3449 ecs_entity_t entity,
3450 ecs_id_t component,
3451 size_t size,
3452 bool *is_new);
3453
3463FLECS_API
3465 ecs_world_t *world,
3466 ecs_entity_t entity,
3467 ecs_id_t component);
3468
3484FLECS_API
3486 ecs_world_t *world,
3487 ecs_entity_t entity,
3488 ecs_id_t component,
3489 size_t size,
3490 const void *ptr);
3491
3520FLECS_API
3522 const ecs_world_t *world,
3523 ecs_entity_t e);
3524
3554FLECS_API
3556 const ecs_world_t *world,
3557 ecs_entity_t e);
3558
3564FLECS_API
3566 ecs_entity_t e);
3567
3584FLECS_API
3586 const ecs_world_t *world,
3587 ecs_entity_t e);
3588
3611FLECS_API
3613 ecs_world_t *world,
3614 ecs_entity_t entity);
3615
3634FLECS_API
3636 ecs_world_t *world,
3637 ecs_id_t component);
3638
3646FLECS_API
3648 const ecs_world_t *world,
3649 ecs_entity_t entity);
3650
3665FLECS_API
3667 ecs_world_t *world,
3668 ecs_entity_t entity);
3669
3675FLECS_API
3677 ecs_entity_t entity);
3678
3694FLECS_API
3696 const ecs_world_t *world,
3697 ecs_entity_t entity);
3698
3705FLECS_API
3707 const ecs_world_t *world,
3708 ecs_entity_t entity);
3709
3717FLECS_API
3719 const ecs_world_t *world,
3720 const ecs_type_t* type);
3721
3733FLECS_API
3735 const ecs_world_t *world,
3736 const ecs_table_t *table);
3737
3752FLECS_API
3754 const ecs_world_t *world,
3755 ecs_entity_t entity);
3756
3767FLECS_API
3768FLECS_ALWAYS_INLINE bool ecs_has_id(
3769 const ecs_world_t *world,
3770 ecs_entity_t entity,
3771 ecs_id_t component);
3772
3783FLECS_API
3784FLECS_ALWAYS_INLINE bool ecs_owns_id(
3785 const ecs_world_t *world,
3786 ecs_entity_t entity,
3787 ecs_id_t component);
3788
3803FLECS_API
3805 const ecs_world_t *world,
3806 ecs_entity_t entity,
3807 ecs_entity_t rel,
3808 int32_t index);
3809
3823FLECS_API
3825 const ecs_world_t *world,
3826 ecs_entity_t entity);
3827
3841FLECS_API
3843 ecs_world_t *world,
3844 ecs_entity_t parent,
3845 const char *name);
3846
3867FLECS_API
3869 const ecs_world_t *world,
3870 ecs_entity_t entity,
3871 ecs_entity_t rel,
3872 ecs_id_t component);
3873
3884FLECS_API
3886 const ecs_world_t *world,
3887 ecs_entity_t entity,
3888 ecs_entity_t rel);
3889
3897FLECS_API
3899 const ecs_world_t *world,
3900 ecs_id_t entity);
3901
3921FLECS_API
3922const char* ecs_get_name(
3923 const ecs_world_t *world,
3924 ecs_entity_t entity);
3925
3935FLECS_API
3936const char* ecs_get_symbol(
3937 const ecs_world_t *world,
3938 ecs_entity_t entity);
3939
3953FLECS_API
3955 ecs_world_t *world,
3956 ecs_entity_t entity,
3957 const char *name);
3958
3972FLECS_API
3974 ecs_world_t *world,
3975 ecs_entity_t entity,
3976 const char *symbol);
3977
3989FLECS_API
3991 ecs_world_t *world,
3992 ecs_entity_t entity,
3993 const char *alias);
3994
4010FLECS_API
4012 const ecs_world_t *world,
4013 const char *path);
4014
4029FLECS_API
4031 const ecs_world_t *world,
4032 ecs_entity_t parent,
4033 const char *name);
4034
4057FLECS_API
4059 const ecs_world_t *world,
4060 ecs_entity_t parent,
4061 const char *path,
4062 const char *sep,
4063 const char *prefix,
4064 bool recursive);
4065
4083FLECS_API
4085 const ecs_world_t *world,
4086 const char *symbol,
4087 bool lookup_as_path,
4088 bool recursive);
4089
4111FLECS_API
4113 const ecs_world_t *world,
4114 ecs_entity_t parent,
4115 ecs_entity_t child,
4116 const char *sep,
4117 const char *prefix);
4118
4131FLECS_API
4133 const ecs_world_t *world,
4134 ecs_entity_t parent,
4135 ecs_entity_t child,
4136 const char *sep,
4137 const char *prefix,
4138 ecs_strbuf_t *buf,
4139 bool escape);
4140
4156FLECS_API
4158 ecs_world_t *world,
4159 ecs_entity_t parent,
4160 const char *path,
4161 const char *sep,
4162 const char *prefix);
4163
4178FLECS_API
4180 ecs_world_t *world,
4181 ecs_entity_t entity,
4182 ecs_entity_t parent,
4183 const char *path,
4184 const char *sep,
4185 const char *prefix);
4186
4200FLECS_API
4202 ecs_world_t *world,
4203 ecs_entity_t scope);
4204
4212FLECS_API
4214 const ecs_world_t *world);
4215
4225FLECS_API
4227 ecs_world_t *world,
4228 const char *prefix);
4229
4256FLECS_API
4258 ecs_world_t *world,
4259 const ecs_entity_t *lookup_path);
4260
4267FLECS_API
4269 const ecs_world_t *world);
4270
4295FLECS_API
4297 ecs_world_t *world,
4298 const ecs_component_desc_t *desc);
4299
4309FLECS_API
4311 const ecs_world_t *world,
4312 ecs_id_t component);
4313
4325FLECS_API
4327 ecs_world_t *world,
4328 ecs_entity_t component,
4329 const ecs_type_hooks_t *hooks);
4330
4337FLECS_API
4339 const ecs_world_t *world,
4340 ecs_entity_t component);
4341
4365FLECS_API
4367 const ecs_world_t *world,
4368 ecs_id_t component);
4369
4378FLECS_API
4380 const ecs_world_t *world,
4381 ecs_id_t component);
4382
4402FLECS_API
4404 const ecs_world_t *world,
4405 ecs_id_t component);
4406
4415FLECS_API
4417 ecs_id_t component,
4418 ecs_id_t pattern);
4419
4425FLECS_API
4427 ecs_id_t component);
4428
4434FLECS_API
4436 ecs_id_t component);
4437
4444 ecs_id_t component);
4445
4459FLECS_API
4461 const ecs_world_t *world,
4462 ecs_id_t component);
4463
4472FLECS_API
4473ecs_flags32_t ecs_id_get_flags(
4474 const ecs_world_t *world,
4475 ecs_id_t component);
4476
4487FLECS_API
4489 uint64_t component_flags);
4490
4506FLECS_API
4508 const ecs_world_t *world,
4509 ecs_id_t component);
4510
4518FLECS_API
4520 const ecs_world_t *world,
4521 ecs_id_t component,
4522 ecs_strbuf_t *buf);
4523
4531FLECS_API
4533 const ecs_world_t *world,
4534 const char *expr);
4535
4551FLECS_API
4553 const ecs_term_ref_t *ref);
4554
4566FLECS_API
4568 const ecs_term_t *term);
4569
4584FLECS_API
4586 const ecs_term_t *term);
4587
4600FLECS_API
4602 const ecs_term_t *term);
4603
4612FLECS_API
4614 const ecs_world_t *world,
4615 const ecs_term_t *term);
4616
4624FLECS_API
4626 const ecs_query_t *query);
4627
4668FLECS_API
4670 const ecs_world_t *world,
4671 ecs_id_t component);
4672
4678FLECS_API
4680 ecs_iter_t *it);
4681
4704FLECS_API
4705FLECS_ALWAYS_INLINE ecs_iter_t ecs_children(
4706 const ecs_world_t *world,
4707 ecs_entity_t parent);
4708
4716FLECS_API
4717FLECS_ALWAYS_INLINE ecs_iter_t ecs_children_w_rel(
4718 const ecs_world_t *world,
4719 ecs_entity_t relationship,
4720 ecs_entity_t parent);
4721
4727FLECS_API
4729 ecs_iter_t *it);
4730
4746FLECS_API
4748 ecs_world_t *world,
4749 const ecs_query_desc_t *desc);
4750
4755FLECS_API
4757 ecs_query_t *query);
4758
4767FLECS_API
4769 const ecs_query_t *query,
4770 const char *name);
4771
4779FLECS_API
4781 const ecs_query_t *query,
4782 int32_t var_id);
4783
4794FLECS_API
4796 const ecs_query_t *query,
4797 int32_t var_id);
4798
4867FLECS_API
4869 const ecs_world_t *world,
4870 const ecs_query_t *query);
4871
4879FLECS_API
4881 ecs_iter_t *it);
4882
4901FLECS_API
4903 const ecs_query_t *query,
4904 ecs_entity_t entity,
4905 ecs_iter_t *it);
4906
4925FLECS_API
4927 const ecs_query_t *query,
4928 ecs_table_t *table,
4929 ecs_iter_t *it);
4930
4957FLECS_API
4959 const ecs_query_t *query,
4960 ecs_table_range_t *range,
4961 ecs_iter_t *it);
4962
4970FLECS_API
4972 const ecs_query_t *query);
4973
4983FLECS_API
4985 const ecs_query_t *query);
4986
5001FLECS_API
5003 const ecs_query_t *query,
5004 const ecs_iter_t *it);
5005
5011FLECS_API
5013 const ecs_query_t *query);
5014
5032FLECS_API
5034 ecs_query_t *query,
5035 ecs_iter_t *it,
5036 const char *expr);
5037
5065FLECS_API
5067 ecs_query_t *query);
5068
5077FLECS_API
5079 const ecs_world_t *world,
5080 ecs_entity_t query);
5081
5092FLECS_API
5094 ecs_iter_t *it);
5095
5118FLECS_API
5120 ecs_iter_t *it,
5121 uint64_t group_id);
5122
5148FLECS_API
5149const ecs_map_t* ecs_query_get_groups(
5150 const ecs_query_t *query);
5151
5160FLECS_API
5162 const ecs_query_t *query,
5163 uint64_t group_id);
5164
5173FLECS_API
5175 const ecs_query_t *query,
5176 uint64_t group_id);
5177
5186
5193FLECS_API
5195 const ecs_query_t *query);
5196
5202FLECS_API
5204 const ecs_query_t *query);
5205
5214FLECS_API
5216 const ecs_query_t *query);
5217
5246FLECS_API
5248 ecs_world_t *world,
5249 ecs_event_desc_t *desc);
5250
5261FLECS_API
5263 ecs_world_t *world,
5264 ecs_event_desc_t *desc);
5265
5276FLECS_API
5278 ecs_world_t *world,
5279 const ecs_observer_desc_t *desc);
5280
5289FLECS_API
5291 const ecs_world_t *world,
5292 ecs_entity_t observer);
5293
5316FLECS_API
5318 ecs_iter_t *it);
5319
5329FLECS_API
5331 ecs_iter_t *it);
5332
5344FLECS_API
5346 ecs_iter_t *it);
5347
5360FLECS_API
5362 ecs_iter_t *it);
5363
5371FLECS_API
5373 ecs_iter_t *it);
5374
5413FLECS_API
5415 ecs_iter_t *it,
5416 int32_t var_id,
5417 ecs_entity_t entity);
5418
5429FLECS_API
5431 ecs_iter_t *it,
5432 int32_t var_id,
5433 const ecs_table_t *table);
5434
5445FLECS_API
5447 ecs_iter_t *it,
5448 int32_t var_id,
5449 const ecs_table_range_t *range);
5450
5463FLECS_API
5465 ecs_iter_t *it,
5466 int32_t var_id);
5467
5474FLECS_API
5476 const ecs_iter_t *it,
5477 int32_t var_id);
5478
5484FLECS_API
5486 const ecs_iter_t *it);
5487
5493FLECS_API
5495 const ecs_iter_t *it);
5496
5510FLECS_API
5512 ecs_iter_t *it,
5513 int32_t var_id);
5514
5528FLECS_API
5530 ecs_iter_t *it,
5531 int32_t var_id);
5532
5544FLECS_API
5546 ecs_iter_t *it,
5547 int32_t var_id);
5548
5560FLECS_API
5562 const ecs_iter_t *it);
5563
5575FLECS_API
5577 ecs_iter_t *it);
5578
5590FLECS_API
5592 const ecs_iter_t *it);
5593
5609FLECS_API
5611 const ecs_iter_t *it,
5612 int32_t offset,
5613 int32_t limit);
5614
5621FLECS_API
5623 ecs_iter_t *it);
5624
5645FLECS_API
5647 const ecs_iter_t *it,
5648 int32_t index,
5649 int32_t count);
5650
5657FLECS_API
5659 ecs_iter_t *it);
5660
5702FLECS_API
5704 const ecs_iter_t *it,
5705 size_t size,
5706 int8_t index);
5707
5729FLECS_API
5731 const ecs_iter_t *it,
5732 size_t size,
5733 int8_t index,
5734 int32_t row);
5735
5744FLECS_API
5746 const ecs_iter_t *it,
5747 int8_t index);
5748
5759FLECS_API
5761 const ecs_iter_t *it,
5762 int8_t index);
5763
5770FLECS_API
5772 const ecs_iter_t *it,
5773 int8_t index);
5774
5781FLECS_API
5783 const ecs_iter_t *it,
5784 int8_t index);
5785
5794FLECS_API
5796 const ecs_iter_t *it,
5797 int8_t index);
5798
5806FLECS_API
5808 const ecs_iter_t *it,
5809 int8_t index);
5810
5818FLECS_API
5820 const ecs_iter_t *it,
5821 int8_t index);
5822
5836FLECS_API
5838 const ecs_iter_t *it,
5839 int8_t index);
5840
5856FLECS_API
5858 const ecs_table_t *table);
5859
5870FLECS_API
5872 const ecs_world_t *world,
5873 const ecs_table_t *table,
5874 ecs_id_t component);
5875
5885FLECS_API
5887 const ecs_world_t *world,
5888 const ecs_table_t *table,
5889 ecs_id_t component);
5890
5898FLECS_API
5900 const ecs_table_t *table);
5901
5915FLECS_API
5917 const ecs_table_t *table,
5918 int32_t index);
5919
5928FLECS_API
5930 const ecs_table_t *table,
5931 int32_t index);
5932
5941FLECS_API
5943 const ecs_table_t *table,
5944 int32_t index,
5945 int32_t offset);
5946
5956FLECS_API
5958 const ecs_world_t *world,
5959 const ecs_table_t *table,
5960 ecs_id_t component,
5961 int32_t offset);
5962
5970FLECS_API
5972 const ecs_table_t *table,
5973 int32_t index);
5974
5981FLECS_API
5983 const ecs_table_t *table);
5984
5992FLECS_API
5994 const ecs_table_t *table);
5995
6002FLECS_API
6004 const ecs_table_t *table);
6005
6016FLECS_API
6018 const ecs_world_t *world,
6019 const ecs_table_t *table,
6020 ecs_id_t component);
6021
6032FLECS_API
6034 const ecs_world_t *world,
6035 const ecs_table_t *table,
6036 ecs_entity_t relationship,
6037 int32_t index);
6038
6049FLECS_API
6051 const ecs_world_t *world,
6052 const ecs_table_t *table,
6053 ecs_entity_t rel);
6054
6064FLECS_API
6066 ecs_world_t *world,
6067 ecs_table_t *table,
6068 ecs_id_t component);
6069
6080FLECS_API
6082 ecs_world_t *world,
6083 const ecs_id_t *ids,
6084 int32_t id_count);
6085
6095FLECS_API
6097 ecs_world_t *world,
6098 ecs_table_t *table,
6099 ecs_id_t component);
6100
6116FLECS_API
6118 ecs_world_t *world,
6119 ecs_table_t *table);
6120
6127FLECS_API
6129 ecs_world_t *world,
6130 ecs_table_t *table);
6131
6141FLECS_API
6143 ecs_table_t *table,
6144 ecs_flags32_t flags);
6145
6153FLECS_API
6155 const ecs_table_t *table);
6156
6164FLECS_API
6166 ecs_world_t* world,
6167 ecs_table_t* table,
6168 int32_t row_1,
6169 int32_t row_2);
6170
6193FLECS_API
6195 ecs_world_t *world,
6196 ecs_entity_t entity,
6197 ecs_record_t *record,
6198 ecs_table_t *table,
6199 const ecs_type_t *added,
6200 const ecs_type_t *removed);
6201
6202
6222FLECS_API
6224 const ecs_world_t *world,
6225 const ecs_table_t *table,
6226 ecs_id_t component,
6227 ecs_id_t *component_out);
6228
6264FLECS_API
6266 const ecs_world_t *world,
6267 const ecs_table_t *table,
6268 int32_t offset,
6269 ecs_id_t component,
6270 ecs_id_t *component_out);
6271
6313FLECS_API
6315 const ecs_world_t *world,
6316 const ecs_table_t *table,
6317 int32_t offset,
6318 ecs_id_t component,
6319 ecs_entity_t rel,
6320 ecs_flags64_t flags, /* EcsSelf and/or EcsUp */
6321 ecs_entity_t *tgt_out,
6322 ecs_id_t *component_out,
6323 struct ecs_table_record_t **tr_out);
6324
6325/* Up traversal from entity */
6326FLECS_API
6327int32_t ecs_search_relation_for_entity(
6328 const ecs_world_t *world,
6329 ecs_entity_t entity,
6330 ecs_id_t id,
6331 ecs_entity_t rel,
6332 bool self,
6334 ecs_entity_t *tgt_out,
6335 ecs_id_t *id_out,
6336 struct ecs_table_record_t **tr_out);
6337
6345FLECS_API
6347 ecs_world_t* world,
6348 ecs_table_t* table);
6349
6366FLECS_API
6368 const ecs_world_t *world,
6369 ecs_entity_t type,
6370 void *ptr);
6371
6379FLECS_API
6381 const ecs_world_t *world,
6382 const ecs_type_info_t *ti,
6383 void *ptr);
6384
6391FLECS_API
6393 ecs_world_t *world,
6394 ecs_entity_t type);
6395
6403 ecs_world_t *world,
6404 const ecs_type_info_t *ti);
6405
6414 const ecs_world_t *world,
6415 const ecs_type_info_t *ti,
6416 void *ptr);
6417
6425FLECS_API
6427 const ecs_world_t *world,
6428 ecs_entity_t type,
6429 void* ptr);
6430
6438FLECS_API
6440 ecs_world_t *world,
6441 ecs_entity_t type,
6442 void* ptr);
6443
6452FLECS_API
6454 const ecs_world_t *world,
6455 const ecs_type_info_t *ti,
6456 void* dst,
6457 const void *src);
6458
6467FLECS_API
6469 const ecs_world_t *world,
6470 ecs_entity_t type,
6471 void* dst,
6472 const void *src);
6473
6483 const ecs_world_t *world,
6484 const ecs_type_info_t *ti,
6485 void* dst,
6486 void *src);
6487
6497 const ecs_world_t *world,
6498 ecs_entity_t type,
6499 void* dst,
6500 void *src);
6501
6511 const ecs_world_t *world,
6512 const ecs_type_info_t *ti,
6513 void* dst,
6514 void *src);
6515
6525 const ecs_world_t *world,
6526 ecs_entity_t type,
6527 void* dst,
6528 void *src);
6529
6543#include "flecs/addons/flecs_c.h"
6544
6545#ifdef __cplusplus
6546}
6547#endif
6548
6549#include "flecs/private/addons.h"
6550
6551#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 auto override for component.
void ecs_remove_all(ecs_world_t *world, ecs_id_t component)
Remove all instances of the specified component.
void ecs_clear(ecs_world_t *world, ecs_entity_t entity)
Clear all components.
ecs_id_t ecs_get_with(const ecs_world_t *world)
Get component set with ecs_set_with().
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Add a (component) id to an entity.
ecs_entity_t ecs_set_with(ecs_world_t *world, ecs_id_t component)
Create new entities with specified component.
struct ecs_value_t ecs_value_t
Utility to hold a value of a dynamic type.
struct EcsIdentifier EcsIdentifier
A (string) identifier.
struct EcsPoly EcsPoly
Component for storing a poly object.
struct EcsDefaultChildComponent EcsDefaultChildComponent
When added to an entity this informs serialization formats which component to use when a value is ass...
struct EcsComponent EcsComponent
Component information.
const ecs_entity_t EcsScopeClose
Marker used to indicate the end of a scope (}) in queries.
const ecs_entity_t EcsOnRemove
Event that triggers when an id is removed from an entity.
const ecs_entity_t EcsThis
This entity.
const ecs_entity_t EcsWildcard
Wildcard entity ("*").
const ecs_entity_t EcsName
Tag to indicate name identifier.
const ecs_entity_t EcsAcyclic
Marks a relationship as acyclic.
const ecs_entity_t EcsSymmetric
Marks relationship as commutative.
const ecs_entity_t EcsAlias
Tag to indicate alias identifier.
const ecs_entity_t EcsOnSet
Event that triggers when a component is set for an entity.
const ecs_entity_t EcsReflexive
Marks a relationship as reflexive.
const ecs_entity_t EcsTrait
Can be added to components to indicate it is a trait.
const ecs_entity_t EcsEmpty
Tag used to indicate query is empty.
const ecs_entity_t EcsOneOf
Ensure that relationship target is child of specified entity.
const ecs_entity_t EcsOnTableDelete
Event that triggers when a table is deleted.
const ecs_entity_t EcsOnTableCreate
Event that triggers when a table is created.
const ecs_entity_t EcsObserver
Tag added to observers.
const ecs_entity_t EcsQuery
Tag added to queries.
const ecs_entity_t EcsRelationship
Ensure that an entity is always used in pair as relationship.
const ecs_entity_t EcsSingleton
Mark component as singleton.
const ecs_entity_t EcsOnStart
OnStart pipeline phase.
const ecs_entity_t EcsNotQueryable
Trait added to entities that should never be returned by queries.
const ecs_entity_t EcsOnStore
OnStore pipeline phase.
const ecs_entity_t EcsOrderedChildren
Tag that when added to a parent ensures stable order of ecs_children result.
const ecs_entity_t EcsDontFragment
Mark component as non-fragmenting.
const ecs_entity_t EcsTraversable
Marks 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 relationship to indicate that the relationship can only occur once on an entity.
const ecs_entity_t EcsSymbol
Tag to indicate symbol identifier.
const ecs_entity_t EcsDependsOn
Used to express dependency relationships.
const ecs_entity_t EcsTransitive
Marks a relationship as transitive.
const ecs_entity_t EcsDelete
Delete cleanup policy.
const ecs_entity_t EcsChildOf
Used to express parent-child relationships.
const ecs_entity_t EcsFlecsCore
Core module scope.
const ecs_entity_t EcsMonitor
Event that triggers observer when an entity starts/stops matching a query.
const ecs_entity_t EcsCanToggle
Mark a component as toggleable with ecs_enable_id().
const ecs_entity_t EcsPredEq
Marker used to indicate $var == ... matching in queries.
const ecs_entity_t EcsPhase
Phase pipeline phase.
const ecs_entity_t EcsWorld
Entity associated with world (used for "attaching" components to world)
const ecs_entity_t EcsScopeOpen
Marker used to indicate the start of a scope ({) in queries.
const ecs_entity_t EcsPostUpdate
PostUpdate pipeline phase.
const ecs_entity_t EcsOnValidate
OnValidate pipeline phase.
const ecs_entity_t EcsRemove
Remove cleanup policy.
const ecs_entity_t EcsOverride
Override component on instantiate.
const ecs_entity_t EcsPredMatch
Marker used to indicate $var == "name" matching in queries.
const ecs_entity_t EcsInherit
Inherit component on instantiate.
const ecs_entity_t EcsSlotOf
Used to express a slot (used with prefab inheritance)
const ecs_entity_t EcsModule
Tag added to module entities.
const ecs_entity_t EcsSparse
Mark component as sparse.
const ecs_entity_t EcsPreUpdate
PreUpdate pipeline phase.
const ecs_entity_t EcsOnAdd
Event that triggers when an id is added to an entity.
const ecs_entity_t EcsPrefab
Tag added to prefab entities.
const ecs_entity_t EcsOnInstantiate
Relationship that specifies component inheritance behavior.
const ecs_entity_t EcsPostFrame
PostFrame pipeline phase.
const ecs_entity_t EcsInheritable
Mark component as inheritable.
const ecs_entity_t EcsAny
Any entity ("_").
const ecs_entity_t EcsTarget
Ensure that an entity is always used in pair as target.
const ecs_entity_t EcsParentDepth
Relationship storing the entity's depth in a non-fragmenting hierarchy.
const ecs_entity_t EcsWith
Ensure that a component always is 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 builtin 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 querie...
const ecs_entity_t EcsDontInherit
Never inherit component on instantiate.
const ecs_entity_t EcsPairIsTag
Can be added to relationship to indicate that it should never hold data, even when it or the relation...
const ecs_entity_t EcsPanic
Panic cleanup policy.
const ecs_entity_t EcsFinal
Ensures that entity/component cannot be used as target in IsA relationship.
const ecs_entity_t EcsVariable
Variable entity ("$").
const ecs_entity_t EcsConstant
Tag added to enum/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 unmanaged stage.
bool ecs_defer_end(ecs_world_t *world)
End 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 end of frame.
void ecs_defer_suspend(ecs_world_t *world)
Suspend deferring but do not flush queue.
bool ecs_is_deferred(const ecs_world_t *world)
Test if deferring is enabled for current stage.
void ecs_stage_free(ecs_world_t *stage)
Free unmanaged stage.
void ecs_merge(ecs_world_t *stage)
Merge stage.
int32_t ecs_stage_get_id(const ecs_world_t *world)
Get 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 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 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 current stage.
const ecs_type_hooks_t * ecs_get_hooks_id(const ecs_world_t *world, ecs_entity_t component)
Get hooks for component.
ecs_entity_t ecs_component_init(ecs_world_t *world, const ecs_component_desc_t *desc)
Find or create a component.
const ecs_type_info_t * ecs_get_type_info(const ecs_world_t *world, ecs_id_t component)
Get the type info for an 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 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:493
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:428
struct ecs_ref_t ecs_ref_t
A ref is a fast way to fetch a component for a specific entity.
Definition flecs.h:477
ecs_id_t ecs_entity_t
An entity identifier.
Definition flecs.h:381
struct ecs_world_t ecs_world_t
A world is the container for all ECS data and supporting features.
Definition flecs.h:425
struct ecs_mixins_t ecs_mixins_t
Type that stores poly mixins.
Definition flecs.h:517
uint64_t ecs_id_t
Ids are the things that can be added to an entity.
Definition flecs.h:374
struct ecs_observable_t ecs_observable_t
An observable produces events that can be listened for by an observer.
Definition flecs.h:461
struct ecs_record_t ecs_record_t
Information about an entity, like its table and row.
Definition flecs.h:490
struct ecs_table_t ecs_table_t
A table stores entities and components for a specific type.
Definition flecs.h:431
void ecs_poly_t
A poly object.
Definition flecs.h:514
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/populate new entities.
ecs_entity_t ecs_clone(ecs_world_t *world, ecs_entity_t dst, ecs_entity_t src, bool copy_value)
Clone an entity This operation clones the components of one entity into another entity.
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 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 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 custom relationship argument.
void ecs_enable_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, bool enable)
Enable or disable component.
bool ecs_is_enabled_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t component)
Test if component is enabled.
void ecs_enable(ecs_world_t *world, ecs_entity_t entity, bool enabled)
Enable or disable 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 entity to string.
ecs_entity_t ecs_get_target(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, int32_t index)
Get the target of a relationship.
ecs_entity_t ecs_get_parent(const ecs_world_t *world, ecs_entity_t entity)
Get parent (target of ChildOf relationship) for 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 type to string.
char * ecs_table_str(const ecs_world_t *world, const ecs_table_t *table)
Convert table to string.
int32_t ecs_count_id(const ecs_world_t *world, ecs_id_t entity)
Count entities that have the specified id.
int32_t ecs_get_depth(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel)
Return depth for entity in tree for 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:636
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:616
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:678
uint64_t(* ecs_hash_value_action_t)(const void *ptr)
Callback used for hashing values.
Definition flecs.h:654
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:629
void(* ecs_iter_fini_action_t)(ecs_iter_t *it)
Function prototype for freeing an iterator.
Definition flecs.h:594
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:623
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:605
bool(* ecs_iter_next_action_t)(ecs_iter_t *it)
Function prototype for iterating an iterator.
Definition flecs.h:586
void(* ecs_iter_action_t)(ecs_iter_t *it)
Function prototype for iterables.
Definition flecs.h:576
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:664
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:684
int(* ecs_compare_action_t)(const void *ptr1, const void *ptr2)
Callback used for sorting values.
Definition flecs.h:649
void(* ecs_fini_action_t)(ecs_world_t *world, void *ctx)
Action callback on world exit.
Definition flecs.h:640
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:671
void(* flecs_poly_dtor_t)(ecs_poly_t *poly)
Destructor function for poly objects.
Definition flecs.h:690
void(* ecs_run_action_t)(ecs_iter_t *it)
Function prototype for runnables (systems, observers).
Definition flecs.h:567
void(* ecs_ctx_free_t)(void *ctx)
Function to cleanup context data.
Definition flecs.h:645
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:598
void(* ecs_xtor_t)(void *ptr, int32_t count, const ecs_type_info_t *type_info)
Constructor/destructor callback.
Definition flecs.h:658
void * ecs_ref_get_id(const ecs_world_t *world, ecs_ref_t *ref, ecs_id_t component)
Get component from ref.
void * ecs_emplace_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size, bool *is_new)
Emplace a component.
void ecs_ref_update(const ecs_world_t *world, ecs_ref_t *ref)
Update 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 entity has component, return pointer.
void ecs_set_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t component, size_t size, const void *ptr)
Set the value of a component.
const ecs_id_t ECS_PAIR
Indicates 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
Adds bitset to storage which allows component to be enabled/disabled.
const ecs_id_t ECS_VALUE_PAIR
Indicates that the target of a pair is an integer value.
char * ecs_id_str(const ecs_world_t *world, ecs_id_t component)
Convert component id to string.
bool ecs_id_is_tag(const ecs_world_t *world, ecs_id_t component)
Returns whether 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 id.
bool ecs_id_is_valid(const ecs_world_t *world, ecs_id_t component)
Utility to check if id is valid.
const char * ecs_id_flag_str(uint64_t component_flags)
Convert component flag to string.
bool ecs_id_in_use(const ecs_world_t *world, ecs_id_t component)
Returns whether 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 component string to buffer.
bool ecs_id_is_pair(ecs_id_t component)
Utility to check if 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 string to a component.
bool ecs_id_is_wildcard(ecs_id_t component)
Utility to check if component is a wildcard.
bool ecs_id_is_any(ecs_id_t component)
Utility to check if component is an any wildcard.
ecs_entity_t ecs_field_src(const ecs_iter_t *it, int8_t index)
Return field source.
bool ecs_iter_changed(ecs_iter_t *it)
Returns whether current iterator result has changed.
bool ecs_field_is_writeonly(const ecs_iter_t *it, int8_t index)
Test whether the field is writeonly.
ecs_var_t * ecs_iter_get_vars(const ecs_iter_t *it)
Get variable array.
bool ecs_field_is_readonly(const ecs_iter_t *it, int8_t index)
Test whether the field is readonly.
const char * ecs_iter_get_var_name(const ecs_iter_t *it, int32_t var_id)
Get 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 iterator is true.
void ecs_iter_fini(ecs_iter_t *it)
Cleanup iterator resources.
char * ecs_iter_str(const ecs_iter_t *it)
Convert iterator to string.
bool ecs_iter_var_is_constrained(ecs_iter_t *it, int32_t var_id)
Returns whether variable is constrained.
ecs_iter_t ecs_page_iter(const ecs_iter_t *it, int32_t offset, int32_t limit)
Create a paged iterator.
int32_t ecs_iter_get_var_count(const ecs_iter_t *it)
Get 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 field at specified row.
ecs_id_t ecs_field_id(const ecs_iter_t *it, int8_t index)
Return id matched for field.
bool ecs_field_is_set(const ecs_iter_t *it, int8_t index)
Test whether field is set.
void ecs_iter_set_var(ecs_iter_t *it, int32_t var_id, ecs_entity_t entity)
Set value for 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 value of iterator variable as entity.
bool ecs_worker_next(ecs_iter_t *it)
Progress a worker iterator.
ecs_entity_t ecs_iter_first(ecs_iter_t *it)
Get first matching entity from iterator.
int32_t ecs_field_column(const ecs_iter_t *it, int8_t index)
Return index of 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 value of iterator variable as table.
void * ecs_field_w_size(const ecs_iter_t *it, size_t size, int8_t index)
Get data for field.
int32_t ecs_iter_count(ecs_iter_t *it)
Count number of matched entities in query.
bool ecs_page_next(ecs_iter_t *it)
Progress a paged iterator.
void ecs_iter_set_var_as_range(ecs_iter_t *it, int32_t var_id, const ecs_table_range_t *range)
Same as ecs_iter_set_var(), but for a range of entities This constrains the variable to a range of en...
size_t ecs_field_size(const ecs_iter_t *it, int8_t index)
Return field type size.
ecs_table_range_t ecs_iter_get_var_as_range(ecs_iter_t *it, int32_t var_id)
Get value of iterator variable as table range.
ecs_id_t ecs_strip_generation(ecs_entity_t e)
Remove generation from entity id.
void ecs_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 id is alive.
ecs_entity_t ecs_get_alive(const ecs_world_t *world, ecs_entity_t e)
Get alive identifier.
uint32_t ecs_get_version(ecs_entity_t entity)
Get 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.
void ecs_emit(ecs_world_t *world, ecs_event_desc_t *desc)
Send event.
void ecs_enqueue(ecs_world_t *world, ecs_event_desc_t *desc)
Enqueue event.
ecs_entity_t ecs_observer_init(ecs_world_t *world, const ecs_observer_desc_t *desc)
Create observer.
const ecs_observer_t * ecs_observer_get(const ecs_world_t *world, ecs_entity_t observer)
Get 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:316
#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 ecs_entity_desc_t / ecs_bulk_desc_t.
Definition flecs.h:310
#define FLECS_TERM_COUNT_MAX
Maximum number of terms in queries.
Definition flecs.h:326
#define FLECS_TREE_SPAWNER_DEPTH_CACHE_SIZE
Size of depth cache in tree spawner component.
Definition flecs.h:359
char * ecs_get_path_w_sep(const ecs_world_t *world, ecs_entity_t parent, ecs_entity_t child, const char *sep, const char *prefix)
Get a path identifier for an entity.
ecs_entity_t ecs_new_from_path_w_sep(ecs_world_t *world, ecs_entity_t parent, const char *path, const char *sep, const char *prefix)
Find or create entity from path.
ecs_entity_t ecs_lookup_symbol(const ecs_world_t *world, const char *symbol, bool lookup_as_path, bool recursive)
Lookup an entity by its symbol name.
void ecs_set_alias(ecs_world_t *world, ecs_entity_t entity, const char *alias)
Set alias for entity.
ecs_entity_t ecs_lookup(const ecs_world_t *world, const char *path)
Lookup an entity by it's 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 path identifier to buffer.
ecs_entity_t * ecs_set_lookup_path(ecs_world_t *world, const ecs_entity_t *lookup_path)
Set search path for lookup operations.
ecs_entity_t ecs_set_name(ecs_world_t *world, ecs_entity_t entity, const char *name)
Set the name of an entity.
const char * ecs_get_symbol(const ecs_world_t *world, ecs_entity_t entity)
Get the symbol of an entity.
ecs_entity_t ecs_lookup_path_w_sep(const ecs_world_t *world, ecs_entity_t parent, const char *path, const char *sep, const char *prefix, bool recursive)
Lookup an entity from a path.
ecs_entity_t ecs_set_symbol(ecs_world_t *world, ecs_entity_t entity, const char *symbol)
Set the symbol of an entity.
ecs_entity_t ecs_lookup_child(const ecs_world_t *world, ecs_entity_t parent, const char *name)
Lookup a child entity by name.
const char * ecs_get_name(const ecs_world_t *world, ecs_entity_t entity)
Get the name of an entity.
ecs_entity_t ecs_add_path_w_sep(ecs_world_t *world, ecs_entity_t entity, ecs_entity_t parent, const char *path, const char *sep, const char *prefix)
Add specified path to entity.
ecs_entity_t * ecs_get_lookup_path(const ecs_world_t *world)
Get current lookup path.
ecs_entity_t ecs_set_scope(ecs_world_t *world, ecs_entity_t scope)
Set the current scope.
const char * ecs_set_name_prefix(ecs_world_t *world, const char *prefix)
Set a name prefix for newly created entities.
void ecs_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 table with query.
void ecs_iter_set_group(ecs_iter_t *it, uint64_t group_id)
Set group to iterate for query iterator.
const ecs_query_t * ecs_query_get(const ecs_world_t *world, ecs_entity_t query)
Get query object.
bool ecs_query_next(ecs_iter_t *it)
Progress 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 query group.
bool ecs_query_is_true(const ecs_query_t *query)
Does query return one or more results.
char * ecs_term_str(const ecs_world_t *world, const ecs_term_t *term)
Convert term to string expression.
bool ecs_query_has_range(const ecs_query_t *query, ecs_table_range_t *range, ecs_iter_t *it)
Match range with query.
int32_t ecs_query_find_var(const ecs_query_t *query, const char *name)
Find 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 entity with query.
char * ecs_query_plan_w_profile(const ecs_query_t *query, const ecs_iter_t *it)
Convert query to string with 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 key-value string.
int32_t ecs_query_match_count(const ecs_query_t *query)
Returns how often a match event happened for a cached query.
char * ecs_query_plan(const ecs_query_t *query)
Convert 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 query to string expression.
bool ecs_query_var_is_entity(const ecs_query_t *query, int32_t var_id)
Test if 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)
Returns whether the query data changed since the last iteration.
const char * ecs_query_var_name(const ecs_query_t *query, int32_t var_id)
Get variable name.
bool ecs_term_match_this(const ecs_term_t *term)
Is term matched on $this variable.
char * ecs_query_plans(const ecs_query_t *query)
Same as ecs_query_plan(), but includes plan for populating cache (if any).
void * ecs_query_get_group_ctx(const ecs_query_t *query, uint64_t group_id)
Get context of query group.
ecs_query_count_t ecs_query_count(const ecs_query_t *query)
Returns number of entities and results the query matches with.
const ecs_map_t * ecs_query_get_groups(const ecs_query_t *query)
Return 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 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 term matched on 0 source.
const ecs_query_t * ecs_query_get_cache_query(const ecs_query_t *query)
Get query used to populate 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:724
ecs_inout_kind_t
Specify read/write access for term.
Definition flecs.h:703
ecs_oper_kind_t
Specify operator for term.
Definition flecs.h:713
@ EcsQueryCacheAll
Require that all query terms can be cached.
Definition flecs.h:727
@ EcsQueryCacheDefault
Behavior determined by query creation context.
Definition flecs.h:725
@ EcsQueryCacheNone
No caching.
Definition flecs.h:728
@ EcsQueryCacheAuto
Cache query terms that are cacheable.
Definition flecs.h:726
@ EcsOut
Term is only written.
Definition flecs.h:709
@ EcsInOut
Term is both read and written.
Definition flecs.h:707
@ EcsInOutFilter
Same as InOutNone + prevents term from triggering observers.
Definition flecs.h:706
@ EcsInOutDefault
InOut for regular terms, In for shared terms.
Definition flecs.h:704
@ EcsInOutNone
Term is neither read nor written.
Definition flecs.h:705
@ EcsIn
Term is only read.
Definition flecs.h:708
@ EcsNot
The term must not match.
Definition flecs.h:716
@ EcsOptional
The term may match.
Definition flecs.h:717
@ EcsOr
One of the terms in an or chain must match.
Definition flecs.h:715
@ EcsOrFrom
Term must match at least one component from term id.
Definition flecs.h:719
@ EcsAnd
The term must match.
Definition flecs.h:714
@ EcsNotFrom
Term must match none of the components from term id.
Definition flecs.h:720
@ EcsAndFrom
Term must match all components from term id.
Definition flecs.h:718
ecs_table_t * ecs_table_add_id(ecs_world_t *world, ecs_table_t *table, ecs_id_t component)
Get table that has all components of 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 component in 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 table that has all components of current table minus the specified component.
const ecs_type_t * ecs_table_get_type(const ecs_table_t *table)
Get type for table.
int32_t ecs_table_get_column_index(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component)
Get column index for component.
void * ecs_table_get_id(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component, int32_t offset)
Get column from table by component.
int32_t ecs_table_size(const ecs_table_t *table)
Returns allocated size of table.
bool ecs_table_has_flags(ecs_table_t *table, ecs_flags32_t flags)
Test table for flags.
int32_t ecs_table_column_to_type_index(const ecs_table_t *table, int32_t index)
Convert column index to type index.
int32_t ecs_table_column_count(const ecs_table_t *table)
Return number of columns in table.
bool ecs_commit(ecs_world_t *world, ecs_entity_t entity, ecs_record_t *record, ecs_table_t *table, const ecs_type_t *added, const ecs_type_t *removed)
Commit (move) entity to a table.
int32_t ecs_search_relation(const ecs_world_t *world, const ecs_table_t *table, int32_t offset, ecs_id_t component, ecs_entity_t rel, ecs_flags64_t flags, ecs_entity_t *tgt_out, ecs_id_t *component_out, struct ecs_table_record_t **tr_out)
Search for component/relationship id in table type starting from an offset.
void * ecs_table_get_column(const ecs_table_t *table, int32_t index, int32_t offset)
Get column from 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 component in 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 relationship target for table.
int32_t ecs_table_count(const ecs_table_t *table)
Returns the number of entities in the table.
const ecs_entity_t * ecs_table_entities(const ecs_table_t *table)
Returns array with entity ids for 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 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 depth for table in tree for relationship rel.
bool ecs_table_has_id(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component)
Test if table has component.
void ecs_table_swap_rows(ecs_world_t *world, ecs_table_t *table, int32_t row_1, int32_t row_2)
Swaps two elements inside the table.
void ecs_table_lock(ecs_world_t *world, ecs_table_t *table)
Lock a table.
ecs_table_t * ecs_table_find(ecs_world_t *world, const ecs_id_t *ids, int32_t id_count)
Find table from id array.
size_t ecs_table_get_column_size(const ecs_table_t *table, int32_t index)
Get column size from table.
int32_t ecs_table_get_type_index(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t component)
Get type index for 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 type index to column index.
int ecs_value_fini_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *ptr)
Destruct a value.
int ecs_value_fini(const ecs_world_t *world, ecs_entity_t type, void *ptr)
Destruct a value.
int ecs_value_copy(const ecs_world_t *world, ecs_entity_t type, void *dst, const void *src)
Copy value.
int ecs_value_move(const ecs_world_t *world, ecs_entity_t type, void *dst, void *src)
Move value.
int ecs_value_move_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *dst, void *src)
Move value.
void * ecs_value_new_w_type_info(ecs_world_t *world, const ecs_type_info_t *ti)
Construct a value in new storage.
int ecs_value_move_ctor_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *dst, void *src)
Move construct value.
int ecs_value_copy_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *dst, const void *src)
Copy value.
int ecs_value_init_w_type_info(const ecs_world_t *world, const ecs_type_info_t *ti, void *ptr)
Construct a value in existing storage.
void * ecs_value_new(ecs_world_t *world, ecs_entity_t type)
Construct a value in new storage.
int ecs_value_free(ecs_world_t *world, ecs_entity_t type, void *ptr)
Destruct a value, free storage.
int ecs_value_move_ctor(const ecs_world_t *world, ecs_entity_t type, void *dst, void *src)
Move construct value.
int ecs_value_init(const ecs_world_t *world, ecs_entity_t type, void *ptr)
Construct a value in existing storage.
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 action to be executed when world is destroyed.
bool ecs_is_fini(const ecs_world_t *world)
Returns whether the world is being deleted.
int ecs_fini(ecs_world_t *world)
Delete a world.
ecs_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 world.
void ecs_set_target_fps(ecs_world_t *world, float fps)
Set target frames per second (FPS) for application.
void ecs_measure_system_time(ecs_world_t *world, bool enable)
Measure system time.
float ecs_frame_begin(ecs_world_t *world, float delta_time)
Begin frame.
void ecs_run_post_frame(ecs_world_t *world, ecs_fini_action_t action, void *ctx)
Register action to be executed once after frame.
bool ecs_should_quit(const ecs_world_t *world)
Return whether a quit has been requested.
void ecs_set_default_query_flags(ecs_world_t *world, ecs_flags32_t flags)
Set default query flags.
void ecs_quit(ecs_world_t *world)
Signal exit This operation signals that the application should quit.
void ecs_measure_frame_time(ecs_world_t *world, bool enable)
Measure frame time.
void ecs_frame_end(ecs_world_t *world)
End frame.
ecs_entity_t ecs_get_entity(const ecs_poly_t *poly)
Get entity from poly.
ecs_id_t ecs_make_pair(ecs_entity_t first, ecs_entity_t second)
Make a pair id.
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 pointer is of 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.
void ecs_set_entity_range(ecs_world_t *world, ecs_entity_t id_start, ecs_entity_t id_end)
Set a range for issuing new entity ids.
const ecs_world_info_t * ecs_get_world_info(const ecs_world_t *world)
Get world info.
const ecs_world_t * ecs_get_world(const ecs_poly_t *poly)
Get world from poly.
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)
Cleanup 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().
bool ecs_enable_range_check(ecs_world_t *world, bool enable)
Enable/disable range limits.
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:1562
ecs_size_t size
Component size.
Definition flecs.h:1563
ecs_size_t alignment
Component alignment.
Definition flecs.h:1564
When added to an entity this informs serialization formats which component to use when a value is ass...
Definition flecs.h:1577
ecs_id_t component
Default component id.
Definition flecs.h:1578
A (string) identifier.
Definition flecs.h:1553
ecs_size_t length
Length of identifier.
Definition flecs.h:1555
char * value
Identifier string.
Definition flecs.h:1554
ecs_hashmap_t * index
Current index.
Definition flecs.h:1558
uint64_t hash
Hash of current value.
Definition flecs.h:1556
uint64_t index_hash
Hash of existing record in current index.
Definition flecs.h:1557
Component for storing a poly object.
Definition flecs.h:1568
ecs_poly_t * poly
Pointer to poly object.
Definition flecs.h:1569
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/interval timer functionality.
Definition timer.h:35
Type with information about the current Flecs build.
Definition flecs.h:1460
const char ** flags
Compile time settings.
Definition flecs.h:1463
int16_t version_major
Major flecs version.
Definition flecs.h:1465
const char ** addons
Addons included in build.
Definition flecs.h:1462
const char * version
Stringified version.
Definition flecs.h:1464
const char * compiler
Compiler used to compile flecs.
Definition flecs.h:1461
bool sanitize
Is this a sanitize build.
Definition flecs.h:1469
bool perf_trace
Is this a perf tracing build.
Definition flecs.h:1470
int16_t version_minor
Minor flecs version.
Definition flecs.h:1466
bool debug
Is this a debug build.
Definition flecs.h:1468
int16_t version_patch
Patch flecs version.
Definition flecs.h:1467
Used with ecs_bulk_init().
Definition flecs.h:1084
ecs_id_t ids[32]
Ids to create the entities with.
Definition flecs.h:1094
void ** data
Array with component data to insert.
Definition flecs.h:1096
int32_t count
Number of entities to create/populate.
Definition flecs.h:1092
int32_t _canary
Used for validity testing.
Definition flecs.h:1085
ecs_entity_t * entities
Entities to bulk insert.
Definition flecs.h:1087
ecs_table_t * table
Table to insert the entities into.
Definition flecs.h:1103
Used with ecs_component_init().
Definition flecs.h:1114
int32_t _canary
Used for validity testing.
Definition flecs.h:1115
ecs_type_info_t type
Parameters for type (size, hooks, ...)
Definition flecs.h:1121
ecs_entity_t entity
Existing entity to associate with observer (optional)
Definition flecs.h:1118
Used with ecs_delete_empty_tables().
Definition flecs.h:2719
uint16_t delete_generation
Delete table when generation > delete_generation.
Definition flecs.h:2724
double time_budget_seconds
Amount of time operation is allowed to spend.
Definition flecs.h:2727
uint16_t clear_generation
Free table data when generation > clear_generation.
Definition flecs.h:2721
Type returned by ecs_get_entities().
Definition flecs.h:2074
int32_t alive_count
Number of alive entity ids.
Definition flecs.h:2077
int32_t count
Total number of entity ids.
Definition flecs.h:2076
const ecs_entity_t * ids
Array with all entity ids in the world.
Definition flecs.h:2075
Used with ecs_entity_init().
Definition flecs.h:1038
const char * sep
Optional custom separator for hierarchical names.
Definition flecs.h:1050
const char * root_sep
Optional, used for identifiers relative to root.
Definition flecs.h:1054
const char * name
Name of the entity.
Definition flecs.h:1045
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:1066
const char * symbol
Optional entity symbol.
Definition flecs.h:1056
int32_t _canary
Used for validity testing.
Definition flecs.h:1039
const ecs_id_t * add
0-terminated array of ids to add to the entity.
Definition flecs.h:1071
const char * add_expr
String expression with components to add.
Definition flecs.h:1077
const ecs_value_t * set
0-terminated array of values to set on the entity.
Definition flecs.h:1074
ecs_entity_t id
Set to modify existing entity (optional)
Definition flecs.h:1041
ecs_entity_t parent
Parent entity.
Definition flecs.h:1043
Used with ecs_emit().
Definition flecs.h:1406
ecs_entity_t entity
Single-entity alternative to setting table / offset / count.
Definition flecs.h:1431
const void * const_param
Same as param, but with the guarantee that the value won't be modified.
Definition flecs.h:1442
ecs_table_t * table
The table for which to notify.
Definition flecs.h:1416
int32_t count
Limit number of notified entities to count.
Definition flecs.h:1428
ecs_table_t * other_table
Optional 2nd table to notify.
Definition flecs.h:1420
int32_t offset
Limit notified entities to ones starting from offset (row) in table.
Definition flecs.h:1423
const ecs_type_t * ids
Component ids.
Definition flecs.h:1413
ecs_poly_t * observable
Observable (usually the world)
Definition flecs.h:1445
ecs_entity_t event
The event id.
Definition flecs.h:1408
ecs_flags32_t flags
Event flags.
Definition flecs.h:1448
void * param
Optional context.
Definition flecs.h:1437
Header for ecs_poly_t objects.
Definition flecs.h:520
int32_t type
Magic number indicating which type of flecs object.
Definition flecs.h:521
int32_t refcount
Refcount, to enable RAII handles.
Definition flecs.h:522
ecs_mixins_t * mixins
Table with offsets to (optional) mixins.
Definition flecs.h:523
Iterator.
Definition flecs.h:1162
ecs_world_t * real_world
Actual world.
Definition flecs.h:1165
void * param
Param passed to ecs_run.
Definition flecs.h:1198
ecs_entity_t event
The event (if applicable)
Definition flecs.h:1186
int32_t frame_offset
Offset relative to start of iteration.
Definition flecs.h:1209
ecs_flags32_t ref_fields
Bitset with fields that aren't component arrays.
Definition flecs.h:1180
ecs_entity_t interrupted_by
When set, system execution is interrupted.
Definition flecs.h:1213
ecs_flags32_t flags
Iterator flags.
Definition flecs.h:1212
ecs_iter_t * chain_it
Optional, allows for creating iterator chains.
Definition flecs.h:1220
void * ctx
System context.
Definition flecs.h:1199
void * run_ctx
Run language binding context.
Definition flecs.h:1202
ecs_table_t * table
Current table.
Definition flecs.h:1174
int32_t offset
Offset relative to current table.
Definition flecs.h:1168
ecs_id_t event_id
The (component) id for the event.
Definition flecs.h:1187
ecs_iter_fini_action_t fini
Function to cleanup iterator resources.
Definition flecs.h:1219
ecs_iter_private_t priv_
Private data.
Definition flecs.h:1214
ecs_world_t * world
The world.
Definition flecs.h:1164
void * callback_ctx
Callback language binding context.
Definition flecs.h:1201
ecs_entity_t * sources
Entity on which the id was matched (0 if same as entities)
Definition flecs.h:1177
void * binding_ctx
System binding context.
Definition flecs.h:1200
ecs_flags32_t row_fields
Fields that must be obtained with field_at.
Definition flecs.h:1181
float delta_system_time
Time elapsed since last system invocation.
Definition flecs.h:1206
const ecs_query_t * query
Query being evaluated.
Definition flecs.h:1195
int8_t term_index
Index of term that emitted an event.
Definition flecs.h:1192
ecs_entity_t system
The system (if applicable)
Definition flecs.h:1185
ecs_flags32_t set_fields
Fields that are set.
Definition flecs.h:1179
const ecs_size_t * sizes
Component sizes.
Definition flecs.h:1173
float delta_time
Time elapsed since last frame.
Definition flecs.h:1205
ecs_flags32_t up_fields
Bitset with fields matched through up traversal.
Definition flecs.h:1182
ecs_iter_action_t callback
Callback of system or observer.
Definition flecs.h:1218
int8_t field_count
Number of fields in iterator.
Definition flecs.h:1191
ecs_table_t * other_table
Prev or next table when adding/removing.
Definition flecs.h:1175
int32_t event_cur
Unique event id.
Definition flecs.h:1188
const ecs_table_record_t ** trs
Info on where to find field in table.
Definition flecs.h:1172
int32_t count
Number of entities to iterate.
Definition flecs.h:1169
void ** ptrs
Component pointers.
Definition flecs.h:1171
ecs_iter_next_action_t next
Function to progress iterator.
Definition flecs.h:1217
const ecs_entity_t * entities
Entity identifiers.
Definition flecs.h:1170
ecs_id_t * ids
(Component) ids
Definition flecs.h:1176
ecs_flags64_t constrained_vars
Bitset that marks constrained variables.
Definition flecs.h:1178
Used with ecs_observer_init().
Definition flecs.h:1345
ecs_ctx_free_t run_ctx_free
Callback to free run ctx.
Definition flecs.h:1394
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1382
void * run_ctx
Context associated with run (for language bindings).
Definition flecs.h:1391
ecs_entity_t entity
Existing entity to associate with observer (optional)
Definition flecs.h:1350
int32_t * last_event_id
Used for internal purposes.
Definition flecs.h:1397
void * callback_ctx
Context associated with callback (for language bindings).
Definition flecs.h:1385
void * ctx
User context to pass to callback.
Definition flecs.h:1379
ecs_query_desc_t query
Query for observer.
Definition flecs.h:1353
ecs_ctx_free_t callback_ctx_free
Callback to free callback ctx.
Definition flecs.h:1388
bool global_observer
Global observers are tied to the lifespan of the world.
Definition flecs.h:1365
ecs_iter_action_t callback
Callback to invoke on an event, invoked when the observer matches.
Definition flecs.h:1368
bool yield_existing
When observer is created, generate events from existing data.
Definition flecs.h:1360
ecs_run_action_t run
Callback invoked on an event.
Definition flecs.h:1376
ecs_entity_t events[8]
Events to observe (OnAdd, OnRemove, OnSet)
Definition flecs.h:1356
int32_t _canary
Used for validity testing.
Definition flecs.h:1347
An observer reacts to events matching a query.
Definition flecs.h:874
int32_t event_count
Number of events.
Definition flecs.h:881
ecs_iter_action_t callback
See ecs_observer_desc_t::callback.
Definition flecs.h:883
ecs_entity_t entity
Entity associated with observer.
Definition flecs.h:897
ecs_observable_t * observable
Observable for observer.
Definition flecs.h:894
ecs_run_action_t run
See ecs_observer_desc_t::run.
Definition flecs.h:884
ecs_header_t hdr
Object header.
Definition flecs.h:875
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:890
ecs_entity_t events[8]
Observer events.
Definition flecs.h:880
void * run_ctx
Run language binding context.
Definition flecs.h:888
ecs_world_t * world
The world.
Definition flecs.h:896
ecs_ctx_free_t run_ctx_free
Callback to free run_ctx.
Definition flecs.h:892
void * callback_ctx
Callback language binding context.
Definition flecs.h:887
void * ctx
Observer context.
Definition flecs.h:886
ecs_ctx_free_t callback_ctx_free
Callback to free callback_ctx.
Definition flecs.h:891
ecs_query_t * query
Observer query.
Definition flecs.h:877
Struct returned by ecs_query_count().
Definition flecs.h:5179
int32_t entities
Number of entities returned by query.
Definition flecs.h:5181
int32_t results
Number of results returned by query.
Definition flecs.h:5180
int32_t tables
Number of tables returned by query.
Definition flecs.h:5182
Used with ecs_query_init().
Definition flecs.h:1271
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1332
ecs_id_t group_by
Component id to be used for grouping.
Definition flecs.h:1302
ecs_term_t terms[32]
Query terms.
Definition flecs.h:1276
int32_t _canary
Used for validity testing.
Definition flecs.h:1273
void * ctx
User context to pass to callback.
Definition flecs.h:1326
ecs_ctx_free_t group_by_ctx_free
Function to free group_by_ctx.
Definition flecs.h:1323
void * group_by_ctx
Context to pass to group_by.
Definition flecs.h:1320
void * binding_ctx
Context to be used for language bindings.
Definition flecs.h:1329
ecs_entity_t order_by
Component to sort on, used together with order_by_callback or order_by_table_callback.
Definition flecs.h:1298
ecs_order_by_action_t order_by_callback
Callback used for ordering query results.
Definition flecs.h:1290
ecs_group_create_action_t on_group_create
Callback that is invoked when a new group is created.
Definition flecs.h:1313
ecs_entity_t entity
Entity associated with query (optional)
Definition flecs.h:1338
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition flecs.h:1335
ecs_group_by_action_t group_by_callback
Callback used for grouping results.
Definition flecs.h:1309
ecs_group_delete_action_t on_group_delete
Callback that is invoked when an existing group is deleted.
Definition flecs.h:1317
ecs_sort_table_action_t order_by_table_callback
Callback used for ordering query results.
Definition flecs.h:1294
ecs_flags32_t flags
Flags for enabling query features.
Definition flecs.h:1285
ecs_query_cache_kind_t cache_kind
Caching policy of query.
Definition flecs.h:1282
const char * expr
Query DSL expression (optional)
Definition flecs.h:1279
Type that contains information about a query group.
Definition flecs.h:1536
int32_t table_count
Number of tables in group.
Definition flecs.h:1539
void * ctx
Group context, returned by on_group_create.
Definition flecs.h:1540
int32_t match_count
How often tables have been matched/unmatched.
Definition flecs.h:1538
Queries are lists of constraints (terms) that match entities.
Definition flecs.h:833
ecs_flags32_t row_fields
Fields that must be acquired with field_at.
Definition flecs.h:853
ecs_flags32_t data_fields
Fields that have data.
Definition flecs.h:850
ecs_flags32_t read_fields
Fields that read data.
Definition flecs.h:852
ecs_header_t hdr
Object header.
Definition flecs.h:834
int8_t var_count
Number of query variables.
Definition flecs.h:842
ecs_flags32_t fixed_fields
Fields with a fixed source.
Definition flecs.h:847
ecs_flags32_t var_fields
Fields with non-$this variable source.
Definition flecs.h:848
ecs_flags32_t write_fields
Fields that write data.
Definition flecs.h:851
int32_t eval_count
Number of times query is evaluated.
Definition flecs.h:868
ecs_world_t * world
World or stage query was created with.
Definition flecs.h:866
ecs_flags32_t static_id_fields
Fields with a static (component) id.
Definition flecs.h:849
uint64_t bloom_filter
Bitmask used to quickly discard tables.
Definition flecs.h:840
ecs_world_t * real_world
Actual world.
Definition flecs.h:865
ecs_flags32_t set_fields
Fields that will be set.
Definition flecs.h:855
ecs_entity_t entity
Entity associated with query (optional)
Definition flecs.h:864
void * ctx
User context to pass to callback.
Definition flecs.h:861
int32_t * sizes
Component sizes.
Definition flecs.h:837
ecs_id_t * ids
Component ids.
Definition flecs.h:838
ecs_flags32_t shared_readonly_fields
Fields that don't write shared data.
Definition flecs.h:854
ecs_term_t * terms
Query terms.
Definition flecs.h:836
ecs_query_cache_kind_t cache_kind
Caching policy of query.
Definition flecs.h:857
int8_t term_count
Number of query terms.
Definition flecs.h:843
char ** vars
Array with variable names for iterator.
Definition flecs.h:859
int8_t field_count
Number of fields returned by query.
Definition flecs.h:844
ecs_flags32_t flags
Query flags.
Definition flecs.h:841
void * binding_ctx
Context to be used for language bindings.
Definition flecs.h:862
Type that describes a reference to an entity or variable in a term.
Definition flecs.h:794
const char * name
Name.
Definition flecs.h:801
ecs_entity_t id
Entity id.
Definition flecs.h:795
Type that describes a term (single element in a query).
Definition flecs.h:809
ecs_term_ref_t src
Source of term.
Definition flecs.h:815
int8_t field_index
Index of field for term in iterator.
Definition flecs.h:826
ecs_id_t id
Component id to be matched by term.
Definition flecs.h:810
int16_t oper
Operator of term.
Definition flecs.h:824
ecs_term_ref_t second
Second element of pair.
Definition flecs.h:817
ecs_flags16_t flags_
Flags that help eval, set by ecs_query_init()
Definition flecs.h:827
ecs_entity_t trav
Relationship to traverse when looking for the component.
Definition flecs.h:819
int16_t inout
Access to contents matched by term.
Definition flecs.h:823
ecs_term_ref_t first
Component or first element of pair.
Definition flecs.h:816
ecs_copy_t copy_ctor
Ctor + copy.
Definition flecs.h:953
void * lifecycle_ctx
Component lifecycle context (see meta add-on)
Definition flecs.h:1004
void * ctx
User defined context.
Definition flecs.h:1002
ecs_iter_action_t on_remove
Callback that is invoked when an instance of the component is removed.
Definition flecs.h:994
void * binding_ctx
Language binding context.
Definition flecs.h:1003
ecs_move_t move_dtor
Move + dtor.
Definition flecs.h:968
ecs_flags32_t flags
Hook flags.
Definition flecs.h:980
ecs_cmp_t cmp
Compare hook.
Definition flecs.h:971
ecs_copy_t copy
copy assignment
Definition flecs.h:949
ecs_ctx_free_t lifecycle_ctx_free
Callback to free lifecycle_ctx.
Definition flecs.h:1008
ecs_iter_action_t on_set
Callback that is invoked when an instance of the component is set.
Definition flecs.h:989
ecs_move_t move
move assignment
Definition flecs.h:950
ecs_xtor_t ctor
ctor
Definition flecs.h:947
ecs_iter_action_t on_replace
Callback that is invoked with the existing and new value before the value is assigned.
Definition flecs.h:1000
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1006
ecs_iter_action_t on_add
Callback that is invoked when an instance of a component is added.
Definition flecs.h:984
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition flecs.h:1007
ecs_move_t move_ctor
Ctor + move.
Definition flecs.h:956
ecs_equals_t equals
Equals hook.
Definition flecs.h:974
ecs_move_t ctor_move_dtor
Ctor + move + dtor (or move_ctor + dtor).
Definition flecs.h:962
ecs_xtor_t dtor
dtor
Definition flecs.h:948
Type that contains component information (passed to ctors/dtors/...)
Definition flecs.h:1015
ecs_size_t alignment
Alignment of type.
Definition flecs.h:1017
ecs_size_t size
Size of type.
Definition flecs.h:1016
const char * name
Type name.
Definition flecs.h:1020
ecs_entity_t component
Handle to component (do not set)
Definition flecs.h:1019
ecs_type_hooks_t hooks
Type hooks.
Definition flecs.h:1018
A type is a list of (component) ids.
Definition flecs.h:398
ecs_id_t * array
Array with ids.
Definition flecs.h:399
int32_t count
Number of elements in array.
Definition flecs.h:400
Utility to hold a value of a dynamic type.
Definition flecs.h:1029
void * ptr
Pointer to value.
Definition flecs.h:1031
ecs_entity_t type
Type of value.
Definition flecs.h:1030
Type that contains information about the world.
Definition flecs.h:1474
int64_t observers_ran_total
Total number of times observer was invoked.
Definition flecs.h:1502
float delta_time
Time passed to or computed by ecs_progress()
Definition flecs.h:1480
ecs_entity_t min_id
First allowed entity id.
Definition flecs.h:1476
int64_t systems_ran_total
Total number of systems ran.
Definition flecs.h:1501
int64_t set_count
Set commands processed.
Definition flecs.h:1519
double world_time_total
Time elapsed in simulation.
Definition flecs.h:1488
int32_t tag_id_count
Number of tag (no data) ids in the world.
Definition flecs.h:1505
int32_t component_id_count
Number of component (data) ids in the world.
Definition flecs.h:1506
int64_t pipeline_build_count_total
Total number of pipeline builds.
Definition flecs.h:1500
int64_t eval_comp_monitors_total
Total number of monitor evaluations.
Definition flecs.h:1493
int32_t table_count
Number of tables.
Definition flecs.h:1509
float delta_time_raw
Raw delta time (no time scaling)
Definition flecs.h:1479
float frame_time_total
Total time spent processing a frame.
Definition flecs.h:1483
int64_t table_create_total
Total number of times a table was created.
Definition flecs.h:1498
float system_time_total
Total time spent in systems.
Definition flecs.h:1484
int64_t id_delete_total
Total number of times an id was deleted.
Definition flecs.h:1497
float merge_time_total
Total time spent in merges.
Definition flecs.h:1486
struct ecs_world_info_t::@0 cmd
Command statistics.
int64_t discard_count
Commands discarded, happens when entity is no longer alive when running the command.
Definition flecs.h:1522
int64_t clear_count
Clear commands processed.
Definition flecs.h:1518
ecs_entity_t last_component_id
Last issued component entity id.
Definition flecs.h:1475
int64_t frame_count_total
Total number of frames.
Definition flecs.h:1491
ecs_entity_t max_id
Last allowed entity id.
Definition flecs.h:1477
int64_t merge_count_total
Total number of merges.
Definition flecs.h:1492
int64_t other_count
Other commands processed.
Definition flecs.h:1524
int64_t batched_command_count
Commands batched.
Definition flecs.h:1526
int64_t table_delete_total
Total number of times a table was deleted.
Definition flecs.h:1499
int64_t queries_ran_total
Total number of times a query was evaluated.
Definition flecs.h:1503
int64_t delete_count
Delete commands processed.
Definition flecs.h:1517
int64_t rematch_count_total
Total number of rematches.
Definition flecs.h:1494
int64_t id_create_total
Total number of times a new id was created.
Definition flecs.h:1496
int64_t batched_entity_count
Entities for which commands were batched.
Definition flecs.h:1525
float time_scale
Time scale applied to delta_time.
Definition flecs.h:1481
int32_t pair_id_count
Number of pair ids in the world.
Definition flecs.h:1507
float rematch_time_total
Time spent on query rematching.
Definition flecs.h:1487
int64_t ensure_count
Ensure/emplace commands processed.
Definition flecs.h:1520
float target_fps
Target fps.
Definition flecs.h:1482
double world_time_total_raw
Time elapsed in simulation (no scaling)
Definition flecs.h:1489
float emit_time_total
Total time spent notifying observers.
Definition flecs.h:1485
uint32_t creation_time
Time when world was created.
Definition flecs.h:1511
int64_t modified_count
Modified commands processed.
Definition flecs.h:1521
const char * name_prefix
Value set by ecs_set_name_prefix().
Definition flecs.h:1529
int64_t event_count
Enqueued custom events.
Definition flecs.h:1523
int64_t add_count
Add commands processed.
Definition flecs.h:1515
int64_t remove_count
Remove commands processed.
Definition flecs.h:1516