mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 13:27:22 -04:00
Fix Polynesia's Wayfinding (#6238)
* Fix Polynesia's Wayfinding * Fix mod option to use other unit filters with UnitsMayEnterOcean
This commit is contained in:
parent
f360eda047
commit
651dcff581
@ -488,7 +488,7 @@
|
||||
"innerColor": [255,255,78],
|
||||
"favoredReligion": "Christianity",
|
||||
"uniqueName": "Wayfinding",
|
||||
"uniques": ["Enables embarkation for land units <starting from the [Ancient era]>", "Enables embarked units to enter ocean tiles <starting from the [Ancient era]>", "Normal vision when embarked <for [All] units>", "+[10]% Strength if within [2] tiles of a [Moai]"],
|
||||
"uniques": ["Enables embarkation for land units <starting from the [Ancient era]>", "Enables [All] units to enter ocean tiles <starting from the [Ancient era]>", "Normal vision when embarked <for [All] units>", "+[10]% Strength if within [2] tiles of a [Moai]"],
|
||||
"cities": ["Honolulu","Samoa","Tonga","Nuku Hiva","Raiatea","Aotearoa","Tahiti","Hilo","Te Wai Pounamu","Rapa Nui",
|
||||
"Tuamotu","Rarotonga","Tuvalu","Tubuai","Mangareva","Oahu","Kiritimati","Ontong Java","Niue","Rekohu",
|
||||
"Rakahanga","Bora Bora","Kailua","Uvea","Futuna","Rotuma","Tokelau","Lahaina","Bellona","Mungava","Tikopia",
|
||||
|
@ -266,7 +266,7 @@
|
||||
{
|
||||
"name": "Astronomy",
|
||||
"row": 2,
|
||||
"uniques": ["[+1] Movement <for [Embarked] units>","Enables embarked units to enter ocean tiles"],
|
||||
"uniques": ["[+1] Movement <for [Embarked] units>","Enables [Embarked] units to enter ocean tiles"],
|
||||
"prerequisites": ["Compass","Education"],
|
||||
"quote": "'Joyfully to the breeze royal Odysseus spread his sail, and with his rudder skillfully he steered.' - Homer"
|
||||
},
|
||||
|
@ -468,7 +468,7 @@
|
||||
"outerColor": [225,105,0],
|
||||
"innerColor": [255,255,78],
|
||||
"uniqueName": "Wayfinding",
|
||||
"uniques": ["Enables embarkation for land units <starting from the [Ancient era]>", "Enables embarked units to enter ocean tiles <starting from the [Ancient era]>", "Normal vision when embarked <for [All] units>", "+[10]% Strength if within [2] tiles of a [Moai]"],
|
||||
"uniques": ["Enables embarkation for land units <starting from the [Ancient era]>", "Enables [All] units to enter ocean tiles <starting from the [Ancient era]>", "Normal vision when embarked <for [All] units>", "+[10]% Strength if within [2] tiles of a [Moai]"],
|
||||
"cities": ["Honolulu","Samoa","Tonga","Nuku Hiva","Raiatea","Aotearoa","Tahiti","Hilo","Te Wai Pounamu","Rapa Nui",
|
||||
"Tuamotu","Rarotonga","Tuvalu","Tubuai","Mangareva","Oahu","Kiritimati","Ontong Java","Niue","Rekohu",
|
||||
"Rakahanga","Bora Bora","Kailua","Uvea","Futuna","Rotuma","Tokelau","Lahaina","Bellona","Mungava","Tikopia",
|
||||
|
@ -246,7 +246,7 @@
|
||||
{
|
||||
"name": "Astronomy",
|
||||
"row": 2,
|
||||
"uniques": ["[+1] Movement <for [Embarked] units>","Enables embarked units to enter ocean tiles"],
|
||||
"uniques": ["[+1] Movement <for [Embarked] units>","Enables [Embarked] units to enter ocean tiles"],
|
||||
"prerequisites": ["Compass","Education"],
|
||||
"quote": "'Joyfully to the breeze royal Odysseus spread his sail, and with his rudder skillfully he steered.' - Homer"
|
||||
},
|
||||
|
@ -3,7 +3,6 @@ package com.unciv.logic.civilization
|
||||
import com.unciv.logic.city.CityInfo
|
||||
import com.unciv.logic.map.MapSize
|
||||
import com.unciv.logic.map.RoadStatus
|
||||
import com.unciv.logic.map.TileInfo
|
||||
import com.unciv.models.ruleset.Era
|
||||
import com.unciv.models.ruleset.unique.UniqueMap
|
||||
import com.unciv.models.ruleset.unique.UniqueTriggerActivation
|
||||
@ -34,11 +33,13 @@ class TechManager {
|
||||
|
||||
// MapUnit.canPassThrough is the most called function in the game, and having these extremely specific booleans is one way of improving the time cost
|
||||
@Transient
|
||||
var wayfinding = false
|
||||
@Transient
|
||||
var unitsCanEmbark = false
|
||||
@Transient
|
||||
var embarkedUnitsCanEnterOcean = false
|
||||
@Transient
|
||||
var allUnitsCanEnterOcean = false
|
||||
@Transient
|
||||
var specificUnitsCanEnterOcean = false
|
||||
|
||||
// UnitMovementAlgorithms.getMovementCostBetweenAdjacentTiles is a close second =)
|
||||
@Transient
|
||||
@ -373,15 +374,22 @@ class TechManager {
|
||||
fun setTransients() {
|
||||
researchedTechnologies.addAll(techsResearched.map { getRuleset().technologies[it]!! })
|
||||
researchedTechnologies.forEach { addTechToTransients(it) }
|
||||
updateEra() // before updateTransientBooleans so era-based conditionals can work
|
||||
updateTransientBooleans()
|
||||
updateEra()
|
||||
}
|
||||
|
||||
private fun updateTransientBooleans() {
|
||||
wayfinding = civInfo.hasUnique(UniqueType.EmbarkAndEnterOcean)
|
||||
unitsCanEmbark = wayfinding || civInfo.hasUnique(UniqueType.LandUnitEmbarkation)
|
||||
val wayfinding = civInfo.hasUnique(UniqueType.EmbarkAndEnterOcean)
|
||||
unitsCanEmbark = wayfinding ||
|
||||
civInfo.hasUnique(UniqueType.LandUnitEmbarkation)
|
||||
val enterOceanUniques = civInfo.getMatchingUniques(UniqueType.UnitsMayEnterOcean)
|
||||
allUnitsCanEnterOcean = enterOceanUniques.any { it.params[0] == "All" }
|
||||
embarkedUnitsCanEnterOcean = wayfinding ||
|
||||
allUnitsCanEnterOcean ||
|
||||
enterOceanUniques.any { it.params[0] == "Embarked" } ||
|
||||
civInfo.hasUnique(UniqueType.EmbarkedUnitsMayEnterOcean)
|
||||
specificUnitsCanEnterOcean = enterOceanUniques.any { it.params[0] != "All" && it.params[0] != "Embarked" }
|
||||
|
||||
embarkedUnitsCanEnterOcean = wayfinding || civInfo.hasUnique(UniqueType.EmbarkedUnitsMayEnterOcean)
|
||||
movementSpeedOnRoads = if (civInfo.hasUnique(UniqueType.RoadMovementSpeed))
|
||||
RoadStatus.Road.movementImproved else RoadStatus.Road.movement
|
||||
roadsConnectAcrossRivers = civInfo.hasUnique(UniqueType.RoadsConnectAcrossRivers)
|
||||
|
@ -610,14 +610,18 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
|
||||
&& !tile.isCityCenter())
|
||||
return false
|
||||
|
||||
|
||||
val unitSpecificAllowOcean: Boolean by lazy {
|
||||
unit.civInfo.tech.specificUnitsCanEnterOcean &&
|
||||
unit.civInfo.getMatchingUniques(UniqueType.UnitsMayEnterOcean)
|
||||
.any { unit.matchesFilter(it.params[0]) }
|
||||
}
|
||||
if (tile.isWater && unit.baseUnit.isLandUnit()) {
|
||||
if (!unit.civInfo.tech.unitsCanEmbark) return false
|
||||
if (tile.isOcean && !unit.civInfo.tech.embarkedUnitsCanEnterOcean)
|
||||
if (tile.isOcean && !unit.civInfo.tech.embarkedUnitsCanEnterOcean && !unitSpecificAllowOcean)
|
||||
return false
|
||||
}
|
||||
if (tile.isOcean && !unit.civInfo.tech.wayfinding) { // Apparently all Polynesian naval units can enter oceans
|
||||
if (unit.cannotEnterOceanTiles) return false
|
||||
if (tile.isOcean && !unit.civInfo.tech.allUnitsCanEnterOcean) { // Apparently all Polynesian naval units can enter oceans
|
||||
if (!unitSpecificAllowOcean && unit.cannotEnterOceanTiles) return false
|
||||
}
|
||||
if (tile.naturalWonder != null) return false
|
||||
|
||||
|
@ -279,20 +279,22 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
CityHealingUnits("[mapUnitFilter] Units adjacent to this city heal [amount] HP per turn when healing", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
|
||||
GoldenAgeLength("[amount]% Golden Age length", UniqueTarget.Global),
|
||||
|
||||
|
||||
StrengthForCities("[amount]% Strength for cities", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
@Deprecated("as of 3.19.1", ReplaceWith("[+amount]% Strength for cities <with a garrison> <when attacking>"))
|
||||
StrengthForGarrisonedCitiesAttacking("+[amount]% attacking strength for cities with garrisoned units", UniqueTarget.Global),
|
||||
|
||||
|
||||
UnitStartingExperience("New [baseUnitFilter] units start with [amount] Experience [cityFilter]", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
UnitStartingPromotions("All newly-trained [baseUnitFilter] units [cityFilter] receive the [promotion] promotion", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
UnitStartingActions("[baseUnitFilter] units built [cityFilter] can [action] [amount] extra times", UniqueTarget.Global, UniqueTarget.FollowerBelief),
|
||||
// ToDo: make per unit and use unit filters?
|
||||
LandUnitEmbarkation("Enables embarkation for land units", UniqueTarget.Global),
|
||||
UnitsMayEnterOcean("Enables [mapUnitFilter] units to enter ocean tiles", UniqueTarget.Global),
|
||||
@Deprecated("as of 3.19.13", ReplaceWith("Enables [Embarked] units to enter ocean tiles <starting from the [Ancient era]>"))
|
||||
EmbarkedUnitsMayEnterOcean("Enables embarked units to enter ocean tiles", UniqueTarget.Global),
|
||||
@Deprecated("as of 3.19.9", ReplaceWith("Enables embarkation for land units <starting from the [Ancient era]>\", \"Enables embarked units to enter ocean tiles <starting from the [Ancient era]>"))
|
||||
@Deprecated("as of 3.19.9", ReplaceWith("Enables embarkation for land units <starting from the [Ancient era]>\", \"Enables [All] units to enter ocean tiles <starting from the [Ancient era]>"))
|
||||
EmbarkAndEnterOcean("Can embark and move over Coasts and Oceans immediately", UniqueTarget.Global),
|
||||
|
||||
|
||||
PopulationLossFromNukes("Population loss from nuclear attacks [amount]% [cityFilter]", UniqueTarget.Global),
|
||||
@Deprecated("as of 3.19.2", ReplaceWith("Population loss from nuclear attacks [-amount]% [in this city]"))
|
||||
PopulationLossFromNukesDeprecated("Population loss from nuclear attacks -[amount]%", UniqueTarget.Global),
|
||||
|
@ -551,7 +551,9 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
|
||||
??? example "Enables embarkation for land units"
|
||||
Applicable to: Global
|
||||
|
||||
??? example "Enables embarked units to enter ocean tiles"
|
||||
??? example "Enables [mapUnitFilter] units to enter ocean tiles"
|
||||
Example: "Enables [Wounded] units to enter ocean tiles"
|
||||
|
||||
Applicable to: Global
|
||||
|
||||
??? example "Population loss from nuclear attacks [amount]% [cityFilter]"
|
||||
|
Loading…
x
Reference in New Issue
Block a user