aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/ComponentManager.hpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-10-16 17:21:04 +0200
committerLoek Le Blansch <loek@pipeframe.xyz>2024-10-16 17:21:04 +0200
commit1f82ffa4d3ee8355215d43bf43edf8cecaca0d1d (patch)
tree218b7f87df6edd5a5e2a13ca5bbcca43b7a717a3 /src/crepe/ComponentManager.hpp
parentf9aa198eef7b85eeba3bac4c4fe2d4578b836bbf (diff)
fix user script implementation
Diffstat (limited to 'src/crepe/ComponentManager.hpp')
-rw-r--r--src/crepe/ComponentManager.hpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/crepe/ComponentManager.hpp b/src/crepe/ComponentManager.hpp
index c872594..e0242a2 100644
--- a/src/crepe/ComponentManager.hpp
+++ b/src/crepe/ComponentManager.hpp
@@ -3,12 +3,11 @@
#include <type_traits>
#include "ComponentManager.h"
-#include "api/BehaviorScript.h"
namespace crepe {
template <class T, typename... Args>
-void ComponentManager::add_component(uint32_t id, Args &&... args) {
+T & ComponentManager::add_component(uint32_t id, Args &&... args) {
using namespace std;
static_assert(is_base_of<Component, T>::value, "add_component must recieve a derivative class of Component");
@@ -33,6 +32,8 @@ void ComponentManager::add_component(uint32_t id, Args &&... args) {
T * instance = new T(forward<Args>(args)...);
// store its unique_ptr in the vector<>
components[type][id].push_back(unique_ptr<T>(instance));
+
+ return *instance;
}
template <typename T>