mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 23:37:31 +07:00
Create Cannot Move Unique (#7855)
* Create Cannot Move Unique * Covering other potential avenues of moving * Remove transient, fix Air Units movement range UI * Better fix for AirUnits
This commit is contained in:
parent
2a740b9ede
commit
91bb6fa89a
@ -487,6 +487,7 @@ class MapUnit : IsPartOfGameInfoSerialization {
|
||||
}
|
||||
|
||||
fun getMaxMovementForAirUnits(): Int {
|
||||
if (hasUnique(UniqueType.CannotMove)) return getRange() // also used for marking attack range
|
||||
return getRange() * 2
|
||||
}
|
||||
|
||||
|
@ -608,6 +608,7 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
||||
* DOES NOT designate whether we can reach that tile in the current turn
|
||||
*/
|
||||
fun canMoveTo(tile: TileInfo, assumeCanPassThrough: Boolean = false): Boolean {
|
||||
if (unit.hasUnique(UniqueType.CannotMove)) return false
|
||||
if (unit.baseUnit.movesLikeAirUnits())
|
||||
return canAirUnitMoveTo(tile, unit)
|
||||
|
||||
@ -626,6 +627,7 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
||||
}
|
||||
|
||||
private fun canAirUnitMoveTo(tile: TileInfo, unit: MapUnit): Boolean {
|
||||
if (unit.hasUnique(UniqueType.CannotMove)) return false
|
||||
// landing in the city
|
||||
if (tile.isCityCenter()) {
|
||||
if (tile.airUnits.filter { !it.isTransported }.size < 6 && tile.getCity()?.civInfo == unit.civInfo)
|
||||
@ -641,6 +643,7 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
||||
|
||||
// Can a paratrooper land at this tile?
|
||||
fun canParadropOn(destination: TileInfo): Boolean {
|
||||
if (unit.hasUnique(UniqueType.CannotMove)) return false
|
||||
// Can only move to land tiles within range that are visible and not impassible
|
||||
// Based on some testing done in the base game
|
||||
if (!destination.isLand || destination.isImpassible() || !unit.civInfo.viewableTiles.contains(destination)) return false
|
||||
@ -657,6 +660,7 @@ class UnitMovementAlgorithms(val unit: MapUnit) {
|
||||
* because optimization on this function results in massive benefits!
|
||||
*/
|
||||
fun canPassThrough(tile: TileInfo): Boolean {
|
||||
if (unit.hasUnique(UniqueType.CannotMove)) return false
|
||||
if (tile.isImpassible()) {
|
||||
// special exception - ice tiles are technically impassible, but some units can move through them anyway
|
||||
// helicopters can pass through impassable tiles like mountains
|
||||
|
@ -455,6 +455,7 @@ enum class UniqueType(val text: String, vararg targets: UniqueTarget, val flags:
|
||||
DestroysImprovementUponAttack("Destroys tile improvements when attacking", UniqueTarget.Unit),
|
||||
|
||||
// The following block gets cached in MapUnit for faster getMovementCostBetweenAdjacentTiles
|
||||
CannotMove("Cannot move", UniqueTarget.Unit),
|
||||
DoubleMovementOnTerrain("Double movement in [terrainFilter]", UniqueTarget.Unit),
|
||||
AllTilesCost1Move("All tiles cost 1 movement", UniqueTarget.Unit),
|
||||
CanPassImpassable("Can pass through impassable tiles", UniqueTarget.Unit),
|
||||
|
@ -30,6 +30,7 @@ import com.unciv.models.AttackableTile
|
||||
import com.unciv.models.UncivSound
|
||||
import com.unciv.models.helpers.MapArrowType
|
||||
import com.unciv.models.helpers.MiscArrowTypes
|
||||
import com.unciv.models.ruleset.unique.UniqueType
|
||||
import com.unciv.ui.UncivStage
|
||||
import com.unciv.ui.audio.SoundPlayer
|
||||
import com.unciv.ui.images.ImageGetter
|
||||
|
Loading…
Reference in New Issue
Block a user