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

Public Member Functions

 EntityBuilder (World &world, Entity entity, EntityContainer &ec)
 
 EntityBuilder (World &world, Entity entity)
 
 EntityBuilder (const EntityBuilder &)=default
 
 EntityBuilder (EntityBuilder &&)=delete
 
EntityBuilderoperator= (const EntityBuilder &)=delete
 
EntityBuilderoperator= (EntityBuilder &&)=delete
 
void commit ()
 Commits all gathered changes and performs an archetype movement.
 
void name (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 (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.
 
void del_name ()
 Removes any name associated with the entity.
 
EntityBuilderadd (Entity entity)
 Prepares an archetype movement by following the "add" edge of the current archetype.
 
EntityBuilderadd (Pair pair)
 Prepares an archetype movement by following the "add" edge of the current archetype.
 
EntityBuilderas (Entity entityBase)
 Shortcut for add(Pair(Is, entityBase)). Effectively makes an entity inherit from entityBase.
 
GAIA_NODISCARD bool as (Entity entity, Entity entityBase) const
 Check if entity inherits from entityBase.
 
EntityBuilderchild (Entity parent)
 Shortcut for add(Pair(ChildOf, parent))
 
template<typename T >
Entity register_component ()
 Takes care of registering the component.
 
template<typename T >
EntityBuilderadd ()
 
EntityBuilderdel (Entity entity)
 Prepares an archetype movement by following the "del" edge of the current archetype.
 
EntityBuilderdel (Pair pair)
 Prepares an archetype movement by following the "del" edge of the current archetype.
 
template<typename T >
EntityBuilderdel ()
 

Public Attributes

Worldm_world
 
Archetypem_pArchetypeSrc
 Original archetype m_entity belongs to.
 
Chunkm_pChunkSrc
 Original chunk m_entity belonged to.
 
uint32_t m_rowSrc
 Original row.
 
Archetypem_pArchetype
 Target archetype we want to move to.
 
EntityNameLookupKey m_targetNameKey
 Target name.
 
Entity m_entity
 Source entity.
 
cnt::sarray_ext< Entity, 32 > tl_new_comps
 
cnt::sarray_ext< Entity, 32 > tl_del_comps
 

Friends

class World
 

Member Function Documentation

◆ add() [1/2]

EntityBuilder & gaia::ecs::World::EntityBuilder::add ( Entity  entity)
inline

Prepares an archetype movement by following the "add" edge of the current archetype.

Parameters
entityAdded entity

◆ add() [2/2]

EntityBuilder & gaia::ecs::World::EntityBuilder::add ( Pair  pair)
inline

Prepares an archetype movement by following the "add" edge of the current archetype.

Parameters
pairRelationship pair

◆ as() [1/2]

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

Check if entity inherits from entityBase.

Parameters
entitySource entity
entityBaseBase entity
Returns
True if entity inherits from entityBase

◆ as() [2/2]

EntityBuilder & gaia::ecs::World::EntityBuilder::as ( Entity  entityBase)
inline

Shortcut for add(Pair(Is, entityBase)). Effectively makes an entity inherit from entityBase.

Parameters
entityBaseEntity to inherit from

◆ commit()

void gaia::ecs::World::EntityBuilder::commit ( )
inline

Commits all gathered changes and performs an archetype movement.

Warning
Once called, the object is returned to its default state (as if no add/remove was ever called).

◆ del() [1/2]

EntityBuilder & gaia::ecs::World::EntityBuilder::del ( Entity  entity)
inline

Prepares an archetype movement by following the "del" edge of the current archetype.

Parameters
entityRemoved entity

◆ del() [2/2]

EntityBuilder & gaia::ecs::World::EntityBuilder::del ( Pair  pair)
inline

Prepares an archetype movement by following the "del" edge of the current archetype.

Parameters
pairRelationship pair

◆ name()

void gaia::ecs::World::EntityBuilder::name ( 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
nameA null-terminated string.
lenString length. If zero, the length is calculated.
Warning
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_raw()

void gaia::ecs::World::EntityBuilder::name_raw ( 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
namePointer to a stable null-terminated string.
lenString length. If zero, the length is calculated.
Warning
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.

◆ register_component()

template<typename T >
Entity gaia::ecs::World::EntityBuilder::register_component ( )
inline

Takes care of registering the component.

Template Parameters
T

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