Replaced the List with MutableList to avoid creating new ones on adding/removing values (#2746)
This commit is contained in:
parent
835c0832e2
commit
e18bfa0053
2 changed files with 4 additions and 4 deletions
|
@ -59,7 +59,7 @@ class MapGenerator(val ruleset: Ruleset) {
|
|||
private fun spawnLakesAndCoasts(map: TileMap) {
|
||||
|
||||
//define lakes
|
||||
var waterTiles = map.values.filter { it.isWater }
|
||||
val waterTiles = map.values.filter { it.isWater }.toMutableList()
|
||||
|
||||
val tilesInArea = ArrayList<TileInfo>()
|
||||
val tilesToCheck = ArrayList<TileInfo>()
|
||||
|
|
|
@ -10,11 +10,11 @@ class RiverGenerator(val randomness: MapGenerationRandomness){
|
|||
val numberOfRivers = map.values.count { it.isLand } / 100
|
||||
|
||||
var optionalTiles = map.values
|
||||
.filter { it.baseTerrain== Constants.mountain && it.aerialDistanceTo(getClosestWaterTile(it)) > 4 }
|
||||
.filter { it.baseTerrain== Constants.mountain && it.aerialDistanceTo(getClosestWaterTile(it)) > 4 }.toMutableList()
|
||||
if(optionalTiles.size < numberOfRivers)
|
||||
optionalTiles += map.values.filter { it.baseTerrain== Constants.hill && it.aerialDistanceTo(getClosestWaterTile(it)) > 4 }
|
||||
optionalTiles.addAll(map.values.filter { it.baseTerrain== Constants.hill && it.aerialDistanceTo(getClosestWaterTile(it)) > 4 })
|
||||
if(optionalTiles.size < numberOfRivers)
|
||||
optionalTiles = map.values.filter { it.isLand && it.aerialDistanceTo(getClosestWaterTile(it)) > 4 }
|
||||
optionalTiles = map.values.filter { it.isLand && it.aerialDistanceTo(getClosestWaterTile(it)) > 4 }.toMutableList()
|
||||
|
||||
|
||||
val riverStarts = randomness.chooseSpreadOutLocations(numberOfRivers, optionalTiles, 10)
|
||||
|
|
Loading…
Reference in a new issue