Resolved #3686 - world wrapped 'continents' map now separates continents properly

This commit is contained in:
Yair Morgenstern 2021-03-13 23:02:57 +02:00
parent aab037b409
commit 20f5672337
2 changed files with 18 additions and 11 deletions

View File

@ -89,8 +89,16 @@ class MapLandmassGenerator(val randomness: MapGenerationRandomness) {
}
private fun getTwoContinentsTransform(tileInfo: TileInfo, tileMap: TileMap): Double {
// The idea here is to create a water area separating the two land areas.
// So what we do it create a line of water in the middle - where longitude is close to 0.
val randomScale = randomness.RNG.nextDouble()
val longitudeFactor = abs(tileInfo.longitude) / tileMap.maxLongitude
var longitudeFactor = abs(tileInfo.longitude) / tileMap.maxLongitude
// If this is a world wrap, we want it to be separated on both sides -
// so we make the actual strip of water thinner, but we put it both in the middle of the map and on the edges of the map
if (tileMap.mapParameters.worldWrap)
longitudeFactor = min(longitudeFactor,
(tileMap.maxLongitude - abs(tileInfo.longitude)) / tileMap.maxLongitude) * 1.5f
return min(0.2, -1.0 + (5.0 * longitudeFactor.pow(0.6f) + randomScale) / 3.0)
}

View File

@ -50,27 +50,26 @@ class RiverGenerator(val randomness: MapGenerationRandomness){
RiverCoordinate.BottomRightOrLeft.values().random(randomness.RNG))
while(getAdjacentTiles(riverCoordinate, map).none { it.isWater }){
while(getAdjacentTiles(riverCoordinate, map).none { it.isWater }) {
val possibleCoordinates = riverCoordinate.getAdjacentPositions()
.filter { map.contains(it.position) }
if(possibleCoordinates.none()) return // end of the line
if (possibleCoordinates.none()) return // end of the line
val newCoordinate = possibleCoordinates
.groupBy { getAdjacentTiles(it,map).map { it.aerialDistanceTo(endPosition) }.min()!! }
.groupBy { getAdjacentTiles(it, map).map { it.aerialDistanceTo(endPosition) }.min()!! }
.minBy { it.key }!!
.component2().random(randomness.RNG)
// set new rivers in place
val riverCoordinateTile = map[riverCoordinate.position]
if(newCoordinate.position == riverCoordinate.position) // same tile, switched right-to-left
riverCoordinateTile.hasBottomRiver=true
else if(riverCoordinate.bottomRightOrLeft== RiverCoordinate.BottomRightOrLeft.BottomRight){
if(getAdjacentTiles(newCoordinate,map).contains(riverCoordinateTile)) // moved from our 5 O'Clock to our 3 O'Clock
if (newCoordinate.position == riverCoordinate.position) // same tile, switched right-to-left
riverCoordinateTile.hasBottomRiver = true
else if (riverCoordinate.bottomRightOrLeft == RiverCoordinate.BottomRightOrLeft.BottomRight) {
if (getAdjacentTiles(newCoordinate, map).contains(riverCoordinateTile)) // moved from our 5 O'Clock to our 3 O'Clock
riverCoordinateTile.hasBottomRightRiver = true
else // moved from our 5 O'Clock down in the 5 O'Clock direction - this is the 8 O'Clock river of the tile to our 4 O'Clock!
map[newCoordinate.position].hasBottomLeftRiver = true
}
else { // riverCoordinate.bottomRightOrLeft==RiverCoordinate.BottomRightOrLeft.Left
if(getAdjacentTiles(newCoordinate,map).contains(riverCoordinateTile)) // moved from our 7 O'Clock to our 9 O'Clock
} else { // riverCoordinate.bottomRightOrLeft==RiverCoordinate.BottomRightOrLeft.Left
if (getAdjacentTiles(newCoordinate, map).contains(riverCoordinateTile)) // moved from our 7 O'Clock to our 9 O'Clock
riverCoordinateTile.hasBottomLeftRiver = true
else // moved from our 7 O'Clock down in the 7 O'Clock direction
map[newCoordinate.position].hasBottomRightRiver = true