Elevate Engine 1
Loading...
Searching...
No Matches
SceneManager.h
Go to the documentation of this file.
1#pragma once
2
3#include <vector>
4
6
7namespace Elevate
8{
10 public:
11 static inline void LoadScene(ScenePtr scene) { PushScene(scene); }
12 static inline void UnloadScene(ScenePtr scene) { PopScene(scene); }
13
14 static inline void SetScene(ScenePtr scene)
15 {
16 m_Scenes.clear();
17 LoadScene(scene);
18 }
19
20 static inline ScenePtr GetCurrentScene()
21 {
22 if (!m_Scenes.empty())
23 {
24 return m_Scenes.back();
25 }
26 else return nullptr;
27 }
28
29 static inline ScenePtr GetCurrentScene(SceneType type) {
30 for (auto it = m_Scenes.end() - 1; it >= m_Scenes.begin(); it--) {
31 ScenePtr ptr = *it;
32 if (it->get()->GetType() == type) {
33 return ptr;
34 }
35 }
36 return nullptr;
37 }
38
39 static inline std::vector<ScenePtr>::iterator begin() { return m_Scenes.begin(); }
40 static inline std::vector<ScenePtr>::iterator end() { return m_Scenes.end(); }
41
42 private:
43 static inline void PushScene(ScenePtr scene) { m_Scenes.push_back(scene); }
44 static inline void PopScene(ScenePtr scene)
45 {
46 m_Scenes.erase(std::remove(m_Scenes.begin(), m_Scenes.end(), scene), m_Scenes.end());
47 }
48
49 private:
50 static inline std::vector<ScenePtr> m_Scenes;
51 };
52}
static void LoadScene(ScenePtr scene)
static void SetScene(ScenePtr scene)
static ScenePtr GetCurrentScene()
static void UnloadScene(ScenePtr scene)
static ScenePtr GetCurrentScene(SceneType type)
static std::vector< ScenePtr >::iterator end()
static std::vector< ScenePtr >::iterator begin()
SceneType
Definition Scene.h:28
std::shared_ptr< Scene > ScenePtr
Definition Renderer.h:12