mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
non solid block can be place over actors
This commit is contained in:
@@ -25,15 +25,15 @@ object BlockBase {
|
|||||||
val ingame = Terrarum.ingame!! as TerrarumIngame
|
val ingame = Terrarum.ingame!! as TerrarumIngame
|
||||||
val mousePoint = Point2d(mtx.toDouble(), mty.toDouble())
|
val mousePoint = Point2d(mtx.toDouble(), mty.toDouble())
|
||||||
val mouseTile = Point2i(mtx, mty)
|
val mouseTile = Point2i(mtx, mty)
|
||||||
|
val terrainUnderCursor = ingame.world.getTileFromTerrain(mouseTile.x, mouseTile.y)
|
||||||
|
val wallUnderCursor = ingame.world.getTileFromWall(mouseTile.x, mouseTile.y)
|
||||||
|
val terrProp = BlockCodex[terrainUnderCursor]
|
||||||
|
val wallProp = BlockCodex[wallUnderCursor]
|
||||||
|
val heldTileisWall = itemID.isWall()
|
||||||
|
val heldProp = BlockCodex[itemID]
|
||||||
|
|
||||||
// check for collision with actors (BLOCK only)
|
// check for collision with actors (solid terrain block only)
|
||||||
// FIXME properly fix the collision detection: it OVERRIDES the tiki-torches which should not happen AT ALL
|
if (gameItem.inventoryCategory == GameItem.Category.BLOCK && heldProp.isSolid) {
|
||||||
// FIXME (h)IntTilewiseHitbox is badly defined
|
|
||||||
// FIXME actually it's this code: not recognising hitbox's starting point correctly. Use F9 for visualisation
|
|
||||||
// FIXME the above issue is resolved by using intTilewise instead of hInt, but the hitbox itself is still
|
|
||||||
// FIXME badly defined
|
|
||||||
|
|
||||||
if (gameItem.inventoryCategory == GameItem.Category.BLOCK) {
|
|
||||||
var ret1 = true
|
var ret1 = true
|
||||||
ingame.actorContainerActive.filter { it is ActorWithBody }.forEach { val it = it as ActorWithBody
|
ingame.actorContainerActive.filter { it is ActorWithBody }.forEach { val it = it as ActorWithBody
|
||||||
if ((it is FixtureBase || it.physProp.usePhysics) && it.intTilewiseHitbox.intersects(mousePoint))
|
if ((it is FixtureBase || it.physProp.usePhysics) && it.intTilewiseHitbox.intersects(mousePoint))
|
||||||
@@ -42,22 +42,19 @@ object BlockBase {
|
|||||||
if (!ret1) return@mouseInInteractableRange -1L
|
if (!ret1) return@mouseInInteractableRange -1L
|
||||||
}
|
}
|
||||||
|
|
||||||
val isWall = itemID.isWall()
|
|
||||||
val terrainUnderCursor = ingame.world.getTileFromTerrain(mouseTile.x, mouseTile.y)
|
|
||||||
val wallUnderCursor = ingame.world.getTileFromWall(mouseTile.x, mouseTile.y)
|
|
||||||
|
|
||||||
// return false if there is a same tile already (including non-solid!)
|
// return false if there is a same tile already (including non-solid!)
|
||||||
if (isWall && wallUnderCursor == itemID || !isWall && terrainUnderCursor == itemID)
|
if (heldTileisWall && wallUnderCursor == itemID || !heldTileisWall && terrainUnderCursor == itemID)
|
||||||
return@mouseInInteractableRange -1L
|
return@mouseInInteractableRange -1L
|
||||||
|
|
||||||
// return false if there is a "solid" tile already
|
// return false if there is a "solid" tile already
|
||||||
if (isWall && BlockCodex[wallUnderCursor].isSolid ||
|
if (heldTileisWall && wallProp.isSolid ||
|
||||||
!isWall && !BlockCodex[terrainUnderCursor].hasTag("INCONSEQUENTIAL"))
|
!heldTileisWall && !terrProp.hasTag("INCONSEQUENTIAL"))
|
||||||
return@mouseInInteractableRange -1L
|
return@mouseInInteractableRange -1L
|
||||||
|
|
||||||
// filter passed, do the job
|
// filter passed, do the job
|
||||||
// FIXME this is only useful for Player
|
// FIXME this is only useful for Player
|
||||||
if (isWall) {
|
if (heldTileisWall) {
|
||||||
ingame.world.setTileWall(
|
ingame.world.setTileWall(
|
||||||
mouseTile.x,
|
mouseTile.x,
|
||||||
mouseTile.y,
|
mouseTile.y,
|
||||||
|
|||||||
Reference in New Issue
Block a user