getInteractablesByClassifier's classifier param is now optional

This commit is contained in:
Marcin Kostrzewski 2020-05-16 11:41:51 +02:00
parent 6ec1c0b2d2
commit 5e1e089015

View File

@ -90,16 +90,20 @@ class Map:
print("Failed to load entity " + entity)
return actualEntities
def getInteractablesByClassifier(self, classifier: Classifiers):
def getInteractablesByClassifier(self, classifier=None):
"""
Return a list of all Interactable entities by a given classifier.
If the classifier is None, returns all interactables.
:type classifier: Classifiers
:param classifier: Classifier
"""
result = []
for entity in self.entities.sprites():
if isinstance(entity, Interactable) and entity.classifier.value == classifier.value:
if isinstance(entity, Interactable):
if classifier is None:
result.append(entity)
elif entity.classifier.value == classifier.value:
result.append(entity)
return result