This commit is contained in:
simon
2017-12-30 10:30:18 -05:00
parent 9e402fe8a1
commit fd73a47796
4 changed files with 32 additions and 8 deletions

View File

@@ -54,7 +54,7 @@ public class World implements JSONSerialisable {
*/
public boolean isTileBlocked(int x, int y) {
return getGameObjectsAt(x, y).size() > 0 || tileMap.getTileAt(x, y) == TileMap.WALL_TILE;
return getGameObjectsBlockingAt(x, y).size() > 0 || tileMap.getTileAt(x, y) == TileMap.WALL_TILE;
}
@@ -245,13 +245,13 @@ public class World implements JSONSerialisable {
}
/**
* Get the list of game objects at a location
* Get the list of game objects that are blocking a tile at a set of coordinates
*
* @param x X coordinate on the World
* @param y Y coordinate on the World
* @return the list of game objects at a location
* @return the list of game objects blocking a location
*/
public ArrayList<GameObject> getGameObjectsAt(int x, int y) {
public ArrayList<GameObject> getGameObjectsBlockingAt(int x, int y) {
ArrayList<GameObject> gameObjects = new ArrayList<>(2);
@@ -266,6 +266,30 @@ public class World implements JSONSerialisable {
return gameObjects;
}
/**
* Get the list of game objects that are exactly at a given location
* <br>
* Note: Objects like the Factory that are more than 1x1 tiles wide will only be returned
* when their exact coordinates are specified
*
* @param x X coordinate on the World
* @param y Y coordinate on the World
* @return the list of game objects at a location
*/
public ArrayList<GameObject> getGameObjectsAt(int x, int y) {
ArrayList<GameObject> gameObjects = new ArrayList<>(2);
for (GameObject obj : this.gameObjects) {
if (obj.getX() == x && obj.getY() == y) {
gameObjects.add(obj);
}
}
return gameObjects;
}
public void incUpdatable() {
updatable++;
}