Browse Source

Lesson 19.6

Godzil 3 years ago
parent
commit
52a7052165
2 changed files with 5 additions and 3 deletions
  1. 4 0
      source/ECS.cpp
  2. 1 3
      source/include/Systems/Damage.h

+ 4 - 0
source/ECS.cpp

@@ -196,6 +196,10 @@ void Registry::groupEntity(Entity entity, const std::string &groupName)
 
 bool Registry::entityBelongsToGroup(Entity entity, const std::string &groupName) const
 {
+    if (this->entitiesPerGroup.find(groupName) == this->entitiesPerGroup.end())
+    {
+        return false;
+    }
     auto groupEntities = this->entitiesPerGroup.at(groupName);
     return groupEntities.find(entity) != groupEntities.end();
 }

+ 1 - 3
source/include/Systems/Damage.h

@@ -64,7 +64,7 @@ public:
             {
                 enemyEntity.kill();
             }
-            
+
             projectileEntity.kill();
         }
     }
@@ -90,8 +90,6 @@ public:
         {
             this->onProjectileHitEnemy(event.b, event.a);
         }
-
-
     }
 
     void Update()