@tool
class_name BodyInArea extends ConditionLeaf
## Is the body at the given blackboard key in the given area?
##
## Returns FAILURE if there is no Node3D at the given blackboard key.

## Blackboard key of the body to check.
@export var blackboard_key := "target"
## Area3D to check for the target body.
@export var area: Area3D


func tick(_actor: Node, blackboard: Blackboard) -> int:
	@warning_ignore("unsafe_cast")
	var body := blackboard.get_value(blackboard_key) as Node3D
	return SUCCESS if is_instance_valid(body) and body in area.get_overlapping_bodies() else FAILURE
