diff options
author | Yann Herklotz <ymherklotz@gmail.com> | 2018-06-23 15:51:37 +0100 |
---|---|---|
committer | Yann Herklotz <ymherklotz@gmail.com> | 2018-06-23 15:51:37 +0100 |
commit | 801299f3175fccb940550cba48903decd7882822 (patch) | |
tree | a065643549f7fa2103b065be16a862c5a34ef2e7 /yage/entity/entity.cpp | |
parent | 083fcf24c50753b6f5fa04c5358be783be64407d (diff) | |
download | YAGE-801299f3175fccb940550cba48903decd7882822.tar.gz YAGE-801299f3175fccb940550cba48903decd7882822.zip |
Entity implementation with added 'each' function
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; } |