/// <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); } }
/// <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); } }