extends Sprite2D
class_name  EncounterNode

signal reactivated
@export var scene_to_open : PackedScene

var encounter_parent : EncounterParentName
var mouse_over = false


var activating_timer = 0
var activating_timer_max = 120
var activating_timer_min = 60
var children = []
func _ready() -> void:
	pass # Replace with function body.

func deactive():
	activating_timer = randf_range(activating_timer_min,activating_timer_max)

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	if activating_timer > 0:
		activating_timer -= delta
		if activating_timer <= 0:
			reactivated.emit()
		
	if mouse_over and Input.is_action_just_pressed("mouse_click"):
		spawn_object()

func spawn_object():
	SignalBus.encounter_clicked.emit(scene_to_open,self)



func _on_area_2d_mouse_entered() -> void:
	mouse_over = true


func _on_area_2d_mouse_exited() -> void:
	mouse_over = false
