8#include <unordered_map>
33 virtual void Update(
const float deltaT) = 0;
73 void Update(
const float deltaT);
97 template <
typename T,
typename... Args>
98 requires std::is_base_of_v<Scene, T>
101 auto ptr = std::make_unique<T>(std::forward<Args>(args)...);
103 m_scenes.emplace(
typeid(T), std::move(ptr));
112 template <
typename T>
113 requires std::is_base_of_v<Scene, T>
116 auto it = m_scenes.find(
typeid(T));
117 if (it != m_scenes.end())
119 Assert(it->second.get() != m_currentScene,
"Cannot delete the current scene");
134 template <
typename T>
135 requires std::is_base_of_v<Scene, T>
138 auto it = m_scenes.find(
typeid(T));
139 Assert(it != m_scenes.end(),
"Scene ", Demangle<T>().c_str(),
" does not exist");
140 Assert(it->second.get() != m_currentScene,
"Cannot change to the current scene");
142 m_nextSceneType =
typeid(T);
143 m_changeScene =
true;
154 void CheckForChange();
156 Scene* m_currentScene =
nullptr;
158 bool m_changeScene =
false;
159 std::type_index m_nextSceneType =
typeid(void);
161 std::unordered_map<std::type_index, std::unique_ptr<Scene>> m_scenes;
Manages scenes and the the execution of the current scene.
Definition SceneManager.h:64
void ClearScenes()
Removes all scenes.
Definition SceneManager.cpp:23
void Draw()
Renders the current scene.
Definition SceneManager.cpp:13
void RemoveScene()
Removes a scene from the manager.
Definition SceneManager.h:114
void AddScene(Args &&... args)
Adds a scene to the manager.
Definition SceneManager.h:99
void Update(const float deltaT)
Updates current scene.
Definition SceneManager.cpp:5
void ChangeScene()
Queues a scene change at the end of the frame.
Definition SceneManager.h:136
Base class for all scenes.
Definition SceneManager.h:18
virtual void Draw()=0
Renders the scene.
virtual void OnExit()=0
Called by the engine when a scene is left.
virtual void OnEnter()=0
Called by the engine when a scene is entered.
virtual void Update(const float deltaT)=0
Updates the scene.