wall render bug fixed

- wall wouldn't render if transparent-yet-sold tiles like glass is placed on top of it
This commit is contained in:
minjaesong
2017-07-15 00:02:00 +09:00
parent 75cd080023
commit dfa2a0a86d
12 changed files with 242 additions and 155 deletions

View File

@@ -27,7 +27,7 @@ import java.util.zip.GZIPInputStream
* Created by minjaesong on 16-01-19.
*/
object BlocksDrawer {
private val world: GameWorld = Terrarum.ingame!!.world
private inline val world: GameWorld; get() = Terrarum.ingame!!.world
private val TILE_SIZE = FeaturesDrawer.TILE_SIZE
private val TILE_SIZEF = FeaturesDrawer.TILE_SIZE.toFloat()
@@ -385,17 +385,15 @@ object BlocksDrawer {
private fun canIHazRender(mode: Int, x: Int, y: Int) =
(world.getTileFrom(mode, x, y) != 0) && // not an air tile
// for WALLs:
if (mode == WALL)
mode == WALL && (
// DRAW WHEN it is visible and 'is a lip'
!BlockCodex[world.getTileFromTerrain(x, y) ?: 0].isSolid ||
!(BlockCodex[world.getTileFromTerrain(x, y) ?: 0].isSolid &&
((BlockCodex[world.getTileFromTerrain(x, y - 1) ?: 0].isSolid && BlockCodex[world.getTileFromTerrain(x, y + 1) ?: 0].isSolid)
&&
(BlockCodex[world.getTileFromTerrain(x - 1, y) ?: 0].isSolid && BlockCodex[world.getTileFromTerrain(x + 1, y + 1) ?: 0].isSolid)
)
)
)
if (mode == WALL) { // DRAW WHEN it is visible and 'is a lip'
( BlockCodex[world.getTileFromTerrain(x, y) ?: 0].isClear ||
!
((!BlockCodex[world.getTileFromTerrain(x, y - 1) ?: 0].isClear && !BlockCodex[world.getTileFromTerrain(x, y + 1) ?: 0].isClear)
&&
(!BlockCodex[world.getTileFromTerrain(x - 1, y) ?: 0].isClear && !BlockCodex[world.getTileFromTerrain(x + 1, y + 1) ?: 0].isClear)
)
)
}
else
true