Added getEntitiesByType method

This commit is contained in:
Marcin Kostrzewski 2020-05-15 08:54:21 +02:00
parent dae94576e7
commit a40a598ffe

View File

@ -87,6 +87,20 @@ class Map:
print("Failed to load entity " + entity) print("Failed to load entity " + entity)
return actualEntities 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): def terrainDraw(self):
""" """
Composes terrain data. Composes terrain data.