Flecs v3.1
A fast entity component system (ECS) for C & C++
Loading...
Searching...
No Matches
flecs.h File Reference

Flecs public API. More...

#include "flecs/private/api_defines.h"
#include "flecs/private/vector.h"
#include "flecs/private/vec.h"
#include "flecs/private/sparse.h"
#include "flecs/private/block_allocator.h"
#include "flecs/private/map.h"
#include "flecs/private/allocator.h"
#include "flecs/private/strbuf.h"
#include "flecs/os_api.h"
#include "flecs/private/api_types.h"
#include "flecs/private/api_support.h"
#include "flecs/private/hashmap.h"
#include "flecs/addons/flecs_c.h"
#include "flecs/private/addons.h"

Go to the source code of this file.

Classes

struct  ecs_type_t
 An array with (component) ids. More...
 
struct  ecs_header_t
 Header for ecs_poly_t objects. More...
 
struct  ecs_iterable_t
 Iterable mixin. More...
 
struct  ecs_term_id_t
 Type that describes a single identifier in a term. More...
 
struct  ecs_term_t
 Type that describes a term (single element in a query) More...
 
struct  ecs_filter_t
 Filters alllow for ad-hoc quick filtering of entity tables. More...
 
struct  ecs_observer_t
 
struct  ecs_type_hooks_t
 Type that contains component lifecycle callbacks. More...
 
struct  ecs_type_info_t
 Type that contains component information (passed to ctors/dtors/...) More...
 
struct  ecs_entity_desc_t
 Used with ecs_entity_init. More...
 
struct  ecs_bulk_desc_t
 Used with ecs_bulk_init. More...
 
struct  ecs_component_desc_t
 Used with ecs_component_init. More...
 
struct  ecs_filter_desc_t
 Used with ecs_filter_init. More...
 
struct  ecs_query_desc_t
 Used with ecs_query_init. More...
 
struct  ecs_observer_desc_t
 Used with ecs_observer_init. More...
 
struct  ecs_value_t
 
struct  ecs_world_info_t
 Type that contains information about the world. More...
 
struct  ecs_query_group_info_t
 Type that contains information about a query group. More...
 
struct  EcsIdentifier
 A (string) identifier. More...
 
struct  EcsComponent
 Component information. More...
 
struct  EcsPoly
 Component for storing a poly object. More...
 
struct  ecs_event_desc_t
 

Macros

#define ecs_float_t   float
 Customizable precision for floating point operations. More...
 
#define ecs_ftime_t   ecs_float_t
 Customizable precision for scalar time values. More...
 
#define FLECS_NO_DEPRECATED_WARNINGS
 disables deprecated warnings More...
 
#define FLECS_DEBUG
 Used for input parameter checking and cheap sanity checks. More...
 
#define FLECS_CPP
 C++ API. More...
 
#define FLECS_MODULE
 Module support. More...
 
#define FLECS_PARSER
 String parser for queries. More...
 
#define FLECS_PLECS
 ECS data definition format. More...
 
#define FLECS_RULES
 Constraint solver for advanced queries. More...
 
#define FLECS_SNAPSHOT
 Snapshot & restore ECS data. More...
 
#define FLECS_STATS
 Access runtime statistics. More...
 
#define FLECS_MONITOR
 Track runtime statistics periodically. More...
 
#define FLECS_SYSTEM
 System support. More...
 
#define FLECS_PIPELINE
 Pipeline support. More...
 
#define FLECS_TIMER
 Timer support. More...
 
#define FLECS_META
 Reflection support. More...
 
#define FLECS_META_C
 Utilities for populating reflection data. More...
 
#define FLECS_UNITS
 Builtin standard units. More...
 
#define FLECS_EXPR
 Parsing strings to/from component values. More...
 
#define FLECS_JSON
 Parsing JSON to/from component values. More...
 
#define FLECS_DOC
 Document entities & components. More...
 
#define FLECS_COREDOC
 Documentation for core entities & components. More...
 
#define FLECS_LOG
 When enabled ECS provides more detailed logs. More...
 
#define FLECS_APP
 Application addon. More...
 
#define FLECS_OS_API_IMPL
 Default implementation for OS API. More...
 
#define FLECS_HTTP
 Tiny HTTP server for connecting to remote UI. More...
 
#define FLECS_REST
 REST API for querying application data. More...
 
#define ECS_ID_CACHE_SIZE   (32)
 Maximum number of components to add/remove in a single operation. More...
 
#define ECS_TERM_DESC_CACHE_SIZE   (16)
 Maximum number of terms in desc (larger, as these are temp objects) More...
 
#define ECS_OBSERVER_DESC_EVENT_COUNT_MAX   (8)
 Maximum number of events to set in static array of observer descriptor. More...
 
#define ECS_VARIABLE_COUNT_MAX   (64)
 Maximum number of query variables per query. More...
 
#define EcsSelf   (1u << 1)
 Match on self. More...
 
#define EcsUp   (1u << 2)
 Match by traversing upwards. More...
 
#define EcsDown   (1u << 3)
 Match by traversing downwards (derived, cannot be set) More...
 
#define EcsTraverseAll   (1u << 4)
 Match all entities encountered through traversal. More...
 
#define EcsCascade   (1u << 5)
 Sort results breadth first. More...
 
#define EcsParent   (1u << 6)
 Short for up(ChildOf) More...
 
#define EcsIsVariable   (1u << 7)
 Term id is a variable. More...
 
#define EcsIsEntity   (1u << 8)
 Term id is an entity. More...
 
#define EcsFilter   (1u << 9)
 Prevent observer from triggering on term. More...
 
#define EcsTraverseFlags   (EcsUp|EcsDown|EcsTraverseAll|EcsSelf|EcsCascade|EcsParent)
 
#define ECS_ID_FLAG_BIT   (1ull << 63)
 Bit added to flags to differentiate between id flags and generation. More...
 
#define EcsLastInternalComponentId   (ecs_id(EcsPoly))
 Value used to quickly check if component is builtin. More...
 
#define EcsFirstUserComponentId   (8)
 The first user-defined component starts from this id. More...
 
#define EcsFirstUserEntityId   (ECS_HI_COMPONENT_ID + 128)
 The first user-defined entity starts from this id. More...
 
#define ecs_poly_is(object, type)    _ecs_poly_is(object, type##_magic)
 

Typedefs

typedef uint64_t ecs_id_t
 An id. More...
 
typedef ecs_id_t ecs_entity_t
 An entity identifier. More...
 
typedef struct ecs_world_t ecs_world_t
 A world is the container for all ECS data and supporting features. More...
 
typedef struct ecs_table_t ecs_table_t
 A table is where entities and components are stored. More...
 
typedef struct ecs_term_t ecs_term_t
 A term is a single element in a query. More...
 
typedef struct ecs_query_t ecs_query_t
 A query allows for cached iteration over ECS data. More...
 
typedef struct ecs_filter_t ecs_filter_t
 A filter allows for uncached, ad hoc iteration over ECS data. More...
 
typedef struct ecs_rule_t ecs_rule_t
 A rule implements a non-trivial filter. More...
 
typedef struct ecs_observer_t ecs_observer_t
 An observer reacts to events matching multiple filter terms. More...
 
typedef struct ecs_observable_t ecs_observable_t
 An observable contains lists of triggers for specific events/components. More...
 
typedef struct ecs_iter_t ecs_iter_t
 
typedef struct ecs_ref_t ecs_ref_t
 Refs cache data that lets them access components faster than ecs_get. More...
 
typedef struct ecs_type_hooks_t ecs_type_hooks_t
 Type hooks (callbacks) More...
 
typedef struct ecs_type_info_t ecs_type_info_t
 Type information. More...
 
typedef struct ecs_id_record_t ecs_id_record_t
 
typedef struct ecs_table_record_t ecs_table_record_t
 
typedef void ecs_poly_t
 A poly object. More...
 
typedef struct ecs_mixins_t ecs_mixins_t
 Type that stores poly mixins. More...
 
typedef struct ecs_header_t ecs_header_t
 Header for ecs_poly_t objects.
 
typedef void(* ecs_run_action_t) (ecs_iter_t *it)
 Function prototype for runnables (systems, observers). More...
 
typedef void(* ecs_iter_action_t) (ecs_iter_t *it)
 Function prototype for iterables. More...
 
typedef void(* ecs_iter_init_action_t) (const ecs_world_t *world, const ecs_poly_t *iterable, ecs_iter_t *it, ecs_term_t *filter)
 Function prototype for creating an iterator from a poly. More...
 
typedef bool(* ecs_iter_next_action_t) (ecs_iter_t *it)
 Function prototype for iterating an iterator. More...
 
typedef void(* ecs_iter_fini_action_t) (ecs_iter_t *it)
 Function prototype for freeing an iterator. More...
 
typedef 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. More...
 
typedef 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. More...
 
typedef 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. More...
 
typedef void *(* ecs_group_create_action_t) (ecs_world_t *world, uint64_t group_id, void *group_by_ctx)
 
typedef void(* ecs_group_delete_action_t) (ecs_world_t *world, uint64_t group_id, void *group_ctx, void *group_by_ctx)
 
typedef void(* ecs_module_action_t) (ecs_world_t *world)
 Initialization action for modules. More...
 
typedef void(* ecs_fini_action_t) (ecs_world_t *world, void *ctx)
 Action callback on world exit. More...
 
typedef void(* ecs_ctx_free_t) (void *ctx)
 Function to cleanup context data. More...
 
typedef int(* ecs_compare_action_t) (const void *ptr1, const void *ptr2)
 Callback used for sorting values. More...
 
typedef uint64_t(* ecs_hash_value_action_t) (const void *ptr)
 Callback used for hashing values. More...
 
typedef void(* ecs_xtor_t) (void *ptr, int32_t count, const ecs_type_info_t *type_info)
 Constructor/destructor callback. More...
 
typedef 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. More...
 
typedef 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. More...
 
typedef void(* ecs_poly_dtor_t) (ecs_poly_t *poly)
 
typedef struct ecs_iterable_t ecs_iterable_t
 Iterable mixin. More...
 
typedef enum ecs_inout_kind_t ecs_inout_kind_t
 Specify read/write access for term.
 
typedef enum ecs_oper_kind_t ecs_oper_kind_t
 Specify operator for term.
 
typedef struct ecs_term_id_t ecs_term_id_t
 Type that describes a single identifier in a term.
 
typedef struct ecs_entity_desc_t ecs_entity_desc_t
 Used with ecs_entity_init. More...
 
typedef struct ecs_bulk_desc_t ecs_bulk_desc_t
 Used with ecs_bulk_init. More...
 
typedef struct ecs_component_desc_t ecs_component_desc_t
 Used with ecs_component_init.
 
typedef struct ecs_filter_desc_t ecs_filter_desc_t
 Used with ecs_filter_init.
 
typedef struct ecs_query_desc_t ecs_query_desc_t
 Used with ecs_query_init.
 
typedef struct ecs_observer_desc_t ecs_observer_desc_t
 Used with ecs_observer_init.
 
typedef struct ecs_value_t ecs_value_t
 
typedef struct ecs_world_info_t ecs_world_info_t
 Type that contains information about the world.
 
typedef struct ecs_query_group_info_t ecs_query_group_info_t
 Type that contains information about a query group.
 
typedef struct EcsIdentifier EcsIdentifier
 A (string) identifier. More...
 
typedef struct EcsComponent EcsComponent
 Component information.
 
typedef struct EcsPoly EcsPoly
 Component for storing a poly object.
 
typedef ecs_iterable_t EcsIterable
 Component for iterable entities. More...
 
typedef struct ecs_event_desc_t ecs_event_desc_t
 

Enumerations

enum  ecs_inout_kind_t {
  EcsInOutDefault , EcsInOutNone , EcsInOut , EcsIn ,
  EcsOut
}
 Specify read/write access for term. More...
 
enum  ecs_oper_kind_t {
  EcsAnd , EcsOr , EcsNot , EcsOptional ,
  EcsAndFrom , EcsOrFrom , EcsNotFrom
}
 Specify operator for term. More...
 

Functions

ecs_world_tecs_init (void)
 Create a new world. More...
 
ecs_world_tecs_mini (void)
 Same as ecs_init, but with minimal set of modules loaded. More...
 
ecs_world_tecs_init_w_args (int argc, char *argv[])
 Create a new world with arguments. More...
 
int ecs_fini (ecs_world_t *world)
 Delete a world. More...
 
bool ecs_is_fini (const ecs_world_t *world)
 Returns whether the world is being deleted. More...
 
void ecs_atfini (ecs_world_t *world, ecs_fini_action_t action, void *ctx)
 Register action to be executed when world is destroyed. More...
 
float ecs_frame_begin (ecs_world_t *world, float delta_time)
 Begin frame. More...
 
void ecs_frame_end (ecs_world_t *world)
 End frame. More...
 
void ecs_run_post_frame (ecs_world_t *world, ecs_fini_action_t action, void *ctx)
 Register action to be executed once after frame. More...
 
void ecs_quit (ecs_world_t *world)
 Signal exit This operation signals that the application should quit. More...
 
bool ecs_should_quit (const ecs_world_t *world)
 Return whether a quit has been signaled. More...
 
void ecs_measure_frame_time (ecs_world_t *world, bool enable)
 Measure frame time. More...
 
void ecs_measure_system_time (ecs_world_t *world, bool enable)
 Measure system time. More...
 
void ecs_set_target_fps (ecs_world_t *world, float fps)
 Set target frames per second (FPS) for application. More...
 
bool ecs_readonly_begin (ecs_world_t *world)
 Begin readonly mode. More...
 
void ecs_readonly_end (ecs_world_t *world)
 End readonly mode. More...
 
void ecs_merge (ecs_world_t *world)
 Merge world or stage. More...
 
bool ecs_defer_begin (ecs_world_t *world)
 Defer operations until end of frame. More...
 
bool ecs_is_deferred (const ecs_world_t *world)
 Test if deferring is enabled for current stage. More...
 
bool ecs_defer_end (ecs_world_t *world)
 End block of operations to defer. More...
 
void ecs_defer_suspend (ecs_world_t *world)
 Suspend deferring but do not flush queue. More...
 
void ecs_defer_resume (ecs_world_t *world)
 Resume deferring. More...
 
void ecs_set_automerge (ecs_world_t *world, bool automerge)
 Enable/disable automerging for world or stage. More...
 
void ecs_set_stage_count (ecs_world_t *world, int32_t stages)
 Configure world to have N stages. More...
 
int32_t ecs_get_stage_count (const ecs_world_t *world)
 Get number of configured stages. More...
 
int32_t ecs_get_stage_id (const ecs_world_t *world)
 Get current stage id. More...
 
ecs_world_tecs_get_stage (const ecs_world_t *world, int32_t stage_id)
 Get stage-specific world pointer. More...
 
bool ecs_stage_is_readonly (const ecs_world_t *world)
 Test whether the current world is readonly. More...
 
ecs_world_tecs_async_stage_new (ecs_world_t *world)
 Create asynchronous stage. More...
 
void ecs_async_stage_free (ecs_world_t *stage)
 Free asynchronous stage. More...
 
bool ecs_stage_is_async (ecs_world_t *stage)
 Test whether provided stage is asynchronous. More...
 
void ecs_set_context (ecs_world_t *world, void *ctx)
 Set a world context. More...
 
void * ecs_get_context (const ecs_world_t *world)
 Get the world context. More...
 
const ecs_world_info_tecs_get_world_info (const ecs_world_t *world)
 Get world info. More...
 
void ecs_dim (ecs_world_t *world, int32_t entity_count)
 Dimension the world for a specified number of entities. More...
 
void ecs_set_entity_range (ecs_world_t *world, ecs_entity_t id_start, ecs_entity_t id_end)
 Set a range for issueing new entity ids. More...
 
bool ecs_enable_range_check (ecs_world_t *world, bool enable)
 Enable/disable range limits. More...
 
void ecs_run_aperiodic (ecs_world_t *world, ecs_flags32_t flags)
 Force aperiodic actions. More...
 
int32_t ecs_delete_empty_tables (ecs_world_t *world, ecs_id_t id, uint16_t clear_generation, uint16_t delete_generation, int32_t min_id_count, double time_budget_seconds)
 Cleanup empty tables. More...
 
const ecs_world_tecs_get_world (const ecs_poly_t *poly)
 Get world from poly. More...
 
ecs_entity_t ecs_get_entity (const ecs_poly_t *poly)
 Get entity from poly. More...
 
bool _ecs_poly_is (const ecs_poly_t *object, int32_t type)
 Test if pointer is of specified type. More...
 
ecs_id_t ecs_make_pair (ecs_entity_t first, ecs_entity_t second)
 Make a pair id. More...
 
ecs_entity_t ecs_new_id (ecs_world_t *world)
 Create new entity id. More...
 
ecs_entity_t ecs_new_low_id (ecs_world_t *world)
 Create new low id. More...
 
ecs_entity_t ecs_new_w_id (ecs_world_t *world, ecs_id_t id)
 Create new entity with (component) id. More...
 
ecs_entity_t ecs_entity_init (ecs_world_t *world, const ecs_entity_desc_t *desc)
 Find or create an entity. More...
 
const ecs_entity_tecs_bulk_init (ecs_world_t *world, const ecs_bulk_desc_t *desc)
 Bulk create/populate new entities. More...
 
const ecs_entity_tecs_bulk_new_w_id (ecs_world_t *world, ecs_id_t id, int32_t count)
 Create N new entities. More...
 
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. More...
 
void ecs_delete (ecs_world_t *world, ecs_entity_t entity)
 Delete an entity. More...
 
void ecs_delete_with (ecs_world_t *world, ecs_id_t id)
 Delete all entities with the specified id. More...
 
void ecs_add_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
 Add a (component) id to an entity. More...
 
void ecs_remove_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
 Remove a (component) id from an entity. More...
 
void ecs_override_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
 Add override for (component) id. More...
 
void ecs_clear (ecs_world_t *world, ecs_entity_t entity)
 Clear all components. More...
 
void ecs_remove_all (ecs_world_t *world, ecs_id_t id)
 Remove all instances of the specified id. More...
 
ecs_entity_t ecs_set_with (ecs_world_t *world, ecs_id_t id)
 Set current with id. More...
 
ecs_id_t ecs_get_with (const ecs_world_t *world)
 Get current with id. More...
 
void ecs_enable (ecs_world_t *world, ecs_entity_t entity, bool enabled)
 Enable or disable entity. More...
 
void ecs_enable_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, bool enable)
 Enable or disable component. More...
 
bool ecs_is_enabled_id (const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
 Test if component is enabled. More...
 
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. More...
 
ecs_ref_t ecs_ref_init_id (const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
 Create a component ref. More...
 
void * ecs_ref_get_id (const ecs_world_t *world, ecs_ref_t *ref, ecs_id_t id)
 Get component from ref. More...
 
void ecs_ref_update (const ecs_world_t *world, ecs_ref_t *ref)
 Update ref. More...
 
void * ecs_get_mut_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
 Get a mutable pointer to a component. More...
 
ecs_record_t * ecs_write_begin (ecs_world_t *world, ecs_entity_t entity)
 Begin exclusive write access to entity. More...
 
void ecs_write_end (ecs_record_t *record)
 End exclusive write access to entity. More...
 
const ecs_record_t * ecs_read_begin (ecs_world_t *world, ecs_entity_t entity)
 Begin read access to entity. More...
 
void ecs_read_end (const ecs_record_t *record)
 End read access to entity. More...
 
const void * ecs_record_get_id (ecs_world_t *world, const ecs_record_t *record, ecs_id_t id)
 Get component from entity record. More...
 
void * ecs_record_get_mut_id (ecs_world_t *world, ecs_record_t *record, ecs_id_t id)
 Same as ecs_record_get_id, but returns a mutable pointer. More...
 
void * ecs_emplace_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
 Emplace a component. More...
 
void ecs_modified_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
 Signal that a component has been modified. More...
 
ecs_entity_t ecs_set_id (ecs_world_t *world, ecs_entity_t entity, ecs_id_t id, size_t size, const void *ptr)
 Set the value of a component. More...
 
bool ecs_is_valid (const ecs_world_t *world, ecs_entity_t e)
 Test whether an entity is valid. More...
 
bool ecs_is_alive (const ecs_world_t *world, ecs_entity_t e)
 Test whether an entity is alive. More...
 
ecs_id_t ecs_strip_generation (ecs_entity_t e)
 Remove generation from entity id. More...
 
void ecs_set_entity_generation (ecs_world_t *world, ecs_entity_t entity)
 Override the generation of an entity. More...
 
ecs_entity_t ecs_get_alive (const ecs_world_t *world, ecs_entity_t e)
 Get alive identifier. More...
 
void ecs_ensure (ecs_world_t *world, ecs_entity_t entity)
 Ensure id is alive. More...
 
void ecs_ensure_id (ecs_world_t *world, ecs_id_t id)
 Same as ecs_ensure, but for (component) ids. More...
 
bool ecs_exists (const ecs_world_t *world, ecs_entity_t entity)
 Test whether an entity exists. More...
 
const ecs_type_tecs_get_type (const ecs_world_t *world, ecs_entity_t entity)
 Get the type of an entity. More...
 
ecs_table_tecs_get_table (const ecs_world_t *world, ecs_entity_t entity)
 Get the table of an entity. More...
 
char * ecs_type_str (const ecs_world_t *world, const ecs_type_t *type)
 Convert type to string. More...
 
char * ecs_table_str (const ecs_world_t *world, const ecs_table_t *table)
 Convert table to string. More...
 
char * ecs_entity_str (const ecs_world_t *world, ecs_entity_t entity)
 Convert entity to string. More...
 
bool ecs_has_id (const ecs_world_t *world, ecs_entity_t entity, ecs_id_t id)
 Test if an entity has an entity. More...
 
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. More...
 
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. More...
 
int32_t ecs_get_depth (const ecs_world_t *world, ecs_entity_t entity, ecs_entity_t rel)
 Return depth for entity in tree for relationship rel. More...
 
int32_t ecs_count_id (const ecs_world_t *world, ecs_id_t entity)
 Count entities that have the specified id. More...
 
const char * ecs_get_name (const ecs_world_t *world, ecs_entity_t entity)
 Get the name of an entity. More...
 
const char * ecs_get_symbol (const ecs_world_t *world, ecs_entity_t entity)
 Get the symbol of an entity. More...
 
ecs_entity_t ecs_set_name (ecs_world_t *world, ecs_entity_t entity, const char *name)
 Set the name of an entity. More...
 
ecs_entity_t ecs_set_symbol (ecs_world_t *world, ecs_entity_t entity, const char *symbol)
 Set the symbol of an entity. More...
 
void ecs_set_alias (ecs_world_t *world, ecs_entity_t entity, const char *alias)
 Set alias for entity. More...
 
ecs_entity_t ecs_lookup (const ecs_world_t *world, const char *name)
 Lookup an entity by name. More...
 
ecs_entity_t ecs_lookup_child (const ecs_world_t *world, ecs_entity_t parent, const char *name)
 Lookup a child entity by name. More...
 
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. More...
 
ecs_entity_t ecs_lookup_symbol (const ecs_world_t *world, const char *symbol, bool lookup_as_path)
 Lookup an entity by its symbol name. More...
 
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. More...
 
void ecs_get_path_w_sep_buf (const ecs_world_t *world, ecs_entity_t parent, ecs_entity_t child, const char *sep, const char *prefix, ecs_strbuf_t *buf)
 Write path identifier to buffer. More...
 
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. More...
 
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. More...
 
ecs_entity_t ecs_set_scope (ecs_world_t *world, ecs_entity_t scope)
 Set the current scope. More...
 
ecs_entity_t ecs_get_scope (const ecs_world_t *world)
 Get the current scope. More...
 
const char * ecs_set_name_prefix (ecs_world_t *world, const char *prefix)
 Set a name prefix for newly created entities. More...
 
ecs_entity_tecs_set_lookup_path (ecs_world_t *world, const ecs_entity_t *lookup_path)
 Set search path for lookup operations. More...
 
ecs_entity_tecs_get_lookup_path (const ecs_world_t *world)
 Get current lookup path. More...
 
ecs_entity_t ecs_component_init (ecs_world_t *world, const ecs_component_desc_t *desc)
 Find or create a component. More...
 
void ecs_set_hooks_id (ecs_world_t *world, ecs_entity_t id, const ecs_type_hooks_t *hooks)
 Register hooks for component. More...
 
const ecs_type_hooks_tecs_get_hooks_id (ecs_world_t *world, ecs_entity_t id)
 Get hooks for component. More...
 
bool ecs_id_is_tag (const ecs_world_t *world, ecs_id_t id)
 Returns whether specified id a tag. More...
 
bool ecs_id_in_use (ecs_world_t *world, ecs_id_t id)
 Returns whether specified id is in use. More...
 
const ecs_type_info_tecs_get_type_info (const ecs_world_t *world, ecs_id_t id)
 Get the type for an id. More...
 
ecs_entity_t ecs_get_typeid (const ecs_world_t *world, ecs_id_t id)
 Get the type for an id. More...
 
bool ecs_id_match (ecs_id_t id, ecs_id_t pattern)
 Utility to match an id with a pattern. More...
 
bool ecs_id_is_pair (ecs_id_t id)
 Utility to check if id is a pair. More...
 
bool ecs_id_is_wildcard (ecs_id_t id)
 Utility to check if id is a wildcard. More...
 
bool ecs_id_is_valid (const ecs_world_t *world, ecs_id_t id)
 Utility to check if id is valid. More...
 
ecs_flags32_t ecs_id_get_flags (const ecs_world_t *world, ecs_id_t id)
 Get flags associated with id. More...
 
const char * ecs_id_flag_str (ecs_id_t id_flags)
 Convert id flag to string. More...
 
char * ecs_id_str (const ecs_world_t *world, ecs_id_t id)
 Convert id to string. More...
 
void ecs_id_str_buf (const ecs_world_t *world, ecs_id_t id, ecs_strbuf_t *buf)
 Write id string to buffer. More...
 
ecs_iter_t ecs_term_iter (const ecs_world_t *world, ecs_term_t *term)
 Iterator for a single (component) id. More...
 
ecs_iter_t ecs_term_chain_iter (const ecs_iter_t *it, ecs_term_t *term)
 Return a chained term iterator. More...
 
bool ecs_term_next (ecs_iter_t *it)
 Progress a term iterator. More...
 
ecs_iter_t ecs_children (const ecs_world_t *world, ecs_entity_t parent)
 Iterator for a parent's children. More...
 
bool ecs_children_next (ecs_iter_t *it)
 Progress a children iterator. More...
 
bool ecs_term_id_is_set (const ecs_term_id_t *id)
 Test whether term id is set. More...
 
bool ecs_term_is_initialized (const ecs_term_t *term)
 Test whether a term is set. More...
 
bool ecs_term_match_this (const ecs_term_t *term)
 
bool ecs_term_match_0 (const ecs_term_t *term)
 
int ecs_term_finalize (const ecs_world_t *world, ecs_term_t *term)
 Finalize term. More...
 
ecs_term_t ecs_term_copy (const ecs_term_t *src)
 Copy resources of a term to another term. More...
 
ecs_term_t ecs_term_move (ecs_term_t *src)
 Move resources of a term to another term. More...
 
void ecs_term_fini (ecs_term_t *term)
 Free resources of term. More...
 
ecs_filter_tecs_filter_init (ecs_world_t *world, const ecs_filter_desc_t *desc)
 Initialize filter A filter is a lightweight object that can be used to query for entities in a world. More...
 
void ecs_filter_fini (ecs_filter_t *filter)
 Deinitialize filter. More...
 
int ecs_filter_finalize (const ecs_world_t *world, ecs_filter_t *filter)
 Finalize filter. More...
 
int32_t ecs_filter_find_this_var (const ecs_filter_t *filter)
 Find index for This variable. More...
 
char * ecs_term_str (const ecs_world_t *world, const ecs_term_t *term)
 Convert ter, to string expression. More...
 
char * ecs_filter_str (const ecs_world_t *world, const ecs_filter_t *filter)
 Convert filter to string expression. More...
 
ecs_iter_t ecs_filter_iter (const ecs_world_t *world, const ecs_filter_t *filter)
 Return a filter iterator. More...
 
ecs_iter_t ecs_filter_chain_iter (const ecs_iter_t *it, const ecs_filter_t *filter)
 Return a chained filter iterator. More...
 
int32_t ecs_filter_pivot_term (const ecs_world_t *world, const ecs_filter_t *filter)
 Get pivot term for filter. More...
 
bool ecs_filter_next (ecs_iter_t *it)
 Iterate tables matched by filter. More...
 
bool ecs_filter_next_instanced (ecs_iter_t *it)
 Same as ecs_filter_next, but always instanced. More...
 
void ecs_filter_move (ecs_filter_t *dst, ecs_filter_t *src)
 Move resources of one filter to another.
 
void ecs_filter_copy (ecs_filter_t *dst, const ecs_filter_t *src)
 Copy resources of one filter to another.
 
ecs_query_tecs_query_init (ecs_world_t *world, const ecs_query_desc_t *desc)
 Create a query. More...
 
void ecs_query_fini (ecs_query_t *query)
 Destroy a query. More...
 
const ecs_filter_tecs_query_get_filter (ecs_query_t *query)
 Get filter from a query. More...
 
ecs_iter_t ecs_query_iter (const ecs_world_t *world, ecs_query_t *query)
 Return a query iterator. More...
 
bool ecs_query_next (ecs_iter_t *iter)
 Progress the query iterator. More...
 
bool ecs_query_next_instanced (ecs_iter_t *iter)
 Same as ecs_query_next, but always instanced. More...
 
bool ecs_query_next_table (ecs_iter_t *iter)
 Fast alternative to ecs_query_next that only returns matched tables. More...
 
void ecs_query_populate (ecs_iter_t *iter)
 Populate iterator fields. More...
 
bool ecs_query_changed (ecs_query_t *query, const ecs_iter_t *it)
 Returns whether the query data changed since the last iteration. More...
 
void ecs_query_skip (ecs_iter_t *it)
 Skip a table while iterating. More...
 
void ecs_query_set_group (ecs_iter_t *it, uint64_t group_id)
 Set group to iterate for query iterator. More...
 
void * ecs_query_get_group_ctx (ecs_query_t *query, uint64_t group_id)
 Get context of query group. More...
 
const ecs_query_group_info_tecs_query_get_group_info (ecs_query_t *query, uint64_t group_id)
 Get information about query group. More...
 
bool ecs_query_orphaned (ecs_query_t *query)
 Returns whether query is orphaned. More...
 
char * ecs_query_str (const ecs_query_t *query)
 Convert query to string. More...
 
int32_t ecs_query_table_count (const ecs_query_t *query)
 Returns number of tables query matched with. More...
 
int32_t ecs_query_empty_table_count (const ecs_query_t *query)
 Returns number of empty tables query matched with. More...
 
int32_t ecs_query_entity_count (const ecs_query_t *query)
 Returns number of entities query matched with. More...
 
void ecs_emit (ecs_world_t *world, ecs_event_desc_t *desc)
 Send event. More...
 
ecs_entity_t ecs_observer_init (ecs_world_t *world, const ecs_observer_desc_t *desc)
 Create observer. More...
 
bool ecs_observer_default_run_action (ecs_iter_t *it)
 Default run action for observer. More...
 
void * ecs_get_observer_ctx (const ecs_world_t *world, ecs_entity_t observer)
 
void * ecs_get_observer_binding_ctx (const ecs_world_t *world, ecs_entity_t observer)
 
void ecs_iter_poly (const ecs_world_t *world, const ecs_poly_t *poly, ecs_iter_t *iter, ecs_term_t *filter)
 Create iterator from poly object. More...
 
bool ecs_iter_next (ecs_iter_t *it)
 Progress any iterator. More...
 
void ecs_iter_fini (ecs_iter_t *it)
 Cleanup iterator resources. More...
 
int32_t ecs_iter_count (ecs_iter_t *it)
 Count number of matched entities in query. More...
 
bool ecs_iter_is_true (ecs_iter_t *it)
 Test if iterator is true. More...
 
ecs_entity_t ecs_iter_first (ecs_iter_t *it)
 Get first matching entity from iterator. More...
 
void ecs_iter_set_var (ecs_iter_t *it, int32_t var_id, ecs_entity_t entity)
 Set value for iterator variable. More...
 
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. More...
 
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 entities in a table. More...
 
ecs_entity_t ecs_iter_get_var (ecs_iter_t *it, int32_t var_id)
 Get value of iterator variable as entity. More...
 
ecs_table_tecs_iter_get_var_as_table (ecs_iter_t *it, int32_t var_id)
 Get value of iterator variable as table. More...
 
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. More...
 
bool ecs_iter_var_is_constrained (ecs_iter_t *it, int32_t var_id)
 Returns whether variable is constrained. More...
 
ecs_iter_t ecs_page_iter (const ecs_iter_t *it, int32_t offset, int32_t limit)
 Create a paged iterator. More...
 
bool ecs_page_next (ecs_iter_t *it)
 Progress a paged iterator. More...
 
ecs_iter_t ecs_worker_iter (const ecs_iter_t *it, int32_t index, int32_t count)
 Create a worker iterator. More...
 
bool ecs_worker_next (ecs_iter_t *it)
 Progress a worker iterator. More...
 
void * ecs_field_w_size (const ecs_iter_t *it, size_t size, int32_t index)
 Obtain data for a query field. More...
 
bool ecs_field_is_readonly (const ecs_iter_t *it, int32_t index)
 Test whether the field is readonly. More...
 
bool ecs_field_is_writeonly (const ecs_iter_t *it, int32_t index)
 Test whether the field is writeonly. More...
 
bool ecs_field_is_set (const ecs_iter_t *it, int32_t index)
 Test whether field is set. More...
 
ecs_id_t ecs_field_id (const ecs_iter_t *it, int32_t index)
 Return id matched for field. More...
 
ecs_entity_t ecs_field_src (const ecs_iter_t *it, int32_t index)
 Return field source. More...
 
size_t ecs_field_size (const ecs_iter_t *it, int32_t index)
 Return field type size. More...
 
bool ecs_field_is_self (const ecs_iter_t *it, int32_t index)
 Test whether the field is matched on self. More...
 
char * ecs_iter_str (const ecs_iter_t *it)
 Convert iterator to string. More...
 
const ecs_type_tecs_table_get_type (const ecs_table_t *table)
 Get type for table. More...
 
void * ecs_table_get_column (const ecs_table_t *table, int32_t index, int32_t offset)
 Get column from table. More...
 
int32_t ecs_table_get_index (const ecs_world_t *world, const ecs_table_t *table, ecs_id_t id)
 Get column index for id. More...
 
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. More...
 
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. More...
 
ecs_table_tecs_table_get_storage_table (const ecs_table_t *table)
 Get storage type for table. More...
 
int32_t ecs_table_type_to_storage_index (const ecs_table_t *table, int32_t index)
 Convert index in table type to index in table storage type.
 
int32_t ecs_table_storage_to_type_index (const ecs_table_t *table, int32_t index)
 Convert index in table storage type to index in table type.
 
int32_t ecs_table_count (const ecs_table_t *table)
 Returns the number of records in the table. More...
 
ecs_table_tecs_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. More...
 
ecs_table_tecs_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. More...
 
void ecs_table_lock (ecs_world_t *world, ecs_table_t *table)
 Lock or unlock table. More...
 
void ecs_table_unlock (ecs_world_t *world, ecs_table_t *table)
 Unlock a table. More...
 
bool ecs_table_has_module (ecs_table_t *table)
 Returns whether table is a module or contains module contents Returns true for tables that have module contents. More...
 
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. More...
 
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. More...
 
ecs_record_t * ecs_record_find (const ecs_world_t *world, ecs_entity_t entity)
 Find record for entity.
 
void * ecs_record_get_column (const ecs_record_t *r, int32_t column, size_t c_size)
 Get component pointer from column/record.
 
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. More...
 
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. More...
 
int32_t ecs_search_relation (const ecs_world_t *world, const ecs_table_t *table, int32_t offset, ecs_id_t id, ecs_entity_t rel, ecs_flags32_t flags, ecs_entity_t *subject_out, ecs_id_t *id_out, struct ecs_table_record_t **tr_out)
 Search for component/relationship id in table type starting from an offset. More...
 
int ecs_value_init (const ecs_world_t *world, ecs_entity_t type, void *ptr)
 Construct a value in existing storage. More...
 
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. More...
 
void * ecs_value_new (ecs_world_t *world, ecs_entity_t type)
 Construct a value in new storage. More...
 
int ecs_value_fini_w_type_info (const ecs_world_t *world, const ecs_type_info_t *ti, void *ptr)
 Destruct a value. More...
 
int ecs_value_fini (const ecs_world_t *world, ecs_entity_t type, void *ptr)
 Destruct a value. More...
 
int ecs_value_free (ecs_world_t *world, ecs_entity_t type, void *ptr)
 Destruct a value, free storage. More...
 
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. More...
 
int ecs_value_copy (const ecs_world_t *world, ecs_entity_t type, void *dst, const void *src)
 Copy value. More...
 
int ecs_value_move_w_type_info (const ecs_world_t *world, const ecs_type_info_t *ti, void *dst, void *src)
 Move value. More...
 
int ecs_value_move (const ecs_world_t *world, ecs_entity_t type, void *dst, void *src)
 Move value. More...
 
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. More...
 
int ecs_value_move_ctor (const ecs_world_t *world, ecs_entity_t type, void *dst, void *src)
 Move construct value. More...
 

Variables

ecs_filter_t ECS_FILTER_INIT
 Use this variable to initialize user-allocated filter object.
 
const ecs_id_t ECS_PAIR
 Indicates that the id is a pair.
 
const ecs_id_t ECS_OVERRIDE
 Automatically override component when it is inherited.
 
const ecs_id_t ECS_TOGGLE
 Adds bitset to storage which allows component to be enabled/disabled.
 
const ecs_id_t ECS_AND
 Include all components from entity to which AND is applied.
 
const ecs_entity_t FLECS__EEcsComponent
 
const ecs_entity_t FLECS__EEcsIdentifier
 
const ecs_entity_t FLECS__EEcsIterable
 
const ecs_entity_t FLECS__EEcsPoly
 
const ecs_entity_t EcsQuery
 
const ecs_entity_t EcsObserver
 
const ecs_entity_t EcsSystem
 
const ecs_entity_t FLECS__EEcsTickSource
 
const ecs_entity_t FLECS__EEcsPipelineQuery
 
const ecs_entity_t FLECS__EEcsTimer
 
const ecs_entity_t FLECS__EEcsRateFilter
 
const ecs_entity_t EcsFlecs
 Root scope for builtin flecs entities.
 
const ecs_entity_t EcsFlecsCore
 Core module scope.
 
const ecs_entity_t EcsWorld
 Entity associated with world (used for "attaching" components to world)
 
const ecs_entity_t EcsWildcard
 Wildcard entity ("*"). More...
 
const ecs_entity_t EcsAny
 Any entity ("_"). More...
 
const ecs_entity_t EcsThis
 This entity. More...
 
const ecs_entity_t EcsVariable
 Variable entity ("$"). More...
 
const ecs_entity_t EcsTransitive
 Marks a relationship as transitive. More...
 
const ecs_entity_t EcsReflexive
 Marks a relatoinship as reflexive. More...
 
const ecs_entity_t EcsFinal
 Ensures that entity/component cannot be used as target in IsA relationship. More...
 
const ecs_entity_t EcsDontInherit
 Ensures that component is never inherited from an IsA target. More...
 
const ecs_entity_t EcsSymmetric
 Marks relationship as commutative. More...
 
const ecs_entity_t EcsExclusive
 Can be added to relationship to indicate that the relationship can only occur once on an entity. More...
 
const ecs_entity_t EcsAcyclic
 Marks a relationship as acyclic. More...
 
const ecs_entity_t EcsTraversable
 Marks a relationship as traversable. More...
 
const ecs_entity_t EcsWith
 Ensure that a component always is added together with another component. More...
 
const ecs_entity_t EcsOneOf
 Ensure that relationship target is child of specified entity. More...
 
const ecs_entity_t EcsTag
 Can be added to relationship to indicate that it should never hold data, even when it or the relationship target is a component.
 
const ecs_entity_t EcsUnion
 Tag to indicate that relationship is stored as union. More...
 
const ecs_entity_t EcsName
 Tag to indicate name identifier.
 
const ecs_entity_t EcsSymbol
 Tag to indicate symbol identifier.
 
const ecs_entity_t EcsAlias
 Tag to indicate alias identifier.
 
const ecs_entity_t EcsChildOf
 Used to express parent-child relationships.
 
const ecs_entity_t EcsIsA
 Used to express inheritance relationships.
 
const ecs_entity_t EcsDependsOn
 Used to express dependency relationships.
 
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 EcsPrivate
 Tag to indicate an entity/component/system is private to a module.
 
const ecs_entity_t EcsPrefab
 Tag added to prefab entities. More...
 
const ecs_entity_t EcsDisabled
 When this tag is added to an entity it is skipped by all queries/filters.
 
const ecs_entity_t EcsOnAdd
 Event. More...
 
const ecs_entity_t EcsOnRemove
 Event. More...
 
const ecs_entity_t EcsOnSet
 Event. More...
 
const ecs_entity_t EcsUnSet
 Event. More...
 
const ecs_entity_t EcsMonitor
 Event. More...
 
const ecs_entity_t EcsOnDelete
 Event. More...
 
const ecs_entity_t EcsOnTableCreate
 Event. More...
 
const ecs_entity_t EcsOnTableDelete
 Event. More...
 
const ecs_entity_t EcsOnTableEmpty
 Event. More...
 
const ecs_entity_t EcsOnTableFill
 Event. More...
 
const ecs_entity_t EcsOnDeleteTarget
 Relationship used to define what should happen when a target entity (second element of a pair) is deleted. More...
 
const ecs_entity_t EcsRemove
 Remove cleanup policy. More...
 
const ecs_entity_t EcsDelete
 Delete cleanup policy. More...
 
const ecs_entity_t EcsPanic
 Panic cleanup policy. More...
 
const ecs_entity_t EcsDefaultChildComponent
 Used like (EcsDefaultChildComponent, Component). More...
 
const ecs_entity_t EcsEmpty
 Tag used to indicate query is empty.
 
const ecs_entity_t FLECS__EEcsPipeline
 
const ecs_entity_t EcsOnStart
 
const ecs_entity_t EcsPreFrame
 
const ecs_entity_t EcsOnLoad
 
const ecs_entity_t EcsPostLoad
 
const ecs_entity_t EcsPreUpdate
 
const ecs_entity_t EcsOnUpdate
 
const ecs_entity_t EcsOnValidate
 
const ecs_entity_t EcsPostUpdate
 
const ecs_entity_t EcsPreStore
 
const ecs_entity_t EcsOnStore
 
const ecs_entity_t EcsPostFrame
 
const ecs_entity_t EcsPhase
 

Detailed Description

Flecs public API.

This file contains the public API for Flecs.

Definition in file flecs.h.