added getInteractablesByClassifier method
This commit is contained in:
parent
74093de1d3
commit
b6893379cf
@ -2,6 +2,7 @@ import json
|
|||||||
|
|
||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
|
from src.entities.Enums import Classifiers
|
||||||
from src.entities.Interactable import Interactable
|
from src.entities.Interactable import Interactable
|
||||||
from src.game.TerrainTile import TerrainTile
|
from src.game.TerrainTile import TerrainTile
|
||||||
from src.game.Screen import Locations
|
from src.game.Screen import Locations
|
||||||
@ -89,6 +90,19 @@ class Map:
|
|||||||
print("Failed to load entity " + entity)
|
print("Failed to load entity " + entity)
|
||||||
return actualEntities
|
return actualEntities
|
||||||
|
|
||||||
|
def getInteractablesByClassifier(self, classifier: Classifiers):
|
||||||
|
"""
|
||||||
|
Return a list of all Interactable entities by a given classifier.
|
||||||
|
|
||||||
|
:type classifier: Classifiers
|
||||||
|
:param classifier: Classifier
|
||||||
|
"""
|
||||||
|
result = []
|
||||||
|
for entity in self.entities.sprites():
|
||||||
|
if isinstance(entity, Interactable) and entity.classifier.value == classifier.value:
|
||||||
|
result.append(entity)
|
||||||
|
return result
|
||||||
|
|
||||||
def getEntitiesByType(self, type):
|
def getEntitiesByType(self, type):
|
||||||
"""
|
"""
|
||||||
Get a list of all entities by their type.
|
Get a list of all entities by their type.
|
||||||
|
Loading…
Reference in New Issue
Block a user