From a40a598ffe3969e5f592aaa36dc1209eace95d8f Mon Sep 17 00:00:00 2001 From: Marcin Kostrzewski Date: Fri, 15 May 2020 08:54:21 +0200 Subject: [PATCH] Added getEntitiesByType method --- src/game/Map.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/game/Map.py b/src/game/Map.py index 73b04ec..b5e75b3 100644 --- a/src/game/Map.py +++ b/src/game/Map.py @@ -87,6 +87,20 @@ class Map: print("Failed to load entity " + entity) return actualEntities + def getEntitiesByType(self, type): + """ + Get a list of all entities by their type. + + :param type: Entity type as class tpe + :return A list of all entities of specified type + """ + result = [] + for entity in self.entities.sprites(): + if isinstance(entity, type): + result.append(entity) + + return result + def terrainDraw(self): """ Composes terrain data.