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

Applies structural and value changes to one entity. More...

#include <world.h>

Public Types

using RelationMutationPath = detail::RelationMutationPath
 Mutation path selected for fragmenting or non-fragmenting relation updates.
 

Public Member Functions

 EntityBuilder (World &world, Entity entity, EntityContainer &ec)
 Creates a builder from an already fetched entity record.
 
 EntityBuilder (World &world, Entity entity)
 Creates a builder and fetches the entity's current storage record.
 
 EntityBuilder (const EntityBuilder &)=default
 
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 alias (const char *alias, uint32_t len=0)
 Assigns an alias to entity. Ignored if used with pair. The string is copied and kept internally.
 
void alias_raw (const char *alias, uint32_t len=0)
 Assigns an alias to entity. Ignored if used with pair. The string is NOT copied. You are responsible for its lifetime.
 
void del_name ()
 Removes any name associated with the entity.
 
void del_alias ()
 Removes any alias 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.
 
EntityBuilderprefab ()
 Marks the entity as a prefab.
 
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 type used by T.
 
template<typename T >
EntityBuilderadd ()
 Adds the registered component or pair type to the pending entity state.
 
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 ()
 Removes the registered component or pair type from the pending entity state.
 

Public Attributes

Worldm_world
 World receiving the accumulated entity changes.
 
Archetypem_pArchetypeSrc = nullptr
 Original archetype m_entity belongs to.
 
Chunkm_pChunkSrc = nullptr
 Original chunk m_entity belonged to.
 
uint32_t m_rowSrc = 0
 Original row.
 
Archetypem_pArchetype = nullptr
 Target archetype we want to move to.
 
EntityNameLookupKey m_targetNameKey
 Target name.
 
EntityNameLookupKey m_targetAliasKey
 Target alias string pointer.
 
Entity m_entity
 Source entity.
 

Friends

class World
 

Detailed Description

Applies structural and value changes to one entity.

Constructor & Destructor Documentation

◆ EntityBuilder() [1/2]

gaia::ecs::World::EntityBuilder::EntityBuilder ( World world,
Entity  entity,
EntityContainer &  ec 
)
inline

Creates a builder from an already fetched entity record.

Parameters
worldWorld owning entity.
entityEntity to mutate.
ecCurrent storage record for entity.

◆ EntityBuilder() [2/2]

gaia::ecs::World::EntityBuilder::EntityBuilder ( World world,
Entity  entity 
)
inline

Creates a builder and fetches the entity's current storage record.

Parameters
worldWorld owning entity.
entityEntity to mutate.

Member Function Documentation

◆ add() [1/3]

template<typename T >
EntityBuilder & gaia::ecs::World::EntityBuilder::add ( )
inline

Adds the registered component or pair type to the pending entity state.

Template Parameters
TComponent or pair type to add.
Returns
This builder.

◆ add() [2/3]

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
Returns
This builder.

◆ add() [3/3]

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
Returns
This builder.

◆ alias()

void gaia::ecs::World::EntityBuilder::alias ( const char *  alias,
uint32_t  len = 0 
)
inline

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

Parameters
aliasA null-terminated string.
lenString length. If zero, the length is calculated.

◆ alias_raw()

void gaia::ecs::World::EntityBuilder::alias_raw ( const char *  alias,
uint32_t  len = 0 
)
inline

Assigns an alias to entity. Ignored if used with pair. The string is NOT copied. You are responsible for its lifetime.

Parameters
aliasPointer to a stable null-terminated string.
lenString length. If zero, the length is calculated.

◆ 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
Returns
This builder.

◆ child()

EntityBuilder & gaia::ecs::World::EntityBuilder::child ( Entity  parent)
inline

Shortcut for add(Pair(ChildOf, parent))

Parameters
parentParent entity to attach through ChildOf.
Returns
This builder.

◆ 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/3]

template<typename T >
EntityBuilder & gaia::ecs::World::EntityBuilder::del ( )
inline

Removes the registered component or pair type from the pending entity state.

Template Parameters
TComponent or pair type to remove.
Returns
This builder.

◆ del() [2/3]

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
Returns
This builder.

◆ del() [3/3]

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
Returns
This builder.

◆ 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.

◆ prefab()

EntityBuilder & gaia::ecs::World::EntityBuilder::prefab ( )
inline

Marks the entity as a prefab.

Returns
This builder.

◆ register_component()

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

Takes care of registering the component type used by T.

Template Parameters
TComponent or pair type to register.
Returns
Registered component or pair entity.

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