コード例 #1
0
    /// <summary>
    /// Check if item has an interaction with a an item in a slot
    /// If not or if bool returned is true, swap items
    /// </summary>
    public void TryItemInteract(bool swapIfEmpty = true)
    {
        var slotName = itemSlot.SlotIdentifier.NamedSlot;

        // Clicked on another slot other than our own hands
        if (itemSlot != UIManager.Hands.LeftHand.ItemSlot && itemSlot != UIManager.Hands.RightHand.itemSlot)
        {
            // If full, attempt to interact the two, otherwise swap
            if (Item != null)
            {
                //check IF2 InventoryApply interaction - combine the active hand item with this (only if
                //both are occupied)
                if (TryIF2InventoryApply())
                {
                    return;
                }

                if (swapIfEmpty)
                {
                    UIManager.Hands.SwapItem(this);
                }
                return;
            }
            else
            {
                if (swapIfEmpty)
                {
                    UIManager.Hands.SwapItem(this);
                }
                return;
            }
        }
        // If there is an item and the hand is interacting in the same slot
        if (Item != null && UIManager.Hands.CurrentSlot.ItemSlot == itemSlot)
        {
            //check IF2 logic first
            var interactables = Item.GetComponents <IBaseInteractable <HandActivate> >()
                                .Where(mb => mb != null && (mb as MonoBehaviour).enabled);
            var activate = HandActivate.ByLocalPlayer();
            InteractionUtils.ClientCheckAndTrigger(interactables, activate);
        }
        else
        {
            if (UIManager.Hands.CurrentSlot.ItemSlot != itemSlot)
            {
                //Clicked on item with otherslot selected
                if (UIManager.Hands.OtherSlot.Item != null)
                {
                    if (TryIF2InventoryApply())
                    {
                        return;
                    }
                    if (swapIfEmpty)
                    {
                        UIManager.Hands.SwapItem(this);
                    }
                }
            }
        }
    }
コード例 #2
0
    /// <summary>
    /// Check if item has an interaction with a an item in a slot
    /// If not or if bool returned is true, swap items
    /// </summary>
    public void TryItemInteract()
    {
        // Clicked on another slot other than hands
        if (equipSlot != EquipSlot.leftHand && equipSlot != EquipSlot.rightHand)
        {
            // If full, attempt to interact the two, otherwise swap
            if (Item != null)
            {
                //check IF2 InventoryApply interaction - combine the active hand item with this (only if
                //both are occupied)
                if (TryIF2InventoryApply())
                {
                    return;
                }

                UIManager.Hands.SwapItem(this);
                return;
            }
            else
            {
                UIManager.Hands.SwapItem(this);
                return;
            }
        }
        // If there is an item and the hand is interacting in the same slot
        if (Item != null && UIManager.Hands.CurrentSlot.equipSlot == equipSlot)
        {
            //check IF2 logic first
            var interactables = Item.GetComponents <IInteractable <HandActivate> >()
                                .Where(mb => mb != null && (mb as MonoBehaviour).enabled);
            var activate = HandActivate.ByLocalPlayer();
            foreach (var interactable in interactables)
            {
                if (interactable.Interact(activate))
                {
                    return;
                }
            }
        }
        else
        {
            if (UIManager.Hands.CurrentSlot.equipSlot != equipSlot)
            {
                //Clicked on item with otherslot selected
                if (UIManager.Hands.OtherSlot.Item != null)
                {
                    if (TryIF2InventoryApply())
                    {
                        return;
                    }
                    UIManager.Hands.SwapItem(this);
                }
            }
        }
    }
コード例 #3
0
    /// <summary>
    /// Check if item has an interaction with a an item in a slot
    /// If not or if bool returned is true, swap items
    /// </summary>
    public void TryItemInteract(bool swapIfEmpty = true)
    {
        // Clicked on another slot other than our own hands
        bool IsHandSlots = false;

        foreach (var HadnitemSlot in PlayerManager.LocalPlayerScript.DynamicItemStorage.GetHandSlots())
        {
            if (HadnitemSlot == itemSlot)
            {
                IsHandSlots = true;
            }
        }

        if (IsHandSlots == false)
        {
            // If full, attempt to interact the two, otherwise swap
            if (Item != null)
            {
                //check IF2 InventoryApply interaction - combine the active hand item with this (only if
                //both are occupied)
                if (TryIF2InventoryApply())
                {
                    return;
                }

                if (swapIfEmpty)
                {
                    SwapItem(this);
                }
                return;
            }
            else
            {
                if (swapIfEmpty)
                {
                    SwapItem(this);
                }
                return;
            }
        }

        // If there is an item and the hand is interacting in the same slot
        if (Item != null && PlayerManager.LocalPlayerScript.DynamicItemStorage.GetActiveHandSlot() == itemSlot)
        {
            //check IF2 logic first
            var interactables = Item.GetComponents <IBaseInteractable <HandActivate> >()
                                .Where(mb => mb != null && (mb as MonoBehaviour).enabled);
            var activate = HandActivate.ByLocalPlayer();
            InteractionUtils.ClientCheckAndTrigger(interactables, activate);
        }
        else
        {
            if (PlayerManager.LocalPlayerScript.DynamicItemStorage.GetActiveHandSlot() != itemSlot)
            {
                if (TryIF2InventoryApply())
                {
                    return;
                }
                if (swapIfEmpty)
                {
                    SwapItem(this);
                }
            }
        }
    }