getInteractablesByClassifier's classifier param is now optional
This commit is contained in:
parent
6ec1c0b2d2
commit
5e1e089015
@ -90,17 +90,21 @@ class Map:
|
|||||||
print("Failed to load entity " + entity)
|
print("Failed to load entity " + entity)
|
||||||
return actualEntities
|
return actualEntities
|
||||||
|
|
||||||
def getInteractablesByClassifier(self, classifier: Classifiers):
|
def getInteractablesByClassifier(self, classifier=None):
|
||||||
"""
|
"""
|
||||||
Return a list of all Interactable entities by a given classifier.
|
Return a list of all Interactable entities by a given classifier.
|
||||||
|
If the classifier is None, returns all interactables.
|
||||||
|
|
||||||
:type classifier: Classifiers
|
:type classifier: Classifiers
|
||||||
:param classifier: Classifier
|
:param classifier: Classifier
|
||||||
"""
|
"""
|
||||||
result = []
|
result = []
|
||||||
for entity in self.entities.sprites():
|
for entity in self.entities.sprites():
|
||||||
if isinstance(entity, Interactable) and entity.classifier.value == classifier.value:
|
if isinstance(entity, Interactable):
|
||||||
result.append(entity)
|
if classifier is None:
|
||||||
|
result.append(entity)
|
||||||
|
elif entity.classifier.value == classifier.value:
|
||||||
|
result.append(entity)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
def getEntitiesByType(self, type):
|
def getEntitiesByType(self, type):
|
||||||
|
Loading…
Reference in New Issue
Block a user