mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-15 02:09:21 +07:00
chore: rename canSwap to allowSwap so we don't think it's a precomputed value of something
This commit is contained in:
@ -85,8 +85,8 @@ class WorkerAutomation(
|
||||
|
||||
if (tileToWork != currentTile && tileToWork != null) {
|
||||
debug("WorkerAutomation: %s -> head towards %s", unit.toString(), tileToWork)
|
||||
if (unit.movement.canReachInCurrentTurn(tileToWork) && unit.movement.canMoveTo(tileToWork, canSwap = true)) {
|
||||
if (!unit.movement.canMoveTo(tileToWork, canSwap = false) && unit.movement.canUnitSwapTo(tileToWork)) {
|
||||
if (unit.movement.canReachInCurrentTurn(tileToWork) && unit.movement.canMoveTo(tileToWork, allowSwap = true)) {
|
||||
if (!unit.movement.canMoveTo(tileToWork, allowSwap = false) && unit.movement.canUnitSwapTo(tileToWork)) {
|
||||
// There must be a unit on the target tile! Lets swap with it.
|
||||
unit.movement.swapMoveToTile(tileToWork)
|
||||
}
|
||||
|
@ -333,8 +333,8 @@ class UnitMovement(val unit: MapUnit) {
|
||||
|| otherUnit.cache.cannotMove // redundant, line below would cover it too
|
||||
|| !otherUnit.movement.canReachInCurrentTurn(ourPosition)) return false
|
||||
|
||||
if (!canMoveTo(reachableTile, canSwap = true)) return false
|
||||
if (!otherUnit.movement.canMoveTo(ourPosition, canSwap = true)) return false
|
||||
if (!canMoveTo(reachableTile, allowSwap = true)) return false
|
||||
if (!otherUnit.movement.canMoveTo(ourPosition, allowSwap = true)) return false
|
||||
// All clear!
|
||||
return true
|
||||
}
|
||||
@ -583,7 +583,7 @@ class UnitMovement(val unit: MapUnit) {
|
||||
* @param includeOtherEscortUnit determines whether or not this method will also check if the other escort unit [canMoveTo] if it has one.
|
||||
* Leave it as default unless you know what [canMoveTo] does.
|
||||
*/
|
||||
fun canMoveTo(tile: Tile, assumeCanPassThrough: Boolean = false, canSwap: Boolean = false, includeOtherEscortUnit: Boolean = true): Boolean {
|
||||
fun canMoveTo(tile: Tile, assumeCanPassThrough: Boolean = false, allowSwap: Boolean = false, includeOtherEscortUnit: Boolean = true): Boolean {
|
||||
if (unit.baseUnit.movesLikeAirUnits)
|
||||
return canAirUnitMoveTo(tile, unit)
|
||||
|
||||
@ -595,15 +595,15 @@ class UnitMovement(val unit: MapUnit) {
|
||||
return false
|
||||
|
||||
if (includeOtherEscortUnit && unit.isEscorting()
|
||||
&& !unit.getOtherEscortUnit()!!.movement.canMoveTo(tile, assumeCanPassThrough,canSwap, includeOtherEscortUnit = false))
|
||||
&& !unit.getOtherEscortUnit()!!.movement.canMoveTo(tile, assumeCanPassThrough, allowSwap, includeOtherEscortUnit = false))
|
||||
return false
|
||||
|
||||
return if (unit.isCivilian())
|
||||
(tile.civilianUnit == null || (canSwap && tile.civilianUnit!!.owner == unit.owner))
|
||||
(tile.civilianUnit == null || (allowSwap && tile.civilianUnit!!.owner == unit.owner))
|
||||
&& (tile.militaryUnit == null || tile.militaryUnit!!.owner == unit.owner)
|
||||
else
|
||||
// can skip checking for airUnit since not a city
|
||||
(tile.militaryUnit == null || (canSwap && tile.militaryUnit!!.owner == unit.owner))
|
||||
(tile.militaryUnit == null || (allowSwap && tile.militaryUnit!!.owner == unit.owner))
|
||||
&& (tile.civilianUnit == null || tile.civilianUnit!!.owner == unit.owner || unit.civ.isAtWarWith(tile.civilianUnit!!.civ))
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user