Flecs v4.0
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 0
36#define FLECS_VERSION_PATCH 5
39#define FLECS_VERSION FLECS_VERSION_IMPL(\
40 FLECS_VERSION_MAJOR, FLECS_VERSION_MINOR, FLECS_VERSION_PATCH)
41
45#ifdef FLECS_CONFIG_HEADER
46#include "flecs_config.h"
47#endif
48
51#ifndef ecs_float_t
52#define ecs_float_t float
53#endif
54
58#ifndef ecs_ftime_t
59#define ecs_ftime_t ecs_float_t
60#endif
61
65// #define FLECS_LEGACY
66
72// #define FLECS_ACCURATE_COUNTERS
73
79// #define FLECS_DISABLE_COUNTERS
80
81/* Make sure provided configuration is valid */
82#if defined(FLECS_DEBUG) && defined(FLECS_NDEBUG)
83#error "invalid configuration: cannot both define FLECS_DEBUG and FLECS_NDEBUG"
84#endif
85#if defined(FLECS_DEBUG) && defined(NDEBUG)
86#error "invalid configuration: cannot both define FLECS_DEBUG and NDEBUG"
87#endif
88
93#if !defined(FLECS_DEBUG) && !defined(FLECS_NDEBUG)
94#if defined(NDEBUG)
95#define FLECS_NDEBUG
96#else
97#define FLECS_DEBUG
98#endif
99#endif
100
105#ifdef FLECS_SANITIZE
106#ifndef FLECS_DEBUG
107#define FLECS_DEBUG /* If sanitized mode is enabled, so is debug mode */
108#endif
109#endif
110
115#ifdef FLECS_DEBUG
116#ifndef FLECS_DEBUG_INFO
117#define FLECS_DEBUG_INFO
118#endif
119#endif
120
121/* Tip: if you see weird behavior that you think might be a bug, make sure to
122 * test with the FLECS_DEBUG or FLECS_SANITIZE flags enabled. There's a good
123 * chance that this gives you more information about the issue! */
124
138// #define FLECS_SOFT_ASSERT
139
145// #define FLECS_KEEP_ASSERT
146
153// #define FLECS_DEFAULT_TO_UNCACHED_QUERIES
154
163// #define FLECS_CPP_NO_AUTO_REGISTRATION
164
172// #define FLECS_CPP_NO_ENUM_REFLECTION
173
178// #define FLECS_NO_ALWAYS_INLINE
179
207// #define FLECS_CUSTOM_BUILD
208
209#ifndef FLECS_CUSTOM_BUILD
210#define FLECS_ALERTS
211#define FLECS_APP
212// #define FLECS_C /**< C API convenience macros, always enabled */
213#define FLECS_CPP
214#define FLECS_DOC
215// #define FLECS_JOURNAL /**< Journaling addon */
216#define FLECS_JSON
217#define FLECS_HTTP
218#define FLECS_LOG
219#define FLECS_META
220#define FLECS_METRICS
221#define FLECS_MODULE
222#define FLECS_OS_API_IMPL
223// #define FLECS_PERF_TRACE /**< Enable performance tracing */
224#define FLECS_PIPELINE
225#define FLECS_REST
226#define FLECS_PARSER
227#define FLECS_QUERY_DSL
228#define FLECS_SCRIPT
229// #define FLECS_SCRIPT_MATH /**< Math functions for flecs script (may require linking with libm) */
230#define FLECS_SYSTEM
231#define FLECS_STATS
232#define FLECS_TIMER
233#define FLECS_UNITS
234#endif // ifndef FLECS_CUSTOM_BUILD
235
239// #define FLECS_LOW_FOOTPRINT
240#ifdef FLECS_LOW_FOOTPRINT
241#define FLECS_HI_COMPONENT_ID (16)
242#define FLECS_HI_ID_RECORD_ID (16)
243#define FLECS_ENTITY_PAGE_BITS (6)
244#define FLECS_USE_OS_ALLOC
245#define FLECS_DEFAULT_TO_UNCACHED_QUERIES
246#endif
247
258#ifndef FLECS_HI_COMPONENT_ID
259#define FLECS_HI_COMPONENT_ID (256)
260#endif
261
268#ifndef FLECS_HI_ID_RECORD_ID
269#define FLECS_HI_ID_RECORD_ID (1024)
270#endif
271
277#ifndef FLECS_SPARSE_PAGE_BITS
278#define FLECS_SPARSE_PAGE_BITS (6)
279#endif
280
283#ifndef FLECS_ENTITY_PAGE_BITS
284#define FLECS_ENTITY_PAGE_BITS (10)
285#endif
286
291// #define FLECS_USE_OS_ALLOC
292
295#ifndef FLECS_ID_DESC_MAX
296#define FLECS_ID_DESC_MAX (32)
297#endif
298
301#ifndef FLECS_EVENT_DESC_MAX
302#define FLECS_EVENT_DESC_MAX (8)
303#endif
304
307#define FLECS_VARIABLE_COUNT_MAX (64)
308
311#ifndef FLECS_TERM_COUNT_MAX
312#define FLECS_TERM_COUNT_MAX 32
313#endif
314
317#ifndef FLECS_TERM_ARG_COUNT_MAX
318#define FLECS_TERM_ARG_COUNT_MAX (16)
319#endif
320
323#ifndef FLECS_QUERY_VARIABLE_COUNT_MAX
324#define FLECS_QUERY_VARIABLE_COUNT_MAX (64)
325#endif
326
329#ifndef FLECS_QUERY_SCOPE_NESTING_MAX
330#define FLECS_QUERY_SCOPE_NESTING_MAX (8)
331#endif
332
337#ifndef FLECS_DAG_DEPTH_MAX
338#define FLECS_DAG_DEPTH_MAX (128)
339#endif
340
343#include "flecs/private/api_defines.h"
344#include "flecs/datastructures/vec.h" /* Vector datatype */
345#include "flecs/datastructures/sparse.h" /* Sparse set */
346#include "flecs/datastructures/block_allocator.h" /* Block allocator */
347#include "flecs/datastructures/stack_allocator.h" /* Stack allocator */
348#include "flecs/datastructures/map.h" /* Map */
349#include "flecs/datastructures/switch_list.h" /* Switch list */
350#include "flecs/datastructures/allocator.h" /* Allocator */
351#include "flecs/datastructures/strbuf.h" /* String builder */
352#include "flecs/os_api.h" /* Abstraction for operating system functions */
353
354#ifdef __cplusplus
355extern "C" {
356#endif
357
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
546typedef void (*ecs_run_action_t)(
547 ecs_iter_t *it);
548
555typedef void (*ecs_iter_action_t)(
556 ecs_iter_t *it);
557
566 ecs_iter_t *it);
567
574 ecs_iter_t *it);
575
578 ecs_entity_t e1,
579 const void *ptr1,
580 ecs_entity_t e2,
581 const void *ptr2);
582
585 ecs_world_t* world,
586 ecs_table_t* table,
587 ecs_entity_t* entities,
588 void* ptr,
589 int32_t size,
590 int32_t lo,
591 int32_t hi,
592 ecs_order_by_action_t order_by);
593
595typedef uint64_t (*ecs_group_by_action_t)(
596 ecs_world_t *world,
597 ecs_table_t *table,
598 ecs_id_t group_id,
599 void *ctx);
600
602typedef void* (*ecs_group_create_action_t)(
603 ecs_world_t *world,
604 uint64_t group_id,
605 void *group_by_ctx); /* from ecs_query_desc_t */
606
609 ecs_world_t *world,
610 uint64_t group_id,
611 void *group_ctx, /* return value from ecs_group_create_action_t */
612 void *group_by_ctx); /* from ecs_query_desc_t */
613
615typedef void (*ecs_module_action_t)(
616 ecs_world_t *world);
617
619typedef void (*ecs_fini_action_t)(
620 ecs_world_t *world,
621 void *ctx);
622
624typedef void (*ecs_ctx_free_t)(
625 void *ctx);
626
628typedef int (*ecs_compare_action_t)(
629 const void *ptr1,
630 const void *ptr2);
631
633typedef uint64_t (*ecs_hash_value_action_t)(
634 const void *ptr);
635
637typedef void (*ecs_xtor_t)(
638 void *ptr,
639 int32_t count,
640 const ecs_type_info_t *type_info);
641
643typedef void (*ecs_copy_t)(
644 void *dst_ptr,
645 const void *src_ptr,
646 int32_t count,
647 const ecs_type_info_t *type_info);
648
650typedef void (*ecs_move_t)(
651 void *dst_ptr,
652 void *src_ptr,
653 int32_t count,
654 const ecs_type_info_t *type_info);
655
657typedef int (*ecs_cmp_t)(
658 const void *a_ptr,
659 const void *b_ptr,
660 const ecs_type_info_t *type_info);
661
663typedef bool (*ecs_equals_t)(
664 const void *a_ptr,
665 const void *b_ptr,
666 const ecs_type_info_t *type_info);
667
669typedef void (*flecs_poly_dtor_t)(
670 ecs_poly_t *poly);
671
690
701
709
710/* Term id flags */
711
716#define EcsSelf (1llu << 63)
717
722#define EcsUp (1llu << 62)
723
728#define EcsTrav (1llu << 61)
729
734#define EcsCascade (1llu << 60)
735
740#define EcsDesc (1llu << 59)
741
746#define EcsIsVariable (1llu << 58)
747
752#define EcsIsEntity (1llu << 57)
753
758#define EcsIsName (1llu << 56)
759
764#define EcsTraverseFlags (EcsSelf|EcsUp|EcsTrav|EcsCascade|EcsDesc)
765
770#define EcsTermRefFlags (EcsTraverseFlags|EcsIsVariable|EcsIsEntity|EcsIsName)
771
786
808
816 int32_t *sizes;
819 uint64_t bloom_filter;
820 ecs_flags32_t flags;
821 int8_t var_count;
822 int8_t term_count;
823 int8_t field_count;
825 /* Bitmasks for quick field information lookups */
826 ecs_termset_t fixed_fields;
827 ecs_termset_t var_fields;
828 ecs_termset_t static_id_fields;
829 ecs_termset_t data_fields;
830 ecs_termset_t write_fields;
831 ecs_termset_t read_fields;
832 ecs_termset_t row_fields;
834 ecs_termset_t set_fields;
838 char **vars;
840 void *ctx;
847 int32_t eval_count;
848};
849
878
886/* Flags that can be used to check which hooks a type has set */
887#define ECS_TYPE_HOOK_CTOR ECS_CAST(ecs_flags32_t, 1 << 0)
888#define ECS_TYPE_HOOK_DTOR ECS_CAST(ecs_flags32_t, 1 << 1)
889#define ECS_TYPE_HOOK_COPY ECS_CAST(ecs_flags32_t, 1 << 2)
890#define ECS_TYPE_HOOK_MOVE ECS_CAST(ecs_flags32_t, 1 << 3)
891#define ECS_TYPE_HOOK_COPY_CTOR ECS_CAST(ecs_flags32_t, 1 << 4)
892#define ECS_TYPE_HOOK_MOVE_CTOR ECS_CAST(ecs_flags32_t, 1 << 5)
893#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 6)
894#define ECS_TYPE_HOOK_MOVE_DTOR ECS_CAST(ecs_flags32_t, 1 << 7)
895#define ECS_TYPE_HOOK_CMP ECS_CAST(ecs_flags32_t, 1 << 8)
896#define ECS_TYPE_HOOK_EQUALS ECS_CAST(ecs_flags32_t, 1 << 9)
897
898
899/* Flags that can be used to set/check which hooks of a type are invalid */
900#define ECS_TYPE_HOOK_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 10)
901#define ECS_TYPE_HOOK_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 12)
902#define ECS_TYPE_HOOK_COPY_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 13)
903#define ECS_TYPE_HOOK_MOVE_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 14)
904#define ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 15)
905#define ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 16)
906#define ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 17)
907#define ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 18)
908#define ECS_TYPE_HOOK_CMP_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 19)
909#define ECS_TYPE_HOOK_EQUALS_ILLEGAL ECS_CAST(ecs_flags32_t, 1 << 20)
910
911
912/* All valid hook flags */
913#define ECS_TYPE_HOOKS (ECS_TYPE_HOOK_CTOR|ECS_TYPE_HOOK_DTOR|\
914 ECS_TYPE_HOOK_COPY|ECS_TYPE_HOOK_MOVE|ECS_TYPE_HOOK_COPY_CTOR|\
915 ECS_TYPE_HOOK_MOVE_CTOR|ECS_TYPE_HOOK_CTOR_MOVE_DTOR|\
916 ECS_TYPE_HOOK_MOVE_DTOR|ECS_TYPE_HOOK_CMP|ECS_TYPE_HOOK_EQUALS)
917
918/* All invalid hook flags */
919#define ECS_TYPE_HOOKS_ILLEGAL (ECS_TYPE_HOOK_CTOR_ILLEGAL|\
920 ECS_TYPE_HOOK_DTOR_ILLEGAL|ECS_TYPE_HOOK_COPY_ILLEGAL|\
921 ECS_TYPE_HOOK_MOVE_ILLEGAL|ECS_TYPE_HOOK_COPY_CTOR_ILLEGAL|\
922 ECS_TYPE_HOOK_MOVE_CTOR_ILLEGAL|ECS_TYPE_HOOK_CTOR_MOVE_DTOR_ILLEGAL|\
923 ECS_TYPE_HOOK_MOVE_DTOR_ILLEGAL|ECS_TYPE_HOOK_CMP_ILLEGAL|\
924 ECS_TYPE_HOOK_EQUALS_ILLEGAL)
984
996
997#include "flecs/private/api_types.h" /* Supporting API types */
998#include "flecs/private/api_support.h" /* Supporting API functions */
999#include "flecs/datastructures/hashmap.h" /* Hashmap */
1000#include "flecs/private/api_internals.h" /* Supporting API functions */
1001
1007
1012typedef struct ecs_entity_desc_t {
1013 int32_t _canary;
1019 const char *name;
1024 const char *sep;
1028 const char *root_sep;
1030 const char *symbol;
1046
1049
1051 const char *add_expr;
1053
1083
1097
1137 /* World */
1141 /* Matched data */
1142 int32_t offset;
1143 int32_t count;
1145 void **ptrs;
1146 const ecs_table_record_t **trs;
1147 const ecs_size_t *sizes;
1152 ecs_flags64_t constrained_vars;
1153 ecs_termset_t set_fields;
1154 ecs_termset_t ref_fields;
1155 ecs_termset_t row_fields;
1156 ecs_termset_t up_fields;
1158 /* Input information */
1162 int32_t event_cur;
1164 /* Query information */
1166 int8_t term_index;
1171 /* Context */
1172 void *param;
1173 void *ctx;
1176 void *run_ctx;
1178 /* Time */
1182 /* Iterator counters */
1185 /* Misc */
1186 ecs_flags32_t flags;
1188 ecs_iter_private_t priv_;
1190 /* Chained iterators */
1195};
1196
1197
1202#define EcsQueryMatchPrefab (1u << 1u)
1203
1208#define EcsQueryMatchDisabled (1u << 2u)
1209
1214#define EcsQueryMatchEmptyTables (1u << 3u)
1215
1220#define EcsQueryAllowUnresolvedByName (1u << 6u)
1221
1226#define EcsQueryTableOnly (1u << 7u)
1227
1238#define EcsQueryDetectChanges (1u << 8u)
1239
1240
1314
1376
1381typedef struct ecs_event_desc_t {
1384
1389
1392
1396
1398 int32_t offset;
1399
1403 int32_t count;
1404
1407
1412 void *param;
1413
1417 const void *const_param;
1418
1421
1423 ecs_flags32_t flags;
1425
1426
1435typedef struct ecs_build_info_t {
1436 const char *compiler;
1437 const char **addons;
1438 const char *version;
1442 bool debug;
1446
1505
1508 uint64_t id;
1509 int32_t match_count;
1510 int32_t table_count;
1511 void *ctx;
1513
1524typedef struct EcsIdentifier {
1525 char *value;
1526 ecs_size_t length;
1527 uint64_t hash;
1528 uint64_t index_hash;
1529 ecs_hashmap_t *index;
1531
1533typedef struct EcsComponent {
1534 ecs_size_t size;
1535 ecs_size_t alignment;
1537
1542
1551
1555/* Only include deprecated definitions if deprecated addon is required */
1556#ifdef FLECS_DEPRECATED
1558#endif
1559
1575FLECS_API extern const ecs_id_t ECS_PAIR;
1576
1578FLECS_API extern const ecs_id_t ECS_AUTO_OVERRIDE;
1579
1581FLECS_API extern const ecs_id_t ECS_TOGGLE;
1582
1590/* Builtin component ids */
1591
1593FLECS_API extern const ecs_entity_t ecs_id(EcsComponent);
1594
1596FLECS_API extern const ecs_entity_t ecs_id(EcsIdentifier);
1597
1599FLECS_API extern const ecs_entity_t ecs_id(EcsPoly);
1600
1602FLECS_API extern const ecs_entity_t ecs_id(EcsDefaultChildComponent);
1603
1605FLECS_API extern const ecs_entity_t EcsQuery;
1606
1608FLECS_API extern const ecs_entity_t EcsObserver;
1609
1611FLECS_API extern const ecs_entity_t EcsSystem;
1612
1614FLECS_API extern const ecs_entity_t ecs_id(EcsTickSource);
1615
1617FLECS_API extern const ecs_entity_t ecs_id(EcsPipelineQuery);
1618
1620FLECS_API extern const ecs_entity_t ecs_id(EcsTimer);
1621
1623FLECS_API extern const ecs_entity_t ecs_id(EcsRateFilter);
1624
1626FLECS_API extern const ecs_entity_t EcsFlecs;
1627
1629FLECS_API extern const ecs_entity_t EcsFlecsCore;
1630
1632FLECS_API extern const ecs_entity_t EcsWorld;
1633
1635FLECS_API extern const ecs_entity_t EcsWildcard;
1636
1638FLECS_API extern const ecs_entity_t EcsAny;
1639
1641FLECS_API extern const ecs_entity_t EcsThis;
1642
1644FLECS_API extern const ecs_entity_t EcsVariable;
1645
1647#define EcsSingleton EcsVariable
1648
1656FLECS_API extern const ecs_entity_t EcsTransitive;
1657
1665FLECS_API extern const ecs_entity_t EcsReflexive;
1666
1677FLECS_API extern const ecs_entity_t EcsFinal;
1678
1684FLECS_API extern const ecs_entity_t EcsInheritable;
1685
1687FLECS_API extern const ecs_entity_t EcsOnInstantiate;
1688
1692FLECS_API extern const ecs_entity_t EcsOverride;
1693
1697FLECS_API extern const ecs_entity_t EcsInherit;
1698
1703FLECS_API extern const ecs_entity_t EcsDontInherit;
1704
1712FLECS_API extern const ecs_entity_t EcsSymmetric;
1713
1723FLECS_API extern const ecs_entity_t EcsExclusive;
1724
1726FLECS_API extern const ecs_entity_t EcsAcyclic;
1727
1730FLECS_API extern const ecs_entity_t EcsTraversable;
1731
1741FLECS_API extern const ecs_entity_t EcsWith;
1742
1752FLECS_API extern const ecs_entity_t EcsOneOf;
1753
1755FLECS_API extern const ecs_entity_t EcsCanToggle;
1756
1760FLECS_API extern const ecs_entity_t EcsTrait;
1761
1771FLECS_API extern const ecs_entity_t EcsRelationship;
1772
1782FLECS_API extern const ecs_entity_t EcsTarget;
1783
1786FLECS_API extern const ecs_entity_t EcsPairIsTag;
1787
1789FLECS_API extern const ecs_entity_t EcsName;
1790
1792FLECS_API extern const ecs_entity_t EcsSymbol;
1793
1795FLECS_API extern const ecs_entity_t EcsAlias;
1796
1798FLECS_API extern const ecs_entity_t EcsChildOf;
1799
1801FLECS_API extern const ecs_entity_t EcsIsA;
1802
1804FLECS_API extern const ecs_entity_t EcsDependsOn;
1805
1807FLECS_API extern const ecs_entity_t EcsSlotOf;
1808
1810FLECS_API extern const ecs_entity_t EcsOrderedChildren;
1811
1813FLECS_API extern const ecs_entity_t EcsModule;
1814
1816FLECS_API extern const ecs_entity_t EcsPrivate;
1817
1820FLECS_API extern const ecs_entity_t EcsPrefab;
1821
1824FLECS_API extern const ecs_entity_t EcsDisabled;
1825
1829FLECS_API extern const ecs_entity_t EcsNotQueryable;
1830
1832FLECS_API extern const ecs_entity_t EcsOnAdd;
1833
1835FLECS_API extern const ecs_entity_t EcsOnRemove;
1836
1838FLECS_API extern const ecs_entity_t EcsOnSet;
1839
1841FLECS_API extern const ecs_entity_t EcsMonitor;
1842
1844FLECS_API extern const ecs_entity_t EcsOnTableCreate;
1845
1847FLECS_API extern const ecs_entity_t EcsOnTableDelete;
1848
1850FLECS_API extern const ecs_entity_t EcsOnDelete;
1851
1854FLECS_API extern const ecs_entity_t EcsOnDeleteTarget;
1855
1858FLECS_API extern const ecs_entity_t EcsRemove;
1859
1862FLECS_API extern const ecs_entity_t EcsDelete;
1863
1866FLECS_API extern const ecs_entity_t EcsPanic;
1867
1869FLECS_API extern const ecs_entity_t EcsSparse;
1870
1872FLECS_API extern const ecs_entity_t EcsDontFragment;
1873
1875FLECS_API extern const ecs_entity_t EcsUnion;
1876
1878FLECS_API extern const ecs_entity_t EcsPredEq;
1879
1881FLECS_API extern const ecs_entity_t EcsPredMatch;
1882
1884FLECS_API extern const ecs_entity_t EcsPredLookup;
1885
1887FLECS_API extern const ecs_entity_t EcsScopeOpen;
1888
1890FLECS_API extern const ecs_entity_t EcsScopeClose;
1891
1896FLECS_API extern const ecs_entity_t EcsEmpty;
1897
1898FLECS_API extern const ecs_entity_t ecs_id(EcsPipeline);
1899FLECS_API extern const ecs_entity_t EcsOnStart;
1900FLECS_API extern const ecs_entity_t EcsPreFrame;
1901FLECS_API extern const ecs_entity_t EcsOnLoad;
1902FLECS_API extern const ecs_entity_t EcsPostLoad;
1903FLECS_API extern const ecs_entity_t EcsPreUpdate;
1904FLECS_API extern const ecs_entity_t EcsOnUpdate;
1905FLECS_API extern const ecs_entity_t EcsOnValidate;
1906FLECS_API extern const ecs_entity_t EcsPostUpdate;
1907FLECS_API extern const ecs_entity_t EcsPreStore;
1908FLECS_API extern const ecs_entity_t EcsOnStore;
1909FLECS_API extern const ecs_entity_t EcsPostFrame;
1910FLECS_API extern const ecs_entity_t EcsPhase;
1912FLECS_API extern const ecs_entity_t EcsConstant;
1916#define EcsLastInternalComponentId (ecs_id(EcsPoly))
1917
1920#define EcsFirstUserComponentId (8)
1921
1924#define EcsFirstUserEntityId (FLECS_HI_COMPONENT_ID + 128)
1925
1926/* When visualized the reserved id ranges look like this:
1927 * - [1..8]: Builtin components
1928 * - [9..FLECS_HI_COMPONENT_ID]: Low ids reserved for application components
1929 * - [FLECS_HI_COMPONENT_ID + 1..EcsFirstUserEntityId]: Builtin entities
1930 */
1931
1953FLECS_API
1955
1962FLECS_API
1964
1972FLECS_API
1974 int argc,
1975 char *argv[]);
1976
1983FLECS_API
1985 ecs_world_t *world);
1986
1994FLECS_API
1996 const ecs_world_t *world);
1997
2005FLECS_API
2007 ecs_world_t *world,
2008 ecs_fini_action_t action,
2009 void *ctx);
2010
2017
2044FLECS_API
2046 const ecs_world_t *world);
2047
2055FLECS_API
2057 const ecs_world_t *world);
2058
2084FLECS_API
2086 ecs_world_t *world,
2087 ecs_ftime_t delta_time);
2088
2095FLECS_API
2097 ecs_world_t *world);
2098
2106FLECS_API
2108 ecs_world_t *world,
2109 ecs_fini_action_t action,
2110 void *ctx);
2111
2118FLECS_API
2120 ecs_world_t *world);
2121
2128FLECS_API
2130 const ecs_world_t *world);
2131
2144 ecs_world_t *world,
2145 bool enable);
2146
2158 ecs_world_t *world,
2159 bool enable);
2160
2176FLECS_API
2178 ecs_world_t *world,
2179 ecs_ftime_t fps);
2180
2194FLECS_API
2196 ecs_world_t *world,
2197 ecs_flags32_t flags);
2198
2275FLECS_API
2277 ecs_world_t *world,
2278 bool multi_threaded);
2279
2287FLECS_API
2289 ecs_world_t *world);
2290
2301FLECS_API
2303 ecs_world_t *world);
2304
2320FLECS_API
2322 ecs_world_t *world);
2323
2334FLECS_API
2336 const ecs_world_t *world);
2337
2351FLECS_API
2353 ecs_world_t *world);
2354
2369FLECS_API
2371 ecs_world_t *world);
2372
2383FLECS_API
2385 ecs_world_t *world);
2386
2400FLECS_API
2402 ecs_world_t *world,
2403 int32_t stages);
2404
2411FLECS_API
2413 const ecs_world_t *world);
2414
2430FLECS_API
2432 const ecs_world_t *world,
2433 int32_t stage_id);
2434
2442FLECS_API
2444 const ecs_world_t *world);
2445
2453FLECS_API
2455 ecs_world_t *world);
2456
2461FLECS_API
2463 ecs_world_t *stage);
2464
2472FLECS_API
2474 const ecs_world_t *world);
2475
2491FLECS_API
2493 ecs_world_t *world,
2494 void *ctx,
2495 ecs_ctx_free_t ctx_free);
2496
2505FLECS_API
2507 ecs_world_t *world,
2508 void *ctx,
2509 ecs_ctx_free_t ctx_free);
2510
2518FLECS_API
2520 const ecs_world_t *world);
2521
2529FLECS_API
2531 const ecs_world_t *world);
2532
2538FLECS_API
2540
2546FLECS_API
2548 const ecs_world_t *world);
2549
2558FLECS_API
2560 ecs_world_t *world,
2561 int32_t entity_count);
2562
2577FLECS_API
2579 ecs_world_t *world);
2580
2596FLECS_API
2598 ecs_world_t *world,
2599 ecs_entity_t id_start,
2600 ecs_entity_t id_end);
2601
2612FLECS_API
2614 ecs_world_t *world,
2615 bool enable);
2616
2622FLECS_API
2624 const ecs_world_t *world);
2625
2639FLECS_API
2641 ecs_world_t *world,
2642 ecs_flags32_t flags);
2643
2655
2685FLECS_API
2687 ecs_world_t *world,
2688 const ecs_delete_empty_tables_desc_t *desc);
2689
2695FLECS_API
2697 const ecs_poly_t *poly);
2698
2704FLECS_API
2706 const ecs_poly_t *poly);
2707
2721FLECS_API
2723 const ecs_poly_t *object,
2724 int32_t type);
2725
2729#define flecs_poly_is(object, type)\
2730 flecs_poly_is_(object, type##_magic)
2731
2740FLECS_API
2742 ecs_entity_t first,
2743 ecs_entity_t second);
2744
2767FLECS_API
2769 ecs_world_t *world,
2770 const char *thread_name);
2771
2794FLECS_API
2796 ecs_world_t *world,
2797 bool lock_world);
2798
2825FLECS_API
2827 ecs_world_t *world);
2828
2846FLECS_API
2848 ecs_world_t *world);
2849
2858FLECS_API
2860 ecs_world_t *world,
2861 ecs_id_t id);
2862
2870FLECS_API
2872 ecs_world_t *world,
2873 ecs_table_t *table);
2874
2893FLECS_API
2895 ecs_world_t *world,
2896 const ecs_entity_desc_t *desc);
2897
2924FLECS_API
2926 ecs_world_t *world,
2927 const ecs_bulk_desc_t *desc);
2928
2938FLECS_API
2940 ecs_world_t *world,
2941 ecs_id_t id,
2942 int32_t count);
2943
2959FLECS_API
2961 ecs_world_t *world,
2962 ecs_entity_t dst,
2963 ecs_entity_t src,
2964 bool copy_value);
2965
2974FLECS_API
2976 ecs_world_t *world,
2977 ecs_entity_t entity);
2978
2986FLECS_API
2988 ecs_world_t *world,
2989 ecs_id_t id);
2990
3008FLECS_API
3010 ecs_world_t *world,
3011 ecs_entity_t parent,
3012 const ecs_entity_t *children,
3013 int32_t child_count);
3014
3032FLECS_API
3034 ecs_world_t *world,
3035 ecs_entity_t entity,
3036 ecs_id_t id);
3037
3046FLECS_API
3048 ecs_world_t *world,
3049 ecs_entity_t entity,
3050 ecs_id_t id);
3051
3103FLECS_API
3105 ecs_world_t *world,
3106 ecs_entity_t entity,
3107 ecs_id_t id);
3108
3115FLECS_API
3117 ecs_world_t *world,
3118 ecs_entity_t entity);
3119
3127FLECS_API
3129 ecs_world_t *world,
3130 ecs_id_t id);
3131
3139FLECS_API
3141 ecs_world_t *world,
3142 ecs_id_t id);
3143
3150FLECS_API
3152 const ecs_world_t *world);
3153
3172FLECS_API
3174 ecs_world_t *world,
3175 ecs_entity_t entity,
3176 bool enabled);
3177
3191FLECS_API
3193 ecs_world_t *world,
3194 ecs_entity_t entity,
3195 ecs_id_t id,
3196 bool enable);
3197
3208FLECS_API
3210 const ecs_world_t *world,
3211 ecs_entity_t entity,
3212 ecs_id_t id);
3213
3237FLECS_API
3238FLECS_ALWAYS_INLINE const void* ecs_get_id(
3239 const ecs_world_t *world,
3240 ecs_entity_t entity,
3241 ecs_id_t id);
3242
3254FLECS_API
3255FLECS_ALWAYS_INLINE void* ecs_get_mut_id(
3256 const ecs_world_t *world,
3257 ecs_entity_t entity,
3258 ecs_id_t id);
3259
3277FLECS_API
3279 ecs_world_t *world,
3280 ecs_entity_t entity,
3281 ecs_id_t id);
3282
3294FLECS_API
3296 ecs_world_t *world,
3297 ecs_entity_t entity,
3298 ecs_id_t id);
3299
3310FLECS_API
3312 const ecs_world_t *world,
3313 ecs_entity_t entity,
3314 ecs_id_t id);
3315
3324FLECS_API
3326 const ecs_world_t *world,
3327 ecs_ref_t *ref,
3328 ecs_id_t id);
3329
3337FLECS_API
3339 const ecs_world_t *world,
3340 ecs_ref_t *ref);
3341
3361FLECS_API
3363 ecs_world_t *world,
3364 ecs_entity_t entity,
3365 ecs_id_t id,
3366 bool *is_new);
3367
3377FLECS_API
3379 ecs_world_t *world,
3380 ecs_entity_t entity,
3381 ecs_id_t id);
3382
3398FLECS_API
3400 ecs_world_t *world,
3401 ecs_entity_t entity,
3402 ecs_id_t id,
3403 size_t size,
3404 const void *ptr);
3405
3433FLECS_API
3435 const ecs_world_t *world,
3436 ecs_entity_t e);
3437
3463FLECS_API
3465 const ecs_world_t *world,
3466 ecs_entity_t e);
3467
3473FLECS_API
3475 ecs_entity_t e);
3476
3493FLECS_API
3495 const ecs_world_t *world,
3496 ecs_entity_t e);
3497
3520FLECS_API
3522 ecs_world_t *world,
3523 ecs_entity_t entity);
3524
3543FLECS_API
3545 ecs_world_t *world,
3546 ecs_id_t id);
3547
3555FLECS_API
3557 const ecs_world_t *world,
3558 ecs_entity_t entity);
3559
3574FLECS_API
3576 ecs_world_t *world,
3577 ecs_entity_t entity);
3578
3594FLECS_API
3596 const ecs_world_t *world,
3597 ecs_entity_t entity);
3598
3605FLECS_API
3607 const ecs_world_t *world,
3608 ecs_entity_t entity);
3609
3617FLECS_API
3619 const ecs_world_t *world,
3620 const ecs_type_t* type);
3621
3633FLECS_API
3635 const ecs_world_t *world,
3636 const ecs_table_t *table);
3637
3652FLECS_API
3654 const ecs_world_t *world,
3655 ecs_entity_t entity);
3656
3667FLECS_API
3668FLECS_ALWAYS_INLINE bool ecs_has_id(
3669 const ecs_world_t *world,
3670 ecs_entity_t entity,
3671 ecs_id_t id);
3672
3683FLECS_API
3684FLECS_ALWAYS_INLINE bool ecs_owns_id(
3685 const ecs_world_t *world,
3686 ecs_entity_t entity,
3687 ecs_id_t id);
3688
3703FLECS_API
3705 const ecs_world_t *world,
3706 ecs_entity_t entity,
3707 ecs_entity_t rel,
3708 int32_t index);
3709
3723FLECS_API
3725 const ecs_world_t *world,
3726 ecs_entity_t entity);
3727
3748FLECS_API
3750 const ecs_world_t *world,
3751 ecs_entity_t entity,
3752 ecs_entity_t rel,
3753 ecs_id_t id);
3754
3765FLECS_API
3767 const ecs_world_t *world,
3768 ecs_entity_t entity,
3769 ecs_entity_t rel);
3770
3778FLECS_API
3780 const ecs_world_t *world,
3781 ecs_id_t entity);
3782
3802FLECS_API
3803const char* ecs_get_name(
3804 const ecs_world_t *world,
3805 ecs_entity_t entity);
3806
3816FLECS_API
3817const char* ecs_get_symbol(
3818 const ecs_world_t *world,
3819 ecs_entity_t entity);
3820
3834FLECS_API
3836 ecs_world_t *world,
3837 ecs_entity_t entity,
3838 const char *name);
3839
3853FLECS_API
3855 ecs_world_t *world,
3856 ecs_entity_t entity,
3857 const char *symbol);
3858
3870FLECS_API
3872 ecs_world_t *world,
3873 ecs_entity_t entity,
3874 const char *alias);
3875
3891FLECS_API
3893 const ecs_world_t *world,
3894 const char *path);
3895
3910FLECS_API
3912 const ecs_world_t *world,
3913 ecs_entity_t parent,
3914 const char *name);
3915
3938FLECS_API
3940 const ecs_world_t *world,
3941 ecs_entity_t parent,
3942 const char *path,
3943 const char *sep,
3944 const char *prefix,
3945 bool recursive);
3946
3964FLECS_API
3966 const ecs_world_t *world,
3967 const char *symbol,
3968 bool lookup_as_path,
3969 bool recursive);
3970
3992FLECS_API
3994 const ecs_world_t *world,
3995 ecs_entity_t parent,
3996 ecs_entity_t child,
3997 const char *sep,
3998 const char *prefix);
3999
4012FLECS_API
4014 const ecs_world_t *world,
4015 ecs_entity_t parent,
4016 ecs_entity_t child,
4017 const char *sep,
4018 const char *prefix,
4019 ecs_strbuf_t *buf,
4020 bool escape);
4021
4037FLECS_API
4039 ecs_world_t *world,
4040 ecs_entity_t parent,
4041 const char *path,
4042 const char *sep,
4043 const char *prefix);
4044
4059FLECS_API
4061 ecs_world_t *world,
4062 ecs_entity_t entity,
4063 ecs_entity_t parent,
4064 const char *path,
4065 const char *sep,
4066 const char *prefix);
4067
4081FLECS_API
4083 ecs_world_t *world,
4084 ecs_entity_t scope);
4085
4093FLECS_API
4095 const ecs_world_t *world);
4096
4106FLECS_API
4108 ecs_world_t *world,
4109 const char *prefix);
4110
4137FLECS_API
4139 ecs_world_t *world,
4140 const ecs_entity_t *lookup_path);
4141
4148FLECS_API
4150 const ecs_world_t *world);
4151
4176FLECS_API
4178 ecs_world_t *world,
4179 const ecs_component_desc_t *desc);
4180
4190FLECS_API
4192 const ecs_world_t *world,
4193 ecs_id_t id);
4194
4206FLECS_API
4208 ecs_world_t *world,
4209 ecs_entity_t id,
4210 const ecs_type_hooks_t *hooks);
4211
4218FLECS_API
4220 const ecs_world_t *world,
4221 ecs_entity_t id);
4222
4246FLECS_API
4248 const ecs_world_t *world,
4249 ecs_id_t id);
4250
4259FLECS_API
4261 const ecs_world_t *world,
4262 ecs_id_t id);
4263
4283FLECS_API
4285 const ecs_world_t *world,
4286 ecs_id_t id);
4287
4296FLECS_API
4298 ecs_id_t id,
4299 ecs_id_t pattern);
4300
4306FLECS_API
4308 ecs_id_t id);
4309
4315FLECS_API
4317 ecs_id_t id);
4318
4325 ecs_id_t id);
4326
4340FLECS_API
4342 const ecs_world_t *world,
4343 ecs_id_t id);
4344
4353FLECS_API
4354ecs_flags32_t ecs_id_get_flags(
4355 const ecs_world_t *world,
4356 ecs_id_t id);
4357
4364FLECS_API
4366 ecs_id_t id_flags);
4367
4375FLECS_API
4377 const ecs_world_t *world,
4378 ecs_id_t id);
4379
4387FLECS_API
4389 const ecs_world_t *world,
4390 ecs_id_t id,
4391 ecs_strbuf_t *buf);
4392
4400FLECS_API
4402 const ecs_world_t *world,
4403 const char *expr);
4404
4418FLECS_API
4420 const ecs_term_ref_t *id);
4421
4433FLECS_API
4435 const ecs_term_t *term);
4436
4451FLECS_API
4453 const ecs_term_t *term);
4454
4467FLECS_API
4469 const ecs_term_t *term);
4470
4479FLECS_API
4481 const ecs_world_t *world,
4482 const ecs_term_t *term);
4483
4491FLECS_API
4493 const ecs_query_t *query);
4494
4535FLECS_API
4537 const ecs_world_t *world,
4538 ecs_id_t id);
4539
4545FLECS_API
4547 ecs_iter_t *it);
4548
4565FLECS_API
4567 const ecs_world_t *world,
4568 ecs_entity_t parent);
4569
4575FLECS_API
4577 ecs_iter_t *it);
4578
4594FLECS_API
4596 ecs_world_t *world,
4597 const ecs_query_desc_t *desc);
4598
4603FLECS_API
4605 ecs_query_t *query);
4606
4615FLECS_API
4617 const ecs_query_t *query,
4618 const char *name);
4619
4627FLECS_API
4629 const ecs_query_t *query,
4630 int32_t var_id);
4631
4642FLECS_API
4644 const ecs_query_t *query,
4645 int32_t var_id);
4646
4715FLECS_API
4717 const ecs_world_t *world,
4718 const ecs_query_t *query);
4719
4727FLECS_API
4729 ecs_iter_t *it);
4730
4749FLECS_API
4751 ecs_query_t *query,
4752 ecs_entity_t entity,
4753 ecs_iter_t *it);
4754
4773FLECS_API
4775 ecs_query_t *query,
4776 ecs_table_t *table,
4777 ecs_iter_t *it);
4778
4805FLECS_API
4807 ecs_query_t *query,
4808 ecs_table_range_t *range,
4809 ecs_iter_t *it);
4810
4818FLECS_API
4820 const ecs_query_t *query);
4821
4831FLECS_API
4833 const ecs_query_t *query);
4834
4849FLECS_API
4851 const ecs_query_t *query,
4852 const ecs_iter_t *it);
4853
4871FLECS_API
4873 ecs_query_t *query,
4874 ecs_iter_t *it,
4875 const char *expr);
4876
4904FLECS_API
4906 ecs_query_t *query);
4907
4916FLECS_API
4918 const ecs_world_t *world,
4919 ecs_entity_t query);
4920
4931FLECS_API
4933 ecs_iter_t *it);
4934
4957FLECS_API
4959 ecs_iter_t *it,
4960 uint64_t group_id);
4961
4970FLECS_API
4972 const ecs_query_t *query,
4973 uint64_t group_id);
4974
4983FLECS_API
4985 const ecs_query_t *query,
4986 uint64_t group_id);
4987
4995
5002FLECS_API
5004 const ecs_query_t *query);
5005
5011FLECS_API
5013 const ecs_query_t *query);
5014
5023FLECS_API
5025 const ecs_query_t *query);
5026
5055FLECS_API
5057 ecs_world_t *world,
5058 ecs_event_desc_t *desc);
5059
5070FLECS_API
5072 ecs_world_t *world,
5073 ecs_event_desc_t *desc);
5074
5085FLECS_API
5087 ecs_world_t *world,
5088 const ecs_observer_desc_t *desc);
5089
5098FLECS_API
5100 const ecs_world_t *world,
5101 ecs_entity_t observer);
5102
5125FLECS_API
5127 ecs_iter_t *it);
5128
5138FLECS_API
5140 ecs_iter_t *it);
5141
5153FLECS_API
5155 ecs_iter_t *it);
5156
5169FLECS_API
5171 ecs_iter_t *it);
5172
5180FLECS_API
5182 ecs_iter_t *it);
5183
5222FLECS_API
5224 ecs_iter_t *it,
5225 int32_t var_id,
5226 ecs_entity_t entity);
5227
5238FLECS_API
5240 ecs_iter_t *it,
5241 int32_t var_id,
5242 const ecs_table_t *table);
5243
5254FLECS_API
5256 ecs_iter_t *it,
5257 int32_t var_id,
5258 const ecs_table_range_t *range);
5259
5272FLECS_API
5274 ecs_iter_t *it,
5275 int32_t var_id);
5276
5283FLECS_API
5285 const ecs_iter_t *it,
5286 int32_t var_id);
5287
5293FLECS_API
5295 const ecs_iter_t *it);
5296
5302FLECS_API
5304 const ecs_iter_t *it);
5305
5319FLECS_API
5321 ecs_iter_t *it,
5322 int32_t var_id);
5323
5337FLECS_API
5339 ecs_iter_t *it,
5340 int32_t var_id);
5341
5353FLECS_API
5355 ecs_iter_t *it,
5356 int32_t var_id);
5357
5369FLECS_API
5371 const ecs_iter_t *it);
5372
5384FLECS_API
5386 ecs_iter_t *it);
5387
5399FLECS_API
5401 const ecs_iter_t *it);
5402
5418FLECS_API
5420 const ecs_iter_t *it,
5421 int32_t offset,
5422 int32_t limit);
5423
5430FLECS_API
5432 ecs_iter_t *it);
5433
5454FLECS_API
5456 const ecs_iter_t *it,
5457 int32_t index,
5458 int32_t count);
5459
5466FLECS_API
5468 ecs_iter_t *it);
5469
5511FLECS_API
5513 const ecs_iter_t *it,
5514 size_t size,
5515 int8_t index);
5516
5538FLECS_API
5540 const ecs_iter_t *it,
5541 size_t size,
5542 int8_t index,
5543 int32_t row);
5544
5553FLECS_API
5555 const ecs_iter_t *it,
5556 int8_t index);
5557
5568FLECS_API
5570 const ecs_iter_t *it,
5571 int8_t index);
5572
5579FLECS_API
5581 const ecs_iter_t *it,
5582 int8_t index);
5583
5590FLECS_API
5592 const ecs_iter_t *it,
5593 int8_t index);
5594
5603FLECS_API
5605 const ecs_iter_t *it,
5606 int8_t index);
5607
5615FLECS_API
5617 const ecs_iter_t *it,
5618 int8_t index);
5619
5627FLECS_API
5629 const ecs_iter_t *it,
5630 int8_t index);
5631
5645FLECS_API
5647 const ecs_iter_t *it,
5648 int8_t index);
5649
5665FLECS_API
5667 const ecs_table_t *table);
5668
5679FLECS_API
5681 const ecs_world_t *world,
5682 const ecs_table_t *table,
5683 ecs_id_t id);
5684
5694FLECS_API
5696 const ecs_world_t *world,
5697 const ecs_table_t *table,
5698 ecs_id_t id);
5699
5707FLECS_API
5709 const ecs_table_t *table);
5710
5724FLECS_API
5726 const ecs_table_t *table,
5727 int32_t index);
5728
5737FLECS_API
5739 const ecs_table_t *table,
5740 int32_t index);
5741
5750FLECS_API
5752 const ecs_table_t *table,
5753 int32_t index,
5754 int32_t offset);
5755
5765FLECS_API
5767 const ecs_world_t *world,
5768 const ecs_table_t *table,
5769 ecs_id_t id,
5770 int32_t offset);
5771
5779FLECS_API
5781 const ecs_table_t *table,
5782 int32_t index);
5783
5790FLECS_API
5792 const ecs_table_t *table);
5793
5801FLECS_API
5803 const ecs_table_t *table);
5804
5811FLECS_API
5813 const ecs_table_t *table);
5814
5825FLECS_API
5827 const ecs_world_t *world,
5828 const ecs_table_t *table,
5829 ecs_id_t id);
5830
5841FLECS_API
5843 const ecs_world_t *world,
5844 const ecs_table_t *table,
5845 ecs_entity_t rel);
5846
5856FLECS_API
5858 ecs_world_t *world,
5859 ecs_table_t *table,
5860 ecs_id_t id);
5861
5872FLECS_API
5874 ecs_world_t *world,
5875 const ecs_id_t *ids,
5876 int32_t id_count);
5877
5887FLECS_API
5889 ecs_world_t *world,
5890 ecs_table_t *table,
5891 ecs_id_t id);
5892
5908FLECS_API
5910 ecs_world_t *world,
5911 ecs_table_t *table);
5912
5919FLECS_API
5921 ecs_world_t *world,
5922 ecs_table_t *table);
5923
5933FLECS_API
5935 ecs_table_t *table,
5936 ecs_flags32_t flags);
5937
5945FLECS_API
5947 ecs_world_t* world,
5948 ecs_table_t* table,
5949 int32_t row_1,
5950 int32_t row_2);
5951
5974FLECS_API
5976 ecs_world_t *world,
5977 ecs_entity_t entity,
5978 ecs_record_t *record,
5979 ecs_table_t *table,
5980 const ecs_type_t *added,
5981 const ecs_type_t *removed);
5982
5983
6002FLECS_API
6004 const ecs_world_t *world,
6005 const ecs_table_t *table,
6006 ecs_id_t id,
6007 ecs_id_t *id_out);
6008
6044FLECS_API
6046 const ecs_world_t *world,
6047 const ecs_table_t *table,
6048 int32_t offset,
6049 ecs_id_t id,
6050 ecs_id_t *id_out);
6051
6093FLECS_API
6095 const ecs_world_t *world,
6096 const ecs_table_t *table,
6097 int32_t offset,
6098 ecs_id_t id,
6099 ecs_entity_t rel,
6100 ecs_flags64_t flags, /* EcsSelf and/or EcsUp */
6101 ecs_entity_t *subject_out,
6102 ecs_id_t *id_out,
6103 struct ecs_table_record_t **tr_out);
6104
6112FLECS_API
6114 ecs_world_t* world,
6115 ecs_table_t* table);
6116
6133FLECS_API
6135 const ecs_world_t *world,
6136 ecs_entity_t type,
6137 void *ptr);
6138
6146FLECS_API
6148 const ecs_world_t *world,
6149 const ecs_type_info_t *ti,
6150 void *ptr);
6151
6158FLECS_API
6160 ecs_world_t *world,
6161 ecs_entity_t type);
6162
6170 ecs_world_t *world,
6171 const ecs_type_info_t *ti);
6172
6181 const ecs_world_t *world,
6182 const ecs_type_info_t *ti,
6183 void *ptr);
6184
6192FLECS_API
6194 const ecs_world_t *world,
6195 ecs_entity_t type,
6196 void* ptr);
6197
6205FLECS_API
6207 ecs_world_t *world,
6208 ecs_entity_t type,
6209 void* ptr);
6210
6219FLECS_API
6221 const ecs_world_t *world,
6222 const ecs_type_info_t *ti,
6223 void* dst,
6224 const void *src);
6225
6234FLECS_API
6236 const ecs_world_t *world,
6237 ecs_entity_t type,
6238 void* dst,
6239 const void *src);
6240
6250 const ecs_world_t *world,
6251 const ecs_type_info_t *ti,
6252 void* dst,
6253 void *src);
6254
6264 const ecs_world_t *world,
6265 ecs_entity_t type,
6266 void* dst,
6267 void *src);
6268
6278 const ecs_world_t *world,
6279 const ecs_type_info_t *ti,
6280 void* dst,
6281 void *src);
6282
6292 const ecs_world_t *world,
6293 ecs_entity_t type,
6294 void* dst,
6295 void *src);
6296
6310#include "flecs/addons/flecs_c.h"
6311
6312#ifdef __cplusplus
6313}
6314#endif
6315
6316#include "flecs/private/addons.h"
6317
6318#endif
The deprecated addon contains deprecated operations.
Extends the core API with convenience macros for C applications.
ecs_entity_t ecs_set_with(ecs_world_t *world, ecs_id_t id)
Set current with id.
void ecs_add_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Add a (component) id to an entity.
void ecs_remove_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Remove a (component) id from an entity.
void ecs_clear(ecs_world_t *world, ecs_entity_t entity)
Clear all components.
ecs_id_t ecs_get_with(const ecs_world_t *world)
Get current with id.
void ecs_remove_all(ecs_world_t *world, ecs_id_t id)
Remove all instances of the specified (component) id.
void ecs_auto_override_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Add auto override for (component) id.
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 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 EcsPrivate
Tag to indicate an entity/component/system is private to a module.
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 EcsUnion
Mark relationship as union.
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 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 *world)
Merge world or 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.
ecs_entity_t ecs_component_init(ecs_world_t *world, const ecs_component_desc_t *desc)
Find or create a component.
void ecs_set_hooks_id(ecs_world_t *world, ecs_entity_t id, const ecs_type_hooks_t *hooks)
Register hooks for component.
struct ecs_component_desc_t ecs_component_desc_t
Used with ecs_component_init().
const ecs_type_info_t * ecs_get_type_info(const ecs_world_t *world, ecs_id_t id)
Get the type for an id.
const ecs_type_hooks_t * ecs_get_hooks_id(const ecs_world_t *world, ecs_entity_t id)
Get 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.
ecs_entity_t ecs_new_w_id(ecs_world_t *world, ecs_id_t id)
Create new entity with (component) 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.
const ecs_entity_t * ecs_bulk_new_w_id(ecs_world_t *world, ecs_id_t id, int32_t count)
Create N new entities.
ecs_entity_t ecs_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_with(ecs_world_t *world, ecs_id_t id)
Delete all entities with the specified id.
void ecs_delete(ecs_world_t *world, ecs_entity_t entity)
Delete an entity.
ecs_entity_t ecs_new_w_table(ecs_world_t *world, ecs_table_t *table)
Create new entity in table.
bool ecs_children_next(ecs_iter_t *it)
Progress an iterator created with ecs_children().
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_each_id(const ecs_world_t *world, ecs_id_t id)
Iterate all entities with specified (component id).
bool ecs_is_enabled_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Test if component is enabled.
void ecs_enable_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, bool enable)
Enable or disable component.
void ecs_enable(ecs_world_t *world, ecs_entity_t entity, bool enabled)
Enable or disable entity.
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.
const ecs_type_t * ecs_get_type(const ecs_world_t *world, ecs_entity_t entity)
Get the type of an entity.
bool ecs_has_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Test if an entity has an id.
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.
bool ecs_owns_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Test if an entity owns an 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_entity_t ecs_get_target_for_id(const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel, ecs_id_t id)
Get the target of a relationship for a given id.
ecs_table_t * ecs_get_table(const ecs_world_t *world, ecs_entity_t entity)
Get the table of an entity.
void(* ecs_module_action_t)(ecs_world_t *world)
Initialization action for modules.
Definition flecs.h:615
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:595
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:657
uint64_t(* ecs_hash_value_action_t)(const void *ptr)
Callback used for hashing values.
Definition flecs.h:633
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:608
void(* ecs_iter_fini_action_t)(ecs_iter_t *it)
Function prototype for freeing an iterator.
Definition flecs.h:573
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:602
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:584
bool(* ecs_iter_next_action_t)(ecs_iter_t *it)
Function prototype for iterating an iterator.
Definition flecs.h:565
void(* ecs_iter_action_t)(ecs_iter_t *it)
Function prototype for iterables.
Definition flecs.h:555
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:643
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:663
int(* ecs_compare_action_t)(const void *ptr1, const void *ptr2)
Callback used for sorting values.
Definition flecs.h:628
void(* ecs_fini_action_t)(ecs_world_t *world, void *ctx)
Action callback on world exit.
Definition flecs.h:619
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:650
void(* flecs_poly_dtor_t)(ecs_poly_t *poly)
Destructor function for poly objects.
Definition flecs.h:669
void(* ecs_run_action_t)(ecs_iter_t *it)
Function prototype for runnables (systems, observers).
Definition flecs.h:546
void(* ecs_ctx_free_t)(void *ctx)
Function to cleanup context data.
Definition flecs.h:624
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:577
void(* ecs_xtor_t)(void *ptr, int32_t count, const ecs_type_info_t *type_info)
Constructor/destructor callback.
Definition flecs.h:637
void * ecs_get_mut_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Get a mutable pointer to a component.
ecs_ref_t ecs_ref_init_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Create a component ref.
void ecs_ref_update(const ecs_world_t *world, ecs_ref_t *ref)
Update ref.
void * ecs_emplace_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, bool *is_new)
Emplace a component.
void * ecs_ensure_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Get a mutable pointer to a component.
void ecs_set_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, size_t size, const void *ptr)
Set the value of a component.
void * ecs_ensure_modified_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Combines ensure + modified in single operation.
void * ecs_ref_get_id(const ecs_world_t *world, ecs_ref_t *ref, ecs_id_t id)
Get component from ref.
const void * ecs_get_id(const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Get an immutable pointer to a component.
void ecs_modified_id(ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
Signal that a component has been modified.
const ecs_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.
bool ecs_id_is_valid(const ecs_world_t *world, ecs_id_t id)
Utility to check if id is valid.
bool ecs_id_is_pair(ecs_id_t id)
Utility to check if id is a pair.
ecs_entity_t ecs_get_typeid(const ecs_world_t *world, ecs_id_t id)
Get the type for an id.
bool ecs_id_match(ecs_id_t id, ecs_id_t pattern)
Utility to match an id with a pattern.
const char * ecs_id_flag_str(ecs_id_t id_flags)
Convert id flag to string.
bool ecs_id_in_use(const ecs_world_t *world, ecs_id_t id)
Returns whether specified id is in use.
bool ecs_id_is_tag(const ecs_world_t *world, ecs_id_t id)
Returns whether specified id a tag.
void ecs_id_str_buf(const ecs_world_t *world, ecs_id_t id, ecs_strbuf_t *buf)
Write (component) id string to buffer.
char * ecs_id_str(const ecs_world_t *world, ecs_id_t id)
Convert (component) id to string.
bool ecs_id_is_any(ecs_id_t id)
Utility to check if id is an any wildcard.
bool ecs_id_is_wildcard(ecs_id_t id)
Utility to check if id is a wildcard.
ecs_id_t ecs_id_from_str(const ecs_world_t *world, const char *expr)
Convert string to a (component) id.
ecs_flags32_t ecs_id_get_flags(const ecs_world_t *world, ecs_id_t id)
Get flags associated with id.
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.
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.
void ecs_make_alive_id(ecs_world_t *world, ecs_id_t id)
Same as ecs_make_alive(), but for (component) ids.
ecs_entity_t ecs_get_alive(const ecs_world_t *world, ecs_entity_t e)
Get alive identifier.
bool ecs_exists(const ecs_world_t *world, ecs_entity_t entity)
Test whether an entity exists.
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:302
#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:296
#define FLECS_TERM_COUNT_MAX
Maximum number of terms in queries.
Definition flecs.h:312
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.
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_has(ecs_query_t *query, ecs_entity_t entity, ecs_iter_t *it)
Match entity with query.
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.
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.
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.
bool ecs_query_has_range(ecs_query_t *query, ecs_table_range_t *range, ecs_iter_t *it)
Match range with query.
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.
bool ecs_query_has_table(ecs_query_t *query, ecs_table_t *table, ecs_iter_t *it)
Match table with query.
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.
bool ecs_term_ref_is_set(const ecs_term_ref_t *id)
Test whether term id is set.
bool ecs_term_is_initialized(const ecs_term_t *term)
Test whether a term 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:703
ecs_inout_kind_t
Specify read/write access for term.
Definition flecs.h:682
ecs_oper_kind_t
Specify operator for term.
Definition flecs.h:692
@ EcsQueryCacheAll
Require that all query terms can be cached.
Definition flecs.h:706
@ EcsQueryCacheDefault
Behavior determined by query creation context.
Definition flecs.h:704
@ EcsQueryCacheNone
No caching.
Definition flecs.h:707
@ EcsQueryCacheAuto
Cache query terms that are cacheable.
Definition flecs.h:705
@ EcsOut
Term is only written.
Definition flecs.h:688
@ EcsInOut
Term is both read and written.
Definition flecs.h:686
@ EcsInOutFilter
Same as InOutNone + prevents term from triggering observers.
Definition flecs.h:685
@ EcsInOutDefault
InOut for regular terms, In for shared terms.
Definition flecs.h:683
@ EcsInOutNone
Term is neither read nor written.
Definition flecs.h:684
@ EcsIn
Term is only read.
Definition flecs.h:687
@ EcsNot
The term must not match.
Definition flecs.h:695
@ EcsOptional
The term may match.
Definition flecs.h:696
@ EcsOr
One of the terms in an or chain must match.
Definition flecs.h:694
@ EcsOrFrom
Term must match at least one component from term id.
Definition flecs.h:698
@ EcsAnd
The term must match.
Definition flecs.h:693
@ EcsNotFrom
Term must match none of the components from term id.
Definition flecs.h:699
@ EcsAndFrom
Term must match all components from term id.
Definition flecs.h:697
ecs_table_t * ecs_table_add_id(ecs_world_t *world, ecs_table_t *table, ecs_id_t id)
Get table that has all components of current table plus the specified id.
int32_t ecs_search(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t id, ecs_id_t *id_out)
Search for component id in table type.
const ecs_type_t * ecs_table_get_type(const ecs_table_t *table)
Get type for table.
int32_t ecs_search_offset(const ecs_world_t *world, const ecs_table_t *table, int32_t offset, ecs_id_t id, ecs_id_t *id_out)
Search for component id in table type starting from an offset.
int32_t ecs_table_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.
void * ecs_table_get_column(const ecs_table_t *table, int32_t index, int32_t offset)
Get column from table by column index.
bool ecs_table_has_id(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t id)
Test if table has id.
ecs_table_t * ecs_table_remove_id(ecs_world_t *world, ecs_table_t *table, ecs_id_t id)
Get table that has all components of current table minus the specified id.
int32_t ecs_table_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.
int32_t ecs_table_get_depth(const ecs_world_t *world, const ecs_table_t *table, ecs_entity_t rel)
Return depth for table in tree for relationship rel.
void * ecs_table_get_id(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t id, int32_t offset)
Get column from table by component id.
void ecs_table_swap_rows(ecs_world_t *world, ecs_table_t *table, int32_t row_1, int32_t row_2)
Swaps two elements inside the table.
int32_t ecs_table_get_column_index(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t id)
Get column index for id.
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.
int32_t ecs_table_get_type_index(const ecs_world_t *world, const ecs_table_t *table, ecs_id_t id)
Get type index for id.
size_t ecs_table_get_column_size(const ecs_table_t *table, int32_t index)
Get column size from table.
void ecs_table_clear_entities(ecs_world_t *world, ecs_table_t *table)
Remove all entities in a table.
int32_t ecs_search_relation(const ecs_world_t *world, const ecs_table_t *table, int32_t offset, ecs_id_t id, ecs_entity_t rel, ecs_flags64_t flags, ecs_entity_t *subject_out, ecs_id_t *id_out, struct ecs_table_record_t **tr_out)
Search for component/relationship id in table type starting from an offset.
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:1533
ecs_size_t size
Component size.
Definition flecs.h:1534
ecs_size_t alignment
Component alignment.
Definition flecs.h:1535
When added to an entity this informs serialization formats which component to use when a value is ass...
Definition flecs.h:1548
ecs_id_t component
Default component id.
Definition flecs.h:1549
A (string) identifier.
Definition flecs.h:1524
ecs_size_t length
Length of identifier.
Definition flecs.h:1526
char * value
Identifier string.
Definition flecs.h:1525
ecs_hashmap_t * index
Current index.
Definition flecs.h:1529
uint64_t hash
Hash of current value.
Definition flecs.h:1527
uint64_t index_hash
Hash of existing record in current index.
Definition flecs.h:1528
Component for storing a poly object.
Definition flecs.h:1539
ecs_poly_t * poly
Pointer to poly object.
Definition flecs.h:1540
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:1435
int16_t version_major
Major flecs version.
Definition flecs.h:1439
const char ** addons
Addons included in build.
Definition flecs.h:1437
const char * version
Stringified version.
Definition flecs.h:1438
const char * compiler
Compiler used to compile flecs.
Definition flecs.h:1436
bool sanitize
Is this a sanitize build.
Definition flecs.h:1443
bool perf_trace
Is this a perf tracing build.
Definition flecs.h:1444
int16_t version_minor
Minor flecs version.
Definition flecs.h:1440
bool debug
Is this a debug build.
Definition flecs.h:1442
int16_t version_patch
Patch flecs version.
Definition flecs.h:1441
Used with ecs_bulk_init().
Definition flecs.h:1058
void ** data
Array with component data to insert.
Definition flecs.h:1070
ecs_id_t ids[(32)]
Ids to create the entities with.
Definition flecs.h:1068
int32_t count
Number of entities to create/populate.
Definition flecs.h:1066
int32_t _canary
Used for validity testing.
Definition flecs.h:1059
ecs_entity_t * entities
Entities to bulk insert.
Definition flecs.h:1061
ecs_table_t * table
Table to insert the entities into.
Definition flecs.h:1077
Used with ecs_component_init().
Definition flecs.h:1088
int32_t _canary
Used for validity testing.
Definition flecs.h:1089
ecs_type_info_t type
Parameters for type (size, hooks, ...)
Definition flecs.h:1095
ecs_entity_t entity
Existing entity to associate with observer (optional)
Definition flecs.h:1092
Used with ecs_delete_empty_tables().
Definition flecs.h:2645
uint16_t delete_generation
Delete table when generation > delete_generation.
Definition flecs.h:2650
double time_budget_seconds
Amount of time operation is allowed to spend.
Definition flecs.h:2653
uint16_t clear_generation
Free table data when generation > clear_generation.
Definition flecs.h:2647
Type returned by ecs_get_entities().
Definition flecs.h:2012
int32_t alive_count
Number of alive entity ids.
Definition flecs.h:2015
int32_t count
Total number of entity ids.
Definition flecs.h:2014
const ecs_entity_t * ids
Array with all entity ids in the world.
Definition flecs.h:2013
Used with ecs_entity_init().
Definition flecs.h:1012
const char * sep
Optional custom separator for hierarchical names.
Definition flecs.h:1024
const char * root_sep
Optional, used for identifiers relative to root.
Definition flecs.h:1028
const char * name
Name of the entity.
Definition flecs.h:1019
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:1040
const char * symbol
Optional entity symbol.
Definition flecs.h:1030
int32_t _canary
Used for validity testing.
Definition flecs.h:1013
const ecs_id_t * add
0-terminated array of ids to add to the entity.
Definition flecs.h:1045
const char * add_expr
String expression with components to add.
Definition flecs.h:1051
const ecs_value_t * set
0-terminated array of values to set on the entity.
Definition flecs.h:1048
ecs_entity_t id
Set to modify existing entity (optional)
Definition flecs.h:1015
ecs_entity_t parent
Parent entity.
Definition flecs.h:1017
Used with ecs_emit().
Definition flecs.h:1381
ecs_entity_t entity
Single-entity alternative to setting table / offset / count.
Definition flecs.h:1406
const void * const_param
Same as param, but with the guarantee that the value won't be modified.
Definition flecs.h:1417
ecs_table_t * table
The table for which to notify.
Definition flecs.h:1391
int32_t count
Limit number of notified entities to count.
Definition flecs.h:1403
ecs_table_t * other_table
Optional 2nd table to notify.
Definition flecs.h:1395
int32_t offset
Limit notified entities to ones starting from offset (row) in table.
Definition flecs.h:1398
const ecs_type_t * ids
Component ids.
Definition flecs.h:1388
ecs_poly_t * observable
Observable (usually the world)
Definition flecs.h:1420
ecs_entity_t event
The event id.
Definition flecs.h:1383
ecs_flags32_t flags
Event flags.
Definition flecs.h:1423
void * param
Optional context.
Definition flecs.h:1412
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:1136
ecs_world_t * real_world
Actual world.
Definition flecs.h:1139
void * param
Param passed to ecs_run.
Definition flecs.h:1172
ecs_entity_t event
The event (if applicable)
Definition flecs.h:1160
int32_t frame_offset
Offset relative to start of iteration.
Definition flecs.h:1183
ecs_flags32_t ref_fields
Bitset with fields that aren't component arrays.
Definition flecs.h:1154
ecs_entity_t interrupted_by
When set, system execution is interrupted.
Definition flecs.h:1187
ecs_flags32_t flags
Iterator flags.
Definition flecs.h:1186
ecs_iter_t * chain_it
Optional, allows for creating iterator chains.
Definition flecs.h:1194
void * ctx
System context.
Definition flecs.h:1173
void * run_ctx
Run language binding context.
Definition flecs.h:1176
ecs_table_t * table
Current table.
Definition flecs.h:1148
int32_t offset
Offset relative to current table.
Definition flecs.h:1142
ecs_id_t event_id
The (component) id for the event.
Definition flecs.h:1161
ecs_iter_fini_action_t fini
Function to cleanup iterator resources.
Definition flecs.h:1193
ecs_iter_private_t priv_
Private data.
Definition flecs.h:1188
ecs_world_t * world
The world.
Definition flecs.h:1138
void * callback_ctx
Callback language binding context.
Definition flecs.h:1175
ecs_entity_t * sources
Entity on which the id was matched (0 if same as entities)
Definition flecs.h:1151
void * binding_ctx
System binding context.
Definition flecs.h:1174
ecs_flags32_t row_fields
Fields that must be obtained with field_at.
Definition flecs.h:1155
float delta_system_time
Time elapsed since last system invocation.
Definition flecs.h:1180
const ecs_query_t * query
Query being evaluated.
Definition flecs.h:1169
int8_t term_index
Index of term that emitted an event.
Definition flecs.h:1166
ecs_entity_t system
The system (if applicable)
Definition flecs.h:1159
ecs_flags32_t set_fields
Fields that are set.
Definition flecs.h:1153
const ecs_size_t * sizes
Component sizes.
Definition flecs.h:1147
float delta_time
Time elapsed since last frame.
Definition flecs.h:1179
ecs_flags32_t up_fields
Bitset with fields matched through up traversal.
Definition flecs.h:1156
ecs_iter_action_t callback
Callback of system or observer.
Definition flecs.h:1192
int8_t field_count
Number of fields in iterator.
Definition flecs.h:1165
ecs_table_t * other_table
Prev or next table when adding/removing.
Definition flecs.h:1149
int32_t event_cur
Unique event id.
Definition flecs.h:1162
const ecs_table_record_t ** trs
Info on where to find field in table.
Definition flecs.h:1146
int32_t count
Number of entities to iterate.
Definition flecs.h:1143
void ** ptrs
Component pointers.
Definition flecs.h:1145
ecs_iter_next_action_t next
Function to progress iterator.
Definition flecs.h:1191
const ecs_entity_t * entities
Entity identifiers.
Definition flecs.h:1144
ecs_id_t * ids
(Component) ids
Definition flecs.h:1150
ecs_flags64_t constrained_vars
Bitset that marks constrained variables.
Definition flecs.h:1152
Used with ecs_observer_init().
Definition flecs.h:1319
ecs_ctx_free_t run_ctx_free
Callback to free run ctx.
Definition flecs.h:1363
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1351
void * run_ctx
Context associated with run (for language bindings).
Definition flecs.h:1360
ecs_entity_t entity
Existing entity to associate with observer (optional)
Definition flecs.h:1324
ecs_entity_t events[(8)]
Events to observe (OnAdd, OnRemove, OnSet)
Definition flecs.h:1330
int32_t * last_event_id
Optional shared last event id for multiple observers.
Definition flecs.h:1370
void * callback_ctx
Context associated with callback (for language bindings).
Definition flecs.h:1354
void * ctx
User context to pass to callback.
Definition flecs.h:1348
ecs_query_desc_t query
Query for observer.
Definition flecs.h:1327
ecs_poly_t * observable
Observable with which to register the observer.
Definition flecs.h:1366
ecs_ctx_free_t callback_ctx_free
Callback to free callback ctx.
Definition flecs.h:1357
int8_t term_index_
Used for internal purposes.
Definition flecs.h:1373
ecs_iter_action_t callback
Callback to invoke on an event, invoked when the observer matches.
Definition flecs.h:1337
bool yield_existing
When observer is created, generate events from existing data.
Definition flecs.h:1334
ecs_run_action_t run
Callback invoked on an event.
Definition flecs.h:1345
int32_t _canary
Used for validity testing.
Definition flecs.h:1321
An observer reacts to events matching a query.
Definition flecs.h:853
int32_t event_count
Number of events.
Definition flecs.h:860
ecs_iter_action_t callback
See ecs_observer_desc_t::callback.
Definition flecs.h:862
ecs_entity_t entity
Entity associated with observer.
Definition flecs.h:876
ecs_observable_t * observable
Observable for observer.
Definition flecs.h:873
ecs_run_action_t run
See ecs_observer_desc_t::run.
Definition flecs.h:863
ecs_header_t hdr
Object header.
Definition flecs.h:854
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:869
void * run_ctx
Run language binding context.
Definition flecs.h:867
ecs_world_t * world
The world.
Definition flecs.h:875
ecs_ctx_free_t run_ctx_free
Callback to free run_ctx.
Definition flecs.h:871
void * callback_ctx
Callback language binding context.
Definition flecs.h:866
void * ctx
Observer context.
Definition flecs.h:865
ecs_entity_t events[(8)]
Observer events.
Definition flecs.h:859
ecs_ctx_free_t callback_ctx_free
Callback to free callback_ctx.
Definition flecs.h:870
ecs_query_t * query
Observer query.
Definition flecs.h:856
Struct returned by ecs_query_count().
Definition flecs.h:4989
int32_t empty_tables
Number of empty tables returned by query.
Definition flecs.h:4993
int32_t entities
Number of entities returned by query.
Definition flecs.h:4991
int32_t results
Number of results returned by query.
Definition flecs.h:4990
int32_t tables
Number of tables returned by query.
Definition flecs.h:4992
Used with ecs_query_init().
Definition flecs.h:1245
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:1306
ecs_id_t group_by
Component id to be used for grouping.
Definition flecs.h:1276
ecs_term_t terms[32]
Query terms.
Definition flecs.h:1250
int32_t _canary
Used for validity testing.
Definition flecs.h:1247
void * ctx
User context to pass to callback.
Definition flecs.h:1300
ecs_ctx_free_t group_by_ctx_free
Function to free group_by_ctx.
Definition flecs.h:1297
void * group_by_ctx
Context to pass to group_by.
Definition flecs.h:1294
void * binding_ctx
Context to be used for language bindings.
Definition flecs.h:1303
ecs_entity_t order_by
Component to sort on, used together with order_by_callback or order_by_table_callback.
Definition flecs.h:1272
ecs_order_by_action_t order_by_callback
Callback used for ordering query results.
Definition flecs.h:1264
ecs_group_create_action_t on_group_create
Callback that is invoked when a new group is created.
Definition flecs.h:1287
ecs_entity_t entity
Entity associated with query (optional)
Definition flecs.h:1312
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition flecs.h:1309
ecs_group_by_action_t group_by_callback
Callback used for grouping results.
Definition flecs.h:1283
ecs_group_delete_action_t on_group_delete
Callback that is invoked when an existing group is deleted.
Definition flecs.h:1291
ecs_sort_table_action_t order_by_table_callback
Callback used for ordering query results.
Definition flecs.h:1268
ecs_flags32_t flags
Flags for enabling query features.
Definition flecs.h:1259
ecs_query_cache_kind_t cache_kind
Caching policy of query.
Definition flecs.h:1256
const char * expr
Query DSL expression (optional)
Definition flecs.h:1253
Type that contains information about a query group.
Definition flecs.h:1507
int32_t table_count
Number of tables in group.
Definition flecs.h:1510
void * ctx
Group context, returned by on_group_create.
Definition flecs.h:1511
int32_t match_count
How often tables have been matched/unmatched.
Definition flecs.h:1509
Queries are lists of constraints (terms) that match entities.
Definition flecs.h:812
ecs_flags32_t row_fields
Fields that must be acquired with field_at.
Definition flecs.h:832
ecs_flags32_t data_fields
Fields that have data.
Definition flecs.h:829
ecs_flags32_t read_fields
Fields that read data.
Definition flecs.h:831
ecs_header_t hdr
Object header.
Definition flecs.h:813
int8_t var_count
Number of query variables.
Definition flecs.h:821
ecs_flags32_t fixed_fields
Fields with a fixed source.
Definition flecs.h:826
ecs_flags32_t var_fields
Fields with non-$this variable source.
Definition flecs.h:827
ecs_flags32_t write_fields
Fields that write data.
Definition flecs.h:830
int32_t eval_count
Number of times query is evaluated.
Definition flecs.h:847
ecs_world_t * world
World or stage query was created with.
Definition flecs.h:845
ecs_flags32_t static_id_fields
Fields with a static (component) id.
Definition flecs.h:828
uint64_t bloom_filter
Bitmask used to quickly discard tables.
Definition flecs.h:819
ecs_world_t * real_world
Actual world.
Definition flecs.h:844
ecs_flags32_t set_fields
Fields that will be set.
Definition flecs.h:834
ecs_entity_t entity
Entity associated with query (optional)
Definition flecs.h:843
void * ctx
User context to pass to callback.
Definition flecs.h:840
int32_t * sizes
Component sizes.
Definition flecs.h:816
ecs_id_t * ids
Component ids.
Definition flecs.h:817
ecs_flags32_t shared_readonly_fields
Fields that don't write shared data.
Definition flecs.h:833
ecs_term_t * terms
Query terms.
Definition flecs.h:815
ecs_query_cache_kind_t cache_kind
Caching policy of query.
Definition flecs.h:836
int8_t term_count
Number of query terms.
Definition flecs.h:822
char ** vars
Array with variable names for iterator.
Definition flecs.h:838
int8_t field_count
Number of fields returned by query.
Definition flecs.h:823
ecs_flags32_t flags
Query flags.
Definition flecs.h:820
void * binding_ctx
Context to be used for language bindings.
Definition flecs.h:841
Type that describes a reference to an entity or variable in a term.
Definition flecs.h:773
const char * name
Name.
Definition flecs.h:780
ecs_entity_t id
Entity id.
Definition flecs.h:774
Type that describes a term (single element in a query).
Definition flecs.h:788
ecs_term_ref_t src
Source of term.
Definition flecs.h:794
int8_t field_index
Index of field for term in iterator.
Definition flecs.h:805
ecs_id_t id
Component id to be matched by term.
Definition flecs.h:789
int16_t oper
Operator of term.
Definition flecs.h:803
ecs_term_ref_t second
Second element of pair.
Definition flecs.h:796
ecs_flags16_t flags_
Flags that help eval, set by ecs_query_init()
Definition flecs.h:806
ecs_entity_t trav
Relationship to traverse when looking for the component.
Definition flecs.h:798
int16_t inout
Access to contents matched by term.
Definition flecs.h:802
ecs_term_ref_t first
Component or first element of pair.
Definition flecs.h:795
ecs_copy_t copy_ctor
Ctor + copy.
Definition flecs.h:932
void * lifecycle_ctx
Component lifecycle context (see meta add-on)
Definition flecs.h:978
void * ctx
User defined context.
Definition flecs.h:976
ecs_iter_action_t on_remove
Callback that is invoked when an instance of the component is removed.
Definition flecs.h:974
void * binding_ctx
Language binding context.
Definition flecs.h:977
ecs_move_t move_dtor
Move + dtor.
Definition flecs.h:947
ecs_flags32_t flags
Hook flags.
Definition flecs.h:959
ecs_cmp_t cmp
Compare hook.
Definition flecs.h:950
ecs_copy_t copy
copy assignment
Definition flecs.h:928
ecs_ctx_free_t lifecycle_ctx_free
Callback to free lifecycle_ctx.
Definition flecs.h:982
ecs_iter_action_t on_set
Callback that is invoked when an instance of the component is set.
Definition flecs.h:969
ecs_move_t move
move assignment
Definition flecs.h:929
ecs_xtor_t ctor
ctor
Definition flecs.h:926
ecs_ctx_free_t ctx_free
Callback to free ctx.
Definition flecs.h:980
ecs_iter_action_t on_add
Callback that is invoked when an instance of a component is added.
Definition flecs.h:964
ecs_ctx_free_t binding_ctx_free
Callback to free binding_ctx.
Definition flecs.h:981
ecs_move_t move_ctor
Ctor + move.
Definition flecs.h:935
ecs_equals_t equals
Equals hook.
Definition flecs.h:953
ecs_move_t ctor_move_dtor
Ctor + move + dtor (or move_ctor + dtor).
Definition flecs.h:941
ecs_xtor_t dtor
dtor
Definition flecs.h:927
Type that contains component information (passed to ctors/dtors/...)
Definition flecs.h:989
ecs_size_t alignment
Alignment of type.
Definition flecs.h:991
ecs_size_t size
Size of type.
Definition flecs.h:990
const char * name
Type name.
Definition flecs.h:994
ecs_entity_t component
Handle to component (do not set)
Definition flecs.h:993
ecs_type_hooks_t hooks
Type hooks.
Definition flecs.h:992
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:1003
void * ptr
Pointer to value.
Definition flecs.h:1005
ecs_entity_t type
Type of value.
Definition flecs.h:1004
Type that contains information about the world.
Definition flecs.h:1448
float delta_time
Time passed to or computed by ecs_progress()
Definition flecs.h:1454
ecs_entity_t min_id
First allowed entity id.
Definition flecs.h:1450
int64_t set_count
Set commands processed.
Definition flecs.h:1490
double world_time_total
Time elapsed in simulation.
Definition flecs.h:1462
int32_t tag_id_count
Number of tag (no data) ids in the world.
Definition flecs.h:1478
int32_t component_id_count
Number of component (data) ids in the world.
Definition flecs.h:1479
int64_t pipeline_build_count_total
Total number of pipeline builds.
Definition flecs.h:1474
int64_t eval_comp_monitors_total
Total number of monitor evaluations.
Definition flecs.h:1467
int32_t table_count
Number of tables.
Definition flecs.h:1482
float delta_time_raw
Raw delta time (no time scaling)
Definition flecs.h:1453
float frame_time_total
Total time spent processing a frame.
Definition flecs.h:1457
int64_t table_create_total
Total number of times a table was created.
Definition flecs.h:1472
int64_t observers_ran_frame
Total number of times observer was invoked.
Definition flecs.h:1476
float system_time_total
Total time spent in systems.
Definition flecs.h:1458
int64_t id_delete_total
Total number of times an id was deleted.
Definition flecs.h:1471
int64_t systems_ran_frame
Total number of systems ran in last frame.
Definition flecs.h:1475
float merge_time_total
Total time spent in merges.
Definition flecs.h:1460
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:1493
int64_t clear_count
Clear commands processed.
Definition flecs.h:1489
ecs_entity_t last_component_id
Last issued component entity id.
Definition flecs.h:1449
int64_t frame_count_total
Total number of frames.
Definition flecs.h:1465
ecs_entity_t max_id
Last allowed entity id.
Definition flecs.h:1451
int64_t merge_count_total
Total number of merges.
Definition flecs.h:1466
int64_t other_count
Other commands processed.
Definition flecs.h:1495
int64_t batched_command_count
Commands batched.
Definition flecs.h:1497
int64_t table_delete_total
Total number of times a table was deleted.
Definition flecs.h:1473
int64_t delete_count
Selete commands processed.
Definition flecs.h:1488
int64_t rematch_count_total
Total number of rematches.
Definition flecs.h:1468
int64_t id_create_total
Total number of times a new id was created.
Definition flecs.h:1470
int64_t batched_entity_count
Entities for which commands were batched.
Definition flecs.h:1496
float time_scale
Time scale applied to delta_time.
Definition flecs.h:1455
int32_t pair_id_count
Number of pair ids in the world.
Definition flecs.h:1480
float rematch_time_total
Time spent on query rematching.
Definition flecs.h:1461
int64_t ensure_count
Ensure/emplace commands processed.
Definition flecs.h:1491
float target_fps
Target fps.
Definition flecs.h:1456
double world_time_total_raw
Time elapsed in simulation (no scaling)
Definition flecs.h:1463
float emit_time_total
Total time spent notifying observers.
Definition flecs.h:1459
int64_t modified_count
Modified commands processed.
Definition flecs.h:1492
const char * name_prefix
Value set by ecs_set_name_prefix().
Definition flecs.h:1500
int64_t event_count
Enqueued custom events.
Definition flecs.h:1494
int64_t add_count
Add commands processed.
Definition flecs.h:1486
int64_t remove_count
Remove commands processed.
Definition flecs.h:1487