mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-11 11:04:05 +09:00
fixed a bug where non-solid blocks would still placed indefinitely
This commit is contained in:
@@ -44,8 +44,13 @@ object BlockBase {
|
||||
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 || BlockCodex[terrainUnderCursor].isActorBlock))
|
||||
// return false if there is a same tile already (including non-solid!)
|
||||
if (isWall && wallUnderCursor == itemID || !isWall && terrainUnderCursor == itemID)
|
||||
return@mouseInInteractableRange -1L
|
||||
|
||||
// return false if there is a "solid" tile already
|
||||
if (isWall && BlockCodex[wallUnderCursor].isSolid ||
|
||||
!isWall && (BlockCodex[terrainUnderCursor].isSolid || BlockCodex[terrainUnderCursor].isActorBlock))
|
||||
return@mouseInInteractableRange -1L
|
||||
|
||||
// filter passed, do the job
|
||||
|
||||
@@ -10,6 +10,7 @@ import net.torvald.terrarum.gameitems.mouseInInteractableRange
|
||||
import net.torvald.terrarum.itemproperties.Material
|
||||
import net.torvald.terrarum.modulebasegame.TerrarumIngame
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.FixtureBase
|
||||
import net.torvald.terrarum.modulebasegame.gameactors.IngamePlayer
|
||||
import net.torvald.terrarumsansbitmap.gdx.TextureRegionPack
|
||||
import java.util.concurrent.atomic.AtomicBoolean
|
||||
import java.util.concurrent.atomic.AtomicReference
|
||||
@@ -86,7 +87,7 @@ open class FixtureItemBase(originalID: ItemID, val fixtureClassName: String) : G
|
||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float) = mouseInInteractableRange(actor) {
|
||||
val item = ghostItem.getAndSet(makeFixture()) // renew the "ghost" otherwise you'll be spawning exactly the same fixture again; old ghost will be returned
|
||||
|
||||
if (item.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY)) 1 else -1
|
||||
if (item.spawn(Terrarum.mouseTileX, Terrarum.mouseTileY, if (actor is IngamePlayer) actor.uuid else null)) 1 else -1
|
||||
// return true when placed, false when cannot be placed
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user