Fixed "units from ruins block activating unit" bug and fixed colors for new city states

This commit is contained in:
Yair Morgenstern
2019-07-27 22:34:57 +03:00
parent 42e5f3b883
commit b131372b13
4 changed files with 18 additions and 10 deletions

View File

@ -460,7 +460,8 @@ class UnitAutomation{
fun tryGoToRuin(unit:MapUnit, unitDistanceToTiles: PathsToTilesWithinTurn): Boolean {
if(!unit.civInfo.isMajorCiv()) return false // barbs don't have anything to do in ruins
val tileWithRuin = unitDistanceToTiles.keys.firstOrNull{unit.movement.canMoveTo(it) && it.improvement == Constants.ancientRuins}
val tileWithRuin = unitDistanceToTiles.keys
.firstOrNull{ it.improvement == Constants.ancientRuins && unit.movement.canMoveTo(it) }
if(tileWithRuin==null) return false
unit.movement.moveToTile(tileWithRuin)
return true

View File

@ -239,12 +239,18 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
// Move through all intermediate tiles to get ancient ruins, barb encampments
// and to view tiles along the way
val pathToFinalTile = distanceToTiles.getPathToTile(destination)
unit.removeFromTile()
unit.putInTile(destination)
// We only activate the moveThroughTile AFTER the putInTile because of a really weird bug -
// If you're going to (or past) a ruin, and you activate the ruin bonus, and A UNIT spawns.
// That unit could now be blocking your entrance to the destination, so the putInTile would fail! =0
// Instead, we move you to the destination directly, and only afterwards activate the various tileson the way.
for(tile in pathToFinalTile){
unit.moveThroughTile(tile)
}
unit.putInTile(destination)
}
@ -256,7 +262,8 @@ class UnitMovementAlgorithms(val unit:MapUnit) {
if(unit.type.isAirUnit())
return tile.airUnits.size<6 && tile.isCityCenter() && tile.getCity()?.civInfo==unit.civInfo
if(!canPassThrough(tile)) return false
if(!canPassThrough(tile))
return false
if (unit.type.isCivilian())
return tile.civilianUnit==null && (tile.militaryUnit==null || tile.militaryUnit!!.owner==unit.owner)