Decompiled source of Tunnel Safehouse v1.1.2

Tunnel_Safehouse.dll

Decompiled 11 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using Atlas;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using Sabresaurus.SabreCSG.ShapeEditor;
using Sabresaurus.SabreCSG.ShapeEditor.Decomposition;
using Sodalite.Api;
using Sodalite.Utilities;
using Technie.PhysicsCreator.QHull;
using UnityEditor;
using UnityEditor.Callbacks;
using UnityEditor.SceneManagement;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.Serialization;
using UnityEngine.UI;

[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 Sabresaurus.SabreCSG
{
	public abstract class CompoundBrush : BrushBase
	{
		[SerializeField]
		protected Bounds localBounds = new Bounds(Vector3.zero, new Vector3(2f, 2f, 2f));

		protected List<PrimitiveBrush> generatedBrushes = new List<PrimitiveBrush>();

		private CSGModelBase parentCsgModel;

		public abstract int BrushCount { get; }

		public override string BeautifulBrushName => ((object)this).GetType().Name;

		public CSGModelBase GetCSGModel()
		{
			if ((Object)(object)parentCsgModel == (Object)null)
			{
				CSGModelBase[] componentsInParent = ((Component)((Component)this).transform).GetComponentsInParent<CSGModelBase>(true);
				if (componentsInParent.Length > 0)
				{
					parentCsgModel = componentsInParent[0];
				}
			}
			return parentCsgModel;
		}

		protected virtual void Start()
		{
			generatedBrushes = new List<PrimitiveBrush>(((Component)this).GetComponentsInChildren<PrimitiveBrush>());
			for (int i = 0; i < generatedBrushes.Count; i++)
			{
				generatedBrushes[i].SetBrushController(this);
			}
		}

		public override void Invalidate(bool polygonsChanged)
		{
			base.Invalidate(polygonsChanged);
			generatedBrushes.RemoveAll((PrimitiveBrush item) => (Object)(object)item == (Object)null);
			if (generatedBrushes.Count > BrushCount)
			{
				for (int i = BrushCount; i < generatedBrushes.Count; i++)
				{
					if ((Object)(object)generatedBrushes[i] != (Object)null)
					{
						Object.DestroyImmediate((Object)(object)((Component)generatedBrushes[i]).gameObject);
					}
				}
				generatedBrushes.RemoveRange(BrushCount, generatedBrushes.Count - BrushCount);
			}
			else if (generatedBrushes.Count < BrushCount)
			{
				while (generatedBrushes.Count < BrushCount)
				{
					PrimitiveBrush primitiveBrush = CreateBrush();
					((Component)primitiveBrush).transform.SetParent(((Component)this).transform, false);
					primitiveBrush.SetBrushController(this);
					generatedBrushes.Add(primitiveBrush);
				}
			}
		}

		public override Bounds GetBounds()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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)
			return localBounds;
		}

		public override void SetBounds(Bounds newBounds)
		{
			//IL_0007: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			((Bounds)(ref localBounds)).center = Vector3.zero;
			((Bounds)(ref localBounds)).extents = ((Bounds)(ref newBounds)).extents;
			((Component)this).transform.Translate(((Bounds)(ref newBounds)).center);
		}

		public override Bounds GetBoundsTransformed()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_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_00ce: 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_00e9: 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_0076: 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_007c: 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_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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[8];
			for (int i = 0; i < 8; i++)
			{
				Vector3 center = ((Bounds)(ref localBounds)).center;
				Vector3 extents = ((Bounds)(ref localBounds)).extents;
				if (i % 2 == 0)
				{
					extents.x = 0f - extents.x;
				}
				if (i % 4 < 2)
				{
					extents.y = 0f - extents.y;
				}
				if (i % 8 < 4)
				{
					extents.z = 0f - extents.z;
				}
				center += extents;
				center = ((Component)this).transform.TransformPoint(center);
				array[i] = center;
			}
			Bounds result = default(Bounds);
			((Bounds)(ref result))..ctor(array[0], Vector3.zero);
			for (int j = 1; j < 8; j++)
			{
				((Bounds)(ref result)).Encapsulate(array[j]);
			}
			return result;
		}

		public override Bounds GetBoundsLocalTo(Transform otherTransform)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_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_00d4: 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_00ef: 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_0076: 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_007c: 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_0085: 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_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_00f6: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[8];
			for (int i = 0; i < 8; i++)
			{
				Vector3 center = ((Bounds)(ref localBounds)).center;
				Vector3 extents = ((Bounds)(ref localBounds)).extents;
				if (i % 2 == 0)
				{
					extents.x = 0f - extents.x;
				}
				if (i % 4 < 2)
				{
					extents.y = 0f - extents.y;
				}
				if (i % 8 < 4)
				{
					extents.z = 0f - extents.z;
				}
				center += extents;
				center = otherTransform.InverseTransformPoint(((Component)this).transform.TransformPoint(center));
				array[i] = center;
			}
			Bounds result = default(Bounds);
			((Bounds)(ref result))..ctor(array[0], Vector3.zero);
			for (int j = 1; j < 8; j++)
			{
				((Bounds)(ref result)).Encapsulate(array[j]);
			}
			return result;
		}

		public Polygon[] GetPolygons()
		{
			List<Polygon> list = new List<Polygon>();
			Brush[] componentsInChildren = ((Component)this).GetComponentsInChildren<Brush>();
			foreach (Brush brush in componentsInChildren)
			{
				list.AddRange(GenerateTransformedPolygons(((Component)brush).transform, brush.GetPolygons()));
			}
			return list.ToArray();
		}

		private Polygon[] GenerateTransformedPolygons(Transform t, Polygon[] polygons)
		{
			//IL_0009: 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_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_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)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			Polygon[] array = polygons.DeepCopy();
			Vector3 localPosition = t.localPosition;
			Quaternion localRotation = t.localRotation;
			Vector3 lossyScale = t.lossyScale;
			for (int i = 0; i < array.Length; i++)
			{
				for (int j = 0; j < array[i].Vertices.Length; j++)
				{
					array[i].Vertices[j].Position = localRotation * array[i].Vertices[j].Position.Multiply(lossyScale) + localPosition;
					array[i].Vertices[j].Normal = localRotation * array[i].Vertices[j].Normal;
				}
				array[i].CalculatePlane();
			}
			return array;
		}

		public virtual PrimitiveBrush CreateBrush()
		{
			//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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			return GetCSGModel().CreateBrush(PrimitiveBrushType.Cube, Vector3.zero, Vector3.one).GetComponent<PrimitiveBrush>();
		}

		public override void OnUndoRedoPerformed()
		{
			generatedBrushes = new List<PrimitiveBrush>(((Component)this).GetComponentsInChildren<PrimitiveBrush>());
			for (int i = 0; i < generatedBrushes.Count; i++)
			{
				generatedBrushes[i].SetBrushController(this);
			}
			Invalidate(polygonsChanged: true);
		}

		public static List<Type> FindAllInAssembly()
		{
			List<Type> list = new List<Type>();
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			Assembly[] array = assemblies;
			foreach (Assembly assembly in array)
			{
				if (!assembly.FullName.StartsWith("Assembly-CSharp"))
				{
					continue;
				}
				Type[] types = assembly.GetTypes();
				for (int j = 0; j < types.Length; j++)
				{
					if (!types[j].IsAbstract && types[j].IsSubclassOf(typeof(CompoundBrush)) && (object)types[j] != typeof(StairBrush) && (object)types[j] != typeof(CurvedStairBrush) && (object)types[j] != typeof(ShapeEditorBrush))
					{
						list.Add(types[j]);
					}
				}
			}
			return list;
		}
	}
	[ExecuteInEditMode]
	public class CurvedStairBrush : CompoundBrush
	{
		[SerializeField]
		private float innerRadius = 1f;

		[SerializeField]
		private float stepHeight = 0.0625f;

		[SerializeField]
		private float stepWidth = 1f;

		[SerializeField]
		private float angleOfCurve = 90f;

		[SerializeField]
		private int numSteps = 4;

		[SerializeField]
		private float addToFirstStep = 0f;

		[SerializeField]
		private bool counterClockwise = false;

		[SerializeField]
		private bool fillToBottom = true;

		[SerializeField]
		private bool curvedWall = false;

		[SerializeField]
		private bool slopedFloor = false;

		[SerializeField]
		private bool slopedCeiling = false;

		private Vector3 m_LastKnownExtents;

		private Vector3 m_LastKnownPosition;

		public float InnerRadius
		{
			get
			{
				return innerRadius;
			}
			set
			{
				innerRadius = value;
			}
		}

		public float StepHeight
		{
			get
			{
				return stepHeight;
			}
			set
			{
				stepHeight = value;
			}
		}

		public float StepWidth
		{
			get
			{
				return stepWidth;
			}
			set
			{
				stepWidth = value;
			}
		}

		public float AngleOfCurve
		{
			get
			{
				return angleOfCurve;
			}
			set
			{
				angleOfCurve = value;
			}
		}

		public int NumberOfSteps
		{
			get
			{
				return numSteps;
			}
			set
			{
				numSteps = value;
			}
		}

		public float AddToFirstStep
		{
			get
			{
				return addToFirstStep;
			}
			set
			{
				addToFirstStep = value;
			}
		}

		public bool CounterClockwise
		{
			get
			{
				return counterClockwise;
			}
			set
			{
				counterClockwise = value;
			}
		}

		public bool FillToBottom
		{
			get
			{
				return fillToBottom;
			}
			set
			{
				fillToBottom = value;
			}
		}

		public bool CurvedWall
		{
			get
			{
				return curvedWall;
			}
			set
			{
				curvedWall = value;
			}
		}

		public bool SlopedFloor
		{
			get
			{
				return slopedFloor;
			}
			set
			{
				slopedFloor = value;
			}
		}

		public bool SlopedCeiling
		{
			get
			{
				return slopedCeiling;
			}
			set
			{
				slopedCeiling = value;
			}
		}

		public override string BeautifulBrushName => "Curved Stairs Brush";

		public override int BrushCount => numSteps;

		protected override void Awake()
		{
			//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_001f: 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)
			base.Awake();
			m_LastKnownExtents = ((Bounds)(ref localBounds)).extents;
			m_LastKnownPosition = ((Component)this).transform.localPosition;
		}

		public override void UpdateVisibility()
		{
		}

		public override void Invalidate(bool polygonsChanged)
		{
			//IL_0009: 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_00ef: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_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_006e: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_0177: 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_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_01a3: 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_0268: 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_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: 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_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: 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_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e4c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e51: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e5d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e62: Unknown result type (might be due to invalid IL or missing references)
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_0535: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_054e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_057d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0582: Unknown result type (might be due to invalid IL or missing references)
			//IL_0690: Unknown result type (might be due to invalid IL or missing references)
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06be: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_070f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0714: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_0642: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_0657: Unknown result type (might be due to invalid IL or missing references)
			//IL_065c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_072c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0741: Unknown result type (might be due to invalid IL or missing references)
			//IL_0746: Unknown result type (might be due to invalid IL or missing references)
			//IL_074b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0756: Unknown result type (might be due to invalid IL or missing references)
			//IL_076b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0770: Unknown result type (might be due to invalid IL or missing references)
			//IL_0775: Unknown result type (might be due to invalid IL or missing references)
			//IL_081a: Unknown result type (might be due to invalid IL or missing references)
			//IL_082f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0834: Unknown result type (might be due to invalid IL or missing references)
			//IL_0839: Unknown result type (might be due to invalid IL or missing references)
			//IL_084d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0852: Unknown result type (might be due to invalid IL or missing references)
			//IL_0866: Unknown result type (might be due to invalid IL or missing references)
			//IL_086b: Unknown result type (might be due to invalid IL or missing references)
			//IL_087f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0894: Unknown result type (might be due to invalid IL or missing references)
			//IL_0899: Unknown result type (might be due to invalid IL or missing references)
			//IL_089e: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0902: Unknown result type (might be due to invalid IL or missing references)
			//IL_0907: Unknown result type (might be due to invalid IL or missing references)
			//IL_090c: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_09df: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a12: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a17: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a35: Unknown result type (might be due to invalid IL or missing references)
			//IL_094c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0951: Unknown result type (might be due to invalid IL or missing references)
			//IL_0963: Unknown result type (might be due to invalid IL or missing references)
			//IL_0968: Unknown result type (might be due to invalid IL or missing references)
			//IL_0978: Unknown result type (might be due to invalid IL or missing references)
			//IL_097d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0991: Unknown result type (might be due to invalid IL or missing references)
			//IL_0996: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a58: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a99: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b42: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b57: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b61: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b94: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bdb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bfa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0adf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0afb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b12: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c36: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c6f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c74: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c79: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d35: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d58: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d6c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d85: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d9a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d9f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cbc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d00: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e23: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dcc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de7: Unknown result type (might be due to invalid IL or missing references)
			base.Invalidate(polygonsChanged);
			if (m_LastKnownExtents != ((Bounds)(ref localBounds)).extents)
			{
				((Component)this).transform.localPosition = m_LastKnownPosition;
				if (((Bounds)(ref localBounds)).extents.y > m_LastKnownExtents.y)
				{
					numSteps++;
					m_LastKnownExtents = ((Bounds)(ref localBounds)).extents;
					Invalidate(polygonsChanged: true);
					return;
				}
				if (((Bounds)(ref localBounds)).extents.y < m_LastKnownExtents.y)
				{
					numSteps--;
					if (numSteps < 1)
					{
						numSteps = 1;
					}
					m_LastKnownExtents = ((Bounds)(ref localBounds)).extents;
					Invalidate(polygonsChanged: true);
					return;
				}
			}
			List<Vector3> list = new List<Vector3>();
			Vector3 val = default(Vector3);
			Vector3 val2 = default(Vector3);
			Vector3 val3 = default(Vector3);
			val.z = angleOfCurve / (float)numSteps;
			if (counterClockwise)
			{
				val.z *= -1f;
			}
			int count = list.Count;
			val2.x = innerRadius;
			for (int i = 0; i < numSteps + 1; i++)
			{
				float num = ((i != 0) ? 0f : addToFirstStep);
				val3 = Quaternion.Euler(val * (float)i) * val2;
				list.Add(new Vector3(val3.x, val2.z - num, val3.y));
				if (curvedWall)
				{
					val2.z = stepHeight * (float)numSteps;
				}
				else
				{
					val2.z += stepHeight;
				}
				list.Add(new Vector3(val3.x, val2.z, val3.y));
			}
			int count2 = list.Count;
			val2.x = innerRadius + stepWidth;
			val2.z = 0f;
			for (int j = 0; j < numSteps + 1; j++)
			{
				float num = ((j != 0) ? 0f : addToFirstStep);
				val3 = Quaternion.Euler(val * (float)j) * val2;
				list.Add(new Vector3(val3.x, val2.z - num, val3.y));
				if (curvedWall)
				{
					val2.z = stepHeight * (float)numSteps;
				}
				else
				{
					val2.z += stepHeight;
				}
				list.Add(new Vector3(val3.x, val2.z, val3.y));
			}
			int count3 = list.Count;
			val2.x = innerRadius;
			val2.z = 0f;
			for (int k = 0; k < numSteps + 1; k++)
			{
				val3 = Quaternion.Euler(val * (float)k) * val2;
				list.Add(new Vector3(val3.x, val2.z - addToFirstStep, val3.y));
			}
			int count4 = list.Count;
			val2.x = innerRadius + stepWidth;
			for (int l = 0; l < numSteps + 1; l++)
			{
				val3 = Quaternion.Euler(val * (float)l) * val2;
				list.Add(new Vector3(val3.x, val2.z - addToFirstStep, val3.y));
			}
			int num2 = 0;
			int num3 = 1;
			int num4 = 2;
			int num5 = 3;
			if (counterClockwise)
			{
				num2 = 2;
				num3 = 1;
				num4 = 0;
				num5 = 3;
			}
			if (curvedWall)
			{
				slopedFloor = false;
				slopedCeiling = false;
			}
			if (fillToBottom)
			{
				slopedCeiling = false;
			}
			if (slopedFloor || slopedCeiling)
			{
				base.IsNoCSG = true;
			}
			Bounds val4 = default(Bounds);
			int brushCount = BrushCount;
			for (int m = 0; m < brushCount; m++)
			{
				generatedBrushes[m].Mode = base.Mode;
				generatedBrushes[m].IsNoCSG = base.IsNoCSG;
				generatedBrushes[m].IsVisible = base.IsVisible;
				generatedBrushes[m].HasCollision = base.HasCollision;
				Polygon[] polygons = generatedBrushes[m].GetPolygons();
				Vertex[] vertices = polygons[5].Vertices;
				if (slopedFloor)
				{
					vertices[num2].Position = list[count2 + m * 2 + 2 + 1];
					vertices[num3].Position = list[count2 + m * 2 + 1];
					vertices[num4].Position = list[count + m * 2 + 1];
					vertices[num5].Position = list[count + m * 2 + 2 + 1];
				}
				else
				{
					vertices[num2].Position = list[count2 + m * 2 + 2];
					vertices[num3].Position = list[count2 + m * 2 + 1];
					vertices[num4].Position = list[count + m * 2 + 1];
					vertices[num5].Position = list[count + m * 2 + 2];
				}
				GenerateNormals(polygons[5]);
				GenerateUvCoordinates(polygons[5]);
				vertices = polygons[3].Vertices;
				if (fillToBottom)
				{
					vertices[num2].Position = list[count2 + m * 2 + 1];
					vertices[num3].Position = list[count4 + m];
					vertices[num4].Position = list[count3 + m];
					vertices[num5].Position = list[count + m * 2 + 1];
				}
				else
				{
					vertices[num2].Position = list[count2 + m * 2 + 1];
					vertices[num3].Position = list[count2 + m * 2 + 1] - new Vector3(0f, stepHeight, 0f);
					vertices[num4].Position = list[count + m * 2 + 1] - new Vector3(0f, stepHeight, 0f);
					vertices[num5].Position = list[count + m * 2 + 1];
				}
				if (slopedCeiling)
				{
					Vertex obj = vertices[num3];
					obj.Position -= new Vector3(0f, stepHeight, 0f);
					Vertex obj2 = vertices[num4];
					obj2.Position -= new Vector3(0f, stepHeight, 0f);
				}
				GenerateNormals(polygons[3]);
				GenerateUvCoordinates(polygons[3]);
				vertices = polygons[1].Vertices;
				if (fillToBottom)
				{
					vertices[num2].Position = list[count3 + m + 1];
					vertices[num3].Position = list[count + m * 2 + 2];
					vertices[num4].Position = list[count + m * 2 + 1];
					vertices[num5].Position = list[count3 + m];
				}
				else
				{
					vertices[num2].Position = list[count + m * 2 + 2] - new Vector3(0f, stepHeight, 0f);
					vertices[num3].Position = list[count + m * 2 + 2];
					vertices[num4].Position = list[count + m * 2 + 1];
					vertices[num5].Position = list[count + m * 2 + 1] - new Vector3(0f, stepHeight, 0f);
				}
				if (slopedFloor)
				{
					vertices[num3].Position = list[count + m * 2 + 2 + 1];
				}
				if (slopedCeiling)
				{
					vertices[num5].Position = list[count + m * 2 + 1] - new Vector3(0f, stepHeight * 2f, 0f);
				}
				GenerateNormals(polygons[1]);
				GenerateUvCoordinates(polygons[1]);
				vertices = polygons[2].Vertices;
				if (fillToBottom)
				{
					vertices[num2].Position = list[count2 + m * 2 + 2];
					vertices[num3].Position = list[count4 + m + 1];
					vertices[num4].Position = list[count4 + m];
					vertices[num5].Position = list[count2 + m * 2 + 1];
				}
				else
				{
					vertices[num2].Position = list[count2 + m * 2 + 2];
					vertices[num3].Position = list[count2 + m * 2 + 2] - new Vector3(0f, stepHeight, 0f);
					vertices[num4].Position = list[count2 + m * 2 + 1] - new Vector3(0f, stepHeight, 0f);
					vertices[num5].Position = list[count2 + m * 2 + 1];
				}
				if (slopedFloor)
				{
					vertices[num2].Position = list[count2 + m * 2 + 2 + 1];
				}
				if (slopedCeiling)
				{
					vertices[num4].Position = list[count2 + m * 2 + 1] - new Vector3(0f, stepHeight * 2f, 0f);
				}
				GenerateNormals(polygons[2]);
				GenerateUvCoordinates(polygons[2]);
				vertices = polygons[4].Vertices;
				if (fillToBottom)
				{
					vertices[num2].Position = list[count4 + m];
					vertices[num3].Position = list[count4 + m + 1];
					vertices[num4].Position = list[count3 + m + 1];
					vertices[num5].Position = list[count3 + m];
				}
				else
				{
					vertices[num2].Position = list[count2 + m * 2 + 1] - new Vector3(0f, stepHeight, 0f);
					vertices[num3].Position = list[count2 + m * 2 + 2] - new Vector3(0f, stepHeight, 0f);
					vertices[num4].Position = list[count + m * 2 + 2] - new Vector3(0f, stepHeight, 0f);
					vertices[num5].Position = list[count + m * 2 + 1] - new Vector3(0f, stepHeight, 0f);
				}
				if (slopedCeiling)
				{
					vertices[num2].Position = list[count2 + m * 2 + 1] - new Vector3(0f, stepHeight * 2f, 0f);
					vertices[num5].Position = list[count + m * 2 + 1] - new Vector3(0f, stepHeight * 2f, 0f);
				}
				GenerateNormals(polygons[4]);
				GenerateUvCoordinates(polygons[4]);
				vertices = polygons[0].Vertices;
				if (fillToBottom)
				{
					vertices[num2].Position = list[count4 + m + 1];
					vertices[num3].Position = list[count2 + m * 2 + 2];
					vertices[num4].Position = list[count + m * 2 + 2];
					vertices[num5].Position = list[count3 + m + 1];
				}
				else
				{
					vertices[num2].Position = list[count2 + m * 2 + 2] - new Vector3(0f, stepHeight, 0f);
					vertices[num3].Position = list[count2 + m * 2 + 2];
					vertices[num4].Position = list[count + m * 2 + 2];
					vertices[num5].Position = list[count + m * 2 + 2] - new Vector3(0f, stepHeight, 0f);
				}
				if (slopedFloor)
				{
					vertices[num3].Position = list[count2 + m * 2 + 2 + 1];
					vertices[num4].Position = list[count + m * 2 + 2 + 1];
				}
				GenerateNormals(polygons[0]);
				GenerateUvCoordinates(polygons[0]);
				generatedBrushes[m].Invalidate(polygonsChanged: true);
				((Bounds)(ref val4)).Encapsulate(generatedBrushes[m].GetBounds());
			}
			localBounds = val4;
			m_LastKnownExtents = ((Bounds)(ref localBounds)).extents;
			m_LastKnownPosition = ((Component)this).transform.localPosition;
			UpdateGeneratedHierarchyName();
		}

		private void GenerateUvCoordinates(Polygon polygon)
		{
			//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)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			Vertex[] vertices = polygon.Vertices;
			foreach (Vertex vertex in vertices)
			{
				vertex.UV = GeometryHelper.GetUVForPosition(polygon, vertex.Position);
			}
		}

		private void GenerateNormals(Polygon polygon)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0045: 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)
			Plane val = default(Plane);
			((Plane)(ref val))..ctor(polygon.Vertices[1].Position, polygon.Vertices[2].Position, polygon.Vertices[3].Position);
			Vertex[] vertices = polygon.Vertices;
			foreach (Vertex vertex in vertices)
			{
				vertex.Normal = ((Plane)(ref val)).normal;
			}
		}
	}
	[ExecuteInEditMode]
	public class HollowBoxBrush : CompoundBrush
	{
		[SerializeField]
		private float wallThickness = 0.25f;

		public float WallThickness
		{
			get
			{
				return wallThickness;
			}
			set
			{
				wallThickness = value;
			}
		}

		public override string BeautifulBrushName => "Hollow Box Brush";

		public override int BrushCount => (!IsBrushXYZTooSmall) ? 1 : 2;

		public bool IsBrushXYZTooSmall => ((Bounds)(ref localBounds)).size.x > wallThickness * 2f && ((Bounds)(ref localBounds)).size.z > wallThickness * 2f && ((Bounds)(ref localBounds)).size.y > wallThickness * 2f;

		public override void UpdateVisibility()
		{
		}

		public override void Invalidate(bool polygonsChanged)
		{
			//IL_0170: 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_00db: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			base.Invalidate(polygonsChanged);
			for (int i = 0; i < BrushCount; i++)
			{
				generatedBrushes[i].Mode = base.Mode;
				generatedBrushes[i].IsNoCSG = base.IsNoCSG;
				generatedBrushes[i].IsVisible = base.IsVisible;
				generatedBrushes[i].HasCollision = base.HasCollision;
			}
			if (IsBrushXYZTooSmall)
			{
				generatedBrushes[0].Mode = CSGMode.Add;
				BrushUtility.Resize(generatedBrushes[0], ((Bounds)(ref localBounds)).size);
				generatedBrushes[1].Mode = CSGMode.Subtract;
				BrushUtility.Resize(generatedBrushes[1], ((Bounds)(ref localBounds)).size - new Vector3(wallThickness * 2f, wallThickness * 2f, wallThickness * 2f));
				for (int j = 0; j < BrushCount; j++)
				{
					generatedBrushes[j].SetPolygons(GeneratePolys(j));
					generatedBrushes[j].Invalidate(polygonsChanged: true);
				}
			}
			else
			{
				BrushUtility.Resize(generatedBrushes[0], ((Bounds)(ref localBounds)).size);
			}
		}

		private Polygon[] GeneratePolys(int index)
		{
			Polygon[] polygons = generatedBrushes[index].GetPolygons();
			for (int i = 0; i < 6; i++)
			{
				polygons[i].ResetVertexNormals();
				polygons[i].GenerateUvCoordinates();
			}
			return polygons;
		}
	}
}
namespace Sabresaurus.SabreCSG.ShapeEditor
{
	public static class Bezier
	{
		public static Vector3 GetPoint(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, float t)
		{
			//IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0048: 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_0056: 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_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)
			t = Mathf.Clamp01(t);
			float num = 1f - t;
			return num * num * num * p0 + 3f * num * num * t * p1 + 3f * num * t * t * p2 + t * t * t * p3;
		}

		public static Vector3 GetPoint(Vector3 p0, Vector3 p1, Vector3 p2, float t)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			t = Mathf.Clamp01(t);
			float num = 1f - t;
			return num * num * p0 + 2f * num * t * p1 + t * t * p2;
		}
	}
}
namespace Sabresaurus.SabreCSG.ShapeEditor.Decomposition
{
	public static class BayazitDecomposer
	{
		private static class MathUtils
		{
			public static float Area(Vector2 a, Vector2 b, Vector2 c)
			{
				return Area(ref a, ref b, ref c);
			}

			public static float Area(ref Vector2 a, ref Vector2 b, ref Vector2 c)
			{
				return a.x * (b.y - c.y) + b.x * (c.y - a.y) + c.x * (a.y - b.y);
			}

			public static bool FloatEquals(float value1, float value2)
			{
				return Math.Abs(value1 - value2) <= SettingsEpsilon;
			}

			public static bool Collinear(ref Vector2 a, ref Vector2 b, ref Vector2 c)
			{
				return Collinear(ref a, ref b, ref c, 0f);
			}

			public static bool Collinear(ref Vector2 a, ref Vector2 b, ref Vector2 c, float tolerance)
			{
				return FloatInRange(Area(ref a, ref b, ref c), 0f - tolerance, tolerance);
			}

			public static bool FloatInRange(float value, float min, float max)
			{
				return value >= min && value <= max;
			}

			public static int NextIndex(Vector2[] vertices, int index)
			{
				return (index + 1 <= vertices.Length - 1) ? (index + 1) : 0;
			}

			public static int PreviousIndex(Vector2[] vertices, int index)
			{
				return (index - 1 >= 0) ? (index - 1) : (vertices.Length - 1);
			}
		}

		private static class LineTools
		{
			public static Vector2 LineIntersect(Vector2 p1, Vector2 p2, Vector2 q1, Vector2 q2)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
				Vector2 zero = Vector2.zero;
				float num = p2.y - p1.y;
				float num2 = p1.x - p2.x;
				float num3 = num * p1.x + num2 * p1.y;
				float num4 = q2.y - q1.y;
				float num5 = q1.x - q2.x;
				float num6 = num4 * q1.x + num5 * q1.y;
				float num7 = num * num5 - num4 * num2;
				if (!MathUtils.FloatEquals(num7, 0f))
				{
					zero.x = (num5 * num3 - num2 * num6) / num7;
					zero.y = (num * num6 - num4 * num3) / num7;
				}
				return zero;
			}

			public static bool LineIntersect(Vector2 point1, Vector2 point2, Vector2 point3, Vector2 point4, out Vector2 intersectionPoint)
			{
				return LineIntersect(ref point1, ref point2, ref point3, ref point4, firstIsSegment: true, secondIsSegment: true, out intersectionPoint);
			}

			public static bool LineIntersect(Vector2 point1, Vector2 point2, Vector2 point3, Vector2 point4, bool firstIsSegment, bool secondIsSegment, out Vector2 intersectionPoint)
			{
				return LineIntersect(ref point1, ref point2, ref point3, ref point4, firstIsSegment, secondIsSegment, out intersectionPoint);
			}

			public static bool LineIntersect(ref Vector2 point1, ref Vector2 point2, ref Vector2 point3, ref Vector2 point4, bool firstIsSegment, bool secondIsSegment, out Vector2 point)
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				point = default(Vector2);
				float num = point4.y - point3.y;
				float num2 = point2.x - point1.x;
				float num3 = point4.x - point3.x;
				float num4 = point2.y - point1.y;
				float num5 = num * num2 - num3 * num4;
				if (!(num5 >= 0f - SettingsEpsilon) || !(num5 <= SettingsEpsilon))
				{
					float num6 = point1.y - point3.y;
					float num7 = point1.x - point3.x;
					float num8 = 1f / num5;
					float num9 = num3 * num6 - num * num7;
					num9 *= num8;
					if (!firstIsSegment || (num9 >= 0f && num9 <= 1f))
					{
						float num10 = num2 * num6 - num4 * num7;
						num10 *= num8;
						if ((!secondIsSegment || (num10 >= 0f && num10 <= 1f)) && (num9 != 0f || num10 != 0f))
						{
							point.x = point1.x + num9 * num2;
							point.y = point1.y + num9 * num4;
							return true;
						}
					}
				}
				return false;
			}
		}

		private static class SimplifyTools
		{
			public static Vector2[] CollinearSimplify(Vector2[] vertices, float collinearityTolerance)
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: 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_004a: 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_0059: 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)
				if (vertices.Length < 3)
				{
					return vertices;
				}
				List<Vector2> list = new List<Vector2>();
				for (int i = 0; i < vertices.Length; i++)
				{
					int num = MathUtils.PreviousIndex(vertices, i);
					int num2 = MathUtils.NextIndex(vertices, i);
					Vector2 a = vertices[num];
					Vector2 b = vertices[i];
					Vector2 c = vertices[num2];
					if (!MathUtils.Collinear(ref a, ref b, ref c, collinearityTolerance))
					{
						list.Add(b);
					}
				}
				return list.ToArray();
			}
		}

		public static float SettingsEpsilon = 0.0001f;

		public static int MaxPolygonVertices = 1024;

		private static Vector2 At(int i, Vector2[] vertices)
		{
			//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_002b: Unknown result type (might be due to invalid IL or missing references)
			int num = vertices.Length;
			return vertices[(i >= 0) ? (i % num) : (num - -i % num)];
		}

		private static Vector2[] Copy(int i, int j, Vector2[] vertices)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			List<Vector2> list = new List<Vector2>();
			while (j < i)
			{
				j += vertices.Length;
			}
			while (i <= j)
			{
				list.Add(At(i, vertices));
				i++;
			}
			return list.ToArray();
		}

		public static List<Vector2[]> ConvexPartition(Vector2[] vertices)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0052: 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_0104: 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_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_01da: 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_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: 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_0132: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00af: 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_00c0: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: 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_015f: 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_016e: 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_017a: 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_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: 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_00f6: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: 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_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: 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_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			List<Vector2[]> list = new List<Vector2[]>();
			Vector2 val = default(Vector2);
			Vector2 val2 = default(Vector2);
			int num = 0;
			int i = 0;
			for (int j = 0; j < vertices.Length; j++)
			{
				if (!Reflex(j, vertices))
				{
					continue;
				}
				float num2;
				float num3 = (num2 = float.MaxValue);
				for (int k = 0; k < vertices.Length; k++)
				{
					Vector2 val3;
					if (Left(At(j - 1, vertices), At(j, vertices), At(k, vertices)) && RightOn(At(j - 1, vertices), At(j, vertices), At(k - 1, vertices)))
					{
						val3 = LineTools.LineIntersect(At(j - 1, vertices), At(j, vertices), At(k, vertices), At(k - 1, vertices));
						if (Right(At(j + 1, vertices), At(j, vertices), val3))
						{
							float num4 = SquareDist(At(j, vertices), val3);
							if (num4 < num3)
							{
								num3 = num4;
								val = val3;
								num = k;
							}
						}
					}
					if (!Left(At(j + 1, vertices), At(j, vertices), At(k + 1, vertices)) || !RightOn(At(j + 1, vertices), At(j, vertices), At(k, vertices)))
					{
						continue;
					}
					val3 = LineTools.LineIntersect(At(j + 1, vertices), At(j, vertices), At(k, vertices), At(k + 1, vertices));
					if (Left(At(j - 1, vertices), At(j, vertices), val3))
					{
						float num4 = SquareDist(At(j, vertices), val3);
						if (num4 < num2)
						{
							num2 = num4;
							i = k;
							val2 = val3;
						}
					}
				}
				List<Vector2> list2;
				List<Vector2> list3;
				if (num == (i + 1) % vertices.Length)
				{
					Vector2 item = (val + val2) / 2f;
					list2 = Copy(j, i, vertices).ToList();
					list2.Add(item);
					list3 = Copy(num, j, vertices).ToList();
					list3.Add(item);
				}
				else
				{
					double num5 = 0.0;
					double num6 = num;
					for (; i < num; i += vertices.Length)
					{
					}
					for (int l = num; l <= i; l++)
					{
						if (CanSee(j, l, vertices))
						{
							double num7 = 1f / (SquareDist(At(j, vertices), At(l, vertices)) + 1f);
							num7 = ((!Reflex(l, vertices)) ? (num7 + 1.0) : ((!RightOn(At(l - 1, vertices), At(l, vertices), At(j, vertices)) || !LeftOn(At(l + 1, vertices), At(l, vertices), At(j, vertices))) ? (num7 + 2.0) : (num7 + 3.0)));
							if (num7 > num5)
							{
								num6 = l;
								num5 = num7;
							}
						}
					}
					list2 = Copy(j, (int)num6, vertices).ToList();
					list3 = Copy((int)num6, j, vertices).ToList();
				}
				list.AddRange(ConvexPartition(list2.ToArray()));
				list.AddRange(ConvexPartition(list3.ToArray()));
				return list;
			}
			if (vertices.Length > MaxPolygonVertices)
			{
				List<Vector2> list2 = Copy(0, vertices.Length / 2, vertices).ToList();
				List<Vector2> list3 = Copy(vertices.Length / 2, 0, vertices).ToList();
				list.AddRange(ConvexPartition(list2.ToArray()));
				list.AddRange(ConvexPartition(list3.ToArray()));
			}
			else
			{
				list.Add(vertices);
			}
			for (int m = 0; m < list.Count; m++)
			{
				list[m] = SimplifyTools.CollinearSimplify(list[m], 0f);
			}
			for (int num8 = list.Count - 1; num8 >= 0; num8--)
			{
				if (list[num8].Length == 0)
				{
					list.RemoveAt(num8);
				}
			}
			return list;
		}

		private static bool CanSee(int i, int j, Vector2[] vertices)
		{
			//IL_0060: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0020: 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_008a: 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_0031: 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_0041: 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_0110: 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_00b7: 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_00c7: 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_0131: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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_0187: 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_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			if (Reflex(i, vertices))
			{
				if (LeftOn(At(i, vertices), At(i - 1, vertices), At(j, vertices)) && RightOn(At(i, vertices), At(i + 1, vertices), At(j, vertices)))
				{
					return false;
				}
			}
			else if (RightOn(At(i, vertices), At(i + 1, vertices), At(j, vertices)) || LeftOn(At(i, vertices), At(i - 1, vertices), At(j, vertices)))
			{
				return false;
			}
			if (Reflex(j, vertices))
			{
				if (LeftOn(At(j, vertices), At(j - 1, vertices), At(i, vertices)) && RightOn(At(j, vertices), At(j + 1, vertices), At(i, vertices)))
				{
					return false;
				}
			}
			else if (RightOn(At(j, vertices), At(j + 1, vertices), At(i, vertices)) || LeftOn(At(j, vertices), At(j - 1, vertices), At(i, vertices)))
			{
				return false;
			}
			for (int k = 0; k < vertices.Length; k++)
			{
				if ((k + 1) % vertices.Length != i && k != i && (k + 1) % vertices.Length != j && k != j && LineTools.LineIntersect(At(i, vertices), At(j, vertices), At(k, vertices), At(k + 1, vertices), out var _))
				{
					return false;
				}
			}
			return true;
		}

		private static bool Reflex(int i, Vector2[] vertices)
		{
			return Right(i, vertices);
		}

		private static bool Right(int i, Vector2[] vertices)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			return Right(At(i - 1, vertices), At(i, vertices), At(i + 1, vertices));
		}

		private static bool Left(Vector2 a, Vector2 b, Vector2 c)
		{
			return MathUtils.Area(ref a, ref b, ref c) > 0f;
		}

		private static bool LeftOn(Vector2 a, Vector2 b, Vector2 c)
		{
			return MathUtils.Area(ref a, ref b, ref c) >= 0f;
		}

		private static bool Right(Vector2 a, Vector2 b, Vector2 c)
		{
			return MathUtils.Area(ref a, ref b, ref c) < 0f;
		}

		private static bool RightOn(Vector2 a, Vector2 b, Vector2 c)
		{
			return MathUtils.Area(ref a, ref b, ref c) <= 0f;
		}

		private static float SquareDist(Vector2 a, Vector2 b)
		{
			float num = b.x - a.x;
			float num2 = b.y - a.y;
			return num * num + num2 * num2;
		}
	}
	public static class SeidelDecomposer
	{
		public static List<Vector2[]> ConvexPartition(Vector2[] vertices, float sheer)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			List<Point> list = new List<Point>(vertices.Length);
			for (int i = 0; i < vertices.Length; i++)
			{
				Vector2 val = vertices[i];
				list.Add(new Point(val.x, val.y));
			}
			Triangulator triangulator = new Triangulator(list, sheer);
			List<Vector2[]> list2 = new List<Vector2[]>();
			foreach (List<Point> triangle in triangulator.Triangles)
			{
				List<Vector2> list3 = new List<Vector2>(triangle.Count);
				foreach (Point item in triangle)
				{
					list3.Add(new Vector2(item.X, item.Y));
				}
				list2.Add(list3.ToArray());
			}
			return list2;
		}

		public static List<Vector2[]> ConvexPartitionTrapezoid(Vector2[] vertices, float sheer)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			List<Point> list = new List<Point>(vertices.Length);
			for (int i = 0; i < vertices.Length; i++)
			{
				Vector2 val = vertices[i];
				list.Add(new Point(val.x, val.y));
			}
			Triangulator triangulator = new Triangulator(list, sheer);
			List<Vector2[]> list2 = new List<Vector2[]>();
			foreach (Trapezoid trapezoid in triangulator.Trapezoids)
			{
				List<Vector2> list3 = new List<Vector2>();
				List<Point> list4 = trapezoid.Vertices();
				foreach (Point item in list4)
				{
					list3.Add(new Vector2(item.X, item.Y));
				}
				list2.Add(list3.ToArray());
			}
			return list2;
		}
	}
	internal class MonotoneMountain
	{
		private const float PiSlop = 3.1f;

		public List<List<Point>> Triangles;

		private HashSet<Point> _convexPoints;

		private Point _head;

		private List<Point> _monoPoly;

		private bool _positive;

		private int _size;

		private Point _tail;

		public MonotoneMountain()
		{
			_size = 0;
			_tail = null;
			_head = null;
			_positive = false;
			_convexPoints = new HashSet<Point>();
			_monoPoly = new List<Point>();
			Triangles = new List<List<Point>>();
		}

		public void Add(Point point)
		{
			if (_size == 0)
			{
				_head = point;
				_size = 1;
			}
			else if (_size == 1)
			{
				_tail = point;
				_tail.Prev = _head;
				_head.Next = _tail;
				_size = 2;
			}
			else
			{
				_tail.Next = point;
				point.Prev = _tail;
				_tail = point;
				_size++;
			}
		}

		public void Remove(Point point)
		{
			Point next = point.Next;
			Point prev = point.Prev;
			point.Prev.Next = next;
			point.Next.Prev = prev;
			_size--;
		}

		public void Process()
		{
			_positive = AngleSign();
			GenMonoPoly();
			Point next = _head.Next;
			while (next.Neq(_tail))
			{
				float num = Angle(next);
				if (num >= 3.1f || num <= -3.1f || (double)num == 0.0)
				{
					Remove(next);
				}
				else if (IsConvex(next))
				{
					_convexPoints.Add(next);
				}
				next = next.Next;
			}
			Triangulate();
		}

		private void Triangulate()
		{
			while (_convexPoints.Count != 0)
			{
				IEnumerator<Point> enumerator = _convexPoints.GetEnumerator();
				enumerator.MoveNext();
				Point current = enumerator.Current;
				_convexPoints.Remove(current);
				Point prev = current.Prev;
				Point item = current;
				Point next = current.Next;
				List<Point> list = new List<Point>(3);
				list.Add(prev);
				list.Add(item);
				list.Add(next);
				Triangles.Add(list);
				Remove(current);
				if (Valid(prev))
				{
					_convexPoints.Add(prev);
				}
				if (Valid(next))
				{
					_convexPoints.Add(next);
				}
			}
			Debug.Assert(_size <= 3, "Triangulation bug, please report");
		}

		private bool Valid(Point p)
		{
			return p.Neq(_head) && p.Neq(_tail) && IsConvex(p);
		}

		private void GenMonoPoly()
		{
			for (Point point = _head; point != null; point = point.Next)
			{
				_monoPoly.Add(point);
			}
		}

		private float Angle(Point p)
		{
			Point point = p.Next - p;
			Point p2 = p.Prev - p;
			return (float)Math.Atan2(point.Cross(p2), point.Dot(p2));
		}

		private bool AngleSign()
		{
			Point point = _head.Next - _head;
			Point p = _tail - _head;
			return Math.Atan2(point.Cross(p), point.Dot(p)) >= 0.0;
		}

		private bool IsConvex(Point p)
		{
			if (_positive != Angle(p) >= 0f)
			{
				return false;
			}
			return true;
		}
	}
	internal abstract class Node
	{
		protected Node LeftChild;

		public List<Node> ParentList;

		protected Node RightChild;

		protected Node(Node left, Node right)
		{
			ParentList = new List<Node>();
			LeftChild = left;
			RightChild = right;
			left?.ParentList.Add(this);
			right?.ParentList.Add(this);
		}

		public abstract Sink Locate(Edge s);

		public void Replace(Node node)
		{
			foreach (Node parent in node.ParentList)
			{
				if (parent.LeftChild == node)
				{
					parent.LeftChild = this;
				}
				else
				{
					parent.RightChild = this;
				}
			}
			ParentList.AddRange(node.ParentList);
		}
	}
	internal class QueryGraph
	{
		private Node _head;

		public QueryGraph(Node head)
		{
			_head = head;
		}

		private Trapezoid Locate(Edge edge)
		{
			return _head.Locate(edge).Trapezoid;
		}

		public List<Trapezoid> FollowEdge(Edge edge)
		{
			List<Trapezoid> list = new List<Trapezoid>();
			list.Add(Locate(edge));
			for (int i = 0; edge.Q.X > list[i].RightPoint.X; i++)
			{
				if (edge.IsAbove(list[i].RightPoint))
				{
					list.Add(list[i].UpperRight);
				}
				else
				{
					list.Add(list[i].LowerRight);
				}
			}
			return list;
		}

		private void Replace(Sink sink, Node node)
		{
			if (sink.ParentList.Count == 0)
			{
				_head = node;
			}
			else
			{
				node.Replace(sink);
			}
		}

		public void Case1(Sink sink, Edge edge, Trapezoid[] tList)
		{
			YNode lChild = new YNode(edge, Sink.Isink(tList[1]), Sink.Isink(tList[2]));
			XNode rChild = new XNode(edge.Q, lChild, Sink.Isink(tList[3]));
			XNode node = new XNode(edge.P, Sink.Isink(tList[0]), rChild);
			Replace(sink, node);
		}

		public void Case2(Sink sink, Edge edge, Trapezoid[] tList)
		{
			YNode rChild = new YNode(edge, Sink.Isink(tList[1]), Sink.Isink(tList[2]));
			XNode node = new XNode(edge.P, Sink.Isink(tList[0]), rChild);
			Replace(sink, node);
		}

		public void Case3(Sink sink, Edge edge, Trapezoid[] tList)
		{
			YNode node = new YNode(edge, Sink.Isink(tList[0]), Sink.Isink(tList[1]));
			Replace(sink, node);
		}

		public void Case4(Sink sink, Edge edge, Trapezoid[] tList)
		{
			YNode lChild = new YNode(edge, Sink.Isink(tList[0]), Sink.Isink(tList[1]));
			XNode node = new XNode(edge.Q, lChild, Sink.Isink(tList[2]));
			Replace(sink, node);
		}
	}
	internal class Sink : Node
	{
		public Trapezoid Trapezoid;

		private Sink(Trapezoid trapezoid)
			: base(null, null)
		{
			Trapezoid = trapezoid;
			trapezoid.Sink = this;
		}

		public static Sink Isink(Trapezoid trapezoid)
		{
			if (trapezoid.Sink == null)
			{
				return new Sink(trapezoid);
			}
			return trapezoid.Sink;
		}

		public override Sink Locate(Edge edge)
		{
			return this;
		}
	}
	internal class TrapezoidalMap
	{
		public HashSet<Trapezoid> Map;

		private Edge _bCross;

		private Edge _cross;

		private float _margin;

		public TrapezoidalMap()
		{
			Map = new HashSet<Trapezoid>();
			_margin = 50f;
			_bCross = null;
			_cross = null;
		}

		public void Clear()
		{
			_bCross = null;
			_cross = null;
		}

		public Trapezoid[] Case1(Trapezoid t, Edge e)
		{
			Trapezoid[] array = new Trapezoid[4]
			{
				new Trapezoid(t.LeftPoint, e.P, t.Top, t.Bottom),
				new Trapezoid(e.P, e.Q, t.Top, e),
				new Trapezoid(e.P, e.Q, e, t.Bottom),
				new Trapezoid(e.Q, t.RightPoint, t.Top, t.Bottom)
			};
			array[0].UpdateLeft(t.UpperLeft, t.LowerLeft);
			array[1].UpdateLeftRight(array[0], null, array[3], null);
			array[2].UpdateLeftRight(null, array[0], null, array[3]);
			array[3].UpdateRight(t.UpperRight, t.LowerRight);
			return array;
		}

		public Trapezoid[] Case2(Trapezoid t, Edge e)
		{
			Point rightPoint = ((e.Q.X != t.RightPoint.X) ? t.RightPoint : e.Q);
			Trapezoid[] array = new Trapezoid[3]
			{
				new Trapezoid(t.LeftPoint, e.P, t.Top, t.Bottom),
				new Trapezoid(e.P, rightPoint, t.Top, e),
				new Trapezoid(e.P, rightPoint, e, t.Bottom)
			};
			array[0].UpdateLeft(t.UpperLeft, t.LowerLeft);
			array[1].UpdateLeftRight(array[0], null, t.UpperRight, null);
			array[2].UpdateLeftRight(null, array[0], null, t.LowerRight);
			_bCross = t.Bottom;
			_cross = t.Top;
			e.Above = array[1];
			e.Below = array[2];
			return array;
		}

		public Trapezoid[] Case3(Trapezoid t, Edge e)
		{
			Point leftPoint = ((e.P.X != t.LeftPoint.X) ? t.LeftPoint : e.P);
			Point rightPoint = ((e.Q.X != t.RightPoint.X) ? t.RightPoint : e.Q);
			Trapezoid[] array = new Trapezoid[2];
			if (_cross == t.Top)
			{
				array[0] = t.UpperLeft;
				array[0].UpdateRight(t.UpperRight, null);
				array[0].RightPoint = rightPoint;
			}
			else
			{
				array[0] = new Trapezoid(leftPoint, rightPoint, t.Top, e);
				array[0].UpdateLeftRight(t.UpperLeft, e.Above, t.UpperRight, null);
			}
			if (_bCross == t.Bottom)
			{
				array[1] = t.LowerLeft;
				array[1].UpdateRight(null, t.LowerRight);
				array[1].RightPoint = rightPoint;
			}
			else
			{
				array[1] = new Trapezoid(leftPoint, rightPoint, e, t.Bottom);
				array[1].UpdateLeftRight(e.Below, t.LowerLeft, null, t.LowerRight);
			}
			_bCross = t.Bottom;
			_cross = t.Top;
			e.Above = array[0];
			e.Below = array[1];
			return array;
		}

		public Trapezoid[] Case4(Trapezoid t, Edge e)
		{
			Point leftPoint = ((e.P.X != t.LeftPoint.X) ? t.LeftPoint : e.P);
			Trapezoid[] array = new Trapezoid[3];
			if (_cross == t.Top)
			{
				array[0] = t.UpperLeft;
				array[0].RightPoint = e.Q;
			}
			else
			{
				array[0] = new Trapezoid(leftPoint, e.Q, t.Top, e);
				array[0].UpdateLeft(t.UpperLeft, e.Above);
			}
			if (_bCross == t.Bottom)
			{
				array[1] = t.LowerLeft;
				array[1].RightPoint = e.Q;
			}
			else
			{
				array[1] = new Trapezoid(leftPoint, e.Q, e, t.Bottom);
				array[1].UpdateLeft(e.Below, t.LowerLeft);
			}
			array[2] = new Trapezoid(e.Q, t.RightPoint, t.Top, t.Bottom);
			array[2].UpdateLeftRight(array[0], array[1], t.UpperRight, t.LowerRight);
			return array;
		}

		public Trapezoid BoundingBox(List<Edge> edges)
		{
			Point point = edges[0].P + _margin;
			Point point2 = edges[0].Q - _margin;
			foreach (Edge edge3 in edges)
			{
				if (edge3.P.X > point.X)
				{
					point = new Point(edge3.P.X + _margin, point.Y);
				}
				if (edge3.P.Y > point.Y)
				{
					point = new Point(point.X, edge3.P.Y + _margin);
				}
				if (edge3.Q.X > point.X)
				{
					point = new Point(edge3.Q.X + _margin, point.Y);
				}
				if (edge3.Q.Y > point.Y)
				{
					point = new Point(point.X, edge3.Q.Y + _margin);
				}
				if (edge3.P.X < point2.X)
				{
					point2 = new Point(edge3.P.X - _margin, point2.Y);
				}
				if (edge3.P.Y < point2.Y)
				{
					point2 = new Point(point2.X, edge3.P.Y - _margin);
				}
				if (edge3.Q.X < point2.X)
				{
					point2 = new Point(edge3.Q.X - _margin, point2.Y);
				}
				if (edge3.Q.Y < point2.Y)
				{
					point2 = new Point(point2.X, edge3.Q.Y - _margin);
				}
			}
			Edge edge = new Edge(new Point(point2.X, point.Y), new Point(point.X, point.Y));
			Edge edge2 = new Edge(new Point(point2.X, point2.Y), new Point(point.X, point2.Y));
			Point p = edge2.P;
			Point q = edge.Q;
			return new Trapezoid(p, q, edge, edge2);
		}
	}
	internal class Point
	{
		public Point Next;

		public Point Prev;

		public float X;

		public float Y;

		public Point(float x, float y)
		{
			X = x;
			Y = y;
			Next = null;
			Prev = null;
		}

		public static Point operator -(Point p1, Point p2)
		{
			return new Point(p1.X - p2.X, p1.Y - p2.Y);
		}

		public static Point operator +(Point p1, Point p2)
		{
			return new Point(p1.X + p2.X, p1.Y + p2.Y);
		}

		public static Point operator -(Point p1, float f)
		{
			return new Point(p1.X - f, p1.Y - f);
		}

		public static Point operator +(Point p1, float f)
		{
			return new Point(p1.X + f, p1.Y + f);
		}

		public float Cross(Point p)
		{
			return X * p.Y - Y * p.X;
		}

		public float Dot(Point p)
		{
			return X * p.X + Y * p.Y;
		}

		public bool Neq(Point p)
		{
			return p.X != X || p.Y != Y;
		}

		public float Orient2D(Point pb, Point pc)
		{
			float num = X - pc.X;
			float num2 = pb.X - pc.X;
			float num3 = Y - pc.Y;
			float num4 = pb.Y - pc.Y;
			return num * num4 - num3 * num2;
		}
	}
	internal class Edge
	{
		public Trapezoid Above;

		public float B;

		public Trapezoid Below;

		public HashSet<Point> MPoints;

		public Point P;

		public Point Q;

		public float Slope;

		public Edge(Point p, Point q)
		{
			P = p;
			Q = q;
			if (q.X - p.X != 0f)
			{
				Slope = (q.Y - p.Y) / (q.X - p.X);
			}
			else
			{
				Slope = 0f;
			}
			B = p.Y - p.X * Slope;
			Above = null;
			Below = null;
			MPoints = new HashSet<Point>();
			MPoints.Add(p);
			MPoints.Add(q);
		}

		public bool IsAbove(Point point)
		{
			return P.Orient2D(Q, point) < 0f;
		}

		public bool IsBelow(Point point)
		{
			return P.Orient2D(Q, point) > 0f;
		}

		public void AddMpoint(Point point)
		{
			foreach (Point mPoint in MPoints)
			{
				if (!mPoint.Neq(point))
				{
					return;
				}
			}
			MPoints.Add(point);
		}
	}
	internal class Trapezoid
	{
		public Edge Bottom;

		public bool Inside;

		public Point LeftPoint;

		public Trapezoid LowerLeft;

		public Trapezoid LowerRight;

		public Point RightPoint;

		public Sink Sink;

		public Edge Top;

		public Trapezoid UpperLeft;

		public Trapezoid UpperRight;

		public Trapezoid(Point leftPoint, Point rightPoint, Edge top, Edge bottom)
		{
			LeftPoint = leftPoint;
			RightPoint = rightPoint;
			Top = top;
			Bottom = bottom;
			UpperLeft = null;
			UpperRight = null;
			LowerLeft = null;
			LowerRight = null;
			Inside = true;
			Sink = null;
		}

		public void UpdateLeft(Trapezoid ul, Trapezoid ll)
		{
			UpperLeft = ul;
			if (ul != null)
			{
				ul.UpperRight = this;
			}
			LowerLeft = ll;
			if (ll != null)
			{
				ll.LowerRight = this;
			}
		}

		public void UpdateRight(Trapezoid ur, Trapezoid lr)
		{
			UpperRight = ur;
			if (ur != null)
			{
				ur.UpperLeft = this;
			}
			LowerRight = lr;
			if (lr != null)
			{
				lr.LowerLeft = this;
			}
		}

		public void UpdateLeftRight(Trapezoid ul, Trapezoid ll, Trapezoid ur, Trapezoid lr)
		{
			UpperLeft = ul;
			if (ul != null)
			{
				ul.UpperRight = this;
			}
			LowerLeft = ll;
			if (ll != null)
			{
				ll.LowerRight = this;
			}
			UpperRight = ur;
			if (ur != null)
			{
				ur.UpperLeft = this;
			}
			LowerRight = lr;
			if (lr != null)
			{
				lr.LowerLeft = this;
			}
		}

		public void TrimNeighbors()
		{
			if (Inside)
			{
				Inside = false;
				if (UpperLeft != null)
				{
					UpperLeft.TrimNeighbors();
				}
				if (LowerLeft != null)
				{
					LowerLeft.TrimNeighbors();
				}
				if (UpperRight != null)
				{
					UpperRight.TrimNeighbors();
				}
				if (LowerRight != null)
				{
					LowerRight.TrimNeighbors();
				}
			}
		}

		public bool Contains(Point point)
		{
			return point.X > LeftPoint.X && point.X < RightPoint.X && Top.IsAbove(point) && Bottom.IsBelow(point);
		}

		public List<Point> Vertices()
		{
			List<Point> list = new List<Point>(4);
			list.Add(LineIntersect(Top, LeftPoint.X));
			list.Add(LineIntersect(Bottom, LeftPoint.X));
			list.Add(LineIntersect(Bottom, RightPoint.X));
			list.Add(LineIntersect(Top, RightPoint.X));
			return list;
		}

		private Point LineIntersect(Edge edge, float x)
		{
			float y = edge.Slope * x + edge.B;
			return new Point(x, y);
		}

		public void AddPoints()
		{
			if (LeftPoint != Bottom.P)
			{
				Bottom.AddMpoint(LeftPoint);
			}
			if (RightPoint != Bottom.Q)
			{
				Bottom.AddMpoint(RightPoint);
			}
			if (LeftPoint != Top.P)
			{
				Top.AddMpoint(LeftPoint);
			}
			if (RightPoint != Top.Q)
			{
				Top.AddMpoint(RightPoint);
			}
		}
	}
	internal class XNode : Node
	{
		private Point _point;

		public XNode(Point point, Node lChild, Node rChild)
			: base(lChild, rChild)
		{
			_point = point;
		}

		public override Sink Locate(Edge edge)
		{
			if (edge.P.X >= _point.X)
			{
				return RightChild.Locate(edge);
			}
			return LeftChild.Locate(edge);
		}
	}
	internal class YNode : Node
	{
		private Edge _edge;

		public YNode(Edge edge, Node lChild, Node rChild)
			: base(lChild, rChild)
		{
			_edge = edge;
		}

		public override Sink Locate(Edge edge)
		{
			if (_edge.IsAbove(edge.P))
			{
				return RightChild.Locate(edge);
			}
			if (_edge.IsBelow(edge.P))
			{
				return LeftChild.Locate(edge);
			}
			if (edge.Slope < _edge.Slope)
			{
				return RightChild.Locate(edge);
			}
			return LeftChild.Locate(edge);
		}
	}
	internal class Triangulator
	{
		public List<Trapezoid> Trapezoids;

		public List<List<Point>> Triangles;

		private Trapezoid _boundingBox;

		private List<Edge> _edgeList;

		private QueryGraph _queryGraph;

		private float _sheer = 0.001f;

		private TrapezoidalMap _trapezoidalMap;

		private List<MonotoneMountain> _xMonoPoly;

		public Triangulator(List<Point> polyLine, float sheer)
		{
			_sheer = sheer;
			Triangles = new List<List<Point>>();
			Trapezoids = new List<Trapezoid>();
			_xMonoPoly = new List<MonotoneMountain>();
			_edgeList = InitEdges(polyLine);
			_trapezoidalMap = new TrapezoidalMap();
			_boundingBox = _trapezoidalMap.BoundingBox(_edgeList);
			_queryGraph = new QueryGraph(Sink.Isink(_boundingBox));
			Process();
		}

		private void Process()
		{
			foreach (Edge edge in _edgeList)
			{
				List<Trapezoid> list = _queryGraph.FollowEdge(edge);
				foreach (Trapezoid item2 in list)
				{
					_trapezoidalMap.Map.Remove(item2);
					bool flag = item2.Contains(edge.P);
					bool flag2 = item2.Contains(edge.Q);
					Trapezoid[] array;
					if (flag && flag2)
					{
						array = _trapezoidalMap.Case1(item2, edge);
						_queryGraph.Case1(item2.Sink, edge, array);
					}
					else if (flag && !flag2)
					{
						array = _trapezoidalMap.Case2(item2, edge);
						_queryGraph.Case2(item2.Sink, edge, array);
					}
					else if (!flag && !flag2)
					{
						array = _trapezoidalMap.Case3(item2, edge);
						_queryGraph.Case3(item2.Sink, edge, array);
					}
					else
					{
						array = _trapezoidalMap.Case4(item2, edge);
						_queryGraph.Case4(item2.Sink, edge, array);
					}
					Trapezoid[] array2 = array;
					foreach (Trapezoid item in array2)
					{
						_trapezoidalMap.Map.Add(item);
					}
				}
				_trapezoidalMap.Clear();
			}
			foreach (Trapezoid item3 in _trapezoidalMap.Map)
			{
				MarkOutside(item3);
			}
			foreach (Trapezoid item4 in _trapezoidalMap.Map)
			{
				if (item4.Inside)
				{
					Trapezoids.Add(item4);
					item4.AddPoints();
				}
			}
			CreateMountains();
		}

		private void CreateMountains()
		{
			foreach (Edge edge in _edgeList)
			{
				if (edge.MPoints.Count <= 2)
				{
					continue;
				}
				MonotoneMountain monotoneMountain = new MonotoneMountain();
				List<Point> list = new List<Point>(edge.MPoints);
				list.Sort((Point p1, Point p2) => p1.X.CompareTo(p2.X));
				foreach (Point item in list)
				{
					monotoneMountain.Add(item);
				}
				monotoneMountain.Process();
				foreach (List<Point> triangle in monotoneMountain.Triangles)
				{
					Triangles.Add(triangle);
				}
				_xMonoPoly.Add(monotoneMountain);
			}
		}

		private void MarkOutside(Trapezoid t)
		{
			if (t.Top == _boundingBox.Top || t.Bottom == _boundingBox.Bottom)
			{
				t.TrimNeighbors();
			}
		}

		private List<Edge> InitEdges(List<Point> points)
		{
			List<Edge> list = new List<Edge>();
			for (int i = 0; i < points.Count - 1; i++)
			{
				list.Add(new Edge(points[i], points[i + 1]));
			}
			list.Add(new Edge(points[0], points[points.Count - 1]));
			return OrderSegments(list);
		}

		private List<Edge> OrderSegments(List<Edge> edgeInput)
		{
			List<Edge> list = new List<Edge>();
			foreach (Edge item in edgeInput)
			{
				Point point = ShearTransform(item.P);
				Point point2 = ShearTransform(item.Q);
				if (point.X > point2.X)
				{
					list.Add(new Edge(point2, point));
				}
				else if (point.X < point2.X)
				{
					list.Add(new Edge(point, point2));
				}
			}
			Shuffle(list);
			return list;
		}

		private static void Shuffle<T>(IList<T> list)
		{
			Random random = new Random();
			int num = list.Count;
			while (num > 1)
			{
				num--;
				int index = random.Next(num + 1);
				T value = list[index];
				list[index] = list[num];
				list[num] = value;
			}
		}

		private Point ShearTransform(Point point)
		{
			return new Point(point.X + _sheer * point.Y, point.Y);
		}
	}
}
namespace Sabresaurus.SabreCSG.ShapeEditor
{
	public interface ISelectable
	{
		Vector2Int position { get; set; }
	}
	[Serializable]
	public class Pivot : ISelectable
	{
		[SerializeField]
		private Vector2Int _position;

		public Vector2Int position
		{
			get
			{
				return _position;
			}
			set
			{
				_position = value;
			}
		}
	}
	[Serializable]
	public class Project
	{
		[SerializeField]
		public int version = 1;

		[SerializeField]
		public List<Shape> shapes = new List<Shape>
		{
			new Shape()
		};

		[SerializeField]
		public Pivot globalPivot = new Pivot();

		[SerializeField]
		public bool flipHorizontally = false;

		[SerializeField]
		public bool flipVertically = false;

		[SerializeField]
		public float extrudeDepth = 1f;

		[SerializeField]
		public float extrudeClipDepth = 0.5f;

		[SerializeField]
		public Vector2 extrudeScale = Vector2.one;

		[SerializeField]
		public int revolve360 = 8;

		[SerializeField]
		public int revolveSteps = 4;

		[SerializeField]
		public int revolveDistance = 1;

		[SerializeField]
		public int revolveRadius = 1;

		[SerializeField]
		public bool revolveDirection = true;

		[SerializeField]
		public bool revolveSpiralSloped = false;

		[SerializeField]
		public bool convexBrushes = true;

		public Project Clone()
		{
			return JsonUtility.FromJson<Project>(JsonUtility.ToJson((object)this));
		}
	}
	[Serializable]
	public class Segment : ISelectable
	{
		[SerializeField]
		private Vector2Int _position;

		[SerializeField]
		public SegmentType type = SegmentType.Linear;

		[SerializeField]
		public Pivot bezierPivot1 = new Pivot();

		[SerializeField]
		public Pivot bezierPivot2 = new Pivot();

		[SerializeField]
		public int bezierDetail = 3;

		public Vector2Int position
		{
			get
			{
				return _position;
			}
			set
			{
				_position = value;
			}
		}

		public Segment(int x, int y)
		{
			position = new Vector2Int(x, y);
		}
	}
	public enum SegmentType
	{
		Linear,
		Bezier
	}
	[Serializable]
	public class Shape
	{
		[SerializeField]
		public List<Segment> segments = new List<Segment>
		{
			new Segment(-8, -8),
			new Segment(8, -8),
			new Segment(8, 8),
			new Segment(-8, 8)
		};

		public Pivot pivot = new Pivot();

		public void CalculatePivotPosition()
		{
			Vector2Int vector2Int = default(Vector2Int);
			foreach (Segment segment in segments)
			{
				vector2Int += segment.position;
			}
			pivot.position = new Vector2Int(vector2Int.x / segments.Count, vector2Int.y / segments.Count);
		}

		public Shape Clone()
		{
			return JsonUtility.FromJson<Shape>(JsonUtility.ToJson((object)this));
		}
	}
	[ExecuteInEditMode]
	public class ShapeEditorBrush : CompoundBrush
	{
		public enum ExtrudeMode
		{
			CreatePolygon,
			RevolveShape,
			ExtrudeShape,
			ExtrudePoint,
			ExtrudeBevel
		}

		[SerializeField]
		private Project project = JsonUtility.FromJson<Project>("{\"version\":1,\"shapes\":[{\"segments\":[{\"_position\":{\"x\":-18,\"y\":-8},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-14,\"y\":-11},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-14,\"y\":-13},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-20,\"y\":-13},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-10,\"y\":-19},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-6,\"y\":-19},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-6,\"y\":-16},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-3,\"y\":-19},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":6,\"y\":-19},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":9,\"y\":-16},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":11,\"y\":-16},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":14,\"y\":-12},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":14,\"y\":-2},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":10,\"y\":-8},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":9,\"y\":-11},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":5,\"y\":-15},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-2,\"y\":-16},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-3,\"y\":-11},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":9,\"y\":-11},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":10,\"y\":-8},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":6,\"y\":-8},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-2,\"y\":-1},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-2,\"y\":3},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":5,\"y\":6},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":12,\"y\":6},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":10,\"y\":8},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-10,\"y\":8},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3},{\"_position\":{\"x\":-18,\"y\":0},\"type\":0,\"bezierPivot1\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierPivot2\":{\"_position\":{\"x\":-2,\"y\":-6}},\"bezierDetail\":3}],\"pivot\":{\"_position\":{\"x\":0,\"y\":-8}}}],\"globalPivot\":{\"_position\":{\"x\":0,\"y\":0}},\"flipHorizontally\":false,\"flipVertically\":false,\"extrudeDepth\":1.0,\"extrudeClipDepth\":0.5,\"extrudeScale\":{\"x\":1.0,\"y\":1.0},\"revolve360\":8,\"revolveSteps\":4,\"revolveDistance\":1,\"revolveRadius\":1,\"revolveDirection\":true}");

		[SerializeField]
		private ExtrudeMode extrudeMode = ExtrudeMode.ExtrudeShape;

		[SerializeField]
		private int desiredBrushCount;

		[SerializeField]
		private bool isDirty = true;

		private Vector3 m_LastKnownExtents;

		private Vector3 m_LastKnownPosition;

		private List<Polygon> m_LastBuiltPolygons;

		public override string BeautifulBrushName => "2D Shape Editor Brush";

		public override int BrushCount
		{
			get
			{
				if (!project.convexBrushes)
				{
					return 1;
				}
				if (!isDirty)
				{
					return desiredBrushCount;
				}
				if (m_LastBuiltPolygons == null)
				{
					m_LastBuiltPolygons = BuildConvexPolygons();
				}
				return desiredBrushCount;
			}
		}

		protected override void Awake()
		{
			//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_001f: 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)
			base.Awake();
			m_LastKnownExtents = ((Bounds)(ref localBounds)).extents;
			m_LastKnownPosition = ((Component)this).transform.localPosition;
		}

		public override void UpdateVisibility()
		{
		}

		public override void Invalidate(bool polygonsChanged)
		{
			//IL_0002: 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_0031: 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_0130: 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_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_0180: 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_0d3c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d5f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a15: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_0594: Unknown result type (might be due to invalid IL or missing references)
			//IL_059c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_061b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0620: Unknown result type (might be due to invalid IL or missing references)
			//IL_0625: Unknown result type (might be due to invalid IL or missing references)
			//IL_068f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0694: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0721: Unknown result type (might be due to invalid IL or missing references)
			//IL_0726: Unknown result type (might be due to invalid IL or missing references)
			//IL_072a: Unknown result type (might be due to invalid IL or missing references)
			//IL_072f: Unknown result type (might be due to invalid IL or missing references)
			if (m_LastKnownExtents != ((Bounds)(ref localBounds)).extents)
			{
				((Component)this).transform.localPosition = m_LastKnownPosition;
			}
			Bounds val = default(Bounds);
			if (extrudeMode == ExtrudeMode.CreatePolygon)
			{
				base.IsNoCSG = true;
			}
			if (extrudeMode == ExtrudeMode.RevolveShape && project.revolveSpiralSloped && project.globalPivot.position.y != 0)
			{
				base.IsNoCSG = true;
			}
			if (!project.convexBrushes)
			{
				base.IsNoCSG = true;
			}
			if (!isDirty)
			{
				for (int i = 0; i < ((!project.convexBrushes) ? 1 : desiredBrushCount); i++)
				{
					generatedBrushes[i].Mode = base.Mode;
					generatedBrushes[i].IsNoCSG = base.IsNoCSG;
					generatedBrushes[i].IsVisible = base.IsVisible;
					generatedBrushes[i].HasCollision = base.HasCollision;
					generatedBrushes[i].Invalidate(polygonsChanged: true);
					((Bounds)(ref val)).Encapsulate(generatedBrushes[i].GetBounds());
				}
				localBounds = val;
				m_LastKnownExtents = ((Bounds)(ref localBounds)).extents;
				m_LastKnownPosition = ((Component)this).transform.localPosition;
				return;
			}
			base.Invalidate(polygonsChanged);
			isDirty = false;
			if (m_LastBuiltPolygons == null)
			{
				m_LastBuiltPolygons = BuildConvexPolygons();