Nazara Engine  0.4
A fast, complete, cross-platform API designed for game development
Ndk::Entity Class Reference

NDK class that represents an entity in a world. More...

Inherits Nz::HandledObject< T >.

Public Member Functions

 Entity (const Entity &)=delete
 
 Entity (Entity &&entity)
 Constructs a Entity object by move semantic. More...
 
 ~Entity ()
 Destructs the object and calls Destroy. More...
 
BaseComponentAddComponent (std::unique_ptr< BaseComponent > &&component)
 Adds a component to the entity. More...
 
template<typename ComponentType , typename... Args>
ComponentType & AddComponent (Args &&... args)
 Adds a component to the entity. More...
 
const EntityHandleClone () const
 Clones the entity. More...
 
void Enable (bool enable=true)
 Enables the entity. More...
 
BaseComponentGetComponent (ComponentIndex index)
 Gets a component in the entity by index. More...
 
template<typename ComponentType >
ComponentType & GetComponent ()
 Gets a component in the entity by type. More...
 
const BaseComponentGetComponent (ComponentIndex index) const
 Gets a component in the entity by index. More...
 
template<typename ComponentType >
const ComponentType & GetComponent () const
 Gets a component in the entity by type. More...
 
const Nz::BitsetGetComponentBits () const
 Gets the bits representing the components in the entiy. More...
 
EntityId GetId () const
 Gets the identifier of the entity. More...
 
const Nz::BitsetGetSystemBits () const
 Gets the bits representing the systems in the entiy. More...
 
WorldGetWorld () const
 Gets the world in which the entity is. More...
 
bool HasComponent (ComponentIndex index) const
 Checks whether or not a component is present in the entity by index. More...
 
template<typename ComponentType >
bool HasComponent () const
 Checks whether or not a component is present in the entity by type. More...
 
void Kill ()
 Kills the entity.
 
void Invalidate ()
 Invalidates the entity.
 
bool IsEnabled () const
 Checks whether or not the entity is enabled. More...
 
bool IsValid () const
 Checks whether or not the entity is valid. More...
 
void RemoveAllComponents ()
 Removes every components.
 
void RemoveComponent (ComponentIndex index)
 Removes a component in the entity by index. More...
 
template<typename ComponentType >
void RemoveComponent ()
 Removes a component in the entity by type.
 
Nz::String ToString () const
 Gives a string representation. More...
 
Entityoperator= (const Entity &)=delete
 
Entityoperator= (Entity &&)=delete
 
 NazaraSignal (OnEntityDestruction, Entity *)
 

Detailed Description

NDK class that represents an entity in a world.

Constructor & Destructor Documentation

◆ Entity()

Ndk::Entity::Entity ( Entity &&  entity)

Constructs a Entity object by move semantic.

Parameters
entityEntity to move into this

◆ ~Entity()

Ndk::Entity::~Entity ( )

Destructs the object and calls Destroy.

See also
Destroy

Member Function Documentation

◆ AddComponent() [1/2]

BaseComponent & Ndk::Entity::AddComponent ( std::unique_ptr< BaseComponent > &&  componentPtr)

Adds a component to the entity.

Returns
A reference to the newly added component
Parameters
componentPtrComponent to add to the entity
Remarks
Produces a NazaraAssert if component is nullptr

◆ AddComponent() [2/2]

template<typename ComponentType , typename... Args>
ComponentType & Ndk::Entity::AddComponent ( Args &&...  args)

Adds a component to the entity.

Returns
A reference to the newly added component
Parameters
argsArguments to create in place the component to add to the entity

◆ Clone()

const EntityHandle & Ndk::Entity::Clone ( ) const

Clones the entity.

Returns
The clone newly created
Remarks
The close is enable by default, even if the original is disabled
Produces a NazaraAssert if the entity is not valid

◆ Enable()

void Ndk::Entity::Enable ( bool  enable = true)
inline

Enables the entity.

Parameters
enableShould the entity be enabled

◆ GetComponent() [1/4]

BaseComponent & Ndk::Entity::GetComponent ( ComponentIndex  index)
inline

Gets a component in the entity by index.

Returns
A reference to the component
Parameters
indexIndex of the component
Remarks
Produces a NazaraAssert if component is not available in this entity or is invalid

◆ GetComponent() [2/4]

template<typename ComponentType >
ComponentType & Ndk::Entity::GetComponent ( )

Gets a component in the entity by type.

Returns
A reference to the component
Remarks
Produces a NazaraAssert if component is not available in this entity

◆ GetComponent() [3/4]

const BaseComponent & Ndk::Entity::GetComponent ( ComponentIndex  index) const
inline

Gets a component in the entity by index.

Returns
A constant reference to the component
Parameters
indexIndex of the component
Remarks
Produces a NazaraAssert if component is not available in this entity or is invalid

◆ GetComponent() [4/4]

template<typename ComponentType >
const ComponentType & Ndk::Entity::GetComponent ( ) const

Gets a component in the entity by type.

Returns
A constant reference to the component
Remarks
Produces a NazaraAssert if component is not available in this entity

◆ GetComponentBits()

const Nz::Bitset & Ndk::Entity::GetComponentBits ( ) const
inline

Gets the bits representing the components in the entiy.

Returns
A constant reference to the set of component's bits

◆ GetId()

EntityId Ndk::Entity::GetId ( ) const
inline

Gets the identifier of the entity.

Returns
Identifier of the entity

◆ GetSystemBits()

const Nz::Bitset & Ndk::Entity::GetSystemBits ( ) const
inline

Gets the bits representing the systems in the entiy.

Returns
A constant reference to the set of system's bits

◆ GetWorld()

World * Ndk::Entity::GetWorld ( ) const
inline

Gets the world in which the entity is.

Returns
Pointer to the world

◆ HasComponent() [1/2]

bool Ndk::Entity::HasComponent ( ComponentIndex  index) const
inline

Checks whether or not a component is present in the entity by index.

Returns
true If it is the case
Parameters
indexIndex of the component

◆ HasComponent() [2/2]

template<typename ComponentType >
bool Ndk::Entity::HasComponent ( ) const

Checks whether or not a component is present in the entity by type.

Returns
true If it is the case

◆ IsEnabled()

bool Ndk::Entity::IsEnabled ( ) const
inline

Checks whether or not the entity is enabled.

Returns
true If it is the case

◆ IsValid()

bool Ndk::Entity::IsValid ( ) const
inline

Checks whether or not the entity is valid.

Returns
true If it is the case

◆ RemoveComponent()

void Ndk::Entity::RemoveComponent ( ComponentIndex  index)
inline

Removes a component in the entity by index.

Parameters
indexIndex of the component

◆ ToString()

Nz::String Ndk::Entity::ToString ( ) const
inline

Gives a string representation.

Returns
A string representation of the object: "Entity(GetId())"

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