More terrainFeature refactors (#3694)

This commit is contained in:
GGGuenni 2021-03-13 22:38:11 +01:00 committed by GitHub
parent 20f5672337
commit 57f6c99d86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 11 additions and 12 deletions

View File

@ -332,8 +332,8 @@ class GameInfo {
// So we remove them so the game doesn't crash when it tries to access them.
private fun removeMissingModReferences() {
for (tile in tileMap.values) {
if (tile.terrainFeature != null && !ruleSet.terrains.containsKey(tile.terrainFeature!!))
tile.terrainFeature = null
for (terrainFeature in tile.terrainFeatures.filter{ !ruleSet.terrains.containsKey(it) })
tile.terrainFeatures.remove(terrainFeature)
if (tile.resource != null && !ruleSet.tileResources.containsKey(tile.resource!!))
tile.resource = null
if (tile.improvement != null && !ruleSet.tileImprovements.containsKey(tile.improvement!!)

View File

@ -404,7 +404,7 @@ object Battle {
tile.improvementInProgress = null
tile.turnsToImprovement = 0
tile.roadStatus = RoadStatus.None
if (tile.isLand && !tile.isImpassible()) tile.terrainFeature = "Fallout"
if (tile.isLand && !tile.isImpassible()) tile.terrainFeatures.contains("Fallout")
}
for (civ in attacker.getCivInfo().getKnownCivs()) {

View File

@ -116,8 +116,8 @@ class CityInfo {
tryUpdateRoadStatus()
val tile = getCenterTile()
if (getRuleset().tileImprovements.containsKey("Remove " + tile.terrainFeature))
tile.terrainFeature = null
for (terrainFeature in tile.terrainFeatures.filter { getRuleset().tileImprovements.containsKey("Remove $it") })
tile.terrainFeatures.remove(terrainFeature)
tile.improvement = null
tile.improvementInProgress = null

View File

@ -60,7 +60,7 @@ class CivInfoStats(val civInfo: CivilizationInfo) {
if (tile.isCityCenter()) continue
if (ignoreHillTiles && tile.isHill()) continue
if (tile.terrainFeature in ignoredTileTypes || tile.baseTerrain in ignoredTileTypes) {
if (tile.terrainFeatures.any { it in ignoredTileTypes } || tile.baseTerrain in ignoredTileTypes) {
continue
}

View File

@ -260,7 +260,7 @@ class MapGenerator(val ruleset: Ruleset) {
val vegetation = (randomness.getPerlinNoise(tile, vegetationSeed, scale = 3.0, nOctaves = 1) + 1.0) / 2.0
if (vegetation <= tileMap.mapParameters.vegetationRichness)
tile.terrainFeature = Constants.vegetation.filter { ruleset.terrains[it]!!.occursOn.contains(tile.baseTerrain) }.random(randomness.RNG)
tile.terrainFeatures.add(Constants.vegetation.filter { ruleset.terrains[it]!!.occursOn.contains(tile.baseTerrain) }.random(randomness.RNG))
}
}
/**
@ -275,7 +275,7 @@ class MapGenerator(val ruleset: Ruleset) {
val possibleFeatures = rareFeatures.filter { it.occursOn.contains(tile.baseTerrain)
&& (!tile.isHill() || it.occursOn.contains(Constants.hill)) }
if (possibleFeatures.any())
tile.terrainFeature = possibleFeatures.random(randomness.RNG).name
tile.terrainFeatures.add(possibleFeatures.random(randomness.RNG).name)
}
}
}

View File

@ -22,7 +22,7 @@ class RiverGenerator(val randomness: MapGenerationRandomness){
for(tile in map.values){
if(tile.isAdjacentToRiver()){
if(tile.baseTerrain== Constants.desert && !tile.isHill()) tile.terrainFeature= Constants.floodPlains
if(tile.baseTerrain== Constants.desert && !tile.isHill()) tile.terrainFeatures.add(Constants.floodPlains)
else if(tile.baseTerrain== Constants.snow) tile.baseTerrain = Constants.tundra
else if(tile.baseTerrain== Constants.tundra) tile.baseTerrain = Constants.plains
tile.setTerrainTransients()

View File

@ -367,9 +367,8 @@ object UnitActions {
uncivSound = UncivSound.Chimes,
action = {
val unitTile = unit.getTile()
if (unitTile.terrainFeature != null &&
unitTile.ruleset.tileImprovements.containsKey("Remove " + unitTile.terrainFeature))
unitTile.terrainFeature = null // remove forest/jungle/marsh
for (terrainFeature in tile.terrainFeatures.filter{ unitTile.ruleset.tileImprovements.containsKey("Remove $it") })
unitTile.terrainFeatures.remove(terrainFeature)// remove forest/jungle/marsh
unitTile.improvement = improvementName
unitTile.improvementInProgress = null
unitTile.turnsToImprovement = 0