extends Spatial

export var grow_time: float = 2.0

class GrowerStateIdle:
	func _on_coin_machine_coin_requirement_met(player):
		pass

	func _on_grow_timer_timeout():
		pass

	func _on_item_holder_item_changed(item):
		pass

class GrowerStateGrowing:
	func _on_coin_machine_coin_requirement_met(player):
		pass

	func _on_grow_timer_timeout():
		pass

	func _on_item_holder_item_changed(item):
		pass

class GrowerStateBlocked:
	func _on_coin_machine_coin_requirement_met(player):
		pass

	func _on_grow_timer_timeout():
		pass

	func _on_item_holder_item_changed(item):
		pass

func _ready():
	$grow_timer.wait_time = grow_time

func _on_coin_machine_coin_requirement_met(player):
	if $grow_timer.is_stopped():
		$coin_machine.enabled = false
		$grow_timer.start()

func _on_grow_timer_timeout():
	var yam = preload("res://scenes/item_pickup.tscn").instance()
	yam.item_name = "yam"
	yam.item_amount = 1
	yam.connect("tree_exited", self, "_on_yam_item_tree_exited")
	$MeshInstance/Yam.visible = true
	add_child(yam)

func _on_yam_item_tree_exited():
	$coin_machine.enabled = true
	$MeshInstance/Yam.visible = false
	add_child(Dialogic.start("yamget"))

func _process(delta):
	$"%status_label".text = "%f" % $grow_timer.time_left

func _on_item_holder_item_changed(item):
	pass # Replace with function body.
