mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-13 03:54:06 +09:00
fix: barehand action is not draggable
This commit is contained in:
@@ -117,7 +117,8 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
|||||||
GameItem.Category.TOOL,
|
GameItem.Category.TOOL,
|
||||||
GameItem.Category.WALL,
|
GameItem.Category.WALL,
|
||||||
GameItem.Category.WIRE,
|
GameItem.Category.WIRE,
|
||||||
GameItem.Category.BLOCK
|
GameItem.Category.BLOCK,
|
||||||
|
null // empty hands won't prevent dragging for barehand action
|
||||||
)
|
)
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
@@ -129,25 +130,28 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
|
|||||||
// Use item: assuming the player has only one effective grip (EquipPosition.HAND_GRIP)
|
// Use item: assuming the player has only one effective grip (EquipPosition.HAND_GRIP)
|
||||||
// don't separate Player from this! Physics will break, esp. airborne manoeuvre
|
// don't separate Player from this! Physics will break, esp. airborne manoeuvre
|
||||||
if (!terrarumIngame.paused) {
|
if (!terrarumIngame.paused) {
|
||||||
|
val actor = terrarumIngame.actorNowPlaying
|
||||||
|
val itemOnGrip = terrarumIngame.actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)
|
||||||
// fire world click events; the event is defined as Ingame's (or any others') WorldClick event
|
// fire world click events; the event is defined as Ingame's (or any others') WorldClick event
|
||||||
|
|
||||||
// DON'T DO UI-FILTERING HERE; they're already done on ingame.worldPrimaryClickStart
|
// DON'T DO UI-FILTERING HERE; they're already done on ingame.worldPrimaryClickStart
|
||||||
// also, some UIs should NOT affect item usage (e.g. quickslot) and ingame's uiOpened property is doing
|
// also, some UIs should NOT affect item usage (e.g. quickslot) and ingame's uiOpened property is doing
|
||||||
// the very job.
|
// the very job.
|
||||||
|
|
||||||
if (terrarumIngame.actorNowPlaying != null && Terrarum.mouseDown && !worldPrimaryClickLatched) {
|
if (actor != null && Terrarum.mouseDown && !worldPrimaryClickLatched) {
|
||||||
terrarumIngame.worldPrimaryClickStart(terrarumIngame.actorNowPlaying!!, App.UPDATE_RATE)
|
terrarumIngame.worldPrimaryClickStart(actor, App.UPDATE_RATE)
|
||||||
worldPrimaryClickLatched = true
|
worldPrimaryClickLatched = true
|
||||||
}
|
}
|
||||||
if (Gdx.input.isButtonPressed(App.getConfigInt("config_mousesecondary"))) {
|
if (actor != null && Gdx.input.isButtonPressed(App.getConfigInt("config_mousesecondary"))) {
|
||||||
terrarumIngame.worldSecondaryClickStart(terrarumIngame.actorNowPlaying!!, App.UPDATE_RATE)
|
terrarumIngame.worldSecondaryClickStart(actor, App.UPDATE_RATE)
|
||||||
}
|
}
|
||||||
|
|
||||||
// unlatch when:
|
// unlatch when:
|
||||||
// - not clicking anymore
|
// - not clicking anymore
|
||||||
// - using any item that is not fixture (blocks, picks)
|
// - using any item that is not fixture (blocks, picks)
|
||||||
if (!Terrarum.mouseDown ||
|
// DON'T unlatch when:
|
||||||
inventoryCategoryAllowClickAndDrag.contains(ItemCodex[terrarumIngame.actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)]?.inventoryCategory)) {
|
// - performing barehand action
|
||||||
|
if (!Terrarum.mouseDown || inventoryCategoryAllowClickAndDrag.contains(ItemCodex[itemOnGrip]?.inventoryCategory)) {
|
||||||
worldPrimaryClickLatched = false
|
worldPrimaryClickLatched = false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -632,12 +632,6 @@ 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)]
|
||||||
// bring up the UIs of the fixtures (e.g. crafting menu from a crafting table)
|
// bring up the UIs of the fixtures (e.g. crafting menu from a crafting table)
|
||||||
|
|
||||||
// TODO actorsUnderMouse: support ROUNDWORLD
|
|
||||||
val actorsUnderMouse: List<FixtureBase> = getActorsAt(Terrarum.mouseX, Terrarum.mouseY).filterIsInstance<FixtureBase>()
|
|
||||||
if (actorsUnderMouse.size > 1) {
|
|
||||||
App.printdbgerr(this, "Multiple fixtures at world coord ${Terrarum.mouseX}, ${Terrarum.mouseY}")
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|
||||||
// #1. If ~~there is no UI under and~~ I'm holding an item, use it
|
// #1. If ~~there is no UI under and~~ I'm holding an item, use it
|
||||||
@@ -659,6 +653,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
|
|||||||
override fun worldPrimaryClickEnd(actor: ActorWithBody, delta: Float) {
|
override fun worldPrimaryClickEnd(actor: ActorWithBody, delta: Float) {
|
||||||
val canPerformBarehandAction = actor.scale * actor.baseHitboxH >=
|
val canPerformBarehandAction = actor.scale * actor.baseHitboxH >=
|
||||||
(actor.actorValue.getAsDouble(AVKey.BAREHAND_MINHEIGHT) ?: 4294967296.0)
|
(actor.actorValue.getAsDouble(AVKey.BAREHAND_MINHEIGHT) ?: 4294967296.0)
|
||||||
|
|
||||||
val itemOnGrip = (actor as Pocketed).inventory.itemEquipped.get(GameItem.EquipPosition.HAND_GRIP)
|
val itemOnGrip = (actor as Pocketed).inventory.itemEquipped.get(GameItem.EquipPosition.HAND_GRIP)
|
||||||
ItemCodex[itemOnGrip]?.endPrimaryUse(actor, delta)
|
ItemCodex[itemOnGrip]?.endPrimaryUse(actor, delta)
|
||||||
|
|
||||||
|
|||||||
@@ -562,7 +562,7 @@ internal object WeatherMixer : RNGConsumer {
|
|||||||
batch.color = Color.WHITE
|
batch.color = Color.WHITE
|
||||||
}
|
}
|
||||||
|
|
||||||
private val RECIPROCAL_OF_APPARENT_SOLAR_Y_AT_90DEG = 0.0000085
|
private val RECIPROCAL_OF_APPARENT_SOLAR_Y_AT_90DEG = 0.0000077
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mathematical model: https://www.desmos.com/calculator/8dsgigfoys
|
* Mathematical model: https://www.desmos.com/calculator/8dsgigfoys
|
||||||
|
|||||||
Reference in New Issue
Block a user