diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2018-06-23 16:06:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-06-23 16:06:42 +0100 |
commit | 11a6d07652c98b13be6d8097e389480453a7c568 (patch) | |
tree | 3f06a7d35e8ec647041fccea90d5d763ebe6849f /yage/entity/entity.cpp | |
parent | b1673de1b46bd2e566b7c66197ad989d0323f061 (diff) | |
parent | 93c8bfea8b5bcfc0d6513d93cec0eafe82dc465a (diff) | |
download | YAGE-master.tar.gz YAGE-master.zip |
Develop
Diffstat (limited to 'yage/entity/entity.cpp')
-rw-r--r-- | yage/entity/entity.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/yage/entity/entity.cpp b/yage/entity/entity.cpp index 25e8e2d0..c20d15d6 100644 --- a/yage/entity/entity.cpp +++ b/yage/entity/entity.cpp @@ -3,6 +3,8 @@ #include "component.h" #include <algorithm> +#include <iostream> +#include <memory> namespace yage { @@ -29,12 +31,17 @@ bool EntityManager::is_valid(Entity entity) const return false; } -EntityManager &EntityManager::add_component(Entity entity, - BaseComponent *component) +EntityManager & +EntityManager::add_component(Entity entity, + std::unique_ptr<BaseComponent> &&component) { auto id = component->getGroup(); component_masks_[entity] = component_masks_[entity] | ComponentMask(1 << id); + if (id+1 > component_group_.size()) { + component_group_.resize(id+1); + } + component_group_[id].add(std::move(component)); return *this; } |