igor::iEntity Class Reference

#include <iEntity.h>

Public Member Functions

const iEntityIDgetID () const
 
iEntityIDPath getIDPath () const
 
void setName (const iaString &name)
 
const iaStringgetName () const
 
void setParent (const iEntityID &parentID)
 
void setParent (iEntityPtr parent)
 
void removeParent ()
 
iEntityPtr getParent () const
 
bool hasParent () const
 
bool isRoot () const
 
const std::vector< iEntityPtr > & getChildren () const
 
const std::vector< iEntityPtr > & getInactiveChildren () const
 
void setActive (bool active)
 
void setActiveExclusive (bool active)
 
bool isActive () const
 
iEntityScenePtr getScene () const
 
iEntityComponentMask getComponentMask () const
 
template<typename T >
T * addComponent (T *component)
 
void addComponent (const std::type_index &typeID, iEntityComponentPtr component)
 
template<typename T >
T * getComponent () const
 
iEntityComponentPtr getComponent (const std::type_index &typeID) const
 
const std::vector< std::type_index > getComponentTypes ()
 
template<typename T >
void destroyComponent ()
 
template<typename T >
void reloadComponent ()
 
void addBehaviour (const iBehaviourDelegate &behaviour, const std::any &userData=std::any(), const iaString &name="", uint8 priority=100)
 
void removeBehaviour (const iBehaviourDelegate &behaviour)
 
void clearComponents ()
 
bool isHierarchyDirty () const
 
void setDirtyHierarchy ()
 
void resetDirtyHierarchy ()
 
template<typename T >
T * addComponent (T *component)
 
template<typename T >
T * getComponent () const
 
template<typename T >
void destroyComponent ()
 
template<typename T >
void reloadComponent ()
 

Static Public Member Functions

static iEntityComponentMask calcComponentMask (const std::vector< std::type_index > &types)
 

Friends

class iEntityScene
 
class iEntityTransformTraverser
 
class iTransformComponent
 

Detailed Description

entity definition

Igor uses the terms entity, component and system but it is not a classic entity component system or ECS. An entity is a hierarchical element in the scene with parents and children. It behaves more like a game object.

Member Function Documentation

◆ addBehaviour()

void igor::iEntity::addBehaviour ( const iBehaviourDelegate &  behaviour,
const std::any &  userData = std::any(),
const iaString name = "",
uint8  priority = 100 
)

adds behaviour to entity

Parameters
behaviourthe behaviour to be added
userDatauser data added to behaviour
namethe name of the behaviour
priorityexecution priority (low = 0, default = 100, high = ...)

◆ addComponent() [1/3]

void igor::iEntity::addComponent ( const std::type_index &  typeID,
iEntityComponentPtr  component 
)

adds component with given type id

entity takes ownership of component

Parameters
typeIDthe given type id
componentthe component to add

◆ addComponent() [2/3]

template<typename T >
T * igor::iEntity::addComponent ( T *  component)

add component

entity takes ownership of component

Parameters
componentthe component to add
Returns
the new component

◆ addComponent() [3/3]

template<typename T >
T * igor::iEntity::addComponent ( T *  component)

◆ calcComponentMask()

iEntityComponentMask igor::iEntity::calcComponentMask ( const std::vector< std::type_index > &  types)
static

calculate type hash from component types

Parameters
typesthe types to use for calculation

◆ clearComponents()

void igor::iEntity::clearComponents ( )

removes all components

◆ destroyComponent() [1/2]

template<typename T >
void igor::iEntity::destroyComponent ( )

destroys given component by type

◆ destroyComponent() [2/2]

template<typename T >
void igor::iEntity::destroyComponent ( )

◆ getChildren()

const std::vector< iEntityPtr > & igor::iEntity::getChildren ( ) const
Returns
active children

◆ getComponent() [1/3]

template<typename T >
T * igor::iEntity::getComponent ( ) const
Returns
component for given type

◆ getComponent() [2/3]

template<typename T >
T * igor::iEntity::getComponent ( ) const

◆ getComponent() [3/3]

iEntityComponentPtr igor::iEntity::getComponent ( const std::type_index &  typeID) const
Returns
component for given type
Parameters
typeIDthe given type

◆ getComponentMask()

iEntityComponentMask igor::iEntity::getComponentMask ( ) const
Returns
type hash of this entity

◆ getComponentTypes()

const std::vector< std::type_index > igor::iEntity::getComponentTypes ( )
Returns
component types

◆ getID()

const iEntityID & igor::iEntity::getID ( ) const
Returns
entity id

◆ getIDPath()

iEntityIDPath igor::iEntity::getIDPath ( ) const
Returns
entity id path

This is slow. Use with care

◆ getInactiveChildren()

const std::vector< iEntityPtr > & igor::iEntity::getInactiveChildren ( ) const
Returns
inactive children

◆ getName()

const iaString & igor::iEntity::getName ( ) const
Returns
name of entity

◆ getParent()

iEntityPtr igor::iEntity::getParent ( ) const
Returns
parent

◆ getScene()

iEntityScenePtr igor::iEntity::getScene ( ) const
Returns
scene this entity belongs to

◆ hasParent()

bool igor::iEntity::hasParent ( ) const
Returns
true if entity has parent

◆ isActive()

bool igor::iEntity::isActive ( ) const
Returns
true if entity is active

◆ isHierarchyDirty()

bool igor::iEntity::isHierarchyDirty ( ) const
Returns
true if hierarchy (including transforms) is dirty

◆ isRoot()

bool igor::iEntity::isRoot ( ) const
Returns
true if this is the root entity

used for special case handling

◆ reloadComponent() [1/2]

template<typename T >
void igor::iEntity::reloadComponent ( )

destroys given component by type

◆ reloadComponent() [2/2]

template<typename T >
void igor::iEntity::reloadComponent ( )

◆ removeBehaviour()

void igor::iEntity::removeBehaviour ( const iBehaviourDelegate &  behaviour)

removes behaviour from entity

Parameters
behaviourthe behaviour to be removed

◆ removeParent()

void igor::iEntity::removeParent ( )

removes parent connection

◆ resetDirtyHierarchy()

void igor::iEntity::resetDirtyHierarchy ( )

resets dirty flag on this entity

◆ setActive()

void igor::iEntity::setActive ( bool  active)

sets wether and entity is active or not

Parameters
activeif true entity will be active

◆ setActiveExclusive()

void igor::iEntity::setActiveExclusive ( bool  active)

sets wether and entity is active or not while at the same time make sure all siblings will be set to the opposite

Parameters
activeif true entity will be active

◆ setDirtyHierarchy()

void igor::iEntity::setDirtyHierarchy ( )

sets dirty flag up and down the hierarchy

◆ setName()

void igor::iEntity::setName ( const iaString name)

sets name of entity

Parameters
namethe name to set

◆ setParent() [1/2]

void igor::iEntity::setParent ( const iEntityID parentID)

sets parent of this entity by id

Parameters
parentIDthe given parent id

◆ setParent() [2/2]

void igor::iEntity::setParent ( iEntityPtr  parent)

sets parent of this entity

Parameters
parentthe given parent

Friends And Related Function Documentation

◆ iEntityScene

friend class iEntityScene
friend

◆ iEntityTransformTraverser

friend class iEntityTransformTraverser
friend

◆ iTransformComponent

friend class iTransformComponent
friend

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