Added method to find objects of particular type in a world

This commit is contained in:
simon
2018-05-12 19:09:00 -04:00
parent 80f45f1eb0
commit be8dd14d36
2 changed files with 14 additions and 3 deletions

View File

@@ -131,6 +131,19 @@ public class World implements MongoSerializable {
return matchingObjects;
}
public ArrayList<GameObject> findGameObjects(String type) {
ArrayList<GameObject> matchingObjects = new ArrayList<>(2);
for (GameObject obj : gameObjects.values()) {
if ((obj.getClass().getName().equals(type))) {
matchingObjects.add(obj);
}
}
return matchingObjects;
}
public void addObject(GameObject object) {
gameObjects.put(object.getObjectId(), object);
}