mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-15 21:14:04 +09:00
fixture pickup and mining works except for the dropping of a mined fixture
This commit is contained in:
@@ -665,7 +665,7 @@ open class ActorHumanoid : ActorWithBody, Controllable, Pocketed, Factionable, L
|
||||
// make quickslot work
|
||||
if (key == AVKey.__PLAYER_QUICKSLOTSEL && value != null) {
|
||||
// ONLY FOR HAND_GRIPs!!
|
||||
val quickBarItem = ItemCodex[inventory.getQuickslot(actorValue.getAsInt(key)!!)?.itm]
|
||||
val quickBarItem = ItemCodex[inventory.getQuickslotItem(actorValue.getAsInt(key)!!)?.itm]
|
||||
|
||||
if (quickBarItem != null && quickBarItem.equipPosition == GameItem.EquipPosition.HAND_GRIP) {
|
||||
equipItem(quickBarItem)
|
||||
|
||||
@@ -47,16 +47,22 @@ class ActorInventory() : FixtureInventory() {
|
||||
actor.unequipItem(existingItem.itm)
|
||||
// also unequip on the quickslot
|
||||
actor.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)?.let {
|
||||
setQuickBar(it, null)
|
||||
setQuickslotItem(it, null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun setQuickBar(slot: Int, dynamicID: ItemID?) {
|
||||
fun setQuickslotItem(slot: Int, dynamicID: ItemID?) {
|
||||
quickSlot[slot] = dynamicID
|
||||
}
|
||||
|
||||
fun getQuickslot(slot: Int): InventoryPair? = invSearchByDynamicID(quickSlot[slot])
|
||||
fun setQuickslotItemAtSelected(dynamicID: ItemID?) {
|
||||
actor.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)?.let {
|
||||
setQuickslotItem(it, dynamicID)
|
||||
}
|
||||
}
|
||||
|
||||
fun getQuickslotItem(slot: Int): InventoryPair? = invSearchByDynamicID(quickSlot[slot])
|
||||
|
||||
fun consumeItem(item: GameItem) {
|
||||
val actor = this.actor as Actor
|
||||
@@ -85,7 +91,7 @@ class ActorInventory() : FixtureInventory() {
|
||||
|
||||
// update quickslot designation as the item is being unpacked (e.g. using fresh new pickaxe)
|
||||
actor.actorValue.getAsInt(AVKey.__PLAYER_QUICKSLOTSEL)?.let {
|
||||
setQuickBar(it, newItem.dynamicID)
|
||||
setQuickslotItem(it, newItem.dynamicID)
|
||||
}
|
||||
|
||||
// FIXME now damage meter (vital) is broken
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.torvald.terrarum.gameactors.ActorWithBody
|
||||
import net.torvald.terrarum.gameactors.PhysProperties
|
||||
import net.torvald.terrarum.gameitems.ItemID
|
||||
import net.torvald.terrarum.gameworld.fmod
|
||||
import net.torvald.terrarum.modulebasegame.gameitems.FixtureItemBase
|
||||
import net.torvald.terrarum.ui.UICanvas
|
||||
import org.dyn4j.geometry.Vector2
|
||||
|
||||
@@ -36,7 +37,9 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
|
||||
protected constructor() : super(RenderOrder.BEHIND, PhysProperties.IMMOBILE, null)
|
||||
|
||||
constructor(blockBox0: BlockBox,
|
||||
|
||||
constructor(
|
||||
blockBox0: BlockBox,
|
||||
blockBoxProps: BlockBoxProps = BlockBoxProps(0),
|
||||
renderOrder: RenderOrder = RenderOrder.MIDDLE,
|
||||
nameFun: () -> String,
|
||||
@@ -55,6 +58,7 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
App.disposables.add(mainUI)
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tile-wise position of this fixture when it's placed on the world, top-left origin. Null if it's not on the world
|
||||
*/
|
||||
@@ -151,11 +155,11 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
* Removes this instance of the fixture from the world
|
||||
*/
|
||||
open fun despawn() {
|
||||
println("${this.javaClass.simpleName} dispose")
|
||||
printdbg(this, "despawn ${nameFun()}")
|
||||
|
||||
// remove filler block
|
||||
forEachBlockbox { x, y ->
|
||||
world!!.setTileTerrain(x, y, Block.AIR, false)
|
||||
world!!.setTileTerrain(x, y, Block.AIR, true)
|
||||
}
|
||||
|
||||
worldBlockPos = null
|
||||
@@ -173,7 +177,6 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
}
|
||||
|
||||
override fun update(delta: Float) {
|
||||
super.update(delta)
|
||||
// if not flagged to despawn and not actually despawned (which sets worldBlockPos as null), always fill up fillerBlock
|
||||
if (!flagDespawn && worldBlockPos != null) {
|
||||
// for removal-by-player because player is removing the filler block by pick
|
||||
@@ -183,9 +186,10 @@ open class FixtureBase : ActorWithBody, CuedByTerrainChange {
|
||||
}
|
||||
}
|
||||
|
||||
if (flagDespawn) despawn()
|
||||
}
|
||||
// actual actor removal is performed by the TerrarumIngame
|
||||
if (flagDespawn) despawn()
|
||||
// actual actor removal is performed by the TerrarumIngame.killOrKnockdownActors
|
||||
super.update(delta)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user