fixture ghost is now red when it cant be placed there

This commit is contained in:
minjaesong
2023-09-28 23:40:58 +09:00
parent ebe63916d7
commit 430de3dcbf
9 changed files with 146 additions and 124 deletions

View File

@@ -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
}
/**