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; } } }
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; }
private IEnumerator SampleSurface() { while (true) { if (base.isActiveAndEnabled) { Vector3 hitPoint = Vector3.zero; int num = LocomotionUtils.SampleSurface(base.transform, SurfaceSamplingData, out hitPoint); AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(anim); if (LocomotionUtils.IsLocomoting(animatorStateInfo)) { if (LocomotionUtils.IsWalking(animatorStateInfo)) { if (locoStatus != LocomotionStatus.Walking || num != prevSurfaceTypeIndex) { locoStatus = LocomotionStatus.Walking; if (num >= 0) { if (!string.IsNullOrEmpty(SurfaceSamplingData.Effects[num].WalkSwitch.SwitchValue)) { EventManager.Instance.PostEvent(SurfaceSamplingData.Effects[num].WalkSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.Effects[num].WalkSwitch.SwitchValue, base.gameObject); } } else if (!string.IsNullOrEmpty(SurfaceSamplingData.DefaultWalkSwitch.EventName)) { EventManager.Instance.PostEvent(SurfaceSamplingData.DefaultWalkSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.DefaultWalkSwitch.SwitchValue, base.gameObject); } } } else if (locoStatus != LocomotionStatus.Jogging || num != prevSurfaceTypeIndex) { locoStatus = LocomotionStatus.Jogging; if (num >= 0) { if (!string.IsNullOrEmpty(SurfaceSamplingData.Effects[num].JogSwitch.SwitchValue)) { EventManager.Instance.PostEvent(SurfaceSamplingData.Effects[num].JogSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.Effects[num].JogSwitch.SwitchValue, base.gameObject); } } else if (!string.IsNullOrEmpty(SurfaceSamplingData.DefaultJogSwitch.EventName)) { EventManager.Instance.PostEvent(SurfaceSamplingData.DefaultJogSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.DefaultJogSwitch.SwitchValue, base.gameObject); } } } else if (LocomotionUtils.IsInAir(animatorStateInfo) || LocomotionUtils.IsLanding(animatorStateInfo)) { if (locoStatus != LocomotionStatus.InAir || num != prevSurfaceTypeIndex) { locoStatus = LocomotionStatus.InAir; if (num >= 0) { if (!string.IsNullOrEmpty(SurfaceSamplingData.Effects[num].LandSwitch.SwitchValue)) { EventManager.Instance.PostEvent(SurfaceSamplingData.Effects[num].LandSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.Effects[num].LandSwitch.SwitchValue, base.gameObject); } } else if (!string.IsNullOrEmpty(SurfaceSamplingData.DefaultLandSwitch.EventName)) { EventManager.Instance.PostEvent(SurfaceSamplingData.DefaultLandSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.DefaultLandSwitch.SwitchValue, base.gameObject); } } } else if (tracker.IsCurrentControllerOfType <SlideController>()) { if (locoStatus != LocomotionStatus.Tubing || num != prevSurfaceTypeIndex) { locoStatus = LocomotionStatus.Tubing; if (num >= 0) { if (!string.IsNullOrEmpty(SurfaceSamplingData.Effects[num].TubeSlideLoopSwitch.SwitchValue)) { EventManager.Instance.PostEvent(SurfaceSamplingData.Effects[num].TubeSlideLoopSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.Effects[num].TubeSlideLoopSwitch.SwitchValue, base.gameObject); } } else if (!string.IsNullOrEmpty(SurfaceSamplingData.DefaultTubeSlideLoopSwitch.EventName)) { EventManager.Instance.PostEvent(SurfaceSamplingData.DefaultTubeSlideLoopSwitch.EventName, EventAction.SetSwitch, SurfaceSamplingData.DefaultTubeSlideLoopSwitch.SwitchValue, base.gameObject); } } } else { locoStatus = LocomotionStatus.Unknown; } prevSurfaceTypeIndex = num; } yield return(new WaitForSeconds(sampleTime)); } }
protected virtual bool canSlideFromCurrentState() { AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(animator); return(LocomotionUtils.IsIdling(animatorStateInfo) || LocomotionUtils.IsLocomoting(animatorStateInfo) || LocomotionUtils.IsInAir(animatorStateInfo) || LocomotionUtils.IsLanding(animatorStateInfo)); }
private bool canSitFromCurrentState() { AnimatorStateInfo animatorStateInfo = LocomotionUtils.GetAnimatorStateInfo(animator); return(LocomotionUtils.IsIdling(animatorStateInfo) || LocomotionUtils.IsLocomoting(animatorStateInfo) || LocomotionUtils.IsInAir(animatorStateInfo) || LocomotionUtils.IsLanding(animatorStateInfo) || LocomotionUtils.IsSwimming(animatorStateInfo)); }