mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-08 04:41:51 +09:00
fix: torches can be placed anywhere
This commit is contained in:
@@ -4,6 +4,9 @@ import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import net.torvald.gdx.graphics.Cvec
|
||||
import net.torvald.terrarum.BlockCodex
|
||||
import net.torvald.terrarum.CommonResourcePool
|
||||
import net.torvald.terrarum.INGAME
|
||||
import net.torvald.terrarum.Terrarum
|
||||
import net.torvald.terrarum.TerrarumAppConfiguration.TILE_SIZE
|
||||
import net.torvald.terrarum.blockproperties.Block
|
||||
import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameitems.GameItem
|
||||
@@ -69,7 +72,17 @@ class ItemTorch(originalID: ItemID) : LightIngredientBase(originalID) {
|
||||
override fun getLumCol() = BlockCodex[Block.TORCH].getLumCol(0, 0)
|
||||
|
||||
override fun startPrimaryUse(actor: ActorWithBody, delta: Float): Long {
|
||||
return BlockBase.blockStartPrimaryUse(actor, this, "basegame:176", delta)
|
||||
val mwx = (Terrarum.mouseX / TILE_SIZE).toInt()
|
||||
val mwy = (Terrarum.mouseY / TILE_SIZE).toInt()
|
||||
val wall = BlockCodex[INGAME.world.getTileFromWall(mwx, mwy)]
|
||||
val terr1 = BlockCodex[INGAME.world.getTileFromTerrain(mwx - 1, mwy)]
|
||||
val terr2 = BlockCodex[INGAME.world.getTileFromTerrain(mwx, mwy + 1)]
|
||||
val terr3 = BlockCodex[INGAME.world.getTileFromTerrain(mwx + 1, mwy)]
|
||||
|
||||
if (wall.isSolid || terr1.isSolid || terr2.isSolid || terr3.isSolid)
|
||||
return BlockBase.blockStartPrimaryUse(actor, this, "basegame:176", delta)
|
||||
else
|
||||
return -1L
|
||||
}
|
||||
|
||||
override fun effectWhileEquipped(actor: ActorWithBody, delta: Float) {
|
||||
|
||||
@@ -563,7 +563,7 @@ class UICrafting(val full: UIInventoryFull?) : UICanvas(
|
||||
fun resolveIngredientKey(inventory: FixtureInventory, ingredient: CraftingCodex.CraftingIngredients, product: ItemID): ItemID {
|
||||
val candidate = getItemCandidatesForIngredient(inventory, ingredient).filter { it.itm != product }
|
||||
|
||||
printdbg(this, "resolveIngredientKey product=$product, candidate=$candidate")
|
||||
// printdbg(this, "resolveIngredientKey product=$product, candidate=$candidate")
|
||||
|
||||
return if (ingredient.keyMode == CraftingCodex.CraftingItemKeyMode.TAG) {
|
||||
// filter out the product itself from the ingredient
|
||||
|
||||
Reference in New Issue
Block a user