Example #1
0
        private void Interact(Transform target, Vector3 position, Vector3 normal)
        {
            var interactable = FindInteractable(target);

            var held = hands.GetItemInHand();
            InteractionReceiver heldInteractionReceiver = null;

            if (held != null)
            {
                heldInteractionReceiver = FindInteractable(held.transform);
                if (heldInteractionReceiver)
                {
                    foreach (var kind in heldInteractionsOnClick)
                    {
                        heldInteractionReceiver.Trigger(new InteractionEvent(kind, hands.gameObject, gameObject)
                                                        .WorldPosition(position).WorldNormal(normal).ForwardTo(interactable)
                                                        .RunWhile(e => Input.GetButton("Click")));
                    }
                }
            }

            if (interactable)
            {
                foreach (var kind in interactionsOnClick)
                {
                    interactable.Trigger(new InteractionEvent(kind, hands.gameObject, gameObject)
                                         .WorldPosition(position).WorldNormal(normal).WaitFor(heldInteractionReceiver));
                }
            }
        }