コード例 #1
0
        public override void OnPress(UIItemSlot slot, PointerEventData.InputButton button)
        {
            if (button == PointerEventData.InputButton.Middle)
            {
                return;
            }

            SlotInfo info       = GetSlotLink(slot);
            Filter   slotFilter = info.container.GetFilter(info.index);
            // TODO: Hack, this should be decoupled in some way
            GameObject         playerObject = info.container.gameObject;
            GameObject         item         = info.container.GetItem(info.index)?.gameObject;
            InteractionHandler handler      = playerObject.GetComponent <InteractionHandler>();
            Hands hands = playerObject.GetComponent <Hands>();

            if (handler != null && hands != null && hands.GetActiveTool() != null && item != null && (slotFilter.Hash == Filters.RightHand || slotFilter.Hash == Filters.LeftHand))
            {
                handler.InteractInHand(item, playerObject, button == PointerEventData.InputButton.Right);
                return;
            }

            base.OnPress(slot, button);
        }