mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-03 22:22:51 +07:00
Added hasExplored and explore() functions to civinfo to mask exploredTiles
This commit is contained in:
parent
da5948364e
commit
b8da124263
@ -23,7 +23,7 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) {
|
||||
// and we never actually iterate on the explored tiles (only check contains()),
|
||||
// so there's no fear of concurrency problems.
|
||||
val newlyExploredTiles = civInfo.viewableTiles.asSequence().map { it.position }
|
||||
civInfo.exploredTiles.addAll(newlyExploredTiles)
|
||||
civInfo.addExploredTiles(newlyExploredTiles)
|
||||
|
||||
|
||||
val viewedCivs = HashMap<CivilizationInfo, TileInfo>()
|
||||
@ -70,7 +70,7 @@ class CivInfoTransientUpdater(val civInfo: CivilizationInfo) {
|
||||
if (civInfo.isSpectator() || UncivGame.Current.viewEntireMapForDebug) {
|
||||
val allTiles = civInfo.gameInfo.tileMap.values.toSet()
|
||||
civInfo.viewableTiles = allTiles
|
||||
civInfo.exploredTiles = allTiles.map { it.position }.toHashSet()
|
||||
civInfo.addExploredTiles(allTiles.map { it.position }.toHashSet()
|
||||
civInfo.viewableInvisibleUnitsTiles = allTiles
|
||||
return
|
||||
}
|
||||
|
@ -113,6 +113,10 @@ class CivilizationInfo : IsPartOfGameInfoSerialization {
|
||||
@Transient
|
||||
var enemyMovementPenaltyUniques: Sequence<Unique>? = null
|
||||
|
||||
/** Same as above variable */
|
||||
@Transient
|
||||
var isEntireMapRevealed: Sequence<Unique>? = null
|
||||
|
||||
@Transient
|
||||
var statsForNextTurn = Stats()
|
||||
|
||||
@ -199,6 +203,10 @@ class CivilizationInfo : IsPartOfGameInfoSerialization {
|
||||
fun hasExplored(position: Vector2) = exploredTiles.contains(position)
|
||||
fun hasExplored(tileInfo: TileInfo) = hasExplored(tileInfo.position)
|
||||
|
||||
fun addExploredTiles(tiles:Sequence<Vector2>){
|
||||
exploredTiles.addAll(tiles)
|
||||
}
|
||||
|
||||
var lastSeenImprovement = HashMapVector2<String>()
|
||||
|
||||
// To correctly determine "game over" condition as clarified in #4707
|
||||
@ -1289,7 +1297,6 @@ class CivilizationInfo : IsPartOfGameInfoSerialization {
|
||||
fun addCity(location: Vector2) {
|
||||
val newCity = CityInfo(this, location)
|
||||
newCity.cityConstructions.chooseNextConstruction()
|
||||
|
||||
}
|
||||
|
||||
fun destroy() {
|
||||
|
@ -298,8 +298,8 @@ object UniqueTriggerActivation {
|
||||
if (notification != null) {
|
||||
civInfo.addNotification(notification, LocationAction(tile?.position), NotificationIcon.Scout)
|
||||
}
|
||||
return civInfo.exploredTiles.addAll(
|
||||
civInfo.gameInfo.tileMap.values.asSequence().map { it.position })
|
||||
civInfo.addExploredTiles(civInfo.gameInfo.tileMap.values.asSequence().map { it.position })
|
||||
return true
|
||||
}
|
||||
|
||||
UnitsGainPromotion -> {
|
||||
@ -462,8 +462,8 @@ object UniqueTriggerActivation {
|
||||
// Implements [UniqueParameterType.CombatantFilter] - At the moment the only use
|
||||
if (unique.params[0] != "All") this.take(unique.params[0].toInt())
|
||||
}
|
||||
civInfo.addExploredTiles(revealedTiles)
|
||||
for (position in revealedTiles) {
|
||||
civInfo.exploredTiles.add(position)
|
||||
val revealedTileInfo = civInfo.gameInfo.tileMap[position]
|
||||
if (revealedTileInfo.improvement == null)
|
||||
civInfo.lastSeenImprovement.remove(position)
|
||||
@ -493,7 +493,7 @@ object UniqueTriggerActivation {
|
||||
.getTilesInDistance(unique.params[1].toInt())
|
||||
.map { it.position }
|
||||
.filter { tileBasedRandom.nextFloat() < unique.params[2].toFloat() / 100f }
|
||||
civInfo.exploredTiles.addAll(tilesToReveal)
|
||||
civInfo.addExploredTiles(tilesToReveal)
|
||||
civInfo.updateViewableTiles()
|
||||
if (notification != null)
|
||||
civInfo.addNotification(
|
||||
|
Loading…
Reference in New Issue
Block a user