mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 06:16:37 -04:00
Split 6 tiles visible unique into its parts, making it more moddable (#6389)
* Split sight unique into its parts, making it more moddable * Standardized unique ordering
This commit is contained in:
parent
3374bb15d5
commit
1df49749f2
@ -59,7 +59,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Fighter",
|
"name": "Fighter",
|
||||||
"movementType": "Air",
|
"movementType": "Air",
|
||||||
"uniques": ["Aircraft", "6 tiles in every direction always visible"]
|
"uniques": ["Aircraft", "[+4] Sight", "Can see over obstacles"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Bomber",
|
"name": "Bomber",
|
||||||
|
@ -1589,7 +1589,7 @@
|
|||||||
"cost": 425,
|
"cost": 425,
|
||||||
"requiredTech": "Stealth",
|
"requiredTech": "Stealth",
|
||||||
"requiredResource": "Aluminum",
|
"requiredResource": "Aluminum",
|
||||||
"uniques": ["Damage taken from interception reduced by [100]%", "Cannot be carried by [Carrier] units", "6 tiles in every direction always visible"],
|
"uniques": ["Damage taken from interception reduced by [100]%", "Cannot be carried by [Carrier] units", "[+4] Sight", "Can see over obstacles"],
|
||||||
"attackSound": "bombing"
|
"attackSound": "bombing"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@
|
|||||||
{
|
{
|
||||||
"name": "Fighter",
|
"name": "Fighter",
|
||||||
"movementType": "Air",
|
"movementType": "Air",
|
||||||
"uniques": ["Aircraft", "6 tiles in every direction always visible"]
|
"uniques": ["Aircraft", "[+4] Sight", "Can see over obstacles"]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Bomber",
|
"name": "Bomber",
|
||||||
|
@ -1265,7 +1265,7 @@
|
|||||||
"cost": 425,
|
"cost": 425,
|
||||||
"requiredTech": "Stealth",
|
"requiredTech": "Stealth",
|
||||||
"requiredResource": "Aluminum",
|
"requiredResource": "Aluminum",
|
||||||
"uniques": ["Damage taken from interception reduced by [100]%", "Cannot be carried by [Carrier] units", "6 tiles in every direction always visible"],
|
"uniques": ["Damage taken from interception reduced by [100]%", "Cannot be carried by [Carrier] units", "[+4] Sight", "Can see over obstacles"],
|
||||||
"attackSound": "bombing"
|
"attackSound": "bombing"
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -376,16 +376,14 @@ class MapUnit {
|
|||||||
|
|
||||||
val conditionalState = StateForConditionals(civInfo = civInfo, unit = this)
|
val conditionalState = StateForConditionals(civInfo = civInfo, unit = this)
|
||||||
|
|
||||||
if (isEmbarked() && !hasUnique(UniqueType.NormalVisionWhenEmbarked, conditionalState)
|
if (isEmbarked() && !hasUnique(UniqueType.NormalVisionWhenEmbarked, conditionalState, checkCivInfoUniques = true)) {
|
||||||
&& !civInfo.hasUnique(UniqueType.NormalVisionWhenEmbarked, conditionalState)) {
|
|
||||||
return 1
|
return 1
|
||||||
}
|
}
|
||||||
|
|
||||||
visibilityRange += getMatchingUniques(UniqueType.Sight, conditionalState, checkCivInfoUniques = true)
|
visibilityRange += getMatchingUniques(UniqueType.Sight, conditionalState, checkCivInfoUniques = true)
|
||||||
.sumOf { it.params[0].toInt() }
|
.sumOf { it.params[0].toInt() }
|
||||||
|
|
||||||
visibilityRange += getTile().getAllTerrains()
|
visibilityRange += getTile().getMatchingUniques(UniqueType.Sight, conditionalState)
|
||||||
.flatMap { it.getMatchingUniques(UniqueType.Sight, conditionalState) }
|
|
||||||
.sumOf { it.params[0].toInt() }
|
.sumOf { it.params[0].toInt() }
|
||||||
|
|
||||||
if (visibilityRange < 1) visibilityRange = 1
|
if (visibilityRange < 1) visibilityRange = 1
|
||||||
@ -399,13 +397,13 @@ class MapUnit {
|
|||||||
fun updateVisibleTiles(updateCivViewableTiles:Boolean = true) {
|
fun updateVisibleTiles(updateCivViewableTiles:Boolean = true) {
|
||||||
val oldViewableTiles = viewableTiles
|
val oldViewableTiles = viewableTiles
|
||||||
|
|
||||||
if (baseUnit.isAirUnit()) {
|
viewableTiles = when {
|
||||||
viewableTiles = if (hasUnique(UniqueType.SixTilesAlwaysVisible))
|
hasUnique(UniqueType.NoSight) -> hashSetOf()
|
||||||
getTile().getTilesInDistance(6).toHashSet() // it's that simple
|
hasUnique(UniqueType.CanSeeOverObstacles) ->
|
||||||
else HashSet(0) // bomber units don't do recon
|
getTile().getTilesInDistance(getVisibilityRange()).toHashSet() // it's that simple
|
||||||
} else {
|
else -> getTile().getViewableTilesList(getVisibilityRange()).toHashSet()
|
||||||
viewableTiles = getTile().getViewableTilesList(getVisibilityRange()).toHashSet()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set equality automatically determines if anything changed - https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-abstract-set/equals.html
|
// Set equality automatically determines if anything changed - https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-abstract-set/equals.html
|
||||||
if (updateCivViewableTiles && oldViewableTiles != viewableTiles)
|
if (updateCivViewableTiles && oldViewableTiles != viewableTiles)
|
||||||
civInfo.updateViewableTiles() // for the civ
|
civInfo.updateViewableTiles() // for the civ
|
||||||
|
@ -11,6 +11,7 @@ import com.unciv.models.ruleset.Ruleset
|
|||||||
import com.unciv.models.ruleset.unique.UniqueType
|
import com.unciv.models.ruleset.unique.UniqueType
|
||||||
import com.unciv.models.ruleset.tile.*
|
import com.unciv.models.ruleset.tile.*
|
||||||
import com.unciv.models.ruleset.unique.StateForConditionals
|
import com.unciv.models.ruleset.unique.StateForConditionals
|
||||||
|
import com.unciv.models.ruleset.unique.Unique
|
||||||
import com.unciv.models.stats.Stats
|
import com.unciv.models.stats.Stats
|
||||||
import com.unciv.models.translations.tr
|
import com.unciv.models.translations.tr
|
||||||
import com.unciv.ui.civilopedia.FormattedLine
|
import com.unciv.ui.civilopedia.FormattedLine
|
||||||
@ -242,6 +243,9 @@ open class TileInfo {
|
|||||||
fun isRoughTerrain() = getAllTerrains().any{ it.isRough() }
|
fun isRoughTerrain() = getAllTerrains().any{ it.isRough() }
|
||||||
|
|
||||||
fun hasUnique(uniqueType: UniqueType) = getAllTerrains().any { it.hasUnique(uniqueType) }
|
fun hasUnique(uniqueType: UniqueType) = getAllTerrains().any { it.hasUnique(uniqueType) }
|
||||||
|
fun getMatchingUniques(uniqueType: UniqueType, stateForConditionals: StateForConditionals = StateForConditionals(tile=this) ): Sequence<Unique> {
|
||||||
|
return getAllTerrains().flatMap { it.getMatchingUniques(uniqueType, stateForConditionals) }
|
||||||
|
}
|
||||||
|
|
||||||
fun getWorkingCity(): CityInfo? {
|
fun getWorkingCity(): CityInfo? {
|
||||||
val civInfo = getOwner() ?: return null
|
val civInfo = getOwner() ?: return null
|
||||||
|
@ -436,6 +436,9 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
|||||||
AttackFromSea("Eliminates combat penalty for attacking from the sea", UniqueTarget.Unit),
|
AttackFromSea("Eliminates combat penalty for attacking from the sea", UniqueTarget.Unit),
|
||||||
AttackAcrossCoast("Eliminates combat penalty for attacking across a coast", UniqueTarget.Unit),
|
AttackAcrossCoast("Eliminates combat penalty for attacking across a coast", UniqueTarget.Unit),
|
||||||
|
|
||||||
|
NoSight("No Sight", UniqueTarget.Unit),
|
||||||
|
CanSeeOverObstacles("Can see over obstacles", UniqueTarget.Unit),
|
||||||
|
@Deprecated("as of 3.19.19", ReplaceWith("[+4] Sight\", \"Can see over obstacles"))
|
||||||
SixTilesAlwaysVisible("6 tiles in every direction always visible", UniqueTarget.Unit),
|
SixTilesAlwaysVisible("6 tiles in every direction always visible", UniqueTarget.Unit),
|
||||||
|
|
||||||
CarryAirUnits("Can carry [amount] [mapUnitFilter] units", UniqueTarget.Unit),
|
CarryAirUnits("Can carry [amount] [mapUnitFilter] units", UniqueTarget.Unit),
|
||||||
|
@ -377,14 +377,16 @@ class OptionsPopup(val previousScreen: BaseScreen) : Popup(previousScreen) {
|
|||||||
private fun getDeprecatedReplaceableUniques(mod:Ruleset): HashMap<String, String> {
|
private fun getDeprecatedReplaceableUniques(mod:Ruleset): HashMap<String, String> {
|
||||||
|
|
||||||
val objectsToCheck = sequenceOf(
|
val objectsToCheck = sequenceOf(
|
||||||
mod.units,
|
mod.beliefs,
|
||||||
|
mod.buildings,
|
||||||
|
mod.nations,
|
||||||
|
mod.policies,
|
||||||
|
mod.technologies,
|
||||||
|
mod.terrains,
|
||||||
mod.tileImprovements,
|
mod.tileImprovements,
|
||||||
mod.unitPromotions,
|
mod.unitPromotions,
|
||||||
mod.buildings,
|
mod.unitTypes,
|
||||||
mod.policies,
|
mod.units,
|
||||||
mod.nations,
|
|
||||||
mod.beliefs,
|
|
||||||
mod.technologies,
|
|
||||||
)
|
)
|
||||||
val allDeprecatedUniques = HashSet<String>()
|
val allDeprecatedUniques = HashSet<String>()
|
||||||
val deprecatedUniquesToReplacementText = HashMap<String, String>()
|
val deprecatedUniquesToReplacementText = HashMap<String, String>()
|
||||||
@ -442,15 +444,20 @@ class OptionsPopup(val previousScreen: BaseScreen) : Popup(previousScreen) {
|
|||||||
|
|
||||||
private fun autoUpdateUniques(mod: Ruleset, replaceableUniques: HashMap<String, String>, ) {
|
private fun autoUpdateUniques(mod: Ruleset, replaceableUniques: HashMap<String, String>, ) {
|
||||||
|
|
||||||
|
if (mod.name.contains("mod"))
|
||||||
|
println("mod")
|
||||||
|
|
||||||
val filesToReplace = listOf(
|
val filesToReplace = listOf(
|
||||||
"Units.json",
|
"Beliefs.json",
|
||||||
|
"Buildings.json",
|
||||||
|
"Nations.json",
|
||||||
|
"Policies.json",
|
||||||
|
"Techs.json",
|
||||||
|
"Terrains.json",
|
||||||
"TileImprovements.json",
|
"TileImprovements.json",
|
||||||
"UnitPromotions.json",
|
"UnitPromotions.json",
|
||||||
"Buildings.json",
|
"UnitTypes.json",
|
||||||
"Policies.json",
|
"Units.json",
|
||||||
"Nations.json",
|
|
||||||
"Beliefs.json",
|
|
||||||
"Techs.json",
|
|
||||||
)
|
)
|
||||||
|
|
||||||
val jsonFolder = mod.folderLocation!!.child("jsons")
|
val jsonFolder = mod.folderLocation!!.child("jsons")
|
||||||
|
@ -1017,7 +1017,10 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
|
|||||||
??? example "Eliminates combat penalty for attacking across a coast"
|
??? example "Eliminates combat penalty for attacking across a coast"
|
||||||
Applicable to: Unit
|
Applicable to: Unit
|
||||||
|
|
||||||
??? example "6 tiles in every direction always visible"
|
??? example "No Sight"
|
||||||
|
Applicable to: Unit
|
||||||
|
|
||||||
|
??? example "Can see over obstacles"
|
||||||
Applicable to: Unit
|
Applicable to: Unit
|
||||||
|
|
||||||
??? example "Can carry [amount] [mapUnitFilter] units"
|
??? example "Can carry [amount] [mapUnitFilter] units"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user