@tool
class_name SetPlayerPriorityTarget extends ActionLeaf
## Set the player as a pursuit target if the grunk alert level is above a priority threshold.

## Blackboard key to set.
@export var blackboard_key := "pursuit_target"

## Set the player as target only if the grunk alert level is greater than or equal to this.
@export var alert_threshold := 3


func tick(_actor: Node, blackboard: Blackboard) -> int:
	if Game.manager.alert_level >= alert_threshold and is_instance_valid(Player.instance):
		blackboard.set_value(blackboard_key, Player.instance)
		return SUCCESS
	return FAILURE
