mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-10 10:34:06 +09:00
fixed a bug where blocks are still consumend even if there is a block already under the cursor
This commit is contained in:
BIN
assets/mods/basegame/sprites/fixtures/door_test.tga
LFS
Normal file
BIN
assets/mods/basegame/sprites/fixtures/door_test.tga
LFS
Normal file
Binary file not shown.
@@ -69,7 +69,7 @@ class ActorInventory() : FixtureInventory() {
|
|||||||
fun consumeItem(item: GameItem, amount: Long = 1L) {
|
fun consumeItem(item: GameItem, amount: Long = 1L) {
|
||||||
val actor = this.actor as Actor
|
val actor = this.actor as Actor
|
||||||
|
|
||||||
if (item.isDynamic && amount != 1L) throw IllegalArgumentException("Dynamic item must be consumed 'once' (expected 1, got $amount)")
|
if (amount < 0) throw IllegalArgumentException("Consuming negative amount of an item (expected >=0, got $amount)")
|
||||||
|
|
||||||
if (item.stackable && !item.isDynamic) {
|
if (item.stackable && !item.isDynamic) {
|
||||||
remove(item, amount)
|
remove(item, amount)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ object BlockBase {
|
|||||||
// FIXME actually it's this code: not recognising hitbox's starting point correctly. Use F9 for visualisation
|
// 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 the above issue is resolved by using intTilewise instead of hInt, but the hitbox itself is still
|
||||||
// FIXME badly defined
|
// FIXME badly defined
|
||||||
|
|
||||||
if (gameItem.inventoryCategory == GameItem.Category.BLOCK) {
|
if (gameItem.inventoryCategory == GameItem.Category.BLOCK) {
|
||||||
var ret1 = true
|
var ret1 = true
|
||||||
ingame.actorContainerActive.forEach {
|
ingame.actorContainerActive.forEach {
|
||||||
@@ -39,20 +39,17 @@ object BlockBase {
|
|||||||
if (!ret1) return@mouseInInteractableRange -1L
|
if (!ret1) return@mouseInInteractableRange -1L
|
||||||
}
|
}
|
||||||
|
|
||||||
// return false if the tile underneath is:
|
val isWall = itemID.startsWith("wall@")
|
||||||
// 0. same tile
|
val terrainUnderCursor = ingame.world.getTileFromTerrain(mouseTile.x, mouseTile.y)
|
||||||
// 1. actorblock
|
val wallUnderCursor = ingame.world.getTileFromWall(mouseTile.x, mouseTile.y)
|
||||||
if (gameItem.inventoryCategory == GameItem.Category.BLOCK &&
|
|
||||||
gameItem.dynamicID == ingame.world.getTileFromTerrain(mouseTile.x, mouseTile.y) ||
|
// return false if there is a tile already
|
||||||
gameItem.inventoryCategory == GameItem.Category.WALL &&
|
if (isWall && BlockCodex[wallUnderCursor].isSolid || !isWall && BlockCodex[terrainUnderCursor].isSolid)
|
||||||
gameItem.dynamicID == "wall@" + ingame.world.getTileFromWall(mouseTile.x, mouseTile.y) ||
|
return@mouseInInteractableRange -1L
|
||||||
BlockCodex[ingame.world.getTileFromTerrain(mouseTile.x, mouseTile.y)].nameKey.contains("ACTORBLOCK_")
|
|
||||||
)
|
|
||||||
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 (itemID.startsWith("wall@")) {
|
if (isWall) {
|
||||||
ingame.world.setTileWall(
|
ingame.world.setTileWall(
|
||||||
mouseTile.x,
|
mouseTile.x,
|
||||||
mouseTile.y,
|
mouseTile.y,
|
||||||
|
|||||||
Reference in New Issue
Block a user