VEX Engine
Retro looking game engine made in vulkan mostly because i wanted to understand it better.
Loading...
Searching...
No Matches
SceneManager.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
10#include <memory>
11#include <functional>
12
13#include "VEX/VEX_export.h"
14
15namespace vex {
16
18class VEX_EXPORT SceneManager {
19public:
24void loadScene(const std::string& path, Engine& engine);
25
29void unloadScene(const std::string& path);
30
38void loadSceneWithoutClearing(const std::string& path, Engine& engine);
39
43void clearScenes(Engine& engine);
44
48void scenesUpdate(float deltaTime);
49
53const std::vector<std::shared_ptr<GameObject>>& GetAllObjects(const std::string& scene) const { return m_scenes.at(scene)->GetAllObjects(); }
54
58const std::vector<std::shared_ptr<GameObject>>& GetAllAddedObjects(const std::string& scene) const { return m_scenes.at(scene)->GetAllAddedObjects(); }
59
63std::vector<std::string> GetAllSceneNames() const;
64
67std::string getLastSceneName() const { return lastSceneName; }
68
73Scene* GetScene(const std::string& scene) const {
74 if(m_scenes.contains(scene)){
75 return m_scenes.at(scene).get();
76 }
77 return nullptr;
78}
79
80private:
81std::map<std::string, std::shared_ptr<Scene>> m_scenes;
82std::string lastSceneName = "";
83
84bool m_isUpdating = false;
85std::vector<std::function<void()>> m_pendingActions;
86};
87
88} // namespace vex
This file defines SceneManager class.
Class for interaction with engine systems.
Definition Engine.hpp:47
SceneManager class implements scene management functionality like loading and unloading scenes,...
void unloadScene(const std::string &path)
Unloads a specific scene from memory.
void loadScene(const std::string &path, Engine &engine)
Unloads all current scenes and loads a new one from a file.
const std::vector< std::shared_ptr< GameObject > > & GetAllObjects(const std::string &scene) const
Function to get all game objects.
Scene * GetScene(const std::string &scene) const
Safely retrieves a pointer to a specific Scene.
std::string getLastSceneName() const
Function to get last scene name.
const std::vector< std::shared_ptr< GameObject > > & GetAllAddedObjects(const std::string &scene) const
Function to get all added game objects.
void loadSceneWithoutClearing(const std::string &path, Engine &engine)
Loads a scene from a file additively without clearing existing scenes.
void scenesUpdate(float deltaTime)
Updates all currently loaded scenes.
void clearScenes(Engine &engine)
Function to clear the current scene.
Scene class implements scene functionality like loading and holding game objects.
Definition Scene.hpp:22