[DEV] add get component

This commit is contained in:
Edouard DUPIN 2017-10-02 23:41:19 +02:00
parent 7154278417
commit f30ec409bb
2 changed files with 13 additions and 0 deletions

View File

@ -151,6 +151,18 @@ void ege::Entity::rmComponent(const etk::String& _type) {
}
}
ememory::SharedPtr<ege::Component> ege::Entity::getComponent(const etk::String& _type) {
// check if not exist
for (size_t iii=0; iii<m_component.size(); ++iii) {
if (m_component[iii] == nullptr) {
continue;
}
if (m_component[iii]->getType() == _type) {
return m_component[iii];
}
}
return nullptr;
}

View File

@ -46,6 +46,7 @@ namespace ege {
void addComponent(const ememory::SharedPtr<ege::Component>& _ref);
void rmComponent(const ememory::SharedPtr<ege::Component>& _ref);
void rmComponent(const etk::String& _type);
ememory::SharedPtr<ege::Component> getComponent(const etk::String& _type);
/**
* @brief get the Entity Type description string.