mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-26 23:58:43 +07:00
When generating map, we no longer get terrain areas that have only 1 or 2 tiles
This commit is contained in:
@ -43,8 +43,10 @@ class SeedRandomMapGenerator : RandomMapGenerator() {
|
||||
areas += area
|
||||
}
|
||||
|
||||
val expandableAreas = ArrayList<Area>(areas)
|
||||
|
||||
|
||||
fun expandAreas(){
|
||||
val expandableAreas = ArrayList<Area>(areas)
|
||||
while (expandableAreas.isNotEmpty()){
|
||||
val areaToExpand = expandableAreas.getRandom()
|
||||
val availableExpansionVectors = areaToExpand.locations.flatMap { HexMath.GetAdjacentVectors(it) }.distinct()
|
||||
@ -55,6 +57,19 @@ class SeedRandomMapGenerator : RandomMapGenerator() {
|
||||
map[expansionVector] = areaToExpand.addTile(expansionVector)
|
||||
}
|
||||
}
|
||||
}
|
||||
expandAreas()
|
||||
|
||||
// After we've assigned all the tiles, there will be some areas that contain only 1 or 2 tiles.
|
||||
// So, we kill those areas, and have the world expand on and cover them too.
|
||||
for(area in areas.toList()){
|
||||
if(area.locations.size<3){
|
||||
areas -= area
|
||||
for(location in area.locations) map[location] = null
|
||||
}
|
||||
}
|
||||
|
||||
expandAreas()
|
||||
|
||||
val mapToReturn = HashMap<String,TileInfo>()
|
||||
for (entry in map){
|
||||
|
Reference in New Issue
Block a user