Gaia-ECS v0.9.3
A simple and powerful entity component system
Loading...
Searching...
No Matches
gaia::ecs::World Class Referencefinal

Classes

struct  EntityBuilder
 

Public Member Functions

 World (World &&)=delete
 
 World (const World &)=delete
 
Worldoperator= (World &&)=delete
 
Worldoperator= (const World &)=delete
 
template<bool UseCache = true>
auto query ()
 Provides a query set up to work with the parent world.
 
GAIA_NODISCARD EntityContainerfetch (Entity entity)
 
GAIA_NODISCARD const EntityContainerfetch (Entity entity) const
 
void set_serializer (ser::ISerializer *pSerializer)
 
ser::ISerializerget_serializer () const
 
GAIA_NODISCARD ComponentCachecomp_cache_mut ()
 
GAIA_NODISCARD const ComponentCachecomp_cache () const
 
GAIA_NODISCARD QuerySerMapquery_ser_map ()
 
GAIA_NODISCARD bool valid (Entity entity) const
 Checks if entity is valid.
 
GAIA_NODISCARD Entity get (EntityId id) const
 Returns the entity located at the index id.
 
template<typename T >
GAIA_NODISCARD Entity get () const
 
EntityBuilder build (Entity entity)
 Starts a bulk add/remove operation on entity.
 
GAIA_NODISCARD Entity add (EntityKind kind=EntityKind::EK_Gen)
 Creates a new empty entity.
 
template<typename Func = TFunc_Void_With_Entity>
void add_n (uint32_t count, Func func=func_void_with_entity)
 Creates count new empty entities.
 
template<typename Func = TFunc_Void_With_Entity>
void add_n (Entity entity, uint32_t count, Func func=func_void_with_entity)
 Creates count of entities of the same archetype as entity.
 
template<typename T >
GAIA_NODISCARD const ComponentCacheItemadd ()
 Creates a new component if not found already.
 
void add (Entity entity, Entity object)
 Attaches entity object to entity entity.
 
void add (Entity entity, Pair pair)
 Creates a new entity relationship pair.
 
template<typename T >
void add (Entity entity)
 Attaches a new component T to entity.
 
template<typename T >
void add (Entity entity, Entity object, T &&value)
 Attaches object to entity. Also sets its value.
 
template<typename T , typename U = typename actual_type_t<T>::Type>
void add (Entity entity, U &&value)
 Attaches a new component T to entity. Also sets its value.
 
void clear (Entity entity)
 Removes any component or entity attached to entity.
 
GAIA_NODISCARD Entity copy (Entity srcEntity)
 Creates a new entity by cloning an already existing one.
 
template<typename Func = TFunc_Void_With_Entity>
void copy_n (Entity entity, uint32_t count, Func func=func_void_with_entity)
 Creates count new entities by cloning an already existing one.
 
void del (Entity entity)
 Removes an entity along with all data associated with it.
 
void del (Entity entity, Entity object)
 Removes an object from entity if possible.
 
void del (Entity entity, Pair pair)
 Removes an existing entity relationship pair.
 
template<typename T >
void del (Entity entity)
 Removes a component T from entity.
 
void as (Entity entity, Entity entityBase)
 Shortcut for add(entity, Pair(Is, entityBase)
 
GAIA_NODISCARD bool is (Entity entity, Entity entityBase) const
 Checks if entity inherits from entityBase.
 
GAIA_NODISCARD bool in (Entity entity, Entity entityBase) const
 Checks if entity is located in entityBase. This is almost the same as "is" with the exception that false is returned if entity matches entityBase.
 
GAIA_NODISCARD bool is_base (Entity target) const
 
void child (Entity entity, Entity parent)
 Shortcut for add(entity, Pair(ChildOf, parent)
 
GAIA_NODISCARD bool child (Entity entity, Entity parent) const
 Checks if.
 
template<typename T >
void modify (Entity entity)
 Marks the component T as modified. Best used with acc_mut().sset() or set() to manually trigger an update at user's whim. If TriggerHooks is true, also triggers the component's set hooks.
 
GAIA_NODISCARD ComponentSetter acc_mut (Entity entity)
 Starts a bulk set operation on entity.
 
template<typename T >
GAIA_NODISCARD decltype(auto) set (Entity entity)
 Sets the value of the component T on entity.
 
template<typename T >
GAIA_NODISCARD decltype(auto) sset (Entity entity)
 Sets the value of the component T on entity without triggering a world version update.
 
template<typename T >
GAIA_NODISCARD decltype(auto) mut (Entity entity)
 Sets the value of the component T on entity without triggering a world version update.
 
ComponentGetter acc (Entity entity) const
 Starts a bulk get operation on an entity.
 
template<typename T >
GAIA_NODISCARD decltype(auto) get (Entity entity) const
 Returns the value stored in the component T on entity.
 
GAIA_NODISCARD bool has (Entity entity) const
 Checks if entity is currently used by the world.
 
GAIA_NODISCARD bool has (Pair pair) const
 Checks if pair is currently used by the world.
 
GAIA_NODISCARD bool has (Entity entity, Entity object) const
 Checks if entity contains the entity object.
 
GAIA_NODISCARD bool has (Entity entity, Pair pair) const
 Checks if entity contains pair.
 
template<typename T >
GAIA_NODISCARD bool has (Entity entity) const
 Checks if entity contains the component T.
 
void name (Entity entity, const char *name, uint32_t len=0)
 Assigns a name to entity. Ignored if used with pair. The string is copied and kept internally.
 
void name_raw (Entity entity, const char *name, uint32_t len=0)
 Assigns a name to entity. Ignored if used with pair. The string is NOT copied. Your are responsible for its lifetime.
 
GAIA_NODISCARD const char * name (Entity entity) const
 Returns the name assigned to entity.
 
GAIA_NODISCARD const char * name (EntityId entityId) const
 Returns the name assigned to entityId.
 
GAIA_NODISCARD Entity get (const char *name, uint32_t len=0) const
 Returns the entity that is assigned a name name. If the name contains the character '.' hierarchical lookup is use. E.g. "parent.child.subchild" will return the entity for subchild is the entire tree could be found by name.
 
GAIA_NODISCARD Entity get_inter (const char *name, uint32_t len=0) const
 
GAIA_NODISCARD const cnt::set< EntityLookupKey > * relations (Entity target) const
 Returns relations for target.
 
GAIA_NODISCARD Entity relation (Entity entity, Entity target) const
 Returns the first relationship relation for the target entity on entity.
 
template<typename Func >
void relations (Entity entity, Entity target, Func func) const
 Returns the relationship relations for the target entity on entity.
 
template<typename Func >
void relations_if (Entity entity, Entity target, Func func) const
 Returns the relationship relations for the target entity on entity.
 
template<typename Func >
void as_relations_trav (Entity target, Func func) const
 
template<typename Func >
GAIA_NODISCARD bool as_relations_trav_if (Entity target, Func func) const
 
GAIA_NODISCARD const cnt::set< EntityLookupKey > * targets (Entity relation) const
 Returns targets for relation.
 
GAIA_NODISCARD Entity target (Entity entity, Entity relation) const
 Returns the first relationship target for the relation entity on entity.
 
template<typename Func >
void targets (Entity entity, Entity relation, Func func) const
 Returns the relationship targets for the relation entity on entity.
 
template<typename Func >
void targets_if (Entity entity, Entity relation, Func func) const
 Returns the relationship targets for the relation entity on entity.
 
template<typename Func >
void as_targets_trav (Entity relation, Func func) const
 
template<typename Func >
bool as_targets_trav_if (Entity relation, Func func) const
 
CommandBufferSTcmd_buffer_st () const
 
CommandBufferMTcmd_buffer_mt () const
 
void enable (Entity entity, bool enable)
 Enables or disables an entire entity.
 
GAIA_NODISCARD bool enabled (Entity entity) const
 Checks if an entity is enabled.
 
GAIA_NODISCARD Chunkget_chunk (Entity entity) const
 Returns a chunk containing the entity.
 
GAIA_NODISCARD Chunkget_chunk (Entity entity, uint32_t &row) const
 Returns a chunk containing the entity. Index of the entity is stored in row.
 
GAIA_NODISCARD uint32_t size () const
 Returns the number of active entities.
 
GAIA_NODISCARD uint32_t & world_version ()
 Returns the current version of the world.
 
void set_max_lifespan (Entity entity, uint32_t lifespan=Archetype::MAX_ARCHETYPE_LIFESPAN)
 Sets maximal lifespan of an archetype entity belongs to.
 
void update ()
 Performs various internal operations related to the end of the frame such as memory cleanup and other management operations which keep the system healthy.
 
void cleanup ()
 Clears the world so that all its entities and components are released.
 
void defrag_entities_per_tick (uint32_t value)
 Sets the maximum number of entities defragmented per world tick.
 
void diag_archetypes () const
 Performs diagnostics on archetypes. Prints basic info about them and the chunks they contain.
 
void diag_components () const
 Performs diagnostics on registered components. Prints basic info about them and reports and detected issues.
 
void diag_entities () const
 Performs diagnostics on entities of the world. Also performs validation of internal structures which hold the entities.
 
void diag () const
 Performs all diagnostics.
 
GAIA_NODISCARD bool locked () const
 Checks if the chunk is locked for structural changes.
 
void save ()
 Saves contents of the world to a buffer. The buffer is reset, not appended. NOTE: In order for custom version of save to be used for a given component, it needs to have either of the following functions defined: 1) member function: "void save(BinarySerializer& s)" 2) free function in gaia::ser namespace: "void tag_invoke(gaia::ser::save_v, BinarySerializer& s, const YourType& data)".
 
bool load (ser::ISerializer *pOutputSerializer=nullptr)
 Loads a world state from a buffer. The buffer is sought to 0 before any loading happens. NOTE: In order for custom version of load to be used for a given component, it needs to have either of the following functions defined: 1) member function: "void save(BinarySerializer& s)" 2) free function in gaia::ser namespace: "void tag_invoke(gaia::ser::load_v, BinarySerializer& s, YourType& data)".
 
QuerySerBufferquery_buffer (QueryId &serId)
 
void query_buffer_reset (QueryId &serId)
 
void invalidate_queries_for_entity (Pair is_pair)
 
Entity name_to_entity (std::span< const char > exprRaw) const
 
Entity expr_to_entity (va_list &args, std::span< const char > exprRaw) const
 

Static Public Member Functions

static GAIA_NODISCARD bool is_req_del (const EntityContainer &ec)
 

Friends

class ECSSystem
 
class ECSSystemManager
 
void lock (World &)
 
void unlock (World &)
 

Member Function Documentation

◆ acc()

ComponentGetter gaia::ecs::World::acc ( Entity  entity) const
inline

Starts a bulk get operation on an entity.

Parameters
entityEntity
Returns
ComponentGetter
Warning
It is expected that entity is valid. Undefined behavior otherwise.
Undefined behavior if entity changes archetype after ComponentGetter is created.

◆ acc_mut()

GAIA_NODISCARD ComponentSetter gaia::ecs::World::acc_mut ( Entity  entity)
inline

Starts a bulk set operation on entity.

Parameters
entityEntity
Returns
ComponentSetter
Warning
It is expected entity is valid. Undefined behavior otherwise.
Undefined behavior if entity changes archetype after ComponentSetter is created.

◆ add() [1/7]

template<typename T >
GAIA_NODISCARD const ComponentCacheItem & gaia::ecs::World::add ( )
inline

Creates a new component if not found already.

Template Parameters
TComponent
Returns
Component cache item of the component

◆ add() [2/7]

template<typename T >
void gaia::ecs::World::add ( Entity  entity)
inline

Attaches a new component T to entity.

Template Parameters
TComponent
Parameters
entityEntity
Warning
It is expected the component is not present on entity yet. Undefined behavior otherwise.
It is expected entity is valid. Undefined behavior otherwise.

◆ add() [3/7]

void gaia::ecs::World::add ( Entity  entity,
Entity  object 
)
inline

Attaches entity object to entity entity.

Parameters
entitySource entity
objectAdded entity
Warning
It is expected both entity and object are valid. Undefined behavior otherwise.

◆ add() [4/7]

template<typename T >
void gaia::ecs::World::add ( Entity  entity,
Entity  object,
T &&  value 
)
inline

Attaches object to entity. Also sets its value.

Parameters
objectObject
entityEntity
valueValue to set for the object
Warning
It is expected the component is not present on entity yet. Undefined behavior otherwise.
It is expected entity is valid. Undefined behavior otherwise.
It is expected object is valid. Undefined behavior otherwise.

◆ add() [5/7]

void gaia::ecs::World::add ( Entity  entity,
Pair  pair 
)
inline

Creates a new entity relationship pair.

Parameters
entitySource entity
pairPair
Warning
It is expected both entity and the entities forming the relationship are valid. Undefined behavior otherwise.

◆ add() [6/7]

template<typename T , typename U = typename actual_type_t<T>::Type>
void gaia::ecs::World::add ( Entity  entity,
U &&  value 
)
inline

Attaches a new component T to entity. Also sets its value.

Template Parameters
TComponent
Parameters
entityEntity
valueValue to set for the component
Warning
It is expected the component is not present on entity yet. Undefined behavior otherwise.
It is expected entity is valid. Undefined behavior otherwise.

◆ add() [7/7]

GAIA_NODISCARD Entity gaia::ecs::World::add ( EntityKind  kind = EntityKind::EK_Gen)
inline

Creates a new empty entity.

Parameters
kindEntity kind. Generic entity by default.
Returns
New entity

◆ add_n() [1/2]

template<typename Func = TFunc_Void_With_Entity>
void gaia::ecs::World::add_n ( Entity  entity,
uint32_t  count,
Func  func = func_void_with_entity 
)
inline

Creates count of entities of the same archetype as entity.

Parameters
entitySource entity to copy
countNumber of enities to create
funcFunctor to execute every time an entity is added
Note
Similar to copy_n, but keeps component values uninitialized or default-initialized if they provide a constructor

◆ add_n() [2/2]

template<typename Func = TFunc_Void_With_Entity>
void gaia::ecs::World::add_n ( uint32_t  count,
Func  func = func_void_with_entity 
)
inline

Creates count new empty entities.

Parameters
countNumber of enities to create
funcFunctor to execute every time an entity is added

◆ build()

EntityBuilder gaia::ecs::World::build ( Entity  entity)
inline

Starts a bulk add/remove operation on entity.

Parameters
entityEntity
Returns
EntityBuilder
Warning
It is expected entity is valid. Undefined behavior otherwise.

◆ child()

GAIA_NODISCARD bool gaia::ecs::World::child ( Entity  entity,
Entity  parent 
) const
inline

Checks if.

Parameters
entityis a child of
parentTrue if entity is a child of parent. False otherwise.

◆ clear()

void gaia::ecs::World::clear ( Entity  entity)
inline

Removes any component or entity attached to entity.

Parameters
entityEntity we want to remove any attached component or entity from
Warning
It is expected entity is not a pair. Undefined behavior otherwise.
It is expected entity is valid. Undefined behavior otherwise.

◆ copy()

GAIA_NODISCARD Entity gaia::ecs::World::copy ( Entity  srcEntity)
inline

Creates a new entity by cloning an already existing one.

Parameters
srcEntityEntity to clone
Returns
New entity
Warning
It is expected srcEntity is valid. Undefined behavior otherwise.
If EntityDesc is present on srcEntity, it is not copied because names are expected to be unique. Instead, the copied entity will be a part of an archetype without EntityDesc and any calls to World::name(copiedEntity) will return nullptr.

◆ copy_n()

template<typename Func = TFunc_Void_With_Entity>
void gaia::ecs::World::copy_n ( Entity  entity,
uint32_t  count,
Func  func = func_void_with_entity 
)
inline

Creates count new entities by cloning an already existing one.

Parameters
entityEntity to clone
countNumber of clones to make
funcFunctor executed every time a copy is created. It can be either void(ecs::Entity) or void(ecs::CopyIter&).
Warning
It is expected entity is valid generic entity. Undefined behavior otherwise.
If EntityDesc is present on entity, it is not copied because names are expected to be unique. Instead, the copied entity will be a part of an archetype without EntityDesc and any calls to World::name(copiedEntity) will return nullptr.

◆ defrag_entities_per_tick()

void gaia::ecs::World::defrag_entities_per_tick ( uint32_t  value)
inline

Sets the maximum number of entities defragmented per world tick.

Parameters
valueNumber of entities to defragment

◆ del() [1/4]

void gaia::ecs::World::del ( Entity  entity)
inline

Removes an entity along with all data associated with it.

Parameters
entityEntity to delete

◆ del() [2/4]

template<typename T >
void gaia::ecs::World::del ( Entity  entity)
inline

Removes a component T from entity.

Template Parameters
TComponent
Parameters
entityEntity
Warning
It is expected the component is present on entity. Undefined behavior otherwise.
It is expected entity is valid. Undefined behavior otherwise.

◆ del() [3/4]

void gaia::ecs::World::del ( Entity  entity,
Entity  object 
)
inline

Removes an object from entity if possible.

Parameters
entityEntity to delete from
objectEntity to delete
Warning
It is expected both entity and object are valid. Undefined behavior otherwise.

◆ del() [4/4]

void gaia::ecs::World::del ( Entity  entity,
Pair  pair 
)
inline

Removes an existing entity relationship pair.

Parameters
entitySource entity
pairPair
Warning
It is expected both entity and the entities forming the relationship are valid. Undefined behavior otherwise.

◆ enable()

void gaia::ecs::World::enable ( Entity  entity,
bool  enable 
)
inline

Enables or disables an entire entity.

Parameters
entityEntity
enableEnable or disable the entity
Warning
It is expected entity is valid. Undefined behavior otherwise.

◆ enabled()

GAIA_NODISCARD bool gaia::ecs::World::enabled ( Entity  entity) const
inline

Checks if an entity is enabled.

Parameters
entityEntity
Returns
True it the entity is enabled. False otherwise.
Warning
It is expected entity is valid. Undefined behavior otherwise.

◆ get() [1/3]

GAIA_NODISCARD Entity gaia::ecs::World::get ( const char *  name,
uint32_t  len = 0 
) const
inline

Returns the entity that is assigned a name name. If the name contains the character '.' hierarchical lookup is use. E.g. "parent.child.subchild" will return the entity for subchild is the entire tree could be found by name.

Parameters
namePointer to a stable null-terminated string
lenString length. If zero, the length is calculated
Returns
Entity assigned the given name. EntityBad if there is nothing to return.

◆ get() [2/3]

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::World::get ( Entity  entity) const
inline

Returns the value stored in the component T on entity.

Template Parameters
TComponent
Parameters
entityEntity
Returns
Value stored in the component.
Warning
It is expected the component is present on entity. Undefined behavior otherwise.
It is expected entity is valid. Undefined behavior otherwise.
Undefined behavior if entity changes archetype after ComponentGetter is created.

◆ get() [3/3]

GAIA_NODISCARD Entity gaia::ecs::World::get ( EntityId  id) const
inline

Returns the entity located at the index id.

Parameters
idEntity id
Returns
Entity

◆ get_chunk() [1/2]

GAIA_NODISCARD Chunk * gaia::ecs::World::get_chunk ( Entity  entity) const
inline

Returns a chunk containing the entity.

Parameters
entityEntity
Returns
Chunk or nullptr if not found.

◆ get_chunk() [2/2]

GAIA_NODISCARD Chunk * gaia::ecs::World::get_chunk ( Entity  entity,
uint32_t &  row 
) const
inline

Returns a chunk containing the entity. Index of the entity is stored in row.

Parameters
entityEntity
[out]rowRow of entity within chunk
Returns
Chunk or nullptr if not found

◆ has() [1/5]

GAIA_NODISCARD bool gaia::ecs::World::has ( Entity  entity) const
inline

Checks if entity is currently used by the world.

Parameters
entityEntity.
Returns
True if the entity is used. False otherwise.

◆ has() [2/5]

template<typename T >
GAIA_NODISCARD bool gaia::ecs::World::has ( Entity  entity) const
inline

Checks if entity contains the component T.

Template Parameters
TComponent
Parameters
entityEntity
Returns
True if the component is present on entity.
Warning
It is expected entity is valid. Undefined behavior otherwise.
Undefined behavior if entity changes archetype after ComponentSetter is created.

◆ has() [3/5]

GAIA_NODISCARD bool gaia::ecs::World::has ( Entity  entity,
Entity  object 
) const
inline

Checks if entity contains the entity object.

Parameters
entityEntity
objectTested entity
Returns
True if object is present on entity. False otherwise or if any of the entities is not valid.
Warning
It is expected entity is valid. Undefined behavior otherwise.
Undefined behavior if entity changes archetype after ComponentSetter is created.

◆ has() [4/5]

GAIA_NODISCARD bool gaia::ecs::World::has ( Entity  entity,
Pair  pair 
) const
inline

Checks if entity contains pair.

Parameters
entityEntity
pairTested pair
Returns
True if object is present on entity. False otherwise or if any of the entities is not valid.
Warning
It is expected entity is valid. Undefined behavior otherwise.
Undefined behavior if entity changes archetype after ComponentSetter is created.

◆ has() [5/5]

GAIA_NODISCARD bool gaia::ecs::World::has ( Pair  pair) const
inline

Checks if pair is currently used by the world.

Parameters
pairPair
Returns
True if the entity is used. False otherwise.

◆ in()

GAIA_NODISCARD bool gaia::ecs::World::in ( Entity  entity,
Entity  entityBase 
) const
inline

Checks if entity is located in entityBase. This is almost the same as "is" with the exception that false is returned if entity matches entityBase.

Parameters
entityEntity
entityBaseBase entity
Returns
True if entity is located in entityBase. False otherwise.

◆ is()

GAIA_NODISCARD bool gaia::ecs::World::is ( Entity  entity,
Entity  entityBase 
) const
inline

Checks if entity inherits from entityBase.

Parameters
entityEntity
entityBaseBase entity
Returns
True if entity is located in entityBase. False otherwise.

◆ modify()

template<typename T >
void gaia::ecs::World::modify ( Entity  entity)
inline

Marks the component T as modified. Best used with acc_mut().sset() or set() to manually trigger an update at user's whim. If TriggerHooks is true, also triggers the component's set hooks.

Template Parameters
TComponent type
TriggerHooksTriggers hooks if true

◆ mut()

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::World::mut ( Entity  entity)
inline

Sets the value of the component T on entity without triggering a world version update.

Template Parameters
TComponent
Parameters
entityEntity
Warning
It is expected the component is present on entity. Undefined behavior otherwise.
It is expected entity is valid. Undefined behavior otherwise.
Undefined behavior if entity changes archetype after ComponentSetter is created.

◆ name() [1/3]

GAIA_NODISCARD const char * gaia::ecs::World::name ( Entity  entity) const
inline

Returns the name assigned to entity.

Parameters
entityEntity
Returns
Name assigned to entity.
Warning
It is expected entity is valid. Undefined behavior otherwise.

◆ name() [2/3]

void gaia::ecs::World::name ( Entity  entity,
const char *  name,
uint32_t  len = 0 
)
inline

Assigns a name to entity. Ignored if used with pair. The string is copied and kept internally.

Parameters
entityEntity
nameA null-terminated string
lenString length. If zero, the length is calculated
Warning
It is expected entity is valid. Undefined behavior otherwise.
Name is expected to be unique. If it is not this function does nothing.
The name can't contain the character '.'. This character is reserved for hierarchical lookups such as "parent.child.subchild".

◆ name() [3/3]

GAIA_NODISCARD const char * gaia::ecs::World::name ( EntityId  entityId) const
inline

Returns the name assigned to entityId.

Parameters
entityIdEntityId
Returns
Name assigned to entity.
Warning
It is expected entityId is valid. Undefined behavior otherwise.

◆ name_raw()

void gaia::ecs::World::name_raw ( Entity  entity,
const char *  name,
uint32_t  len = 0 
)
inline

Assigns a name to entity. Ignored if used with pair. The string is NOT copied. Your are responsible for its lifetime.

Parameters
entityEntity
namePointer to a stable null-terminated string
lenString length. If zero, the length is calculated
Warning
It is expected entity is valid. Undefined behavior otherwise.
The name is expected to be unique. If it is not this function does nothing.
The name can't contain the character '.'. This character is reserved for hierarchical lookups such as "parent.child.subchild".
In this case the string is NOT copied and NOT stored internally. You are responsible for its lifetime. The pointer also needs to be stable. Otherwise, any time your storage tries to move the string to a different place you have to unset the name before it happens and set it anew after the move is done.

◆ query()

template<bool UseCache = true>
auto gaia::ecs::World::query ( )
inline

Provides a query set up to work with the parent world.

Template Parameters
UseCacheIf true, results of the query are cached
Returns
Valid query object

◆ relation()

GAIA_NODISCARD Entity gaia::ecs::World::relation ( Entity  entity,
Entity  target 
) const
inline

Returns the first relationship relation for the target entity on entity.

Parameters
entitySource entity
targetTarget entity
Returns
Relationship target. EntityBad if there is nothing to return.
Warning
It is expected entity is valid. Undefined behavior otherwise.

◆ relations() [1/2]

template<typename Func >
void gaia::ecs::World::relations ( Entity  entity,
Entity  target,
Func  func 
) const
inline

Returns the relationship relations for the target entity on entity.

Parameters
entitySource entity
targetTarget entity
funcvoid(Entity relation) functor executed for relationship relation found.
Warning
It is expected entity is valid. Undefined behavior otherwise.

◆ relations() [2/2]

GAIA_NODISCARD const cnt::set< EntityLookupKey > * gaia::ecs::World::relations ( Entity  target) const
inline

Returns relations for target.

Parameters
targetTarget entity
Warning
It is expected target is valid. Undefined behavior otherwise.

◆ relations_if()

template<typename Func >
void gaia::ecs::World::relations_if ( Entity  entity,
Entity  target,
Func  func 
) const
inline

Returns the relationship relations for the target entity on entity.

Parameters
entitySource entity
targetTarget entity
funcbool(Entity relation) functor executed for relationship relation found. Stops if false is returned.
Warning
It is expected entity is valid. Undefined behavior otherwise.

◆ set()

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::World::set ( Entity  entity)
inline

Sets the value of the component T on entity.

Template Parameters
TComponent
Parameters
entityEntity
Warning
It is expected the component is present on entity. Undefined behavior otherwise.
It is expected entity is valid. Undefined behavior otherwise.
Undefined behavior if entity changes archetype after ComponentSetter is created.

◆ set_max_lifespan()

void gaia::ecs::World::set_max_lifespan ( Entity  entity,
uint32_t  lifespan = Archetype::MAX_ARCHETYPE_LIFESPAN 
)
inline

Sets maximal lifespan of an archetype entity belongs to.

Parameters
entityEntity
lifespanHow many world updates an empty archetype is kept. If zero, the archetype it kept indefinitely.

◆ size()

GAIA_NODISCARD uint32_t gaia::ecs::World::size ( ) const
inline

Returns the number of active entities.

Returns
Entity

◆ sset()

template<typename T >
GAIA_NODISCARD decltype(auto) gaia::ecs::World::sset ( Entity  entity)
inline

Sets the value of the component T on entity without triggering a world version update.

Template Parameters
TComponent
Parameters
entityEntity
Warning
It is expected the component is present on entity. Undefined behavior otherwise.
It is expected entity is valid. Undefined behavior otherwise.
Undefined behavior if entity changes archetype after ComponentSetter is created.

◆ target()

GAIA_NODISCARD Entity gaia::ecs::World::target ( Entity  entity,
Entity  relation 
) const
inline

Returns the first relationship target for the relation entity on entity.

Parameters
entitySource entity
relationRelation entity
Returns
Relationship target. EntityBad if there is nothing to return.
Warning
It is expected entity is valid. Undefined behavior otherwise.

◆ targets() [1/2]

template<typename Func >
void gaia::ecs::World::targets ( Entity  entity,
Entity  relation,
Func  func 
) const
inline

Returns the relationship targets for the relation entity on entity.

Parameters
entitySource entity
relationRelation entity
funcvoid(Entity target) functor executed for relationship target found.
Warning
It is expected entity is valid. Undefined behavior otherwise.

◆ targets() [2/2]

GAIA_NODISCARD const cnt::set< EntityLookupKey > * gaia::ecs::World::targets ( Entity  relation) const
inline

Returns targets for relation.

Parameters
relationRelation entity
Warning
It is expected entity is valid. Undefined behavior otherwise.

◆ targets_if()

template<typename Func >
void gaia::ecs::World::targets_if ( Entity  entity,
Entity  relation,
Func  func 
) const
inline

Returns the relationship targets for the relation entity on entity.

Parameters
entitySource entity
relationRelation entity
funcbool(Entity target) functor executed for relationship target found. Stops if false is returned.
Warning
It is expected entity is valid. Undefined behavior otherwise.

◆ valid()

GAIA_NODISCARD bool gaia::ecs::World::valid ( Entity  entity) const
inline

Checks if entity is valid.

Parameters
entityChecked entity.
Returns
True if the entity is valid. False otherwise.

◆ world_version()

GAIA_NODISCARD uint32_t & gaia::ecs::World::world_version ( )
inline

Returns the current version of the world.

Returns
World version number.

The documentation for this class was generated from the following file: