using System;
using Cpp2IlInjected;
using UnityEngine;

namespace Obi
{
	// Token: 0x020004E6 RID: 1254
	[Token(Token = "0x20004E6")]
	[RequireComponent(typeof(ObiClothPicker))]
	public class ObiClothDragger : MonoBehaviour
	{
		// Token: 0x06002BEA RID: 11242 RVA: 0x0005EA34 File Offset: 0x0005CC34
		[Token(Token = "0x6002BEA")]
		[Address(RVA = "0x10036F0", Offset = "0x10024F0", VA = "0x1810036F0")]
		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: 0x06002BEB RID: 11243 RVA: 0x0005EB44 File Offset: 0x0005CD44
		[Token(Token = "0x6002BEB")]
		[Address(RVA = "0x10033B0", Offset = "0x10021B0", VA = "0x1810033B0")]
		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: 0x06002BEC RID: 11244 RVA: 0x0005EC40 File Offset: 0x0005CE40
		[Token(Token = "0x6002BEC")]
		[Address(RVA = "0x10041A0", Offset = "0x1002FA0", VA = "0x1810041A0")]
		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: 0x06002BED RID: 11245 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002BED")]
		[Address(RVA = "0x1003E30", Offset = "0x1002C30", VA = "0x181003E30")]
		private void Picker_OnParticleHeld(object sender, ObiClothPicker.ParticlePickEventArgs e)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002BEE RID: 11246 RVA: 0x000020D3 File Offset: 0x000002D3
		[Token(Token = "0x6002BEE")]
		[Address(RVA = "0x1003A50", Offset = "0x1002850", VA = "0x181003A50")]
		private void Picker_OnParticleDragged(object sender, ObiClothPicker.ParticlePickEventArgs e)
		{
			throw new AnalysisFailedException("CPP2IL failed to recover any usable IL for this method.");
		}

		// Token: 0x06002BEF RID: 11247 RVA: 0x0005ECC4 File Offset: 0x0005CEC4
		[Token(Token = "0x6002BEF")]
		[Address(RVA = "0x1004020", Offset = "0x1002E20", VA = "0x181004020")]
		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: 0x06002BF0 RID: 11248 RVA: 0x0005ED74 File Offset: 0x0005CF74
		[Token(Token = "0x6002BF0")]
		[Address(RVA = "0x3088F0", Offset = "0x3076F0", VA = "0x1803088F0")]
		public ObiClothDragger()
		{
		}

		// Token: 0x0400345B RID: 13403
		[FieldOffset(Offset = "0x18")]
		[Token(Token = "0x400345B")]
		private ObiClothPicker picker;

		// Token: 0x0400345C RID: 13404
		[FieldOffset(Offset = "0x20")]
		[Token(Token = "0x400345C")]
		private float originalMass;

		// Token: 0x0400345D RID: 13405
		[Token(Token = "0x400345D")]
		private const float DRAGGED_PARTICLE_MASS = 0.0001f;
	}
}
