summary refs log tree commit diff stats
path: root/src/entity_manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/entity_manager.cpp')
-rw-r--r--src/entity_manager.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/entity_manager.cpp b/src/entity_manager.cpp index 9ad758b..f792e17 100644 --- a/src/entity_manager.cpp +++ b/src/entity_manager.cpp
@@ -4,17 +4,18 @@
4#include "entity_manager.h" 4#include "entity_manager.h"
5 5
6template <> 6template <>
7std::set<int> EntityManager::getEntitiesWithComponents<>(std::set<std::type_index>& componentTypes) 7std::set<EntityManager::id_type> EntityManager::getEntitiesWithComponents<>(
8 std::set<std::type_index>& componentTypes)
8{ 9{
9 if (cachedComponents.count(componentTypes) == 1) 10 if (cachedComponents.count(componentTypes) == 1)
10 { 11 {
11 return cachedComponents[componentTypes]; 12 return cachedComponents[componentTypes];
12 } 13 }
13 14
14 std::set<int>& cache = cachedComponents[componentTypes]; 15 std::set<id_type>& cache = cachedComponents[componentTypes];
15 for (auto& entity : entities) 16 for (id_type entity = 0; entity < entities.size(); entity++)
16 { 17 {
17 EntityData& data = entity.second; 18 EntityData& data = entities[entity];
18 bool cacheEntity = true; 19 bool cacheEntity = true;
19 20
20 for (auto& componentType : componentTypes) 21 for (auto& componentType : componentTypes)
@@ -28,7 +29,7 @@ std::set<int> EntityManager::getEntitiesWithComponents<>(std::set<std::type_inde
28 29
29 if (cacheEntity) 30 if (cacheEntity)
30 { 31 {
31 cache.insert(entity.first); 32 cache.insert(entity);
32 } 33 }
33 } 34 }
34 35