mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +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) {
|
||||
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) {
|
||||
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 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
|
||||
ingame.actorContainerActive.forEach {
|
||||
@@ -39,20 +39,17 @@ object BlockBase {
|
||||
if (!ret1) return@mouseInInteractableRange -1L
|
||||
}
|
||||
|
||||
// return false if the tile underneath is:
|
||||
// 0. same tile
|
||||
// 1. actorblock
|
||||
if (gameItem.inventoryCategory == GameItem.Category.BLOCK &&
|
||||
gameItem.dynamicID == ingame.world.getTileFromTerrain(mouseTile.x, mouseTile.y) ||
|
||||
gameItem.inventoryCategory == GameItem.Category.WALL &&
|
||||
gameItem.dynamicID == "wall@" + ingame.world.getTileFromWall(mouseTile.x, mouseTile.y) ||
|
||||
BlockCodex[ingame.world.getTileFromTerrain(mouseTile.x, mouseTile.y)].nameKey.contains("ACTORBLOCK_")
|
||||
)
|
||||
return@mouseInInteractableRange 1L
|
||||
val isWall = itemID.startsWith("wall@")
|
||||
val terrainUnderCursor = ingame.world.getTileFromTerrain(mouseTile.x, mouseTile.y)
|
||||
val wallUnderCursor = ingame.world.getTileFromWall(mouseTile.x, mouseTile.y)
|
||||
|
||||
// return false if there is a tile already
|
||||
if (isWall && BlockCodex[wallUnderCursor].isSolid || !isWall && BlockCodex[terrainUnderCursor].isSolid)
|
||||
return@mouseInInteractableRange -1L
|
||||
|
||||
// filter passed, do the job
|
||||
// FIXME this is only useful for Player
|
||||
if (itemID.startsWith("wall@")) {
|
||||
if (isWall) {
|
||||
ingame.world.setTileWall(
|
||||
mouseTile.x,
|
||||
mouseTile.y,
|
||||
|
||||
Reference in New Issue
Block a user