mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-08 14:57:58 +07:00
Reassign workers when resistance ends or improvement created (#9212)
This commit is contained in:
@ -156,6 +156,7 @@ class CityInfoConquestFunctions(val city: City){
|
||||
fun annexCity() {
|
||||
city.isPuppet = false
|
||||
city.cityConstructions.inProgressConstructions.clear() // undo all progress of the previous civ on units etc.
|
||||
if (!city.isInResistance()) city.updateCitizens = true
|
||||
city.cityStats.update()
|
||||
GUI.setUpdateWorldOnNextRender()
|
||||
}
|
||||
|
@ -19,22 +19,23 @@ class CityTurnManager(val city: City) {
|
||||
city.cityConstructions.constructIfEnough()
|
||||
city.cityConstructions.addFreeBuildings()
|
||||
|
||||
city.cityStats.update()
|
||||
city.tryUpdateRoadStatus()
|
||||
city.attackedThisTurn = false
|
||||
|
||||
// The ordering is intentional - you get a turn without WLTKD even if you have the next resource already
|
||||
// Also resolve end of resistance before updateCitizens
|
||||
if (!city.hasFlag(CityFlags.WeLoveTheKing))
|
||||
tryWeLoveTheKing()
|
||||
nextTurnFlags()
|
||||
|
||||
if (city.isPuppet) {
|
||||
city.cityAIFocus = CityFocus.GoldFocus
|
||||
city.reassignAllPopulation()
|
||||
} else if (city.updateCitizens) {
|
||||
city.reassignPopulation()
|
||||
city.reassignPopulation() // includes cityStats.update
|
||||
city.updateCitizens = false
|
||||
}
|
||||
|
||||
// The ordering is intentional - you get a turn without WLTKD even if you have the next resource already
|
||||
if (!city.hasFlag(CityFlags.WeLoveTheKing))
|
||||
tryWeLoveTheKing()
|
||||
nextTurnFlags()
|
||||
} else
|
||||
city.cityStats.update()
|
||||
|
||||
// Seed resource demand countdown
|
||||
if (city.demandedResource == "" && !city.hasFlag(CityFlags.ResourceDemand)) {
|
||||
@ -74,6 +75,7 @@ class CityTurnManager(val city: City) {
|
||||
demandNewResource()
|
||||
}
|
||||
CityFlags.Resistance.name -> {
|
||||
city.updateCitizens = true
|
||||
city.civ.addNotification(
|
||||
"The resistance in [${city.name}] has ended!",
|
||||
city.location, NotificationCategory.General, "StatIcons/Resistance")
|
||||
|
@ -208,9 +208,8 @@ class UnitTurnManager(val unit: MapUnit) {
|
||||
tile.improvementInProgress == RoadStatus.Railroad.name -> tile.addRoad(RoadStatus.Railroad, unit.civ)
|
||||
tile.improvementInProgress == Constants.repair -> tile.setRepaired()
|
||||
else -> {
|
||||
val improvement = unit.civ.gameInfo.ruleset.tileImprovements[tile.improvementInProgress]!!
|
||||
improvement.handleImprovementCompletion(unit)
|
||||
tile.changeImprovement(tile.improvementInProgress)
|
||||
tile.getTileImprovement()!!.handleImprovementCompletion(unit)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -80,6 +80,7 @@ class TileImprovement : RulesetStatsObject() {
|
||||
if (tile.resource != null) {
|
||||
val city = builder.getTile().getCity()
|
||||
if (city != null) {
|
||||
city.updateCitizens = true
|
||||
city.cityStats.update()
|
||||
city.civ.cache.updateCivResources()
|
||||
}
|
||||
|
@ -159,12 +159,8 @@ object UnitActions {
|
||||
return UnitAction(UnitActionType.Create, "Create [$improvementName]",
|
||||
action = {
|
||||
tile.changeImprovement(improvementName)
|
||||
val city = tile.getCity()
|
||||
if (city != null) {
|
||||
city.cityStats.update()
|
||||
city.civ.cache.updateCivResources()
|
||||
}
|
||||
unit.destroy()
|
||||
tile.getTileImprovement()!!.handleImprovementCompletion(unit)
|
||||
unit.destroy() // Modders may wish for a nondestructive way, but that should be another Unique
|
||||
}.takeIf { unit.currentMovement > 0 })
|
||||
}
|
||||
|
||||
@ -502,7 +498,7 @@ object UnitActions {
|
||||
unitTile.stopWorkingOnImprovement()
|
||||
improvement.handleImprovementCompletion(unit)
|
||||
|
||||
// without this the world screen won't the improvement because it isn't the 'last seen improvement'
|
||||
// without this the world screen won't show the improvement because it isn't the 'last seen improvement'
|
||||
unit.civ.cache.updateViewableTiles()
|
||||
|
||||
if (unique.type == UniqueType.ConstructImprovementConsumingUnit) unit.consume()
|
||||
|
Reference in New Issue
Block a user