using System;
using Cpp2IlInjected;
using UnityEngine;

namespace RootMotion.FinalIK
{
	// Token: 0x02000484 RID: 1156
	[Token(Token = "0x2000484")]
	[Serializable]
	public class IKSolverFullBody : IKSolver
	{
		// Token: 0x06002906 RID: 10502 RVA: 0x0005CAAC File Offset: 0x0005ACAC
		[Token(Token = "0x6002906")]
		[Address(RVA = "0x1518E90", Offset = "0x1517E90", VA = "0x181518E90")]
		public IKEffector GetEffector(Transform t)
		{
			IKEffector[] array = this.effectors;
			int num = 0;
			if (num < array.Length)
			{
				bool flag = array[num].bone == t;
				IKEffector[] array2 = this.effectors;
				if (!flag)
				{
					num++;
				}
				return array2[num];
			}
			throw new NullReferenceException();
		}

		// Token: 0x06002907 RID: 10503 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002907")]
		[Address(RVA = "0x1518E40", Offset = "0x1517E40", VA = "0x181518E40")]
		public FBIKChain GetChain(Transform transform)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002908 RID: 10504 RVA: 0x0005CAFC File Offset: 0x0005ACFC
		[Token(Token = "0x6002908")]
		[Address(RVA = "0x1518D10", Offset = "0x1517D10", VA = "0x181518D10")]
		public int GetChainIndex(Transform transform)
		{
			FBIKChain[] array = this.chain;
			int num = 0;
			int num2 = 0;
			if (num2 < array.Length)
			{
				int num3 = 0;
				IKSolver.Node[] nodes = this.chain[num].nodes;
				if (num3 < nodes.Length)
				{
					if (nodes[num3].transform == transform)
					{
						return num;
					}
					num3++;
				}
				num++;
				return num;
			}
			throw new NullReferenceException();
		}

		// Token: 0x06002909 RID: 10505 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002909")]
		[Address(RVA = "0x1518FB0", Offset = "0x1517FB0", VA = "0x181518FB0")]
		public IKSolver.Node GetNode(int chainIndex, int nodeIndex)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x0600290A RID: 10506 RVA: 0x0005CB64 File Offset: 0x0005AD64
		[Token(Token = "0x600290A")]
		[Address(RVA = "0x1518C80", Offset = "0x1517C80", VA = "0x181518C80")]
		public void GetChainAndNodeIndexes(Transform transform, out int chainIndex, out int nodeIndex)
		{
			int chainIndex2 = this.GetChainIndex(transform);
			chainIndex.m_value = chainIndex2;
			if (chainIndex2 != -1)
			{
				int nodeIndex2 = this.chain[chainIndex2].GetNodeIndex(transform);
				nodeIndex.m_value = nodeIndex2;
			}
		}

		// Token: 0x0600290B RID: 10507 RVA: 0x0005CBA4 File Offset: 0x0005ADA4
		[Token(Token = "0x600290B")]
		[Address(RVA = "0x15191B0", Offset = "0x15181B0", VA = "0x1815191B0", Slot = "6")]
		public override IKSolver.Point[] GetPoints()
		{
			IKSolver.Point[] array2;
			int num5;
			int num6;
			IKSolver.Node[] nodes2;
			do
			{
				FBIKChain[] array = this.chain;
				int num = 0;
				int num2 = 0;
				int num3 = 0;
				int length = array.Length;
				if (num3 < length)
				{
					IKSolver.Node[] nodes = array[num2].nodes;
					num2++;
				}
				array2 = new IKSolver.Point[num];
				FBIKChain[] array3 = this.chain;
				int num4 = 0;
				num5 = 0;
				if (num4 >= array3.Length)
				{
					return array2;
				}
				num6 = 0;
				nodes2 = this.chain[num5].nodes;
				if (num6 >= nodes2.Length)
				{
					goto IL_97;
				}
			}
			while (nodes2[num6] != 0 && num6 == 0);
			throw new IndexOutOfRangeException();
			IL_97:
			num5++;
			return array2;
		}

		// Token: 0x0600290C RID: 10508 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x600290C")]
		[Address(RVA = "0x1519020", Offset = "0x1518020", VA = "0x181519020", Slot = "7")]
		public override IKSolver.Point GetPoint(Transform transform)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x0600290D RID: 10509 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x600290D")]
		[Address(RVA = "0x1519340", Offset = "0x1518340", VA = "0x181519340", Slot = "4")]
		public override bool IsValid(ref string message)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x0600290E RID: 10510 RVA: 0x0005CC5C File Offset: 0x0005AE5C
		[Token(Token = "0x600290E")]
		[Address(RVA = "0x151A090", Offset = "0x1519090", VA = "0x18151A090", Slot = "9")]
		public override void StoreDefaultLocalState()
		{
			this.spineMapping.StoreDefaultLocalState();
			IKMappingLimb[] array = this.limbMappings;
			int num = 0;
			if (num < array.Length)
			{
				array[num].StoreDefaultLocalState();
				IKMappingLimb[] array2 = this.limbMappings;
				num++;
			}
			IKMappingBone[] array3 = this.boneMappings;
			if (num < array3.Length)
			{
				array3[num].StoreDefaultLocalState();
				IKMappingBone[] array4 = this.boneMappings;
				num++;
				while (array4 != 0)
				{
				}
			}
			IKSolver.UpdateDelegate onStoreDefaultLocalState = this.OnStoreDefaultLocalState;
			if (onStoreDefaultLocalState != 0)
			{
				onStoreDefaultLocalState();
			}
		}

		// Token: 0x0600290F RID: 10511 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x600290F")]
		[Address(RVA = "0x1518B60", Offset = "0x1517B60", VA = "0x181518B60", Slot = "8")]
		public override void FixTransforms()
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002910 RID: 10512 RVA: 0x0005CCE4 File Offset: 0x0005AEE4
		[Token(Token = "0x6002910")]
		[Address(RVA = "0x15195E0", Offset = "0x15185E0", VA = "0x1815195E0", Slot = "10")]
		protected override void OnInitiate()
		{
			int num = 0;
			FBIKChain[] array = this.chain;
			if (num < array.Length)
			{
				array[num].Initiate(this);
				FBIKChain[] array2 = this.chain;
				num++;
			}
			IKEffector[] array3 = this.effectors;
			int length = array3.Length;
			if (num < length)
			{
				array3[num].Initiate(this);
				num++;
			}
			this.spineMapping.Initiate(this);
			IKMappingBone[] array4 = this.boneMappings;
			int length2 = array4.Length;
			if (num < length2)
			{
				array4[num].Initiate(this);
				num++;
			}
			IKMappingLimb[] array5 = this.limbMappings;
			int length3 = array5.Length;
			if (num < length3)
			{
				array5[num].Initiate(this);
				num++;
			}
		}

		// Token: 0x06002911 RID: 10513 RVA: 0x0005CDA4 File Offset: 0x0005AFA4
		[Token(Token = "0x6002911")]
		[Address(RVA = "0x15197B0", Offset = "0x15187B0", VA = "0x1815197B0", Slot = "11")]
		protected override void OnUpdate()
		{
			do
			{
				float ikpositionWeight = this.IKPositionWeight;
				int num = 0;
				IKEffector[] array2;
				if (num < (int)ikpositionWeight)
				{
					if (this.chain.Length == 0)
					{
						break;
					}
					float num2 = Mathf.Clamp(ikpositionWeight, (float)num, 1f);
					IKSolver.UpdateDelegate onPreRead = this.OnPreRead;
					this.IKPositionWeight = num2;
					if (onPreRead != 0)
					{
						onPreRead();
					}
					this.ReadPose();
					IKSolver.UpdateDelegate onPreSolve = this.OnPreSolve;
					if (onPreSolve != 0)
					{
						onPreSolve();
					}
					this.Solve();
					IKSolver.UpdateDelegate onPostSolve = this.OnPostSolve;
					if (onPostSolve != 0)
					{
						onPostSolve();
					}
					this.WritePose();
					IKEffector[] array = this.effectors;
					int num3 = 0;
					if (num3 >= array.Length)
					{
						break;
					}
					array[num3].OnPostWrite();
					array2 = this.effectors;
					num3++;
				}
				IKEffector ikeffector = array2[9];
				int num4 = 0;
				if (num4 >= ikeffector.target)
				{
					break;
				}
				Vector3 zero = Vector3.zero;
				num4++;
			}
			while (this.effectors != 0);
		}

		// Token: 0x06002912 RID: 10514 RVA: 0x0005CE9C File Offset: 0x0005B09C
		[Token(Token = "0x6002912")]
		[Address(RVA = "0x1519960", Offset = "0x1518960", VA = "0x181519960", Slot = "12")]
		protected virtual void ReadPose()
		{
			FBIKChain[] array = this.chain;
			int num = 0;
			if (num < array.Length)
			{
				FBIKChain fbikchain = array[num];
				IKConstraintBend bendConstraint = fbikchain.bendConstraint;
				if ((bendConstraint.<initiated>k__BackingField ? 1 : 0) != num)
				{
					IKSolver.Node[] nodes = fbikchain.nodes;
					float ikpositionWeight = this.IKPositionWeight;
					Transform transform = nodes[2].transform;
					float positionWeight = this.GetEffector(transform).positionWeight;
					bendConstraint.LimitBend(ikpositionWeight, positionWeight);
				}
				num++;
			}
			IKEffector[] array2 = this.effectors;
			if (num < array2.Length)
			{
				array2[num].ResetOffset(this);
				IKEffector[] array3 = this.effectors;
				num++;
				while (array3 != 0)
				{
				}
			}
			if (num < array2.Length)
			{
				array2[num].OnPreSolve(this);
				IKEffector[] array4 = this.effectors;
				num++;
				while (array4 != 0)
				{
				}
			}
			FBIKChain[] array5 = this.chain;
			if (num < array5.Length)
			{
				FBIKChain fbikchain2 = array5[num];
				bool flag = this.iterations > num;
				fbikchain2.ReadPose(this, flag);
				FBIKChain[] array6 = this.chain;
				num++;
				while (array6 != 0)
				{
				}
			}
			if (this.iterations > num)
			{
				this.spineMapping.ReadPose();
				IKMappingBone[] array7 = this.boneMappings;
				if (num < array7.Length)
				{
					array7[num].ReadPose();
					IKMappingBone[] array8 = this.boneMappings;
					num++;
					while (array8 != 0)
					{
					}
				}
			}
			IKMappingLimb[] array9 = this.limbMappings;
			if (num < array9.Length)
			{
				array9[num].ReadPose();
				IKMappingLimb[] array10 = this.limbMappings;
				num++;
				while (array10 != 0)
				{
				}
			}
		}

		// Token: 0x06002913 RID: 10515 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002913")]
		[Address(RVA = "0x1519CB0", Offset = "0x1518CB0", VA = "0x181519CB0", Slot = "13")]
		protected virtual void Solve()
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002914 RID: 10516 RVA: 0x0005D028 File Offset: 0x0005B228
		[Token(Token = "0x6002914")]
		[Address(RVA = "0x1518B10", Offset = "0x1517B10", VA = "0x181518B10", Slot = "14")]
		protected virtual void ApplyBendConstraints()
		{
			this.chain[0].SolveTrigonometric(this, true);
		}

		// Token: 0x06002915 RID: 10517 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002915")]
		[Address(RVA = "0x151A1A0", Offset = "0x15191A0", VA = "0x18151A1A0", Slot = "15")]
		protected virtual void WritePose()
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002916 RID: 10518 RVA: 0x0005D050 File Offset: 0x0005B250
		[Token(Token = "0x6002916")]
		[Address(RVA = "0x151A2D0", Offset = "0x15192D0", VA = "0x18151A2D0")]
		public IKSolverFullBody()
		{
			FBIKChain[] array = new FBIKChain[0];
			this.chain = array;
			IKEffector[] array2 = new IKEffector[0];
			this.effectors = array2;
			IKMappingSpine ikmappingSpine = new IKMappingSpine();
			this.spineMapping = ikmappingSpine;
			IKMappingBone[] array3 = new IKMappingBone[0];
			this.boneMappings = array3;
			IKMappingLimb[] array4 = new IKMappingLimb[0];
			this.limbMappings = array4;
			this.FABRIKPass = true;
			base..ctor();
		}

		// Token: 0x040032A0 RID: 12960
		[FieldOffset(Offset = "0x58")]
		[Token(Token = "0x40032A0")]
		[Range(0f, 10f)]
		public int iterations = (int)((ulong)4L);

		// Token: 0x040032A1 RID: 12961
		[FieldOffset(Offset = "0x60")]
		[Token(Token = "0x40032A1")]
		public FBIKChain[] chain;

		// Token: 0x040032A2 RID: 12962
		[FieldOffset(Offset = "0x68")]
		[Token(Token = "0x40032A2")]
		public IKEffector[] effectors;

		// Token: 0x040032A3 RID: 12963
		[FieldOffset(Offset = "0x70")]
		[Token(Token = "0x40032A3")]
		public IKMappingSpine spineMapping;

		// Token: 0x040032A4 RID: 12964
		[FieldOffset(Offset = "0x78")]
		[Token(Token = "0x40032A4")]
		public IKMappingBone[] boneMappings;

		// Token: 0x040032A5 RID: 12965
		[FieldOffset(Offset = "0x80")]
		[Token(Token = "0x40032A5")]
		public IKMappingLimb[] limbMappings;

		// Token: 0x040032A6 RID: 12966
		[FieldOffset(Offset = "0x88")]
		[Token(Token = "0x40032A6")]
		public bool FABRIKPass;

		// Token: 0x040032A7 RID: 12967
		[FieldOffset(Offset = "0x90")]
		[Token(Token = "0x40032A7")]
		public IKSolver.UpdateDelegate OnPreRead;

		// Token: 0x040032A8 RID: 12968
		[FieldOffset(Offset = "0x98")]
		[Token(Token = "0x40032A8")]
		public IKSolver.UpdateDelegate OnPreSolve;

		// Token: 0x040032A9 RID: 12969
		[FieldOffset(Offset = "0xA0")]
		[Token(Token = "0x40032A9")]
		public IKSolver.IterationDelegate OnPreIteration;

		// Token: 0x040032AA RID: 12970
		[FieldOffset(Offset = "0xA8")]
		[Token(Token = "0x40032AA")]
		public IKSolver.IterationDelegate OnPostIteration;

		// Token: 0x040032AB RID: 12971
		[FieldOffset(Offset = "0xB0")]
		[Token(Token = "0x40032AB")]
		public IKSolver.UpdateDelegate OnPreBend;

		// Token: 0x040032AC RID: 12972
		[FieldOffset(Offset = "0xB8")]
		[Token(Token = "0x40032AC")]
		public IKSolver.UpdateDelegate OnPostSolve;

		// Token: 0x040032AD RID: 12973
		[FieldOffset(Offset = "0xC0")]
		[Token(Token = "0x40032AD")]
		public IKSolver.UpdateDelegate OnStoreDefaultLocalState;

		// Token: 0x040032AE RID: 12974
		[FieldOffset(Offset = "0xC8")]
		[Token(Token = "0x40032AE")]
		public IKSolver.UpdateDelegate OnFixTransforms;
	}
}
