Esempio n. 1
0
    private bool CanEquipItem(Item item, int targetSlot)
    {
        object obj = Interface.CallHook("CanEquipItem", this, item, targetSlot);

        if (obj as bool)
        {
            return((bool)obj);
        }
        ItemModContainerRestriction component = item.info.GetComponent <ItemModContainerRestriction>();

        if (component == null)
        {
            return(true);
        }
        Item[] array = this.containerBelt.itemList.ToArray();
        for (int i = 0; i < (int)array.Length; i++)
        {
            Item item1 = array[i];
            if (item1 != item)
            {
                ItemModContainerRestriction itemModContainerRestriction = item1.info.GetComponent <ItemModContainerRestriction>();
                if (!(itemModContainerRestriction == null) && !component.CanExistWith(itemModContainerRestriction) && !item1.MoveToContainer(this.containerMain, -1, true))
                {
                    item1.Drop(base.baseEntity.GetDropPosition(), base.baseEntity.GetDropVelocity(), new Quaternion());
                }
            }
        }
        return(true);
    }
    private bool CanEquipItem(Item item, int targetSlot)
    {
        object obj1 = Interface.CallHook(nameof(CanEquipItem), (object)this, (object)item, (object)targetSlot);

        if (obj1 is bool)
        {
            return((bool)obj1);
        }
        ItemModContainerRestriction component1 = (ItemModContainerRestriction)((Component)item.info).GetComponent <ItemModContainerRestriction>();

        if (Object.op_Equality((Object)component1, (Object)null))
        {
            return(true);
        }
        foreach (Item obj2 in this.containerBelt.itemList.ToArray())
        {
            if (obj2 != item)
            {
                ItemModContainerRestriction component2 = (ItemModContainerRestriction)((Component)obj2.info).GetComponent <ItemModContainerRestriction>();
                if (!Object.op_Equality((Object)component2, (Object)null) && !component1.CanExistWith(component2) && !obj2.MoveToContainer(this.containerMain, -1, true))
                {
                    obj2.Drop(this.baseEntity.GetDropPosition(), this.baseEntity.GetDropVelocity(), (Quaternion)null);
                }
            }
        }
        return(true);
    }