protected override void OnEnable()
        {
            AnimatorStateInfo    animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(animator);
            LocomotionController currentController = GetComponent <LocomotionTracker>().GetCurrentController();

            if (currentController is SlideController)
            {
                base.Sled          = ((SlideController)currentController).Sled;
                base.SledTransform = ((SlideController)currentController).SledTransform;
                base.Pilot         = ((SlideController)currentController).Pilot;
                if (base.Sled == null || base.SledTransform == null || base.Pilot == null || LocomotionUtils.IsInAir(animatorStateInfo) || LocomotionUtils.IsLanding(animatorStateInfo) || ((SlideController)currentController).CurrentMode == Mode.Animated)
                {
                    base.enabled = false;
                    return;
                }
                ((SlideController)currentController).ToRaceController = true;
                FromSlideController = true;
            }
            else if (!LocomotionUtils.IsIdling(animatorStateInfo) && !LocomotionUtils.IsLocomoting(animatorStateInfo))
            {
                base.enabled = false;
                return;
            }
            base.OnEnable();
            if (myMutableData.SpeedLinesTubeRacePrefab != null)
            {
                speedLines = Object.Instantiate(myMutableData.SpeedLinesTubeRacePrefab);
                CameraCullingMaskHelper.SetLayerIncludingChildren(speedLines.transform, LayerMask.LayerToName(base.gameObject.layer));
                Vector3    localPosition = new Vector3(speedLines.transform.position.x, speedLines.transform.position.y, speedLines.transform.position.z);
                Quaternion localRotation = new Quaternion(speedLines.transform.rotation.x, speedLines.transform.rotation.y, speedLines.transform.rotation.z, speedLines.transform.rotation.w);
                speedLines.transform.parent        = base.transform;
                speedLines.transform.localPosition = localPosition;
                speedLines.transform.localRotation = localRotation;
                speedLines.SetActive(value: false);
            }
            if (visualizeTrackSegment)
            {
                steeringObject         = new GameObject();
                steeringObjectRenderer = steeringObject.AddComponent <LineRenderer>();
                steeringObjectRenderer.transform.parent = base.gameObject.transform;
                steeringObjectRenderer.useWorldSpace    = true;
                trackDirObject   = new GameObject();
                trackDirRenderer = trackDirObject.AddComponent <LineRenderer>();
                trackDirObject.transform.parent = base.gameObject.transform;
                trackDirRenderer.useWorldSpace  = true;
            }
            if (FromSlideController)
            {
                mode           = Mode.Animated;
                base.IsSliding = true;
            }
            steerVel = Vector3.zero;
        }
Beispiel #2
0
        protected IEnumerator waitForValidLocomotionModeToInteract()
        {
            if (locomotionTracker != null && locomotionTracker.GetCurrentController() is RunController)
            {
                Animator      anim          = GetComponent <Animator>();
                RunController runController = (RunController)locomotionTracker.GetCurrentController();
                RunController.ControllerBehaviour oldBehaviour = runController.Behaviour;
                runController.Behaviour = new RunController.ControllerBehaviour
                {
                    IgnoreCollisions   = false,
                    IgnoreGravity      = false,
                    IgnoreRotation     = false,
                    IgnoreTranslation  = false,
                    IgnoreJumpRequests = true,
                    IgnoreStickInput   = true,
                    LastModifier       = this
                };
                AnimatorStateInfo animStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim);
                while (!LocomotionUtils.IsLocomoting(animStateInfo) && !LocomotionUtils.IsLanding(animStateInfo) && !LocomotionUtils.IsIdling(animStateInfo))
                {
                    yield return(null);

                    animStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim);
                }
                runController.ResetMomentum();
                if (runController.Behaviour.LastModifier == this)
                {
                    runController.Behaviour = oldBehaviour;
                }
            }
        }
        private bool canSitFromCurrentState()
        {
            AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(animator);

            return(LocomotionUtils.IsIdling(animatorStateInfo) || LocomotionUtils.IsLocomoting(animatorStateInfo) || LocomotionUtils.IsInAir(animatorStateInfo) || LocomotionUtils.IsLanding(animatorStateInfo) || LocomotionUtils.IsSwimming(animatorStateInfo));
        }
        protected virtual bool canSlideFromCurrentState()
        {
            AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(animator);

            return(LocomotionUtils.IsIdling(animatorStateInfo) || LocomotionUtils.IsLocomoting(animatorStateInfo) || LocomotionUtils.IsInAir(animatorStateInfo) || LocomotionUtils.IsLanding(animatorStateInfo));
        }
 private void applyIK()
 {
     if (propUser == null)
     {
         propUser = GetComponent <PropUser>();
         if (propUser == null)
         {
             return;
         }
     }
     if (curPropGO == null)
     {
         if (propUser.Prop != null)
         {
             resetIK(propUser.Prop.gameObject);
         }
         else
         {
             InvitationalItemController componentInChildren = GetComponentInChildren <InvitationalItemController>();
             if (componentInChildren != null)
             {
                 curPropGO = componentInChildren.gameObject;
                 resetIK(curPropGO);
             }
         }
     }
     if (curPropGO == null && isHoldingProp)
     {
         AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(1);
         if (!LocomotionUtils.IsUsing(currentAnimatorStateInfo))
         {
             resetIK(null);
         }
     }
     if (propIK != null && ikBones.Count > 0)
     {
         AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(animator);
         for (int i = 0; i < ikBones.Count; i++)
         {
             if (swim.IsInShallowWater)
             {
                 if (LocomotionUtils.IsIdling(animatorStateInfo))
                 {
                     ikBones[i].TargetAngle = propIK.IKModifiers[i].IdleZRot;
                 }
                 else
                 {
                     ikBones[i].TargetAngle = propIK.IKModifiers[i].SwimMoveZRot;
                 }
             }
             else if (LocomotionUtils.IsIdling(animatorStateInfo))
             {
                 ikBones[i].TargetAngle = propIK.IKModifiers[i].IdleZRot;
             }
             else
             {
                 ikBones[i].TargetAngle = propIK.IKModifiers[i].DiveMoveZRot;
             }
         }
     }
     blendIK();
 }