Exemplo n.º 1
0
        protected virtual void Update()
        {
            if (!isStringGrabbed)
            {
                if (!StringNock.transform.localPosition.ApproxEquals(nockRestingPosition))
                {
                    StringNock.transform.localPosition = Vector3.MoveTowards(StringNock.transform.localPosition, nockRestingPosition, StringReturnSpeed * Time.deltaTime);
                }
            }
            else
            {
                secondaryInteractor = BowInteractable.GrabbingInteractors.Count > 1 ? BowInteractable.GrabbingInteractors[1] : null;
                if (secondaryInteractor != null)
                {
                    StringNock.transform.position      = secondaryInteractor.GrabAttachPoint.transform.position;
                    StringNock.transform.localPosition = Vector3.forward * Mathf.Clamp(StringNock.transform.localPosition.z, MaxStringPull * -1, minStringPull);
                }
            }

            FlexAnimationScrubber.Scrub(Mathf.Clamp01(NormalizedPullDistance - 0.001f));
            for (int linePoint = 0; linePoint < StringPoints.Length; linePoint++)
            {
                StringRenderer.SetPosition(linePoint, StringPoints[linePoint].position);
            }
        }
 public void TriggerPressed(InteractorFacade hand)
 {
     if (this.createMode)
     {
         NodeObject grabbedNode      = GrabbedNode(hand);
         NodeObject otherGrabbedNode = OtherGrabbedNode(hand);
         if (grabbedNode != null && otherGrabbedNode != null)
         {
             MakeConnection(grabbedNode, otherGrabbedNode);
         }
         else
         {
             NodeObject node = TriggerCreate(head.transform, WhichHand(hand).transform);
             if (grabbedNode != null)
             {
                 MakeConnection(grabbedNode, node);
             }
             if (otherGrabbedNode != null)
             {
                 MakeConnection(otherGrabbedNode, node);
             }
         }
     }
     else if (hovering != null)
     {
         hovering.Detach();
         Destroy(hovering.gameObject, 0.1f);
         hovering = null;
     }
 }
 /// <summary>
 /// Attempts to show the given <see cref="InteractorFacade"/>.
 /// </summary>
 /// <param name="interactorFacade">The interactor to show.</param>
 public virtual void Show(InteractorFacade interactorFacade)
 {
     if (Emit(ShowEmitter, interactorFacade))
     {
         Shown?.Invoke(interactorFacade);
     }
 }
Exemplo n.º 4
0
        /// <summary>
        /// Attempts to nock the arrow.
        /// </summary>
        /// <param name="data">The collision data which should contain an arrow.</param>
        public virtual void AttemptArrowNock(CollisionNotifier.EventData data)
        {
            if (ArrowSnapZone.SnappedGameObject != null || !data.ColliderData.name.Equals("ArrowNockPoint"))
            {
                return;
            }

            InteractableFacade arrow = data.ColliderData.GetAttachedRigidbody().GetComponent <InteractableFacade>();

            if (arrow == null || arrow.GrabbingInteractors.Count == 0)
            {
                return;
            }

            arrowInteractor = arrow.GrabbingInteractors.Count > 0 ? arrow.GrabbingInteractors[0] : null;

            if (arrowInteractor == null)
            {
                return;
            }

            arrowInteractor.Ungrab();
            arrowInteractor.SimulateUntouch(arrow);
            arrowInteractor.Grab(BowInteractable);
            ArrowSnapZone.Snap(arrow);

            nockedArrow = arrow.GetComponentInParent <ArrowController>();
            ToggleColliders(BowColliders, nockedArrow.ArrowColliders, true);
            nockedArrow.ToggleColliderTrigger(true);
        }
        protected virtual IEnumerator DoUngrabAtEndOfFrame(InteractorFacade interactor)
        {
            yield return(delayInstruction);

            Configuration.GrabConfiguration.Ungrab(interactor);
            ungrabRoutine = null;
        }
 /// <summary>
 /// Attempts to hide the given <see cref="InteractorFacade"/>.
 /// </summary>
 /// <param name="interactorFacade">The interactor to hide.</param>
 public virtual void Hide(InteractorFacade interactorFacade)
 {
     if (Emit(HideEmitter, interactorFacade))
     {
         Hidden?.Invoke(interactorFacade);
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Notifies that the Interactable is being no longer touched.
        /// </summary>
        /// <param name="data">The previous touching object.</param>
        public virtual void NotifyUntouch(CollisionNotifier.EventData data)
        {
            InteractorFacade interactor = InteractorFacade.TryGetFromGameObject(data.forwardSource.gameObject);

            if (interactor != null)
            {
                facade?.Untouched?.Invoke(interactor);
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// Notifies that the Interactable is being ungrabbed for the last time.
        /// </summary>
        /// <param name="data">The ungrabbing object.</param>
        public virtual void NotifyLastUngrab(GameObject data)
        {
            InteractorFacade interactor = data.TryGetComponent <InteractorFacade>(true, true);

            if (interactor != null)
            {
                facade?.LastUngrabbed?.Invoke(interactor);
            }
        }
        /// <summary>
        /// Attempt to grab the Interactable to the given Interactor and does not ungrab any existing grab.
        /// </summary>
        /// <param name="interactor">The Interactor to attach the Interactable to.</param>
        public virtual void GrabIgnoreUngrab(InteractorFacade interactor)
        {
            if (interactor == null)
            {
                return;
            }

            interactor.GrabIgnoreUngrab(Facade);
        }
Exemplo n.º 10
0
        /// <summary>
        /// Notifies that the Interactable is being touched for the first time.
        /// </summary>
        /// <param name="data">The touching object.</param>
        public virtual void NotifyFirstTouch(GameObject data)
        {
            InteractorFacade interactor = InteractorFacade.TryGetFromGameObject(data);

            if (interactor != null)
            {
                facade?.FirstTouched?.Invoke(interactor);
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Enables the given source <see cref="InteractorFacade"/> on the <see cref="ActionRegistrar"/>.
        /// </summary>
        /// <param name="source">The source to enable.</param>
        public virtual void EnableActionRegistrar(InteractorFacade source)
        {
            if (source == null)
            {
                return;
            }

            EnableActionRegistrar(source.gameObject);
        }
Exemplo n.º 12
0
        /// <summary>
        /// Retreives the currently active grabbing Interactor.
        /// </summary>
        /// <returns>The currently active grabbing Interactor.</returns>
        protected virtual InteractorFacade GetGrabbingInteractor()
        {
            if (attachmentLogic == null || attachmentLogic.sourceComponent == null)
            {
                return(null);
            }

            return(InteractorFacade.TryGetFromGameObject(attachmentLogic.sourceComponent.gameObject));
        }
        /// <summary>
        /// Attempts to highlight the <see cref="Facade.Interactbale"/> meshes.
        /// </summary>
        /// <param name="interactor">The Interactor initiating the interaction.</param>
        public virtual void AttemptHighlight(InteractorFacade interactor)
        {
            if (Facade.HighlightMaterial != null)
            {
                ApplyMaterialToAllMeshes(Facade.Interactable, Facade.HighlightMaterial);
            }

            Facade.Highlighted?.Invoke(interactor);
        }
        /// <summary>
        /// Handles when the <see cref="InteractableFacade"/> is first touched.
        /// </summary>
        /// <param name="interactor">The Interactor initiating the event.</param>
        protected virtual void HandleFirstTouched(InteractorFacade interactor)
        {
            if (HighlighterProxyEmitter == null)
            {
                return;
            }

            HighlighterProxyEmitter.Receive(interactor);
        }
        /// <summary>
        /// Notifies that the Interactable is being ungrabbed for the last time.
        /// </summary>
        /// <param name="data">The ungrabbing object.</param>
        public virtual void NotifyLastUngrab(GameObject data)
        {
            InteractorFacade interactor = InteractorFacade.TryGetFromGameObject(data);

            if (interactor != null)
            {
                facade?.LastUngrabbed?.Invoke(interactor);
            }
        }
Exemplo n.º 16
0
        /// <summary>
        /// Notifies that the Interactable is being touched for the first time.
        /// </summary>
        /// <param name="data">The touching object.</param>
        public virtual void NotifyFirstTouch(GameObject data)
        {
            InteractorFacade interactor = data.TryGetComponent <InteractorFacade>(true, true);

            if (interactor != null)
            {
                facade?.FirstTouched?.Invoke(interactor);
            }
        }
        /// <summary>
        /// Handles when the <see cref="InteractableFacade"/> is last ungrabbed.
        /// </summary>
        /// <param name="interactor">The Interactor initiating the event.</param>
        protected virtual void LastUngrabbed(InteractorFacade interactor)
        {
            if (HighlighterProxyEmitter == null)
            {
                return;
            }

            HighlighterProxyEmitter.gameObject.SetActive(true);
            HighlighterProxyEmitter.Receive(interactor);
        }
        protected virtual bool Emit(InteractorFacadeEventProxyEmitter emitter, InteractorFacade interactorFacade)
        {
            if (emitter == null)
            {
                return(false);
            }

            emitter.Receive(interactorFacade);
            return(true);
        }
        /// <summary>
        /// Handles when the <see cref="InteractableFacade"/> is first grabbed.
        /// </summary>
        /// <param name="interactor">The Interactor initiating the event.</param>
        protected virtual void HandleFirstGrabbed(InteractorFacade interactor)
        {
            if (HighlighterProxyEmitter == null || UnhighlighterProxyEmitter == null)
            {
                return;
            }

            HighlighterProxyEmitter.gameObject.SetActive(false);
            UnhighlighterProxyEmitter.Receive(interactor);
        }
        /// <summary>
        /// Configures the rules for the controller.
        /// </summary>
        /// <param name="interactor">The Interactor associated with the controller.</param>
        /// <param name="ruleList">The rule to manage.</param>
        protected virtual void ConfigureControllerRules(InteractorFacade interactor, ListContainsRule ruleList)
        {
            if (interactor == null || ruleList == null)
            {
                return;
            }

            ruleList.Objects.Clear();
            ruleList.Objects.Add(interactor.gameObject);
        }
        /// <summary>
        /// Resumes all collisions between any found Interactor and this PsuedoBody.
        /// </summary>
        /// <param name="ignoredObject">The object being ignored.</param>
        public virtual void ResumeInteractorsCollisions(GameObject ignoredObject)
        {
            InteractorFacade interactor = ignoredObject.GetComponent <InteractorFacade>();

            if (interactor != null)
            {
                interactor.Grabbed.RemoveListener(IgnoreInteractorGrabbedCollision);
                interactor.Ungrabbed.RemoveListener(ResumeInteractorUngrabbedCollision);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Notifies that the Interactable is no longer being grabbed.
        /// </summary>
        /// <param name="data">The previous grabbing object.</param>
        public virtual void NotifyUngrab(GameObject data)
        {
            InteractorFacade interactor = data.TryGetComponent <InteractorFacade>(true, true);

            if (interactor != null)
            {
                facade?.Ungrabbed?.Invoke(interactor);
                interactor.Ungrabbed?.Invoke(facade);
                interactor.grabInteractorSetup?.grabbedObjects?.RemoveElement(facade?.gameObject);
            }
        }
Exemplo n.º 23
0
    //	public ClimbFacade climbFacade;
    //	InputManager hand;
    public IEnumerator GetOffWhenCan(InteractorFacade hand)
    {
        while (!canGetOff)
        {
            yield return(new WaitForFixedUpdate());
        }

        yield return(new WaitForSeconds(1f));

        climbRef.StopClimbing(thisInteractible, hand);
    }
        public virtual void UngrabAtEndOfFrame(InteractorFacade interactor)
        {
            Debug.LogWarning("`InteractableFacade.UngrabAtEndOfFrame()` has been deprecated. Use `WaitForEndOfFrameYieldEmitter.Yielded() -> InteractableFacade.Ungrab()` instead.", gameObject);

            if (ungrabRoutine != null)
            {
                StopCoroutine(ungrabRoutine);
            }

            ungrabRoutine = StartCoroutine(DoUngrabAtEndOfFrame(interactor));
        }
        /// <summary>
        /// Notifies that the Interactable is no longer being grabbed.
        /// </summary>
        /// <param name="data">The previous grabbing object.</param>
        public virtual void NotifyUngrab(GameObject data)
        {
            InteractorFacade interactor = InteractorFacade.TryGetFromGameObject(data);

            if (interactor != null)
            {
                facade?.Ungrabbed?.Invoke(interactor);
                interactor.Ungrabbed?.Invoke(facade);
                interactor.grabInteractorSetup?.grabbedObjects?.RemoveElement(facade?.gameObject);
            }
        }
        /// <summary>
        /// Prepares the initiator for a kinematic change if the initiator is an Interactor.
        /// </summary>
        /// <param name="initiator">The potential Interactor causing this state change.</param>
        protected virtual void PrepareColliderForKinematicChange(GameObject initiator)
        {
            InteractorFacade interactor = initiator.GetComponent <InteractorFacade>();

            if (interactor == null)
            {
                return;
            }

            interactor.TouchConfiguration.TouchTracker.PrepareKinematicStateChange(GrabSetup.Facade.Configuration.ConsumerRigidbody);
        }
Exemplo n.º 27
0
 public void UnGrabbed(InteractorFacade hand)
 {
     if (canGetOff)
     {
         climbRef.StopClimbing(thisInteractible, hand);
     }
     else if (!tryingToGetOff)
     {
         StartCoroutine(GetOffWhenCan(hand));
     }
 }
 private NodeObject GrabbedNode(InteractorFacade hand)
 {
     foreach (GameObject obj in hand.GrabbedObjects)
     {
         Debug.Log("Trigger pressed while object is grabbed: " + obj);
         NodeObject grabbedNode = obj.GetComponent <NodeObject>();
         if (grabbedNode != null)
         {
             return(grabbedNode);
         }
     }
     return(null);
 }
        /// <summary>
        /// Attempts to unhighlight the <see cref="Facade.Interactbale"/> meshes.
        /// </summary>
        /// <param name="interactor">The Interactor initiating the interaction.</param>
        public virtual void AttemptUnhighlight(InteractorFacade interactor)
        {
            if (Facade.UnhighlightMaterial != null)
            {
                ApplyMaterialToAllMeshes(Facade.Interactable, Facade.UnhighlightMaterial);
            }
            else if (Facade.HighlightMaterial != null)
            {
                ResetInteractableMaterialsFromCache();
            }

            Facade.Unhighlighted?.Invoke(interactor);
        }
Exemplo n.º 30
0
        public virtual GameObject ExtractAttachPoint(InteractorFacade interactor)
        {
            Debug.LogWarning("`InteractorExtractor.ExtractAttachPoint()` has been deprecated. Use `InteractorAttachPointExtractor.Extract()` instead.", gameObject);

            if (interactor == null || interactor.GrabConfiguration == null)
            {
                Result = null;
                return(null);
            }

            cachedGrabAttachPoint = interactor.GrabAttachPoint;
            return(base.Extract());
        }