SceneManager class implements scene management functionality like loading and unloading scenes, holding game objects. More...
#include <SceneManager.hpp>
Public Member Functions | |
| void | loadScene (const std::string &path, Engine &engine) |
| Unloads all current scenes and loads a new one from a file. | |
| void | unloadScene (const std::string &path) |
| Unloads a specific scene from memory. | |
| void | loadSceneWithoutClearing (const std::string &path, Engine &engine) |
| Loads a scene from a file additively without clearing existing scenes. | |
| void | clearScenes (Engine &engine) |
| Function to clear the current scene. | |
| void | scenesUpdate (float deltaTime) |
| Updates all currently loaded scenes. | |
| const std::vector< std::shared_ptr< GameObject > > & | GetAllObjects (const std::string &scene) const |
| Function to get all game objects. | |
| const std::vector< std::shared_ptr< GameObject > > & | GetAllAddedObjects (const std::string &scene) const |
| Function to get all added game objects. | |
| std::vector< std::string > | GetAllSceneNames () const |
| Retrieves the names of all currently loaded scenes. | |
| std::string | getLastSceneName () const |
| Function to get last scene name. | |
| Scene * | GetScene (const std::string &scene) const |
| Safely retrieves a pointer to a specific Scene. | |
Private Attributes | |
| std::map< std::string, std::shared_ptr< Scene > > | m_scenes |
| std::string | lastSceneName = "" |
| bool | m_isUpdating = false |
| std::vector< std::function< void()> > | m_pendingActions |
SceneManager class implements scene management functionality like loading and unloading scenes, holding game objects.
Definition at line 18 of file SceneManager.hpp.
| void vex::SceneManager::clearScenes | ( | Engine & | engine | ) |
Function to clear the current scene.
Clears also all entities in the registry without PersistentTags and MeshManager.
Clears the registry and then clears the m_scenes map.
Definition at line 239 of file SceneManager.cpp.
|
inline |
Function to get all added game objects.
| const | std::string& scene - Name of the scene to get the game objects from. |
Definition at line 58 of file SceneManager.hpp.
|
inline |
Function to get all game objects.
| const | std::string& scene - Name of the scene to get the game objects from. |
Definition at line 53 of file SceneManager.hpp.
| std::vector< std::string > vex::SceneManager::GetAllSceneNames | ( | ) | const |
Retrieves the names of all currently loaded scenes.
Iterates through the internal m_scenes map keys to construct the list.
Definition at line 274 of file SceneManager.cpp.
|
inline |
Function to get last scene name.
Definition at line 67 of file SceneManager.hpp.
|
inline |
Safely retrieves a pointer to a specific Scene.
Checks if the scene exists in the m_scenes map before returning.
| const | std::string& scene - Name/Path of the scene to retrieve. |
Definition at line 73 of file SceneManager.hpp.
| void vex::SceneManager::loadScene | ( | const std::string & | path, |
| Engine & | engine ) |
Unloads all current scenes and loads a new one from a file.
Effectively resets the game state by calling clearScenes() followed by loadSceneWithoutClearing().
| const | std::string& path - Path to the scene file. |
| Engine& | engine - Reference to the engine instance required for object creation. |
Definition at line 216 of file SceneManager.cpp.
| void vex::SceneManager::loadSceneWithoutClearing | ( | const std::string & | path, |
| Engine & | engine ) |
Loads a scene from a file additively without clearing existing scenes.
| const | std::string& path - Path to the scene file. |
| Engine& | engine - Reference to the engine instance. |
Definition at line 233 of file SceneManager.cpp.
| void vex::SceneManager::scenesUpdate | ( | float | deltaTime | ) |
Updates all currently loaded scenes.
Iterates through the m_scenes map and calls sceneUpdate(deltaTime) on each active scene.
| float | deltaTime - Delta time since the last frame. |
Definition at line 259 of file SceneManager.cpp.
| void vex::SceneManager::unloadScene | ( | const std::string & | path | ) |
Unloads a specific scene from memory.
Removes the scene from the internal m_scenes map, triggering the destructor of the Scene object.
| const | std::string& path - Path/Name of the scene to unload. |
Definition at line 229 of file SceneManager.cpp.
|
private |
Definition at line 82 of file SceneManager.hpp.
|
private |
Definition at line 84 of file SceneManager.hpp.
|
private |
Definition at line 85 of file SceneManager.hpp.
|
private |
Definition at line 81 of file SceneManager.hpp.