mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-18 06:24:06 +09:00
fixture clicking action is now integrated into the FixtureBase
This commit is contained in:
@@ -692,6 +692,13 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
private var worldPrimaryClickLatch = false
|
||||
|
||||
private fun fireFixtureInteractEvent(fixture: FixtureBase, mwx: Double, mwy: Double) {
|
||||
if (fixture.mouseUp) {
|
||||
fixture.onInteract(mwx, mwy)
|
||||
}
|
||||
}
|
||||
|
||||
// left click: use held item, attack, pick up fixture if i'm holding a pickaxe or hammer (aka tool), do 'bare hand action' if holding nothing
|
||||
override fun worldPrimaryClickStart(actor: ActorWithBody, delta: Float) {
|
||||
//println("[Ingame] worldPrimaryClickStart $delta")
|
||||
@@ -709,13 +716,25 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
// #1. If ~~there is no UI under and~~ I'm holding an item, use it
|
||||
// #1. If holding an item, use it
|
||||
// don't want to open the UI and use the item at the same time, would ya?
|
||||
if (itemOnGrip != null) {
|
||||
val consumptionSuccessful = itemOnGrip.startPrimaryUse(actor, delta)
|
||||
if (consumptionSuccessful > -1)
|
||||
(actor as Pocketed).inventory.consumeItem(itemOnGrip, consumptionSuccessful)
|
||||
|
||||
// TODO filter blocks/walls/wires/wire cutter
|
||||
if (fixtureUnderMouse != null) {
|
||||
if (!worldPrimaryClickLatch) {
|
||||
mouseInInteractableRange(actor) { mwx, mwy, mtx, mty ->
|
||||
fixtureUnderMouse.let { fixture ->
|
||||
fireFixtureInteractEvent(fixture, mwx, mwy)
|
||||
}
|
||||
0L
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
worldPrimaryClickLatch = true
|
||||
}
|
||||
else {
|
||||
@@ -740,6 +759,10 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
||||
)
|
||||
ui.setAsOpen()
|
||||
}
|
||||
|
||||
if (!uiOpened) {
|
||||
fireFixtureInteractEvent(fixture, mwx, mwy)
|
||||
}
|
||||
}
|
||||
}
|
||||
0L
|
||||
|
||||
Reference in New Issue
Block a user