mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-10 07:16:54 +07:00
Resolved #6559 - Air units with no space in the city cannot be selected for construction
This commit is contained in:
parent
e296604b24
commit
dbaf4edb2f
@ -129,7 +129,8 @@ class RejectionReasons: HashSet<RejectionReasonInstance>() {
|
||||
RejectionReason.PopulationRequirement,
|
||||
RejectionReason.ConsumesResources,
|
||||
RejectionReason.CanOnlyBePurchased,
|
||||
RejectionReason.MaxNumberBuildable
|
||||
RejectionReason.MaxNumberBuildable,
|
||||
RejectionReason.NoPlaceToPutUnit
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -184,7 +185,8 @@ enum class RejectionReason(val shouldShow: Boolean, val errorMessage: String) {
|
||||
|
||||
PopulationRequirement(true, "Requires more population"),
|
||||
|
||||
NoSettlerForOneCityPlayers(false, "No settlers for city-states or one-city challengers");
|
||||
NoSettlerForOneCityPlayers(false, "No settlers for city-states or one-city challengers"),
|
||||
NoPlaceToPutUnit(true, "No space to place this unit");
|
||||
|
||||
fun toInstance(errorMessage: String = this.errorMessage,
|
||||
shouldShow: Boolean = this.shouldShow): RejectionReasonInstance {
|
||||
|
@ -1008,7 +1008,7 @@ class MapUnit {
|
||||
fun canTransport(unit: MapUnit): Boolean {
|
||||
if (owner != unit.owner) return false
|
||||
if (!isTransportTypeOf(unit)) return false
|
||||
if (unit.getMatchingUniques(UniqueType.CannotBeCarriedBy).any{matchesFilter(it.params[0])}) return false
|
||||
if (unit.getMatchingUniques(UniqueType.CannotBeCarriedBy).any { matchesFilter(it.params[0]) }) return false
|
||||
if (currentTile.airUnits.count { it.isTransported } >= carryCapacity(unit)) return false
|
||||
return true
|
||||
}
|
||||
|
@ -351,6 +351,12 @@ class BaseUnit : RulesetObject(), INonPerpetualConstruction {
|
||||
val rejectionReasons = RejectionReasons()
|
||||
if (isWaterUnit() && !cityConstructions.cityInfo.isCoastal())
|
||||
rejectionReasons.add(RejectionReason.WaterUnitsInCoastalCities)
|
||||
if (isAirUnit()) {
|
||||
val fakeUnit = getMapUnit(cityConstructions.cityInfo.civInfo)
|
||||
val canUnitEnterTile = fakeUnit.movement.canMoveTo(cityConstructions.cityInfo.getCenterTile())
|
||||
if (!canUnitEnterTile)
|
||||
rejectionReasons.add(RejectionReason.NoPlaceToPutUnit)
|
||||
}
|
||||
val civInfo = cityConstructions.cityInfo.civInfo
|
||||
for (unique in uniqueObjects) {
|
||||
@Suppress("NON_EXHAUSTIVE_WHEN")
|
||||
|
Loading…
Reference in New Issue
Block a user