Engine²
Open-source game engine written in C++.
Loading...
Searching...
No Matches
Scene::Resource::SceneManager Class Reference

#include <SceneManager.hpp>

Classes

struct  TransparentHash

Public Member Functions

 SceneManager ()=default
 ~SceneManager ()=default
void SetNextScene (const std::string_view &name)
 Set the next scene to load. It will be loaded at the next call of Update.
void Update (Engine::Core &core)
 Unload the current scene and load the next scene.
template<typename TScene>
TScene & RegisterScene (const std::string &name)
 Register a scene using a name as a key.
const std::optional< std::string > & GetCurrentScene () const

Private Member Functions

void _loadScene (Engine::Core &core, const std::string &name)
void _unloadScene (Engine::Core &core, const std::string &name)
std::optional< std::shared_ptr< Utils::AScene > > _getScene (const std::string &name)

Private Attributes

std::unordered_map< std::string, std::shared_ptr< Utils::AScene >, TransparentHash, std::equal_to<> > _scenes
std::optional< std::string > _nextScene
std::optional< std::string > _currentScene

Constructor & Destructor Documentation

◆ SceneManager()

Scene::Resource::SceneManager::SceneManager ( )
default

◆ ~SceneManager()

Scene::Resource::SceneManager::~SceneManager ( )
default

Member Function Documentation

◆ _getScene()

std::optional< std::shared_ptr< Scene::Utils::AScene > > Scene::Resource::SceneManager::_getScene ( const std::string & name)
nodiscardprivate

◆ _loadScene()

void Scene::Resource::SceneManager::_loadScene ( Engine::Core & core,
const std::string & name )
private

◆ _unloadScene()

void Scene::Resource::SceneManager::_unloadScene ( Engine::Core & core,
const std::string & name )
private

◆ GetCurrentScene()

const std::optional< std::string > & Scene::Resource::SceneManager::GetCurrentScene ( ) const
inline

◆ RegisterScene()

template<typename TScene>
TScene & Scene::Resource::SceneManager::RegisterScene ( const std::string & name)
inline

Register a scene using a name as a key.

Template Parameters
TScenetype of the scene to register
Parameters
namename of the scene
Returns
reference of the registered scene

◆ SetNextScene()

void Scene::Resource::SceneManager::SetNextScene ( const std::string_view & name)
inline

Set the next scene to load. It will be loaded at the next call of Update.

Parameters
namename of the scene to load

◆ Update()

void Scene::Resource::SceneManager::Update ( Engine::Core & core)

Unload the current scene and load the next scene.

Parameters
corecore that contains all components

Member Data Documentation

◆ _currentScene

std::optional<std::string> Scene::Resource::SceneManager::_currentScene
private

◆ _nextScene

std::optional<std::string> Scene::Resource::SceneManager::_nextScene
private

◆ _scenes

std::unordered_map<std::string, std::shared_ptr<Utils::AScene>, TransparentHash, std::equal_to<> > Scene::Resource::SceneManager::_scenes
private

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