v2.3.0: code refactoring and improved enemy spawn spread in caves quest
This commit is contained in:
+2
-2
@@ -125,7 +125,7 @@ public abstract class RegularLevel extends Level {
|
|||||||
do {
|
do {
|
||||||
s = StandardRoom.createRoom();
|
s = StandardRoom.createRoom();
|
||||||
} while (!s.setSizeCat( standards-i ));
|
} while (!s.setSizeCat( standards-i ));
|
||||||
i += s.sizeCat.roomValue-1;
|
i += s.sizeFactor()-1;
|
||||||
initRooms.add(s);
|
initRooms.add(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -213,7 +213,7 @@ public abstract class RegularLevel extends Level {
|
|||||||
ArrayList<Room> stdRooms = new ArrayList<>();
|
ArrayList<Room> stdRooms = new ArrayList<>();
|
||||||
for (Room room : rooms) {
|
for (Room room : rooms) {
|
||||||
if (room instanceof StandardRoom && room != roomEntrance) {
|
if (room instanceof StandardRoom && room != roomEntrance) {
|
||||||
for (int i = 0; i < ((StandardRoom) room).sizeCat.roomValue; i++) {
|
for (int i = 0; i < ((StandardRoom) room).mobSpawnWeight(); i++) {
|
||||||
stdRooms.add(room);
|
stdRooms.add(room);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -123,7 +123,7 @@ public abstract class RegularBuilder extends Builder {
|
|||||||
while (roomsOnMainPath > 0 && !multiConnections.isEmpty()){
|
while (roomsOnMainPath > 0 && !multiConnections.isEmpty()){
|
||||||
Room r = multiConnections.remove(0);
|
Room r = multiConnections.remove(0);
|
||||||
if (r instanceof StandardRoom){
|
if (r instanceof StandardRoom){
|
||||||
roomsOnMainPath -= ((StandardRoom) r).sizeCat.roomValue;
|
roomsOnMainPath -= ((StandardRoom) r).sizeFactor();
|
||||||
} else {
|
} else {
|
||||||
roomsOnMainPath--;
|
roomsOnMainPath--;
|
||||||
}
|
}
|
||||||
@@ -136,7 +136,7 @@ public abstract class RegularBuilder extends Builder {
|
|||||||
protected void weightRooms(ArrayList<Room> rooms){
|
protected void weightRooms(ArrayList<Room> rooms){
|
||||||
for (Room r : rooms.toArray(new Room[0])){
|
for (Room r : rooms.toArray(new Room[0])){
|
||||||
if (r instanceof StandardRoom){
|
if (r instanceof StandardRoom){
|
||||||
for (int i = 1; i < ((StandardRoom) r).sizeCat.connectionWeight(); i++)
|
for (int i = 1; i < ((StandardRoom) r).connectionWeight(); i++)
|
||||||
rooms.add(r);
|
rooms.add(r);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -228,7 +228,7 @@ public abstract class RegularBuilder extends Builder {
|
|||||||
}
|
}
|
||||||
if (r.maxConnections(Room.ALL) > 1 && Random.Int(3) == 0) {
|
if (r.maxConnections(Room.ALL) > 1 && Random.Int(3) == 0) {
|
||||||
if (r instanceof StandardRoom){
|
if (r instanceof StandardRoom){
|
||||||
for (int j = 0; j < ((StandardRoom) r).sizeCat.connectionWeight(); j++){
|
for (int j = 0; j < ((StandardRoom) r).connectionWeight(); j++){
|
||||||
branchable.add(r);
|
branchable.add(r);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+7
@@ -47,6 +47,13 @@ public class MineGiantRoom extends CaveRoom {
|
|||||||
return 0.70f;
|
return 0.70f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int mobSpawnWeight() {
|
||||||
|
//This room contains the boss
|
||||||
|
// so don't amp up regular enemy spawns too
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Level level) {
|
public void paint(Level level) {
|
||||||
super.paint(level);
|
super.paint(level);
|
||||||
|
|||||||
+7
@@ -61,6 +61,13 @@ public class MineLargeRoom extends CaveRoom {
|
|||||||
return 0.55f;
|
return 0.55f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int mobSpawnWeight() {
|
||||||
|
//These rooms always spawn their own enemies
|
||||||
|
// so don't amp up regular enemy spawns too
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void paint(Level level) {
|
public void paint(Level level) {
|
||||||
super.paint(level);
|
super.paint(level);
|
||||||
|
|||||||
+2
-2
@@ -87,7 +87,7 @@ public class CavesFissureRoom extends StandardRoom {
|
|||||||
|
|
||||||
//generate angles for 2-4 fissure lines, they can't be too close to doors or eachother
|
//generate angles for 2-4 fissure lines, they can't be too close to doors or eachother
|
||||||
ArrayList<Float> lineAngles = new ArrayList<>();
|
ArrayList<Float> lineAngles = new ArrayList<>();
|
||||||
int numLines = 1 + sizeCat.roomValue;
|
int numLines = 1 + sizeFactor();
|
||||||
for (int i = 0; i < numLines; i++) {
|
for (int i = 0; i < numLines; i++) {
|
||||||
int tries = 100;
|
int tries = 100;
|
||||||
boolean valid;
|
boolean valid;
|
||||||
@@ -190,7 +190,7 @@ public class CavesFissureRoom extends StandardRoom {
|
|||||||
buildBridge(level, Random.element(lineAngles), center, 1);
|
buildBridge(level, Random.element(lineAngles), center, 1);
|
||||||
} else {
|
} else {
|
||||||
for (float angle : lineAngles) {
|
for (float angle : lineAngles) {
|
||||||
buildBridge(level, angle, center, sizeCat.roomValue);
|
buildBridge(level, angle, center, sizeFactor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+14
-4
@@ -48,10 +48,6 @@ public abstract class StandardRoom extends Room {
|
|||||||
roomValue = val;
|
roomValue = val;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int connectionWeight(){
|
|
||||||
return roomValue*roomValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public SizeCategory sizeCat;
|
public SizeCategory sizeCat;
|
||||||
@@ -101,6 +97,20 @@ public abstract class StandardRoom extends Room {
|
|||||||
public int minHeight() { return sizeCat.minDim; }
|
public int minHeight() { return sizeCat.minDim; }
|
||||||
public int maxHeight() { return sizeCat.maxDim; }
|
public int maxHeight() { return sizeCat.maxDim; }
|
||||||
|
|
||||||
|
//larger standard rooms generally count as multiple rooms for various counting/weighting purposes
|
||||||
|
//but there can be exceptions
|
||||||
|
public int sizeFactor(){
|
||||||
|
return sizeCat.roomValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int mobSpawnWeight(){
|
||||||
|
return sizeFactor();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int connectionWeight(){
|
||||||
|
return sizeFactor() * sizeFactor();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
public boolean canMerge(Level l, Point p, int mergeTerrain) {
|
||||||
int cell = l.pointToCell(pointInside(p, 1));
|
int cell = l.pointToCell(pointInside(p, 1));
|
||||||
|
|||||||
Reference in New Issue
Block a user