42 template <
typename TScene> TScene &
RegisterScene(
const std::string &name)
44 static_assert(std::is_base_of_v<Utils::AScene, TScene>,
"TScene must inherit from Utils::AScene");
47 Log::Warning(fmt::format(
"Scene {} already exists", name));
49 std::shared_ptr<TScene> new_scene = std::make_shared<TScene>();
51 return *new_scene.get();
61 [[nodiscard]] std::optional<std::shared_ptr<Utils::AScene>>
_getScene(
const std::string &name);
65 std::size_t
operator()(
const std::string &str)
const noexcept {
return std::hash<std::string>{}(str); }
66 std::size_t
operator()(std::string_view str)
const noexcept {
return std::hash<std::string_view>{}(str); }
67 std::size_t
operator()(
const char *str)
const noexcept {
return std::hash<std::string_view>{}(str); }
The core is the place where all the data of the engine is stored. It contains the registry (entities)...
Definition Core.hpp:33
void _loadScene(Engine::Core &core, const std::string &name)
Definition SceneManager.cpp:23
std::optional< std::shared_ptr< Utils::AScene > > _getScene(const std::string &name)
Definition SceneManager.cpp:43
TScene & RegisterScene(const std::string &name)
Register a scene using a name as a key.
Definition SceneManager.hpp:42
std::unordered_map< std::string, std::shared_ptr< Utils::AScene >, TransparentHash, std::equal_to<> > _scenes
Definition SceneManager.hpp:69
void Update(Engine::Core &core)
Unload the current scene and load the next scene.
Definition SceneManager.cpp:9
const std::optional< std::string > & GetCurrentScene() const
Definition SceneManager.hpp:54
void SetNextScene(const std::string_view &name)
Set the next scene to load. It will be loaded at the next call of Update.
Definition SceneManager.hpp:26
std::optional< std::string > _currentScene
Definition SceneManager.hpp:72
std::optional< std::string > _nextScene
Definition SceneManager.hpp:71
void _unloadScene(Engine::Core &core, const std::string &name)
Definition SceneManager.cpp:33
void Warning(const T &msg) noexcept
Definition Logger.hpp:49
Definition SceneManager.hpp:14
Definition SceneManager.hpp:63
void is_transparent
Definition SceneManager.hpp:64
std::size_t operator()(const char *str) const noexcept
Definition SceneManager.hpp:67
std::size_t operator()(const std::string &str) const noexcept
Definition SceneManager.hpp:65
std::size_t operator()(std::string_view str) const noexcept
Definition SceneManager.hpp:66