extends Spatial

export(Array, Resource) var all_food

var food_to_consume = null

onready var item_holder = $"%item_holder"

func _ready():
	assert(!all_food.empty())
	item_holder.add_enabled = true
	item_holder.remove_enabled = true
	
func on_player_interact(player) -> bool:
	if food_to_consume == null:
		return false
	player.consume_food(food_to_consume)
	item_holder.destroy_item()
	item_holder.remove_enabled = true
	return true

func _on_item_holder_item_changed(item):
	if item != null:
		for food in all_food:
			if item.item_type == food:
				item_holder.remove_enabled = false
				food_to_consume = food
				return
	
	food_to_consume = null
	item_holder.remove_enabled = true
