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

namespace RootMotion.FinalIK
{
	// Token: 0x0200041F RID: 1055
	[Token(Token = "0x200041F")]
	[Serializable]
	public class IKMappingLimb : IKMapping
	{
		// Token: 0x060025C0 RID: 9664 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x60025C0")]
		[Address(RVA = "0x1183420", Offset = "0x1182220", VA = "0x181183420", 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: 0x060025C1 RID: 9665 RVA: 0x00054E88 File Offset: 0x00053088
		[Token(Token = "0x60025C1")]
		[Address(RVA = "0x11830A0", Offset = "0x1181EA0", VA = "0x1811830A0")]
		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: 0x060025C2 RID: 9666 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x60025C2")]
		[Address(RVA = "0x1183760", Offset = "0x1182560", VA = "0x181183760")]
		public void SetLimbOrientation(Vector3 upper, Vector3 lower)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x060025C3 RID: 9667 RVA: 0x00054EE8 File Offset: 0x000530E8
		[Token(Token = "0x60025C3")]
		[Address(RVA = "0x1183DA0", Offset = "0x1182BA0", VA = "0x181183DA0")]
		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: 0x060025C4 RID: 9668 RVA: 0x00054F3C File Offset: 0x0005313C
		[Token(Token = "0x60025C4")]
		[Address(RVA = "0x1183E90", Offset = "0x1182C90", VA = "0x181183E90")]
		public IKMappingLimb(Transform bone1, Transform bone2, Transform bone3, [Optional] Transform parentBone)
		{
			/*
An exception occurred when decompiling this method (060025C4)

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: 0x060025C5 RID: 9669 RVA: 0x00054FAC File Offset: 0x000531AC
		[Token(Token = "0x60025C5")]
		[Address(RVA = "0x11836F0", Offset = "0x11824F0", VA = "0x1811836F0")]
		public void SetBones(Transform bone1, Transform bone2, Transform bone3, [Optional] Transform parentBone)
		{
			/*
An exception occurred when decompiling this method (060025C5)

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: 0x060025C6 RID: 9670 RVA: 0x00054FD4 File Offset: 0x000531D4
		[Token(Token = "0x60025C6")]
		[Address(RVA = "0x1183B60", Offset = "0x1182960", VA = "0x181183B60")]
		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: 0x060025C7 RID: 9671 RVA: 0x00055028 File Offset: 0x00053228
		[Token(Token = "0x60025C7")]
		[Address(RVA = "0x1182FE0", Offset = "0x1181DE0", VA = "0x181182FE0")]
		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: 0x060025C8 RID: 9672 RVA: 0x00055094 File Offset: 0x00053294
		[Token(Token = "0x60025C8")]
		[Address(RVA = "0x1183170", Offset = "0x1181F70", VA = "0x181183170", 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: 0x060025C9 RID: 9673 RVA: 0x00055234 File Offset: 0x00053434
		[Token(Token = "0x60025C9")]
		[Address(RVA = "0x1183680", Offset = "0x1182480", VA = "0x181183680")]
		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: 0x060025CA RID: 9674 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x60025CA")]
		[Address(RVA = "0x1183C10", Offset = "0x1182A10", VA = "0x181183C10")]
		public void WritePose(IKSolverFullBody solver, bool fullBody)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x04002F6A RID: 12138
		[Cpp2IlInjected.FieldOffset(Offset = "0x10")]
		[Token(Token = "0x4002F6A")]
		public Transform parentBone;

		// Token: 0x04002F6B RID: 12139
		[Cpp2IlInjected.FieldOffset(Offset = "0x18")]
		[Token(Token = "0x4002F6B")]
		public Transform bone1;

		// Token: 0x04002F6C RID: 12140
		[Cpp2IlInjected.FieldOffset(Offset = "0x20")]
		[Token(Token = "0x4002F6C")]
		public Transform bone2;

		// Token: 0x04002F6D RID: 12141
		[Cpp2IlInjected.FieldOffset(Offset = "0x28")]
		[Token(Token = "0x4002F6D")]
		public Transform bone3;

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

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

		// Token: 0x04002F70 RID: 12144
		[Cpp2IlInjected.FieldOffset(Offset = "0x38")]
		[Token(Token = "0x4002F70")]
		private IKMapping.BoneMap boneMapParent;

		// Token: 0x04002F71 RID: 12145
		[Cpp2IlInjected.FieldOffset(Offset = "0x40")]
		[Token(Token = "0x4002F71")]
		private IKMapping.BoneMap boneMap1;

		// Token: 0x04002F72 RID: 12146
		[Cpp2IlInjected.FieldOffset(Offset = "0x48")]
		[Token(Token = "0x4002F72")]
		private IKMapping.BoneMap boneMap2;

		// Token: 0x04002F73 RID: 12147
		[Cpp2IlInjected.FieldOffset(Offset = "0x50")]
		[Token(Token = "0x4002F73")]
		private IKMapping.BoneMap boneMap3;

		// Token: 0x02000420 RID: 1056
		[Token(Token = "0x2000420")]
		[Serializable]
		public enum BoneMapType
		{
			// Token: 0x04002F75 RID: 12149
			[Token(Token = "0x4002F75")]
			Parent,
			// Token: 0x04002F76 RID: 12150
			[Token(Token = "0x4002F76")]
			Bone1,
			// Token: 0x04002F77 RID: 12151
			[Token(Token = "0x4002F77")]
			Bone2,
			// Token: 0x04002F78 RID: 12152
			[Token(Token = "0x4002F78")]
			Bone3
		}
	}
}
