Added EntityExists and HasComponent

This commit is contained in:
2026-01-28 14:29:47 +02:00
parent 4cc10ddc21
commit f760cfd658
2 changed files with 12 additions and 4 deletions

View File

@@ -69,8 +69,7 @@ public:
template <Component component>
[[nodiscard("Discarding an expensive operation's result!")]]
bool HasComponent(const Entity &entity) {
// TO BE IMPLEMENTED
return true;
return entityComponentMap.query(entity, typeid(component)).size();
}
template <Component component>

View File

@@ -25,8 +25,17 @@ Entity World::CreateEntity() {
}
bool World::EntityExists(const Entity &entity) noexcept {
// TO BE IMPLEMENTED
bool exists = false;
entityComponentMap.scan(
[&exists, entity](const Tourmaline::Type::UUID &currentEntity,
const std::type_index &, std::any &) -> bool {
if (currentEntity == entity) {
exists = true;
return true;
}
return false;
});
return exists;
}
bool World::DestroyEntity(Entity entity) {