mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
fix: fixture pickup mess with quickslots and needed empty hands
This commit is contained in:
@@ -795,16 +795,27 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
val itemOnGrip = ItemCodex[(actor as Pocketed).inventory.itemEquipped.get(GameItem.EquipPosition.HAND_GRIP)]
|
val itemOnGrip = ItemCodex[(actor as Pocketed).inventory.itemEquipped.get(GameItem.EquipPosition.HAND_GRIP)]
|
||||||
|
|
||||||
if (!worldSecondaryClickLatch) {
|
if (!worldSecondaryClickLatch) {
|
||||||
// #1. Perform item's secondaryUse
|
// #1. Try to pick up the fixture or dropped item first (if in range and there's something to pick up)
|
||||||
val consumptionSuccessful = itemOnGrip?.startSecondaryUse(actor, delta) ?: -1
|
val pickupSuccessful = mouseInInteractableRange(actor) { mwx, mwy, mtx, mty ->
|
||||||
if (consumptionSuccessful > -1)
|
val actorsUnderMouse = getActorsUnderMouse(mwx, mwy)
|
||||||
(actor as Pocketed).inventory.consumeItem(itemOnGrip!!, consumptionSuccessful)
|
val hasPickupableActor = actorsUnderMouse.any {
|
||||||
// #2. If #1 failed, try to pick up the fixture
|
(it is FixtureBase && it.canBeDespawned && System.nanoTime() - it.spawnRequestedTime > 50000000) || // give freshly spawned fixtures 0.05 seconds of immunity
|
||||||
else {
|
(it is DroppedItem && it.noAutoPickup)
|
||||||
mouseInInteractableRange(actor) { mwx, mwy, mtx, mty ->
|
}
|
||||||
pickupFixtureOrDroppedItem(actor, delta, mwx, mwy, mtx, mty)
|
if (hasPickupableActor) {
|
||||||
|
pickupFixtureOrDroppedItem(actor, delta, mwx, mwy, mtx, mty, assignToQuickslot = (itemOnGrip == null))
|
||||||
0L
|
0L
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
-1L
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// #2. If pickup didn't happen, try to perform item's secondaryUse
|
||||||
|
if (pickupSuccessful < 0) {
|
||||||
|
val consumptionSuccessful = itemOnGrip?.startSecondaryUse(actor, delta) ?: -1
|
||||||
|
if (consumptionSuccessful > -1)
|
||||||
|
(actor as Pocketed).inventory.consumeItem(itemOnGrip!!, consumptionSuccessful)
|
||||||
}
|
}
|
||||||
|
|
||||||
worldSecondaryClickLatch = true
|
worldSecondaryClickLatch = true
|
||||||
|
|||||||
Reference in New Issue
Block a user