mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 03:24:06 +09:00
fixture ghost is now red when it cant be placed there
This commit is contained in:
@@ -384,13 +384,13 @@ abstract class GameItem(val originalID: ItemID) : Comparable<GameItem>, Cloneabl
|
||||
* The reach is calculated using the actor's reach, reach buff actorvalue and the actor's scale.
|
||||
*
|
||||
* @param actor actor to check the reach
|
||||
* @param action returns non-negative integer if the action was successfully performed
|
||||
* @param action (Double, Double, Int, Int) to Long; takes `Terrarum.mouseX`, `Terrarum.mouseY`, `Terrarum.mouseTileX`, `Terrarum.mouseTileY` as an input and returns non-negative integer if the action was successfully performed
|
||||
* @return an amount to remove from the inventory (>= 0); -1 if the action failed or not in interactable range
|
||||
*/
|
||||
fun mouseInInteractableRange(actor: ActorWithBody, action: () -> Long): Long {
|
||||
fun mouseInInteractableRange(actor: ActorWithBody, action: (Double, Double, Int, Int) -> Long): Long {
|
||||
val mousePos1 = Vector2(Terrarum.mouseX, Terrarum.mouseY)
|
||||
val distMax = actor.actorValue.getAsDouble(AVKey.REACH)!! * (actor.actorValue.getAsDouble(AVKey.REACHBUFF) ?: 1.0) * actor.scale // perform some error checking here
|
||||
return if (distBetween(actor, mousePos1) <= distMax) action() else -1
|
||||
return if (distBetween(actor, mousePos1) <= distMax) action(Terrarum.mouseX, Terrarum.mouseY, Terrarum.mouseTileX, Terrarum.mouseTileY) else -1
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user