private static string GetFullName(GameObject current) { if (current == null) { return(string.Empty); } if (current.transform.parent == null) { return("/" + current.name); } return(CinemachineOrbitalTransposer.GetFullName(current.transform.parent.gameObject) + "/" + current.name); }
private float GetTargetHeading(float currentHeading, Quaternion targetOrientation, float deltaTime) { if (this.m_BindingMode == CinemachineTransposer.BindingMode.SimpleFollowWithWorldUp) { return(0f); } if (base.FollowTarget == null) { return(currentHeading); } if (this.m_Heading.m_HeadingDefinition == CinemachineOrbitalTransposer.Heading.HeadingDefinition.Velocity && this.mTargetRigidBody == null) { Debug.Log(string.Format("Attempted to use HeadingDerivationMode.Velocity to calculate heading for {0}. No RigidBody was present on '{1}'. Defaulting to position delta", CinemachineOrbitalTransposer.GetFullName(base.VirtualCamera.VirtualCameraGameObject), base.FollowTarget)); this.m_Heading.m_HeadingDefinition = CinemachineOrbitalTransposer.Heading.HeadingDefinition.PositionDelta; } Vector3 vector = Vector3.zero; switch (this.m_Heading.m_HeadingDefinition) { case CinemachineOrbitalTransposer.Heading.HeadingDefinition.PositionDelta: vector = base.FollowTarget.position - this.mLastTargetPosition; goto IL_E9; case CinemachineOrbitalTransposer.Heading.HeadingDefinition.Velocity: vector = this.mTargetRigidBody.velocity; goto IL_E9; case CinemachineOrbitalTransposer.Heading.HeadingDefinition.TargetForward: vector = base.FollowTarget.forward; goto IL_E9; } return(0f); IL_E9: int num = this.m_Heading.m_VelocityFilterStrength * 5; if (this.mHeadingTracker == null || this.mHeadingTracker.FilterSize != num) { this.mHeadingTracker = new CinemachineOrbitalTransposer.HeadingTracker(num); } this.mHeadingTracker.DecayHistory(); Vector3 vector2 = targetOrientation * Vector3.up; vector = vector.ProjectOntoPlane(vector2); if (!vector.AlmostZero()) { this.mHeadingTracker.Add(vector); } vector = this.mHeadingTracker.GetReliableHeading(); if (!vector.AlmostZero()) { return(UnityVectorExtensions.SignedAngle(targetOrientation * Vector3.forward, vector, vector2)); } return(currentHeading); }