diff --git a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt index d7a0ba053d..d90d371d70 100644 --- a/core/src/com/unciv/logic/map/mapunit/MapUnit.kt +++ b/core/src/com/unciv/logic/map/mapunit/MapUnit.kt @@ -750,6 +750,7 @@ class MapUnit : IsPartOfGameInfoSerialization { if (hasUnique(UniqueType.HealingEffectsDoubled, checkCivInfoUniques = true)) 2 else 1 if (health > 100) health = 100 + cache.updateUniques() } fun takeDamage(amount: Int) { @@ -757,6 +758,7 @@ class MapUnit : IsPartOfGameInfoSerialization { if (health > 100) health = 100 // For cheating modders, e.g. negative tile damage if (health < 0) health = 0 if (health == 0) destroy() + else cache.updateUniques() } fun destroy(destroyTransportedUnit: Boolean = true) { @@ -879,6 +881,7 @@ class MapUnit : IsPartOfGameInfoSerialization { // this check is here in order to not load the fresh built unit into carrier right after the build isTransported = !tile.isCityCenter() && baseUnit.movesLikeAirUnits() // not moving civilians moveThroughTile(tile) + cache.updateUniques() } fun startEscorting() { @@ -957,6 +960,7 @@ class MapUnit : IsPartOfGameInfoSerialization { owner = civInfo.civName this.civ = civInfo civInfo.units.addUnit(this, updateCivInfo) + cache.updateUniques() } fun capturedBy(captor: Civilization) { diff --git a/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt b/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt index 443c1b2cd9..0d8abb4fd9 100644 --- a/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt +++ b/core/src/com/unciv/logic/map/mapunit/movement/UnitMovement.kt @@ -281,7 +281,7 @@ class UnitMovement(val unit: MapUnit) { includeOtherEscortUnit && unit.isEscorting() -> { val otherUnitTiles = unit.getOtherEscortUnit()!!.movement.getReachableTilesInCurrentTurn(false).toSet() unit.movement.getDistanceToTiles().filter { otherUnitTiles.contains(it.key) }.keys.asSequence() - } + } else -> unit.movement.getDistanceToTiles().keys.asSequence() } } @@ -581,8 +581,8 @@ class UnitMovement(val unit: MapUnit) { if (isCityCenterCannotEnter(tile)) return false - if (includeOtherEscortUnit && unit.isEscorting() - && !unit.getOtherEscortUnit()!!.movement.canMoveTo(tile, assumeCanPassThrough,canSwap, includeOtherEscortUnit = false)) + if (includeOtherEscortUnit && unit.isEscorting() + && !unit.getOtherEscortUnit()!!.movement.canMoveTo(tile, assumeCanPassThrough,canSwap, includeOtherEscortUnit = false)) return false return if (unit.isCivilian()) @@ -676,7 +676,7 @@ class UnitMovement(val unit: MapUnit) { if (unit.civ.isAtWarWith(firstUnit.civ)) return false } - if (includeOtherEscortUnit && unit.isEscorting() && !unit.getOtherEscortUnit()!!.movement.canPassThrough(tile,false)) + if (includeOtherEscortUnit && unit.isEscorting() && !unit.getOtherEscortUnit()!!.movement.canPassThrough(tile,false)) return false return true } @@ -684,7 +684,7 @@ class UnitMovement(val unit: MapUnit) { /** * @param includeOtherEscortUnit determines whether or not this method will also check if the other escort units [getDistanceToTiles] if it has one. - * Leave it as default unless you know what [getDistanceToTiles] does. + * Leave it as default unless you know what [getDistanceToTiles] does. */ fun getDistanceToTiles( considerZoneOfControl: Boolean = true, @@ -704,7 +704,7 @@ class UnitMovement(val unit: MapUnit) { passThroughCache, movementCostCache ) - + if (includeOtherEscortUnit) { // Only save to cache only if we are the original call and not the subsequent escort unit call pathfindingCache.setDistanceToTiles(considerZoneOfControl, distanceToTiles)