Esempio n. 1
0
        public int Add(int itemId, int amount = 1, ItemProperties properties = null)
        {
            if (!this.IsValidItem(itemId))
            {
                return(amount);
            }
            float num       = 0f;
            int   maxAmount = (num != 0f) ? Mathf.FloorToInt(1f / num) : int.MaxValue;

            ItemStorage.InventoryItemX inventoryItemX = this._usedSlots.LastOrDefault((ItemStorage.InventoryItemX s) => s._itemId == itemId && s._properties.Match(properties));
            if (inventoryItemX != null)
            {
                this.UpdateContentVersion();
                amount = inventoryItemX.Add(amount, false);
            }
            while (amount > 0 && (this._usedSlots.Count < this._slotCount || this._slotCount == 0))
            {
                inventoryItemX = new ItemStorage.InventoryItemX
                {
                    _itemId     = itemId,
                    _maxAmount  = maxAmount,
                    _properties = ((properties == null) ? new ItemProperties
                    {
                        ActiveBonus = (WeaponStatUpgrade.Types)(-1)
                    } : properties.Clone())
                };
                amount = inventoryItemX.Add(amount, false);
                this._usedSlots.Add(inventoryItemX);
                this.UpdateContentVersion();
            }
            this.UpdateFillIcon();
            return(amount);
        }
Esempio n. 2
0
 public void SetItemProperties(int index, int itemId, ItemProperties prop)
 {
     this._itemsProperties[index] = new StorageItemBonusManager.ItemData
     {
         _itemid     = itemId,
         _properties = prop.Clone()
     };
 }