From 7c21e34ae1898fce8c8051b5f1380e268da32140 Mon Sep 17 00:00:00 2001 From: max-001 Date: Fri, 22 Nov 2024 09:36:35 +0100 Subject: Replaced ComponentManager reference by OptionalRef for late binding --- src/crepe/api/SceneManager.hpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/crepe/api/SceneManager.hpp') diff --git a/src/crepe/api/SceneManager.hpp b/src/crepe/api/SceneManager.hpp index 94e5946..1edaa7d 100644 --- a/src/crepe/api/SceneManager.hpp +++ b/src/crepe/api/SceneManager.hpp @@ -4,12 +4,15 @@ namespace crepe { -template -void SceneManager::add_scene() { +template +void SceneManager::add_scene(Args &&... args) { using namespace std; static_assert(is_base_of::value, "T must be derived from Scene"); - Scene * scene = new T(this->component_manager); + Scene * scene = new T(std::forward(args)...); + + scene->component_manager = this->component_manager; + this->scenes.emplace_back(unique_ptr(scene)); // The first scene added, is the one that will be loaded at the beginning -- cgit v1.2.3 From ef6acbee3bd00c322a56221d992d08a64e15e3b9 Mon Sep 17 00:00:00 2001 From: max-001 Date: Fri, 22 Nov 2024 09:46:10 +0100 Subject: Little fix (typo) --- src/crepe/api/SceneManager.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/crepe/api/SceneManager.hpp') diff --git a/src/crepe/api/SceneManager.hpp b/src/crepe/api/SceneManager.hpp index 1edaa7d..ccc755f 100644 --- a/src/crepe/api/SceneManager.hpp +++ b/src/crepe/api/SceneManager.hpp @@ -9,7 +9,7 @@ void SceneManager::add_scene(Args &&... args) { using namespace std; static_assert(is_base_of::value, "T must be derived from Scene"); - Scene * scene = new T(std::forward(args)...); + Scene * scene = new T(std::forward(args)...); scene->component_manager = this->component_manager; -- cgit v1.2.3 From 2f10649bf08bbe507458fa4da8be1dd7b02213da Mon Sep 17 00:00:00 2001 From: max-001 Date: Sun, 24 Nov 2024 11:52:48 +0100 Subject: Implemented feedback --- src/crepe/api/SceneManager.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/crepe/api/SceneManager.hpp') diff --git a/src/crepe/api/SceneManager.hpp b/src/crepe/api/SceneManager.hpp index ccc755f..5c8e417 100644 --- a/src/crepe/api/SceneManager.hpp +++ b/src/crepe/api/SceneManager.hpp @@ -10,10 +10,11 @@ void SceneManager::add_scene(Args &&... args) { static_assert(is_base_of::value, "T must be derived from Scene"); Scene * scene = new T(std::forward(args)...); + unique_ptr unique_scene(scene); - scene->component_manager = this->component_manager; + unique_scene->component_manager = this->component_manager; - this->scenes.emplace_back(unique_ptr(scene)); + this->scenes.emplace_back(std::move(unique_scene)); // The first scene added, is the one that will be loaded at the beginning if (next_scene.empty()) { -- cgit v1.2.3