mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-09 23:39:40 +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()
|
||||
}
|
||||
|
||||
fun destroy() {
|
||||
fun destroy(destroyTransportedUnit: Boolean = true) {
|
||||
val currentPosition = Vector2(getTile().position)
|
||||
civInfo.attacksSinceTurnStart.addAll(attacksSinceTurnStart.asSequence().map { CivilizationInfo.HistoricalAttackMemory(this.name, currentPosition, it) })
|
||||
currentMovement = 0f
|
||||
removeFromTile()
|
||||
civInfo.removeUnit(this)
|
||||
civInfo.updateViewableTiles()
|
||||
// all transported units should be destroyed as well
|
||||
currentTile.getUnits().filter { it.isTransported && isTransportTypeOf(it) }
|
||||
.toList() // because we're changing the list
|
||||
.forEach { unit -> unit.destroy() }
|
||||
if (destroyTransportedUnit) {
|
||||
// all transported units should be destroyed as well
|
||||
currentTile.getUnits().filter { it.isTransported && isTransportTypeOf(it) }
|
||||
.toList() // because we're changing the list
|
||||
.forEach { unit -> unit.destroy() }
|
||||
}
|
||||
isDestroyed = true
|
||||
}
|
||||
|
||||
|
@ -446,7 +446,7 @@ object UnitActions {
|
||||
return UnitAction(UnitActionType.Upgrade,
|
||||
title = title,
|
||||
action = {
|
||||
unit.destroy()
|
||||
unit.destroy(destroyTransportedUnit = false)
|
||||
val newUnit = civInfo.placeUnitNearTile(unitTile.position, upgradedUnit.name)
|
||||
|
||||
/** We were UNABLE to place the new unit, which means that the unit failed to upgrade!
|
||||
|
Reference in New Issue
Block a user