mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-28 14:24:43 -04:00
Fixed naval units not tp-ing out of razed cities (#4238)
This commit is contained in:
parent
f745ca9421
commit
cf9e00c589
@ -383,6 +383,12 @@ class CityInfo {
|
|||||||
fun destroyCity() {
|
fun destroyCity() {
|
||||||
for (airUnit in getCenterTile().airUnits.toList()) airUnit.destroy() //Destroy planes stationed in city
|
for (airUnit in getCenterTile().airUnits.toList()) airUnit.destroy() //Destroy planes stationed in city
|
||||||
|
|
||||||
|
// The relinquish ownership MUST come before removing the city,
|
||||||
|
// because it updates the city stats which assumes there is a capital, so if you remove the capital it crashes
|
||||||
|
getTiles().forEach { expansion.relinquishOwnership(it) }
|
||||||
|
civInfo.cities = civInfo.cities.toMutableList().apply { remove(this@CityInfo) }
|
||||||
|
getCenterTile().improvement = "City ruins"
|
||||||
|
|
||||||
// Edge case! What if a water unit is in a city, and you raze the city?
|
// Edge case! What if a water unit is in a city, and you raze the city?
|
||||||
// Well, the water unit has to return to the water!
|
// Well, the water unit has to return to the water!
|
||||||
for (unit in getCenterTile().getUnits()) {
|
for (unit in getCenterTile().getUnits()) {
|
||||||
@ -390,12 +396,6 @@ class CityInfo {
|
|||||||
unit.movement.teleportToClosestMoveableTile()
|
unit.movement.teleportToClosestMoveableTile()
|
||||||
}
|
}
|
||||||
|
|
||||||
// The relinquish ownership MUST come before removing the city,
|
|
||||||
// because it updates the city stats which assumes there is a capital, so if you remove the capital it crashes
|
|
||||||
getTiles().forEach { expansion.relinquishOwnership(it) }
|
|
||||||
civInfo.cities = civInfo.cities.toMutableList().apply { remove(this@CityInfo) }
|
|
||||||
getCenterTile().improvement = "City ruins"
|
|
||||||
|
|
||||||
if (isCapital() && civInfo.cities.isNotEmpty()) { // Move the capital if destroyed (by a nuke or by razing)
|
if (isCapital() && civInfo.cities.isNotEmpty()) { // Move the capital if destroyed (by a nuke or by razing)
|
||||||
civInfo.cities.first().cityConstructions.addBuilding(capitalCityIndicator())
|
civInfo.cities.first().cityConstructions.addBuilding(capitalCityIndicator())
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user