mirror of
https://github.com/yairm210/Unciv.git
synced 2025-10-04 09:26:16 -04:00
Resolved #3686 - world wrapped 'continents' map now separates continents properly
This commit is contained in:
parent
aab037b409
commit
20f5672337
@ -89,8 +89,16 @@ class MapLandmassGenerator(val randomness: MapGenerationRandomness) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun getTwoContinentsTransform(tileInfo: TileInfo, tileMap: TileMap): Double {
|
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 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)
|
return min(0.2, -1.0 + (5.0 * longitudeFactor.pow(0.6f) + randomScale) / 3.0)
|
||||||
}
|
}
|
||||||
|
@ -50,27 +50,26 @@ class RiverGenerator(val randomness: MapGenerationRandomness){
|
|||||||
RiverCoordinate.BottomRightOrLeft.values().random(randomness.RNG))
|
RiverCoordinate.BottomRightOrLeft.values().random(randomness.RNG))
|
||||||
|
|
||||||
|
|
||||||
while(getAdjacentTiles(riverCoordinate, map).none { it.isWater }){
|
while(getAdjacentTiles(riverCoordinate, map).none { it.isWater }) {
|
||||||
val possibleCoordinates = riverCoordinate.getAdjacentPositions()
|
val possibleCoordinates = riverCoordinate.getAdjacentPositions()
|
||||||
.filter { map.contains(it.position) }
|
.filter { map.contains(it.position) }
|
||||||
if(possibleCoordinates.none()) return // end of the line
|
if (possibleCoordinates.none()) return // end of the line
|
||||||
val newCoordinate = possibleCoordinates
|
val newCoordinate = possibleCoordinates
|
||||||
.groupBy { getAdjacentTiles(it,map).map { it.aerialDistanceTo(endPosition) }.min()!! }
|
.groupBy { getAdjacentTiles(it, map).map { it.aerialDistanceTo(endPosition) }.min()!! }
|
||||||
.minBy { it.key }!!
|
.minBy { it.key }!!
|
||||||
.component2().random(randomness.RNG)
|
.component2().random(randomness.RNG)
|
||||||
|
|
||||||
// set new rivers in place
|
// set new rivers in place
|
||||||
val riverCoordinateTile = map[riverCoordinate.position]
|
val riverCoordinateTile = map[riverCoordinate.position]
|
||||||
if(newCoordinate.position == riverCoordinate.position) // same tile, switched right-to-left
|
if (newCoordinate.position == riverCoordinate.position) // same tile, switched right-to-left
|
||||||
riverCoordinateTile.hasBottomRiver=true
|
riverCoordinateTile.hasBottomRiver = true
|
||||||
else if(riverCoordinate.bottomRightOrLeft== RiverCoordinate.BottomRightOrLeft.BottomRight){
|
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 (getAdjacentTiles(newCoordinate, map).contains(riverCoordinateTile)) // moved from our 5 O'Clock to our 3 O'Clock
|
||||||
riverCoordinateTile.hasBottomRightRiver = true
|
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!
|
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
|
map[newCoordinate.position].hasBottomLeftRiver = true
|
||||||
}
|
} else { // riverCoordinate.bottomRightOrLeft==RiverCoordinate.BottomRightOrLeft.Left
|
||||||
else { // riverCoordinate.bottomRightOrLeft==RiverCoordinate.BottomRightOrLeft.Left
|
if (getAdjacentTiles(newCoordinate, map).contains(riverCoordinateTile)) // moved from our 7 O'Clock to our 9 O'Clock
|
||||||
if(getAdjacentTiles(newCoordinate,map).contains(riverCoordinateTile)) // moved from our 7 O'Clock to our 9 O'Clock
|
|
||||||
riverCoordinateTile.hasBottomLeftRiver = true
|
riverCoordinateTile.hasBottomLeftRiver = true
|
||||||
else // moved from our 7 O'Clock down in the 7 O'Clock direction
|
else // moved from our 7 O'Clock down in the 7 O'Clock direction
|
||||||
map[newCoordinate.position].hasBottomRightRiver = true
|
map[newCoordinate.position].hasBottomRightRiver = true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user