extends Area2D
class_name Slot
signal clicked(slot: Slot)

var i = 0
var plant = null

func _ready():
    set_pickable(true)
    connect("input_event", _on_input_event)
    connect("mouse_entered", _on_mouse_entered)
    connect("mouse_exited", _on_mouse_exited)

func _on_input_event(viewport: Node, event: InputEvent, shape_idx: int):
    if event.is_action_released("lmb"):
        i += 1
        if i == 2:
            emit_signal("clicked", self)
            i = 0
        
func _on_mouse_entered():
    $Slot.set_modulate(Color(1.0, 1.0, 1.0, 1.0))

func _on_mouse_exited():
    $Slot.set_modulate(Color(1.0, 1.0, 1.0, 0.5))

func set_plant(plant_: Node):
    plant = plant_
    plant.set_position(get_global_position())
