mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-10 22:01:52 +09:00
WIP platforms, at least "should I collide with this?" is one single function
This commit is contained in:
@@ -109,7 +109,8 @@ object BlockCodex {
|
||||
|
||||
//prop.isFluid = boolVal(record, "fluid")
|
||||
prop.isSolid = boolVal(record, "solid")
|
||||
prop.isClear = boolVal(record, "clear")
|
||||
//prop.isClear = boolVal(record, "clear")
|
||||
prop.isPlatform = boolVal(record, "plat")
|
||||
prop.isWallable = boolVal(record, "wall")
|
||||
prop.isFallable = boolVal(record, "fall")
|
||||
prop.isVertFriction = boolVal(record, "fv")
|
||||
|
||||
@@ -28,7 +28,8 @@ class BlockProp {
|
||||
var viscosity: Int = 0
|
||||
|
||||
var isSolid: Boolean = false
|
||||
var isClear: Boolean = false
|
||||
//var isClear: Boolean = false
|
||||
var isPlatform: Boolean = false
|
||||
var isWallable: Boolean = false
|
||||
var isVertFriction: Boolean = false
|
||||
|
||||
|
||||
@@ -627,9 +627,9 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
|
||||
|
||||
forEachOccupyingTilePos(stepBox) {
|
||||
val tileCoord = LandUtil.resolveBlockAddr(world!!, it)
|
||||
val tileProp = BlockCodex.getOrNull(world!!.getTileFromTerrain(tileCoord.first, tileCoord.second))
|
||||
val tile = world!!.getTileFromTerrain(tileCoord.first, tileCoord.second) ?: Block.STONE
|
||||
|
||||
if (tileProp == null || tileProp.isSolid) {
|
||||
if (shouldICollideWithThis(tile)) {
|
||||
affectingTiles.add(it)
|
||||
}
|
||||
}
|
||||
@@ -946,15 +946,35 @@ open class ActorWBMovable(renderOrder: RenderOrder, val immobileBody: Boolean =
|
||||
|
||||
for (y in tyStart..tyEnd) {
|
||||
for (x in txStart..txEnd) {
|
||||
val tile = world!!.getTileFromTerrain(x, y)
|
||||
if (BlockCodex[tile].isSolid)
|
||||
val tile = world!!.getTileFromTerrain(x, y) ?: Block.STONE
|
||||
|
||||
if (shouldICollideWithThis(tile))
|
||||
return true
|
||||
|
||||
// this weird statement means that if's the condition is TRUE, return TRUE;
|
||||
// if the condition is FALSE, do nothing and let succeeding code handle it.
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* If this tile should be treated as "collidable"
|
||||
*
|
||||
* Very straightforward for the actual solid tiles, not so much for the platforms
|
||||
*/
|
||||
private fun shouldICollideWithThis(tile: Int): Boolean {
|
||||
// regular solid block
|
||||
return if (BlockCodex[tile].isSolid)
|
||||
return true
|
||||
// platforms and their necessary conditionals
|
||||
else if (BlockCodex[tile].isPlatform)
|
||||
return true
|
||||
|
||||
else return false
|
||||
}
|
||||
|
||||
private fun getContactingAreaFluid(side: Int, translateX: Int = 0, translateY: Int = 0): Int {
|
||||
if (world == null) return 0
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.torvald.terrarum.worlddrawer
|
||||
/*package net.torvald.terrarum.worlddrawer
|
||||
|
||||
import com.badlogic.gdx.Gdx
|
||||
import com.badlogic.gdx.graphics.Color
|
||||
@@ -721,3 +721,4 @@ object BlocksDrawerOLD {
|
||||
x >= WorldCamera.x.div(TILE_SIZE) && y >= WorldCamera.y.div(TILE_SIZE) &&
|
||||
x <= WorldCamera.x.plus(WorldCamera.width).div(TILE_SIZE) && y <= WorldCamera.y.plus(WorldCamera.width).div(TILE_SIZE)
|
||||
}
|
||||
*/
|
||||
Reference in New Issue
Block a user