using System;
using Cpp2IlInjected;
using UnityEngine;

namespace Obi
{
	// Token: 0x0200053E RID: 1342
	[Token(Token = "0x200053E")]
	[RequireComponent(typeof(ObiClothPicker))]
	public class ObiClothDragger : MonoBehaviour
	{
		// Token: 0x06002EB3 RID: 11955 RVA: 0x00065CC8 File Offset: 0x00063EC8
		[Token(Token = "0x6002EB3")]
		[Address(RVA = "0x1096A20", Offset = "0x1095A20", VA = "0x181096A20")]
		private void OnEnable()
		{
			ObiClothPicker component = base.GetComponent<ObiClothPicker>();
			this.picker = component;
			ObiClothPicker obiClothPicker = this.picker;
			EventHandler<ObiClothPicker.ParticlePickEventArgs> eventHandler = new EventHandler(this.Picker_OnParticlePicked);
			EventHandler<ObiClothPicker.ParticlePickEventArgs> onParticlePicked = obiClothPicker.OnParticlePicked;
			Delegate @delegate = Delegate.Combine(onParticlePicked, eventHandler);
			if (@delegate == 0 || @delegate != 0)
			{
				while (@delegate != onParticlePicked)
				{
				}
				ObiClothPicker obiClothPicker2 = this.picker;
				EventHandler<ObiClothPicker.ParticlePickEventArgs> eventHandler2 = new EventHandler(this.Picker_OnParticleHeld);
				EventHandler<ObiClothPicker.ParticlePickEventArgs> onParticleHeld = obiClothPicker2.OnParticleHeld;
				Delegate delegate2 = Delegate.Combine(onParticleHeld, eventHandler2);
				if (delegate2 == 0 || delegate2 != 0)
				{
					while (delegate2 != onParticleHeld)
					{
					}
					ObiClothPicker obiClothPicker3 = this.picker;
					EventHandler<ObiClothPicker.ParticlePickEventArgs> eventHandler3 = new EventHandler(this.Picker_OnParticleDragged);
					EventHandler<ObiClothPicker.ParticlePickEventArgs> onParticleDragged = obiClothPicker3.OnParticleDragged;
					Delegate delegate3 = Delegate.Combine(onParticleDragged, eventHandler3);
					if (delegate3 == 0 || delegate3 != 0)
					{
						while (delegate3 != onParticleDragged)
						{
						}
						ObiClothPicker obiClothPicker4 = this.picker;
						EventHandler<ObiClothPicker.ParticlePickEventArgs> eventHandler4 = new EventHandler(this.Picker_OnParticleReleased);
						EventHandler<ObiClothPicker.ParticlePickEventArgs> onParticleReleased = obiClothPicker4.OnParticleReleased;
						Delegate delegate4 = Delegate.Combine(onParticleReleased, eventHandler4);
						if (delegate4 == 0 || delegate4 != 0)
						{
							while (delegate4 != onParticleReleased)
							{
							}
							return;
						}
					}
				}
			}
			throw new InvalidCastException();
		}

		// Token: 0x06002EB4 RID: 11956 RVA: 0x00065DD8 File Offset: 0x00063FD8
		[Token(Token = "0x6002EB4")]
		[Address(RVA = "0x10966E0", Offset = "0x10956E0", VA = "0x1810966E0")]
		private void OnDisable()
		{
			ObiClothPicker obiClothPicker = this.picker;
			EventHandler<ObiClothPicker.ParticlePickEventArgs> eventHandler = new EventHandler(this.Picker_OnParticlePicked);
			EventHandler<ObiClothPicker.ParticlePickEventArgs> onParticlePicked = obiClothPicker.OnParticlePicked;
			Delegate @delegate = Delegate.Remove(onParticlePicked, eventHandler);
			if (@delegate == 0 || @delegate != 0)
			{
				while (@delegate != onParticlePicked)
				{
				}
				ObiClothPicker obiClothPicker2 = this.picker;
				EventHandler<ObiClothPicker.ParticlePickEventArgs> eventHandler2 = new EventHandler(this.Picker_OnParticleHeld);
				EventHandler<ObiClothPicker.ParticlePickEventArgs> onParticleHeld = obiClothPicker2.OnParticleHeld;
				Delegate delegate2 = Delegate.Remove(onParticleHeld, eventHandler2);
				if (delegate2 == 0 || delegate2 != 0)
				{
					while (delegate2 != onParticleHeld)
					{
					}
					ObiClothPicker obiClothPicker3 = this.picker;
					EventHandler<ObiClothPicker.ParticlePickEventArgs> eventHandler3 = new EventHandler(this.Picker_OnParticleDragged);
					EventHandler<ObiClothPicker.ParticlePickEventArgs> onParticleDragged = obiClothPicker3.OnParticleDragged;
					Delegate delegate3 = Delegate.Remove(onParticleDragged, eventHandler3);
					if (delegate3 == 0 || delegate3 != 0)
					{
						while (delegate3 != onParticleDragged)
						{
						}
						ObiClothPicker obiClothPicker4 = this.picker;
						EventHandler<ObiClothPicker.ParticlePickEventArgs> eventHandler4 = new EventHandler(this.Picker_OnParticleReleased);
						EventHandler<ObiClothPicker.ParticlePickEventArgs> onParticleReleased = obiClothPicker4.OnParticleReleased;
						Delegate delegate4 = Delegate.Remove(onParticleReleased, eventHandler4);
						if (delegate4 == 0 || delegate4 != 0)
						{
							while (delegate4 != onParticleReleased)
							{
							}
							return;
						}
					}
				}
			}
			throw new InvalidCastException();
		}

		// Token: 0x06002EB5 RID: 11957 RVA: 0x00065ED4 File Offset: 0x000640D4
		[Token(Token = "0x6002EB5")]
		[Address(RVA = "0x10974D0", Offset = "0x10964D0", VA = "0x1810974D0")]
		private void Picker_OnParticleReleased(object sender, ObiClothPicker.ParticlePickEventArgs e)
		{
			IntPtr oniSolver = this.picker.cloth.solver.oniSolver;
			float[] array = new float[1];
			float num = this.originalMass;
			array[0] = num;
			int[] particleIndices = this.picker.cloth.particleIndices;
			int particleIndex = e.particleIndex;
			int num2 = particleIndices[particleIndex];
			int num3 = Oni.SetParticleInverseMasses(oniSolver, array, 1, num2);
			this.picker.cloth.solver.RelinquishRenderablePositions();
		}

		// Token: 0x06002EB6 RID: 11958 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002EB6")]
		[Address(RVA = "0x1097160", Offset = "0x1096160", VA = "0x181097160")]
		private void Picker_OnParticleHeld(object sender, ObiClothPicker.ParticlePickEventArgs e)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002EB7 RID: 11959 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002EB7")]
		[Address(RVA = "0x1096D80", Offset = "0x1095D80", VA = "0x181096D80")]
		private void Picker_OnParticleDragged(object sender, ObiClothPicker.ParticlePickEventArgs e)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002EB8 RID: 11960 RVA: 0x00065F58 File Offset: 0x00064158
		[Token(Token = "0x6002EB8")]
		[Address(RVA = "0x1097350", Offset = "0x1096350", VA = "0x181097350")]
		private void Picker_OnParticlePicked(object sender, ObiClothPicker.ParticlePickEventArgs e)
		{
			this.picker.cloth.solver.RequireRenderablePositions();
			ObiClothPicker obiClothPicker = this.picker;
			float[] invMasses = obiClothPicker.cloth.invMasses;
			int particleIndex = e.particleIndex;
			float num = invMasses[particleIndex];
			this.originalMass = num;
			IntPtr oniSolver = obiClothPicker.cloth.solver.oniSolver;
			float[] array = new float[] { (float)((ulong)953267991L) };
			int[] particleIndices = this.picker.cloth.particleIndices;
			int particleIndex2 = e.particleIndex;
			int num2 = particleIndices[particleIndex2];
			int num3 = Oni.SetParticleInverseMasses(oniSolver, array, 1, num2);
		}

		// Token: 0x06002EB9 RID: 11961 RVA: 0x00066008 File Offset: 0x00064208
		[Token(Token = "0x6002EB9")]
		[Address(RVA = "0x328C40", Offset = "0x327C40", VA = "0x180328C40")]
		public ObiClothDragger()
		{
		}

		// Token: 0x04003745 RID: 14149
		[FieldOffset(Offset = "0x18")]
		[Token(Token = "0x4003745")]
		private ObiClothPicker picker;

		// Token: 0x04003746 RID: 14150
		[FieldOffset(Offset = "0x20")]
		[Token(Token = "0x4003746")]
		private float originalMass;

		// Token: 0x04003747 RID: 14151
		[Token(Token = "0x4003747")]
		private const float DRAGGED_PARTICLE_MASS = 0.0001f;
	}
}
