using System;
using Cpp2IlInjected;
using UnityEngine;

namespace RootMotion.FinalIK
{
	// Token: 0x0200042C RID: 1068
	[Token(Token = "0x200042C")]
	[Serializable]
	public class IKSolverFullBody : IKSolver
	{
		// Token: 0x0600263D RID: 9789 RVA: 0x000557B0 File Offset: 0x000539B0
		[Token(Token = "0x600263D")]
		[Address(RVA = "0x1593D30", Offset = "0x1592B30", VA = "0x181593D30")]
		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: 0x0600263E RID: 9790 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x600263E")]
		[Address(RVA = "0x1593CE0", Offset = "0x1592AE0", VA = "0x181593CE0")]
		public FBIKChain GetChain(Transform transform)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x0600263F RID: 9791 RVA: 0x00055800 File Offset: 0x00053A00
		[Token(Token = "0x600263F")]
		[Address(RVA = "0x1593BB0", Offset = "0x15929B0", VA = "0x181593BB0")]
		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: 0x06002640 RID: 9792 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002640")]
		[Address(RVA = "0x1593E50", Offset = "0x1592C50", VA = "0x181593E50")]
		public IKSolver.Node GetNode(int chainIndex, int nodeIndex)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002641 RID: 9793 RVA: 0x00055868 File Offset: 0x00053A68
		[Token(Token = "0x6002641")]
		[Address(RVA = "0x1593B20", Offset = "0x1592920", VA = "0x181593B20")]
		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: 0x06002642 RID: 9794 RVA: 0x000558A8 File Offset: 0x00053AA8
		[Token(Token = "0x6002642")]
		[Address(RVA = "0x1594050", Offset = "0x1592E50", VA = "0x181594050", 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: 0x06002643 RID: 9795 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002643")]
		[Address(RVA = "0x1593EC0", Offset = "0x1592CC0", VA = "0x181593EC0", Slot = "7")]
		public override IKSolver.Point GetPoint(Transform transform)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002644 RID: 9796 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002644")]
		[Address(RVA = "0x15941E0", Offset = "0x1592FE0", VA = "0x1815941E0", Slot = "4")]
		public override bool IsValid(ref string message)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002645 RID: 9797 RVA: 0x00055960 File Offset: 0x00053B60
		[Token(Token = "0x6002645")]
		[Address(RVA = "0x1594F30", Offset = "0x1593D30", VA = "0x181594F30", 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: 0x06002646 RID: 9798 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002646")]
		[Address(RVA = "0x1593A00", Offset = "0x1592800", VA = "0x181593A00", Slot = "8")]
		public override void FixTransforms()
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002647 RID: 9799 RVA: 0x000559E8 File Offset: 0x00053BE8
		[Token(Token = "0x6002647")]
		[Address(RVA = "0x1594480", Offset = "0x1593280", VA = "0x181594480", 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: 0x06002648 RID: 9800 RVA: 0x00055AA8 File Offset: 0x00053CA8
		[Token(Token = "0x6002648")]
		[Address(RVA = "0x1594650", Offset = "0x1593450", VA = "0x181594650", 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: 0x06002649 RID: 9801 RVA: 0x00055BA0 File Offset: 0x00053DA0
		[Token(Token = "0x6002649")]
		[Address(RVA = "0x1594800", Offset = "0x1593600", VA = "0x181594800", 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: 0x0600264A RID: 9802 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x600264A")]
		[Address(RVA = "0x1594B50", Offset = "0x1593950", VA = "0x181594B50", Slot = "13")]
		protected virtual void Solve()
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x0600264B RID: 9803 RVA: 0x00055D2C File Offset: 0x00053F2C
		[Token(Token = "0x600264B")]
		[Address(RVA = "0x15939B0", Offset = "0x15927B0", VA = "0x1815939B0", Slot = "14")]
		protected virtual void ApplyBendConstraints()
		{
			this.chain[0].SolveTrigonometric(this, true);
		}

		// Token: 0x0600264C RID: 9804 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x600264C")]
		[Address(RVA = "0x1595040", Offset = "0x1593E40", VA = "0x181595040", Slot = "15")]
		protected virtual void WritePose()
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x0600264D RID: 9805 RVA: 0x00055D54 File Offset: 0x00053F54
		[Token(Token = "0x600264D")]
		[Address(RVA = "0x1595170", Offset = "0x1593F70", VA = "0x181595170")]
		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: 0x04002FB6 RID: 12214
		[FieldOffset(Offset = "0x58")]
		[Token(Token = "0x4002FB6")]
		[Range(0f, 10f)]
		public int iterations = (int)((ulong)4L);

		// Token: 0x04002FB7 RID: 12215
		[FieldOffset(Offset = "0x60")]
		[Token(Token = "0x4002FB7")]
		public FBIKChain[] chain;

		// Token: 0x04002FB8 RID: 12216
		[FieldOffset(Offset = "0x68")]
		[Token(Token = "0x4002FB8")]
		public IKEffector[] effectors;

		// Token: 0x04002FB9 RID: 12217
		[FieldOffset(Offset = "0x70")]
		[Token(Token = "0x4002FB9")]
		public IKMappingSpine spineMapping;

		// Token: 0x04002FBA RID: 12218
		[FieldOffset(Offset = "0x78")]
		[Token(Token = "0x4002FBA")]
		public IKMappingBone[] boneMappings;

		// Token: 0x04002FBB RID: 12219
		[FieldOffset(Offset = "0x80")]
		[Token(Token = "0x4002FBB")]
		public IKMappingLimb[] limbMappings;

		// Token: 0x04002FBC RID: 12220
		[FieldOffset(Offset = "0x88")]
		[Token(Token = "0x4002FBC")]
		public bool FABRIKPass;

		// Token: 0x04002FBD RID: 12221
		[FieldOffset(Offset = "0x90")]
		[Token(Token = "0x4002FBD")]
		public IKSolver.UpdateDelegate OnPreRead;

		// Token: 0x04002FBE RID: 12222
		[FieldOffset(Offset = "0x98")]
		[Token(Token = "0x4002FBE")]
		public IKSolver.UpdateDelegate OnPreSolve;

		// Token: 0x04002FBF RID: 12223
		[FieldOffset(Offset = "0xA0")]
		[Token(Token = "0x4002FBF")]
		public IKSolver.IterationDelegate OnPreIteration;

		// Token: 0x04002FC0 RID: 12224
		[FieldOffset(Offset = "0xA8")]
		[Token(Token = "0x4002FC0")]
		public IKSolver.IterationDelegate OnPostIteration;

		// Token: 0x04002FC1 RID: 12225
		[FieldOffset(Offset = "0xB0")]
		[Token(Token = "0x4002FC1")]
		public IKSolver.UpdateDelegate OnPreBend;

		// Token: 0x04002FC2 RID: 12226
		[FieldOffset(Offset = "0xB8")]
		[Token(Token = "0x4002FC2")]
		public IKSolver.UpdateDelegate OnPostSolve;

		// Token: 0x04002FC3 RID: 12227
		[FieldOffset(Offset = "0xC0")]
		[Token(Token = "0x4002FC3")]
		public IKSolver.UpdateDelegate OnStoreDefaultLocalState;

		// Token: 0x04002FC4 RID: 12228
		[FieldOffset(Offset = "0xC8")]
		[Token(Token = "0x4002FC4")]
		public IKSolver.UpdateDelegate OnFixTransforms;
	}
}
