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

namespace Obi
{
	// Token: 0x0200049F RID: 1183
	[Token(Token = "0x200049F")]
	public class ObiMeshShapeTracker : ObiShapeTracker
	{
		// Token: 0x06002A08 RID: 10760 RVA: 0x0005BB98 File Offset: 0x00059D98
		[Token(Token = "0x6002A08")]
		[Address(RVA = "0x10123C0", Offset = "0x10111C0", VA = "0x1810123C0")]
		public ObiMeshShapeTracker(MeshCollider collider)
		{
			this.collider = collider;
			this.adaptor.is2D = false;
			IntPtr intPtr = Oni.CreateShape(Oni.ShapeType.TriangleMesh);
			this.oniShape = intPtr;
			this.UpdateMeshData();
		}

		// Token: 0x06002A09 RID: 10761 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002A09")]
		[Address(RVA = "0x1012100", Offset = "0x1010F00", VA = "0x181012100")]
		public void UpdateMeshData()
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002A0A RID: 10762 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002A0A")]
		[Address(RVA = "0x1011F50", Offset = "0x1010D50", VA = "0x181011F50", Slot = "5")]
		public override void UpdateIfNeeded()
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002A0B RID: 10763 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002A0B")]
		[Address(RVA = "0x1011DF0", Offset = "0x1010BF0", VA = "0x181011DF0", Slot = "4")]
		public override void Destroy()
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002A0C RID: 10764 RVA: 0x0005BBD4 File Offset: 0x00059DD4
		// Note: this type is marked as 'beforefieldinit'.
		[Token(Token = "0x6002A0C")]
		[Address(RVA = "0x1012340", Offset = "0x1011140", VA = "0x181012340")]
		static ObiMeshShapeTracker()
		{
			/*
An exception occurred when decompiling this method (06002A0C)

ICSharpCode.Decompiler.DecompilerException: Error decompiling System.Void Obi.ObiMeshShapeTracker::.cctor()

 ---> System.Exception: Basic block has to end with unconditional control flow. 
{; 	Block_0:; 	stsfld:class [mscorlib]System.Collections.Generic.Dictionary`2<class [UnityEngine.CoreModule]UnityEngine.Mesh, class Obi.ObiMeshShapeTracker/MeshDataHandles>(ObiMeshShapeTracker::meshDataCache, newobj:Dictionary`2[exp:class [mscorlib]System.Collections.Generic.Dictionary`2<class [UnityEngine.CoreModule]UnityEngine.Mesh, class Obi.ObiMeshShapeTracker/MeshDataHandles>](Dictionary`2::.ctor)); }; 
   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: 0x0400330E RID: 13070
		[Token(Token = "0x400330E")]
		private static Dictionary<Mesh, ObiMeshShapeTracker.MeshDataHandles> meshDataCache;

		// Token: 0x0400330F RID: 13071
		[Cpp2IlInjected.FieldOffset(Offset = "0x60")]
		[Token(Token = "0x400330F")]
		private bool meshDataHasChanged;

		// Token: 0x04003310 RID: 13072
		[Cpp2IlInjected.FieldOffset(Offset = "0x68")]
		[Token(Token = "0x4003310")]
		private ObiMeshShapeTracker.MeshDataHandles handles;

		// Token: 0x020004A0 RID: 1184
		[Token(Token = "0x20004A0")]
		private class MeshDataHandles
		{
			// Token: 0x170002D8 RID: 728
			// (get) Token: 0x06002A0D RID: 10765 RVA: 0x0005BBEC File Offset: 0x00059DEC
			[Token(Token = "0x170002D8")]
			public int RefCount
			{
				[Token(Token = "0x6002A0D")]
				[Address(RVA = "0x2B3F20", Offset = "0x2B2D20", VA = "0x1802B3F20")]
				get
				{
					return this.refCount;
				}
			}

			// Token: 0x170002D9 RID: 729
			// (get) Token: 0x06002A0E RID: 10766 RVA: 0x000020D3 File Offset: 0x000002D3
			[Token(Token = "0x170002D9")]
			public IntPtr VerticesAddress
			{
				[Token(Token = "0x6002A0E")]
				[Address(RVA = "0x69F360", Offset = "0x69E160", VA = "0x18069F360")]
				get
				{
					throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
				}
			}

			// Token: 0x170002DA RID: 730
			// (get) Token: 0x06002A0F RID: 10767 RVA: 0x000020D3 File Offset: 0x000002D3
			[Token(Token = "0x170002DA")]
			public IntPtr IndicesAddress
			{
				[Token(Token = "0x6002A0F")]
				[Address(RVA = "0x69F350", Offset = "0x69E150", VA = "0x18069F350")]
				get
				{
					throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
				}
			}

			// Token: 0x06002A10 RID: 10768 RVA: 0x0005BC00 File Offset: 0x00059E00
			[Token(Token = "0x6002A10")]
			[Address(RVA = "0x69F280", Offset = "0x69E080", VA = "0x18069F280")]
			public void FromMesh(Mesh mesh)
			{
				Oni.UnpinMemory(this.verticesHandle);
				Oni.UnpinMemory(this.indicesHandle);
				GCHandle gchandle = Oni.PinMemory(mesh.vertices);
				this.verticesHandle = gchandle;
				GCHandle gchandle2 = Oni.PinMemory(mesh.triangles);
				this.indicesHandle = gchandle2;
			}

			// Token: 0x06002A11 RID: 10769 RVA: 0x0005BC50 File Offset: 0x00059E50
			[Token(Token = "0x6002A11")]
			[Address(RVA = "0x69F2F0", Offset = "0x69E0F0", VA = "0x18069F2F0")]
			public void Ref()
			{
			}

			// Token: 0x06002A12 RID: 10770 RVA: 0x0005BC60 File Offset: 0x00059E60
			[Token(Token = "0x6002A12")]
			[Address(RVA = "0x69F300", Offset = "0x69E100", VA = "0x18069F300")]
			public void Unref()
			{
				this.refCount = (int)((ulong)0L);
				Oni.UnpinMemory(this.verticesHandle);
				Oni.UnpinMemory(this.indicesHandle);
			}

			// Token: 0x06002A13 RID: 10771 RVA: 0x0005BC90 File Offset: 0x00059E90
			[Token(Token = "0x6002A13")]
			[Address(RVA = "0x69F340", Offset = "0x69E140", VA = "0x18069F340")]
			public MeshDataHandles()
			{
			}

			// Token: 0x04003311 RID: 13073
			[Cpp2IlInjected.FieldOffset(Offset = "0x10")]
			[Token(Token = "0x4003311")]
			private int refCount = (int)((ulong)1L);

			// Token: 0x04003312 RID: 13074
			[Cpp2IlInjected.FieldOffset(Offset = "0x14")]
			[Token(Token = "0x4003312")]
			private GCHandle verticesHandle;

			// Token: 0x04003313 RID: 13075
			[Cpp2IlInjected.FieldOffset(Offset = "0x18")]
			[Token(Token = "0x4003313")]
			private GCHandle indicesHandle;
		}
	}
}
