extends Reference

const NAME = "holding_item"
const raw_yam = preload("res://item_types/raw_yam.tres")

var ctx = null

func _init():
	pass

func enter_from(state):
	if ctx.get_node("%item_holder").item_in_hold.item_type == raw_yam:
		ctx.get_node("coin_machine").enabled = true
		ctx.get_node("%item_holder").add_enabled = false
		ctx.get_node("%item_holder").remove_enabled = false
	else:
		ctx.get_node("coin_machine").enabled = false
		ctx.get_node("%item_holder").add_enabled = true
		ctx.get_node("%item_holder").remove_enabled = true

func exit_to(state):
	pass

func on_coin_machine_coin_requirement_met(player):
	if ctx.get_node("%item_holder").item_in_hold.item_type == raw_yam:
		ctx.change_state(ctx.StateCooking.new())

func on_cook_timer_timeout():
	assert(false)

func on_item_holder_item_changed(item):
	if item == null:
		ctx.change_state(ctx.StateIdle.new())
	else:
		ctx.change_state(ctx.StateHoldingItem.new())
