public void LoadSpells(List <Item.Types> spells) { List <Item> spellItems = new List <Item>(); foreach (Item.Types spell in spells) { Item spellItem = Item.Factory(spell); if (spellItem == null) { GD.Print("SpellCaster.LoadSpells: Could not create spell " + spell); } else { spellItems.Add(spellItem); } } hotbar = new HotBar(spellItems.Count); for (int i = 0; i < spellItems.Count; i++) { hotbar.SetItemSlot(i, spellItems[i]); AddChild(spellItems[i]); spellItems[i].Equip(this); spellItems[i].Mode = RigidBody.ModeEnum.Static; } }
/* Equip item to hotbar immediately. */ public void PickUpAndEquipItem(Item item) { int slot = hotbar.FirstEmptySlot(); if (slot == -1) { GD.Print("PickUpAndEquipItem: No empty slot"); return; } hotbar.SetItemSlot(slot, item); hotbar.EquipItem(slot); DeferredEquipItem(item); }