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

namespace Obi
{
	// Token: 0x020004ED RID: 1261
	[Token(Token = "0x20004ED")]
	[ExecuteInEditMode]
	[AddComponentMenu("Physics/Obi/Obi Stitcher")]
	public class ObiStitcher : MonoBehaviour, IObiSolverClient
	{
		// Token: 0x170002F7 RID: 759
		// (get) Token: 0x06002CA0 RID: 11424 RVA: 0x000627F8 File Offset: 0x000609F8
		// (set) Token: 0x06002C9F RID: 11423 RVA: 0x000626D4 File Offset: 0x000608D4
		[Token(Token = "0x170002F7")]
		public ObiActor Actor1
		{
			[Token(Token = "0x6002CA0")]
			[Address(RVA = "0x2990A0", Offset = "0x2980A0", VA = "0x1802990A0")]
			get
			{
				return this.actor1;
			}
			[Token(Token = "0x6002C9F")]
			[Address(RVA = "0xE604C0", Offset = "0xE5F4C0", VA = "0x180E604C0")]
			set
			{
				if (this.actor1 != value)
				{
					ObiActor obiActor = this.actor1;
					int num = 0;
					if (obiActor != num)
					{
						ObiActor obiActor2 = this.actor1;
						EventHandler<ObiActor.ObiActorSolverArgs> eventHandler = new EventHandler(this.Actor_OnAddedToSolver);
						obiActor2.OnAddedToSolver -= eventHandler;
						ObiActor obiActor3 = this.actor1;
						EventHandler<ObiActor.ObiActorSolverArgs> eventHandler2 = new EventHandler(this.Actor_OnRemovedFromSolver);
						obiActor3.OnRemovedFromSolver -= eventHandler2;
						ObiActor obiActor4 = this.actor1;
						if (obiActor4.inSolver)
						{
							ObiActor.ObiActorSolverArgs obiActorSolverArgs = new ObiActor.ObiActorSolverArgs(obiActor4.solver);
							this.Actor_OnRemovedFromSolver(obiActor4, obiActorSolverArgs);
						}
					}
					this.actor1 = value;
					ObiActor obiActor5 = this.actor1;
					int num2 = 0;
					if (obiActor5 != num2)
					{
						ObiActor obiActor6 = this.actor1;
						EventHandler<ObiActor.ObiActorSolverArgs> eventHandler3 = new EventHandler(this.Actor_OnAddedToSolver);
						obiActor6.OnAddedToSolver += eventHandler3;
						ObiActor obiActor7 = this.actor1;
						EventHandler<ObiActor.ObiActorSolverArgs> eventHandler4 = new EventHandler(this.Actor_OnRemovedFromSolver);
						obiActor7.OnRemovedFromSolver += eventHandler4;
						ObiActor obiActor8 = this.actor1;
						if (obiActor8.inSolver)
						{
							ObiActor.ObiActorSolverArgs obiActorSolverArgs2 = new ObiActor.ObiActorSolverArgs(obiActor8.solver);
							this.Actor_OnAddedToSolver(obiActor8, obiActorSolverArgs2);
						}
					}
				}
			}
		}

		// Token: 0x170002F8 RID: 760
		// (get) Token: 0x06002CA2 RID: 11426 RVA: 0x00062930 File Offset: 0x00060B30
		// (set) Token: 0x06002CA1 RID: 11425 RVA: 0x0006280C File Offset: 0x00060A0C
		[Token(Token = "0x170002F8")]
		public ObiActor Actor2
		{
			[Token(Token = "0x6002CA2")]
			[Address(RVA = "0x36B6A0", Offset = "0x36A6A0", VA = "0x18036B6A0")]
			get
			{
				return this.actor2;
			}
			[Token(Token = "0x6002CA1")]
			[Address(RVA = "0xE607B0", Offset = "0xE5F7B0", VA = "0x180E607B0")]
			set
			{
				if (this.actor2 != value)
				{
					ObiActor obiActor = this.actor2;
					int num = 0;
					if (obiActor != num)
					{
						ObiActor obiActor2 = this.actor2;
						EventHandler<ObiActor.ObiActorSolverArgs> eventHandler = new EventHandler(this.Actor_OnAddedToSolver);
						obiActor2.OnAddedToSolver -= eventHandler;
						ObiActor obiActor3 = this.actor2;
						EventHandler<ObiActor.ObiActorSolverArgs> eventHandler2 = new EventHandler(this.Actor_OnRemovedFromSolver);
						obiActor3.OnRemovedFromSolver -= eventHandler2;
						ObiActor obiActor4 = this.actor2;
						if (obiActor4.inSolver)
						{
							ObiActor.ObiActorSolverArgs obiActorSolverArgs = new ObiActor.ObiActorSolverArgs(obiActor4.solver);
							this.Actor_OnRemovedFromSolver(obiActor4, obiActorSolverArgs);
						}
					}
					this.actor2 = value;
					ObiActor obiActor5 = this.actor2;
					int num2 = 0;
					if (obiActor5 != num2)
					{
						ObiActor obiActor6 = this.actor2;
						EventHandler<ObiActor.ObiActorSolverArgs> eventHandler3 = new EventHandler(this.Actor_OnAddedToSolver);
						obiActor6.OnAddedToSolver += eventHandler3;
						ObiActor obiActor7 = this.actor2;
						EventHandler<ObiActor.ObiActorSolverArgs> eventHandler4 = new EventHandler(this.Actor_OnRemovedFromSolver);
						obiActor7.OnRemovedFromSolver += eventHandler4;
						ObiActor obiActor8 = this.actor2;
						if (obiActor8.inSolver)
						{
							ObiActor.ObiActorSolverArgs obiActorSolverArgs2 = new ObiActor.ObiActorSolverArgs(obiActor8.solver);
							this.Actor_OnAddedToSolver(obiActor8, obiActorSolverArgs2);
						}
					}
				}
			}
		}

		// Token: 0x170002F9 RID: 761
		// (get) Token: 0x06002CA3 RID: 11427 RVA: 0x00062944 File Offset: 0x00060B44
		[Token(Token = "0x170002F9")]
		public int StitchCount
		{
			[Token(Token = "0x6002CA3")]
			[Address(RVA = "0xE60430", Offset = "0xE5F430", VA = "0x180E60430")]
			get
			{
				return this.stitches._size;
			}
		}

		// Token: 0x170002FA RID: 762
		// (get) Token: 0x06002CA4 RID: 11428 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x170002FA")]
		public IEnumerable<ObiStitcher.Stitch> Stitches
		{
			[Token(Token = "0x6002CA4")]
			[Address(RVA = "0xE60470", Offset = "0xE5F470", VA = "0x180E60470")]
			get
			{
				throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
			}
		}

		// Token: 0x06002CA5 RID: 11429 RVA: 0x00062964 File Offset: 0x00060B64
		[Token(Token = "0x6002CA5")]
		[Address(RVA = "0xE5FD30", Offset = "0xE5ED30", VA = "0x180E5FD30")]
		public void OnEnable()
		{
			ObiActor obiActor = this.actor1;
			int num = 0;
			if (obiActor != num)
			{
				ObiActor obiActor2 = this.actor1;
				EventHandler<ObiActor.ObiActorSolverArgs> eventHandler = new EventHandler(this.Actor_OnAddedToSolver);
				obiActor2.OnAddedToSolver += eventHandler;
				ObiActor obiActor3 = this.actor1;
				EventHandler<ObiActor.ObiActorSolverArgs> eventHandler2 = new EventHandler(this.Actor_OnRemovedFromSolver);
				obiActor3.OnRemovedFromSolver += eventHandler2;
			}
			ObiActor obiActor4 = this.actor2;
			int num2 = 0;
			if (obiActor4 != num2)
			{
				ObiActor obiActor5 = this.actor2;
				EventHandler<ObiActor.ObiActorSolverArgs> eventHandler3 = new EventHandler(this.Actor_OnAddedToSolver);
				obiActor5.OnAddedToSolver += eventHandler3;
				ObiActor obiActor6 = this.actor2;
				EventHandler<ObiActor.ObiActorSolverArgs> eventHandler4 = new EventHandler(this.Actor_OnRemovedFromSolver);
				obiActor6.OnRemovedFromSolver += eventHandler4;
			}
			ObiActor obiActor7 = this.actor1;
			int num3 = 0;
			if (obiActor7 != num3)
			{
				ObiActor obiActor8 = this.actor2;
				int num4 = 0;
				if (obiActor8 != num4)
				{
					bool flag = Oni.EnableBatch(this.batch, true);
				}
			}
		}

		// Token: 0x06002CA6 RID: 11430 RVA: 0x00062A58 File Offset: 0x00060C58
		[Token(Token = "0x6002CA6")]
		[Address(RVA = "0xE5FD20", Offset = "0xE5ED20", VA = "0x180E5FD20")]
		public void OnDisable()
		{
			IntPtr intPtr = this.batch;
			int num = 0;
			bool flag = Oni.EnableBatch(intPtr, num != 0);
		}

		// Token: 0x06002CA7 RID: 11431 RVA: 0x00062A78 File Offset: 0x00060C78
		[Token(Token = "0x6002CA7")]
		[Address(RVA = "0xE5FB50", Offset = "0xE5EB50", VA = "0x180E5FB50")]
		public int AddStitch(int particle1, int particle2)
		{
			List<ObiStitcher.Stitch> list = this.stitches;
			ObiStitcher.Stitch stitch = new ObiStitcher.Stitch(particle1, particle2);
			list.Add(stitch);
			return this.stitches._size;
		}

		// Token: 0x06002CA8 RID: 11432 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002CA8")]
		[Address(RVA = "0xE60340", Offset = "0xE5F340", VA = "0x180E60340")]
		public void RemoveStitch(int index)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002CA9 RID: 11433 RVA: 0x00062AAC File Offset: 0x00060CAC
		[Token(Token = "0x6002CA9")]
		[Address(RVA = "0xE5FCC0", Offset = "0xE5ECC0", VA = "0x180E5FCC0")]
		public void Clear()
		{
			this.stitches.Clear();
			int num = 0;
			this.PushDataToSolver((ParticleData)num);
		}

		// Token: 0x06002CAA RID: 11434 RVA: 0x00062AD4 File Offset: 0x00060CD4
		[Token(Token = "0x6002CAA")]
		[Address(RVA = "0xE5FAE0", Offset = "0xE5EAE0", VA = "0x180E5FAE0")]
		private void Actor_OnRemovedFromSolver(object sender, ObiActor.ObiActorSolverArgs e)
		{
			ObiSolver solver = this.actor1.solver;
			IntPtr intPtr = this.batch;
			Oni.RemoveBatch(solver.oniSolver, intPtr);
			this.batch = (IntPtr)((ulong)0L);
			this.inSolver = false;
		}

		// Token: 0x06002CAB RID: 11435 RVA: 0x00062B18 File Offset: 0x00060D18
		[Token(Token = "0x6002CAB")]
		[Address(RVA = "0xE5F950", Offset = "0xE5E950", VA = "0x180E5F950")]
		private void Actor_OnAddedToSolver(object sender, ObiActor.ObiActorSolverArgs e)
		{
			ObiActor obiActor = this.actor1;
			if (obiActor.inSolver)
			{
				ObiActor obiActor2 = this.actor2;
				if (obiActor2.inSolver)
				{
					ObiSolver solver = obiActor2.solver;
					if (obiActor.solver != solver)
					{
						Debug.LogError("ObiStitcher cannot handle actors in different solvers.");
						return;
					}
					int num = 0;
					IntPtr intPtr = Oni.CreateBatch(10, num != 0);
					ObiActor obiActor3 = this.actor1;
					this.batch = intPtr;
					IntPtr oniSolver = obiActor3.solver.oniSolver;
					int num2 = 0;
					IntPtr intPtr2 = Oni.AddBatch(oniSolver, intPtr, num2 != 0);
					this.inSolver = true;
					int num3 = 0;
					this.PushDataToSolver((ParticleData)num3);
					if (!base.isActiveAndEnabled)
					{
						IntPtr intPtr3 = this.batch;
						int num4 = 0;
						bool flag = Oni.EnableBatch(intPtr3, num4 != 0);
						return;
					}
					this.OnEnable();
					return;
				}
			}
		}

		// Token: 0x06002CAC RID: 11436 RVA: 0x00062BE8 File Offset: 0x00060DE8
		[Token(Token = "0x6002CAC")]
		[Address(RVA = "0xE5FC20", Offset = "0xE5EC20", VA = "0x180E5FC20", Slot = "4")]
		public bool AddToSolver(object info)
		{
			int num = 0;
			IntPtr intPtr = Oni.CreateBatch(10, num != 0);
			ObiActor obiActor = this.actor1;
			this.batch = intPtr;
			IntPtr oniSolver = obiActor.solver.oniSolver;
			int num2 = 0;
			IntPtr intPtr2 = Oni.AddBatch(oniSolver, intPtr, num2 != 0);
			this.inSolver = true;
			int num3 = 0;
			this.PushDataToSolver((ParticleData)num3);
			if (!base.isActiveAndEnabled)
			{
				IntPtr intPtr3 = this.batch;
				int num4 = 0;
				bool flag = Oni.EnableBatch(intPtr3, num4 != 0);
				return true;
			}
			this.OnEnable();
			return true;
		}

		// Token: 0x06002CAD RID: 11437 RVA: 0x00062C68 File Offset: 0x00060E68
		[Token(Token = "0x6002CAD")]
		[Address(RVA = "0xE602D0", Offset = "0xE5F2D0", VA = "0x180E602D0", Slot = "5")]
		public bool RemoveFromSolver(object info)
		{
			ObiSolver solver = this.actor1.solver;
			IntPtr intPtr = this.batch;
			Oni.RemoveBatch(solver.oniSolver, intPtr);
			this.batch = (IntPtr)((ulong)0L);
			this.inSolver = false;
			return true;
		}

		// Token: 0x06002CAE RID: 11438 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002CAE")]
		[Address(RVA = "0xE5FFA0", Offset = "0xE5EFA0", VA = "0x180E5FFA0", Slot = "6")]
		public void PushDataToSolver(ParticleData data = ParticleData.NONE)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002CAF RID: 11439 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002CAF")]
		[Address(RVA = "0x29E8B0", Offset = "0x29D8B0", VA = "0x18029E8B0", Slot = "7")]
		public void PullDataFromSolver(ParticleData data = ParticleData.NONE)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002CB0 RID: 11440 RVA: 0x00062CAC File Offset: 0x00060EAC
		[Token(Token = "0x6002CB0")]
		[Address(RVA = "0xE603B0", Offset = "0xE5F3B0", VA = "0x180E603B0")]
		public ObiStitcher()
		{
			List<ObiStitcher.Stitch> list = new List();
			this.stitches = list;
			base..ctor();
		}

		// Token: 0x040035C3 RID: 13763
		[FieldOffset(Offset = "0x18")]
		[Token(Token = "0x40035C3")]
		[SerializeField]
		[HideInInspector]
		private List<ObiStitcher.Stitch> stitches;

		// Token: 0x040035C4 RID: 13764
		[FieldOffset(Offset = "0x20")]
		[Token(Token = "0x40035C4")]
		[SerializeField]
		[HideInInspector]
		private ObiActor actor1;

		// Token: 0x040035C5 RID: 13765
		[FieldOffset(Offset = "0x28")]
		[Token(Token = "0x40035C5")]
		[HideInInspector]
		[SerializeField]
		private ObiActor actor2;

		// Token: 0x040035C6 RID: 13766
		[FieldOffset(Offset = "0x30")]
		[Token(Token = "0x40035C6")]
		private IntPtr batch;

		// Token: 0x040035C7 RID: 13767
		[FieldOffset(Offset = "0x38")]
		[Token(Token = "0x40035C7")]
		private bool inSolver;

		// Token: 0x020004EE RID: 1262
		[Token(Token = "0x20004EE")]
		[Serializable]
		public class Stitch
		{
			// Token: 0x06002CB1 RID: 11441 RVA: 0x00062CCC File Offset: 0x00060ECC
			[Token(Token = "0x6002CB1")]
			[Address(RVA = "0x69D4F0", Offset = "0x69C4F0", VA = "0x18069D4F0")]
			public Stitch(int particleIndex1, int particleIndex2)
			{
				this.particleIndex1 = particleIndex1;
				this.particleIndex2 = particleIndex2;
			}

			// Token: 0x040035C8 RID: 13768
			[FieldOffset(Offset = "0x10")]
			[Token(Token = "0x40035C8")]
			public int particleIndex1;

			// Token: 0x040035C9 RID: 13769
			[FieldOffset(Offset = "0x14")]
			[Token(Token = "0x40035C9")]
			public int particleIndex2;
		}
	}
}
