extends Sprite2D

@export var nextScene : PackedScene


func _process(_delta: float) -> void:
	var enemies = len(get_tree().get_nodes_in_group("enemy"))
	var player = get_tree().get_first_node_in_group("player")

	if enemies == 0 and player:
		material.set_shader_parameter("intensity", 1.7)
		$MagicCircle.visible = true
		$Text.visible = true
		var player_dist = player.global_position.distance_to(global_position)
		if Input.is_action_just_pressed("interact") && player_dist < 70:
			SceneTransition.change_scene(nextScene)
	else:
		material.set_shader_parameter("intensity", 0)
		$MagicCircle.visible = false
		$Text.visible = false
