From 018f6209378a0c30c1e44fba2f80888553b9f67c Mon Sep 17 00:00:00 2001 From: max-001 Date: Wed, 16 Oct 2024 16:50:59 +0200 Subject: Added functionality for scripts --- mwe/ecs-homemade/inc/ComponentManager.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mwe/ecs-homemade/inc/ComponentManager.hpp') diff --git a/mwe/ecs-homemade/inc/ComponentManager.hpp b/mwe/ecs-homemade/inc/ComponentManager.hpp index d6da8e8..a120ab1 100644 --- a/mwe/ecs-homemade/inc/ComponentManager.hpp +++ b/mwe/ecs-homemade/inc/ComponentManager.hpp @@ -1,6 +1,6 @@ template -void ComponentManager::AddComponent(std::uint32_t id, Args &&... args) { +T& ComponentManager::AddComponent(std::uint32_t id, Args &&... args) { std::type_index type = typeid( T); //Determine the type of T (this is used as the key of the unordered_map<>) @@ -21,6 +21,8 @@ void ComponentManager::AddComponent(std::uint32_t id, Args &&... args) { mComponents[type][id].push_back(std::make_unique(std::forward( args)...)); //Create a new component of type T using perfect forwarding and store its unique_ptr in the vector<> + + return static_cast(*mComponents[type][id].back().get()); } template -- cgit v1.2.3