use of com.shatteredpixel.shatteredpixeldungeon.levels.rooms.secret.SecretRoom in project shattered-pixel-dungeon-gdx by 00-Evan.
the class RegularBuilder method createBranches.
// places the rooms in roomsToBranch into branches from rooms in branchable.
// note that the three arrays should be separate, they may contain the same rooms however
protected void createBranches(ArrayList<Room> rooms, ArrayList<Room> branchable, ArrayList<Room> roomsToBranch, float[] connChances) {
int i = 0;
float angle;
int tries;
Room curr;
ArrayList<Room> connectingRoomsThisBranch = new ArrayList<>();
float[] connectionChances = connChances.clone();
while (i < roomsToBranch.size()) {
Room r = roomsToBranch.get(i);
connectingRoomsThisBranch.clear();
do {
curr = Random.element(branchable);
} while (r instanceof SecretRoom && curr instanceof ConnectionRoom);
int connectingRooms = Random.chances(connectionChances);
if (connectingRooms == -1) {
connectionChances = connChances.clone();
connectingRooms = Random.chances(connectionChances);
}
connectionChances[connectingRooms]--;
for (int j = 0; j < connectingRooms; j++) {
ConnectionRoom t = r instanceof SecretRoom ? new MazeConnectionRoom() : ConnectionRoom.createRoom();
tries = 3;
do {
angle = placeRoom(rooms, curr, t, randomBranchAngle(curr));
tries--;
} while (angle == -1 && tries > 0);
if (angle == -1) {
for (Room c : connectingRoomsThisBranch) {
c.clearConnections();
rooms.remove(c);
}
connectingRoomsThisBranch.clear();
break;
} else {
connectingRoomsThisBranch.add(t);
rooms.add(t);
}
curr = t;
}
if (connectingRoomsThisBranch.size() != connectingRooms) {
continue;
}
tries = 10;
do {
angle = placeRoom(rooms, curr, r, randomBranchAngle(curr));
tries--;
} while (angle == -1 && tries > 0);
if (angle == -1) {
for (Room t : connectingRoomsThisBranch) {
t.clearConnections();
rooms.remove(t);
}
connectingRoomsThisBranch.clear();
continue;
}
for (int j = 0; j < connectingRoomsThisBranch.size(); j++) {
if (Random.Int(3) <= 1)
branchable.add(connectingRoomsThisBranch.get(j));
}
if (r.maxConnections(Room.ALL) > 1 && Random.Int(3) == 0) {
if (r instanceof StandardRoom) {
for (int j = 0; j < ((StandardRoom) r).sizeCat.connectionWeight(); j++) {
branchable.add(r);
}
} else {
branchable.add(r);
}
}
i++;
}
}
Aggregations