extends Control

const ITEM_TEXTURE_RECT = preload("res://Items/ItemTextureRect.tscn")

onready var h_box_container = $CenterContainer/HBoxContainer

func update_items(array: Array):
	for item in h_box_container.get_children():
		item.queue_free()
	
	for item in array:
		if item is Item:
			var item_texture_rect = ITEM_TEXTURE_RECT.instance()
			h_box_container.add_child(item_texture_rect)
			item_texture_rect.get_node("ItemTextureRect").texture = item.texture

func item_used(array: Array):
	if h_box_container.get_child_count() > 0:
		var item_texture_rect = h_box_container.get_child(0)
		if not item_texture_rect == null:
			item_texture_rect.vanish()
			yield(item_texture_rect.tween, "tween_all_completed")
			update_items(array)
			print("test")
