private void connectRooms() { List<ClassicRogueRoom> unconnected = new ArrayList<>(); for (int x = 0; x < horizontalRooms; x++) { for (int y = 0; y < verticalRooms; y++) { unconnected.add(rooms[x][y]); } } unconnected = rng.shuffle(unconnected); Direction[] dirToCheck = new Direction[4]; for (ClassicRogueRoom room : unconnected) { rng.shuffle(Direction.CARDINALS, dirToCheck); for (Direction dir : dirToCheck) { int nextX = room.x + dir.deltaX; int nextY = room.y + dir.deltaY; if (nextX < 0 || nextX >= horizontalRooms || nextY < 0 || nextY >= verticalRooms) { continue; } ClassicRogueRoom otherRoom = rooms[nextX][nextY]; if (room.connections.contains(otherRoom)) { break;//already connected to this room } if (!otherRoom.connections.isEmpty()) { room.connections.add(otherRoom); break; } } } }
for (short i = 0; i < spillers.size() && filled < volume; i++) { currentFresh = fresh.get(i); if(currentFresh.isEmpty()) continue; else
ClassicRogueRoom room = rooms[x][y]; if (room.connections.isEmpty()) { rng.shuffle(Direction.CARDINALS, dirToCheck);
while (!fresh.isEmpty() && spreadPattern.size() < volume) {
for (short i = 0; i < spillers.size() && filled < volume; i++) { OrderedSet<Coord> currentFresh = fresh.get(i); if(currentFresh.isEmpty()) continue; else
above.remove(abv); if(above.isEmpty()) break;
if(chokes.isEmpty()) break; dm.clearGoals();
/** * Takes an x, y position and finds the room, corridor, or cave at that position, if there is one, returning the * same 2D char array format as the other methods. * @param x the x coordinate of a position that should be in a room or corridor * @param y the y coordinate of a position that should be in a room or corridor * @return a masked 2D char array where anything not in the current region is '#' */ public char[][] regionAt(int x, int y) { OrderedSet<GreasedRegion> regions = GreasedRegion.whichContain(x, y, rooms.keySet()); regions.addAll(GreasedRegion.whichContain(x, y, corridors.keySet())); regions.addAll(GreasedRegion.whichContain(x, y, caves.keySet())); GreasedRegion found; if(regions.isEmpty()) found = new GreasedRegion(width, height); else found = regions.first(); return found.mask(map, '#'); }
if(chokes.isEmpty()) break; dm.clearGoals();
if(chokes.isEmpty()) break; dm.clearGoals();
if(chokes.isEmpty()) break; dm.clearGoals();
regions.addAll(atCaves); GreasedRegion found; if(regions.isEmpty()) found = new GreasedRegion(width, height); else