extends Sprite2D
class_name Region

@export var scene_to_open : PackedScene

var mouse_over = false
var children = []
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	pass # Replace with function body.


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

func spawn_object():
	SignalBus.region_clicked.emit(scene_to_open, self)
	
	
func _on_area_2d_mouse_entered() -> void:
	modulate = Color.GREEN
	mouse_over = true

func _on_area_2d_mouse_exited() -> void:
	modulate = Color.WHITE
	mouse_over = false
