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

namespace Obi
{
	// Token: 0x020004F7 RID: 1271
	[Token(Token = "0x20004F7")]
	public class ObiMeshShapeTracker : ObiShapeTracker
	{
		// Token: 0x06002CD1 RID: 11473 RVA: 0x00062F5C File Offset: 0x0006115C
		[Token(Token = "0x6002CD1")]
		[Address(RVA = "0x10A56F0", Offset = "0x10A46F0", VA = "0x1810A56F0")]
		public ObiMeshShapeTracker(MeshCollider collider)
		{
			this.collider = collider;
			this.adaptor.is2D = false;
			IntPtr intPtr = Oni.CreateShape(Oni.ShapeType.TriangleMesh);
			this.oniShape = intPtr;
			this.UpdateMeshData();
		}

		// Token: 0x06002CD2 RID: 11474 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002CD2")]
		[Address(RVA = "0x10A5430", Offset = "0x10A4430", VA = "0x1810A5430")]
		public void UpdateMeshData()
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002CD3 RID: 11475 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002CD3")]
		[Address(RVA = "0x10A5280", Offset = "0x10A4280", VA = "0x1810A5280", Slot = "5")]
		public override void UpdateIfNeeded()
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002CD4 RID: 11476 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002CD4")]
		[Address(RVA = "0x10A5120", Offset = "0x10A4120", VA = "0x1810A5120", Slot = "4")]
		public override void Destroy()
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002CD5 RID: 11477 RVA: 0x00062F98 File Offset: 0x00061198
		// Note: this type is marked as 'beforefieldinit'.
		[Token(Token = "0x6002CD5")]
		[Address(RVA = "0x10A5670", Offset = "0x10A4670", VA = "0x1810A5670")]
		static ObiMeshShapeTracker()
		{
			/*
An exception occurred when decompiling this method (06002CD5)

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: 0x040035F8 RID: 13816
		[Token(Token = "0x40035F8")]
		private static Dictionary<Mesh, ObiMeshShapeTracker.MeshDataHandles> meshDataCache;

		// Token: 0x040035F9 RID: 13817
		[Cpp2IlInjected.FieldOffset(Offset = "0x60")]
		[Token(Token = "0x40035F9")]
		private bool meshDataHasChanged;

		// Token: 0x040035FA RID: 13818
		[Cpp2IlInjected.FieldOffset(Offset = "0x68")]
		[Token(Token = "0x40035FA")]
		private ObiMeshShapeTracker.MeshDataHandles handles;

		// Token: 0x020004F8 RID: 1272
		[Token(Token = "0x20004F8")]
		private class MeshDataHandles
		{
			// Token: 0x170002FD RID: 765
			// (get) Token: 0x06002CD6 RID: 11478 RVA: 0x00062FB0 File Offset: 0x000611B0
			[Token(Token = "0x170002FD")]
			public int RefCount
			{
				[Token(Token = "0x6002CD6")]
				[Address(RVA = "0x366270", Offset = "0x365270", VA = "0x180366270")]
				get
				{
					return this.refCount;
				}
			}

			// Token: 0x170002FE RID: 766
			// (get) Token: 0x06002CD7 RID: 11479 RVA: 0x000020D3 File Offset: 0x000002D3
			[Token(Token = "0x170002FE")]
			public IntPtr VerticesAddress
			{
				[Token(Token = "0x6002CD7")]
				[Address(RVA = "0x699F90", Offset = "0x698F90", VA = "0x180699F90")]
				get
				{
					throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
				}
			}

			// Token: 0x170002FF RID: 767
			// (get) Token: 0x06002CD8 RID: 11480 RVA: 0x000020D3 File Offset: 0x000002D3
			[Token(Token = "0x170002FF")]
			public IntPtr IndicesAddress
			{
				[Token(Token = "0x6002CD8")]
				[Address(RVA = "0x699F80", Offset = "0x698F80", VA = "0x180699F80")]
				get
				{
					throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
				}
			}

			// Token: 0x06002CD9 RID: 11481 RVA: 0x00062FC4 File Offset: 0x000611C4
			[Token(Token = "0x6002CD9")]
			[Address(RVA = "0x699EB0", Offset = "0x698EB0", VA = "0x180699EB0")]
			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: 0x06002CDA RID: 11482 RVA: 0x00063014 File Offset: 0x00061214
			[Token(Token = "0x6002CDA")]
			[Address(RVA = "0x699F20", Offset = "0x698F20", VA = "0x180699F20")]
			public void Ref()
			{
			}

			// Token: 0x06002CDB RID: 11483 RVA: 0x00063024 File Offset: 0x00061224
			[Token(Token = "0x6002CDB")]
			[Address(RVA = "0x699F30", Offset = "0x698F30", VA = "0x180699F30")]
			public void Unref()
			{
				this.refCount = (int)((ulong)0L);
				Oni.UnpinMemory(this.verticesHandle);
				Oni.UnpinMemory(this.indicesHandle);
			}

			// Token: 0x06002CDC RID: 11484 RVA: 0x00063054 File Offset: 0x00061254
			[Token(Token = "0x6002CDC")]
			[Address(RVA = "0x699F70", Offset = "0x698F70", VA = "0x180699F70")]
			public MeshDataHandles()
			{
			}

			// Token: 0x040035FB RID: 13819
			[Cpp2IlInjected.FieldOffset(Offset = "0x10")]
			[Token(Token = "0x40035FB")]
			private int refCount = (int)((ulong)1L);

			// Token: 0x040035FC RID: 13820
			[Cpp2IlInjected.FieldOffset(Offset = "0x14")]
			[Token(Token = "0x40035FC")]
			private GCHandle verticesHandle;

			// Token: 0x040035FD RID: 13821
			[Cpp2IlInjected.FieldOffset(Offset = "0x18")]
			[Token(Token = "0x40035FD")]
			private GCHandle indicesHandle;
		}
	}
}
