mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-10 15:59:33 +07:00
#3050 - Added "automated workers don't replace improvements" setting
This commit is contained in:
@ -342,6 +342,7 @@ Move units with a single tap =
|
|||||||
Show tutorials =
|
Show tutorials =
|
||||||
Auto-assign city production =
|
Auto-assign city production =
|
||||||
Auto-build roads =
|
Auto-build roads =
|
||||||
|
Automated workers replace improvements =
|
||||||
Show minimap =
|
Show minimap =
|
||||||
Show pixel units =
|
Show pixel units =
|
||||||
Show pixel improvements =
|
Show pixel improvements =
|
||||||
|
@ -144,16 +144,17 @@ class WorkerAutomation(val unit: MapUnit) {
|
|||||||
private fun tileCanBeImproved(tile: TileInfo, civInfo: CivilizationInfo): Boolean {
|
private fun tileCanBeImproved(tile: TileInfo, civInfo: CivilizationInfo): Boolean {
|
||||||
if (!tile.isLand || tile.isImpassible() || tile.isCityCenter())
|
if (!tile.isLand || tile.isImpassible() || tile.isCityCenter())
|
||||||
return false
|
return false
|
||||||
val city=tile.getCity()
|
val city = tile.getCity()
|
||||||
if (city == null || city.civInfo != civInfo)
|
if (city == null || city.civInfo != civInfo)
|
||||||
return false
|
return false
|
||||||
|
if (tile.improvement != null && !UncivGame.Current.settings.automatedWorkersReplaceImprovements)
|
||||||
|
return false
|
||||||
|
|
||||||
if(tile.improvement==null){
|
if (tile.improvement == null) {
|
||||||
if(tile.improvementInProgress!=null) return true
|
if (tile.improvementInProgress != null) return true
|
||||||
val chosenImprovement = chooseImprovement(tile, civInfo)
|
val chosenImprovement = chooseImprovement(tile, civInfo)
|
||||||
if(chosenImprovement!=null && tile.canBuildImprovement(chosenImprovement, civInfo)) return true
|
if (chosenImprovement != null && tile.canBuildImprovement(chosenImprovement, civInfo)) return true
|
||||||
}
|
} else if (!tile.containsGreatImprovement() && tile.hasViewableResource(civInfo)
|
||||||
else if(!tile.containsGreatImprovement() && tile.hasViewableResource(civInfo)
|
|
||||||
&& tile.getTileResource().improvement != tile.improvement
|
&& tile.getTileResource().improvement != tile.improvement
|
||||||
&& tile.canBuildImprovement(chooseImprovement(tile, civInfo)!!, civInfo))
|
&& tile.canBuildImprovement(chooseImprovement(tile, civInfo)!!, civInfo))
|
||||||
return true
|
return true
|
||||||
@ -178,10 +179,10 @@ class WorkerAutomation(val unit: MapUnit) {
|
|||||||
private fun chooseImprovement(tile: TileInfo, civInfo: CivilizationInfo): TileImprovement? {
|
private fun chooseImprovement(tile: TileInfo, civInfo: CivilizationInfo): TileImprovement? {
|
||||||
val improvementStringForResource : String ?= when {
|
val improvementStringForResource : String ?= when {
|
||||||
tile.resource == null || !tile.hasViewableResource(civInfo) -> null
|
tile.resource == null || !tile.hasViewableResource(civInfo) -> null
|
||||||
tile.terrainFeature == Constants.marsh && !isImprovementOnFeatureAllowed(tile,civInfo) -> "Remove Marsh"
|
tile.terrainFeature == Constants.marsh && !isImprovementOnFeatureAllowed(tile, civInfo) -> "Remove Marsh"
|
||||||
tile.terrainFeature == "Fallout" && !isImprovementOnFeatureAllowed(tile,civInfo) -> "Remove Fallout" // for really mad modders
|
tile.terrainFeature == "Fallout" && !isImprovementOnFeatureAllowed(tile, civInfo) -> "Remove Fallout" // for really mad modders
|
||||||
tile.terrainFeature == Constants.jungle && !isImprovementOnFeatureAllowed(tile,civInfo) -> "Remove Jungle"
|
tile.terrainFeature == Constants.jungle && !isImprovementOnFeatureAllowed(tile, civInfo) -> "Remove Jungle"
|
||||||
tile.terrainFeature == Constants.forest && !isImprovementOnFeatureAllowed(tile,civInfo) -> "Remove Forest"
|
tile.terrainFeature == Constants.forest && !isImprovementOnFeatureAllowed(tile, civInfo) -> "Remove Forest"
|
||||||
else -> tile.getTileResource().improvement
|
else -> tile.getTileResource().improvement
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,9 +215,6 @@ class WorkerAutomation(val unit: MapUnit) {
|
|||||||
return unit.civInfo.gameInfo.ruleSet.tileImprovements[improvementString] // For mods, the tile improvement may not exist, so don't assume.
|
return unit.civInfo.gameInfo.ruleSet.tileImprovements[improvementString] // For mods, the tile improvement may not exist, so don't assume.
|
||||||
}
|
}
|
||||||
private fun isImprovementOnFeatureAllowed(tile: TileInfo, civInfo: CivilizationInfo): Boolean {
|
private fun isImprovementOnFeatureAllowed(tile: TileInfo, civInfo: CivilizationInfo): Boolean {
|
||||||
// Old hardcoded logic amounts to:
|
|
||||||
//return tile.terrainFeature == Constants.forest && tile.getTileResource().improvement == "Camp"
|
|
||||||
|
|
||||||
// routine assumes the caller ensured that terrainFeature and resource are both present
|
// routine assumes the caller ensured that terrainFeature and resource are both present
|
||||||
val resourceImprovementName = tile.getTileResource().improvement
|
val resourceImprovementName = tile.getTileResource().improvement
|
||||||
?: return false
|
?: return false
|
||||||
|
@ -23,6 +23,8 @@ class GameSettings {
|
|||||||
var showTutorials: Boolean = true
|
var showTutorials: Boolean = true
|
||||||
var autoAssignCityProduction: Boolean = true
|
var autoAssignCityProduction: Boolean = true
|
||||||
var autoBuildingRoads: Boolean = true
|
var autoBuildingRoads: Boolean = true
|
||||||
|
var automatedWorkersReplaceImprovements = true
|
||||||
|
|
||||||
var showMinimap: Boolean = true
|
var showMinimap: Boolean = true
|
||||||
var showPixelUnits: Boolean = false
|
var showPixelUnits: Boolean = false
|
||||||
var showPixelImprovements: Boolean = true
|
var showPixelImprovements: Boolean = true
|
||||||
|
@ -109,6 +109,7 @@ class WorldScreenOptionsPopup(val worldScreen:WorldScreen) : Popup(worldScreen)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
addYesNoRow ("Auto-build roads", settings.autoBuildingRoads) { settings.autoBuildingRoads = it }
|
addYesNoRow ("Auto-build roads", settings.autoBuildingRoads) { settings.autoBuildingRoads = it }
|
||||||
|
addYesNoRow ("Automated workers replace improvements", settings.automatedWorkersReplaceImprovements) { settings.automatedWorkersReplaceImprovements = it }
|
||||||
addYesNoRow ("Order trade offers by amount", settings.orderTradeOffersByAmount) { settings.orderTradeOffersByAmount = it }
|
addYesNoRow ("Order trade offers by amount", settings.orderTradeOffersByAmount) { settings.orderTradeOffersByAmount = it }
|
||||||
|
|
||||||
addAutosaveTurnsSelectBox()
|
addAutosaveTurnsSelectBox()
|
||||||
|
Reference in New Issue
Block a user