mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-26 13:27:22 -04:00
Fix Zone of Control (#6891)
This commit is contained in:
parent
915f3e694f
commit
8b9946e65e
@ -43,7 +43,7 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
|||||||
// Each of these two function calls `hasUnique(UniqueType.CityStateTerritoryAlwaysFriendly)`
|
// Each of these two function calls `hasUnique(UniqueType.CityStateTerritoryAlwaysFriendly)`
|
||||||
// when entering territory of a city state
|
// when entering territory of a city state
|
||||||
val areConnectedByRoad = from.hasConnection(civInfo) && to.hasConnection(civInfo)
|
val areConnectedByRoad = from.hasConnection(civInfo) && to.hasConnection(civInfo)
|
||||||
|
|
||||||
val areConnectedByRiver = from.isAdjacentToRiver() && to.isAdjacentToRiver() && from.isConnectedByRiver(to)
|
val areConnectedByRiver = from.isAdjacentToRiver() && to.isAdjacentToRiver() && from.isConnectedByRiver(to)
|
||||||
|
|
||||||
if (areConnectedByRoad && (!areConnectedByRiver || civInfo.tech.roadsConnectAcrossRivers))
|
if (areConnectedByRoad && (!areConnectedByRiver || civInfo.tech.roadsConnectAcrossRivers))
|
||||||
@ -77,7 +77,7 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
|||||||
|
|
||||||
if (unit.noFilteredDoubleMovementUniques)
|
if (unit.noFilteredDoubleMovementUniques)
|
||||||
return terrainCost + extraCost
|
return terrainCost + extraCost
|
||||||
if (unit.doubleMovementInTerrain.any {
|
if (unit.doubleMovementInTerrain.any {
|
||||||
it.value == MapUnit.DoubleMovementTerrainTarget.Filter &&
|
it.value == MapUnit.DoubleMovementTerrainTarget.Filter &&
|
||||||
to.matchesFilter(it.key)
|
to.matchesFilter(it.key)
|
||||||
})
|
})
|
||||||
@ -92,7 +92,7 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
|||||||
yield(tile)
|
yield(tile)
|
||||||
}
|
}
|
||||||
else if (tile.militaryUnit != null && civInfo.isAtWarWith(tile.militaryUnit!!.civInfo)) {
|
else if (tile.militaryUnit != null && civInfo.isAtWarWith(tile.militaryUnit!!.civInfo)) {
|
||||||
if (tile.militaryUnit!!.type.isWaterUnit() || (unit.type.isLandUnit() && tile.militaryUnit!!.isEmbarked()))
|
if (tile.militaryUnit!!.type.isWaterUnit() || (unit.type.isLandUnit() && !tile.militaryUnit!!.isEmbarked()))
|
||||||
yield(tile)
|
yield(tile)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -126,7 +126,6 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
|||||||
// anyway.
|
// anyway.
|
||||||
if (unit.ignoresZoneOfControl)
|
if (unit.ignoresZoneOfControl)
|
||||||
return false
|
return false
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -455,7 +454,7 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
|||||||
// Cache this in case something goes wrong
|
// Cache this in case something goes wrong
|
||||||
|
|
||||||
var lastReachedEnterableTile = unit.getTile()
|
var lastReachedEnterableTile = unit.getTile()
|
||||||
var previousTile = unit.getTile()
|
var previousTile = unit.getTile()
|
||||||
var passingMovementSpent = 0f // Movement points spent since last tile we could end our turn on
|
var passingMovementSpent = 0f // Movement points spent since last tile we could end our turn on
|
||||||
|
|
||||||
unit.removeFromTile()
|
unit.removeFromTile()
|
||||||
@ -475,7 +474,7 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
|||||||
// This fixes a bug where tiles in the fog of war would always only cost 1 mp
|
// This fixes a bug where tiles in the fog of war would always only cost 1 mp
|
||||||
if (!unit.civInfo.gameInfo.gameParameters.godMode)
|
if (!unit.civInfo.gameInfo.gameParameters.godMode)
|
||||||
passingMovementSpent += getMovementCostBetweenAdjacentTiles(previousTile, tile, unit.civInfo)
|
passingMovementSpent += getMovementCostBetweenAdjacentTiles(previousTile, tile, unit.civInfo)
|
||||||
|
|
||||||
// In case something goes wrong, cache the last tile we were able to end on
|
// In case something goes wrong, cache the last tile we were able to end on
|
||||||
// We can assume we can pass through this tile, as we would have broken earlier
|
// We can assume we can pass through this tile, as we would have broken earlier
|
||||||
if (unit.movement.canMoveTo(tile, assumeCanPassThrough = true)) {
|
if (unit.movement.canMoveTo(tile, assumeCanPassThrough = true)) {
|
||||||
@ -491,7 +490,7 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
|||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val finalTileReached = lastReachedEnterableTile
|
val finalTileReached = lastReachedEnterableTile
|
||||||
|
|
||||||
// Silly floats which are almost zero
|
// Silly floats which are almost zero
|
||||||
@ -664,7 +663,7 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
|||||||
val firstUnit = tile.getFirstUnit()
|
val firstUnit = tile.getFirstUnit()
|
||||||
// Moving to non-empty tile
|
// Moving to non-empty tile
|
||||||
if (firstUnit != null && unit.civInfo != firstUnit.civInfo) {
|
if (firstUnit != null && unit.civInfo != firstUnit.civInfo) {
|
||||||
// Allow movement through unguarded, at-war Civilian Unit. Capture on the way
|
// Allow movement through unguarded, at-war Civilian Unit. Capture on the way
|
||||||
// But not for Embarked Units capturing on Water
|
// But not for Embarked Units capturing on Water
|
||||||
if (!(unit.isEmbarked() && tile.isWater)
|
if (!(unit.isEmbarked() && tile.isWater)
|
||||||
&& firstUnit.isCivilian() && unit.civInfo.isAtWarWith(firstUnit.civInfo))
|
&& firstUnit.isCivilian() && unit.civInfo.isAtWarWith(firstUnit.civInfo))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user