Chore: Slight getShortestPath simplification

This commit is contained in:
yairm210 2025-01-08 20:19:18 +02:00
parent 50979e8a0e
commit 612375d85d
2 changed files with 10 additions and 8 deletions

View File

@ -106,6 +106,7 @@ class UnitMovement(val unit: MapUnit) {
val damageFreePath = getShortestPath(destination, true)
if (damageFreePath.isNotEmpty()) return damageFreePath
}
if (destination.neighbors.none { isUnknownTileWeShouldAssumeToBePassable(it) || canPassThrough(it) }) {
// edge case where this all of the tiles around the destination are
// explored and known the unit can't pass through any of thoes tiles so we know a priori that no path exists
@ -183,15 +184,15 @@ class UnitMovement(val unit: MapUnit) {
pathfindingCache.setShortestPathCache(destination, path)
return path
} else {
if (movementTreeParents.containsKey(reachableTile)) continue // We cannot be faster than anything existing...
if (!isUnknownTileWeShouldAssumeToBePassable(reachableTile) &&
!canMoveToCache.getOrPut(reachableTile) { canMoveTo(reachableTile) })
// This is a tile that we can't actually enter - either an intermediary tile containing our unit, or an enemy unit/city
continue
movementTreeParents[reachableTile] = tileToCheck
newTilesToCheck.add(reachableTile)
}
if (movementTreeParents.containsKey(reachableTile)) continue // We cannot be faster than anything existing...
if (!isUnknownTileWeShouldAssumeToBePassable(reachableTile) &&
!canMoveToCache.getOrPut(reachableTile) { canMoveTo(reachableTile) })
// This is a tile that we can't actually enter - either an intermediary tile containing our unit, or an enemy unit/city
continue
movementTreeParents[reachableTile] = tileToCheck
newTilesToCheck.add(reachableTile)
}
}

View File

@ -132,6 +132,7 @@ Simple unique parameters are explained by mouseover. Complex parameters are expl
??? example "Gain [amount]-[amount] [stat]"
Example: "Gain [3]-[3] [Culture]"
This unique's effect can be modified with <(modified by game speed)>
Applicable to: Triggerable
??? example "Gain enough Faith for a Pantheon"