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

NDK class that represents a world. More...

Inherits Nz::HandledObject< T >.

Public Types

using EntityVector = std::vector< EntityHandle >
 

Public Member Functions

 World (bool addDefaultSystems=true)
 Constructs a World object. More...
 
 World (const World &)=delete
 
 World (World &&world) noexcept
 Constructs a World object by move semantic. More...
 
 ~World () noexcept
 Destructs the object and calls Clear. More...
 
void AddDefaultSystems ()
 Adds default systems to the world.
 
BaseSystemAddSystem (std::unique_ptr< BaseSystem > &&system)
 Adds a system to the world. More...
 
template<typename SystemType , typename... Args>
SystemType & AddSystem (Args &&... args)
 Adds a system to the world. More...
 
const EntityHandleCreateEntity ()
 Creates an entity in the world. More...
 
EntityVector CreateEntities (unsigned int count)
 Creates multiple entities in the world. More...
 
void Clear () noexcept
 Clears the world from every entities. More...
 
const EntityHandleCloneEntity (EntityId id)
 Clones the entity. More...
 
const EntityHandleGetEntity (EntityId id)
 Gets an entity. More...
 
const EntityListGetEntities () const
 Gets every entities in the world. More...
 
BaseSystemGetSystem (SystemIndex index)
 Gets a system in the world by index. More...
 
template<typename SystemType >
SystemType & GetSystem ()
 Gets a system in the world by type. More...
 
bool HasSystem (SystemIndex index) const
 Checks whether or not a system is present in the world by index. More...
 
template<typename SystemType >
bool HasSystem () const
 Checks whether or not a system is present in the world by type. More...
 
void KillEntity (Entity *entity)
 Marks an entity for deletion. More...
 
void KillEntities (const EntityVector &list)
 Kills a set of entities. More...
 
bool IsEntityValid (const Entity *entity) const
 Checks whether or not an entity is valid. More...
 
bool IsEntityIdValid (EntityId id) const
 Checks whether or not an entity is valid. More...
 
void RemoveAllSystems ()
 Removes each system from the world.
 
void RemoveSystem (SystemIndex index)
 Removes a system from the world by index. More...
 
template<typename SystemType >
void RemoveSystem ()
 Removes a system from the world by type.
 
void Update ()
 Updates the world. More...
 
void Update (float elapsedTime)
 Updates the world. More...
 
Worldoperator= (const World &)=delete
 
Worldoperator= (World &&world) noexcept
 Moves a world into another world object. More...
 

Detailed Description

NDK class that represents a world.

Constructor & Destructor Documentation

◆ World() [1/2]

Ndk::World::World ( bool  addDefaultSystems = true)
inline

Constructs a World object.

Parameters
addDefaultSystemsShould default provided systems be used

◆ World() [2/2]

Ndk::World::World ( World &&  world)
inlinenoexcept

Constructs a World object by move semantic.

Parameters
worldWorld to move into this

◆ ~World()

Ndk::World::~World ( )
noexcept

Destructs the object and calls Clear.

See also
Clear

Member Function Documentation

◆ AddSystem() [1/2]

BaseSystem & Ndk::World::AddSystem ( std::unique_ptr< BaseSystem > &&  system)
inline

Adds a system to the world.

Returns
A reference to the newly created system
Parameters
systemSystem to add to the world

◆ AddSystem() [2/2]

template<typename SystemType , typename... Args>
SystemType & Ndk::World::AddSystem ( Args &&...  args)

Adds a system to the world.

Returns
A reference to the newly created system
Parameters
argsArguments used to create the system

◆ Clear()

void Ndk::World::Clear ( )
noexcept

Clears the world from every entities.

Remarks
Every handles are correctly invalidated, entities are immediately invalidated

◆ CloneEntity()

const EntityHandle & Ndk::World::CloneEntity ( EntityId  id)

Clones the entity.

Returns
The clone newly created
Parameters
idIdentifier of the entity
Remarks
Produces a NazaraError if the entity to clone does not exist

◆ CreateEntities()

World::EntityVector Ndk::World::CreateEntities ( unsigned int  count)
inline

Creates multiple entities in the world.

Returns
The set of entities created
Parameters
countNumber of entities to create

◆ CreateEntity()

const EntityHandle & Ndk::World::CreateEntity ( )

Creates an entity in the world.

Returns
The entity created

◆ GetEntities()

const EntityList & Ndk::World::GetEntities ( ) const
inline

Gets every entities in the world.

Returns
A constant reference to the entities

◆ GetEntity()

const EntityHandle & Ndk::World::GetEntity ( EntityId  id)
inline

Gets an entity.

Returns
A constant reference to a handle of the entity
Parameters
idIdentifier of the entity
Remarks
Handle referenced by this function can move in memory when updating the world, do not keep a reference to a handle from a world update to another
If an invalid identifier is provided, an error got triggered and an invalid handle is returned

◆ GetSystem() [1/2]

BaseSystem & Ndk::World::GetSystem ( SystemIndex  index)
inline

Gets a system in the world by index.

Returns
A reference to the system
Parameters
indexIndex of the system
Remarks
Produces a NazaraAssert if system is not available in this world

◆ GetSystem() [2/2]

template<typename SystemType >
SystemType & Ndk::World::GetSystem ( )

Gets a system in the world by type.

Returns
A reference to the system
Remarks
Produces a NazaraAssert if system is not available in this world

◆ HasSystem() [1/2]

bool Ndk::World::HasSystem ( SystemIndex  index) const
inline

Checks whether or not a system is present in the world by index.

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

◆ HasSystem() [2/2]

template<typename SystemType >
bool Ndk::World::HasSystem ( ) const

Checks whether or not a system is present in the world by type.

Returns
true If it is the case

◆ IsEntityIdValid()

bool Ndk::World::IsEntityIdValid ( EntityId  id) const
inline

Checks whether or not an entity is valid.

Returns
true If it is the case
Parameters
idIdentifier of the entity

◆ IsEntityValid()

bool Ndk::World::IsEntityValid ( const Entity entity) const
inline

Checks whether or not an entity is valid.

Returns
true If it is the case
Parameters
entityPointer to the entity

◆ KillEntities()

void Ndk::World::KillEntities ( const EntityVector &  list)
inline

Kills a set of entities.

This function has the same effect as calling KillEntity for every entity contained in the vector

Parameters
listSet of entities to kill

◆ KillEntity()

void Ndk::World::KillEntity ( Entity entity)
inline

Marks an entity for deletion.

Parameters
Pointerto the entity
Remarks
If the entity pointer is invalid, nothing is done
For safety, entities are not killed until the next world update

◆ operator=()

World & Ndk::World::operator= ( World &&  world)
inlinenoexcept

Moves a world into another world object.

Returns
A reference to the object

◆ RemoveSystem()

void Ndk::World::RemoveSystem ( SystemIndex  index)
inline

Removes a system from the world by index.

Parameters
indexIndex of the system
Remarks
No change is done if system is not present

◆ Update() [1/2]

void Ndk::World::Update ( )

Updates the world.

Remarks
Produces a NazaraAssert if an entity is invalid

◆ Update() [2/2]

void Ndk::World::Update ( float  elapsedTime)
inline

Updates the world.

Parameters
elapsedTimeDelta time used for the update

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