M2FT.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using M2FT;
using OtherLoader;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Serialization;

[assembly: Debuggable(DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace M2FT
{
	public sealed class BurnClock
	{
		private double remaining;

		private double pending;

		public bool Burning => remaining > 0.0;

		public void Refresh(float duration)
		{
			if ((double)duration > remaining)
			{
				remaining = duration;
			}
		}

		public float Advance(float dt)
		{
			if (dt <= 0f || remaining <= 0.0)
			{
				return 0f;
			}
			double num = Math.Min(dt, remaining);
			remaining -= num;
			pending += num * 10.0;
			if (pending >= 2.499999 || remaining <= 0.0)
			{
				float result = (float)pending;
				pending = 0.0;
				return result;
			}
			return 0f;
		}
	}
	public sealed class BurningVisual
	{
		private struct Key : IEquatable<Key>
		{
			public int x;

			public int y;

			public int z;

			public Key(Vector3 p, float size)
			{
				x = Mathf.FloorToInt(p.x / size);
				y = Mathf.FloorToInt(p.y / size);
				z = Mathf.FloorToInt(p.z / size);
			}

			public bool Equals(Key b)
			{
				return x == b.x && y == b.y && z == b.z;
			}

			public override bool Equals(object b)
			{
				return b is Key && Equals((Key)b);
			}

			public override int GetHashCode()
			{
				return (x * 73856093) ^ (y * 19349663) ^ (z * 83492791);
			}
		}

		private struct Patch
		{
			public Vector3 p;

			public Vector3 v;

			public float fade;

			public int count;
		}

		private readonly Dictionary<Key, Patch> patches = new Dictionary<Key, Patch>();

		private readonly Transform owner;

		private readonly ParticleSystem fire;

		private readonly ParticleSystem smoke;

		private readonly ParticleSystem embers;

		private readonly ParticleSystemRenderer fireRenderer;

		private readonly ParticleSystemRenderer smokeRenderer;

		private readonly ParticleSystemRenderer emberRenderer;

		private readonly MaterialPropertyBlock properties = new MaterialPropertyBlock();

		private float size;

		private float fireCredit;

		private float smokeCredit;

		private float emberCredit;

		private int limit;

		private Mesh cube;

		private Vector3 cubeSize;

		public BurningVisual(Transform parent)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			owner = parent;
			fire = Create("Fire particles", 1536, 0, out fireRenderer);
			smoke = Create("Smoke particles", 512, 1, out smokeRenderer);
			embers = Create("Ember particles", 256, 2, out emberRenderer);
		}

		private ParticleSystem Create(string label, int capacity, int kind, out ParticleSystemRenderer renderer)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Expected O, but got Unknown
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Expected O, but got Unknown
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(label);
			val.layer = ((Component)owner).gameObject.layer;
			val.transform.SetParent(owner, false);
			val.SetActive(false);
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			val2.Stop();
			val2.Clear();
			MainModule main = val2.main;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).loop = true;
			((MainModule)(ref main)).maxParticles = capacity;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(1f);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(1f);
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).enabled = false;
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).enabled = false;
			NoiseModule noise = val2.noise;
			((NoiseModule)(ref noise)).enabled = true;
			((NoiseModule)(ref noise)).strength = MinMaxCurve.op_Implicit((kind != 0) ? 0.16f : 0.45f);
			((NoiseModule)(ref noise)).frequency = ((kind != 0) ? 0.8f : 2.8f);
			((NoiseModule)(ref noise)).scrollSpeed = MinMaxCurve.op_Implicit((kind != 0) ? 0.6f : 5f);
			((NoiseModule)(ref noise)).damping = true;
			SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = ((kind != 0) ? new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[2]
			{
				new Keyframe(0f, (kind != 1) ? 1f : 0.45f),
				new Keyframe(1f, (kind != 1) ? 0f : 2.5f)
			})) : new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[4]
			{
				new Keyframe(0f, 0f),
				new Keyframe(0.16f, 0.7f),
				new Keyframe(0.55f, 1f),
				new Keyframe(1f, 0.12f)
			})));
			Gradient val3 = new Gradient();
			val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(Color.white, 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(0f, 0f),
				new GradientAlphaKey((kind != 1) ? 0.9f : 0.35f, 0.15f),
				new GradientAlphaKey(0f, 1f)
			});
			ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val3);
			renderer = val.GetComponent<ParticleSystemRenderer>();
			renderer.renderMode = (ParticleSystemRenderMode)0;
			renderer.alignment = (ParticleSystemRenderSpace)0;
			renderer.sortMode = (ParticleSystemSortMode)1;
			((Renderer)renderer).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)renderer).receiveShadows = false;
			val.SetActive(true);
			val2.Clear();
			val2.Play();
			return val2;
		}

		public void Begin(float cellSize, int maxPatches)
		{
			patches.Clear();
			size = Mathf.Max(0.08f, cellSize);
			limit = Mathf.Clamp(maxPatches, 8, 192);
		}

		public void Fuel(Vector3 p, Vector3 v, float particleSize, float fade, Transform surface)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			Key key = new Key(p, size);
			if (patches.TryGetValue(key, out var value) || patches.Count < limit)
			{
				value.p += p;
				value.v += v;
				value.count++;
				value.fade = Mathf.Max(value.fade, fade);
				patches[key] = value;
			}
		}

		private void Emit(ParticleSystem ps, Vector3 p, Vector3 v, float width, float life, Color tint)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			EmitParams val = default(EmitParams);
			((EmitParams)(ref val)).position = p;
			((EmitParams)(ref val)).velocity = v;
			((EmitParams)(ref val)).startSize = width;
			((EmitParams)(ref val)).startLifetime = life;
			((EmitParams)(ref val)).startColor = Color32.op_Implicit(tint);
			((EmitParams)(ref val)).rotation = Random.Range(-35f, 35f);
			ps.Emit(val, 1);
		}

		public void Render(Material flame, Material soot, float height, float smokeAmount, Vector3 wind, float rollSpeed, float motionResponse, Vector3 meshSize)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0360: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)fire == (Object)null)
			{
				return;
			}
			if ((Object)(object)cube == (Object)null || cubeSize != meshSize)
			{
				if ((Object)(object)cube != (Object)null)
				{
					Object.Destroy((Object)(object)cube);
				}
				cube = FireCubeMesh.Create(meshSize);
				cubeSize = meshSize;
				fireRenderer.renderMode = (ParticleSystemRenderMode)4;
				fireRenderer.mesh = cube;
				fireRenderer.alignment = (ParticleSystemRenderSpace)1;
				emberRenderer.renderMode = (ParticleSystemRenderMode)4;
				emberRenderer.mesh = cube;
				emberRenderer.alignment = (ParticleSystemRenderSpace)1;
			}
			((Renderer)fireRenderer).sharedMaterial = flame;
			((Renderer)smokeRenderer).sharedMaterial = soot;
			((Renderer)emberRenderer).sharedMaterial = flame;
			properties.SetFloat("_RollSpeed", Mathf.Clamp(rollSpeed, 0.2f, 6f));
			((Renderer)fireRenderer).SetPropertyBlock(properties);
			((Renderer)emberRenderer).SetPropertyBlock(properties);
			NoiseModule noise = fire.noise;
			((NoiseModule)(ref noise)).scrollSpeed = MinMaxCurve.op_Implicit(Mathf.Clamp(rollSpeed, 0.2f, 6f) * 3f);
			((NoiseModule)(ref noise)).strength = MinMaxCurve.op_Implicit(0.3f + size * 1.5f);
			float num = Mathf.Min(Time.deltaTime, 0.1f);
			foreach (Patch value in patches.Values)
			{
				Vector3 val = value.p / (float)value.count;
				Vector3 val2 = value.v / (float)value.count;
				float num2 = size * Mathf.Clamp(0.9f + Mathf.Sqrt((float)value.count) * 0.2f, 1f, 1.7f) * value.fade;
				Vector3 val3 = Vector3.ClampMagnitude(val2, 30f) * Mathf.Clamp01(motionResponse * 4f) + wind;
				fireCredit += num * 45f;
				smokeCredit += num * 8f * Mathf.Clamp(smokeAmount, 0f, 3f);
				emberCredit += num * 3f;
				int num3 = Mathf.Min(8, Mathf.FloorToInt(fireCredit));
				fireCredit -= num3;
				for (int i = 0; i < num3; i++)
				{
					Emit(fire, val, val3 + Vector3.up * (height * num2 * 3f) + Random.insideUnitSphere * num2 * 1.5f, num2 * 2f, Random.Range(0.35f, 0.65f), Color.white);
				}
				if (smokeCredit >= 1f)
				{
					smokeCredit -= 1f;
					Emit(smoke, val + Vector3.up * num2, val3 * 0.3f + Vector3.up * 0.6f, num2 * 2f, Random.Range(1.8f, 3.2f), Color.white);
				}
				if (emberCredit >= 1f)
				{
					emberCredit -= 1f;
					Emit(embers, val, val3 + Vector3.up * 1.8f + Random.insideUnitSphere * 0.6f, 0.025f, Random.Range(0.4f, 1f), new Color(1f, 0.5f, 0.1f, 1f));
				}
			}
		}

		public void Clear()
		{
			patches.Clear();
			fire.Clear();
			smoke.Clear();
			embers.Clear();
			fireCredit = (smokeCredit = (emberCredit = 0f));
		}

		public void SetEnabled(bool value)
		{
			((Renderer)fireRenderer).enabled = value;
			((Renderer)smokeRenderer).enabled = value;
			((Renderer)emberRenderer).enabled = value;
		}

		public void Dispose()
		{
			if ((Object)(object)fire != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)fire).gameObject);
			}
			if ((Object)(object)smoke != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)smoke).gameObject);
			}
			if ((Object)(object)embers != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)embers).gameObject);
			}
			if ((Object)(object)cube != (Object)null)
			{
				Object.Destroy((Object)(object)cube);
			}
		}
	}
	[ExecuteInEditMode]
	public sealed class ElasticHose : MonoBehaviour
	{
		public Transform startPoint;

		public Transform endPoint;

		public Material material;

		public bool pullConnectedBodies = true;

		[Tooltip("Optional override. Empty automatically finds the endpoint's parent Rigidbody.")]
		public Rigidbody startBody;

		public Rigidbody endBody;

		[Tooltip("Axial spring strength in N/m, scaled by Stiffness.")]
		public float pullStrength = 250f;

		public float pullDamping = 25f;

		public float maxPullForce = 500f;

		[Tooltip("Outer diameter in world units, independent of object scale.")]
		public float thickness = 0.04f;

		[Range(0f, 1f)]
		public float stiffness = 0.65f;

		[Tooltip("Length of the reinforced section at EACH end, in world units. 0 disables it.")]
		public float endStiffLength = 0.2f;

		[Range(0f, 1f)]
		public float endStiffness = 0.95f;

		[Tooltip("Use local connector directions instead of capturing the initial hose direction on reset.")]
		public bool useEndpointDirections;

		[Tooltip("Local direction pointing OUT of the start connector INTO the hose.")]
		public Vector3 startLocalDirection = Vector3.forward;

		[Tooltip("Local direction pointing OUT of the end connector INTO the hose.")]
		public Vector3 endLocalDirection = Vector3.back;

		[Tooltip("0 calculates the length from endpoint distance times Slack on reset.")]
		public float hoseLength;

		[Range(1f, 3f)]
		public float slack = 1.15f;

		[Range(4f, 128f)]
		public int segments = 32;

		[Range(3f, 24f)]
		public int radialSides = 8;

		[Range(1f, 24f)]
		public int solverIterations = 10;

		[Range(1f, 6f)]
		public int substeps = 2;

		[Range(0f, 8f)]
		public float damping = 1.5f;

		public float gravityScale = 1f;

		public bool collision = true;

		public LayerMask collisionLayers = LayerMask.op_Implicit(-1);

		[Tooltip("Exclude endpoint colliders/owners to avoid the hose fighting its attachments.")]
		public Collider[] ignoreColliders = (Collider[])(object)new Collider[0];

		[Range(0f, 1f)]
		public float friction = 0.6f;

		public float textureMetersPerRepeat = 0.25f;

		public bool capEnds = true;

		[Tooltip("Automatically reinitialize on very large endpoint jumps. 0 disables this.")]
		public float teleportResetDistance = 3f;

		private Vector3[] positions;

		private Vector3[] previous;

		private Vector3[] vertices;

		private Vector3[] normals;

		private Vector2[] uv;

		private int[] triangles;

		private readonly Collider[] overlaps = (Collider[])(object)new Collider[24];

		private readonly RaycastHit[] sweepHits = (RaycastHit[])(object)new RaycastHit[24];

		private GameObject renderObject;

		private Mesh mesh;

		private MeshRenderer meshRenderer;

		private Material fallback;

		private int builtSegments;

		private int builtSides;

		private bool builtCaps;

		private bool initialized;

		private float autoLength;

		private float lastStep;

		private Vector3 lastStart;

		private Vector3 lastEnd;

		private Vector3 capturedStartDirection;

		private Vector3 capturedEndDirection;

		public float CurrentTension { get; private set; }

		private void OnEnable()
		{
			initialized = false;
		}

		private void OnValidate()
		{
			segments = Mathf.Clamp(segments, 4, 128);
			radialSides = Mathf.Clamp(radialSides, 3, 24);
			thickness = Mathf.Max(0.002f, thickness);
			hoseLength = Mathf.Max(0f, hoseLength);
			textureMetersPerRepeat = Mathf.Max(0.01f, textureMetersPerRepeat);
			endStiffLength = Mathf.Max(0f, endStiffLength);
			endStiffness = Mathf.Clamp01(endStiffness);
			stiffness = Mathf.Clamp01(stiffness);
			friction = Mathf.Clamp01(friction);
			pullStrength = Mathf.Max(0f, pullStrength);
			pullDamping = Mathf.Max(0f, pullDamping);
			maxPullForce = Mathf.Max(0f, maxPullForce);
		}

		[ContextMenu("Reset Hose")]
		public void ResetHose()
		{
			initialized = false;
		}

		public void SetEndpoints(Transform first, Transform second)
		{
			startPoint = first;
			endPoint = second;
			ResetHose();
		}

		private bool Prepare()
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Expected O, but got Unknown
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)startPoint == (Object)null || (Object)(object)endPoint == (Object)null)
			{
				if ((Object)(object)meshRenderer != (Object)null)
				{
					((Renderer)meshRenderer).enabled = false;
				}
				initialized = false;
				return false;
			}
			int num = Mathf.Clamp(segments, 4, 128);
			int num2 = Mathf.Clamp(radialSides, 3, 24);
			if ((Object)(object)mesh == (Object)null || builtSegments != num || builtSides != num2 || builtCaps != capEnds)
			{
				Release();
				builtSegments = num;
				builtSides = num2;
				builtCaps = capEnds;
				renderObject = new GameObject("Elastic hose mesh");
				((Object)renderObject).hideFlags = (HideFlags)52;
				renderObject.layer = ((Component)this).gameObject.layer;
				renderObject.transform.SetParent(((Component)this).transform, false);
				mesh = new Mesh();
				((Object)mesh).name = "Elastic hose";
				((Object)mesh).hideFlags = (HideFlags)52;
				mesh.MarkDynamic();
				renderObject.AddComponent<MeshFilter>().sharedMesh = mesh;
				meshRenderer = renderObject.AddComponent<MeshRenderer>();
				((Renderer)meshRenderer).shadowCastingMode = (ShadowCastingMode)1;
				positions = (Vector3[])(object)new Vector3[num + 1];
				previous = (Vector3[])(object)new Vector3[num + 1];
				int num3 = (num + 1) * (num2 + 1);
				int num4 = (capEnds ? (2 * (num2 + 2)) : 0);
				vertices = (Vector3[])(object)new Vector3[num3 + num4];
				normals = (Vector3[])(object)new Vector3[vertices.Length];
				uv = (Vector2[])(object)new Vector2[vertices.Length];
				triangles = new int[num * num2 * 6 + (capEnds ? (num2 * 6) : 0)];
				int num5 = 0;
				for (int i = 0; i < num; i++)
				{
					for (int j = 0; j < num2; j++)
					{
						int num6 = i * (num2 + 1) + j;
						int num7 = num6 + num2 + 1;
						triangles[num5++] = num6;
						triangles[num5++] = num6 + 1;
						triangles[num5++] = num7;
						triangles[num5++] = num6 + 1;
						triangles[num5++] = num7 + 1;
						triangles[num5++] = num7;
					}
				}
				if (capEnds)
				{
					for (int k = 0; k < 2; k++)
					{
						for (int l = 0; l < num2; l++)
						{
							int num8 = num3 + k * (num2 + 2);
							triangles[num5++] = num8;
							triangles[num5++] = num8 + 1 + ((k != 0) ? l : (l + 1));
							triangles[num5++] = num8 + 1 + ((k != 0) ? (l + 1) : l);
						}
					}
				}
				initialized = false;
			}
			((Renderer)meshRenderer).enabled = true;
			renderObject.layer = ((Component)this).gameObject.layer;
			if ((Object)(object)material == (Object)null && (Object)(object)fallback == (Object)null)
			{
				Shader val = Shader.Find("Standard");
				if ((Object)(object)val != (Object)null)
				{
					fallback = new Material(val);
					((Object)fallback).hideFlags = (HideFlags)52;
					fallback.color = new Color(0.035f, 0.035f, 0.04f);
					fallback.SetFloat("_Glossiness", 0.35f);
				}
			}
			((Renderer)meshRenderer).sharedMaterial = ((!((Object)(object)material != (Object)null)) ? fallback : material);
			if (!initialized)
			{
				Initialize();
			}
			return true;
		}

		private void Initialize()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			lastStart = startPoint.position;
			lastEnd = endPoint.position;
			float num = Vector3.Distance(lastStart, lastEnd);
			autoLength = Mathf.Max(0.02f, num * Mathf.Clamp(slack, 1f, 3f));
			float num2 = ((!(hoseLength > 0f)) ? autoLength : Mathf.Max(0.02f, hoseLength));
			Vector3 gravity = Physics.gravity;
			Vector3 val;
			if (((Vector3)(ref gravity)).sqrMagnitude > 0.0001f)
			{
				Vector3 gravity2 = Physics.gravity;
				val = ((Vector3)(ref gravity2)).normalized;
			}
			else
			{
				val = Vector3.down;
			}
			Vector3 val2 = val;
			Vector3 val3 = Vector3.Cross(val2, lastEnd - lastStart);
			if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f)
			{
				val2 = startPoint.right;
			}
			float num3 = Mathf.Sqrt(Mathf.Max(0f, num2 * num2 - num * num)) * 0.35f;
			for (int i = 0; i <= builtSegments; i++)
			{
				float num4 = (float)i / (float)builtSegments;
				ref Vector3 reference = ref positions[i];
				reference = Vector3.Lerp(lastStart, lastEnd, num4) + val2 * (Mathf.Sin(num4 * (float)Math.PI) * num3);
				ref Vector3 reference2 = ref previous[i];
				reference2 = positions[i];
			}
			Transform obj = startPoint;
			Vector3 val4 = positions[1] - positions[0];
			capturedStartDirection = obj.InverseTransformDirection(((Vector3)(ref val4)).normalized);
			Transform obj2 = endPoint;
			Vector3 val5 = positions[builtSegments - 1] - positions[builtSegments];
			capturedEndDirection = obj2.InverseTransformDirection(((Vector3)(ref val5)).normalized);
			lastStep = 0f;
			initialized = true;
		}

		private void FixedUpdate()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			if (!Application.isPlaying || !Prepare())
			{
				return;
			}
			Vector3 position = startPoint.position;
			Vector3 position2 = endPoint.position;
			float num = Mathf.Max(Vector3.Distance(position, lastStart), Vector3.Distance(position2, lastEnd));
			bool flag = teleportResetDistance > 0f && num > teleportResetDistance;
			if (flag)
			{
				Initialize();
			}
			CurrentTension = 0f;
			if (pullConnectedBodies && !flag)
			{
				PullBodies(position, position2, Time.fixedDeltaTime);
			}
			int num2 = Mathf.Clamp(substeps, 1, 6);
			float num3 = Time.fixedDeltaTime / (float)num2;
			if (!(num3 <= 0f))
			{
				for (int i = 0; i < num2; i++)
				{
					float num4 = ((float)i + 1f) / (float)num2;
					Vector3 start = Vector3.Lerp(lastStart, position, num4);
					Vector3 end = Vector3.Lerp(lastEnd, position2, num4);
					Step(start, end, num3);
				}
				lastStart = position;
				lastEnd = position2;
			}
		}

		private void PullBodies(Vector3 start, Vector3 end, float dt)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			if (dt <= 0f)
			{
				return;
			}
			Rigidbody val = ((!((Object)(object)startBody != (Object)null)) ? ((Component)startPoint).GetComponentInParent<Rigidbody>() : startBody);
			Rigidbody val2 = ((!((Object)(object)endBody != (Object)null)) ? ((Component)endPoint).GetComponentInParent<Rigidbody>() : endBody);
			if ((Object)(object)val != (Object)null && (Object)(object)val == (Object)(object)val2)
			{
				return;
			}
			bool flag = (Object)(object)val != (Object)null && !val.isKinematic;
			bool flag2 = (Object)(object)val2 != (Object)null && !val2.isKinematic;
			if (!flag && !flag2)
			{
				return;
			}
			Vector3 val3 = end - start;
			float magnitude = ((Vector3)(ref val3)).magnitude;
			if (!(magnitude < 1E-05f))
			{
				Vector3 val4 = val3 / magnitude;
				float num = ((!(hoseLength > 0f)) ? autoLength : Mathf.Max(0.02f, hoseLength));
				Vector3 val5 = ((!((Object)(object)val != (Object)null)) ? ((start - lastStart) / dt) : val.GetPointVelocity(start));
				Vector3 val6 = ((!((Object)(object)val2 != (Object)null)) ? ((end - lastEnd) / dt) : val2.GetPointVelocity(end));
				float inverseMass = ((!flag) ? 0f : (1f / Mathf.Max(0.0001f, val.mass))) + ((!flag2) ? 0f : (1f / Mathf.Max(0.0001f, val2.mass)));
				float spring = Mathf.Max(0f, pullStrength) * Mathf.Lerp(0.1f, 1f, Mathf.Clamp01(stiffness));
				CurrentTension = HoseTension.Calculate(magnitude - num, Vector3.Dot(val6 - val5, val4), spring, pullDamping, maxPullForce, inverseMass, dt);
				Vector3 val7 = val4 * CurrentTension;
				if (flag)
				{
					val.AddForceAtPosition(val7, start, (ForceMode)0);
				}
				if (flag2)
				{
					val2.AddForceAtPosition(-val7, end, (ForceMode)0);
				}
			}
		}

		private void Step(Vector3 start, Vector3 end, float dt)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Exp((0f - Mathf.Max(0f, damping)) * dt);
			float num2 = ((!(lastStep > 0f)) ? 1f : Mathf.Clamp(dt / lastStep, 0.25f, 4f));
			for (int i = 1; i < builtSegments; i++)
			{
				Vector3 val = positions[i];
				Vector3 val2 = (val - previous[i]) * num * num2;
				val2 = Vector3.ClampMagnitude(val2, 30f * dt);
				ref Vector3 reference = ref positions[i];
				reference += val2 + Physics.gravity * gravityScale * (dt * dt);
				previous[i] = val;
			}
			lastStep = dt;
			positions[0] = start;
			positions[builtSegments] = end;
			float num3 = ((!(hoseLength > 0f)) ? autoLength : Mathf.Max(0.02f, hoseLength));
			float num4 = Mathf.Max(num3, Vector3.Distance(start, end) * 1.001f) / (float)builtSegments;
			int num5 = Mathf.Clamp(solverIterations, 1, 24);
			float strength = 1f - Mathf.Pow(1f - Mathf.Lerp(0.7f, 0.9999f, Mathf.Clamp01(stiffness)), 1f / (float)num5);
			float strength2 = 1f - Mathf.Pow(1f - Mathf.Clamp01(stiffness) * 0.95f, 1f / (float)num5);
			for (int j = 0; j < num5; j++)
			{
				for (int k = 0; k < builtSegments; k++)
				{
					int num6 = ((j % 2 != 0) ? (builtSegments - 1 - k) : k);
					Constrain(num6, num6 + 1, num4, strength);
				}
				for (int l = 0; l < builtSegments - 1; l++)
				{
					Constrain(l, l + 2, num4 * 2f, strength2);
				}
				ReinforceEnds(start, end, num4, num5);
				if (collision)
				{
					for (int m = 1; m < builtSegments; m++)
					{
						Collide(m);
					}
				}
				positions[0] = start;
				positions[builtSegments] = end;
			}
		}

		private void ReinforceEnds(Vector3 start, Vector3 end, float rest, int iterations)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Min(Mathf.Max(0f, endStiffLength), rest * (float)builtSegments * 0.45f);
			if (num <= 0f || endStiffness <= 0f)
			{
				return;
			}
			Vector3 val = ((!useEndpointDirections) ? capturedStartDirection : startLocalDirection);
			Vector3 val2 = ((!useEndpointDirections) ? capturedEndDirection : endLocalDirection);
			if (((Vector3)(ref val)).sqrMagnitude < 1E-06f)
			{
				val = Vector3.forward;
			}
			if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f)
			{
				val2 = Vector3.back;
			}
			val = startPoint.TransformDirection(((Vector3)(ref val)).normalized);
			val2 = endPoint.TransformDirection(((Vector3)(ref val2)).normalized);
			for (int i = 1; i < builtSegments; i++)
			{
				float num2 = (float)i * rest;
				if (num2 >= num)
				{
					break;
				}
				float num3 = 1f - num2 / num;
				float num4 = num3 * num3 * (3f - 2f * num3) * Mathf.Clamp01(endStiffness);
				float strength = 1f - Mathf.Pow(1f - num4, 1f / (float)iterations);
				ReinforceNode(i, start + val * num2, strength);
				ReinforceNode(builtSegments - i, end + val2 * num2, strength);
			}
		}

		private void ReinforceNode(int index, Vector3 target, float strength)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (target - positions[index]) * strength;
			ref Vector3 reference = ref positions[index];
			reference += val;
			ref Vector3 reference2 = ref previous[index];
			reference2 += val;
		}

		private void Constrain(int a, int b, float length, float strength)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = positions[b] - positions[a];
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (!(magnitude < 1E-06f))
			{
				float num = ((a != 0) ? 1 : 0);
				float num2 = ((b != builtSegments) ? 1 : 0);
				Vector3 val2 = val * ((magnitude - length) / magnitude * strength / (num + num2));
				ref Vector3 reference = ref positions[a];
				reference += val2 * num;
				ref Vector3 reference2 = ref positions[b];
				reference2 -= val2 * num2;
			}
		}

		private bool Ignore(Collider col)
		{
			if ((Object)(object)col == (Object)null || col.isTrigger)
			{
				return true;
			}
			int num = 0;
			while (ignoreColliders != null && num < ignoreColliders.Length)
			{
				if ((Object)(object)ignoreColliders[num] == (Object)(object)col)
				{
					return true;
				}
				num++;
			}
			return false;
		}

		private void Collide(int i)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(0.001f, thickness * 0.5f);
			Vector3 val = positions[i] - previous[i];
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (magnitude > 1E-05f)
			{
				int num2 = Physics.SphereCastNonAlloc(previous[i], num, val / magnitude, sweepHits, magnitude, LayerMask.op_Implicit(collisionLayers), (QueryTriggerInteraction)1);
				int num3 = -1;
				float num4 = float.PositiveInfinity;
				for (int j = 0; j < num2; j++)
				{
					if (!Ignore(((RaycastHit)(ref sweepHits[j])).collider) && ((RaycastHit)(ref sweepHits[j])).distance < num4)
					{
						num3 = j;
						num4 = ((RaycastHit)(ref sweepHits[j])).distance;
					}
				}
				if (num3 >= 0)
				{
					RaycastHit val2 = sweepHits[num3];
					Resolve(i, ((RaycastHit)(ref val2)).point + ((RaycastHit)(ref val2)).normal * (num + 0.001f), ((RaycastHit)(ref val2)).normal, ((RaycastHit)(ref val2)).collider);
				}
			}
			int num5 = Physics.OverlapSphereNonAlloc(positions[i], num, overlaps, LayerMask.op_Implicit(collisionLayers), (QueryTriggerInteraction)1);
			for (int k = 0; k < num5; k++)
			{
				Collider val3 = overlaps[k];
				if (Ignore(val3))
				{
					continue;
				}
				Vector3 val4 = val3.ClosestPoint(positions[i]);
				Vector3 val5 = positions[i] - val4;
				if (((Vector3)(ref val5)).sqrMagnitude < 1E-06f)
				{
					Vector3 val6 = positions[i];
					Bounds bounds = val3.bounds;
					val5 = val6 - ((Bounds)(ref bounds)).center;
					if (((Vector3)(ref val5)).sqrMagnitude < 1E-06f)
					{
						val5 = Vector3.up;
					}
					Bounds bounds2 = val3.bounds;
					Vector3 center = ((Bounds)(ref bounds2)).center;
					Vector3 normalized = ((Vector3)(ref val5)).normalized;
					Bounds bounds3 = val3.bounds;
					Vector3 extents = ((Bounds)(ref bounds3)).extents;
					val4 = val3.ClosestPoint(center + normalized * (((Vector3)(ref extents)).magnitude + num));
				}
				((Vector3)(ref val5)).Normalize();
				Resolve(i, val4 + val5 * (num + 0.001f), val5, val3);
			}
		}

		private void Resolve(int i, Vector3 point, Vector3 normal, Collider collider)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = positions[i] - previous[i];
			Rigidbody attachedRigidbody = collider.attachedRigidbody;
			Vector3 val2 = ((!((Object)(object)attachedRigidbody != (Object)null)) ? Vector3.zero : (attachedRigidbody.GetPointVelocity(point) * lastStep));
			Vector3 val3 = val - val2;
			val3 -= normal * Mathf.Min(0f, Vector3.Dot(val3, normal));
			val3 = Vector3.Lerp(val3, Vector3.Project(val3, normal), Mathf.Clamp01(friction));
			positions[i] = point;
			ref Vector3 reference = ref previous[i];
			reference = point - (val2 + val3);
		}

		private void LateUpdate()
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (Prepare())
			{
				if (!Application.isPlaying)
				{
					Initialize();
					float num = ((!(hoseLength > 0f)) ? autoLength : Mathf.Max(0.02f, hoseLength));
					ReinforceEnds(startPoint.position, endPoint.position, Mathf.Max(num, Vector3.Distance(startPoint.position, endPoint.position) * 1.001f) / (float)builtSegments, 1);
				}
				ref Vector3 reference = ref positions[0];
				reference = startPoint.position;
				ref Vector3 reference2 = ref positions[builtSegments];
				reference2 = endPoint.position;
				BuildMesh();
			}
		}

		private Vector3 Tangent(int i)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = positions[Mathf.Min(i + 1, builtSegments)] - positions[Mathf.Max(i - 1, 0)];
			return (!(((Vector3)(ref val)).sqrMagnitude > 1E-07f)) ? Vector3.forward : ((Vector3)(ref val)).normalized;
		}

		private void BuildMesh()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(0.001f, thickness * 0.5f);
			float num2 = 0f;
			Vector3 val = Tangent(0);
			Vector3 val2 = Vector3.Cross(val, startPoint.up);
			if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f)
			{
				val2 = Vector3.Cross(val, Vector3.right);
			}
			if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f)
			{
				val2 = Vector3.Cross(val, Vector3.forward);
			}
			((Vector3)(ref val2)).Normalize();
			Vector3 val3 = val;
			Matrix4x4 localToWorldMatrix = ((Component)this).transform.localToWorldMatrix;
			Matrix4x4 transpose = ((Matrix4x4)(ref localToWorldMatrix)).transpose;
			for (int i = 0; i <= builtSegments; i++)
			{
				val = Tangent(i);
				val2 = Quaternion.FromToRotation(val3, val) * val2;
				Vector3 val4 = val2 - val * Vector3.Dot(val2, val);
				val2 = ((Vector3)(ref val4)).normalized;
				if (((Vector3)(ref val2)).sqrMagnitude < 0.0001f)
				{
					Vector3 val5 = Vector3.Cross(val, (!(Mathf.Abs(val.y) < 0.9f)) ? Vector3.right : Vector3.up);
					val2 = ((Vector3)(ref val5)).normalized;
				}
				Vector3 val6 = Vector3.Cross(val, val2);
				Vector3 normalized = ((Vector3)(ref val6)).normalized;
				if (i > 0)
				{
					num2 += Vector3.Distance(positions[i], positions[i - 1]);
				}
				for (int j = 0; j <= builtSides; j++)
				{
					float num3 = (float)j * (float)Math.PI * 2f / (float)builtSides;
					Vector3 val7 = val2 * Mathf.Cos(num3) + normalized * Mathf.Sin(num3);
					int num4 = i * (builtSides + 1) + j;
					ref Vector3 reference = ref vertices[num4];
					reference = ((Component)this).transform.InverseTransformPoint(positions[i] + val7 * num);
					ref Vector3 reference2 = ref normals[num4];
					Vector3 val8 = ((Matrix4x4)(ref transpose)).MultiplyVector(val7);
					reference2 = ((Vector3)(ref val8)).normalized;
					ref Vector2 reference3 = ref uv[num4];
					reference3 = new Vector2((float)j / (float)builtSides, num2 / Mathf.Max(0.01f, textureMetersPerRepeat));
				}
				if (builtCaps && (i == 0 || i == builtSegments))
				{
					int num5 = (builtSegments + 1) * (builtSides + 1) + ((i != 0) ? (builtSides + 2) : 0);
					Vector3 val9 = ((Matrix4x4)(ref transpose)).MultiplyVector(val * (float)((i != 0) ? 1 : (-1)));
					Vector3 normalized2 = ((Vector3)(ref val9)).normalized;
					ref Vector3 reference4 = ref vertices[num5];
					reference4 = ((Component)this).transform.InverseTransformPoint(positions[i]);
					normals[num5] = normalized2;
					ref Vector2 reference5 = ref uv[num5];
					reference5 = Vector2.one * 0.5f;
					for (int k = 0; k <= builtSides; k++)
					{
						ref Vector3 reference6 = ref vertices[num5 + 1 + k];
						reference6 = vertices[i * (builtSides + 1) + k];
						normals[num5 + 1 + k] = normalized2;
						float num6 = (float)k * (float)Math.PI * 2f / (float)builtSides;
						ref Vector2 reference7 = ref uv[num5 + 1 + k];
						reference7 = new Vector2(Mathf.Cos(num6), Mathf.Sin(num6)) * 0.5f + Vector2.one * 0.5f;
					}
				}
				val3 = val;
			}
			mesh.vertices = vertices;
			mesh.normals = normals;
			mesh.uv = uv;
			mesh.triangles = triangles;
			mesh.RecalculateBounds();
		}

		private void OnDisable()
		{
			Release();
		}

		private void OnDestroy()
		{
			Release();
		}

		private void DestroyOwned(Object obj)
		{
			if (!(obj == (Object)null))
			{
				if (Application.isPlaying)
				{
					Object.Destroy(obj);
				}
				else
				{
					Object.DestroyImmediate(obj);
				}
			}
		}

		private void Release()
		{
			DestroyOwned((Object)(object)renderObject);
			DestroyOwned((Object)(object)mesh);
			DestroyOwned((Object)(object)fallback);
			renderObject = null;
			mesh = null;
			meshRenderer = null;
			fallback = null;
			initialized = false;
		}
	}
	public static class FireCubeMesh
	{
		public static Mesh Create(Vector3 size)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			((Vector3)(ref size))..ctor(Mathf.Max(0.001f, size.x), Mathf.Max(0.001f, size.y), Mathf.Max(0.001f, size.z));
			Vector3[] array = (Vector3[])(object)new Vector3[24];
			Vector3[] array2 = (Vector3[])(object)new Vector3[24];
			Vector2[] array3 = (Vector2[])(object)new Vector2[24];
			int[] array4 = new int[36];
			Vector3[] array5 = (Vector3[])(object)new Vector3[6]
			{
				Vector3.right,
				Vector3.left,
				Vector3.up,
				Vector3.down,
				Vector3.forward,
				Vector3.back
			};
			for (int i = 0; i < 6; i++)
			{
				Vector3 val = array5[i];
				Vector3 val2 = Vector3.Cross((!(Mathf.Abs(val.y) > 0.5f)) ? Vector3.up : Vector3.forward, val);
				Vector3 val3 = Vector3.Cross(val, val2);
				for (int j = 0; j < 4; j++)
				{
					float num = ((j != 0 && j != 3) ? 1 : (-1));
					float num2 = ((j >= 2) ? 1 : (-1));
					int num3 = i * 4 + j;
					ref Vector3 reference = ref array[num3];
					reference = Vector3.Scale((val + val2 * num + val3 * num2) * 0.5f, size);
					array2[num3] = val;
					ref Vector2 reference2 = ref array3[num3];
					reference2 = new Vector2((num + 1f) * 0.5f, (num2 + 1f) * 0.5f);
				}
				int num4 = i * 4;
				int num5 = i * 6;
				array4[num5] = num4;
				array4[num5 + 1] = num4 + 1;
				array4[num5 + 2] = num4 + 2;
				array4[num5 + 3] = num4;
				array4[num5 + 4] = num4 + 2;
				array4[num5 + 5] = num4 + 3;
			}
			Mesh val4 = new Mesh();
			((Object)val4).name = "M2FT fire cube";
			val4.vertices = array;
			val4.normals = array2;
			val4.uv = array3;
			val4.triangles = array4;
			val4.RecalculateBounds();
			return val4;
		}
	}
	public sealed class FluidBurnTarget : MonoBehaviour
	{
		private FVRIgnitable native;

		public bool IsBurning => (Object)(object)native != (Object)null && native.IsOnFire();

		public static FluidBurnTarget Ignite(Collider collider, Vector3 point, Vector3 normal, FluidWorld source, float unusedDuration)
		{
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			if (source.IsIgnored(collider))
			{
				return null;
			}
			if (((Component)collider).GetComponentInParent<IFVRDamageable>() == null)
			{
				return null;
			}
			FVRIgnitable componentInParent = ((Component)collider).GetComponentInParent<FVRIgnitable>();
			if ((Object)(object)componentInParent == (Object)null)
			{
				return null;
			}
			FluidBurnTarget fluidBurnTarget = ((Component)componentInParent).GetComponent<FluidBurnTarget>();
			if (componentInParent.IsOnFire())
			{
				return fluidBurnTarget;
			}
			if (!componentInParent.IsIgniteable())
			{
				return null;
			}
			Transform spawnPos = componentInParent.GetSpawnPos();
			if ((Object)(object)spawnPos == (Object)null)
			{
				return null;
			}
			ParticleSystem[] componentsInChildren = ((Component)spawnPos).GetComponentsInChildren<ParticleSystem>(true);
			try
			{
				FXM.Ignite(componentInParent, Mathf.Max(1f, componentInParent.IgnitionThreshold));
			}
			catch (Exception ex)
			{
				Debug.LogWarning((object)("M2FT: native ignition failed; no fallback damage was applied. " + ex.Message), (Object)(object)source);
				return null;
			}
			if (!componentInParent.IsOnFire())
			{
				return null;
			}
			if ((Object)(object)fluidBurnTarget == (Object)null)
			{
				fluidBurnTarget = ((Component)componentInParent).gameObject.AddComponent<FluidBurnTarget>();
			}
			fluidBurnTarget.native = componentInParent;
			ParticleSystem[] componentsInChildren2 = ((Component)spawnPos).GetComponentsInChildren<ParticleSystem>(true);
			ParticleSystem[] array = componentsInChildren2;
			foreach (ParticleSystem val in array)
			{
				bool flag = false;
				ParticleSystem[] array2 = componentsInChildren;
				foreach (ParticleSystem val2 in array2)
				{
					if ((Object)(object)val2 == (Object)(object)val)
					{
						flag = true;
						break;
					}
				}
				if (!flag && (Object)(object)((Component)val).transform.parent == (Object)(object)spawnPos)
				{
					((Component)val).gameObject.AddComponent<NativeCubeFireVisual>().Configure(val, source.flameMaterial, source.flameMeshSize);
				}
			}
			return fluidBurnTarget;
		}

		private void Update()
		{
			if ((Object)(object)native == (Object)null || !native.IsOnFire())
			{
				Object.Destroy((Object)(object)this);
			}
		}
	}
	public sealed class FluidEmitter : MonoBehaviour
	{
		public FluidWorld world;

		public bool emitting = true;

		public float particlesPerSecond = 80f;

		public float speed = 8f;

		[Range(0f, 45f)]
		public float spread = 6f;

		public bool burning;

		[Tooltip("Smooth spread direction over time to maintain a coherent jet.")]
		public bool coherentStream = true;

		public Rigidbody inheritVelocity;

		private float remainder;

		public void SetEmitting(bool value)
		{
			emitting = value;
		}

		private void FixedUpdate()
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			if (!emitting || (Object)(object)world == (Object)null)
			{
				remainder = 0f;
				return;
			}
			remainder += Mathf.Clamp(particlesPerSecond, 0f, 2000f) * Time.fixedDeltaTime;
			int num = Mathf.Min(256, Mathf.FloorToInt(remainder));
			remainder -= Mathf.Floor(remainder);
			Vector3 val2 = default(Vector3);
			for (int i = 0; i < num; i++)
			{
				Vector2 val = (Vector2)((!coherentStream) ? Random.insideUnitCircle : new Vector2(Mathf.PerlinNoise(Time.time * 2.5f, 0.17f) * 2f - 1f, Mathf.PerlinNoise(0.73f, Time.time * 2.5f) * 2f - 1f));
				val *= Mathf.Tan(spread * ((float)Math.PI / 180f));
				Transform transform = ((Component)this).transform;
				((Vector3)(ref val2))..ctor(val.x, val.y, 1f);
				Vector3 val3 = transform.TransformDirection(((Vector3)(ref val2)).normalized) * speed;
				if ((Object)(object)inheritVelocity != (Object)null)
				{
					val3 += inheritVelocity.GetPointVelocity(((Component)this).transform.position);
				}
				world.Emit(((Component)this).transform.position, val3, burning, ((Component)this).transform.forward);
			}
		}
	}
	public sealed class FluidSurface
	{
		public struct Particle
		{
			public Vector3 position;

			public Vector3 scale;

			public Quaternion rotation;
		}

		private struct Key : IEquatable<Key>
		{
			public int x;

			public int y;

			public int z;

			public Key(int a, int b, int c)
			{
				x = a;
				y = b;
				z = c;
			}

			public bool Equals(Key b)
			{
				return x == b.x && y == b.y && z == b.z;
			}

			public override bool Equals(object b)
			{
				return b is Key && Equals((Key)b);
			}

			public override int GetHashCode()
			{
				return (x * 73856093) ^ (y * 19349663) ^ (z * 83492791);
			}
		}

		private struct EdgeKey : IEquatable<EdgeKey>
		{
			public Key a;

			public Key b;

			public EdgeKey(Key first, Key second)
			{
				bool flag = first.x > second.x || (first.x == second.x && (first.y > second.y || (first.y == second.y && first.z > second.z)));
				a = ((!flag) ? first : second);
				b = ((!flag) ? second : first);
			}

			public bool Equals(EdgeKey other)
			{
				return a.Equals(other.a) && b.Equals(other.b);
			}

			public override bool Equals(object other)
			{
				return other is EdgeKey && Equals((EdgeKey)other);
			}

			public override int GetHashCode()
			{
				return (a.GetHashCode() * 397) ^ b.GetHashCode();
			}
		}

		private struct Sample
		{
			public float value;

			public Vector3 normal;
		}

		private struct Vertex
		{
			public Vector3 p;

			public Vector3 n;

			public int index;
		}

		private readonly Dictionary<EdgeKey, Vertex> edgeCache = new Dictionary<EdgeKey, Vertex>();

		private readonly Key[] cornerKeys = new Key[8];

		private readonly Stopwatch timer = new Stopwatch();

		public float BudgetMilliseconds = 4f;

		private Vector3 outward;

		private Matrix4x4 worldToLocal;

		private Matrix4x4 normalToLocal;

		private readonly Dictionary<Key, Sample> field = new Dictionary<Key, Sample>();

		private readonly HashSet<Key> cells = new HashSet<Key>();

		private readonly List<Vector3> vertices = new List<Vector3>();

		private readonly List<Vector3> normals = new List<Vector3>();

		private readonly List<Vector2> uv = new List<Vector2>();

		private readonly List<int> triangles = new List<int>();

		private readonly Vector3[] p = (Vector3[])(object)new Vector3[8];

		private readonly Vector3[] n = (Vector3[])(object)new Vector3[8];

		private readonly float[] f = new float[8];

		private readonly int[] inside = new int[4];

		private readonly int[] outside = new int[4];

		private static readonly int[,] corners = new int[8, 3]
		{
			{ 0, 0, 0 },
			{ 1, 0, 0 },
			{ 1, 1, 0 },
			{ 0, 1, 0 },
			{ 0, 0, 1 },
			{ 1, 0, 1 },
			{ 1, 1, 1 },
			{ 0, 1, 1 }
		};

		private static readonly int[,] tetra = new int[6, 4]
		{
			{ 0, 5, 1, 6 },
			{ 0, 1, 2, 6 },
			{ 0, 2, 3, 6 },
			{ 0, 3, 7, 6 },
			{ 0, 7, 4, 6 },
			{ 0, 4, 5, 6 }
		};

		public double LastBuildMilliseconds { get; private set; }

		public float EffectiveSpacing { get; private set; }

		private bool OverBudget()
		{
			return BudgetMilliseconds > 0f && timer.Elapsed.TotalMilliseconds > (double)BudgetMilliseconds;
		}

		private Vertex Edge(int a, int b, float iso)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			EdgeKey key = new EdgeKey(cornerKeys[a], cornerKeys[b]);
			if (edgeCache.TryGetValue(key, out var value))
			{
				return value;
			}
			float num = Mathf.Clamp01((iso - f[a]) / (f[b] - f[a]));
			Vertex vertex = default(Vertex);
			vertex.p = Vector3.Lerp(p[a], p[b], num);
			Vector3 val = Vector3.Lerp(n[a], n[b], num);
			vertex.n = ((Vector3)(ref val)).normalized;
			vertex.index = vertices.Count;
			vertices.Add(((Matrix4x4)(ref worldToLocal)).MultiplyPoint3x4(vertex.p));
			List<Vector3> list = normals;
			Vector3 val2 = ((Matrix4x4)(ref normalToLocal)).MultiplyVector(vertex.n);
			list.Add(((Vector3)(ref val2)).normalized);
			uv.Add(new Vector2(vertex.p.x, vertex.p.z));
			edgeCache[key] = vertex;
			return vertex;
		}

		private void Triangle(Vertex a, Vertex b, Vertex c, Transform transform)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.Cross(b.p - a.p, c.p - a.p);
			if (!(((Vector3)(ref val)).sqrMagnitude < 1E-18f))
			{
				if (Vector3.Dot(val, outward) < 0f)
				{
					Vertex vertex = b;
					b = c;
					c = vertex;
				}
				triangles.Add(a.index);
				triangles.Add(b.index);
				triangles.Add(c.index);
			}
		}

		public bool Build(List<Particle> particles, Mesh mesh, Transform transform, float spacing, float iso)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			worldToLocal = transform.worldToLocalMatrix;
			Matrix4x4 localToWorldMatrix = transform.localToWorldMatrix;
			normalToLocal = ((Matrix4x4)(ref localToWorldMatrix)).transpose;
			timer.Reset();
			timer.Start();
			bool flag = BuildField(particles, spacing, iso) && Polygonize(transform, spacing, iso);
			if (flag)
			{
				EffectiveSpacing = spacing;
				mesh.Clear();
				mesh.SetVertices(vertices);
				mesh.SetNormals(normals);
				mesh.SetUVs(0, uv);
				mesh.SetTriangles(triangles, 0);
				mesh.RecalculateBounds();
			}
			timer.Stop();
			LastBuildMilliseconds = timer.Elapsed.TotalMilliseconds;
			return flag;
		}

		private bool BuildField(List<Particle> particles, float spacing, float iso)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_039d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			field.Clear();
			cells.Clear();
			int num = 0;
			Vector3 val = default(Vector3);
			Vector3 val6 = default(Vector3);
			Vector3 val8 = default(Vector3);
			foreach (Particle particle in particles)
			{
				Vector3 scale = particle.scale;
				if (scale.x <= 0f || scale.y <= 0f || scale.z <= 0f)
				{
					continue;
				}
				bool flag = scale.x == scale.y && scale.y == scale.z;
				((Vector3)(ref val))..ctor(1f / (scale.x * scale.x), 1f / (scale.y * scale.y), 1f / (scale.z * scale.z));
				Vector3 position = particle.position;
				Quaternion val2 = Quaternion.Inverse(particle.rotation);
				Vector3 val3 = particle.rotation * new Vector3(scale.x, 0f, 0f);
				Vector3 val4 = particle.rotation * new Vector3(0f, scale.y, 0f);
				Vector3 val5 = particle.rotation * new Vector3(0f, 0f, scale.z);
				((Vector3)(ref val6))..ctor(Mathf.Sqrt(val3.x * val3.x + val4.x * val4.x + val5.x * val5.x), Mathf.Sqrt(val3.y * val3.y + val4.y * val4.y + val5.y * val5.y), Mathf.Sqrt(val3.z * val3.z + val4.z * val4.z + val5.z * val5.z));
				int num2 = Mathf.FloorToInt((position.x - val6.x) / spacing);
				int num3 = Mathf.CeilToInt((position.x + val6.x) / spacing);
				int num4 = Mathf.FloorToInt((position.y - val6.y) / spacing);
				int num5 = Mathf.CeilToInt((position.y + val6.y) / spacing);
				int num6 = Mathf.FloorToInt((position.z - val6.z) / spacing);
				int num7 = Mathf.CeilToInt((position.z + val6.z) / spacing);
				for (int i = num2; i <= num3; i++)
				{
					for (int j = num4; j <= num5; j++)
					{
						for (int k = num6; k <= num7; k++)
						{
							if ((++num & 0x3FF) == 0 && OverBudget())
							{
								return false;
							}
							Vector3 val7 = new Vector3((float)i, (float)j, (float)k) * spacing - position;
							if (!flag)
							{
								val7 = val2 * val7;
							}
							((Vector3)(ref val8))..ctor(val7.x * val.x, val7.y * val.y, val7.z * val.z);
							float num8 = Vector3.Dot(val7, val8);
							if (!(num8 >= 1f))
							{
								float num9 = 1f - num8;
								Key key = new Key(i, j, k);
								field.TryGetValue(key, out var value);
								value.value += num9 * num9 * num9;
								value.normal += ((!flag) ? (particle.rotation * val8) : val8) * (6f * num9 * num9);
								field[key] = value;
								if (field.Count > 160000)
								{
									return false;
								}
							}
						}
					}
				}
			}
			foreach (KeyValuePair<Key, Sample> item in field)
			{
				if (item.Value.value < iso)
				{
					continue;
				}
				Key key2 = item.Key;
				for (int l = -1; l <= 0; l++)
				{
					for (int m = -1; m <= 0; m++)
					{
						for (int n = -1; n <= 0; n++)
						{
							cells.Add(new Key(key2.x + l, key2.y + m, key2.z + n));
						}
					}
				}
				if (cells.Count <= 160000 && ((++num & 0xFF) != 0 || !OverBudget()))
				{
					continue;
				}
				return false;
			}
			return true;
		}

		private bool Polygonize(Transform transform, float spacing, float iso)
		{
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be