using System;
using System.Runtime.InteropServices;
using Cpp2IlInjected;
using UnityEngine;

namespace RootMotion.FinalIK
{
	// Token: 0x02000477 RID: 1143
	[Token(Token = "0x2000477")]
	[Serializable]
	public class IKMappingLimb : IKMapping
	{
		// Token: 0x06002889 RID: 10377 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002889")]
		[Address(RVA = "0x1709AF0", Offset = "0x1708AF0", VA = "0x181709AF0", Slot = "4")]
		public override bool IsValid(IKSolver solver, ref string message)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x0600288A RID: 10378 RVA: 0x0005C1E4 File Offset: 0x0005A3E4
		[Token(Token = "0x600288A")]
		[Address(RVA = "0x1709770", Offset = "0x1708770", VA = "0x181709770")]
		public IKMapping.BoneMap GetBoneMap(IKMappingLimb.BoneMapType boneMap)
		{
			if (boneMap == IKMappingLimb.BoneMapType.Parent)
			{
				Transform transform = this.parentBone;
				int num = 0;
				if (transform == num)
				{
					Transform transform2 = this.bone1;
					int num2 = 0;
					Warning.Log("This limb does not have a parent (shoulder) bone", transform2, num2 != 0);
				}
				return this.boneMapParent;
			}
			if (boneMap == IKMappingLimb.BoneMapType.Parent)
			{
				return this.boneMap1;
			}
			if (boneMap != IKMappingLimb.BoneMapType.Bone1)
			{
				return this.boneMap3;
			}
			return this.boneMap2;
		}

		// Token: 0x0600288B RID: 10379 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x600288B")]
		[Address(RVA = "0x1709E30", Offset = "0x1708E30", VA = "0x181709E30")]
		public void SetLimbOrientation(Vector3 upper, Vector3 lower)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x0600288C RID: 10380 RVA: 0x0005C244 File Offset: 0x0005A444
		[Token(Token = "0x600288C")]
		[Address(RVA = "0x170A470", Offset = "0x1709470", VA = "0x18170A470")]
		public IKMappingLimb()
		{
			this.weight = 1f;
			IKMapping.BoneMap boneMap = new IKMapping.BoneMap();
			this.boneMapParent = boneMap;
			IKMapping.BoneMap boneMap2 = new IKMapping.BoneMap();
			this.boneMap1 = boneMap2;
			IKMapping.BoneMap boneMap3 = new IKMapping.BoneMap();
			this.boneMap2 = boneMap3;
			IKMapping.BoneMap boneMap4 = new IKMapping.BoneMap();
			this.boneMap3 = boneMap4;
			base..ctor();
		}

		// Token: 0x0600288D RID: 10381 RVA: 0x0005C298 File Offset: 0x0005A498
		[Token(Token = "0x600288D")]
		[Address(RVA = "0x170A560", Offset = "0x1709560", VA = "0x18170A560")]
		public IKMappingLimb(Transform bone1, Transform bone2, Transform bone3, [Optional] Transform parentBone)
		{
			/*
An exception occurred when decompiling this method (0600288D)

ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void RootMotion.FinalIK.IKMappingLimb::.ctor(UnityEngine.Transform,UnityEngine.Transform,UnityEngine.Transform,UnityEngine.Transform)

 ---> System.Exception: Basic block has to end with unconditional control flow. 
{; 	Block_0:; 	stfld:float32(IKMappingLimb::weight, ldloc:IKMappingLimb(this), ldc.r4:float32(1)); 	stloc:BoneMap(var_0_10, newobj:BoneMap(BoneMap::.ctor)); 	stfld:BoneMap(IKMappingLimb::boneMapParent, ldloc:IKMappingLimb(this), ldloc:BoneMap(var_0_10)); 	stloc:BoneMap(var_1_1D, newobj:BoneMap(BoneMap::.ctor)); 	stfld:BoneMap(IKMappingLimb::boneMap1, ldloc:IKMappingLimb(this), ldloc:BoneMap(var_1_1D)); 	stloc:BoneMap(var_2_2A, newobj:BoneMap(BoneMap::.ctor)); 	stfld:BoneMap(IKMappingLimb::boneMap2, ldloc:IKMappingLimb(this), ldloc:BoneMap(var_2_2A)); 	stloc:BoneMap(var_3_37, newobj:BoneMap(BoneMap::.ctor)); 	stfld:BoneMap(IKMappingLimb::boneMap3, ldloc:IKMappingLimb(this), ldloc:BoneMap(var_3_37)); 	call:void(object::.ctor, ldloc:IKMappingLimb[exp:object](this)); 	stfld:Transform(IKMappingLimb::bone1, ldloc:IKMappingLimb(this), ldloc:Transform(bone1)); 	stfld:Transform(IKMappingLimb::bone2, ldloc:IKMappingLimb(this), ldloc:Transform(bone2)); 	stfld:Transform(IKMappingLimb::bone3, ldloc:IKMappingLimb(this), ldloc:Transform(bone3)); 	stfld:Transform(IKMappingLimb::parentBone, ldloc:IKMappingLimb(this), ldc.i4:int32[exp:Transform](0)); }; 
   at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1810
   at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.Optimize(DecompilerContext context, ILBlock method, AutoPropertyProvider autoPropertyProvider, StateMachineKind& stateMachineKind, MethodDef& inlinedMethod, AsyncMethodDebugInfo& asyncInfo, ILAstOptimizationStep abortBeforeStep) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 344
   at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable`1 parameters, MethodDebugInfoBuilder& builder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 123
   at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 88
   --- End of inner exception stack trace ---
   at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 92
   at ICSharpCode.Decompiler.Ast.AstBuilder.AddMethodBody(EntityDeclaration methodNode, EntityDeclaration& updatedNode, MethodDef method, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, MethodKind methodKind) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstBuilder.cs:line 1618
*/;
		}

		// Token: 0x0600288E RID: 10382 RVA: 0x0005C308 File Offset: 0x0005A508
		[Token(Token = "0x600288E")]
		[Address(RVA = "0x1709DC0", Offset = "0x1708DC0", VA = "0x181709DC0")]
		public void SetBones(Transform bone1, Transform bone2, Transform bone3, [Optional] Transform parentBone)
		{
			/*
An exception occurred when decompiling this method (0600288E)

ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void RootMotion.FinalIK.IKMappingLimb::SetBones(UnityEngine.Transform,UnityEngine.Transform,UnityEngine.Transform,UnityEngine.Transform)

 ---> System.Exception: Basic block has to end with unconditional control flow. 
{; 	Block_0:; 	stfld:Transform(IKMappingLimb::bone1, ldloc:IKMappingLimb(this), ldloc:Transform(bone1)); 	stfld:Transform(IKMappingLimb::bone2, ldloc:IKMappingLimb(this), ldloc:Transform(bone2)); 	stfld:Transform(IKMappingLimb::bone3, ldloc:IKMappingLimb(this), ldloc:Transform(bone3)); 	stfld:Transform(IKMappingLimb::parentBone, ldloc:IKMappingLimb(this), ldc.i4:int32[exp:Transform](0)); }; 
   at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.FlattenBasicBlocks(ILNode node) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 1810
   at ICSharpCode.Decompiler.ILAst.ILAstOptimizer.Optimize(DecompilerContext context, ILBlock method, AutoPropertyProvider autoPropertyProvider, StateMachineKind& stateMachineKind, MethodDef& inlinedMethod, AsyncMethodDebugInfo& asyncInfo, ILAstOptimizationStep abortBeforeStep) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\ILAst\ILAstOptimizer.cs:line 344
   at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(IEnumerable`1 parameters, MethodDebugInfoBuilder& builder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 123
   at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 88
   --- End of inner exception stack trace ---
   at ICSharpCode.Decompiler.Ast.AstMethodBodyBuilder.CreateMethodBody(MethodDef methodDef, DecompilerContext context, AutoPropertyProvider autoPropertyProvider, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, StringBuilder sb, MethodDebugInfoBuilder& stmtsBuilder) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstMethodBodyBuilder.cs:line 92
   at ICSharpCode.Decompiler.Ast.AstBuilder.AddMethodBody(EntityDeclaration methodNode, EntityDeclaration& updatedNode, MethodDef method, IEnumerable`1 parameters, Boolean valueParameterIsKeyword, MethodKind methodKind) in D:\a\dnSpy\dnSpy\Extensions\ILSpy.Decompiler\ICSharpCode.Decompiler\ICSharpCode.Decompiler\Ast\AstBuilder.cs:line 1618
*/;
		}

		// Token: 0x0600288F RID: 10383 RVA: 0x0005C330 File Offset: 0x0005A530
		[Token(Token = "0x600288F")]
		[Address(RVA = "0x170A230", Offset = "0x1709230", VA = "0x18170A230")]
		public void StoreDefaultLocalState()
		{
			Transform transform = this.parentBone;
			int num = 0;
			if (transform != num)
			{
				this.boneMapParent.StoreDefaultLocalState();
			}
			this.boneMap1.StoreDefaultLocalState();
			this.boneMap2.StoreDefaultLocalState();
			this.boneMap3.StoreDefaultLocalState();
		}

		// Token: 0x06002890 RID: 10384 RVA: 0x0005C384 File Offset: 0x0005A584
		[Token(Token = "0x6002890")]
		[Address(RVA = "0x17096B0", Offset = "0x17086B0", VA = "0x1817096B0")]
		public void FixTransforms()
		{
			Transform transform = this.parentBone;
			int num = 0;
			if (transform != num)
			{
				IKMapping.BoneMap boneMap = this.boneMapParent;
				int num2 = 0;
				boneMap.FixTransform(num2 != 0);
			}
			this.boneMap1.FixTransform(true);
			IKMapping.BoneMap boneMap2 = this.boneMap2;
			int num3 = 0;
			boneMap2.FixTransform(num3 != 0);
			IKMapping.BoneMap boneMap3 = this.boneMap3;
			int num4 = 0;
			boneMap3.FixTransform(num4 != 0);
		}

		// Token: 0x06002891 RID: 10385 RVA: 0x0005C3F0 File Offset: 0x0005A5F0
		[Token(Token = "0x6002891")]
		[Address(RVA = "0x1709840", Offset = "0x1708840", VA = "0x181709840", Slot = "5")]
		public override void Initiate(IKSolverFullBody solver)
		{
			if (this.boneMapParent == (ulong)0L)
			{
				IKMapping.BoneMap boneMap = new IKMapping.BoneMap();
				this.boneMapParent = boneMap;
			}
			if (this.boneMap1 == (ulong)0L)
			{
				IKMapping.BoneMap boneMap2 = new IKMapping.BoneMap();
				this.boneMap1 = boneMap2;
			}
			if (this.boneMap2 == (ulong)0L)
			{
				IKMapping.BoneMap boneMap3 = new IKMapping.BoneMap();
				this.boneMap2 = boneMap3;
			}
			if (this.boneMap3 == (ulong)0L)
			{
				IKMapping.BoneMap boneMap4 = new IKMapping.BoneMap();
				this.boneMap3 = boneMap4;
			}
			Transform transform = this.parentBone;
			int num = 0;
			if (transform != num)
			{
				IKMapping.BoneMap boneMap5 = this.boneMapParent;
				Transform transform2 = this.parentBone;
				boneMap5.Initiate(transform2, solver);
			}
			IKMapping.BoneMap boneMap6 = this.boneMap1;
			Transform transform3 = this.bone1;
			boneMap6.Initiate(transform3, solver);
			IKMapping.BoneMap boneMap7 = this.boneMap2;
			Transform transform4 = this.bone2;
			boneMap7.Initiate(transform4, solver);
			IKMapping.BoneMap boneMap8 = this.boneMap3;
			Transform transform5 = this.bone3;
			boneMap8.Initiate(transform5, solver);
			IKMapping.BoneMap boneMap9 = this.boneMap1;
			IKMapping.BoneMap boneMap10 = this.boneMap2;
			Transform transform6 = this.boneMap3.transform;
			Transform transform7 = boneMap10.transform;
			Transform transform8 = boneMap9.transform;
			boneMap9.SetPlane(solver, transform8, transform7, transform6);
			IKMapping.BoneMap boneMap11 = this.boneMap2;
			IKMapping.BoneMap boneMap12 = this.boneMap3;
			Transform transform9 = this.boneMap1.transform;
			Transform transform10 = boneMap12.transform;
			Transform transform11 = boneMap11.transform;
			boneMap11.SetPlane(solver, transform11, transform10, transform9);
			Transform transform12 = this.parentBone;
			int num2 = 0;
			if (transform12 != num2)
			{
				IKMapping.BoneMap boneMap13 = this.boneMapParent;
				IKMapping.BoneMap boneMap14 = this.boneMap1;
				boneMap13.SetLocalSwingAxis(boneMap14);
			}
		}

		// Token: 0x06002892 RID: 10386 RVA: 0x0005C590 File Offset: 0x0005A790
		[Token(Token = "0x6002892")]
		[Address(RVA = "0x1709D50", Offset = "0x1708D50", VA = "0x181709D50")]
		public void ReadPose()
		{
			this.boneMap1.UpdatePlane(true, true);
			IKMapping.BoneMap boneMap = this.boneMap2;
			int num = 0;
			boneMap.UpdatePlane(true, num != 0);
			float num2 = this.weight;
			int num3 = 0;
			float num4 = Mathf.Clamp(num2, (float)num3, 1f);
			IKMapping.BoneMap boneMap2 = this.boneMap3;
			this.weight = num4;
			boneMap2.MaintainRotation();
		}

		// Token: 0x06002893 RID: 10387 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002893")]
		[Address(RVA = "0x170A2E0", Offset = "0x17092E0", VA = "0x18170A2E0")]
		public void WritePose(IKSolverFullBody solver, bool fullBody)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x04003254 RID: 12884
		[Cpp2IlInjected.FieldOffset(Offset = "0x10")]
		[Token(Token = "0x4003254")]
		public Transform parentBone;

		// Token: 0x04003255 RID: 12885
		[Cpp2IlInjected.FieldOffset(Offset = "0x18")]
		[Token(Token = "0x4003255")]
		public Transform bone1;

		// Token: 0x04003256 RID: 12886
		[Cpp2IlInjected.FieldOffset(Offset = "0x20")]
		[Token(Token = "0x4003256")]
		public Transform bone2;

		// Token: 0x04003257 RID: 12887
		[Cpp2IlInjected.FieldOffset(Offset = "0x28")]
		[Token(Token = "0x4003257")]
		public Transform bone3;

		// Token: 0x04003258 RID: 12888
		[Cpp2IlInjected.FieldOffset(Offset = "0x30")]
		[Token(Token = "0x4003258")]
		[Range(0f, 1f)]
		public float maintainRotationWeight;

		// Token: 0x04003259 RID: 12889
		[Cpp2IlInjected.FieldOffset(Offset = "0x34")]
		[Token(Token = "0x4003259")]
		[Range(0f, 1f)]
		public float weight;

		// Token: 0x0400325A RID: 12890
		[Cpp2IlInjected.FieldOffset(Offset = "0x38")]
		[Token(Token = "0x400325A")]
		private IKMapping.BoneMap boneMapParent;

		// Token: 0x0400325B RID: 12891
		[Cpp2IlInjected.FieldOffset(Offset = "0x40")]
		[Token(Token = "0x400325B")]
		private IKMapping.BoneMap boneMap1;

		// Token: 0x0400325C RID: 12892
		[Cpp2IlInjected.FieldOffset(Offset = "0x48")]
		[Token(Token = "0x400325C")]
		private IKMapping.BoneMap boneMap2;

		// Token: 0x0400325D RID: 12893
		[Cpp2IlInjected.FieldOffset(Offset = "0x50")]
		[Token(Token = "0x400325D")]
		private IKMapping.BoneMap boneMap3;

		// Token: 0x02000478 RID: 1144
		[Token(Token = "0x2000478")]
		[Serializable]
		public enum BoneMapType
		{
			// Token: 0x0400325F RID: 12895
			[Token(Token = "0x400325F")]
			Parent,
			// Token: 0x04003260 RID: 12896
			[Token(Token = "0x4003260")]
			Bone1,
			// Token: 0x04003261 RID: 12897
			[Token(Token = "0x4003261")]
			Bone2,
			// Token: 0x04003262 RID: 12898
			[Token(Token = "0x4003262")]
			Bone3
		}
	}
}
