fixed a bug where the barehand action would do nothing

This commit is contained in:
minjaesong
2022-01-14 15:44:37 +09:00
parent a7357c00a9
commit b87dc1f28b
2 changed files with 2 additions and 3 deletions

View File

@@ -372,7 +372,6 @@ fun mouseInInteractableRange(actor: ActorWithBody, action: () -> Boolean): Boole
if (dist <= distMax.sqr()) return action() else return false
}
fun mouseInInteractableRangeTools(actor: ActorWithBody, item: GameItem?, reachMultiplierInTiles: (Int) -> Double = { it.toDouble() }, action: () -> Boolean): Boolean {
if (item == null) return false
val mousePos1 = Vector2(Terrarum.mouseX, Terrarum.mouseY)
val mousePos2 = Vector2(Terrarum.mouseX + INGAME.world.width * TILE_SIZED, Terrarum.mouseY)
val mousePos3 = Vector2(Terrarum.mouseX - INGAME.world.width * TILE_SIZED, Terrarum.mouseY)
@@ -381,7 +380,7 @@ fun mouseInInteractableRangeTools(actor: ActorWithBody, item: GameItem?, reachMu
val reachBonus = (actor.actorValue.getAsDouble(AVKey.REACHBUFF) ?: 1.0) * actor.scale
val distMax = actor.actorValue.getAsDouble(AVKey.REACH)!! * reachBonus // perform some error checking here
val toolDistMax = (TILE_SIZED * reachMultiplierInTiles(item.material.toolReach)) * reachBonus
val toolDistMax = (TILE_SIZED * reachMultiplierInTiles(item?.material?.toolReach ?: Int.MAX_VALUE)) * reachBonus
if (dist <= minOf(toolDistMax, distMax).sqr()) return action() else return false
}