SceneManager
Scene Manager - handles scene loading, switching, and lifecycle
- Module
- Game
- Header
#include "Scene/SceneManager.h"- Namespace
Mowo
Type aliases
| Alias | Description |
|---|---|
using SceneCallback = std::function<void(Scene*)> | Callbacks |
Constructors
| Signature | Name | Description |
|---|---|---|
SceneManager() | SceneManager | |
~SceneManager() | ~SceneManager |
Public functions
| Returns | Name | Description |
|---|---|---|
SceneManager& | Get | Singleton access |
SceneManager* | TryGet | Null-safe singleton accessor. |
void | Initialize | |
void | Shutdown | |
void | ProcessPendingSceneSwitch | Applies a scene switch requested since the last call; the host ticks the scene itself |
Scene* | CreateScene | Scene creation |
Scene* | LoadScene | Scene loading |
Scene* | FindLoadedScene | The scene already loaded from path, or null. |
Scene* | LoadSceneFromDocument | LoadScene for a document the caller read and parsed itself — the editor does that on a worker so a large level's parse never holds a frame. |
bool | ReadSceneDocument | Reads path into the document LoadSceneFromDocument takes, assembling a split .mmap from its actor files. |
bool | SaveScene | |
void | UnloadScene | |
Scene* | CreatePlayWorld | Play-in-editor worlds. |
Scene* | LoadScenePlayCopy | |
int | LoadSceneAdditive | Additive load — appends entities from path to target, leaving target's environment and existing entities untouched. |
void | SetActiveScene | Active scene management |
Scene* | GetActiveScene | |
void | SwitchToScene | Scene switching (with optional transition) |
void | SwitchToScene | |
Scene* | GetScene | Scene queries |
bool | HasScene | |
void | SetOnSceneLoaded | |
void | SetOnSceneUnloaded | |
void | SetOnSceneChanged |
Function details
SceneManager
SceneManager()~SceneManager
~SceneManager()Get
static SceneManager& Get()Singleton access
TryGet
static SceneManager* TryGet()Null-safe singleton accessor. Returns nullptr if SceneManager has not been initialised yet OR has already been destroyed (e.g. during shutdown, where ~Engine tears the manager down before the editor layer's OnDetach fires). Callers in shutdown paths must prefer this over Get() to avoid dereferencing a null this.
Initialize
void Initialize()Shutdown
void Shutdown()ProcessPendingSceneSwitch
void ProcessPendingSceneSwitch()Applies a scene switch requested since the last call; the host ticks the scene itself
CreateScene
Scene* CreateScene(const std::string& name)Scene creation
LoadScene
Scene* LoadScene(const std::string& path)Scene loading
FindLoadedScene
Scene* FindLoadedScene(const std::string& path) constThe scene already loaded from path, or null. What LoadScene returns without touching the disk when the file is open already.
LoadSceneFromDocument
Scene* LoadSceneFromDocument(const std::string& path, MDF::MdfDocument& doc)LoadScene for a document the caller read and parsed itself — the editor does that on a worker so a large level's parse never holds a frame.
ReadSceneDocument
static bool ReadSceneDocument(const std::string& path, MDF::MdfDocument& doc)Reads path into the document LoadSceneFromDocument takes, assembling a split .mmap from its actor files. A caller that parsed the .mmap itself got the world settings alone and loaded an empty level. Touches only the VFS, so it runs on a worker.
SaveScene
bool SaveScene(Scene* scene, const std::string& path = "")UnloadScene
void UnloadScene(Scene* scene)CreatePlayWorld
Scene* CreatePlayWorld(const Scene& source)Play-in-editor worlds. CreatePlayWorld duplicates an edited document into a separate scene the game runs in, so Play never writes into the level and Stop just unloads the copy. LoadScenePlayCopy is the travel half: it always loads path fresh, because the scene already open under that path is an editor document the game must not run in.
LoadScenePlayCopy
Scene* LoadScenePlayCopy(const std::string& path)LoadSceneAdditive
int LoadSceneAdditive(const std::string& path, Scene* target = nullptr)Additive load — appends entities from path to target, leaving target's environment and existing entities untouched. The merged entities receive fresh UUIDs so two additive loads of the same file produce independent sets. Returns the number of entities merged (0 on parse failure / missing file). Pass nullptr target to use the currently active scene.
SetActiveScene
void SetActiveScene(Scene* scene)Active scene management
GetActiveScene
Scene* GetActiveScene() constSwitchToScene
void SwitchToScene(const std::string& path)Scene switching (with optional transition)
SwitchToScene
void SwitchToScene(Scene* scene)GetScene
Scene* GetScene(const std::string& name) constScene queries
HasScene
bool HasScene(const std::string& name) constSetOnSceneLoaded
void SetOnSceneLoaded(SceneCallback callback)SetOnSceneUnloaded
void SetOnSceneUnloaded(SceneCallback callback)SetOnSceneChanged
void SetOnSceneChanged(SceneCallback callback)