public override bool Equip(InventoryEquippableField equipSlot, CharacterUI equipToCollection)
        {
            bool equipped = base.Equip(equipSlot, equipToCollection);
            if (equipped == false)
                return false;

            SetPlyGameValues(1.0f);
            return true;
        }
        /// <summary>
        /// Some item's require multiple slots, for example a 2 handed item forces the left handed item to be empty.
        /// </summary>
        /// <returns>true if items were removed, false if items were not removed.</returns>
        public virtual bool HandleLocks(InventoryEquippableField equipSlot, ItemCollectionBase usedFromCollection, CharacterUI equipTo)
        {
            var toBeRemoved = new List<uint>(8);

            // Loop through things we want to block
            foreach (var blockType in equipType.blockTypes)
            {
                // Check every slot against this block type
                foreach (var field in equipTo.equipSlotFields)
                {
                    var item = equipTo[field.index].item;
                    if(item != null)
                    {
                        var eq = (EquippableInventoryItem)item;

                        if(eq.equipType.ID == blockType && field.index != equipSlot.index)
                        {
                            toBeRemoved.Add(field.index);
                            bool canAdd = InventoryManager.CanAddItem(eq);
                            if (canAdd == false)
                                return false;
                        }
                    }
                }
            }
            
            foreach (uint i in toBeRemoved)
            {
                var item = equipTo[i].item as EquippableInventoryItem;
                bool added = InventoryManager.AddItemAndRemove(item);
                if (added == false)
                {
                    Debug.LogError("Item could not be saved, even after check, please report this bug + stacktrace.");
                    return false;
                }
            }

            return true;
        }
        public virtual InventoryEquippableField GetBestEquipSlot(CharacterUI equipCollection)
        {
            var equipSlots = equipCollection.GetEquippableSlots(this);
            if (equipSlots.Length == 0)
            {
                Debug.LogWarning("No suitable equip slot found for item " + name, gameObject);
                return null;
            }

            InventoryEquippableField equipSlot = equipSlots[0];
            foreach (var e in equipSlots)
            {
                if (equipCollection[e.index].item == null)
                {
                    equipSlot = e; // Prefer an empty slot over swapping a filled one.
                }
            }

            return equipSlot;
        }
        /// <summary>
        /// Equip the item to the given collection
        /// </summary>
        /// <param name="equipSlot">Equip to slot</param>
        /// <param name="equipTo">Collection to equip to</param>
        /// <returns></returns>
        public virtual bool Equip(InventoryEquippableField equipSlot, CharacterUI equipTo)
        {
            if (CanEquip() == false)
                return false;

            bool handled = HandleLocks(equipSlot, itemCollection, equipTo);
            if (handled == false)
                return false; // Other items cannot be unequipped

            // There was already an item in this slot, un-equip that one first
            if (equipTo[equipSlot.index].item != null)
            {
                var item = equipTo[equipSlot.index].item as EquippableInventoryItem;
                bool unEquipped = item.UnEquip(false);
                if (unEquipped == false)
                    return false;
            }

            // The values before the collection / slot changed.
            uint prevIndex = index;
            var fromCollection = itemCollection;

            // Equip the item -> Will swap as merge is not possible
            bool canSet = equipTo.CanSetItem(equipSlot.index, this);
            if (canSet)
            {
                NotifyItemUsed(1, true); // Events still valid, handling before the set

                equipTo.SetItem(equipSlot.index, this);
                if(fromCollection != null)
                    fromCollection.SetItem(prevIndex, null);

                equipTo.NotifyItemAdded(this, currentStackSize, itemCollection != null);
                if (fromCollection != null)
                {
                    fromCollection.NotifyItemRemoved(this, ID, prevIndex, currentStackSize);
                    fromCollection[prevIndex].Repaint();
                }

                //NotifyItemEquipped(equipSlot); // Collection defines when an item is equipped or unequipped
                equipTo[equipSlot.index].Repaint();
                //fromCollection.NotifyItemUsed(this, ID, prevIndex, 1);

                return true;
            }

            return false;
        }
 public CharacterStatsDataProvider(CharacterUI characterUI)
 {
     this.characterUI = characterUI;
 }
 public static void RemoveEquipCollection(CharacterUI collection)
 {
     equipToCollections.RemoveAll(o => o.collection == collection);
     //var found = equipToCollections.FirstOrDefault(o => o.collection == collection);
     //if (found != null)
         //equipToCollections.Remove(found);
 }
 /// <summary>
 /// Add a collection that functions as an Equippable collection. Items can be equipped to this collection.
 /// </summary>
 /// <param name="collection">The collection to add.</param>
 /// <param name="priority">
 /// How important is the collection, if you 2 collections can hold the item, which one should be chosen?
 /// Range of 0 to 100
 /// 
 /// Note: This method is not used yet, it only registers the Equippable collection, that's it.
 /// </param>
 public static void AddEquipCollection(CharacterUI collection, int priority)
 {
     equipToCollections.Add(new InventoryCollectionLookup<CharacterUI>(collection, priority));
 }