mirror of
https://github.com/yairm210/Unciv.git
synced 2025-02-04 16:11:46 +07:00
Added "Vegetation" unique so that vegetation spawn is not limited to just jungle and forest (#6569)
This commit is contained in:
parent
aa6bd364de
commit
1069b0933e
@ -178,7 +178,7 @@
|
||||
"unbuildable": true,
|
||||
"defenceBonus": 0.25,
|
||||
"occursOn": ["Tundra","Plains","Grassland","Hill"],
|
||||
"uniques": ["Rough terrain",
|
||||
"uniques": ["Rough terrain", "Vegetation",
|
||||
"Provides a one-time Production bonus to the closest city when cut down",
|
||||
"Blocks line-of-sight from tiles at same elevation",
|
||||
"[25]% Chance to be destroyed by nukes",
|
||||
@ -202,7 +202,7 @@
|
||||
"defenceBonus": 0.25,
|
||||
"occursOn": ["Plains","Grassland"],
|
||||
"uniques": [
|
||||
"Rough terrain",
|
||||
"Rough terrain", "Vegetation",
|
||||
"Blocks line-of-sight from tiles at same elevation",
|
||||
"[25]% Chance to be destroyed by nukes",
|
||||
"[-1] to Fertility for Map Generation",
|
||||
|
@ -179,7 +179,7 @@
|
||||
"defenceBonus": 0.25,
|
||||
"occursOn": ["Tundra","Plains","Grassland","Hill"],
|
||||
"uniques": [
|
||||
"Rough terrain",
|
||||
"Rough terrain", "Vegetation",
|
||||
"Provides a one-time Production bonus to the closest city when cut down",
|
||||
"Blocks line-of-sight from tiles at same elevation",
|
||||
"[25]% Chance to be destroyed by nukes",
|
||||
@ -204,7 +204,7 @@
|
||||
"defenceBonus": 0.25,
|
||||
"occursOn": ["Plains","Grassland"],
|
||||
"uniques": [
|
||||
"Rough terrain",
|
||||
"Rough terrain", "Vegetation",
|
||||
"Blocks line-of-sight from tiles at same elevation",
|
||||
"[25]% Chance to be destroyed by nukes",
|
||||
"[-1] to Fertility for Map Generation",
|
||||
|
@ -509,15 +509,17 @@ class MapGenerator(val ruleset: Ruleset) {
|
||||
*/
|
||||
private fun spawnVegetation(tileMap: TileMap) {
|
||||
val vegetationSeed = randomness.RNG.nextInt().toDouble()
|
||||
val candidateTerrains = Constants.vegetation.mapNotNull { ruleset.terrains[it] }.flatMap{ it.occursOn }
|
||||
//Checking it.baseTerrain in candidateTerrains to make sure forest does not spawn on desert hill
|
||||
val vegetationTerrains = (Constants.vegetation.mapNotNull { ruleset.terrains[it] }
|
||||
+ ruleset.terrains.values.filter { it.hasUnique(UniqueType.Vegetation) }).toHashSet()
|
||||
val candidateTerrains = vegetationTerrains.flatMap{ it.occursOn }
|
||||
// Checking it.baseTerrain in candidateTerrains to make sure forest does not spawn on desert hill
|
||||
for (tile in tileMap.values.asSequence().filter { it.baseTerrain in candidateTerrains
|
||||
&& it.getLastTerrain().name in candidateTerrains }) {
|
||||
val vegetation = (randomness.getPerlinNoise(tile, vegetationSeed, scale = 3.0, nOctaves = 1) + 1.0) / 2.0
|
||||
|
||||
if (vegetation <= tileMap.mapParameters.vegetationRichness) {
|
||||
val randomVegetation = Constants.vegetation.filter { ruleset.terrains[it]!!.occursOn.contains(tile.getLastTerrain().name) }.random(randomness.RNG)
|
||||
tile.addTerrainFeature(randomVegetation)
|
||||
val randomVegetation = vegetationTerrains.filter { it.occursOn.contains(tile.getLastTerrain().name) }.random(randomness.RNG)
|
||||
tile.addTerrainFeature(randomVegetation.name)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -522,6 +522,8 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
TerrainGrantsPromotion("Grants [promotion] ([comment]) to adjacent [mapUnitFilter] units for the rest of the game", UniqueTarget.Terrain),
|
||||
GrantsCityStrength("[amount] Strength for cities built on this terrain", UniqueTarget.Terrain),
|
||||
ProductionBonusWhenRemoved("Provides a one-time Production bonus to the closest city when cut down", UniqueTarget.Terrain),
|
||||
Vegetation("Vegetation", UniqueTarget.Terrain, flags = UniqueFlag.setOfHiddenToUsers),
|
||||
|
||||
|
||||
TileProvidesYieldWithoutPopulation("Tile provides yield without assigned population", UniqueTarget.Terrain, UniqueTarget.Improvement),
|
||||
NullifyYields("Nullifies all other stats this tile provides", UniqueTarget.Terrain),
|
||||
|
@ -263,10 +263,10 @@ class BattleTable(val worldScreen: WorldScreen): Table() {
|
||||
}
|
||||
worldScreen.stage.addAction(Actions.sequence(
|
||||
object : FloatAction(0f, 1f, 0.3f, Interpolation.sine) {
|
||||
override fun update(percent: Float)=updateRedPercent(percent)
|
||||
override fun update(percent: Float) = updateRedPercent(percent)
|
||||
},
|
||||
object : FloatAction(0f, 1f, 0.3f, Interpolation.sine) {
|
||||
override fun update(percent: Float)=updateRedPercent(1-percent)
|
||||
override fun update(percent: Float) = updateRedPercent(1 - percent)
|
||||
}
|
||||
))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user