Decompiled source of Optimized Kinematic Character Controller v1.0.0

patchers/KinematicCharacterController.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("KinematicCharacterController")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("KinematicCharacterController")]
[assembly: AssemblyTitle("KinematicCharacterController")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace KinematicCharacterController
{
	public abstract class BaseCharacterController : NetworkBehaviour, ICharacterController
	{
		public KinematicCharacterMotor Motor { get; private set; }

		public void SetupCharacterMotor(KinematicCharacterMotor motor)
		{
			Motor = motor;
			motor.CharacterController = this;
		}

		public abstract void UpdateRotation(ref Quaternion currentRotation, float deltaTime);

		public abstract void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime);

		public abstract void BeforeCharacterUpdate(float deltaTime);

		public abstract void PostGroundingUpdate(float deltaTime);

		public abstract void AfterCharacterUpdate(float deltaTime);

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public abstract bool IsColliderValidForCollisions(Collider coll);

		public abstract void OnGroundHit(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, ref HitStabilityReport hitStabilityReport);

		public abstract void OnMovementHit(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, ref HitStabilityReport hitStabilityReport);

		public abstract void ProcessHitStabilityReport(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, Vector3 atCharacterPosition, Quaternion atCharacterRotation, ref HitStabilityReport hitStabilityReport);

		public virtual void OnDiscreteCollisionDetected(Collider hitCollider)
		{
		}

		public virtual void HandleMovementProjection(ref Vector3 movement, Vector3 obstructionNormal, bool stableOnHit)
		{
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			if (Motor.GroundingStatus.IsStableOnGround && !Motor.MustUnground())
			{
				if (stableOnHit)
				{
					movement = Motor.GetDirectionTangentToSurface(movement, obstructionNormal) * ((Vector3)(ref movement)).magnitude;
					return;
				}
				Vector3 val = Vector3.Cross(obstructionNormal, Motor.GroundingStatus.GroundNormal);
				val = Vector3.Cross(((Vector3)(ref val)).normalized, obstructionNormal);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				movement = Motor.GetDirectionTangentToSurface(movement, normalized) * ((Vector3)(ref movement)).magnitude;
				movement = Vector3.ProjectOnPlane(movement, obstructionNormal);
			}
			else if (stableOnHit)
			{
				movement = Vector3.ProjectOnPlane(movement, Motor.CharacterUp);
				movement = Motor.GetDirectionTangentToSurface(movement, obstructionNormal) * ((Vector3)(ref movement)).magnitude;
			}
			else
			{
				movement = Vector3.ProjectOnPlane(movement, obstructionNormal);
			}
		}

		public virtual void HandleSimulatedRigidbodyInteraction(ref Vector3 processedVelocity, RigidbodyProjectionHit hit, float deltaTime)
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.2f;
			Vector3 angularVelocity;
			if (num > 0f && !hit.StableOnHit && !hit.Rigidbody.isKinematic)
			{
				float num2 = num / hit.Rigidbody.mass;
				Motor.GetVelocityFromRigidbodyMovement(hit.Rigidbody, hit.HitPoint, deltaTime, out var linearVelocity, out angularVelocity);
				Vector3 val = Vector3.Project(hit.HitVelocity, hit.EffectiveHitNormal) - linearVelocity;
				hit.Rigidbody.AddForceAtPosition(num2 * val, hit.HitPoint, (ForceMode)2);
			}
			if (!hit.StableOnHit)
			{
				Motor.GetVelocityFromRigidbodyMovement(hit.Rigidbody, hit.HitPoint, deltaTime, out var linearVelocity2, out angularVelocity);
				Vector3 val2 = Vector3.Project(linearVelocity2, hit.EffectiveHitNormal);
				Vector3 val3 = Vector3.Project(processedVelocity, hit.EffectiveHitNormal);
				processedVelocity += val2 - val3;
			}
		}

		private void UNetVersion()
		{
		}

		public override bool OnSerialize(NetworkWriter writer, bool forceAll)
		{
			return false;
		}

		public override void OnDeserialize(NetworkReader reader, bool initialState)
		{
		}

		public override void PreStartClient()
		{
		}
	}
	public abstract class BaseMoverController : MonoBehaviour
	{
		public PhysicsMover Mover { get; private set; }

		public void SetupMover(PhysicsMover mover)
		{
			Mover = mover;
		}

		public abstract void UpdateMovement(out Vector3 goalPosition, out Quaternion goalRotation, float deltaTime);
	}
	[RequireComponent(typeof(Rigidbody))]
	public class BasicPhysicsMoverController : BaseMoverController
	{
		public Transform referenceTransformPosition;

		public override void UpdateMovement(out Vector3 goalPosition, out Quaternion goalRotation, float deltaTime)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			goalPosition = referenceTransformPosition.position;
			goalRotation = referenceTransformPosition.rotation;
		}
	}
	public struct CharacterGroundingReport
	{
		public bool FoundAnyGround;

		public bool IsStableOnGround;

		public bool SnappingPrevented;

		public Vector3 GroundNormal;

		public Vector3 InnerGroundNormal;

		public Vector3 OuterGroundNormal;

		public Collider GroundCollider;

		public Vector3 GroundPoint;

		public void CopyFrom(CharacterTransientGroundingReport transientGroundingReport)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			FoundAnyGround = transientGroundingReport.FoundAnyGround;
			IsStableOnGround = transientGroundingReport.IsStableOnGround;
			SnappingPrevented = transientGroundingReport.SnappingPrevented;
			GroundNormal = transientGroundingReport.GroundNormal;
			InnerGroundNormal = transientGroundingReport.InnerGroundNormal;
			OuterGroundNormal = transientGroundingReport.OuterGroundNormal;
			GroundCollider = null;
			GroundPoint = Vector3.zero;
		}
	}
	public struct CharacterTransientGroundingReport
	{
		public bool FoundAnyGround;

		public bool IsStableOnGround;

		public bool SnappingPrevented;

		public Vector3 GroundNormal;

		public Vector3 InnerGroundNormal;

		public Vector3 OuterGroundNormal;

		public void CopyFrom(CharacterGroundingReport groundingReport)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			FoundAnyGround = groundingReport.FoundAnyGround;
			IsStableOnGround = groundingReport.IsStableOnGround;
			SnappingPrevented = groundingReport.SnappingPrevented;
			GroundNormal = groundingReport.GroundNormal;
			InnerGroundNormal = groundingReport.InnerGroundNormal;
			OuterGroundNormal = groundingReport.OuterGroundNormal;
		}
	}
	public struct HitStabilityReport
	{
		public bool IsStable;

		public bool FoundInnerNormal;

		public Vector3 InnerNormal;

		public bool FoundOuterNormal;

		public Vector3 OuterNormal;

		public bool ValidStepDetected;

		public Collider SteppedCollider;

		public bool LedgeDetected;

		public bool IsOnEmptySideOfLedge;

		public float DistanceFromLedge;

		public bool IsMovingTowardsEmptySideOfLedge;

		public Vector3 LedgeGroundNormal;

		public Vector3 LedgeRightDirection;

		public Vector3 LedgeFacingDirection;
	}
	public interface ICharacterController
	{
		void SetupCharacterMotor(KinematicCharacterMotor motor);

		void UpdateRotation(ref Quaternion currentRotation, float deltaTime);

		void UpdateVelocity(ref Vector3 currentVelocity, float deltaTime);

		void BeforeCharacterUpdate(float deltaTime);

		void PostGroundingUpdate(float deltaTime);

		void AfterCharacterUpdate(float deltaTime);

		bool IsColliderValidForCollisions(Collider coll);

		void OnGroundHit(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, ref HitStabilityReport hitStabilityReport);

		void OnMovementHit(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, ref HitStabilityReport hitStabilityReport);

		void ProcessHitStabilityReport(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, Vector3 atCharacterPosition, Quaternion atCharacterRotation, ref HitStabilityReport hitStabilityReport);

		void OnDiscreteCollisionDetected(Collider hitCollider);
	}
	public interface IMoverController
	{
		void UpdateMovement(out Vector3 goalPosition, out Quaternion goalRotation, float deltaTime);
	}
	[CreateAssetMenu]
	public class KCCSettings : ScriptableObject
	{
		[Tooltip("Determines if the system simulates automatically. If true, the simulation is done on FixedUpdate")]
		public bool AutoSimulation = true;

		[Tooltip("Smooth characters and movers between fixed ticks. Off = everything is written once per FixedUpdate and nothing runs per frame")]
		public bool Interpolate = true;

		[Tooltip("When Interpolate is on: motors that have a kinematic Rigidbody use Unity's native Rigidbody interpolation (zero managed per-frame cost). Motors without one fall back to a managed lerp in LateUpdate")]
		public bool UseRigidbodyInterpolation = true;

		[Tooltip("Initial capacity of the system's list of Motors")]
		public int MotorsListInitialCapacity = 100;

		[Tooltip("Initial capacity of the system's list of Movers")]
		public int MoversListInitialCapacity = 100;
	}
	[RequireComponent(typeof(CapsuleCollider))]
	public class KinematicCharacterMotor : MonoBehaviour
	{
		[ReadOnly]
		[Header("Components")]
		public CapsuleCollider Capsule;

		[SerializeField]
		[Header("Capsule Settings")]
		[Tooltip("Radius of the Character Capsule")]
		private float CapsuleRadius = 0.5f;

		[Tooltip("Height of the Character Capsule")]
		[SerializeField]
		private float CapsuleHeight = 2f;

		[SerializeField]
		[Tooltip("Height of the Character Capsule")]
		private float CapsuleYOffset = 1f;

		[SerializeField]
		[Tooltip("Physics material of the Character Capsule (Does not affect character movement. Only affects things colliding with it)")]
		private PhysicMaterial CapsulePhysicsMaterial;

		[Header("Grounding settings")]
		[Tooltip("Increases the range of ground detection, to allow snapping to ground at very high speeds")]
		public float GroundDetectionExtraDistance;

		[Tooltip("Maximum slope angle on which the character can be stable")]
		[Range(0f, 89f)]
		public float MaxStableSlopeAngle = 60f;

		[Tooltip("Which layers can the character be considered stable on")]
		public LayerMask StableGroundLayers = LayerMask.op_Implicit(-1);

		[Tooltip("Notifies the Character Controller when discrete collisions are detected (costs one extra overlap query per tick)")]
		public bool DiscreteCollisionEvents;

		[Tooltip("None = no stepping. Standard/Extra = cheap step-up (2 queries, only when a low obstacle is hit)")]
		[Header("Step settings")]
		public StepHandlingMethod StepHandling = StepHandlingMethod.Standard;

		[Tooltip("Maximum height of a step which the character can climb")]
		public float MaxStepHeight = 0.5f;

		[Tooltip("Can the character step up obstacles even if it is not currently stable?")]
		public bool AllowSteppingWithoutStableGrounding;

		[Tooltip("(Unused in the lean rewrite)")]
		public float MinRequiredStepDepth = 0.1f;

		[Header("Ledge settings")]
		[Tooltip("Cheap ledge check (one raycast, only when the ground contact is far from the capsule axis)")]
		public bool LedgeAndDenivelationHandling = true;

		[Tooltip("The distance from the capsule central axis at which the character can stand on a ledge and still be stable")]
		public float MaxStableDistanceFromLedge = 0.5f;

		[Tooltip("(Unused in the lean rewrite)")]
		public float MaxVelocityForLedgeSnap;

		[Tooltip("(Unused in the lean rewrite)")]
		[Range(1f, 180f)]
		public float MaxStableDenivelationAngle = 180f;

		[Tooltip("Handles standing on PhysicsMovers / rigidbodies and pushing dynamic rigidbodies")]
		[Header("Rigidbody interaction settings")]
		public bool InteractiveRigidbodyHandling = true;

		[Tooltip("Kinematic = dynamic bodies are ignored by movement queries (Unity contacts push them). SimulatedDynamic = they are obstacles and receive impulses. None = obstacles, no impulses.")]
		public RigidbodyInteractionType RigidbodyInteractionType;

		[Tooltip("Mass used for pushing bodies")]
		public float SimulatedCharacterMass = 1f;

		[Tooltip("Determines if the character preserves moving platform velocities when de-grounding from them")]
		public bool PreserveAttachedRigidbodyMomentum = true;

		[Tooltip("Determines if the character's movement uses the planar constraint")]
		[Header("Constraints settings")]
		public bool HasPlanarConstraint;

		[Tooltip("Defines the plane that the character's movement is constrained on, if HasMovementConstraintPlane is active")]
		public Vector3 PlanarConstraintAxis = Vector3.forward;

		[Header("Other settings")]
		[Tooltip("(Unused in the lean rewrite - movement uses one cast per iteration, depenetration is separate)")]
		public bool CheckMovementInitialOverlaps = true;

		[Tooltip("Sets the velocity to zero if exceed max movement iterations")]
		public bool KillVelocityWhenExceedMaxMovementIterations = true;

		[Tooltip("Sets the remaining movement to zero if exceed max movement iterations")]
		public bool KillRemainingMovementWhenExceedMaxMovementIterations = true;

		[NonSerialized]
		public CharacterGroundingReport GroundingStatus;

		[NonSerialized]
		public CharacterTransientGroundingReport LastGroundingStatus;

		[NonSerialized]
		public LayerMask CollidableLayers = LayerMask.op_Implicit(-1);

		[NonSerialized]
		public ICharacterController CharacterController;

		[NonSerialized]
		public bool LastMovementIterationFoundAnyGround;

		[NonSerialized]
		public int IndexInCharacterSystem;

		[NonSerialized]
		public Vector3 InitialTickPosition;

		[NonSerialized]
		public Quaternion InitialTickRotation;

		[NonSerialized]
		public Rigidbody AttachedRigidbodyOverride;

		[NonSerialized]
		public Vector3 BaseVelocity;

		[NonSerialized]
		public int RegisteredRigidbodyId;

		public static float updateTimerMax;

		public float timeUntilUpdate;

		public bool playerCharacter;

		public const int MaxHitsBudget = 8;

		public const int MaxCollisionBudget = 8;

		public const int MaxGroundingSweepIterations = 1;

		public const int MaxMovementIterations = 3;

		public const int MaxSteppingSweepIterations = 1;

		public const int MaxRigidbodyOverlapsCount = 8;

		public const int MaxDecollisionIterations = 1;

		public const float CollisionOffset = 0.01f;

		public const float GroundProbeReboundDistance = 0.02f;

		public const float MinimumGroundProbingDistance = 0.005f;

		public const float GroundProbingBackstepDistance = 0.1f;

		public const float SweepProbingBackstepDistance = 0.002f;

		public const float SecondaryProbesVertical = 0.02f;

		public const float SecondaryProbesHorizontal = 0.001f;

		public const float MinVelocityMagnitude = 0.01f;

		public const float SteppingForwardDistance = 0.03f;

		public const float MinDistanceForLedge = 0.05f;

		public const float CorrelationForVerticalObstruction = 0.01f;

		public const float ExtraSteppingForwardDistance = 0.01f;

		public const float ExtraStepHeightPadding = 0.01f;

		private const float MinVelocitySqr = 0.0001f;

		private const int BufferSize = 8;

		private const int IdleTicksToSleep = 3;

		private const int SleepProbeMask = 7;

		private const int DepenMask = 3;

		private Transform _transform;

		private Rigidbody _rb;

		private bool _nativeCapable;

		private int _rbInterpMode = -1;

		private int _salt;

		private int _tick;

		private int _idleTicks;

		private Vector3 _transientPosition;

		private Quaternion _transientRotation;

		private Vector3 _characterUp;

		private Vector3 _characterForward;

		private Vector3 _characterRight;

		private Vector3 _bottomHemiWorld;

		private Vector3 _topHemiWorld;

		private Vector3 _initialSimulationPosition;

		private Quaternion _initialSimulationRotation;

		private Vector3 _flushedPosition;

		private Quaternion _flushedRotation;

		private Rigidbody _attachedRigidbody;

		private Rigidbody _lastAttachedRigidbody;

		private Vector3 _attachedRigidbodyVelocity;

		private Vector3 _characterTransformToCapsuleCenter;

		private Vector3 _characterTransformToCapsuleBottom;

		private Vector3 _characterTransformToCapsuleTop;

		private Vector3 _characterTransformToCapsuleBottomHemi;

		private Vector3 _characterTransformToCapsuleTopHemi;

		private int _overlapsCount;

		private readonly OverlapResult[] _overlaps = new OverlapResult[8];

		private readonly RaycastHit[] _internalCharacterHits = (RaycastHit[])(object)new RaycastHit[8];

		private readonly Collider[] _internalProbedColliders = (Collider[])(object)new Collider[8];

		private readonly RigidbodyProjectionHit[] _rigidbodyHits = new RigidbodyProjectionHit[8];

		private readonly int[] _pushedIds = new int[8];

		private int _rigidbodyHitCount;

		private int _pushedCount;

		private bool _solveMovementCollisions = true;

		private bool _solveGrounding = true;

		private bool _movePositionDirty;

		private Vector3 _movePositionTarget = Vector3.zero;

		private bool _moveRotationDirty;

		private Quaternion _moveRotationTarget = Quaternion.identity;

		private bool _isMovingFromAttachedRigidbody;

		private bool _mustUnground;

		private float _mustUngroundTimeCounter;

		private readonly Vector3 _cachedWorldUp = Vector3.up;

		private readonly Vector3 _cachedWorldForward = Vector3.forward;

		private readonly Vector3 _cachedWorldRight = Vector3.right;

		private float _cachedSlopeAngle = -1f;

		private float _stableDot;

		private float localGroundProbingBackstepDistance = 0.1f;

		public float CurrentCapsuleRadius => CapsuleRadius;

		public float CurrentCapsuleHeight => CapsuleHeight;

		public float CurrentCapsuleYOffset => CapsuleYOffset;

		public Transform Transform => _transform;

		public Vector3 TransientPosition => _transientPosition;

		public Vector3 CharacterUp => _characterUp;

		public Vector3 CharacterForward => _characterForward;

		public Vector3 CharacterRight => _characterRight;

		public Vector3 InitialSimulationPosition => _initialSimulationPosition;

		public Quaternion InitialSimulationRotation => _initialSimulationRotation;

		public Rigidbody AttachedRigidbody => _attachedRigidbody;

		public Vector3 CharacterTransformToCapsuleCenter => _characterTransformToCapsuleCenter;

		public Vector3 CharacterTransformToCapsuleBottom => _characterTransformToCapsuleBottom;

		public Vector3 CharacterTransformToCapsuleTop => _characterTransformToCapsuleTop;

		public Vector3 CharacterTransformToCapsuleBottomHemi => _characterTransformToCapsuleBottomHemi;

		public Vector3 CharacterTransformToCapsuleTopHemi => _characterTransformToCapsuleTopHemi;

		public Vector3 AttachedRigidbodyVelocity => _attachedRigidbodyVelocity;

		public int OverlapsCount => _overlapsCount;

		public OverlapResult[] Overlaps => _overlaps;

		public Vector3 Velocity => BaseVelocity + _attachedRigidbodyVelocity;

		public bool ManagedInterpolationActive { get; private set; }

		public Quaternion TransientRotation
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return _transientRotation;
			}
			private set
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				_transientRotation = value;
				RefreshRotationCache();
			}
		}

		private void RefreshRotationCache()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			_characterUp = _transientRotation * _cachedWorldUp;
			_characterForward = _transientRotation * _cachedWorldForward;
			_characterRight = _transientRotation * _cachedWorldRight;
			_bottomHemiWorld = _transientRotation * _characterTransformToCapsuleBottomHemi;
			_topHemiWorld = _transientRotation * _characterTransformToCapsuleTopHemi;
		}

		private void OnEnable()
		{
			KinematicCharacterSystem.EnsureCreation();
			KinematicCharacterSystem.RegisterCharacterMotor(this);
		}

		private void OnDisable()
		{
			KinematicCharacterSystem.UnregisterCharacterMotor(this);
		}

		private void Reset()
		{
			ValidateData();
		}

		private void OnValidate()
		{
			ValidateData();
		}

		[ContextMenu("Remove Component")]
		private void HandleRemoveComponent()
		{
			CapsuleCollider component = ((Component)this).gameObject.GetComponent<CapsuleCollider>();
			Object.DestroyImmediate((Object)(object)this);
			Object.DestroyImmediate((Object)(object)component);
		}

		private void Awake()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			_transform = ((Component)this).transform;
			_rb = ((Component)this).GetComponent<Rigidbody>();
			_nativeCapable = (Object)(object)_rb != (Object)null && _rb.isKinematic;
			_salt = ((Object)this).GetInstanceID() & 7;
			ValidateData();
			_transientPosition = _transform.position;
			TransientRotation = _transform.rotation;
			RebuildCollidableLayers();
			((Component)this).GetComponent<ICharacterController>()?.SetupCharacterMotor(this);
			SetCapsuleDimensions(CapsuleRadius, CapsuleHeight, CapsuleYOffset);
			_flushedPosition = _transientPosition;
			_flushedRotation = _transientRotation;
			InitialTickPosition = _transientPosition;
			InitialTickRotation = _transientRotation;
			_initialSimulationPosition = _transientPosition;
			_initialSimulationRotation = _transientRotation;
		}

		public void ValidateData()
		{
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			Capsule = ((Component)this).GetComponent<CapsuleCollider>();
			CapsuleRadius = Mathf.Clamp(CapsuleRadius, 0f, CapsuleHeight * 0.5f);
			Capsule.direction = 1;
			((Collider)Capsule).sharedMaterial = CapsulePhysicsMaterial;
			SetCapsuleDimensions(CapsuleRadius, CapsuleHeight, CapsuleYOffset);
			SetLocalGroundProbingBackstepDistance();
			MaxStepHeight = Mathf.Clamp(MaxStepHeight, 0f, float.PositiveInfinity);
			MinRequiredStepDepth = Mathf.Clamp(MinRequiredStepDepth, 0f, CapsuleRadius);
			MaxStableDistanceFromLedge = Mathf.Clamp(MaxStableDistanceFromLedge, 0f, CapsuleRadius);
			((Component)this).transform.localScale = Vector3.one;
		}

		public void SetCapsuleDimensions(float radius, float height, float yOffset)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			height = Mathf.Max(height, radius * 2f + 0.01f);
			CapsuleRadius = radius;
			CapsuleHeight = height;
			CapsuleYOffset = yOffset;
			Capsule.radius = CapsuleRadius;
			Capsule.height = Mathf.Clamp(CapsuleHeight, CapsuleRadius * 2f, CapsuleHeight);
			Capsule.center = new Vector3(0f, CapsuleYOffset, 0f);
			float num = Capsule.height * 0.5f;
			_characterTransformToCapsuleCenter = Capsule.center;
			_characterTransformToCapsuleBottom = Capsule.center + -_cachedWorldUp * num;
			_characterTransformToCapsuleTop = Capsule.center + _cachedWorldUp * num;
			_characterTransformToCapsuleBottomHemi = Capsule.center + -_cachedWorldUp * num + _cachedWorldUp * Capsule.radius;
			_characterTransformToCapsuleTopHemi = Capsule.center + _cachedWorldUp * num + -_cachedWorldUp * Capsule.radius;
			RefreshRotationCache();
		}

		private void SetLocalGroundProbingBackstepDistance()
		{
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public void RebuildCollidableLayers()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			CollidableLayers = LayerMask.op_Implicit(0);
			for (int i = 0; i < 32; i++)
			{
				if (!Physics.GetIgnoreLayerCollision(((Component)this).gameObject.layer, i))
				{
					CollidableLayers = LayerMask.op_Implicit(LayerMask.op_Implicit(CollidableLayers) | (1 << i));
				}
			}
		}

		public void SetCapsuleCollisionsActivation(bool collisionsActive)
		{
			((Collider)Capsule).isTrigger = !collisionsActive;
		}

		public void SetMovementCollisionsSolvingActivation(bool active)
		{
			_solveMovementCollisions = active;
		}

		public void SetGroundSolvingActivation(bool active)
		{
			_solveGrounding = active;
		}

		public void SetPosition(Vector3 position, bool bypassInterpolation = true)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			_transform.position = position;
			if ((Object)(object)_rb != (Object)null)
			{
				_rb.position = position;
			}
			_initialSimulationPosition = position;
			_transientPosition = position;
			_flushedPosition = position;
			if (bypassInterpolation)
			{
				InitialTickPosition = position;
			}
			_idleTicks = 0;
		}

		public void SetRotation(Quaternion rotation, bool bypassInterpolation = true)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			_transform.rotation = rotation;
			if ((Object)(object)_rb != (Object)null)
			{
				_rb.rotation = rotation;
			}
			_initialSimulationRotation = rotation;
			TransientRotation = rotation;
			_flushedRotation = rotation;
			if (bypassInterpolation)
			{
				InitialTickRotation = rotation;
			}
		}

		public void SetPositionAndRotation(Vector3 position, Quaternion rotation, bool bypassInterpolation = true)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			_transform.SetPositionAndRotation(position, rotation);
			if ((Object)(object)_rb != (Object)null)
			{
				_rb.position = position;
				_rb.rotation = rotation;
			}
			_initialSimulationPosition = position;
			_initialSimulationRotation = rotation;
			_transientPosition = position;
			TransientRotation = rotation;
			_flushedPosition = position;
			_flushedRotation = rotation;
			if (bypassInterpolation)
			{
				InitialTickPosition = position;
				InitialTickRotation = rotation;
			}
			_idleTicks = 0;
		}

		public void UpdatePositions()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			_transientPosition = _transform.position;
			TransientRotation = _transform.rotation;
		}

		public void SetTransientPosition(Vector3 newPos)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_transientPosition = newPos;
		}

		public void MoveCharacter(Vector3 toPosition)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			_movePositionDirty = true;
			_movePositionTarget = toPosition;
			_idleTicks = 0;
		}

		public void RotateCharacter(Quaternion toRotation)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			_moveRotationDirty = true;
			_moveRotationTarget = toRotation;
		}

		public void ForceUnground(float time = 0.1f)
		{
			_mustUnground = true;
			_mustUngroundTimeCounter = time;
			_idleTicks = 0;
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		public bool MustUnground()
		{
			if (!_mustUnground)
			{
				return _mustUngroundTimeCounter > 0f;
			}
			return true;
		}

		public KinematicCharacterMotorState GetState()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			KinematicCharacterMotorState result = default(KinematicCharacterMotorState);
			result.Position = _transientPosition;
			result.Rotation = _transientRotation;
			result.BaseVelocity = BaseVelocity;
			result.AttachedRigidbodyVelocity = _attachedRigidbodyVelocity;
			result.MustUnground = _mustUnground;
			result.MustUngroundTime = _mustUngroundTimeCounter;
			result.LastMovementIterationFoundAnyGround = LastMovementIterationFoundAnyGround;
			result.GroundingStatus.CopyFrom(GroundingStatus);
			result.AttachedRigidbody = _attachedRigidbody;
			return result;
		}

		public void ApplyState(KinematicCharacterMotorState state, bool bypassInterpolation = true)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			SetPositionAndRotation(state.Position, state.Rotation, bypassInterpolation);
			BaseVelocity = state.BaseVelocity;
			_attachedRigidbodyVelocity = state.AttachedRigidbodyVelocity;
			_mustUnground = state.MustUnground;
			_mustUngroundTimeCounter = state.MustUngroundTime;
			LastMovementIterationFoundAnyGround = state.LastMovementIterationFoundAnyGround;
			GroundingStatus.CopyFrom(state.GroundingStatus);
			_attachedRigidbody = state.AttachedRigidbody;
		}

		private static bool SamePos(Vector3 a, Vector3 b)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (a.x == b.x && a.y == b.y)
			{
				return a.z == b.z;
			}
			return false;
		}

		private static bool SameRot(Quaternion a, Quaternion b)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if (a.x == b.x && a.y == b.y && a.z == b.z)
			{
				return a.w == b.w;
			}
			return false;
		}

		public void FlushPose(bool interpolate, bool preferNative)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			bool flag = !SamePos(_transientPosition, _flushedPosition) || !SameRot(_transientRotation, _flushedRotation);
			if (interpolate)
			{
				if (preferNative && _nativeCapable)
				{
					ManagedInterpolationActive = false;
					SetRbInterpolation(1);
					if (flag)
					{
						_rb.MovePosition(_transientPosition);
						_rb.MoveRotation(_transientRotation);
						_flushedPosition = _transientPosition;
						_flushedRotation = _transientRotation;
					}
				}
				else
				{
					ManagedInterpolationActive = true;
					SetRbInterpolation(0);
				}
			}
			else
			{
				ManagedInterpolationActive = false;
				SetRbInterpolation(0);
				if (flag)
				{
					_transform.SetPositionAndRotation(_transientPosition, _transientRotation);
					_flushedPosition = _transientPosition;
					_flushedRotation = _transientRotation;
				}
			}
		}

		private void SetRbInterpolation(int mode)
		{
			if (!((Object)(object)_rb == (Object)null) && mode != _rbInterpMode)
			{
				_rbInterpMode = mode;
				_rb.interpolation = (RigidbodyInterpolation)(mode == 1);
			}
		}

		public void WriteInterpolatedPose(float t)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val;
			Quaternion val2;
			if (t >= 1f || (SamePos(InitialTickPosition, _transientPosition) && SameRot(InitialTickRotation, _transientRotation)))
			{
				val = _transientPosition;
				val2 = _transientRotation;
			}
			else
			{
				val = Vector3.Lerp(InitialTickPosition, _transientPosition, t);
				val2 = Quaternion.Lerp(InitialTickRotation, _transientRotation, t);
			}
			if (!SamePos(val, _flushedPosition) || !SameRot(val2, _flushedRotation))
			{
				_transform.SetPositionAndRotation(val, val2);
				_flushedPosition = val;
				_flushedRotation = val2;
			}
		}

		public void Simulate(float deltaTime, bool fullUpdate)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fd: Unknown result type (might be due to invalid IL or missing references)
			if (float.IsNaN(BaseVelocity.x) || float.IsNaN(BaseVelocity.y) || float.IsNaN(BaseVelocity.z))
			{
				BaseVelocity = Vector3.zero;
			}
			if (float.IsNaN(_attachedRigidbodyVelocity.x) || float.IsNaN(_attachedRigidbodyVelocity.y) || float.IsNaN(_attachedRigidbodyVelocity.z))
			{
				_attachedRigidbodyVelocity = Vector3.zero;
			}
			InitialTickPosition = _transientPosition;
			InitialTickRotation = _transientRotation;
			timeUntilUpdate -= deltaTime;
			if (!(playerCharacter || fullUpdate) && !_mustUnground && GroundingStatus.IsStableOnGround)
			{
				SimulateLight(deltaTime);
				return;
			}
			timeUntilUpdate = updateTimerMax;
			_tick++;
			_rigidbodyHitCount = 0;
			_pushedCount = 0;
			_overlapsCount = 0;
			CharacterController.BeforeCharacterUpdate(deltaTime);
			_initialSimulationPosition = _transientPosition;
			_initialSimulationRotation = _transientRotation;
			bool movePositionDirty = _movePositionDirty;
			if (_movePositionDirty)
			{
				if (_solveMovementCollisions)
				{
					Vector3 velocity = GetVelocityFromMovement(_movePositionTarget - _transientPosition, deltaTime);
					if (MoveAndSlide(ref velocity, deltaTime) && InteractiveRigidbodyHandling)
					{
						ProcessRigidbodyHits(ref velocity, deltaTime);
					}
				}
				else
				{
					_transientPosition = _movePositionTarget;
				}
				_movePositionDirty = false;
			}
			LastGroundingStatus.CopyFrom(GroundingStatus);
			bool flag = !playerCharacter && _idleTicks >= 3 && GroundingStatus.IsStableOnGround && (Object)(object)_attachedRigidbody == (Object)null && !MustUnground() && !movePositionDirty && ((_tick + _salt) & 7) != 0;
			bool lastMovementIterationFoundAnyGround = false;
			if (_solveMovementCollisions && !flag && (playerCharacter || movePositionDirty || !GroundingStatus.IsStableOnGround || ((_tick + _salt) & 3) == 0))
			{
				lastMovementIterationFoundAnyGround = Depenetrate();
			}
			if (_solveGrounding)
			{
				if (!flag)
				{
					GroundingStatus = default(CharacterGroundingReport);
					GroundingStatus.GroundNormal = _characterUp;
					if (MustUnground())
					{
						_transientPosition += _characterUp * 0.0075f;
					}
					else
					{
						float probingDistance = 0.005f;
						if (!LastGroundingStatus.SnappingPrevented && (LastGroundingStatus.IsStableOnGround || LastMovementIterationFoundAnyGround))
						{
							probingDistance = ((StepHandling == StepHandlingMethod.None) ? CapsuleRadius : Mathf.Max(CapsuleRadius, MaxStepHeight));
							probingDistance += GroundDetectionExtraDistance;
						}
						ProbeGround(ref _transientPosition, _transientRotation, probingDistance, ref GroundingStatus);
						if (!LastGroundingStatus.IsStableOnGround && GroundingStatus.IsStableOnGround)
						{
							BaseVelocity = Vector3.ProjectOnPlane(BaseVelocity, _characterUp);
							BaseVelocity = GetDirectionTangentToSurface(BaseVelocity, GroundingStatus.GroundNormal) * ((Vector3)(ref BaseVelocity)).magnitude;
						}
					}
				}
			}
			else
			{
				GroundingStatus = default(CharacterGroundingReport);
				GroundingStatus.GroundNormal = _characterUp;
			}
			LastMovementIterationFoundAnyGround = lastMovementIterationFoundAnyGround;
			if (_mustUngroundTimeCounter > 0f)
			{
				_mustUngroundTimeCounter -= deltaTime;
			}
			_mustUnground = false;
			if (_solveGrounding)
			{
				CharacterController.PostGroundingUpdate(deltaTime);
			}
			if (InteractiveRigidbodyHandling)
			{
				UpdateAttachedRigidbody(deltaTime);
			}
			Quaternion currentRotation = _transientRotation;
			CharacterController.UpdateRotation(ref currentRotation, deltaTime);
			if (_moveRotationDirty)
			{
				currentRotation = _moveRotationTarget;
				_moveRotationDirty = false;
			}
			if (!SameRot(currentRotation, _transientRotation))
			{
				TransientRotation = currentRotation;
			}
			CharacterController.UpdateVelocity(ref BaseVelocity, deltaTime);
			float num = ((Vector3)(ref BaseVelocity)).sqrMagnitude;
			if (num < 0.0001f)
			{
				BaseVelocity = Vector3.zero;
				num = 0f;
				if (_idleTicks < 1000)
				{
					_idleTicks++;
				}
			}
			else
			{
				_idleTicks = 0;
			}
			if (num > 0f)
			{
				if (_solveMovementCollisions)
				{
					MoveAndSlide(ref BaseVelocity, deltaTime);
				}
				else
				{
					_transientPosition += BaseVelocity * deltaTime;
				}
			}
			if (InteractiveRigidbodyHandling && _rigidbodyHitCount > 0)
			{
				ProcessRigidbodyHits(ref BaseVelocity, deltaTime);
			}
			if (HasPlanarConstraint)
			{
				_transientPosition = _initialSimulationPosition + Vector3.ProjectOnPlane(_transientPosition - _initialSimulationPosition, ((Vector3)(ref PlanarConstraintAxis)).normalized);
			}
			if (DiscreteCollisionEvents)
			{
				int num2 = CharacterCollisionsOverlap(_transientPosition, _transientRotation, _internalProbedColliders, 0.02f);
				for (int i = 0; i < num2; i++)
				{
					CharacterController.OnDiscreteCollisionDetected(_internalProbedColliders[i]);
				}
			}
			CharacterController.AfterCharacterUpdate(deltaTime);
		}

		private void SimulateLight(float deltaTime)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			CharacterController.BeforeCharacterUpdate(deltaTime);
			if (_movePositionDirty)
			{
				Vector3 val = _movePositionTarget - _transientPosition;
				float num = Vector3.Dot(GroundingStatus.GroundNormal, val);
				val -= num * GroundingStatus.GroundNormal;
				_transientPosition += val;
				_moveRotationDirty = false;
				_movePositionDirty = false;
			}
			LastGroundingStatus.CopyFrom(GroundingStatus);
			CharacterController.UpdateVelocity(ref BaseVelocity, deltaTime);
			if (((Vector3)(ref BaseVelocity)).sqrMagnitude < 0.0001f)
			{
				BaseVelocity = Vector3.zero;
			}
			_transientPosition += BaseVelocity * deltaTime;
			CharacterController.AfterCharacterUpdate(deltaTime);
		}

		private bool Depenetrate()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			int num = OverlapInternal(_transientPosition, _internalProbedColliders, 0f);
			if (num <= 0)
			{
				return false;
			}
			if (num > 4)
			{
				num = 4;
			}
			bool result = false;
			Vector3 val2 = default(Vector3);
			float num2 = default(float);
			for (int i = 0; i < num; i++)
			{
				Collider val = _internalProbedColliders[i];
				Transform transform = ((Component)val).transform;
				if (!Physics.ComputePenetration((Collider)(object)Capsule, _transientPosition, _transientRotation, val, transform.position, transform.rotation, ref val2, ref num2))
				{
					continue;
				}
				_transientPosition += val2 * (num2 + 0.01f);
				if (_overlapsCount < _overlaps.Length)
				{
					_overlaps[_overlapsCount] = new OverlapResult(val2, val);
					_overlapsCount++;
				}
				if (!InteractiveRigidbodyHandling)
				{
					continue;
				}
				Rigidbody interactiveRigidbody = GetInteractiveRigidbody(val);
				if ((Object)(object)interactiveRigidbody != (Object)null)
				{
					bool flag = IsStableOnNormal(val2);
					if (flag)
					{
						result = true;
					}
					if ((Object)(object)interactiveRigidbody != (Object)(object)_attachedRigidbody)
					{
						StoreRigidbodyHit(interactiveRigidbody, Velocity, _transientPosition, val2, flag);
					}
				}
			}
			return result;
		}

		private bool IsStableOnNormal(Vector3 normal)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			if (MaxStableSlopeAngle != _cachedSlopeAngle)
			{
				_cachedSlopeAngle = MaxStableSlopeAngle;
				_stableDot = Mathf.Cos(MaxStableSlopeAngle * (MathF.PI / 180f));
			}
			return Vector3.Dot(_characterUp, normal) >= _stableDot;
		}

		public void EvaluateHitStability(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, Vector3 atCharacterPosition, Quaternion atCharacterRotation, Vector3 withCharacterVelocity, ref HitStabilityReport stabilityReport)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			if (!_solveGrounding)
			{
				stabilityReport.IsStable = false;
				return;
			}
			stabilityReport.IsStable = IsStableOnNormal(hitNormal);
			stabilityReport.FoundInnerNormal = false;
			stabilityReport.FoundOuterNormal = false;
			stabilityReport.InnerNormal = hitNormal;
			stabilityReport.OuterNormal = hitNormal;
			if (stabilityReport.IsStable && LedgeAndDenivelationHandling)
			{
				Vector3 val = atCharacterRotation * _cachedWorldUp;
				Vector3 val2 = atCharacterPosition + atCharacterRotation * _characterTransformToCapsuleBottom;
				Vector3 val3 = Vector3.ProjectOnPlane(hitPoint - val2, val);
				float magnitude = ((Vector3)(ref val3)).magnitude;
				if (magnitude > MaxStableDistanceFromLedge)
				{
					float num = ((StepHandling != StepHandlingMethod.None) ? MaxStepHeight : 0.05f) + 0.04f;
					int num2 = LayerMask.op_Implicit(CollidableLayers) & LayerMask.op_Implicit(StableGroundLayers);
					if (!Physics.Raycast(val2 + val * 0.02f, -val, num, num2, (QueryTriggerInteraction)1))
					{
						stabilityReport.LedgeDetected = true;
						stabilityReport.IsOnEmptySideOfLedge = true;
						stabilityReport.DistanceFromLedge = magnitude;
						stabilityReport.IsStable = false;
					}
				}
			}
			CharacterController.ProcessHitStabilityReport(hitCollider, hitNormal, hitPoint, atCharacterPosition, atCharacterRotation, ref stabilityReport);
		}

		public void ProbeGround(ref Vector3 probingPosition, Quaternion atRotation, float probingDistance, ref CharacterGroundingReport groundingReport)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			if (probingDistance < 0.005f)
			{
				probingDistance = 0.005f;
			}
			Vector3 val = atRotation * -_cachedWorldUp;
			float num = localGroundProbingBackstepDistance;
			Vector3 val2 = probingPosition + atRotation * _characterTransformToCapsuleBottomHemi - val * num;
			int num2 = LayerMask.op_Implicit(CollidableLayers) & LayerMask.op_Implicit(StableGroundLayers);
			int num3 = Physics.SphereCastNonAlloc(val2, CapsuleRadius, val, _internalCharacterHits, probingDistance + num, num2, (QueryTriggerInteraction)1);
			int num4 = -1;
			float num5 = float.PositiveInfinity;
			for (int i = 0; i < num3; i++)
			{
				float distance = ((RaycastHit)(ref _internalCharacterHits[i])).distance;
				if (distance > 0f && distance < num5 && CheckIfColliderValidForCollisions(((RaycastHit)(ref _internalCharacterHits[i])).collider))
				{
					num4 = i;
					num5 = distance;
				}
			}
			if (num4 < 0)
			{
				return;
			}
			RaycastHit val3 = _internalCharacterHits[num4];
			float num6 = num5 - num;
			Vector3 atCharacterPosition = probingPosition + val * num6;
			HitStabilityReport stabilityReport = default(HitStabilityReport);
			EvaluateHitStability(((RaycastHit)(ref val3)).collider, ((RaycastHit)(ref val3)).normal, ((RaycastHit)(ref val3)).point, atCharacterPosition, _transientRotation, BaseVelocity, ref stabilityReport);
			groundingReport.FoundAnyGround = true;
			groundingReport.GroundNormal = ((RaycastHit)(ref val3)).normal;
			groundingReport.InnerGroundNormal = stabilityReport.InnerNormal;
			groundingReport.OuterGroundNormal = stabilityReport.OuterNormal;
			groundingReport.GroundCollider = ((RaycastHit)(ref val3)).collider;
			groundingReport.GroundPoint = ((RaycastHit)(ref val3)).point;
			groundingReport.SnappingPrevented = stabilityReport.LedgeDetected && stabilityReport.IsOnEmptySideOfLedge;
			if (stabilityReport.IsStable)
			{
				groundingReport.IsStableOnGround = true;
				if (!groundingReport.SnappingPrevented)
				{
					probingPosition += val * (num6 - 0.01f);
				}
				CharacterController.OnGroundHit(((RaycastHit)(ref val3)).collider, ((RaycastHit)(ref val3)).normal, ((RaycastHit)(ref val3)).point, ref stabilityReport);
			}
		}

		public Vector3 GetDirectionTangentToSurface(Vector3 direction, Vector3 surfaceNormal)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.Cross(direction, _characterUp);
			Vector3 val2 = Vector3.Cross(surfaceNormal, val);
			return ((Vector3)(ref val2)).normalized;
		}

		private bool MoveAndSlide(ref Vector3 velocity, float deltaTime)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			if (deltaTime <= 0f)
			{
				return false;
			}
			float sqrMagnitude = ((Vector3)(ref velocity)).sqrMagnitude;
			if (sqrMagnitude <= 1E-12f)
			{
				return true;
			}
			float num = Mathf.Sqrt(sqrMagnitude);
			float num2 = num * deltaTime;
			Vector3 val = velocity / num;
			Vector3 position = _transientPosition;
			bool result = true;
			int num3 = 0;
			while (num2 > 1E-05f)
			{
				if (num3 >= 3)
				{
					if (KillRemainingMovementWhenExceedMaxMovementIterations)
					{
						num2 = 0f;
					}
					if (KillVelocityWhenExceedMaxMovementIterations)
					{
						velocity = Vector3.zero;
					}
					result = false;
					break;
				}
				num3++;
				if (!SweepInternal(position, val, num2 + 0.01f, out var closest, stableOnly: false))
				{
					break;
				}
				float num4 = Mathf.Max(0f, ((RaycastHit)(ref closest)).distance - 0.01f);
				position += val * num4;
				num2 -= num4;
				Vector3 normal = ((RaycastHit)(ref closest)).normal;
				Collider collider = ((RaycastHit)(ref closest)).collider;
				HitStabilityReport stabilityReport = default(HitStabilityReport);
				EvaluateHitStability(collider, normal, ((RaycastHit)(ref closest)).point, position, _transientRotation, velocity, ref stabilityReport);
				if (!stabilityReport.IsStable && StepHandling != StepHandlingMethod.None && _solveGrounding && (GroundingStatus.IsStableOnGround || AllowSteppingWithoutStableGrounding) && Mathf.Abs(Vector3.Dot(normal, _characterUp)) <= 0.1f && TryStepUp(ref position, ((RaycastHit)(ref closest)).point, normal))
				{
					velocity = Vector3.ProjectOnPlane(velocity, _characterUp);
					float magnitude = ((Vector3)(ref velocity)).magnitude;
					if (magnitude <= 1E-05f)
					{
						num2 = 0f;
						break;
					}
					val = velocity / magnitude;
					continue;
				}
				Vector3 obstructionNormal = GetObstructionNormal(normal, stabilityReport.IsStable);
				CharacterController.OnMovementHit(collider, normal, ((RaycastHit)(ref closest)).point, ref stabilityReport);
				if (InteractiveRigidbodyHandling)
				{
					Rigidbody attachedRigidbody = collider.attachedRigidbody;
					if (Object.op_Implicit((Object)(object)attachedRigidbody))
					{
						StoreRigidbodyHit(attachedRigidbody, velocity, ((RaycastHit)(ref closest)).point, obstructionNormal, stabilityReport.IsStable);
					}
				}
				bool flag = stabilityReport.IsStable && !MustUnground();
				if (flag)
				{
					LastMovementIterationFoundAnyGround = true;
				}
				Vector3 val2 = velocity;
				HandleVelocityProjection(ref velocity, obstructionNormal, flag);
				float magnitude2 = ((Vector3)(ref val2)).magnitude;
				float sqrMagnitude2 = ((Vector3)(ref velocity)).sqrMagnitude;
				if (magnitude2 <= 0f || sqrMagnitude2 <= 1E-10f)
				{
					num2 = 0f;
					velocity = Vector3.zero;
					break;
				}
				float num5 = Mathf.Sqrt(sqrMagnitude2);
				num2 *= num5 / magnitude2;
				val = velocity / num5;
			}
			if (num2 > 0f)
			{
				position += val * num2;
			}
			_transientPosition = position;
			return result;
		}

		private bool TryStepUp(ref Vector3 position, Vector3 hitPoint, Vector3 hitNormal)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			Vector3 characterUp = _characterUp;
			float num = Vector3.Dot(position, characterUp) + (CapsuleYOffset - Capsule.height * 0.5f);
			float num2 = Vector3.Dot(hitPoint, characterUp) - num;
			if (num2 < 0.02f || num2 > MaxStepHeight + 0.01f)
			{
				return false;
			}
			Vector3 val = Vector3.ProjectOnPlane(-hitNormal, characterUp);
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			Vector3 val2 = position + normalized * 0.03f + characterUp * MaxStepHeight;
			if (OverlapInternal(val2, _internalProbedColliders, 0f) > 0)
			{
				return false;
			}
			if (!SweepInternal(val2, -characterUp, MaxStepHeight, out var closest, stableOnly: true))
			{
				return false;
			}
			if (!IsStableOnNormal(((RaycastHit)(ref closest)).normal))
			{
				return false;
			}
			Vector3 val3 = val2 - characterUp * (((RaycastHit)(ref closest)).distance - 0.01f);
			if (Vector3.Dot(val3 - position, characterUp) <= 0.005f)
			{
				return false;
			}
			position = val3;
			return true;
		}

		private Vector3 GetObstructionNormal(Vector3 hitNormal, bool stableOnHit)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = hitNormal;
			if (GroundingStatus.IsStableOnGround && !MustUnground() && !stableOnHit)
			{
				Vector3 val2 = Vector3.Cross(GroundingStatus.GroundNormal, val);
				val2 = Vector3.Cross(((Vector3)(ref val2)).normalized, _characterUp);
				val = ((Vector3)(ref val2)).normalized;
			}
			if (((Vector3)(ref val)).sqrMagnitude == 0f)
			{
				val = hitNormal;
			}
			return val;
		}

		public virtual void HandleVelocityProjection(ref Vector3 velocity, Vector3 obstructionNormal, bool stableOnHit)
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (GroundingStatus.IsStableOnGround && !MustUnground())
			{
				if (stableOnHit)
				{
					velocity = GetDirectionTangentToSurface(velocity, obstructionNormal) * ((Vector3)(ref velocity)).magnitude;
					return;
				}
				Vector3 val = Vector3.Cross(obstructionNormal, GroundingStatus.GroundNormal);
				val = Vector3.Cross(((Vector3)(ref val)).normalized, obstructionNormal);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				velocity = GetDirectionTangentToSurface(velocity, normalized) * ((Vector3)(ref velocity)).magnitude;
				velocity = Vector3.ProjectOnPlane(velocity, obstructionNormal);
			}
			else if (stableOnHit)
			{
				velocity = Vector3.ProjectOnPlane(velocity, _characterUp);
				velocity = GetDirectionTangentToSurface(velocity, obstructionNormal) * ((Vector3)(ref velocity)).magnitude;
			}
			else
			{
				velocity = Vector3.ProjectOnPlane(velocity, obstructionNormal);
			}
		}

		public virtual void HandleSimulatedRigidbodyInteraction(ref Vector3 processedVelocity, RigidbodyProjectionHit hit, float deltaTime)
		{
		}

		private bool SweepInternal(Vector3 position, Vector3 direction, float distance, out RaycastHit closest, bool stableOnly)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			int num = LayerMask.op_Implicit(CollidableLayers);
			if (stableOnly)
			{
				num = LayerMask.op_Implicit(CollidableLayers) & LayerMask.op_Implicit(StableGroundLayers);
			}
			Vector3 val = position + _bottomHemiWorld - direction * 0.002f;
			Vector3 val2 = position + _topHemiWorld - direction * 0.002f;
			int num2 = Physics.CapsuleCastNonAlloc(val, val2, CapsuleRadius, direction, _internalCharacterHits, distance + 0.002f, num, (QueryTriggerInteraction)1);
			closest = default(RaycastHit);
			float num3 = float.PositiveInfinity;
			bool result = false;
			for (int i = 0; i < num2; i++)
			{
				float num4 = ((RaycastHit)(ref _internalCharacterHits[i])).distance - 0.002f;
				if (!(num4 <= 0f) && !(num4 >= num3) && CheckIfColliderValidForCollisions(((RaycastHit)(ref _internalCharacterHits[i])).collider))
				{
					closest = _internalCharacterHits[i];
					((RaycastHit)(ref closest)).distance = num4;
					num3 = num4;
					result = true;
				}
			}
			return result;
		}

		private int OverlapInternal(Vector3 position, Collider[] results, float inflate)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result t

patchers/OptimizedKinematicCharacterController.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Microsoft.CodeAnalysis;
using Mono.Cecil;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("OptimizedKinematicCharacterController")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OptimizedKinematicCharacterController")]
[assembly: AssemblyTitle("OptimizedKinematicCharacterController")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace OptimizedKinematicCharacterController
{
	public static class OptimizedKinematicCharacterControllerPatcher
	{
		public static IEnumerable<string> TargetDLLs
		{
			get
			{
				yield return "KinematicCharacterController.dll";
			}
		}

		public static void Patch(ref AssemblyDefinition assembly)
		{
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(directoryName, "KinematicCharacterController.dll");
			if (!File.Exists(text))
			{
				Console.WriteLine("[OptimizedKinematicCharacterControllerPatcher] ERROR: Replacement assembly not found at " + text);
				return;
			}
			try
			{
				AssemblyDefinition val = AssemblyDefinition.ReadAssembly(text);
				assembly = val;
				Console.WriteLine("[OptimizedKinematicCharacterControllerPatcher] Successfully replaced target assembly!");
			}
			catch (Exception arg)
			{
				Console.WriteLine($"[OptimizedKinematicCharacterControllerPatcher] Failed to replace assembly: {arg}");
			}
		}
	}
}