Example #1
0
        /// <summary>Adds an instance of <see cref="Item"/> to an <see cref="ItemSlot"/>.</summary>
        /// <param name="slot"><see cref="ItemSlot"/> where the <see cref="Item"/> is to be added</param>
        /// <param name="item"><see cref="Item"/> to be added</param>
        internal static void AddItemInstanceToSlot(ItemSlot slot, Item item)
        {
            PackedScene scene = (PackedScene)ResourceLoader.Load("res://scenes/inventory/InventoryItem.tscn");

            while (slot.GetChildren().Count > 1)
            {
                slot.RemoveChild(slot.GetChild(1));
            }
            InventoryItem invItem = (InventoryItem)scene.Instance();

            slot.AddChild(invItem);
            slot.Item = invItem;
            slot.Item.SetItem(item);
            invItem.Theme = (Theme)ResourceLoader.Load("res://resources/TextureRect.tres");
        }