public static bool SetCurrentController <T>(GameObject target) where T : LocomotionController { LocomotionTracker component = target.GetComponent <LocomotionTracker>(); if (component != null) { return(component.SetCurrentController <T>()); } return(false); }
public void Awake() { agent = GetComponent <NavMeshAgent>(); tracker = GetComponent <LocomotionTracker>(); agent.updatePosition = false; agent.updateRotation = false; tracker.SetCurrentController <RunController>(); runController = GetComponent <RunController>(); runController.Behaviour.SetStyle(LocoStyle); }
private void OnTriggerStay(Collider trigger) { SurfaceSwimProperties surfaceSwimProperties = getVolumeTriggerProperties(trigger); if (!base.enabled && Active && (tracker.IsCurrentControllerOfType <RunController>() || (tracker.IsCurrentControllerOfType <SlideController>() && (tracker.GetCurrentController() as SlideController).CurrentMode == SlideController.Mode.Animated)) && surfaceSwimProperties != null && (surfaceSwimProperties.Type == SurfaceSwimProperties.VolumeType.Diving || !isWaterTooShallow(mutableData.MaxShallowWaterDepth + mutableData.ShallowWaterDepthHysteresis))) { tracker.SetCurrentController <SwimController>(); enableWaterEffects(); } }
private void TryExitSit() { if (!SceneRefs.ActionSequencer.GetTrigger(base.gameObject)) { tracker.SetCurrentController <RunController>(); if (exitingViaJump && tracker.GetCurrentController() is RunController && !IsUnderwater) { tracker.GetCurrentController().DoAction(LocomotionAction.Jump); } } }
private IEnumerator toggleSlide() { togglingSlide = true; float timeRemainingBeforeAllowingToggle = minTimeBetweenSlideToggles - (Time.time - lastSlideToggleTime); if (timeRemainingBeforeAllowingToggle > 0f) { yield return(new WaitForSeconds(timeRemainingBeforeAllowingToggle)); } if (SceneRefs.ActionSequencer != null) { SceneRefs.ActionSequencer.UserInputReceived(); } lastSlideToggleTime = Time.time; if (tracker.IsCurrentControllerOfType <SlideController>()) { tracker.SetCurrentController <RunController>(); } else if (tracker.IsCurrentControllerOfType <RunController>()) { tracker.SetCurrentController <SlideController>(); } togglingSlide = false; }
public void MoveToTarget(Transform target, float distanceThreshold = 0.15f, PlayerLocoStyle.Style locomotionStyle = PlayerLocoStyle.Style.Walk, float timeoutTime = 15f, bool autoDestroy = true) { targetDestination = target; actorRadius = 0f; actorHalfHeight = 0.1f; this.timeoutTime = timeoutTime; this.autoDestroy = autoDestroy; CharacterController component = GetComponent <CharacterController>(); if (component != null) { actorRadius = component.radius; actorHalfHeight = component.height / 2f; } LocomotionTracker component2 = GetComponent <LocomotionTracker>(); if (component2.SetCurrentController <RunController>()) { runController = GetComponent <RunController>(); if (!runControllerBehaviourWasSet) { oldRunBehaviour = runController.Behaviour; runController.Behaviour = new RunController.ControllerBehaviour { IgnoreCollisions = false, IgnoreGravity = false, IgnoreRotation = false, IgnoreTranslation = false, IgnoreJumpRequests = true, IgnoreStickInput = true, Style = locomotionStyle }; runControllerBehaviourWasSet = true; } runController.ResetMomentum(); dest = targetDestination.transform.position; Vector3 vector = dest - base.transform.position; if (vector == Vector3.zero) { vector = base.transform.forward; } distThresholdSq = distanceThreshold * distanceThreshold; vector.y = 0f; elapsedTime = 0f; done = false; } if (!CanReachWaypoint()) { if (this.OnComplete != null) { this.OnComplete(); } runController.Steer(Vector3.zero); runController.SnapToPosition(dest); runController.SnapToFacing(targetDestination.transform.forward); if (autoDestroy) { UnityEngine.Object.Destroy(this); } } }