Esempio n. 1
0
 /// <summary>
 /// Is called before adding to check whether the item may be added to the corresponding slot
 /// (given the case that the corresponding slot is valid and unoccupied)
 /// </summary>
 public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
 {
     if (item.Template.Class != ItemClass.Key)
     {
         err = InventoryError.ITEM_DOESNT_GO_TO_SLOT;
     }
 }
Esempio n. 2
0
 /// <summary>
 /// Is called before adding to check whether the item may be added to the corresponding slot
 /// (given the case that the corresponding slot is valid and unoccupied)
 /// </summary>
 public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
 {
     if (item.Template.IsKey)
     {
         err = InventoryError.ITEM_DOESNT_GO_INTO_BAG;
     }
     else if (item.Template.IsContainer)
     {
         err = InventoryError.NONEMPTY_BAG_OVER_OTHER_BAG;
     }
     else
     {
         if (err == InventoryError.OK)
         {
             if (m_container is Item)
             {
                 var bag = (Item)m_container;
                 if (!bag.Template.MayAddToContainer(item.Template))
                 {
                     err = InventoryError.ITEM_DOESNT_GO_INTO_BAG;
                 }
             }
         }
     }
 }
Esempio n. 3
0
        /// <summary>
        /// Is called before adding to check whether the item may be added to the corresponding slot
        /// (given the case that the corresponding slot is valid and unoccupied)
        /// </summary>
        public virtual void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
        {
            var templ = item.Template;

            err = templ.CheckEquip(Owner);
            if (err == InventoryError.OK)
            {
                if (!templ.IsBag)
                {
                    err = InventoryError.NOT_A_BAG;
                }
                else
                {
                    var oldBag = m_inventory[slot];
                    if (oldBag != null)
                    {
                        err = InventoryError.NONEMPTY_BAG_OVER_OTHER_BAG;
                    }
                    else if (!item.IsEquipped)
                    {
                        err = m_inventory.CheckEquipCount(item);
                    }
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Is called before adding to check whether the item may be added to the corresponding slot
        /// (given the case that the corresponding slot is valid and unoccupied)
        /// </summary>
        public virtual void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
        {
            ItemTemplate template = item.Template;

            err = template.CheckEquip(this.Owner);
            if (err != InventoryError.OK)
            {
                return;
            }
            if (!template.IsBag)
            {
                err = InventoryError.NOT_A_BAG;
            }
            else if (this.m_inventory[slot] != null)
            {
                err = InventoryError.NONEMPTY_BAG_OVER_OTHER_BAG;
            }
            else
            {
                if (item.IsEquipped)
                {
                    return;
                }
                err = this.m_inventory.CheckEquipCount(item);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Is called before adding to check whether the item may be added to the corresponding slot
 /// (given the case that the corresponding slot is valid and unoccupied)
 /// </summary>
 public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
 {
     if (item.Template.IsKey)
     {
         err = InventoryError.ITEM_DOESNT_GO_INTO_BAG;
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Is called before adding to check whether the item may be added to the corresponding slot
 /// (given the case that the corresponding slot is valid and unoccupied)
 /// </summary>
 public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
 {
     if (item.Template.IsKey)
     {
         err = InventoryError.ITEM_DOESNT_GO_INTO_BAG;
     }
     else if (item.Template.IsContainer)
     {
         err = InventoryError.NONEMPTY_BAG_OVER_OTHER_BAG;
     }
     else
     {
         if (err == InventoryError.OK)
         {
             if (m_container is Item)
             {
                 var bag = (Item)m_container;
                 if (!bag.Template.MayAddToContainer(item.Template))
                 {
                     err = InventoryError.ITEM_DOESNT_GO_INTO_BAG;
                 }
             }
         }
     }
 }
Esempio n. 7
0
 /// <summary>
 /// Is called before adding to check whether the item may be added to the corresponding slot
 /// (given the case that the corresponding slot is valid and unoccupied)
 /// </summary>
 public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
 {
     if (!m_inventory.IsBankOpen)
     {
         err = InventoryError.TOO_FAR_AWAY_FROM_BANK;
     }
 }
Esempio n. 8
0
 /// <summary>
 /// Is called before removing the given item to check whether it may actually be removed
 /// </summary>
 public void CheckRemove(int slot, IMountableItem templ, ref InventoryError err)
 {
     // Disarmed
     if (templ is IWeapon && templ.Template.IsWeapon && !Owner.MayCarry(templ.Template.InventorySlotMask))
     {
         err = InventoryError.CANT_DO_WHILE_DISARMED;
     }
 }
Esempio n. 9
0
 public virtual SimpleSlotId FindFreeSlot(IMountableItem item, int amount)
 {
     return(new SimpleSlotId
     {
         Container = this,
         Slot = FindFreeSlot()
     });
 }
Esempio n. 10
0
 /// <summary>
 /// Is called before removing the given item to check whether it may actually be removed
 /// </summary>
 public void CheckRemove(int slot, IMountableItem templ, ref InventoryError err)
 {
     if (!(templ is IWeapon) || !templ.Template.IsWeapon ||
         this.Owner.MayCarry(templ.Template.InventorySlotMask))
     {
         return;
     }
     err = InventoryError.CANT_DO_WHILE_DISARMED;
 }
Esempio n. 11
0
        /// <summary>Is called before a bag is removed</summary>
        public void CheckRemove(int slot, IMountableItem item, ref InventoryError err)
        {
            Container container = item as Container;

            if (container == null || container.BaseInventory.IsEmpty)
            {
                return;
            }
            err = InventoryError.CAN_ONLY_DO_WITH_EMPTY_BAGS;
        }
Esempio n. 12
0
 public override void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
 {
     if (!m_inventory.IsBankOpen)
     {
         err = InventoryError.TOO_FAR_AWAY_FROM_BANK;
     }
     else if (slot < m_inventory.Owner.BankBagSlots)
     {
         err = InventoryError.MUST_PURCHASE_THAT_BAG_SLOT;
     }
 }
Esempio n. 13
0
        /// <summary>
        /// Is called before a bag is removed
        /// </summary>
        public void CheckRemove(int slot, IMountableItem item, ref InventoryError err)
        {
            var cont = item as Container;

            if (cont != null)
            {
                if (!cont.BaseInventory.IsEmpty)
                {
                    err = InventoryError.CAN_ONLY_DO_WITH_EMPTY_BAGS;
                }
            }
        }
Esempio n. 14
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="item"></param>
        /// <param name="amount"></param>
        /// <returns></returns>
        public InventoryError CheckAdd(int slot, IMountableItem item, int amount)
        {
            var handler = GetHandler(slot);

            if (handler != null)
            {
                var err = InventoryError.OK;
                handler.CheckAdd(slot, amount, item, ref err);
                return(err);
            }
            return(InventoryError.OK);
        }
Esempio n. 15
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="slot"></param>
        /// <param name="item"></param>
        /// <param name="amount"></param>
        /// <returns></returns>
        public InventoryError CheckAdd(int slot, IMountableItem item, int amount)
        {
            IItemSlotHandler handler = this.GetHandler(slot);

            if (handler == null)
            {
                return(InventoryError.OK);
            }
            InventoryError err = InventoryError.OK;

            handler.CheckAdd(slot, amount, item, ref err);
            return(err);
        }
Esempio n. 16
0
        /// <summary>
        /// Is called before adding to check whether the item may be added to the corresponding slot
        /// (given the case that the corresponding slot is valid and unoccupied)
        /// </summary>
        public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
        {
            ItemTemplate template = item.Template;

            err = template.CheckEquip(this.m_inventory.Owner);
            if (err != InventoryError.OK)
            {
                return;
            }
            if (template.EquipmentSlots == null)
            {
                err = InventoryError.ITEM_CANT_BE_EQUIPPED;
            }
            else if (!((IEnumerable <EquipmentSlot>)template.EquipmentSlots).Contains <EquipmentSlot>(
                         (EquipmentSlot)slot))
            {
                err = InventoryError.ITEM_DOESNT_GO_TO_SLOT;
            }
            else if (slot == 16)
            {
                Item obj = this.m_inventory[InventorySlot.AvLeftHead];
                if (obj != null && obj.Template.IsTwoHandWeapon)
                {
                    err = InventoryError.CANT_EQUIP_WITH_TWOHANDED;
                }
                else
                {
                    if (!template.IsWeapon || this.m_inventory.Owner.Skills.Contains(SkillId.DualWield))
                    {
                        return;
                    }
                    err = InventoryError.CANT_DUAL_WIELD;
                }
            }
            else if (template.IsTwoHandWeapon && this.m_inventory[EquipmentSlot.OffHand] != null)
            {
                err = InventoryError.CANT_EQUIP_WITH_TWOHANDED;
            }
            else
            {
                if (item.IsEquipped)
                {
                    return;
                }
                err = this.m_inventory.CheckEquipCount(item);
            }
        }
Esempio n. 17
0
 /// <summary>
 /// Is called before adding to check whether the item may be added to the corresponding slot
 /// (given the case that the corresponding slot is valid and unoccupied)
 /// </summary>
 public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
 {
     if (item.Template.IsKey)
     {
         err = InventoryError.ITEM_DOESNT_GO_INTO_BAG;
     }
     else if (item.Template.IsContainer)
     {
         err = InventoryError.NONEMPTY_BAG_OVER_OTHER_BAG;
     }
     else
     {
         if (err != InventoryError.OK || !(this.m_container is Item) ||
             ((Item)this.m_container).Template.MayAddToContainer(item.Template))
         {
             return;
         }
         err = InventoryError.ITEM_DOESNT_GO_INTO_BAG;
     }
 }
Esempio n. 18
0
        /// <summary>
        /// Is called before adding to check whether the item may be added to the corresponding slot
        /// (given the case that the corresponding slot is valid and unoccupied)
        /// </summary>
        public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
        {
            var templ = item.Template;

            err = templ.CheckEquip(m_inventory.Owner);
            if (err == InventoryError.OK)
            {
                if (templ.EquipmentSlots == null)
                {
                    err = InventoryError.ITEM_CANT_BE_EQUIPPED;
                }
                else if (!templ.EquipmentSlots.Contains((EquipmentSlot)slot))
                {
                    // client won't ever let you equip an item in a slot that it doesn't go to anyway
                    err = InventoryError.ITEM_DOESNT_GO_TO_SLOT;
                }
                else if (slot == (int)InventorySlot.OffHand)
                {
                    var mainHandWeapon = m_inventory[InventorySlot.MainHand];
                    if (mainHandWeapon != null && mainHandWeapon.Template.IsTwoHandWeapon)
                    {
                        err = InventoryError.CANT_EQUIP_WITH_TWOHANDED;
                    }
                    else if (templ.IsWeapon && !m_inventory.Owner.Skills.Contains(SkillId.DualWield))
                    {
                        err = InventoryError.CANT_DUAL_WIELD;
                    }
                }
                else if (templ.IsTwoHandWeapon && m_inventory[EquipmentSlot.OffHand] != null)
                //|| ((slot == (int)InventorySlot.OffHand && m_inventory[EquipmentSlot.MainHand] != null))
                {
                    err = InventoryError.CANT_EQUIP_WITH_TWOHANDED;
                }
                else if (!item.IsEquipped)
                {
                    err = m_inventory.CheckEquipCount(item);
                }
            }
        }
Esempio n. 19
0
        /// <summary>
        /// Is called before adding the given amount of the given Item.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="amount"></param>
        /// <param name="err"></param>
        internal void CheckUniqueness(IMountableItem item, ref int amount, ref InventoryError err, bool isNew)
        {
            var template = item.Template;

            if (isNew)
            {
                if (template.UniqueCount > 0)
                {
                    var count = OwnerInventory.GetUniqueCount(template.ItemId);
                    if ((count + (int)amount) > template.UniqueCount)
                    {
                        amount = amount - template.UniqueCount;
                        if (amount < 1)
                        {
                            err = InventoryError.CANT_CARRY_MORE_OF_THIS;
                            return;
                        }
                    }
                }

                // also check for unique gems
                if (item.Enchantments != null)
                {
                    for (var i = EnchantSlot.Socket1; i < EnchantSlot.Socket1 + ItemConstants.MaxSocketCount; i++)
                    {
                        var enchant = item.Enchantments[(uint)i];
                        if (enchant != null &&
                            enchant.Entry.GemTemplate != null &&
                            enchant.Entry.GemTemplate.UniqueCount > 0 &&
                            OwnerInventory.GetUniqueCount(enchant.Entry.GemTemplate.ItemId) >= enchant.Entry.GemTemplate.UniqueCount)
                        {
                            err = InventoryError.CANT_CARRY_MORE_OF_THIS;
                            return;
                        }
                    }
                }
            }
        }
Esempio n. 20
0
        /// <summary>
        /// Is called before adding the given amount of the given Item.
        /// </summary>
        /// <param name="item"></param>
        /// <param name="amount"></param>
        /// <param name="err"></param>
        internal void CheckUniqueness(IMountableItem item, ref int amount, ref InventoryError err, bool isNew)
        {
            ItemTemplate template = item.Template;

            if (!isNew)
            {
                return;
            }
            if (template.UniqueCount > 0 &&
                this.OwnerInventory.GetUniqueCount(template.ItemId) + amount > template.UniqueCount)
            {
                amount -= template.UniqueCount;
                if (amount < 1)
                {
                    err = InventoryError.CANT_CARRY_MORE_OF_THIS;
                    return;
                }
            }

            if (item.Enchantments == null)
            {
                return;
            }
            for (EnchantSlot enchantSlot = EnchantSlot.Socket1; enchantSlot < EnchantSlot.Bonus; ++enchantSlot)
            {
                ItemEnchantment enchantment = item.Enchantments[(uint)enchantSlot];
                if (enchantment != null && enchantment.Entry.GemTemplate != null &&
                    (enchantment.Entry.GemTemplate.UniqueCount > 0 &&
                     this.OwnerInventory.GetUniqueCount(enchantment.Entry.GemTemplate.ItemId) >=
                     enchantment.Entry.GemTemplate.UniqueCount))
                {
                    err = InventoryError.CANT_CARRY_MORE_OF_THIS;
                    break;
                }
            }
        }
Esempio n. 21
0
		/// <summary>
		/// Is called before adding to check whether the item may be added to the corresponding slot 
		/// (given the case that the corresponding slot is valid and unoccupied)
		/// </summary>
		public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
		{
			if (item.Template.Class != ItemClass.Key)
			{
				err = InventoryError.ITEM_DOESNT_GO_TO_SLOT;
			}
		}
Esempio n. 22
0
		/// <summary>
		/// Is called before adding to check whether the item may be added to the corresponding slot 
		/// (given the case that the corresponding slot is valid and unoccupied)
		/// </summary>
		public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
		{
		}
Esempio n. 23
0
		public override void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
		{
			if (!m_inventory.IsBankOpen)
			{
				err = InventoryError.TOO_FAR_AWAY_FROM_BANK;
			}
			else if (slot < m_inventory.Owner.BankBagSlots)
			{
				err = InventoryError.MUST_PURCHASE_THAT_BAG_SLOT;
			}
		}
Esempio n. 24
0
		/// <summary>
		/// Is called before adding to check whether the item may be added to the corresponding slot 
		/// (given the case that the corresponding slot is valid and unoccupied)
		/// </summary>
		public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
		{
			if (!m_inventory.IsBankOpen)
			{
				err = InventoryError.TOO_FAR_AWAY_FROM_BANK;
			}
		}
Esempio n. 25
0
		/// <summary>
		/// Is called before a bag is removed
		/// </summary>
		public void CheckRemove(int slot, IMountableItem item, ref InventoryError err)
		{
			var cont = item as Container;
			if (cont != null)
			{
				if (!cont.BaseInventory.IsEmpty)
				{
					err = InventoryError.CAN_ONLY_DO_WITH_EMPTY_BAGS;
				}
			}
		}
Esempio n. 26
0
		/// <summary>
		/// Is called before adding to check whether the item may be added to the corresponding slot 
		/// (given the case that the corresponding slot is valid and unoccupied)
		/// </summary>
		public virtual void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
		{
			var templ = item.Template;
			err = templ.CheckEquip(Owner);
			if (err == InventoryError.OK)
			{
				if (!templ.IsBag)
				{
					err = InventoryError.NOT_A_BAG;
				}
				else
				{
					var oldBag = m_inventory[slot];
					if (oldBag != null)
					{
						err = InventoryError.NONEMPTY_BAG_OVER_OTHER_BAG;
					}
					else if (!item.IsEquipped)
					{
						err = m_inventory.CheckEquipCount(item);
					}
				}
			}
		}
Esempio n. 27
0
 /// <summary>
 /// Is called before adding to check whether the item may be added to the corresponding slot
 /// (given the case that the corresponding slot is valid and unoccupied)
 /// </summary>
 public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
 {
 }
Esempio n. 28
0
		/// <summary>
		/// Is called before adding to check whether the item may be added to the corresponding slot 
		/// (given the case that the corresponding slot is valid and unoccupied)
		/// </summary>
		public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
		{
			var templ = item.Template;
			err = templ.CheckEquip(m_inventory.Owner);
			if (err == InventoryError.OK)
			{
				if (templ.EquipmentSlots == null)
				{
					err = InventoryError.ITEM_CANT_BE_EQUIPPED;
				}
				else if (!templ.EquipmentSlots.Contains((EquipmentSlot)slot))
				{
					// client won't ever let you equip an item in a slot that it doesn't go to anyway
					err = InventoryError.ITEM_DOESNT_GO_TO_SLOT;
				}
				else if (slot == (int)InventorySlot.OffHand)
				{
					var mainHandWeapon = m_inventory[InventorySlot.MainHand];
					if (mainHandWeapon != null && mainHandWeapon.Template.IsTwoHandWeapon)
					{
						err = InventoryError.CANT_EQUIP_WITH_TWOHANDED;
					}
					else if (templ.IsWeapon && !m_inventory.Owner.Skills.Contains(SkillId.DualWield))
					{
						err = InventoryError.CANT_DUAL_WIELD;
					}
				}
				else if (templ.IsTwoHandWeapon && m_inventory[EquipmentSlot.OffHand] != null)
				//|| ((slot == (int)InventorySlot.OffHand && m_inventory[EquipmentSlot.MainHand] != null))
				{
					err = InventoryError.CANT_EQUIP_WITH_TWOHANDED;
				}
				else if (!item.IsEquipped)
				{
					err = m_inventory.CheckEquipCount(item);
				}
			}
		}
Esempio n. 29
0
 /// <summary>
 /// Is called before removing the given item to check whether it may actually be removed
 /// </summary>
 public void CheckRemove(int slot, IMountableItem item, ref InventoryError err)
 {
 }
Esempio n. 30
0
		/// <summary>
		/// Is called before removing the given item to check whether it may actually be removed
		/// </summary>
		public void CheckRemove(int slot, IMountableItem templ, ref InventoryError err)
		{
			// Disarmed
			if (templ is IWeapon && templ.Template.IsWeapon && !Owner.MayCarry(templ.Template.InventorySlotMask))
			{
				err = InventoryError.CANT_DO_WHILE_DISARMED;
			}
		}
Esempio n. 31
0
		/// <summary>
		/// Gets a free slot in a preferred equipped bag (eg Herb bag for Herbs) or backpack.
		/// Looks for a suitable equipment slot first, if tryEquip is true
		/// </summary>
		public SimpleSlotId FindFreeSlot(IMountableItem mountItem, int amount, bool tryEquip)
		{
			var templ = mountItem.Template;

			if (tryEquip && templ.EquipmentSlots != null)
			{
				// try to equip
				for (var i = 0; i < templ.EquipmentSlots.Length; i++)
				{
					var slot = (int)templ.EquipmentSlots[i];
					var item = m_Items[slot];
					if (item == null)
					{
						var handler = GetHandler(slot);
						var err = InventoryError.OK;
						handler.CheckAdd(slot, amount, templ, ref err);
						if (err == InventoryError.OK)
						{
							return new SimpleSlotId { Container = this, Slot = slot };
						}
						break;
					}
				}
			}

			var slotId = SimpleSlotId.Default;

			// check for preferred bag (ore goes to mining sacks, keys go to keychain etc)
			GetPreferredSlot(templ, amount, ref slotId);
			if (slotId.Slot == INVALID_SLOT)
			{
				// add it to any free spot if there isn't any preferred bag
				var slots = ItemMgr.StorageSlotsWithoutBank;
				var contLookup = ItemMgr.ContainerSlotsWithBank;

				for (var j = 0; j < slots.Length; j++)
				{
					var avlblSlot = (int)slots[j];
					if (contLookup[avlblSlot])
					{
						var container = m_Items[avlblSlot] as Container;
						if (container != null && container.Template.MayAddToContainer(templ))
						{
							var contInv = container.BaseInventory;
							var contItems = contInv.Items;
							for (var i = 0; i < contItems.Length; i++)
							{
								if (contItems[i] == null)
								{
									slotId.Container = contInv;
									slotId.Slot = i;
									return slotId;
								}
							}
						}
					}
					else if (m_Items[avlblSlot] == null)
					{
						slotId.Container = this;
						slotId.Slot = avlblSlot;
						return slotId;
					}
				}
				slotId.Slot = INVALID_SLOT;
			}
			return slotId;
		}
Esempio n. 32
0
		/// <summary>
		/// Is called before removing the given item to check whether it may actually be removed
		/// </summary>
		public void CheckRemove(int slot, IMountableItem item, ref InventoryError err)
		{
		}
Esempio n. 33
0
		/// <summary>
		/// Gets a free slot in a preferred equipped bag (eg Herb bag for Herbs) or backpack
		/// </summary>
		public override SimpleSlotId FindFreeSlot(IMountableItem mountItem, int amount)
		{
			return FindFreeSlot(mountItem, amount, AutoEquipNewItems);
		}
Esempio n. 34
0
		/// <summary>
		/// Is called before adding to check whether the item may be added to the corresponding slot 
		/// (given the case that the corresponding slot is valid and unoccupied)
		/// </summary>
		public void CheckAdd(int slot, int amount, IMountableItem item, ref InventoryError err)
		{
			if (item.Template.IsKey)
			{
				err = InventoryError.ITEM_DOESNT_GO_INTO_BAG;
			}
		}
Esempio n. 35
0
		/// <summary>
		/// Gets a free slot in the bank or one of the bankbags
		/// </summary>
		public SimpleSlotId FindFreeBankSlot(IMountableItem item, int amount)
		{
			var slotId = new SimpleSlotId();

			for (var i = 0; i < ItemMgr.BankSlots.Length; i++)
			{
				var avlblSlot = (int)ItemMgr.BankSlots[i];
				if (m_Items[avlblSlot] == null)
				{
					slotId.Container = this;
					slotId.Slot = avlblSlot;
					return slotId;
				}
			}

			for (var i1 = 0; i1 < ItemMgr.BankBagSlots.Length; i1++)
			{
				var avlblSlot = (int)ItemMgr.BankBagSlots[i1];
				var container = m_Items[avlblSlot] as Container;
				if (container != null)
				{
					var contInv = container.BaseInventory;
					if (contInv.CheckAdd(0, item, amount) == InventoryError.OK)
					{
						var contItems = contInv.Items;
						for (var i = 0; i < contItems.Length; i++)
						{
							if (contItems[i] == null)
							{
								slotId.Container = contInv;
								slotId.Slot = i;
								return slotId;
							}
						}
					}
				}
			}
			slotId.Slot = INVALID_SLOT;
			return slotId;
		}
Esempio n. 36
0
		/// <summary>
		/// Checks for whether the given amount of that Item can still be added 
		/// (due to max unique count).
		/// </summary>
		/// <param name="mountItem"></param>
		/// <returns></returns>
		internal InventoryError CheckEquipCount(IMountableItem mountItem)
		{
			var templ = mountItem.Template;
			if (templ.Flags.HasFlag(ItemFlags.UniqueEquipped))
			{
				// may only equip a certain maximum of this item
				foreach (var slot in templ.EquipmentSlots)
				{
					var item = this[slot];
					if (item != null && item.Template.Id == templ.Id)
					{
						return InventoryError.ITEM_UNIQUE_EQUIPABLE;
					}
				}
			}

			// also check for unique gems
			if (mountItem.Enchantments != null)
			{
				for (var i = EnchantSlot.Socket1; i < EnchantSlot.Socket1 + ItemConstants.MaxSocketCount; i++)
				{
					var enchant = mountItem.Enchantments[(uint)i];
					if (enchant != null && !CheckEquippedGems(enchant.Entry.GemTemplate))
					{
						return InventoryError.ITEM_UNIQUE_EQUIPPABLE_SOCKETED;
					}
				}
			}
			return InventoryError.OK;
		}