fix: barehand action is not draggable

This commit is contained in:
minjaesong
2023-09-26 13:15:48 +09:00
parent 2f52e46bad
commit bee939877b
3 changed files with 13 additions and 14 deletions

View File

@@ -117,7 +117,8 @@ class IngameController(val terrarumIngame: TerrarumIngame) : InputAdapter() {
GameItem.Category.TOOL,
GameItem.Category.WALL,
GameItem.Category.WIRE,
GameItem.Category.BLOCK
GameItem.Category.BLOCK,
null // empty hands won't prevent dragging for barehand action
)
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)
// don't separate Player from this! Physics will break, esp. airborne manoeuvre
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
// 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
// the very job.
if (terrarumIngame.actorNowPlaying != null && Terrarum.mouseDown && !worldPrimaryClickLatched) {
terrarumIngame.worldPrimaryClickStart(terrarumIngame.actorNowPlaying!!, App.UPDATE_RATE)
if (actor != null && Terrarum.mouseDown && !worldPrimaryClickLatched) {
terrarumIngame.worldPrimaryClickStart(actor, App.UPDATE_RATE)
worldPrimaryClickLatched = true
}
if (Gdx.input.isButtonPressed(App.getConfigInt("config_mousesecondary"))) {
terrarumIngame.worldSecondaryClickStart(terrarumIngame.actorNowPlaying!!, App.UPDATE_RATE)
if (actor != null && Gdx.input.isButtonPressed(App.getConfigInt("config_mousesecondary"))) {
terrarumIngame.worldSecondaryClickStart(actor, App.UPDATE_RATE)
}
// unlatch when:
// - not clicking anymore
// - using any item that is not fixture (blocks, picks)
if (!Terrarum.mouseDown ||
inventoryCategoryAllowClickAndDrag.contains(ItemCodex[terrarumIngame.actorNowPlaying?.inventory?.itemEquipped?.get(GameItem.EquipPosition.HAND_GRIP)]?.inventoryCategory)) {
// DON'T unlatch when:
// - performing barehand action
if (!Terrarum.mouseDown || inventoryCategoryAllowClickAndDrag.contains(ItemCodex[itemOnGrip]?.inventoryCategory)) {
worldPrimaryClickLatched = false
}

View File

@@ -632,12 +632,6 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
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)
// 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
@@ -659,6 +653,7 @@ open class TerrarumIngame(batch: FlippingSpriteBatch) : IngameInstance(batch) {
override fun worldPrimaryClickEnd(actor: ActorWithBody, delta: Float) {
val canPerformBarehandAction = actor.scale * actor.baseHitboxH >=
(actor.actorValue.getAsDouble(AVKey.BAREHAND_MINHEIGHT) ?: 4294967296.0)
val itemOnGrip = (actor as Pocketed).inventory.itemEquipped.get(GameItem.EquipPosition.HAND_GRIP)
ItemCodex[itemOnGrip]?.endPrimaryUse(actor, delta)

View File

@@ -562,7 +562,7 @@ internal object WeatherMixer : RNGConsumer {
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