mirror of
https://gitlab.com/voidframe/voidframe-cpp.git
synced 2026-10-12 02:10:08 -04:00
Add attempt for Entity::GetComponent
This commit is contained in:
1 parent
45c7b2412c
commit
4afd985a50
2 files changed
+8
-4
No files matched your search
@@ -11,3 +11,10 @@ Component *Entity::AddComponent(Args &&...args) {
|
||||
components.push_back(std::make_unique(std::forward<Args>(args)...));
|
||||
return components.back().get();
|
||||
}
|
||||
|
||||
template <typename CompT> Component *Entity::GetComponent() {
|
||||
for (const auto &comp_ptr : components) {
|
||||
if (auto *comp = dynamic_cast<CompT *>(comp_ptr.get()))
|
||||
return comp;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user