Exemple #1
0
  /**
   * Returns the map grid squares that are within radius of location
   *
   * @param location The location that serves as the center of the area
   * @param radius The radius of the area
   * @return The map grid squares in the area
   */
  public ArrayList<MapGridSquare> getArea(Location location, int radius) {
    ArrayList<MapGridSquare> mapGridSquares = new ArrayList<MapGridSquare>();

    for (int x = location.getX() - radius + 1; x <= location.getX() + radius - 1; x++) {
      if (x < 0 || x > mapSize[0] - 1) {
        continue;
      }

      for (int z = location.getZ() - radius + 1; z <= location.getZ() + radius - 1; z++) {
        if (z < 0 || z > mapSize[1] - 1) {
          continue;
        }

        MapGridSquare mapGridSquare = this.map.get(new Location(x, z));
        if (!(mapGridSquare.isEmpty())) {
          mapGridSquares.add(mapGridSquare);
        }
      }
    }

    return mapGridSquares;
  }