extends Node2D

onready var activatorArea = $"%ActivatorArea"
onready var indicatorPlayer = $"%IndicatorPlayer"
onready var signalManager := get_tree().root.get_child(3).get_node("%SignalManager")
onready var unactivatable_timer := $Timer

var activatable = false

func _process(delta):
	if activatable && Input.is_action_just_released("interact"):
		selfActivate()
		signalManager.emit_signal("unlocked", "gateblock")


func selfActivate():
	indicatorPlayer.play("onning")
	#TODO dis importante
	activatorArea.set_deferred("monitoring", false)


func _on_ActivatorArea_area_entered(area:Area2D) -> void:
		$Label.visible = true
		activatable = true

func _on_ActivatorArea_area_exited(area:Area2D) -> void:
		unactivatable_timer.start()

func _on_Timer_timeout():
	$Label.visible = false
	activatable = false
