Nuke blast simulation no longer shows invisible units. (#9913)

* Nuke blast simulation no longer shows invisible units.

* Changed code to look better.

* Improved readability.
This commit is contained in:
Oskar Niesen 2023-08-16 09:59:30 -05:00 committed by GitHub
parent 9889bfcd1d
commit 65f884cb54
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -695,7 +695,9 @@ class WorldMapHolder(
val attackableTiles: List<AttackableTile> =
if (nukeBlastRadius >= 0)
selectedTile!!.getTilesInDistance(nukeBlastRadius)
.filter { it.getFirstUnit() != null }
// Should not display invisible submarine units even if the tile is visible.
.filter { targetTile -> (targetTile.isVisible(unit.civ) && targetTile.getUnits().any { !it.isInvisible(unit.civ) })
|| (targetTile.isCityCenter() && unit.civ.hasExplored(targetTile)) }
.map { AttackableTile(unit.getTile(), it, 1f, null) }
.toList()
else BattleHelper.getAttackableEnemies(unit, unit.movement.getDistanceToTiles())