mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-25 07:09:16 +07:00
perf
This commit is contained in:
@ -237,7 +237,8 @@ class CityReligionManager : IsPartOfGameInfoSerialization {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun getMajorityReligion(): Religion? {
|
fun getMajorityReligion(): Religion? {
|
||||||
return city.civ.gameInfo.religions[getMajorityReligionName()]
|
val majorityReligionName = getMajorityReligionName() ?: return null
|
||||||
|
return city.civ.gameInfo.religions[majorityReligionName]
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getAffectedBySurroundingCities() {
|
private fun getAffectedBySurroundingCities() {
|
||||||
@ -269,8 +270,9 @@ class CityReligionManager : IsPartOfGameInfoSerialization {
|
|||||||
spreadRange += unique.params[0].toInt()
|
spreadRange += unique.params[0].toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getMajorityReligion() != null) {
|
val majorityReligion = getMajorityReligion()
|
||||||
for (unique in getMajorityReligion()!!.getFounder().getMatchingUniques(UniqueType.ReligionSpreadDistance))
|
if (majorityReligion != null) {
|
||||||
|
for (unique in majorityReligion.getFounder().getMatchingUniques(UniqueType.ReligionSpreadDistance))
|
||||||
spreadRange += unique.params[0].toInt()
|
spreadRange += unique.params[0].toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,8 @@ class CivInfoTransientCache(val civInfo: Civilization) {
|
|||||||
for (tile in civInfo.viewableTiles) {
|
for (tile in civInfo.viewableTiles) {
|
||||||
val tileOwner = tile.getOwner()
|
val tileOwner = tile.getOwner()
|
||||||
if (tileOwner != null) viewedCivs[tileOwner] = tile
|
if (tileOwner != null) viewedCivs[tileOwner] = tile
|
||||||
for (unit in tile.getUnits()) viewedCivs[unit.civ] = tile
|
val unitOwner = tile.getFirstUnit()?.civ
|
||||||
|
if (unitOwner != null) viewedCivs[unitOwner] = tile
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!civInfo.isBarbarian()) {
|
if (!civInfo.isBarbarian()) {
|
||||||
|
@ -404,7 +404,8 @@ class TileMap(initialCapacity: Int = 10) : IsPartOfGameInfoSerialization {
|
|||||||
|
|
||||||
This can all be summed up as "I can see c if a=>b || c>b"
|
This can all be summed up as "I can see c if a=>b || c>b"
|
||||||
*/
|
*/
|
||||||
val bMinimumHighestSeenTerrainSoFar = viewableTiles.filter { it.tile in cTile.neighbors }
|
val bMinimumHighestSeenTerrainSoFar = viewableTiles
|
||||||
|
.filter { it.tile.aerialDistanceTo(cTile) == 1 }
|
||||||
.minOf { it.maxHeightSeenToTile }
|
.minOf { it.maxHeightSeenToTile }
|
||||||
|
|
||||||
tilesToAddInDistanceI.add(ViewableTile(
|
tilesToAddInDistanceI.add(ViewableTile(
|
||||||
|
@ -152,7 +152,7 @@ object MovementCost {
|
|||||||
// function is surprisingly less efficient than the current neighbor-intersection approach.
|
// function is surprisingly less efficient than the current neighbor-intersection approach.
|
||||||
// See #4085 for more details.
|
// See #4085 for more details.
|
||||||
val tilesExertingZoneOfControl = getTilesExertingZoneOfControl(unit, from)
|
val tilesExertingZoneOfControl = getTilesExertingZoneOfControl(unit, from)
|
||||||
if (tilesExertingZoneOfControl.none { to.neighbors.contains(it)})
|
if (tilesExertingZoneOfControl.none { it.aerialDistanceTo(it) == 1 })
|
||||||
return false
|
return false
|
||||||
|
|
||||||
// Even though this is a very fast check, we perform it last. This is because very few units
|
// Even though this is a very fast check, we perform it last. This is because very few units
|
||||||
|
@ -99,7 +99,7 @@ class Religion() : INamed, IsPartOfGameInfoSerialization {
|
|||||||
|
|
||||||
fun isEnhancedReligion() = getBeliefs(BeliefType.Enhancer).any()
|
fun isEnhancedReligion() = getBeliefs(BeliefType.Enhancer).any()
|
||||||
|
|
||||||
fun getFounder() = gameInfo.civilizations.first { it.civName == foundingCivName }
|
fun getFounder() = gameInfo.getCivilization(foundingCivName)
|
||||||
|
|
||||||
private fun unlockedBuildingsPurchasable(): List<String> {
|
private fun unlockedBuildingsPurchasable(): List<String> {
|
||||||
return getAllBeliefsOrdered().flatMap { belief ->
|
return getAllBeliefsOrdered().flatMap { belief ->
|
||||||
|
Reference in New Issue
Block a user