extends Reference const NAME = "cooking" const cooked_yam = preload("res://item_types/cooked_yam.tres") var ctx = null var mat: SpatialMaterial = SpatialMaterial.new() func _init(): mat.albedo_color = Color.red func enter_from(state): ctx.get_node("item_dump").enabled = false ctx.get_node("coin_machine").enabled = false ctx.get_node("%item_holder").add_enabled = false ctx.get_node("%item_holder").remove_enabled = false ctx.get_node("cook_timer").start() ctx.get_node("status_light").activate() func exit_to(state): pass func on_coin_machine_coin_requirement_met(player): assert(false, "coin machine should be disabled while growing") func on_cook_timer_timeout(): var item_holder = ctx.get_node("%item_holder") item_holder.destroy_item() item_holder.spawn_item(cooked_yam) ctx.change_state(ctx.StateHoldingItem.new()) func on_item_holder_item_changed(item): assert(item == null || item.item_type == cooked_yam) func on_item_dump_completed(): assert(false, "item dump should be disabled") func take_damage(): ctx.hp -= 1 if ctx.hp <= 0: assert(ctx.get_node("%item_holder").has_item()) ctx.get_node("%item_holder").destroy_item() ctx.change_state(ctx.StateBroken.new())