mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-12 22:38:54 +00:00
Fixes #65
This commit is contained in:
@@ -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++;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user