![]() |
Flecs v3.2
A fast entity component system (ECS) for C & C++
|
Untyped component class. More...
#include <component.hpp>
Public Member Functions | |
entity () | |
entity (world_t *world) | |
Create entity. More... | |
entity (const flecs::world_t *world, flecs::id_t id) | |
Wrap an existing entity id. More... | |
entity (world_t *world, const char *name) | |
Create a named entity. More... | |
entity (entity_t id) | |
Conversion from flecs::entity_t to flecs::entity. More... | |
![]() | |
entity (world_t *world) | |
Create entity. More... | |
entity (const flecs::world_t *world, flecs::id_t id) | |
Wrap an existing entity id. More... | |
entity (world_t *world, const char *name) | |
Create a named entity. More... | |
entity (entity_t id) | |
Conversion from flecs::entity_t to flecs::entity. More... | |
template<typename T > | |
T * | get_mut () const |
Get mutable component value. More... | |
void * | get_mut (entity_t comp) const |
Get mutable component value (untyped). More... | |
template<typename First , typename Second , typename P = pair<First, Second>, typename A = actual_type_t<P>, if_not_t< flecs::is_pair< First >::value > = 0> | |
A * | get_mut () const |
Get mutable pointer for a pair. More... | |
template<typename First > | |
First * | get_mut (entity_t second) const |
Get mutable pointer for the first element of a pair. More... | |
void * | get_mut (entity_t first, entity_t second) const |
Get mutable pointer for a pair (untyped). More... | |
template<typename Second > | |
Second * | get_mut_second (entity_t first) const |
Get mutable pointer for the second element of a pair. More... | |
template<typename T > | |
void | modified () const |
Signal that component was modified. More... | |
template<typename First , typename Second > | |
void | modified () const |
Signal that the first element of a pair was modified. More... | |
template<typename First > | |
void | modified (entity_t second) const |
Signal that the first part of a pair was modified. More... | |
void | modified (entity_t first, entity_t second) const |
Signal that a pair has modified (untyped). More... | |
void | modified (entity_t comp) const |
Signal that component was modified. More... | |
template<typename T > | |
ref< T > | get_ref () const |
Get reference to component. More... | |
template<typename First , typename Second , typename P = flecs::pair<First, Second>, typename A = actual_type_t<P>> | |
ref< A > | get_ref () const |
template<typename First > | |
ref< First > | get_ref (flecs::entity_t second) const |
template<typename Second > | |
ref< Second > | get_ref_second (flecs::entity_t first) const |
void | flatten (flecs::entity_t r, const ecs_flatten_desc_t *desc=nullptr) |
Recursively flatten relationship. More... | |
void | clear () const |
Clear an entity. More... | |
void | destruct () const |
Delete an entity. More... | |
flecs::entity_view | view () const |
Return entity as entity_view. More... | |
const char * | from_json (const char *json) |
Deserialize entity to JSON. More... | |
![]() | |
entity & | add () |
Add a component to an entity. More... | |
entity & | add (E value) |
Add pair for enum constant. More... | |
entity & | add (id_t component) |
Add an entity to an entity. More... | |
entity & | add (entity_t first, entity_t second) |
Add a pair. More... | |
entity & | add () |
Add a pair. More... | |
entity & | add (Second second) |
Add a pair. More... | |
entity & | add (Second constant) |
Add a pair. More... | |
entity & | add_second (flecs::entity_t first) |
Add a pair. More... | |
entity & | add_if (bool cond, flecs::id_t component) |
Conditional add. More... | |
entity & | add_if (bool cond) |
Conditional add. More... | |
entity & | add_if (bool cond, flecs::entity_t first, flecs::entity_t second) |
Conditional add. More... | |
entity & | add_if (bool cond, flecs::entity_t second) |
Conditional add. More... | |
entity & | add_if (bool cond) |
Conditional add. More... | |
entity & | add_if (bool cond, E constant) |
Conditional add. More... | |
entity & | is_a (entity_t second) |
Shortcut for add(IsA, entity). More... | |
entity & | is_a () |
Shortcut for add(IsA, entity). More... | |
entity & | child_of (entity_t second) |
Shortcut for add(ChildOf, entity). More... | |
entity & | child_of () |
Shortcut for add(ChildOf, entity). More... | |
entity & | depends_on (entity_t second) |
Shortcut for add(DependsOn, entity). More... | |
entity & | depends_on () |
Shortcut for add(DependsOn, entity). More... | |
entity & | slot_of (entity_t second) |
Shortcut for add(SlotOf, entity). More... | |
entity & | slot_of () |
Shortcut for add(SlotOf, entity). More... | |
entity & | slot () |
Shortcut for add(SlotOf, target(ChildOf)). More... | |
entity & | remove () |
Remove a component from an entity. More... | |
entity & | remove () |
Remove pair for enum. More... | |
entity & | remove (entity_t entity) |
Remove an entity from an entity. More... | |
entity & | remove (entity_t first, entity_t second) |
Remove a pair. More... | |
entity & | remove () |
Removes a pair. More... | |
entity & | remove (Second second) |
Remove a pair. More... | |
entity & | remove (Second constant) |
Remove a pair. More... | |
entity & | remove_second (flecs::entity_t first) |
Removes a pair. More... | |
entity & | override (flecs::id_t id) |
Mark id for auto-overriding. More... | |
entity & | override (flecs::entity_t first, flecs::entity_t second) |
Mark pair for auto-overriding. More... | |
entity & | override () |
Mark component for auto-overriding. More... | |
entity & | override (flecs::entity_t second) |
Mark pair for auto-overriding. More... | |
entity & | override () |
Mark pair for auto-overriding. More... | |
entity & | set_override (const T &val) |
Set component, mark component for auto-overriding. More... | |
entity & | set_override (T &&val) |
Set component, mark component for auto-overriding. More... | |
entity & | set_override (flecs::entity_t second, const First &val) |
Set pair, mark component for auto-overriding. More... | |
entity & | set_override (flecs::entity_t second, First &&val) |
Set pair, mark component for auto-overriding. More... | |
entity & | set_override (const A &val) |
Set component, mark component for auto-overriding. More... | |
entity & | set_override (A &&val) |
Set component, mark component for auto-overriding. More... | |
entity & | emplace_override (Args &&... args) |
Emplace component, mark component for auto-overriding. More... | |
entity & | emplace_override (Args &&... args) |
Emplace pair, mark pair for auto-overriding. More... | |
entity & | enable () |
Enable an entity. More... | |
entity & | enable (flecs::id_t id, bool toggle=true) |
Enable an id. More... | |
entity & | enable () |
Enable a component. More... | |
entity & | enable (flecs::id_t first, flecs::id_t second) |
Enable a pair. More... | |
entity & | enable (flecs::id_t second) |
Enable a pair. More... | |
entity & | enable () |
Enable a pair. More... | |
entity & | disable () |
Disable an entity. More... | |
entity & | disable (flecs::id_t id) |
Disable an id. More... | |
entity & | disable () |
Disable a component. More... | |
entity & | disable (flecs::id_t first, flecs::id_t second) |
Disable a pair. More... | |
entity & | disable (flecs::id_t second) |
Disable a pair. More... | |
entity & | disable () |
Disable a pair. More... | |
entity & | set_ptr (entity_t comp, size_t size, const void *ptr) |
entity & | set_ptr (entity_t comp, const void *ptr) |
entity & | set (T &&value) |
entity & | set (const T &value) |
entity & | set (A &&value) |
entity & | set (const A &value) |
entity & | set (A &&value) |
Set a pair for an entity. More... | |
entity & | set (const A &value) |
Set a pair for an entity. More... | |
entity & | set (Second second, const First &value) |
Set a pair for an entity. More... | |
entity & | set (Second second, First &&value) |
Set a pair for an entity. More... | |
entity & | set (Second constant, const First &value) |
Set a pair for an entity. More... | |
entity & | set (const Func &func) |
Set 1..N components. More... | |
entity & | set_second (entity_t first, const Second &value) |
Set a pair for an entity. More... | |
entity & | set_second (entity_t first, Second &&value) |
Set a pair for an entity. More... | |
entity & | set_second (const Second &value) |
entity & | emplace (Args &&... args) |
Emplace component. More... | |
entity & | emplace (Args &&... args) |
entity & | emplace_first (flecs::entity_t second, Args &&... args) |
entity & | emplace_second (flecs::entity_t first, Args &&... args) |
entity & | with (const Func &func) |
Entities created in function will have the current entity. More... | |
entity & | with (const Func &func) |
Entities created in function will have (First, this). More... | |
entity & | with (entity_t first, const Func &func) |
Entities created in function will have (first, this). More... | |
entity & | scope (const Func &func) |
The function will be ran with the scope set to the current entity. More... | |
scoped_world | scope () const |
Return world scoped to entity. More... | |
entity & | set_name (const char *name) |
entity & | set_alias (const char *name) |
entity & | set_doc_name (const char *name) |
Set doc name. More... | |
entity & | set_doc_brief (const char *brief) |
Set doc brief. More... | |
entity & | set_doc_detail (const char *detail) |
Set doc detailed description. More... | |
entity & | set_doc_link (const char *link) |
Set doc link. More... | |
entity & | set_doc_color (const char *link) |
Set doc color. More... | |
entity & | observe (flecs::entity_t evt, Func &&callback) |
Observe event on entity. More... | |
entity & | observe (Func &&callback) |
Observe event on entity. More... | |
entity & | observe (Func &&callback) |
Observe event on entity. More... | |
entity & | set_json (flecs::id_t e, const char *json, flecs::from_json_desc_t *desc=nullptr) |
Set component from JSON. More... | |
entity & | set_json (flecs::entity_t r, flecs::entity_t t, const char *json, flecs::from_json_desc_t *desc=nullptr) |
Set pair from JSON. More... | |
entity & | set_json (const char *json, flecs::from_json_desc_t *desc=nullptr) |
Set component from JSON. More... | |
entity & | set_json (const char *json, flecs::from_json_desc_t *desc=nullptr) |
Set pair from JSON. More... | |
entity & | set_json (flecs::entity_t t, const char *json, flecs::from_json_desc_t *desc=nullptr) |
Set pair from JSON. More... | |
entity & | set_json_second (flecs::entity_t r, const char *json, flecs::from_json_desc_t *desc=nullptr) |
Set pair from JSON. More... | |
entity_view () | |
entity_view (flecs::world_t *world, flecs::id_t id) | |
Wrap an existing entity id. More... | |
entity_view (entity_t id) | |
Implicit conversion from flecs::entity_t to flecs::entity_view. More... | |
![]() | |
entity_view (flecs::world_t *world, flecs::id_t id) | |
Wrap an existing entity id. More... | |
entity_view (entity_t id) | |
Implicit conversion from flecs::entity_t to flecs::entity_view. More... | |
entity_t | id () const |
Get entity id. More... | |
bool | is_valid () const |
Check if entity is valid. More... | |
operator bool () const | |
bool | is_alive () const |
Check if entity is alive. More... | |
flecs::string_view | name () const |
Return the entity name. More... | |
flecs::string_view | symbol () const |
Return the entity symbol. More... | |
flecs::string | path (const char *sep="::", const char *init_sep="::") const |
Return the entity path. More... | |
flecs::string | path_from (flecs::entity_t parent, const char *sep="::", const char *init_sep="::") const |
Return the entity path relative to a parent. More... | |
template<typename Parent > | |
flecs::string | path_from (const char *sep="::", const char *init_sep="::") const |
Return the entity path relative to a parent. More... | |
bool | enabled () const |
flecs::type | type () const |
Get the entity's type. More... | |
flecs::table | table () const |
Get the entity's table. More... | |
flecs::table_range | range () const |
Get table range for the entity. More... | |
template<typename Func > | |
void | each (const Func &func) const |
Iterate (component) ids of an entity. More... | |
template<typename Func > | |
void | each (flecs::id_t first, flecs::id_t second, const Func &func) const |
Iterate matching pair ids of an entity. More... | |
template<typename Func > | |
void | each (const flecs::entity_view &rel, const Func &func) const |
Iterate targets for a given relationship. More... | |
template<typename First , typename Func > | |
void | each (const Func &func) const |
Iterate targets for a given relationship. More... | |
template<typename Func > | |
void | children (flecs::entity_t rel, Func &&func) const |
Iterate children for entity. More... | |
template<typename Rel , typename Func > | |
void | children (Func &&func) const |
Iterate children for entity. More... | |
template<typename Func > | |
void | children (Func &&func) const |
Iterate children for entity. More... | |
template<typename T , if_t< is_actual< T >::value > = 0> | |
const T * | get () const |
Get component value. More... | |
template<typename T , typename A = actual_type_t<T>, if_t< flecs::is_pair< T >::value > = 0> | |
const A * | get () const |
Get component value. More... | |
template<typename First , typename Second , typename P = pair<First, Second>, typename A = actual_type_t<P>, if_not_t< flecs::is_pair< First >::value > = 0> | |
const A * | get () const |
Get a pair. More... | |
template<typename First , typename Second , if_not_t< is_enum< Second >::value > = 0> | |
const First * | get (Second second) const |
Get a pair. More... | |
template<typename First , typename Second , if_t< is_enum< Second >::value > = 0> | |
const First * | get (Second constant) const |
Get a pair. More... | |
const void * | get (flecs::id_t comp) const |
Get component value (untyped). More... | |
const void * | get (flecs::entity_t first, flecs::entity_t second) const |
Get a pair (untyped). More... | |
template<typename Func , if_t< is_callable< Func >::value > = 0> | |
bool | get (const Func &func) const |
Get 1..N components. More... | |
template<typename T , if_t< is_enum< T >::value > = 0> | |
const T * | get () const |
Get enum constant. More... | |
template<typename Second > | |
const Second * | get_second (flecs::entity_t first) const |
Get the second part for a pair. More... | |
template<typename First , typename Second > | |
const Second * | get_second () const |
Get the second part for a pair. More... | |
template<typename First > | |
flecs::entity | target (int32_t index=0) const |
Get target for a given pair. More... | |
flecs::entity | target (flecs::entity_t first, int32_t index=0) const |
Get target for a given pair. More... | |
flecs::entity | target_for (flecs::entity_t relationship, flecs::id_t id) const |
Get the target of a pair for a given relationship id. More... | |
template<typename T > | |
flecs::entity | target_for (flecs::entity_t relationship) const |
template<typename First , typename Second > | |
flecs::entity | target_for (flecs::entity_t relationship) const |
int32_t | depth (flecs::entity_t rel) const |
Get depth for given relationship. More... | |
template<typename Rel > | |
int32_t | depth () const |
Get depth for given relationship. More... | |
flecs::entity | parent () const |
Get parent of entity. More... | |
flecs::entity | lookup (const char *path, bool search_path=false) const |
Lookup an entity by name. More... | |
bool | has (flecs::id_t e) const |
Check if entity has the provided entity. More... | |
template<typename T > | |
bool | has () const |
Check if entity has the provided component. More... | |
template<typename E , if_t< is_enum< E >::value > = 0> | |
bool | has (E value) const |
Check if entity has the provided enum constant. More... | |
template<typename First , typename Second > | |
bool | has () const |
Check if entity has the provided pair. More... | |
template<typename First , typename Second , if_not_t< is_enum< Second >::value > = 0> | |
bool | has (Second second) const |
Check if entity has the provided pair. More... | |
template<typename Second > | |
bool | has_second (flecs::entity_t first) const |
Check if entity has the provided pair. More... | |
template<typename First , typename E , if_t< is_enum< E >::value > = 0> | |
bool | has (E value) const |
Check if entity has the provided pair. More... | |
bool | has (flecs::id_t first, flecs::id_t second) const |
Check if entity has the provided pair. More... | |
bool | owns (flecs::id_t e) const |
Check if entity owns the provided entity. More... | |
template<typename First > | |
bool | owns (flecs::id_t second) const |
Check if entity owns the provided pair. More... | |
bool | owns (flecs::id_t first, flecs::id_t second) const |
Check if entity owns the provided pair. More... | |
template<typename T > | |
bool | owns () const |
Check if entity owns the provided component. More... | |
template<typename First , typename Second > | |
bool | owns () const |
Check if entity owns the provided pair. More... | |
bool | enabled (flecs::id_t id) const |
Test if id is enabled. More... | |
template<typename T > | |
bool | enabled () const |
Test if component is enabled. More... | |
bool | enabled (flecs::id_t first, flecs::id_t second) const |
Test if pair is enabled. More... | |
template<typename First > | |
bool | enabled (flecs::id_t second) const |
Test if pair is enabled. More... | |
template<typename First , typename Second > | |
bool | enabled () const |
Test if pair is enabled. More... | |
flecs::entity | clone (bool clone_value=true, flecs::entity_t dst_id=0) const |
flecs::entity | mut (const flecs::world &stage) const |
Return mutable entity handle for current stage When an entity handle created from the world is used while the world is in staged mode, it will only allow for readonly operations since structural changes are not allowed on the world while in staged mode. More... | |
flecs::entity | mut (const flecs::iter &it) const |
Same as mut(world), but for iterator. More... | |
flecs::entity | mut (const flecs::entity_view &e) const |
Same as mut(world), but for entity. More... | |
int32_t | alert_count (flecs::entity_t alert=0) const |
Return number of alerts for entity. More... | |
template<typename E > | |
E | to_constant () const |
Convert entity to enum constant. More... | |
void | emit (flecs::entity_t evt) |
Emit event for entity. More... | |
void | emit (flecs::entity evt) |
Emit event for entity. More... | |
template<typename Evt , if_t< is_empty< Evt >::value > = 0> | |
void | emit () |
Emit event for entity. More... | |
template<typename Evt , if_not_t< is_empty< Evt >::value > = 0> | |
void | emit (const Evt &payload) |
Emit event with payload for entity. More... | |
void | enqueue (flecs::entity_t evt) |
Enqueue event for entity. More... | |
void | enqueue (flecs::entity evt) |
Enqueue event for entity. More... | |
template<typename Evt , if_t< is_empty< Evt >::value > = 0> | |
void | enqueue () |
Enqueue event for entity. More... | |
template<typename Evt , if_not_t< is_empty< Evt >::value > = 0> | |
void | enqueue (const Evt &payload) |
Enqueue event with payload for entity. More... | |
flecs::string | to_json (const flecs::entity_to_json_desc_t *desc=nullptr) |
Serialize entity to JSON. More... | |
Self & | unit (const char *symbol, flecs::entity_t prefix=0, flecs::entity_t base=0, flecs::entity_t over=0, int32_t factor=0, int32_t power=0) |
Make entity a unit. More... | |
![]() | |
id (flecs::id_t value) | |
id (flecs::world_t *world, flecs::id_t value=0) | |
id (flecs::world_t *world, flecs::id_t first, flecs::id_t second) | |
id (flecs::id_t first, flecs::id_t second) | |
id (const flecs::id &first, const flecs::id &second) | |
bool | is_pair () const |
Test if id is pair (has first, second) More... | |
bool | is_wildcard () const |
Test if id is a wildcard. More... | |
bool | is_entity () const |
Test if id is entity. More... | |
flecs::entity | entity () const |
Return id as entity (only allowed when id is valid entity) More... | |
flecs::entity | add_flags (flecs::id_t flags) const |
Return id with role added. More... | |
flecs::entity | remove_flags (flecs::id_t flags) const |
Return id with role removed. More... | |
flecs::entity | remove_flags () const |
Return id without role. More... | |
flecs::entity | remove_generation () const |
Return id without role. More... | |
flecs::entity | type_id () const |
Return component type of id. More... | |
bool | has_flags (flecs::id_t flags) const |
Test if id has specified role. More... | |
bool | has_flags () const |
Test if id has any role. More... | |
flecs::entity | flags () const |
Return id flags set on id. More... | |
bool | has_relation (flecs::id_t first) const |
Test if id has specified first. More... | |
flecs::entity | first () const |
Get first element from a pair. More... | |
flecs::entity | second () const |
Get second element from a pair. More... | |
flecs::string | str () const |
flecs::string | flags_str () const |
Convert role of id to string. More... | |
flecs::id_t | raw_id () const |
Return flecs::id_t value. More... | |
operator flecs::id_t () const | |
flecs::world | world () const |
Additional Inherited Members | |
![]() | |
static flecs::entity | null (const flecs::world_t *world) |
Entity id 0. More... | |
static flecs::entity | null () |
![]() | |
entity & | to_base () |
![]() | |
flecs::world_t * | m_world |
flecs::id_t | m_id |
![]() | |
Self & | unit (flecs::entity_t prefix=0, flecs::entity_t base=0, flecs::entity_t over=0, int32_t factor=0, int32_t power=0) |
Make entity a derived unit. More... | |
Self & | unit_prefix (const char *symbol, int32_t factor=0, int32_t power=0) |
Make entity a derived unit. More... | |
Self & | quantity (flecs::entity_t quantity) |
Add quantity to unit. More... | |
template<typename Quantity > | |
Self & | quantity () |
Make entity a unity prefix. More... | |
Self & | quantity () |
Make entity a quantity. More... | |
Untyped component class.
Generic base class for flecs::component.
Definition at line 331 of file component.hpp.
|
inline |
Definition at line 31 of file entity.hpp.
|
inlineexplicit |
Wrap an existing entity id.
world | The world in which the entity is created. |
id | The entity id. |
Definition at line 49 of file entity.hpp.
|
inlineexplicit |
Conversion from flecs::entity_t to flecs::entity.
id | The entity_t value to convert. |
Definition at line 79 of file entity.hpp.
|
inlineexplicit |
Create entity.
world | The world in which to create the entity. |
Definition at line 37 of file entity.hpp.
|
inlineexplicit |
Create a named entity.
Named entities can be looked up with the lookup functions. Entity names may be scoped, where each element in the name is separated by "::". For example: "Foo::Bar". If parts of the hierarchy in the scoped name do not yet exist, they will be automatically created.
world | The world in which to create the entity. |
name | The entity name. |
Definition at line 63 of file entity.hpp.