mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-11 00:08:58 +07:00
Tiles 1 step out of bounds of visibility are visible if they're higher than current tile
This commit is contained in:
@ -338,7 +338,7 @@ class TileMap : IsPartOfGameInfoSerialization {
|
||||
isAttackable = false
|
||||
))
|
||||
|
||||
for (i in 1..sightDistance) { // in each layer,
|
||||
for (i in 1..sightDistance+1) { // in each layer,
|
||||
// This is so we don't use tiles in the same distance to "see over",
|
||||
// that is to say, the "viewableTiles.contains(it) check will return false for neighbors from the same distance
|
||||
val tilesToAddInDistanceI = ArrayList<ViewableTile>()
|
||||
@ -346,6 +346,10 @@ class TileMap : IsPartOfGameInfoSerialization {
|
||||
for (cTile in getTilesAtDistance(position, i)) { // for each tile in that layer,
|
||||
val cTileHeight = cTile.tileHeight
|
||||
|
||||
// For the sightdistance+1 layer - that's "one out of sight" - it's only visible if it's higher than the current tile
|
||||
if (i == sightDistance+1 && cTileHeight <= aUnitHeight)
|
||||
continue
|
||||
|
||||
/*
|
||||
Okay so, if we're looking at a tile from height a to one with height c with a MAXIMUM HEIGHT of b in the middle,
|
||||
we have several scenarios:
|
||||
|
@ -163,4 +163,38 @@ class VisibilityTests {
|
||||
assert(!viewableTiles.contains(hill))
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun cannotSee3TilesAwayPlain() {
|
||||
val source = addTile("Grassland", Vector2(0f,0f))
|
||||
addTile("Grassland", Vector2(1f,0f))
|
||||
addTile("Grassland", Vector2(2f,0f))
|
||||
val beyondSight = addTile("Grassland", Vector2(3f,0f))
|
||||
|
||||
val viewableTiles = source.getViewableTilesList(2)
|
||||
assert(!viewableTiles.contains(beyondSight))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun canSeeElevation3Tiles() {
|
||||
val source = addTile("Grassland", Vector2(0f,0f))
|
||||
addTile("Grassland", Vector2(1f,0f))
|
||||
addTile("Grassland", Vector2(2f,0f))
|
||||
val beyondSight = addTile(listOf("Grassland", "Hill"), Vector2(3f,0f))
|
||||
|
||||
val viewableTiles = source.getViewableTilesList(2)
|
||||
assert(viewableTiles.contains(beyondSight))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun cannotSeeHiddenElevation3Tiles() {
|
||||
val source = addTile("Grassland", Vector2(0f,0f))
|
||||
addTile("Grassland", Vector2(1f,0f))
|
||||
addTile(listOf("Grassland", "Forest"), Vector2(2f,0f))
|
||||
val beyondSight = addTile(listOf("Grassland", "Hill"), Vector2(3f,0f))
|
||||
|
||||
val viewableTiles = source.getViewableTilesList(2)
|
||||
assert(!viewableTiles.contains(beyondSight))
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user