aboutsummaryrefslogtreecommitdiff
path: root/src/crepe/ComponentManager.hpp
diff options
context:
space:
mode:
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>