// Called by the InteractionSystem when an interaction is resumed from being paused
        private void OnDrop(FullBodyBipedEffector effectorType, InteractionObject interactionObject)
        {
            if (effectorType != FullBodyBipedEffector.LeftHand) return;

            // Make the box independent of the character
            box.transform.parent = null;

            // Turn on physics for the box
            if (box.GetComponent<Rigidbody>() != null) box.GetComponent<Rigidbody>().isKinematic = false;
        }
		// Called by the InteractionSystem when an interaction starts
		private void OnStart(FullBodyBipedEffector effectorType, InteractionObject interactionObject) {
			if (effectorType != FullBodyBipedEffector.LeftHand) return;
			if (interactionObject != obj) return;
			
			// Rotate the pivot of the hand targets
			RotatePivot();

			// Rotate the hold point so it matches the current rotation of the object
			holdPoint.rotation = obj.transform.rotation;
		}
Example #3
0
        // Start interaction
        public bool Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
        {
            // Get the InteractionTarget
            target = interactionObject.GetTarget(effectorType, tag);
            if (target == null)
            {
                return(false);
            }
            interactionTarget = target.GetComponent <InteractionTarget>();

            return(Start(interactionObject, interactionTarget, fadeInTime, interrupt));
        }
Example #4
0
 public InteractionObject[] GetClosestInteractionObjectsInRange()
 {
     InteractionTrigger.Range closestInteractionRange = this.GetClosestInteractionRange();
     if (closestInteractionRange == null)
     {
         return(new InteractionObject[0]);
     }
     InteractionObject[] array = new InteractionObject[closestInteractionRange.interactions.Length];
     for (int i = 0; i < closestInteractionRange.interactions.Length; i++)
     {
         array[i] = closestInteractionRange.interactions[i].interactionObject;
     }
     return(array);
 }
Example #5
0
        /// <summary>
        /// Starts the interaction between an effector and an interaction object.
        /// </summary>
        public void StartInteraction(FullBodyBipedEffector effectorType, InteractionObject interactionObject, bool interrupt)
        {
            if (!IsValid(true))
            {
                return;
            }

            for (int i = 0; i < interactionEffectors.Length; i++)
            {
                if (interactionEffectors[i].effectorType == effectorType)
                {
                    interactionEffectors[i].Start(interactionObject, targetTag, fadeInTime, interrupt);
                    return;
                }
            }
        }
		// Called by the InteractionSystem when an interaction is paused (on trigger)
		private void OnPause(FullBodyBipedEffector effectorType, InteractionObject interactionObject) {
			if (effectorType != FullBodyBipedEffector.LeftHand) return;
			if (interactionObject != obj) return;

			// Make the object inherit the character's movement
			obj.transform.parent = interactionSystem.transform;
			
			// Make the object kinematic
			var r = obj.GetComponent<Rigidbody>();
			if (r != null) r.isKinematic = true;

			// Set object pick up position and rotation to current
			pickUpPosition = obj.transform.position;
			pickUpRotation = obj.transform.rotation;
			holdWeight = 0f;
			holdWeightVel = 0f;
		}
Example #7
0
        /// <summary>
        /// Gets the closest InteractionObjects in range.
        /// </summary>
        public InteractionObject[] GetClosestInteractionObjectsInRange()
        {
            var range = GetClosestInteractionRange();

            if (range == null)
            {
                return(new InteractionObject[0]);
            }

            InteractionObject[] objects = new InteractionObject[range.interactions.Length];

            for (int i = 0; i < range.interactions.Length; i++)
            {
                objects[i] = range.interactions[i].interactionObject;
            }

            return(objects);
        }
Example #8
0
 public bool StartInteraction(FullBodyBipedEffector effectorType, InteractionObject interactionObject, bool interrupt)
 {
     if (!this.IsValid(true))
     {
         return(false);
     }
     if (interactionObject == null)
     {
         return(false);
     }
     for (int i = 0; i < this.interactionEffectors.Length; i++)
     {
         if (this.interactionEffectors[i].effectorType == effectorType)
         {
             return(this.interactionEffectors[i].Start(interactionObject, this.targetTag, this.fadeInTime, interrupt));
         }
     }
     return(false);
 }
Example #9
0
        /// <summary>
        /// Starts the interaction between an effector and an interaction object.
        /// </summary>
        public void StartInteraction(FullBodyBipedEffector effectorType, InteractionObject interactionObject, bool interrupt)
        {
            if (!IsValid(true)) return;

            for (int i = 0; i < interactionEffectors.Length; i++) {
                if (interactionEffectors[i].effectorType == effectorType) {
                    interactionEffectors[i].Start(interactionObject, targetTag, fadeInTime, interrupt);
                    return;
                }
            }
        }
Example #10
0
        // Start interaction
        public bool Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
        {
            // If not in interaction, set effector positions to their bones
            if (!inInteraction)
            {
                effector.position = effector.bone.position;;
                effector.rotation = effector.bone.rotation;;
            }
            else
            {
                if (!interrupt)
                {
                    return(false);
                }
            }

            // Get the InteractionTarget
            target = interactionObject.GetTarget(effectorType, tag);
            if (target == null)
            {
                return(false);
            }
            interactionTarget = target.GetComponent <InteractionTarget>();

            // Start the interaction
            this.interactionObject = interactionObject;
            if (interactionSystem.OnInteractionStart != null)
            {
                interactionSystem.OnInteractionStart(effectorType, interactionObject);
            }

            // Cleared triggered events
            triggered.Clear();

            for (int i = 0; i < interactionObject.events.Length; i++)
            {
                triggered.Add(false);
            }

            // Posing the hand/foot
            if (poser != null)
            {
                if (poser.poseRoot == null)
                {
                    poser.weight = 0f;
                }

                if (interactionTarget != null)
                {
                    poser.poseRoot = target.transform;
                }
                else
                {
                    poser.poseRoot = null;
                }

                poser.AutoMapping();
            }

            // Reset internal values
            timer       = 0f;
            weight      = 0f;
            fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f;
            length      = interactionObject.length;

            isPaused       = false;
            pickedUp       = false;
            pickUpPosition = Vector3.zero;
            pickUpRotation = Quaternion.identity;

            if (interactionTarget != null)
            {
                interactionTarget.RotateTo(effector.bone.position);
            }

            return(true);
        }
Example #11
0
        // Start interaction
        public void Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
        {
            // If not in interaction, set effector positions to their bones
            if (!inInteraction)
            {
                effector.position = effector.bone.position;
                effector.rotation = effector.bone.rotation;
            }
            else if (!interrupt)
            {
                return;
            }

            // Get the InteractionTarget
            target = interactionObject.GetTarget(effectorType, tag);
            if (target == null)
            {
                return;
            }
            interactionTarget = target.GetComponent <InteractionTarget>();

            // Start the interaction
            this.interactionObject = interactionObject;
            if (OnStart != null)
            {
                OnStart(effectorType, interactionObject);
            }

            // Posing the hand/foot
            if (poser != null)
            {
                if (poser.poseRoot == null)
                {
                    poser.weight = 0f;
                }

                if (interactionTarget != null)
                {
                    poser.poseRoot = target.transform;
                }
                else
                {
                    poser.poseRoot = null;
                }

                poser.AutoMapping();
            }

            // Reset internal values
            timer       = 0f;
            weight      = 0f;
            fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f;
            length      = interactionObject.length;

            triggered = false;
            released  = false;
            isPaused  = false;

            pickedUp       = false;
            pickUpPosition = Vector3.zero;
            pickUpRotation = Quaternion.identity;

            // Call StartInteraction on the InteractionObject
            interactionObject.StartInteraction(effector.bone);
            if (interactionTarget != null)
            {
                interactionTarget.RotateTo(effector.bone.position);
            }
        }
        // Called by the InteractionSystem when an interaction starts
        private void OnStart(FullBodyBipedEffector effectorType, InteractionObject interactionObject)
        {
            if (effectorType != FullBodyBipedEffector.LeftHand) return;

            // Rotate the pivot of the hand targets by 90 degrees so we could grab the box from any direction

            // Get the flat direction towards the character
            Vector3 characterDirection = (interactionSystem.transform.position - pivot.position).normalized;
            characterDirection.y = 0f;

            // Convert the direction to local space of the box
            Vector3 characterDirectionLocal = box.transform.InverseTransformDirection(characterDirection);

            // QuaTools.GetAxis returns a 90 degree ortographic axis for any direction
            Vector3 axis = QuaTools.GetAxis(characterDirectionLocal);
            Vector3 upAxis = QuaTools.GetAxis(box.transform.InverseTransformDirection(interactionSystem.transform.up));

            // Rotate towards axis and upAxis
            pivot.localRotation = Quaternion.LookRotation(axis, upAxis);

            // Rotate the hold point so it matches the current rotation of the box
            boxHoldPoint.rotation = box.transform.rotation;
        }
Example #13
0
 public bool Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
 {
     if (!this.inInteraction)
     {
         this.effector.position = this.effector.bone.position;
         this.effector.rotation = this.effector.bone.rotation;
     }
     else if (!interrupt)
     {
         return(false);
     }
     this.target = interactionObject.GetTarget(this.effectorType, tag);
     if (this.target == null)
     {
         return(false);
     }
     this.interactionTarget = this.target.GetComponent <InteractionTarget>();
     this.interactionObject = interactionObject;
     if (this.interactionSystem.OnInteractionStart != null)
     {
         this.interactionSystem.OnInteractionStart(this.effectorType, interactionObject);
     }
     interactionObject.OnStartInteraction(this.interactionSystem);
     this.triggered.Clear();
     for (int i = 0; i < interactionObject.events.Length; i++)
     {
         this.triggered.Add(false);
     }
     if (this.poser != null)
     {
         if (this.poser.poseRoot == null)
         {
             this.poser.weight = 0f;
         }
         if (this.interactionTarget != null)
         {
             this.poser.poseRoot = this.target.transform;
         }
         else
         {
             this.poser.poseRoot = null;
         }
         this.poser.AutoMapping();
     }
     this.positionWeightUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PositionWeight);
     this.rotationWeightUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.RotationWeight);
     this.pullUsed           = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Pull);
     this.reachUsed          = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Reach);
     this.pushUsed           = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Push);
     this.pushParentUsed     = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PushParent);
     this.StoreDefaults();
     this.timer          = 0f;
     this.weight         = 0f;
     this.fadeInSpeed    = ((fadeInTime > 0f) ? (1f / fadeInTime) : 1000f);
     this.length         = interactionObject.length;
     this.isPaused       = false;
     this.pickedUp       = false;
     this.pickUpPosition = Vector3.zero;
     this.pickUpRotation = Quaternion.identity;
     if (this.interactionTarget != null)
     {
         this.interactionTarget.RotateTo(this.effector.bone.position);
     }
     this.started = true;
     return(true);
 }
Example #14
0
			// Called by the interaction system
			private void OnInteractionStop(FullBodyBipedEffector effectorType, InteractionObject interactionObject) {
				if (effectorType != this.effectorType || interactionObject != this.interactionObject) return;
				
				inTouch = false;
			}
Example #15
0
		private void InteractionStop(FullBodyBipedEffector effector, InteractionObject interactionObject) {
			lookAt.isPaused = false;
		
		}
		// Called by the delegate
		private void LookAtInteraction(FullBodyBipedEffector effector, InteractionObject interactionObject) {
			lookAt.Look(interactionObject.lookAtTarget, Time.time + (interactionObject.length * 0.5f));
		}
        // Start interaction
        public bool Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
        {
            // If not in interaction, set effector positions to their bones
            if (!inInteraction)
            {
                effector.position = effector.bone.position;;
                effector.rotation = effector.bone.rotation;;
            }
            else
            {
                if (!interrupt)
                {
                    return(false);
                }
            }

            // Get the InteractionTarget
            target = interactionObject.GetTarget(effectorType, tag);
            if (target == null)
            {
                return(false);
            }
            interactionTarget = target.GetComponent <InteractionTarget>();

            // Start the interaction
            this.interactionObject = interactionObject;
            if (interactionSystem.OnInteractionStart != null)
            {
                interactionSystem.OnInteractionStart(effectorType, interactionObject);
            }
            interactionObject.OnStartInteraction(interactionSystem);

            // Cleared triggered events
            triggered.Clear();

            for (int i = 0; i < interactionObject.events.Length; i++)
            {
                triggered.Add(false);
            }

            // Posing the hand/foot
            if (poser != null)
            {
                if (poser.poseRoot == null)
                {
                    poser.weight = 0f;
                }

                if (interactionTarget != null)
                {
                    poser.poseRoot = target.transform;
                }
                else
                {
                    poser.poseRoot = null;
                }

                poser.AutoMapping();
            }

            // See which InteractionObject.WeightCurve.Types are used
            //private bool positionWeightUsed, rotationWeightUsed, pullUsed, reachUsed, pushUsed, pushParentUsed, poserUsed;
            positionWeightUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PositionWeight);
            rotationWeightUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.RotationWeight);
            pullUsed           = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Pull);
            reachUsed          = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Reach);
            pushUsed           = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.Push);
            pushParentUsed     = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PushParent);
            //poserUsed = interactionObject.CurveUsed(InteractionObject.WeightCurve.Type.PoserWeight);
            StoreDefaults();

            // Reset internal values
            timer       = 0f;
            weight      = 0f;
            fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f;
            length      = interactionObject.length;

            isPaused       = false;
            pickedUp       = false;
            pickUpPosition = Vector3.zero;
            pickUpRotation = Quaternion.identity;

            if (interactionTarget != null)
            {
                interactionTarget.RotateTo(effector.bone.position);
            }

            started = true;

            return(true);
        }
        // Called by the InteractionSystem when an interaction is paused (on trigger)
        private void OnPause(FullBodyBipedEffector effectorType, InteractionObject interactionObject)
        {
            if (effectorType != FullBodyBipedEffector.LeftHand) return;

            // Make the box inherit the character's movement
            box.transform.parent = interactionSystem.transform;

            // Make the box kinematic
            if (box.GetComponent<Rigidbody>() != null) box.GetComponent<Rigidbody>().isKinematic = true;

            // Set box lerping speed to 0 so we can smoothly accelerate picking up from that
            currentBoxLerpSpeed = 0f;
        }
Example #19
0
 // Called by the delegate
 private void LookAtInteraction(FullBodyBipedEffector effector, InteractionObject interactionObject)
 {
     lookAt.Look(interactionObject.lookAtTarget, Time.time + (interactionObject.length * 0.5f));
 }
Example #20
0
 private void InteractionPause(FullBodyBipedEffector effector, InteractionObject interactionObject)
 {
     lookAt.isPaused = true;
 }
Example #21
0
 // Called by the InteractionSystem on start of an interaction
 private void OnInteractionStart(FullBodyBipedEffector effector, InteractionObject interactionObject)
 {
     lookAtTarget = interactionObject.lookAtTarget;
     stopLookTime = Time.time + (interactionObject.length * 0.5f);
 }
 public bool Resume() => default;                                                                                 // 0x00000001807DC630-0x00000001807DC6E0
 public bool Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt) => default; // 0x00000001807DC6E0-0x00000001807DCC40
Example #23
0
 private void InteractionResume(FullBodyBipedEffector effector, InteractionObject interactionObject)
 {
     this.lookAt.isPaused = false;
 }
Example #24
0
 private void InteractionStop(FullBodyBipedEffector effector, InteractionObject interactionObject)
 {
     lookAt.isPaused = false;
 }
		// Start interaction
		public bool Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt) {
			// If not in interaction, set effector positions to their bones
			if (!inInteraction) {
				effector.position = effector.bone.position;;
				effector.rotation = effector.bone.rotation;;
			} else {
				if (!interrupt) return false;
			}

			// Get the InteractionTarget
			target = interactionObject.GetTarget(effectorType, tag);
			if (target == null) return false;
			interactionTarget = target.GetComponent<InteractionTarget>();

			// Start the interaction
			this.interactionObject = interactionObject;
			if (interactionSystem.OnInteractionStart != null) interactionSystem.OnInteractionStart(effectorType, interactionObject);
			interactionObject.OnStartInteraction(interactionSystem);
			
			// Cleared triggered events
			triggered.Clear();

			for (int i = 0; i < interactionObject.events.Length; i++) {
				triggered.Add(false);
			}

			// Posing the hand/foot
			if (poser != null) {
				if (poser.poseRoot == null) poser.weight = 0f;

				if (interactionTarget != null) poser.poseRoot = target.transform;
				else poser.poseRoot = null;

				poser.AutoMapping();
			}

			// Reset internal values
			timer = 0f;
			weight = 0f;
			fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f;
			length = interactionObject.length;
			
			isPaused = false;
			pickedUp = false;
			pickUpPosition = Vector3.zero;
			pickUpRotation = Quaternion.identity;

			if (interactionTarget != null) interactionTarget.RotateTo(effector.bone.position);

			started = true;

			return true;
		}
Example #26
0
 // Called by the InteractionSystem on start of an interaction
 private void OnInteractionStart(FullBodyBipedEffector effector, InteractionObject interactionObject)
 {
     lookAtTarget = interactionObject.lookAtTarget;
     stopLookTime = Time.time + (interactionObject.length * 0.5f);
 }
Example #27
0
		private void InteractionPause(FullBodyBipedEffector effector, InteractionObject interactionObject) {
			lookAt.isPaused = true;
		}
Example #28
0
 // Should a curve of the Type be ignored for this effector?
 public float GetValue(InteractionObject.WeightCurve.Type curveType)
 {
     for (int i = 0; i < multipliers.Length; i++) if (multipliers[i].curve == curveType) return multipliers[i].multiplier;
     return 1f;
 }
Example #29
0
        // Start interaction
        public void Start(InteractionObject interactionObject, string tag, float fadeInTime, bool interrupt)
        {
            // If not in interaction, set effector positions to their bones
            if (!inInteraction) {
                effector.position = effector.bone.position;
                effector.rotation = effector.bone.rotation;
            } else if (!interrupt) return;

            // Get the InteractionTarget
            target = interactionObject.GetTarget(effectorType, tag);
            if (target == null) return;
            interactionTarget = target.GetComponent<InteractionTarget>();

            // Start the interaction
            this.interactionObject = interactionObject;
            if (OnStart != null) OnStart(effectorType, interactionObject);

            // Posing the hand/foot
            if (poser != null) {
                if (poser.poseRoot == null) poser.weight = 0f;

                if (interactionTarget != null) poser.poseRoot = target.transform;
                else poser.poseRoot = null;

                poser.AutoMapping();
            }

            // Reset internal values
            timer = 0f;
            weight = 0f;
            fadeInSpeed = fadeInTime > 0f? 1f / fadeInTime: 1000f;
            length = interactionObject.length;

            triggered = false;
            released = false;
            isPaused = false;

            pickedUp = false;
            pickUpPosition = Vector3.zero;
            pickUpRotation = Quaternion.identity;

            // Call StartInteraction on the InteractionObject
            interactionObject.StartInteraction(effector.bone);
            if (interactionTarget != null) interactionTarget.RotateTo(effector.bone.position);
        }