mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-11 00:08:58 +07:00
Avoid destroying all onboard units after player upgrade Air Carrier unit. (#8129)
This commit is contained in:
@ -916,17 +916,19 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
|||||||
attacksSinceTurnStart.clear()
|
attacksSinceTurnStart.clear()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun destroy() {
|
fun destroy(destroyTransportedUnit: Boolean = true) {
|
||||||
val currentPosition = Vector2(getTile().position)
|
val currentPosition = Vector2(getTile().position)
|
||||||
civInfo.attacksSinceTurnStart.addAll(attacksSinceTurnStart.asSequence().map { CivilizationInfo.HistoricalAttackMemory(this.name, currentPosition, it) })
|
civInfo.attacksSinceTurnStart.addAll(attacksSinceTurnStart.asSequence().map { CivilizationInfo.HistoricalAttackMemory(this.name, currentPosition, it) })
|
||||||
currentMovement = 0f
|
currentMovement = 0f
|
||||||
removeFromTile()
|
removeFromTile()
|
||||||
civInfo.removeUnit(this)
|
civInfo.removeUnit(this)
|
||||||
civInfo.updateViewableTiles()
|
civInfo.updateViewableTiles()
|
||||||
|
if (destroyTransportedUnit) {
|
||||||
// all transported units should be destroyed as well
|
// all transported units should be destroyed as well
|
||||||
currentTile.getUnits().filter { it.isTransported && isTransportTypeOf(it) }
|
currentTile.getUnits().filter { it.isTransported && isTransportTypeOf(it) }
|
||||||
.toList() // because we're changing the list
|
.toList() // because we're changing the list
|
||||||
.forEach { unit -> unit.destroy() }
|
.forEach { unit -> unit.destroy() }
|
||||||
|
}
|
||||||
isDestroyed = true
|
isDestroyed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -446,7 +446,7 @@ object UnitActions {
|
|||||||
return UnitAction(UnitActionType.Upgrade,
|
return UnitAction(UnitActionType.Upgrade,
|
||||||
title = title,
|
title = title,
|
||||||
action = {
|
action = {
|
||||||
unit.destroy()
|
unit.destroy(destroyTransportedUnit = false)
|
||||||
val newUnit = civInfo.placeUnitNearTile(unitTile.position, upgradedUnit.name)
|
val newUnit = civInfo.placeUnitNearTile(unitTile.position, upgradedUnit.name)
|
||||||
|
|
||||||
/** We were UNABLE to place the new unit, which means that the unit failed to upgrade!
|
/** We were UNABLE to place the new unit, which means that the unit failed to upgrade!
|
||||||
|
Reference in New Issue
Block a user