RLLib
0.1
|
The scene represents a world filled with entities that the game engine can run and display. More...
#include <Scene.hpp>
Public Member Functions | |
Scene ()=default | |
Creates an empty scene. | |
Scene (const FilePath &path) | |
Creates and loads the scene from a file. More... | |
void | load (const FilePath &path) |
Loads the scene from a file. More... | |
void | save (const FilePath &path) const |
Saves the scene into a file. More... | |
bool | hasEntity (const std::string &name) const |
Tells if the scene has an entity with the specified name. More... | |
std::size_t | entityCount () const noexcept |
Returns the number of entities in the scene. More... | |
const Entity & | operator[] (const std::string &name) const |
Returns the entity (const) associated to the given name. More... | |
Entity & | operator[] (const std::string &name) |
Returns the entity associated to the given name. More... | |
const Entity & | operator[] (std::size_t index) const |
Returns the entity (const) at the given index. More... | |
Entity & | operator[] (std::size_t index) |
Returns the entity at the given index. More... | |
std::vector< Entity >::iterator | begin () noexcept |
std::vector< Entity >::const_iterator | cbegin () const noexcept |
std::vector< Entity >::iterator | end () noexcept |
std::vector< Entity >::const_iterator | cend () const noexcept |
Public Attributes | |
ByteStream | header |
Some unknown properties that might be specific to this scene. | |
Static Public Attributes | |
static std::function< std::vector< EntityLocation >ByteStream &)> | locator |
Function that locates entities using a specific strategy. | |
The scene represents a world filled with entities that the game engine can run and display.
When the scene is loaded, it uses an algorithm function to locate all the entities. The default algorithm can be replaced by another one by modifying the static variable rl::Scene::locator, which is a callable object. A few algorithms are available in the namespace rl::locator.
|
explicit |
Creates and loads the scene from a file.
path | The path to the scene file |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
|
noexcept |
Returns the number of entities in the scene.
bool rl::Scene::hasEntity | ( | const std::string & | name | ) | const |
Tells if the scene has an entity with the specified name.
name | The name of the entity |
true
if such an entity exists, false
if not void rl::Scene::load | ( | const FilePath & | path | ) |
Loads the scene from a file.
path | The path to the scene file |
const Entity& rl::Scene::operator[] | ( | const std::string & | name | ) | const |
Returns the entity (const) associated to the given name.
If there is no such entity, the behavior is undefined.
name | The name of the entity |
Entity& rl::Scene::operator[] | ( | const std::string & | name | ) |
Returns the entity associated to the given name.
If there is no such entity, the behavior is undefined.
name | The name of the entity |
const Entity& rl::Scene::operator[] | ( | std::size_t | index | ) | const |
Returns the entity (const) at the given index.
If the index is out of bound, the behavior is undefined.
index | The entity index |
Entity& rl::Scene::operator[] | ( | std::size_t | index | ) |
Returns the entity at the given index.
If the index is out of bound, the behavior is undefined.
index | The entity index |
void rl::Scene::save | ( | const FilePath & | path | ) | const |
Saves the scene into a file.
path | The path to the scene file |