Point pos = centerBlock.getPosition();
if ((pos != null) && (coordOnMap(pos))) {
// check if center block is loaded
if (centerBlock.getTiles() == null) {
MapBlock mapBlock = mapReader.read(pos.x, pos.y);
DrawableBlock tmp = convertToDrawableBlock(mapBlock);
centerBlock.setTiles(tmp.getTiles());
}
// load neighbors if required
for (NeighborDirection direction : NeighborDirection.values()) {
Point newPos = getNeighborPosition(pos, direction);
DrawableBlock neighbor = loadedBlocks.get(newPos);
if (neighbor == null) {
if (coordOnMap(newPos)) {
MapBlock mapBlock = mapReader.read(newPos.x, newPos.y);
neighbor = convertToDrawableBlock(mapBlock);
neighbor.setPosition(newPos);
loadedBlocks.put(newPos, neighbor);
}
}
nextBlocks.add(neighbor);
}