getNeighbours method

Set<Tile> getNeighbours()

Gets all eight neighboring tiles around this tile.

Returns tiles in all cardinal and diagonal directions, wrapping around the world boundaries as needed (longitude wraps, latitude clamps).

Returns a Set containing the 8 neighboring tiles

Implementation

Set<Tile> getNeighbours() {
  Set<Tile> neighbours = {};
  neighbours.add(getLeft());
  neighbours.add(getAboveLeft());
  neighbours.add(getAbove());
  neighbours.add(getAboveRight());
  neighbours.add(getRight());
  neighbours.add(getBelowRight());
  neighbours.add(getBelow());
  neighbours.add(getBelowLeft());
  return neighbours;
}