Decompiled source of KCCDownpatcher v1.0.0

patchers/KCCDownpatcher.dll

Decompiled 21 hours ago
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx.Logging;
using Mono.Cecil;

[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("KCCDownpatcher")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0+54de9dbde1c2d1c1d2daba106d2b77363fe18bca")]
[assembly: AssemblyProduct("KCCDownpatcher")]
[assembly: AssemblyTitle("KCCDownpatcher")]
[assembly: AssemblyVersion("1.0.0.0")]
public static class KCCDownpatcher
{
	public static IEnumerable<string> TargetDLLs { get; } = new string[1] { "KinematicCharacterController.dll" };


	public static void Patch(ref AssemblyDefinition assembly)
	{
		AssemblyDefinition val = AssemblyDefinition.ReadAssembly(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "KinematicCharacterController.dll"));
		if (val == null)
		{
			Logger.CreateLogSource("KCCDownpatcher").LogError((object)"Failed to load KinematicCharacterController.dll");
		}
		else
		{
			assembly = val;
		}
	}
}

patchers/KinematicCharacterController.dll

Decompiled 21 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
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: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
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_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_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_00a6: 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_00af: 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_00b9: 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_00c4: 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_00d0: 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_0044: 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_004b: 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_005b: 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_0069: 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_0070: Unknown result type (might be due to invalid IL or missing references)
		float num = 0.2f;
		if (num > 0f && !hit.StableOnHit && !hit.Rigidbody.isKinematic)
		{
			float num2 = num / hit.Rigidbody.mass;
			Vector3 velocityFromRigidbodyMovement = Motor.GetVelocityFromRigidbodyMovement(hit.Rigidbody, hit.HitPoint, deltaTime);
			Vector3 val = Vector3.Project(hit.HitVelocity, hit.EffectiveHitNormal) - velocityFromRigidbodyMovement;
			hit.Rigidbody.AddForceAtPosition(num2 * val, hit.HitPoint, (ForceMode)2);
		}
		if (!hit.StableOnHit)
		{
			Vector3 val2 = Vector3.Project(Motor.GetVelocityFromRigidbodyMovement(hit.Rigidbody, hit.HitPoint, deltaTime), 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;

	private Rigidbody rb;

	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;
	}

	private void Start()
	{
		rb = ((Component)this).GetComponent<Rigidbody>();
	}

	private void Update()
	{
	}
}
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 enum CharacterSystemInterpolationMethod
{
	None,
	Unity,
	Custom
}
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 Vector3 InnerNormal;

	public Vector3 OuterNormal;

	public bool ValidStepDetected;

	public Collider SteppedCollider;

	public bool LedgeDetected;

	public bool IsOnEmptySideOfLedge;

	public float DistanceFromLedge;

	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);
}
[RequireComponent(typeof(CapsuleCollider))]
[RequireComponent(typeof(Rigidbody))]
public class KinematicCharacterMotor : MonoBehaviour
{
	[Header("Components")]
	public BaseCharacterController CharacterController;

	[ReadOnly]
	public CapsuleCollider Capsule;

	[ReadOnly]
	public Rigidbody Rigidbody;

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

	[SerializeField]
	[Tooltip("Height of the Character Capsule")]
	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("Misc Options")]
	[Tooltip("Notifies the Character Controller when discrete collisions are detected")]
	public bool DetectDiscreteCollisions;

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

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

	[Tooltip("Minimum length of a step that the character can step on (used in Extra stepping method). Use this to let the character step on steps that are smaller that its radius")]
	public float MinRequiredStepDepth = 0.1f;

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

	[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("Prevents snapping to ground on ledges. Set this to true if you want more determinism when launching off slopes")]
	public bool PreventSnappingOnLedges;

	[Range(1f, 180f)]
	[Tooltip("The maximun downward slope angle change that the character can be subjected to and still be snapping to the ground")]
	public float MaxStableDenivelationAngle = 180f;

	[Header("Rigidbody interactions")]
	[Tooltip("How the character interacts with non-kinematic rigidbodies. \"Kinematic\" mode means the character pushes the rigidbodies with infinite force (as a kinematic body would). \"SimulatedDynamic\" pushes the rigidbodies with a simulated mass value.")]
	public RigidbodyInteractionType RigidbodyInteractionType;

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

	[Header("Constraints")]
	[Tooltip("Determines if the character's movement uses the planar constraint")]
	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("Features & Optimizations")]
	[Tooltip("Handles properly detecting grounding status on steps, but has a performance cost.")]
	public StepHandlingMethod StepHandling = StepHandlingMethod.Standard;

	[Tooltip("Handles properly detecting ledge information and grounding status, but has a performance cost.")]
	public bool LedgeAndDenivelationHandling = true;

	[Tooltip("Handles properly being pushed by and standing on PhysicsMovers or dynamic rigidbodies. Also handles pushing dynamic rigidbodies")]
	public bool InteractiveRigidbodyHandling = true;

	[Tooltip("(We suggest leaving this off. This has a pretty heavy performance cost, and is not necessary unless you start seeing situations where a fast-moving character moves through colliders) Makes sure the character cannot perform a move at all if it would be overlapping with any collidable objects at its destination. Useful for preventing \"tunneling\". ")]
	public bool SafeMovement;

	[NonSerialized]
	public CharacterGroundingReport GroundingStatus;

	[NonSerialized]
	public CharacterTransientGroundingReport LastGroundingStatus;

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

	public static float updateTimerMax;

	private RaycastHit[] _internalCharacterHits = (RaycastHit[])(object)new RaycastHit[16];

	private Collider[] _internalProbedColliders = (Collider[])(object)new Collider[16];

	private Rigidbody[] _rigidbodiesPushedThisMove = (Rigidbody[])(object)new Rigidbody[16];

	private RigidbodyProjectionHit[] _internalRigidbodyProjectionHits = new RigidbodyProjectionHit[6];

	private Rigidbody _lastAttachedRigidbody;

	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 _lastSolvedOverlapNormalDirty;

	private Vector3 _lastSolvedOverlapNormal = Vector3.forward;

	private int _rigidbodiesPushedCount;

	private int _rigidbodyProjectionHitCount;

	private float _internalResultingMovementMagnitude;

	private Vector3 _internalResultingMovementDirection = Vector3.zero;

	private bool _isMovingFromAttachedRigidbody;

	private Vector3 _cachedWorldUp = Vector3.up;

	private Vector3 _cachedWorldForward = Vector3.forward;

	private Vector3 _cachedWorldRight = Vector3.right;

	private Vector3 _cachedZeroVector = Vector3.zero;

	private Vector3 _internalTransientPosition;

	private Quaternion _internalTransientRotation;

	public Vector3 BaseVelocity;

	private Vector3 _attachedRigidbodyVelocity;

	private OverlapResult[] _overlaps = new OverlapResult[16];

	public const int MaxHitsBudget = 16;

	public const int MaxCollisionBudget = 16;

	public const int MaxGroundingSweepIterations = 2;

	public const int MaxMovementSweepIterations = 6;

	public const int MaxSteppingSweepIterations = 3;

	public const int MaxRigidbodyOverlapsCount = 16;

	public const int MaxDiscreteCollisionIterations = 3;

	public const float CollisionOffset = 0.001f;

	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;

	public Transform Transform { get; private set; }

	public Vector3 CharacterUp { get; private set; }

	public Vector3 CharacterForward { get; private set; }

	public Vector3 CharacterRight { get; private set; }

	public Vector3 InitialSimulationPosition { get; private set; }

	public Quaternion InitialSimulationRotation { get; private set; }

	public Rigidbody AttachedRigidbody { get; private set; }

	public Vector3 CharacterTransformToCapsuleCenter { get; private set; }

	public Vector3 CharacterTransformToCapsuleBottom { get; private set; }

	public Vector3 CharacterTransformToCapsuleTop { get; private set; }

	public Vector3 CharacterTransformToCapsuleBottomHemi { get; private set; }

	public Vector3 CharacterTransformToCapsuleTopHemi { get; private set; }

	public bool MustUnground { get; private set; }

	public bool LastMovementIterationFoundAnyGround { get; set; }

	public int IndexInCharacterSystem { get; set; }

	public Vector3 InitialTickPosition { get; set; }

	public Quaternion InitialTickRotation { get; set; }

	public Rigidbody AttachedRigidbodyOverride { get; set; }

	public Vector3 TransientPosition
	{
		get
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return _internalTransientPosition;
		}
		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)
			_internalTransientPosition = value;
		}
	}

	public Quaternion TransientRotation
	{
		get
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return _internalTransientRotation;
		}
		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)
			//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_0014: 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_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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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)
			_internalTransientRotation = value;
			CharacterUp = _internalTransientRotation * _cachedWorldUp;
			CharacterForward = _internalTransientRotation * _cachedWorldForward;
			CharacterRight = _internalTransientRotation * _cachedWorldRight;
		}
	}

	public Vector3 InterpolatedPosition => Transform.position;

	public Quaternion InterpolatedRotation => Transform.rotation;

	public Vector3 Velocity => BaseVelocity + _attachedRigidbodyVelocity;

	public Vector3 AttachedRigidbodyVelocity
	{
		get
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			return _attachedRigidbodyVelocity;
		}
		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)
			_attachedRigidbodyVelocity = value;
		}
	}

	public int OverlapsCount { get; private set; }

	public OverlapResult[] Overlaps => _overlaps;

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

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

	private void Reset()
	{
		ValidateData();
	}

	private void OnValidate()
	{
	}

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

	public void ValidateData()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		Rigidbody = ((Component)this).GetComponent<Rigidbody>();
		Rigidbody.centerOfMass = Vector3.zero;
		Rigidbody.useGravity = false;
		Rigidbody.drag = 0f;
		Rigidbody.angularDrag = 0f;
		Rigidbody.maxAngularVelocity = float.PositiveInfinity;
		Rigidbody.maxDepenetrationVelocity = float.PositiveInfinity;
		Rigidbody.collisionDetectionMode = (CollisionDetectionMode)0;
		Rigidbody.isKinematic = true;
		Rigidbody.constraints = (RigidbodyConstraints)0;
		Rigidbody.interpolation = (RigidbodyInterpolation)(KinematicCharacterSystem.InterpolationMethod == CharacterSystemInterpolationMethod.Unity);
		Capsule = ((Component)this).GetComponent<CapsuleCollider>();
		CapsuleRadius = Mathf.Clamp(CapsuleRadius, 0f, CapsuleHeight * 0.5f);
		((Collider)Capsule).isTrigger = false;
		Capsule.direction = 1;
		((Collider)Capsule).sharedMaterial = CapsulePhysicsMaterial;
		SetCapsuleDimensions(CapsuleRadius, CapsuleHeight, CapsuleYOffset);
		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 SetCapsuleCollisionsActivation(bool kinematicCapsuleActive)
	{
		Rigidbody.detectCollisions = kinematicCapsuleActive;
	}

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

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

	public void SetPosition(Vector3 position, bool bypassInterpolation = true)
	{
		//IL_0012: 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_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_0036: Unknown result type (might be due to invalid IL or missing references)
		Rigidbody.interpolation = (RigidbodyInterpolation)0;
		Transform.position = position;
		Rigidbody.position = position;
		InitialSimulationPosition = position;
		TransientPosition = position;
		if (bypassInterpolation)
		{
			InitialTickPosition = position;
		}
		Rigidbody.interpolation = (RigidbodyInterpolation)(KinematicCharacterSystem.InterpolationMethod == CharacterSystemInterpolationMethod.Unity);
	}

	public void SetRotation(Quaternion rotation, bool bypassInterpolation = true)
	{
		//IL_0012: 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_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_0036: Unknown result type (might be due to invalid IL or missing references)
		Rigidbody.interpolation = (RigidbodyInterpolation)0;
		Transform.rotation = rotation;
		Rigidbody.rotation = rotation;
		InitialSimulationRotation = rotation;
		TransientRotation = rotation;
		if (bypassInterpolation)
		{
			InitialTickRotation = rotation;
		}
		Rigidbody.interpolation = (RigidbodyInterpolation)(KinematicCharacterSystem.InterpolationMethod == CharacterSystemInterpolationMethod.Unity);
	}

	public void SetPositionAndRotation(Vector3 position, Quaternion rotation, bool bypassInterpolation = true)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: 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_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_0039: 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_0051: 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)
		Rigidbody.interpolation = (RigidbodyInterpolation)0;
		Transform.SetPositionAndRotation(position, rotation);
		Rigidbody.position = position;
		Rigidbody.rotation = rotation;
		InitialSimulationPosition = position;
		InitialSimulationRotation = rotation;
		TransientPosition = position;
		TransientRotation = rotation;
		if (bypassInterpolation)
		{
			InitialTickPosition = position;
			InitialTickRotation = rotation;
		}
		Rigidbody.interpolation = (RigidbodyInterpolation)(KinematicCharacterSystem.InterpolationMethod == CharacterSystemInterpolationMethod.Unity);
	}

	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;
	}

	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 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 = 0f;
		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)
		SetPositionAndRotation(state.Position, state.Rotation, bypassInterpolation);
		BaseVelocity = state.BaseVelocity;
		AttachedRigidbodyVelocity = state.AttachedRigidbodyVelocity;
		MustUnground = state.MustUnground;
		LastMovementIterationFoundAnyGround = state.LastMovementIterationFoundAnyGround;
		GroundingStatus.CopyFrom(state.GroundingStatus);
		AttachedRigidbody = state.AttachedRigidbody;
	}

	public void SetCapsuleDimensions(float radius, float height, float yOffset)
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: 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_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: 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_00ac: 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_00c3: 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_00de: 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_00f5: 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_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: 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_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		CapsuleRadius = radius;
		CapsuleHeight = height;
		CapsuleYOffset = yOffset;
		Capsule.radius = CapsuleRadius;
		Capsule.height = Mathf.Clamp(CapsuleHeight, CapsuleRadius * 2f, CapsuleHeight);
		Capsule.center = new Vector3(0f, CapsuleYOffset, 0f);
		CharacterTransformToCapsuleCenter = Capsule.center;
		CharacterTransformToCapsuleBottom = Capsule.center + -_cachedWorldUp * (Capsule.height * 0.5f);
		CharacterTransformToCapsuleTop = Capsule.center + _cachedWorldUp * (Capsule.height * 0.5f);
		CharacterTransformToCapsuleBottomHemi = Capsule.center + -_cachedWorldUp * (Capsule.height * 0.5f) + _cachedWorldUp * Capsule.radius;
		CharacterTransformToCapsuleTopHemi = Capsule.center + _cachedWorldUp * (Capsule.height * 0.5f) + -_cachedWorldUp * Capsule.radius;
	}

	private void Awake()
	{
		//IL_0019: 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_003b: 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)
		Transform = ((Component)this).transform;
		ValidateData();
		InitialTickPosition = Transform.position;
		InitialTickRotation = Transform.rotation;
		TransientPosition = Transform.position;
		TransientRotation = Transform.rotation;
		RebuildCollidableLayers();
		if (Object.op_Implicit((Object)(object)CharacterController))
		{
			CharacterController.SetupCharacterMotor(this);
		}
		SetCapsuleDimensions(CapsuleRadius, CapsuleHeight, CapsuleYOffset);
	}

	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 UpdatePhase1(float deltaTime)
	{
		//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_0095: 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_00b2: 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_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: 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_00f5: 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_0300: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_0310: Unknown result type (might be due to invalid IL or missing references)
		//IL_0315: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0380: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: 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)
		//IL_0435: Unknown result type (might be due to invalid IL or missing references)
		//IL_043a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0450: Unknown result type (might be due to invalid IL or missing references)
		//IL_0456: Unknown result type (might be due to invalid IL or missing references)
		//IL_045b: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: 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_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c8: 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_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_04e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0504: Unknown result type (might be due to invalid IL or missing references)
		//IL_0508: Unknown result type (might be due to invalid IL or missing references)
		//IL_050d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0510: Unknown result type (might be due to invalid IL or missing references)
		//IL_0513: Unknown result type (might be due to invalid IL or missing references)
		//IL_0518: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: 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_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Unknown result type (might be due to invalid IL or missing references)
		//IL_048d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0492: Unknown result type (might be due to invalid IL or missing references)
		//IL_0497: Unknown result type (might be due to invalid IL or missing references)
		//IL_049e: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0617: Unknown result type (might be due to invalid IL or missing references)
		//IL_061d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0623: Unknown result type (might be due to invalid IL or missing references)
		//IL_0628: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0609: Unknown result type (might be due to invalid IL or missing references)
		//IL_060e: Unknown result type (might be due to invalid IL or missing references)
		//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0601: Unknown result type (might be due to invalid IL or missing references)
		//IL_0586: Unknown result type (might be due to invalid IL or missing references)
		//IL_058c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0592: Unknown result type (might be due to invalid IL or missing references)
		//IL_0597: Unknown result type (might be due to invalid IL or missing references)
		//IL_059c: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a1: 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;
		}
		CharacterController.BeforeCharacterUpdate(deltaTime);
		TransientPosition = Transform.position;
		TransientRotation = Transform.rotation;
		InitialSimulationPosition = TransientPosition;
		InitialSimulationRotation = TransientRotation;
		_rigidbodyProjectionHitCount = 0;
		OverlapsCount = 0;
		_lastSolvedOverlapNormalDirty = false;
		if (_movePositionDirty)
		{
			if (_solveMovementCollisions)
			{
				if (InternalCharacterMove(_movePositionTarget - TransientPosition, deltaTime, out _internalResultingMovementMagnitude, out _internalResultingMovementDirection) && InteractiveRigidbodyHandling)
				{
					Vector3 processedVelocity = Vector3.zero;
					ProcessVelocityForRigidbodyHits(ref processedVelocity, deltaTime);
				}
			}
			else
			{
				TransientPosition = _movePositionTarget;
			}
			_movePositionDirty = false;
		}
		LastGroundingStatus.CopyFrom(GroundingStatus);
		GroundingStatus = default(CharacterGroundingReport);
		GroundingStatus.GroundNormal = CharacterUp;
		if (_solveMovementCollisions)
		{
			Vector3 val = _cachedWorldUp;
			float num = 0f;
			int i = 0;
			bool flag = false;
			for (; i < 3; i++)
			{
				if (flag)
				{
					break;
				}
				int num2 = CharacterCollisionsOverlap(TransientPosition, TransientRotation, _internalProbedColliders);
				if (num2 > 0)
				{
					for (int j = 0; j < num2; j++)
					{
						Rigidbody attachedRigidbody = _internalProbedColliders[j].attachedRigidbody;
						if (Object.op_Implicit((Object)(object)attachedRigidbody) && (!attachedRigidbody.isKinematic || Object.op_Implicit((Object)(object)((Component)attachedRigidbody).GetComponent<PhysicsMover>())))
						{
							continue;
						}
						Transform component = ((Component)_internalProbedColliders[j]).GetComponent<Transform>();
						if (Physics.ComputePenetration((Collider)(object)Capsule, TransientPosition, TransientRotation, _internalProbedColliders[j], component.position, component.rotation, ref val, ref num))
						{
							HitStabilityReport hitStabilityReport = default(HitStabilityReport);
							hitStabilityReport.IsStable = IsStableOnNormal(val);
							val = GetObstructionNormal(val, hitStabilityReport);
							Vector3 val2 = val * (num + 0.001f);
							TransientPosition += val2;
							if (OverlapsCount < _overlaps.Length)
							{
								_overlaps[OverlapsCount] = new OverlapResult(val, _internalProbedColliders[j]);
								OverlapsCount++;
							}
							break;
						}
					}
				}
				else
				{
					flag = true;
				}
			}
		}
		if (_solveGrounding)
		{
			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 _internalTransientPosition, TransientRotation, probingDistance, ref GroundingStatus);
			}
		}
		LastMovementIterationFoundAnyGround = false;
		MustUnground = false;
		if (_solveGrounding)
		{
			CharacterController.PostGroundingUpdate(deltaTime);
		}
		if (!InteractiveRigidbodyHandling)
		{
			return;
		}
		_lastAttachedRigidbody = AttachedRigidbody;
		if (Object.op_Implicit((Object)(object)AttachedRigidbodyOverride))
		{
			AttachedRigidbody = AttachedRigidbodyOverride;
		}
		else if (GroundingStatus.IsStableOnGround && Object.op_Implicit((Object)(object)GroundingStatus.GroundCollider.attachedRigidbody))
		{
			Rigidbody interactiveRigidbody = GetInteractiveRigidbody(GroundingStatus.GroundCollider);
			if (Object.op_Implicit((Object)(object)interactiveRigidbody))
			{
				AttachedRigidbody = interactiveRigidbody;
			}
		}
		else
		{
			AttachedRigidbody = null;
		}
		Vector3 val3 = Vector3.zero;
		if (Object.op_Implicit((Object)(object)AttachedRigidbody))
		{
			val3 = GetVelocityFromRigidbodyMovement(AttachedRigidbody, TransientPosition, deltaTime);
		}
		if (PreserveAttachedRigidbodyMomentum && (Object)(object)_lastAttachedRigidbody != (Object)null && (Object)(object)AttachedRigidbody != (Object)(object)_lastAttachedRigidbody)
		{
			BaseVelocity += _attachedRigidbodyVelocity;
			BaseVelocity -= val3;
		}
		_attachedRigidbodyVelocity = _cachedZeroVector;
		if (Object.op_Implicit((Object)(object)AttachedRigidbody))
		{
			_attachedRigidbodyVelocity = val3;
			Vector3 val4 = Vector3.ProjectOnPlane(Quaternion.Euler(57.29578f * AttachedRigidbody.angularVelocity * deltaTime) * CharacterForward, CharacterUp);
			Vector3 normalized = ((Vector3)(ref val4)).normalized;
			TransientRotation = Quaternion.LookRotation(normalized, CharacterUp);
		}
		if (Object.op_Implicit((Object)(object)GroundingStatus.GroundCollider) && Object.op_Implicit((Object)(object)GroundingStatus.GroundCollider.attachedRigidbody) && (Object)(object)GroundingStatus.GroundCollider.attachedRigidbody == (Object)(object)AttachedRigidbody && (Object)(object)AttachedRigidbody != (Object)null && (Object)(object)_lastAttachedRigidbody == (Object)null)
		{
			BaseVelocity -= Vector3.ProjectOnPlane(_attachedRigidbodyVelocity, CharacterUp);
		}
		if (!(((Vector3)(ref _attachedRigidbodyVelocity)).sqrMagnitude > 0f))
		{
			return;
		}
		_isMovingFromAttachedRigidbody = true;
		if (_solveMovementCollisions)
		{
			if (InternalCharacterMove(_attachedRigidbodyVelocity * deltaTime, deltaTime, out _internalResultingMovementMagnitude, out _internalResultingMovementDirection))
			{
				_attachedRigidbodyVelocity = _internalResultingMovementDirection * _internalResultingMovementMagnitude / deltaTime;
			}
			else
			{
				_attachedRigidbodyVelocity = Vector3.zero;
			}
		}
		else
		{
			TransientPosition += _attachedRigidbodyVelocity * deltaTime;
		}
		_isMovingFromAttachedRigidbody = false;
	}

	public void UpdatePhase2(float deltaTime)
	{
		//IL_0014: 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_03b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0424: Unknown result type (might be due to invalid IL or missing references)
		//IL_042a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0430: Unknown result type (might be due to invalid IL or missing references)
		//IL_0435: 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_03dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: 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_007e: 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_008f: 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_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_045e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0464: Unknown result type (might be due to invalid IL or missing references)
		//IL_046a: Unknown result type (might be due to invalid IL or missing references)
		//IL_046f: 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_047f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0484: Unknown result type (might be due to invalid IL or missing references)
		//IL_0416: Unknown result type (might be due to invalid IL or missing references)
		//IL_041b: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0403: Unknown result type (might be due to invalid IL or missing references)
		//IL_0409: Unknown result type (might be due to invalid IL or missing references)
		//IL_040e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0498: Unknown result type (might be due to invalid IL or missing references)
		//IL_049e: 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_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: 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_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: 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_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: 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_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0342: 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_02a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: 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_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: 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_031e: Unknown result type (might be due to invalid IL or missing references)
		CharacterController.UpdateRotation(ref _internalTransientRotation, deltaTime);
		TransientRotation = _internalTransientRotation;
		if (_moveRotationDirty)
		{
			TransientRotation = _moveRotationTarget;
			_moveRotationDirty = false;
		}
		if (_solveMovementCollisions && InteractiveRigidbodyHandling)
		{
			if (InteractiveRigidbodyHandling && Object.op_Implicit((Object)(object)AttachedRigidbody))
			{
				float radius = Capsule.radius;
				if (CharacterGroundSweep(TransientPosition + CharacterUp * radius, TransientRotation, -CharacterUp, radius, out var closestHit) && (Object)(object)((RaycastHit)(ref closestHit)).collider.attachedRigidbody == (Object)(object)AttachedRigidbody && IsStableOnNormal(((RaycastHit)(ref closestHit)).normal))
				{
					float num = radius - ((RaycastHit)(ref closestHit)).distance;
					TransientPosition = TransientPosition + CharacterUp * num + CharacterUp * 0.001f;
				}
			}
			if (SafeMovement || InteractiveRigidbodyHandling)
			{
				Vector3 val = _cachedWorldUp;
				float num2 = 0f;
				int i = 0;
				bool flag = false;
				for (; i < 3; i++)
				{
					if (flag)
					{
						break;
					}
					int num3 = CharacterCollisionsOverlap(TransientPosition, TransientRotation, _internalProbedColliders);
					if (num3 > 0)
					{
						for (int j = 0; j < num3; j++)
						{
							Transform component = ((Component)_internalProbedColliders[j]).GetComponent<Transform>();
							if (!Physics.ComputePenetration((Collider)(object)Capsule, TransientPosition, TransientRotation, _internalProbedColliders[j], component.position, component.rotation, ref val, ref num2))
							{
								continue;
							}
							HitStabilityReport hitStabilityReport = default(HitStabilityReport);
							hitStabilityReport.IsStable = IsStableOnNormal(val);
							val = GetObstructionNormal(val, hitStabilityReport);
							Vector3 val2 = val * (num2 + 0.001f);
							TransientPosition += val2;
							if (InteractiveRigidbodyHandling)
							{
								Rigidbody attachedRigidbody = _internalProbedColliders[j].attachedRigidbody;
								if (Object.op_Implicit((Object)(object)attachedRigidbody))
								{
									PhysicsMover component2 = ((Component)attachedRigidbody).GetComponent<PhysicsMover>();
									if (Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)attachedRigidbody) && (!attachedRigidbody.isKinematic || Object.op_Implicit((Object)(object)component2)))
									{
										HitStabilityReport hitStabilityReport2 = default(HitStabilityReport);
										hitStabilityReport2.IsStable = IsStableOnNormal(val);
										if (hitStabilityReport2.IsStable)
										{
											LastMovementIterationFoundAnyGround = hitStabilityReport2.IsStable;
										}
										if (Object.op_Implicit((Object)(object)component2.Rigidbody) && (Object)(object)component2.Rigidbody != (Object)(object)AttachedRigidbody)
										{
											Vector3 val3 = TransientPosition + TransientRotation * CharacterTransformToCapsuleCenter;
											Vector3 transientPosition = TransientPosition;
											Collider obj = _internalProbedColliders[j];
											MeshCollider val4 = (MeshCollider)(object)((obj is MeshCollider) ? obj : null);
											if (!Object.op_Implicit((Object)(object)val4) || val4.convex)
											{
												Physics.ClosestPoint(val3, _internalProbedColliders[j], component.position, component.rotation);
											}
											StoreRigidbodyHit(component2.Rigidbody, Velocity, transientPosition, val, hitStabilityReport2);
										}
									}
								}
							}
							if (OverlapsCount < _overlaps.Length)
							{
								_overlaps[OverlapsCount] = new OverlapResult(val, _internalProbedColliders[j]);
								OverlapsCount++;
							}
							break;
						}
					}
					else
					{
						flag = true;
					}
				}
			}
		}
		CharacterController.UpdateVelocity(ref BaseVelocity, deltaTime);
		if (((Vector3)(ref BaseVelocity)).magnitude < 0.01f)
		{
			BaseVelocity = Vector3.zero;
		}
		if (((Vector3)(ref BaseVelocity)).sqrMagnitude > 0f)
		{
			if (_solveMovementCollisions)
			{
				if (InternalCharacterMove(BaseVelocity * deltaTime, deltaTime, out _internalResultingMovementMagnitude, out _internalResultingMovementDirection))
				{
					BaseVelocity = _internalResultingMovementDirection * _internalResultingMovementMagnitude / deltaTime;
				}
				else
				{
					BaseVelocity = Vector3.zero;
				}
			}
			else
			{
				TransientPosition += BaseVelocity * deltaTime;
			}
		}
		if (InteractiveRigidbodyHandling)
		{
			ProcessVelocityForRigidbodyHits(ref BaseVelocity, deltaTime);
		}
		if (HasPlanarConstraint)
		{
			TransientPosition = InitialSimulationPosition + Vector3.ProjectOnPlane(TransientPosition - InitialSimulationPosition, ((Vector3)(ref PlanarConstraintAxis)).normalized);
		}
		if (DetectDiscreteCollisions)
		{
			int num4 = CharacterCollisionsOverlap(TransientPosition, TransientRotation, _internalProbedColliders, 0.002f);
			for (int k = 0; k < num4; k++)
			{
				CharacterController.OnDiscreteCollisionDetected(_internalProbedColliders[k]);
			}
		}
		CharacterController.AfterCharacterUpdate(deltaTime);
	}

	private bool IsStableOnNormal(Vector3 normal)
	{
		//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)
		return Vector3.Angle(CharacterUp, normal) <= MaxStableSlopeAngle;
	}

	public void ProbeGround(ref Vector3 probingPosition, Quaternion atRotation, float probingDistance, ref CharacterGroundingReport groundingReport)
	{
		//IL_0013: 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_0021: 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_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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: 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_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)
		//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_005a: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: 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_0087: 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_00cd: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: 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_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: 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_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0289: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: 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_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: 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_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		if (probingDistance < 0.005f)
		{
			probingDistance = 0.005f;
		}
		int num = 0;
		RaycastHit closestHit = default(RaycastHit);
		bool flag = false;
		Vector3 val = probingPosition;
		Vector3 val2 = atRotation * -_cachedWorldUp;
		float num2 = probingDistance;
		while (num2 > 0f && num <= 2 && !flag)
		{
			if (CharacterGroundSweep(val, atRotation, val2, num2, out closestHit))
			{
				Vector3 val3 = val + val2 * ((RaycastHit)(ref closestHit)).distance;
				HitStabilityReport stabilityReport = default(HitStabilityReport);
				EvaluateHitStability(((RaycastHit)(ref closestHit)).collider, ((RaycastHit)(ref closestHit)).normal, ((RaycastHit)(ref closestHit)).point, val3, TransientRotation, ref stabilityReport);
				if (stabilityReport.LedgeDetected && stabilityReport.IsOnEmptySideOfLedge && stabilityReport.DistanceFromLedge > MaxStableDistanceFromLedge)
				{
					stabilityReport.IsStable = false;
				}
				groundingReport.FoundAnyGround = true;
				groundingReport.GroundNormal = ((RaycastHit)(ref closestHit)).normal;
				groundingReport.InnerGroundNormal = stabilityReport.InnerNormal;
				groundingReport.OuterGroundNormal = stabilityReport.OuterNormal;
				groundingReport.GroundCollider = ((RaycastHit)(ref closestHit)).collider;
				groundingReport.GroundPoint = ((RaycastHit)(ref closestHit)).point;
				groundingReport.SnappingPrevented = false;
				if (stabilityReport.IsStable)
				{
					if (LedgeAndDenivelationHandling)
					{
						if (LastGroundingStatus.FoundAnyGround && ((Vector3)(ref stabilityReport.InnerNormal)).sqrMagnitude != 0f && ((Vector3)(ref stabilityReport.OuterNormal)).sqrMagnitude != 0f)
						{
							if (Vector3.Angle(stabilityReport.InnerNormal, stabilityReport.OuterNormal) > MaxStableDenivelationAngle)
							{
								groundingReport.SnappingPrevented = true;
							}
							else if (Vector3.Angle(LastGroundingStatus.InnerGroundNormal, stabilityReport.OuterNormal) > MaxStableDenivelationAngle)
							{
								groundingReport.SnappingPrevented = true;
							}
						}
						if (PreventSnappingOnLedges && stabilityReport.LedgeDetected)
						{
							groundingReport.SnappingPrevented = true;
						}
					}
					groundingReport.IsStableOnGround = true;
					if (!groundingReport.SnappingPrevented)
					{
						val3 += -val2 * 0.001f;
						InternalMoveCharacterPosition(ref probingPosition, val3, atRotation);
					}
					CharacterController.OnGroundHit(((RaycastHit)(ref closestHit)).collider, ((RaycastHit)(ref closestHit)).normal, ((RaycastHit)(ref closestHit)).point, ref stabilityReport);
					flag = true;
				}
				else
				{
					Vector3 val4 = val2 * ((RaycastHit)(ref closestHit)).distance + atRotation * Vector3.up * Mathf.Clamp(0.001f, 0f, ((RaycastHit)(ref closestHit)).distance);
					val += val4;
					num2 = Mathf.Min(0.02f, Mathf.Clamp(num2 - ((Vector3)(ref val4)).magnitude, 0f, float.PositiveInfinity));
					Vector3 val5 = Vector3.ProjectOnPlane(val2, ((RaycastHit)(ref closestHit)).normal);
					val2 = ((Vector3)(ref val5)).normalized;
				}
			}
			else
			{
				flag = true;
			}
			num++;
		}
	}

	public void ForceUnground()
	{
		MustUnground = true;
	}

	public void ForceUnground(float time = 0.1f)
	{
		MustUnground = true;
	}

	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 InternalCharacterMove(Vector3 movement, float deltaTime, out float resultingMovementMagnitude, out Vector3 resultingMovementDirection)
	{
		//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_001b: 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_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_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_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_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: 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_0063: 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_00a8: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: 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_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03be: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ca: 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_03d8: 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_0112: 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_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: 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_013c: 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_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_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: 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_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: 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_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_033d: 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_01bc: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_036a: Unknown result type (might be due to invalid IL or missing references)
		//IL_036f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0371: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_027f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_0289: Unknown result type (might be due to invalid IL or missing references)
		_rigidbodiesPushedCount = 0;
		bool result = true;
		Vector3 remainingMovementDirection = ((Vector3)(ref movement)).normalized;
		float remainingMovementMagnitude = ((Vector3)(ref movement)).magnitude;
		resultingMovementDirection = remainingMovementDirection;
		resultingMovementMagnitude = remainingMovementMagnitude;
		int num = 0;
		bool flag = true;
		Vector3 val = TransientPosition;
		Vector3 transientPosition = TransientPosition;
		Vector3 normalized = ((Vector3)(ref movement)).normalized;
		Vector3 previousObstructionNormal = _cachedZeroVector;
		MovementSweepState sweepState = MovementSweepState.Initial;
		for (int i = 0; i < OverlapsCount; i++)
		{
			if (Vector3.Dot(remainingMovementDirection, _overlaps[i].Normal) < 0f)
			{
				InternalHandleMovementProjection(IsStableOnNormal(_overlaps[i].Normal) && !MustUnground, _overlaps[i].Normal, _overlaps[i].Normal, normalized, ref sweepState, ref previousObstructionNormal, ref resultingMovementMagnitude, ref remainingMovementDirection, ref remainingMovementMagnitude);
			}
		}
		while (remainingMovementMagnitude > 0f && num <= 6 && flag)
		{
			if (CharacterCollisionsSweep(val, TransientRotation, remainingMovementDirection, remainingMovementMagnitude + 0.001f, out var closestHit, _internalCharacterHits) > 0)
			{
				transientPosition = val + remainingMovementDirection * ((RaycastHit)(ref closestHit)).distance + ((RaycastHit)(ref closestHit)).normal * 0.001f;
				Vector3 val2 = transientPosition - val;
				HitStabilityReport stabilityReport = default(HitStabilityReport);
				EvaluateHitStability(((RaycastHit)(ref closestHit)).collider, ((RaycastHit)(ref closestHit)).normal, ((RaycastHit)(ref closestHit)).point, transientPosition, TransientRotation, ref stabilityReport);
				bool flag2 = false;
				if (_solveGrounding && StepHandling != 0 && stabilityReport.ValidStepDetected && Mathf.Abs(Vector3.Dot(((RaycastHit)(ref closestHit)).normal, CharacterUp)) <= 0.01f)
				{
					Vector3 val3 = Vector3.ProjectOnPlane(-((RaycastHit)(ref closestHit)).normal, CharacterUp);
					Vector3 normalized2 = ((Vector3)(ref val3)).normalized;
					Vector3 val4 = transientPosition + normalized2 * 0.03f + CharacterUp * MaxStepHeight;
					RaycastHit closestHit2;
					int num2 = CharacterCollisionsSweep(val4, TransientRotation, -CharacterUp, MaxStepHeight, out closestHit2, _internalCharacterHits);
					for (int j = 0; j < num2; j++)
					{
						if ((Object)(object)((RaycastHit)(ref _internalCharacterHits[j])).collider == (Object)(object)stabilityReport.SteppedCollider)
						{
							val = val4 + -CharacterUp * (((RaycastHit)(ref _internalCharacterHits[j])).distance - 0.001f);
							flag2 = true;
							remainingMovementMagnitude = Mathf.Clamp(remainingMovementMagnitude - ((Vector3)(ref val2)).magnitude, 0f, float.PositiveInfinity);
							break;
						}
					}
				}
				if (!flag2)
				{
					val = transientPosition;
					remainingMovementMagnitude = Mathf.Clamp(remainingMovementMagnitude - ((Vector3)(ref val2)).magnitude, 0f, float.PositiveInfinity);
					CharacterController.OnMovementHit(((RaycastHit)(ref closestHit)).collider, ((RaycastHit)(ref closestHit)).normal, ((RaycastHit)(ref closestHit)).point, ref stabilityReport);
					Vector3 obstructionNormal = GetObstructionNormal(((RaycastHit)(ref closestHit)).normal, stabilityReport);
					if (InteractiveRigidbodyHandling && Object.op_Implicit((Object)(object)((RaycastHit)(ref closestHit)).collider.attachedRigidbody))
					{
						StoreRigidbodyHit(((RaycastHit)(ref closestHit)).collider.attachedRigidbody, remainingMovementDirection * resultingMovementMagnitude / deltaTime, ((RaycastHit)(ref closestHit)).point, obstructionNormal, stabilityReport);
					}
					InternalHandleMovementProjection(stabilityReport.IsStable && !MustUnground, ((RaycastHit)(ref closestHit)).normal, obstructionNormal, normalized, ref sweepState, ref previousObstructionNormal, ref resultingMovementMagnitude, ref remainingMovementDirection, ref remainingMovementMagnitude);
				}
			}
			else
			{
				flag = false;
			}
			num++;
			if (num > 6)
			{
				remainingMovementMagnitude = 0f;
				result = false;
			}
		}
		Vector3 targetPosition = val + remainingMovementDirection * remainingMovementMagnitude;
		InternalMoveCharacterPosition(ref _internalTransientPosition, targetPosition, TransientRotation);
		resultingMovementDirection = remainingMovementDirection;
		return result;
	}

	private Vector3 GetObstructionNormal(Vector3 hitNormal, HitStabilityReport hitStabilityReport)
	{
		//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_005c: 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_005b: 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_002b: 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_0033: 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_0043: 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)
		Vector3 val = hitNormal;
		if (GroundingStatus.IsStableOnGround && !MustUnground && !hitStabilityReport.IsStable)
		{
			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;
	}

	private void StoreRigidbodyHit(Rigidbody hitRigidbody, Vector3 hitVelocity, Vector3 hitPoint, Vector3 obstructionNormal, HitStabilityReport hitStabilityReport)
	{
		//IL_002f: 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_0037: 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_0040: 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)
		if (_rigidbodyProjectionHitCount < _internalRigidbodyProjectionHits.Length && !Object.op_Implicit((Object)(object)((Component)hitRigidbody).GetComponent<KinematicCharacterMotor>()))
		{
			RigidbodyProjectionHit rigidbodyProjectionHit = default(RigidbodyProjectionHit);
			rigidbodyProjectionHit.Rigidbody = hitRigidbody;
			rigidbodyProjectionHit.HitPoint = hitPoint;
			rigidbodyProjectionHit.EffectiveHitNormal = obstructionNormal;
			rigidbodyProjectionHit.HitVelocity = hitVelocity;
			rigidbodyProjectionHit.StableOnHit = hitStabilityReport.IsStable;
			_internalRigidbodyProjectionHits[_rigidbodyProjectionHitCount] = rigidbodyProjectionHit;
			_rigidbodyProjectionHitCount++;
		}
	}

	private void InternalHandleMovementProjection(bool stableOnHit, Vector3 hitNormal, Vector3 obstructionNormal, Vector3 originalMoveDirection, ref MovementSweepState sweepState, ref Vector3 previousObstructionNormal, ref float resultingMovementMagnitude, ref Vector3 remainingMovementDirection, ref float remainingMovementMagnitude)
	{
		//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_0015: 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_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_00e9: 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_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_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_00a9: 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_00b1: 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_00b7: 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_00b9: 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)
		if (remainingMovementMagnitude <= 0f)
		{
			return;
		}
		Vector3 movement = originalMoveDirection * remainingMovementMagnitude;
		float num = remainingMovementMagnitude;
		if (stableOnHit)
		{
			LastMovementIterationFoundAnyGround = true;
		}
		if (sweepState == MovementSweepState.FoundBlockingCrease)
		{
			remainingMovementMagnitude = 0f;
			resultingMovementMagnitude = 0f;
			sweepState = MovementSweepState.FoundBlockingCorner;
		}
		else
		{
			CharacterController.HandleMovementProjection(ref movement, obstructionNormal, stableOnHit);
			remainingMovementDirection = ((Vector3)(ref movement)).normalized;
			remainingMovementMagnitude = ((Vector3)(ref movement)).magnitude;
			resultingMovementMagnitude = remainingMovementMagnitude / num * resultingMovementMagnitude;
			if (sweepState == MovementSweepState.Initial)
			{
				sweepState = MovementSweepState.AfterFirstHit;
			}
			else if (sweepState == MovementSweepState.AfterFirstHit && Vector3.Dot(previousObstructionNormal, remainingMovementDirection) < 0f)
			{
				Vector3 val = Vector3.Cross(previousObstructionNormal, obstructionNormal);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				movement = Vector3.Project(movement, normalized);
				remainingMovementDirection = ((Vector3)(ref movement)).normalized;
				remainingMovementMagnitude = ((Vector3)(ref movement)).magnitude;
				resultingMovementMagnitude = remainingMovementMagnitude / num * resultingMovementMagnitude;
				sweepState = MovementSweepState.FoundBlockingCrease;
			}
		}
		previousObstructionNormal = obstructionNormal;
	}

	private bool InternalMoveCharacterPosition(ref Vector3 movedPosition, Vector3 targetPosition, Quaternion atRotation)
	{
		//IL_000b: 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_0026: 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)
		bool flag = true;
		if (SafeMovement && CharacterCollisionsOverlap(targetPosition, atRotation, _internalProbedColliders) > 0)
		{
			flag = false;
		}
		if (flag)
		{
			movedPosition = targetPosition;
			return true;
		}
		return false;
	}

	private void ProcessVelocityForRigidbodyHits(ref Vector3 processedVelocity, float deltaTime)
	{
		for (int i = 0; i < _rigidbodyProjectionHitCount; i++)
		{
			if (!Object.op_Implicit((Object)(object)_internalRigidbodyProjectionHits[i].Rigidbody))
			{
				continue;
			}
			bool flag = false;
			for (int j = 0; j < _rigidbodiesPushedCount && j < 6 && j < 16; j++)
			{
				if ((Object)(object)_rigidbodiesPushedThisMove[j] == (Object)(object)_internalRigidbodyProjectionHits[j].Rigidbody)
				{
					flag = true;
					break;
				}
			}
			if (!flag && (Object)(object)_internalRigidbodyProjectionHits[i].Rigidbody != (Object)(object)AttachedRigidbody && _rigidbodiesPushedCount < _rigidbodiesPushedThisMove.Length)
			{
				_rigidbodiesPushedThisMove[_rigidbodiesPushedCount] = _internalRigidbodyProjectionHits[i].Rigidbody;
				_rigidbodiesPushedCount++;
				if (RigidbodyInteractionType == RigidbodyInteractionType.SimulatedDynamic)
				{
					CharacterController.HandleSimulatedRigidbodyInteraction(ref processedVelocity, _internalRigidbodyProjectionHits[i], deltaTime);
				}
			}
		}
	}

	private bool CheckIfColliderValidForCollisions(Collider coll)
	{
		if ((Object)(object)coll == (Object)null || (Object)(object)coll == (Object)(object)Capsule)
		{
			return false;
		}
		if (!IsColliderValidForCollisions(coll))
		{
			return false;
		}
		return true;
	}

	private bool IsColliderValidForCollisions(Collider coll)
	{
		if ((_isMovingFromAttachedRigidbody || RigidbodyInteractionType == RigidbodyInteractionType.Kinematic) && Object.op_Implicit((Object)(object)coll.attachedRigidbody) && !coll.attachedRigidbody.isKinematic)
		{
			return false;
		}
		if (_isMovingFromAttachedRigidbody && (Object)(object)coll.attachedRigidbody == (Object)(object)AttachedRigidbody)
		{
			return false;
		}
		if (!CharacterController.IsColliderValidForCollisions(coll))
		{
			return false;
		}
		return true;
	}

	public void EvaluateHitStability(Collider hitCollider, Vector3 hitNormal, Vector3 hitPoint, Vector3 atCharacterPosition, Quaternion atCharacterRotation, ref HitStabilityReport stabilityReport)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: 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_001e: 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_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_0028: 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_002f: 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_0039: 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_0041: 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_00a3: 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_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_00b9: 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_00c4: 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_006e: 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_0071: 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_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: 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_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: 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_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0197: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: 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_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01de: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		if (!_solveGrounding)
		{
			stabilityReport.IsStable = false;
			return;
		}
		Vector3 val = atCharacterRotation * Vector3.up;
		Vector3 val2 = Vector3.ProjectOnPlane(hitNormal, val);
		Vector3 normalized = ((Vector3)(ref val2)).normalized;
		bool flag = IsStableOnNormal(hitNormal);
		stabilityReport.InnerNormal = hitNormal;
		stabilityReport.OuterNormal = hitNormal;
		if (StepHandling != 0 && !flag)
		{
			Rigidbody attachedRigidbody = hitCollider.attachedRigidbody;
			if (!Object.op_Implicit((Object)(object)attachedRigidbody) || attachedRigidbody.isKinematic)
			{
				DetectSteps(atCharacterPosition, atCharacterRotation, hitPoint, normalized, ref stabilityReport);
			}
		}
		if (LedgeAndDenivelationHandling)
		{
			float num = 0.05f;
			if (StepHandling != 0)
			{
				num = MaxStepHeight;
			}
			bool flag2 = false;
			bool flag3 = false;
			if (CharacterCollisionsRaycast(hitPoint + val * 0.02f + normalized * 0.001f, -val, num + 0.02f, out var closestHit, _internalCharacterHits) > 0)
			{
				stabilityReport.InnerNormal = ((RaycastHit)(ref closestHit)).normal;
				flag2 = IsStableOnNormal(((RaycastHit)(ref closestHit)).normal);
			}
			if (CharacterCollisionsRaycast(hi

plugins/KCCDownplugin.dll

Decompiled 21 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using KinematicCharacterController;
using MonoMod.RuntimeDetour;
using RoR2;
using UnityEngine;

[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("KCCDownplugin")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0.0+54de9dbde1c2d1c1d2daba106d2b77363fe18bca")]
[assembly: AssemblyProduct("KCCDownplugin")]
[assembly: AssemblyTitle("KCCDownplugin")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace KCCDownplugin;

[BepInPlugin("dolso.kccdownplugin", "KCCDownplugin", "1.0.0")]
public class KCCDownplugin : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		new Hook((MethodBase)typeof(CharacterMotor).GetMethod("Awake", (BindingFlags)(-1)), (Delegate)new Action<Action<CharacterMotor>, CharacterMotor>(FixNullMotor_On_Awake_CharacterMotor));
		new Hook((MethodBase)typeof(CharacterMotor).GetMethod("BeforeCharacterUpdate", (BindingFlags)(-1)), (Delegate)new Action<Action<CharacterMotor, float>, CharacterMotor, float>(AddSafeMovementCheck_On_BeforeCharacterUpdate_CharacterMotor));
	}

	private static void FixNullMotor_On_Awake_CharacterMotor(Action<CharacterMotor> orig, CharacterMotor self)
	{
		if (!Object.op_Implicit((Object)(object)((BaseCharacterController)self).Motor))
		{
			((BaseCharacterController)self).SetupCharacterMotor(((Component)self).GetComponent<KinematicCharacterMotor>());
		}
		orig(self);
	}

	private static void AddSafeMovementCheck_On_BeforeCharacterUpdate_CharacterMotor(Action<CharacterMotor, float> orig, CharacterMotor self, float deltaTime)
	{
		float num = CharacterMotor.cvCMotorSafeCollisionStepThreshold.value * CharacterMotor.cvCMotorSafeCollisionStepThreshold.value;
		if (((Vector3)(ref self.rootMotion)).sqrMagnitude > 0f)
		{
			((BaseCharacterController)self).Motor.SafeMovement = ((Vector3)(ref self.rootMotion)).sqrMagnitude >= num;
		}
		orig(self, deltaTime);
		((BaseCharacterController)self).Motor.SafeMovement = ((Vector3)(ref self.velocity)).sqrMagnitude * Time.fixedDeltaTime * Time.fixedDeltaTime >= num;
	}
}