d96f15c954c8 — Quintillus tip 10 months ago
Add a utility method to grab a tile based on its coordinates.

Kind of surprised one of these didn't already exist.
1 files changed, 15 insertions(+), 0 deletions(-)

M src/main/java/com/civfanatics/civ3/biqFile/IO.java
M src/main/java/com/civfanatics/civ3/biqFile/IO.java +15 -0
@@ 6655,6 6655,21 @@ public class IO
     }
     
     /**
+     * Convenience method that returns the tile at a given index.  Wraps around
+     * the world if need be.
+     * @param xPos The xlocation
+     * @param yPos The ylocation
+     * @return The tile at that location, or null if the location is not valid
+     */
+    public TILE getTileAt(int xPos, int yPos) {
+        int tileIndex = calculateTileIndex(xPos, yPos);
+        if (tileIndex == -1) {
+            return null;
+        }
+        return tile.get(tileIndex);
+    }
+    
+    /**
      * Returns the 8 surrounding tiles.
      * If some of them are off the map, it returns fewer.
      * May be expanded to the 21 tiles cross at one point.