mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-13 22:59:02 +00:00
Added method to find objects of particular type in a world
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user