Decompiled source of PG3D Shooting Range v1.0.0

PG3D_Shooting_Range.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using Atlas;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using Sodalite.Api;
using Sodalite.Utilities;
using Technie.PhysicsCreator.QHull;
using UnityEditor;
using UnityEngine;
using UnityEngine.AI;
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 ShermanJumbo
{
	public class SimpleMusicToggleButton : FVRInteractiveObject
	{
		public Transform Flipsight;

		public Vector3 m_flipsightStartPosition;

		public Vector3 m_flipsightEndPosition = new Vector3(0f, 0f, -0.1f);

		public AudioSource audioSource;

		private bool m_isOpen = true;

		private float m_curFlipLerp;

		private float m_tarFlipLerp;

		private float m_lastFlipLerp;

		public override void Awake()
		{
			//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)
			((FVRInteractiveObject)this).Awake();
			if ((Object)(object)Flipsight != (Object)null)
			{
				m_flipsightStartPosition = Flipsight.localPosition;
			}
			if ((Object)(object)audioSource == (Object)null)
			{
				audioSource = ((Component)this).GetComponent<AudioSource>();
			}
		}

		public override void SimpleInteraction(FVRViveHand hand)
		{
			((FVRInteractiveObject)this).SimpleInteraction(hand);
			m_isOpen = !m_isOpen;
			ToggleAudio();
		}

		public override void FVRUpdate()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: 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)
			((FVRInteractiveObject)this).FVRUpdate();
			m_tarFlipLerp = ((!m_isOpen) ? 1f : 0f);
			m_curFlipLerp = Mathf.MoveTowards(m_curFlipLerp, m_tarFlipLerp, Time.deltaTime * 4f);
			if (Mathf.Abs(m_curFlipLerp - m_lastFlipLerp) > 0.01f)
			{
				Vector3 localPosition = Vector3.Lerp(m_flipsightStartPosition, m_flipsightEndPosition, m_curFlipLerp);
				Flipsight.localPosition = localPosition;
			}
			m_lastFlipLerp = m_curFlipLerp;
		}

		private void ToggleAudio()
		{
			if ((Object)(object)audioSource != (Object)null)
			{
				if (m_isOpen)
				{
					audioSource.Stop();
				}
				else
				{
					audioSource.Play();
				}
			}
		}
	}
}
namespace ShermanJumbo.PG3D_Shooting_Range
{
	[BepInPlugin("ShermanJumbo.PG3D_Shooting_Range", "PG3D_Shooting_Range", "1.0.0")]
	[BepInProcess("h3vr.exe")]
	[Description("Built with MeatKit")]
	[BepInDependency("nrgill28.Atlas", "1.0.1")]
	public class PG3D_Shooting_RangePlugin : BaseUnityPlugin
	{
		private static readonly string BasePath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

		internal static ManualLogSource Logger;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			LoadAssets();
		}

		private void LoadAssets()
		{
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "ShermanJumbo.PG3D_Shooting_Range");
			AtlasPlugin.RegisterScene(Path.Combine(BasePath, "shootingrange"));
		}
	}
}
namespace nrgill28.AtlasSampleScene
{
	public class CTF_CaptureZone : MonoBehaviour
	{
		public CTF_Manager Manager;

		public CTF_Team Team;

		public void OnTriggerEnter(Collider other)
		{
			CTF_Flag component = ((Component)other).GetComponent<CTF_Flag>();
			if (Object.op_Implicit((Object)(object)component) && component.Team != Team)
			{
				Manager.FlagCaptured(component);
			}
		}
	}
	public class CTF_Flag : FVRPhysicalObject
	{
		[Header("Flag stuffs")]
		public CTF_Team Team;

		public float RespawnDelay = 10f;

		public Vector3 FloorOffset = new Vector3(0f, 0.25f, 0f);

		private Vector3 _resetPosition;

		private Quaternion _resetRotation;

		private Transform _followTransform;

		private bool _isHeld;

		private bool _isTaken;

		private float _timer;

		private CTF_Sosig _heldBy;

		public 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)
			((FVRPhysicalObject)this).Awake();
			_resetPosition = ((Component)this).transform.position;
			_resetRotation = ((Component)this).transform.rotation;
		}

		private void Update()
		{
			if (_isTaken && !_isHeld)
			{
				_timer -= Time.deltaTime;
				if (_timer < 0f)
				{
					ReturnFlag();
				}
			}
		}

		public void Take()
		{
			_isHeld = true;
			_isTaken = true;
		}

		public void Drop()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0050: Unknown result type (might be due to invalid IL or missing references)
			((FVRInteractiveObject)this).IsHeld = false;
			_timer = RespawnDelay;
			NavMeshHit val = default(NavMeshHit);
			NavMesh.SamplePosition(((Component)this).transform.position, ref val, 100f, -1);
			((Component)this).transform.position = ((NavMeshHit)(ref val)).position + FloorOffset;
			((Component)this).transform.rotation = Quaternion.identity;
		}

		public void ReturnFlag()
		{
			//IL_0035: 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)
			if (((FVRInteractiveObject)this).IsHeld)
			{
				((FVRInteractiveObject)this).ForceBreakInteraction();
			}
			if (Object.op_Implicit((Object)(object)_heldBy))
			{
				_heldBy.HeldFlag = null;
			}
			((Component)this).transform.SetPositionAndRotation(_resetPosition, _resetRotation);
			_isTaken = false;
		}

		private void OnTriggerEnter(Collider other)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (_isHeld)
			{
				return;
			}
			CTF_Sosig componentInParent = ((Component)other).GetComponentInParent<CTF_Sosig>();
			if (Object.op_Implicit((Object)(object)componentInParent) && (int)componentInParent.Sosig.BodyState == 0)
			{
				if (componentInParent.Team == Team)
				{
					ReturnFlag();
					return;
				}
				_heldBy = componentInParent;
				componentInParent.HeldFlag = this;
				Take();
			}
		}

		public override void BeginInteraction(FVRViveHand hand)
		{
			((FVRPhysicalObject)this).BeginInteraction(hand);
			Take();
		}

		public override void EndInteraction(FVRViveHand hand)
		{
			((FVRPhysicalObject)this).EndInteraction(hand);
			Drop();
		}
	}
	public class CTF_Manager : MonoBehaviour
	{
		[Header("References")]
		public Text[] ScoreTexts;

		public Transform[] AttackPoints;

		public Text StartButtonText;

		[Header("Red Team")]
		public CTF_Flag RedFlag;

		public int RedTeamSize;

		public Transform[] RedSpawns;

		public SosigEnemyID[] RedTeam;

		[Header("Blue Team")]
		public CTF_Flag BlueFlag;

		public int BlueTeamSize;

		public Transform[] BlueSpawns;

		public SosigEnemyID[] BlueTeam;

		private int _blueScore;

		private int _redScore;

		private bool _running;

		private readonly List<CTF_Sosig> _sosigs = new List<CTF_Sosig>();

		private readonly SpawnOptions _spawnOptions;

		public CTF_Manager()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			SpawnOptions val = new SpawnOptions();
			val.SpawnState = (SosigOrder)7;
			val.SpawnActivated = true;
			val.EquipmentMode = (EquipmentSlots)7;
			val.SpawnWithFullAmmo = true;
			_spawnOptions = val;
			((MonoBehaviour)this)..ctor();
		}

		private void Start()
		{
			UpdateScoreText();
		}

		public void ToggleGame()
		{
			if (_running)
			{
				EndGame();
				StartButtonText.text = "Start Game";
			}
			else
			{
				StartGame();
				StartButtonText.text = "Stop Game";
			}
		}

		private void StartGame()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			ResetGame();
			_running = true;
			GM.CurrentSceneSettings.SosigKillEvent += new SosigKill(CurrentSceneSettingsOnSosigKillEvent);
			((MonoBehaviour)this).StartCoroutine(DoInitialSpawns());
		}

		private void EndGame()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			GM.CurrentSceneSettings.SosigKillEvent -= new SosigKill(CurrentSceneSettingsOnSosigKillEvent);
			foreach (CTF_Sosig sosig in _sosigs)
			{
				sosig.Sosig.ClearSosig();
			}
			_running = false;
		}

		private void CurrentSceneSettingsOnSosigKillEvent(Sosig s)
		{
			CTF_Sosig cTF_Sosig = _sosigs.FirstOrDefault((CTF_Sosig x) => (Object)(object)x.Sosig == (Object)(object)s);
			if (Object.op_Implicit((Object)(object)cTF_Sosig))
			{
				((MonoBehaviour)this).StartCoroutine(RespawnSosig(cTF_Sosig));
			}
		}

		private void SpawnSosig(CTF_Team team)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			_spawnOptions.IFF = (int)team;
			_spawnOptions.SosigTargetPosition = SodaliteUtils.GetRandom<Transform>((IList<Transform>)AttackPoints).position;
			Transform transform;
			SosigEnemyID random;
			if (team == CTF_Team.Red)
			{
				transform = ((Component)SodaliteUtils.GetRandom<Transform>((IList<Transform>)RedSpawns)).transform;
				random = SodaliteUtils.GetRandom<SosigEnemyID>((IList<SosigEnemyID>)RedTeam);
			}
			else
			{
				transform = ((Component)SodaliteUtils.GetRandom<Transform>((IList<Transform>)BlueSpawns)).transform;
				random = SodaliteUtils.GetRandom<SosigEnemyID>((IList<SosigEnemyID>)BlueTeam);
			}
			Sosig val = SosigAPI.Spawn(ManagerSingleton<IM>.Instance.odicSosigObjsByID[random], _spawnOptions, transform.position, transform.rotation);
			CTF_Sosig cTF_Sosig = ((Component)val).gameObject.AddComponent<CTF_Sosig>();
			_sosigs.Add(cTF_Sosig);
			cTF_Sosig.Sosig = val;
			cTF_Sosig.Team = team;
		}

		private IEnumerator DoInitialSpawns()
		{
			int i = 0;
			while (i < Mathf.Max(RedTeamSize, BlueTeamSize))
			{
				if (i < RedTeamSize)
				{
					SpawnSosig(CTF_Team.Red);
				}
				if (i < BlueTeamSize)
				{
					SpawnSosig(CTF_Team.Blue);
				}
				i++;
				yield return (object)new WaitForSeconds(2.5f);
			}
		}

		private IEnumerator RespawnSosig(CTF_Sosig sosig)
		{
			yield return (object)new WaitForSeconds(5f);
			sosig.Sosig.ClearSosig();
			_sosigs.Remove(sosig);
			yield return (object)new WaitForSeconds(5f);
			if (_running)
			{
				int sosigsLeft = _sosigs.Count((CTF_Sosig x) => x.Team == sosig.Team);
				int teamSize = ((sosig.Team != 0) ? BlueTeamSize : RedTeamSize);
				if (sosigsLeft < teamSize)
				{
					SpawnSosig(sosig.Team);
				}
			}
		}

		public void ResetGame()
		{
			_blueScore = 0;
			_redScore = 0;
			UpdateScoreText();
			if (Object.op_Implicit((Object)(object)RedFlag))
			{
				RedFlag.ReturnFlag();
			}
			if (Object.op_Implicit((Object)(object)BlueFlag))
			{
				BlueFlag.ReturnFlag();
			}
		}

		public void FlagCaptured(CTF_Flag flag)
		{
			if (flag.Team == CTF_Team.Red)
			{
				_blueScore++;
			}
			else
			{
				_redScore++;
			}
			UpdateScoreText();
			flag.ReturnFlag();
		}

		public void UpdateScoreText()
		{
			Text[] scoreTexts = ScoreTexts;
			foreach (Text val in scoreTexts)
			{
				val.text = "<color=red>" + _redScore + "</color> - <color=blue>" + _blueScore + "</color>";
			}
		}

		private void OnDrawGizmos()
		{
			//IL_0001: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			Gizmos.color = Color.red;
			Transform[] redSpawns = RedSpawns;
			foreach (Transform val in redSpawns)
			{
				Gizmos.DrawSphere(val.position, 0.15f);
			}
			Gizmos.color = Color.blue;
			Transform[] blueSpawns = BlueSpawns;
			foreach (Transform val2 in blueSpawns)
			{
				Gizmos.DrawSphere(val2.position, 0.15f);
			}
			Gizmos.color = Color.green;
			Transform[] attackPoints = AttackPoints;
			foreach (Transform val3 in attackPoints)
			{
				Gizmos.DrawSphere(val3.position, 0.15f);
			}
		}
	}
	public class CTF_Sosig : MonoBehaviour
	{
		public CTF_Team Team;

		public CTF_Flag HeldFlag;

		public Sosig Sosig;

		private void Awake()
		{
			Sosig = ((Component)this).GetComponent<Sosig>();
		}

		private void Update()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0041: 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_0059: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)HeldFlag))
			{
				Vector3 val = ((Component)Sosig).transform.position - ((Component)Sosig).transform.forward * 0.1f;
				((Component)HeldFlag).transform.SetPositionAndRotation(val, ((Component)Sosig).transform.rotation);
			}
		}
	}
	public enum CTF_Team
	{
		Red,
		Blue
	}
	public class PopupTarget : MonoBehaviour, IFVRDamageable
	{
		[Flags]
		public enum TargetRange
		{
			Near = 1,
			Mid = 2,
			Far = 4,
			All = 7
		}

		public PopupTargetManager Manager;

		public TargetRange Range;

		public Transform Pivot;

		public Vector3 SetRotation;

		private Quaternion _startRotation;

		private Quaternion _endRotation;

		private bool _set;

		public bool Set
		{
			get
			{
				return _set;
			}
			set
			{
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: 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_002d: Unknown result type (might be due to invalid IL or missing references)
				if (_set != value)
				{
					_set = value;
					((MonoBehaviour)this).StartCoroutine((!_set) ? RotateTo(_endRotation, _startRotation) : RotateTo(_startRotation, _endRotation));
				}
			}
		}

		private void Awake()
		{
			//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_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)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			_startRotation = Pivot.rotation;
			_endRotation = Quaternion.Euler(SetRotation + ((Quaternion)(ref _startRotation)).eulerAngles);
		}

		void IFVRDamageable.Damage(Damage dam)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			if (Set && (int)dam.Class == 1)
			{
				Set = false;
				Manager.TargetHit(this);
			}
		}

		private IEnumerator RotateTo(Quaternion from, Quaternion to)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			float elapsed = 0f;
			while (elapsed < 0.25f)
			{
				yield return null;
				elapsed += Time.deltaTime;
				Pivot.localRotation = Quaternion.Slerp(from, to, elapsed / 0.25f);
			}
			Pivot.rotation = to;
		}
	}
	public class PopupTargetManager : MonoBehaviour
	{
		public List<PopupTarget> Targets;

		private readonly List<PopupTarget> _setTargets = new List<PopupTarget>();

		private void Awake()
		{
			((MonoBehaviour)this).StartCoroutine(StartSetAsync(3f, 8f, 5, PopupTarget.TargetRange.All));
		}

		private IEnumerator StartSetAsync(float minDelay, float maxDelay, int numTargets, PopupTarget.TargetRange ranges)
		{
			yield return (object)new WaitForSeconds(Random.Range(minDelay, maxDelay));
			IListExtensions.Shuffle<PopupTarget>((IList<PopupTarget>)Targets);
			_setTargets.Clear();
			foreach (PopupTarget target in Targets)
			{
				if ((target.Range & ranges) != 0)
				{
					target.Set = true;
					_setTargets.Add(target);
					numTargets--;
				}
				if (numTargets == 0)
				{
					break;
				}
			}
		}

		public void TargetHit(PopupTarget target)
		{
			if (_setTargets.Contains(target))
			{
				_setTargets.Remove(target);
				if (_setTargets.Count == 0)
				{
					((MonoBehaviour)this).StartCoroutine(StartSetAsync(3f, 8f, 5, PopupTarget.TargetRange.All));
				}
			}
		}
	}
}
namespace Technie.PhysicsCreator
{
	public class AlignedCapsuleFitter
	{
		public CapsuleDef Fit(Hull hull, Vector3[] meshVertices, int[] meshIndices)
		{
			//IL_003c: 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)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			QHullUtil.FindConvexHull(hull.name, hull.selectedFaces.ToArray(), meshVertices, meshIndices, out var hullVertices, out var _, showErrorInLog: false);
			if (hullVertices == null || hullVertices.Length == 0)
			{
				return default(CapsuleDef);
			}
			ConstructionPlane plane = new ConstructionPlane(Vector3.zero);
			RotatedBox rotatedBox = RotatedBoxFitter.FindTightestBox(plane, hullVertices);
			ConstructionPlane constructionPlane;
			CapsuleAxis capsuleDirection;
			if (rotatedBox.size.x > rotatedBox.size.y && rotatedBox.size.x > rotatedBox.size.z)
			{
				constructionPlane = new ConstructionPlane(rotatedBox.center, Vector3.right, Vector3.forward);
				capsuleDirection = CapsuleAxis.X;
			}
			else if (rotatedBox.size.y > rotatedBox.size.z)
			{
				constructionPlane = new ConstructionPlane(rotatedBox.center, Vector3.up, Vector3.right);
				capsuleDirection = CapsuleAxis.Y;
			}
			else
			{
				constructionPlane = new ConstructionPlane(rotatedBox.center, Vector3.forward, Vector3.right);
				capsuleDirection = CapsuleAxis.Z;
			}
			RotatedCapsule inputCapule = RotatedCapsuleFitter.FitCapsule(constructionPlane, hullVertices);
			RotatedCapsuleFitter.Refine(inputCapule, constructionPlane, hullVertices, out var bestCapsule, out var _);
			CapsuleDef result = default(CapsuleDef);
			result.capsuleDirection = capsuleDirection;
			result.capsuleRadius = bestCapsule.radius;
			result.capsuleHeight = bestCapsule.height;
			result.capsuleCenter = bestCapsule.center;
			result.capsulePosition = Vector3.zero;
			result.capsuleRotation = Quaternion.identity;
			return result;
		}
	}
	public class AxisAlignedBoxFitter
	{
		public void Fit(Hull hull, Vector3[] meshVertices, int[] meshIndices)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] selectedVertices = FaceAlignmentBoxFitter.GetSelectedVertices(hull, meshVertices, meshIndices);
			ConstructionPlane plane = new ConstructionPlane(Vector3.zero, Vector3.up, Vector3.right);
			RotatedBox computedBox = RotatedBoxFitter.FindTightestBox(plane, selectedVertices);
			RotatedBoxFitter.ApplyToHull(computedBox, hull);
		}
	}
	public class Pose
	{
		public Vector3 forward;

		public Vector3 up;

		public Vector3 right;
	}
	public class Triangle
	{
		public Vector3 normal;

		public float area;

		public Vector3 center;

		public Triangle(Vector3 p0, Vector3 p1, Vector3 p2)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_000f: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = p1 - p0;
			Vector3 val2 = p2 - p0;
			Vector3 val3 = Vector3.Cross(val, val2);
			area = ((Vector3)(ref val3)).magnitude * 0.5f;
			normal = ((Vector3)(ref val3)).normalized;
			center = (p0 + p1 + p2) / 3f;
		}
	}
	public class TriangleBucket
	{
		private List<Triangle> triangles;

		private Vector3 averagedNormal;

		private Vector3 averagedCenter;

		private float totalArea;

		public float Area => totalArea;

		public TriangleBucket(Triangle initialTriangle)
		{
			triangles = new List<Triangle>();
			triangles.Add(initialTriangle);
			CalculateNormal();
			CalcTotalArea();
		}

		public void Add(Triangle t)
		{
			triangles.Add(t);
			CalculateNormal();
			CalcTotalArea();
		}

		public void Add(TriangleBucket otherBucket)
		{
			foreach (Triangle triangle in otherBucket.triangles)
			{
				triangles.Add(triangle);
			}
			CalculateNormal();
			CalcTotalArea();
		}

		private void CalculateNormal()
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			averagedNormal = Vector3.zero;
			foreach (Triangle triangle in triangles)
			{
				averagedNormal += triangle.normal * triangle.area;
			}
			((Vector3)(ref averagedNormal)).Normalize();
		}

		public Vector3 GetAverageNormal()
		{
			//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 averagedNormal;
		}

		public Vector3 GetAverageCenter()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: 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)
			return triangles[0].center;
		}

		private void CalcTotalArea()
		{
			totalArea = 0f;
			foreach (Triangle triangle in triangles)
			{
				totalArea += triangle.area;
			}
		}
	}
	public class TriangleAreaSorter : IComparer<Triangle>
	{
		public int Compare(Triangle lhs, Triangle rhs)
		{
			if (lhs.area < rhs.area)
			{
				return 1;
			}
			if (lhs.area > rhs.area)
			{
				return -1;
			}
			return 0;
		}
	}
	public class TriangleBucketSorter : IComparer<TriangleBucket>
	{
		public int Compare(TriangleBucket lhs, TriangleBucket rhs)
		{
			if (lhs.Area < rhs.Area)
			{
				return 1;
			}
			if (lhs.Area > rhs.Area)
			{
				return -1;
			}
			return 0;
		}
	}
	public class FaceAlignmentBoxFitter
	{
		public void Fit(Hull hull, Vector3[] meshVertices, int[] meshIndices)
		{
			if (meshIndices.Length < 3)
			{
				return;
			}
			List<Triangle> list = FindTriangles(meshVertices, meshIndices, hull.selectedFaces);
			list.Sort(new TriangleAreaSorter());
			List<TriangleBucket> list2 = new List<TriangleBucket>();
			foreach (Triangle item in list)
			{
				TriangleBucket triangleBucket = FindBestBucket(item, 30f, list2);
				if (triangleBucket != null)
				{
					triangleBucket.Add(item);
					continue;
				}
				triangleBucket = new TriangleBucket(item);
				list2.Add(triangleBucket);
			}
			while (list2.Count > 3)
			{
				MergeClosestBuckets(list2);
			}
			list2.Sort(new TriangleBucketSorter());
			Vector3[] selectedVertices = GetSelectedVertices(hull, meshVertices, meshIndices);
			ConstructionPlane plane = CreateConstructionPlane(list2[0], (list2.Count <= 1) ? null : list2[1], (list2.Count <= 2) ? null : list2[2]);
			RotatedBox computedBox = RotatedBoxFitter.FindTightestBox(plane, selectedVertices);
			RotatedBoxFitter.ApplyToHull(computedBox, hull);
		}

		public static List<Triangle> FindTriangles(Vector3[] meshVertices, int[] meshIndices, List<int> selectedFaces)
		{
			//IL_003c: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			List<Triangle> list = new List<Triangle>();
			foreach (int selectedFace in selectedFaces)
			{
				int num = meshIndices[selectedFace * 3];
				int num2 = meshIndices[selectedFace * 3 + 1];
				int num3 = meshIndices[selectedFace * 3 + 2];
				Vector3 p = meshVertices[num];
				Vector3 p2 = meshVertices[num2];
				Vector3 p3 = meshVertices[num3];
				Triangle item = new Triangle(p, p2, p3);
				list.Add(item);
			}
			return list;
		}

		public static void FindTriangles(Hull hull, Vector3[] meshVertices, int[] meshIndices, out Vector3[] hullVertices, out int[] hullIndices)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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)
			List<Vector3> list = new List<Vector3>();
			foreach (int selectedFace in hull.selectedFaces)
			{
				int num = meshIndices[selectedFace * 3];
				int num2 = meshIndices[selectedFace * 3 + 1];
				int num3 = meshIndices[selectedFace * 3 + 2];
				Vector3 item = meshVertices[num];
				Vector3 item2 = meshVertices[num2];
				Vector3 item3 = meshVertices[num3];
				list.Add(item);
				list.Add(item2);
				list.Add(item3);
			}
			hullVertices = list.ToArray();
			hullIndices = new int[hullVertices.Length];
			for (int i = 0; i < hullIndices.Length; i++)
			{
				hullIndices[i] = i;
			}
		}

		public static Vector3[] GetSelectedVertices(Hull hull, Vector3[] meshVertices, int[] meshIndices)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<int, int> dictionary = new Dictionary<int, int>();
			foreach (int selectedFace in hull.selectedFaces)
			{
				int num = meshIndices[selectedFace * 3];
				int num2 = meshIndices[selectedFace * 3 + 1];
				int num3 = meshIndices[selectedFace * 3 + 2];
				dictionary[num] = num;
				dictionary[num2] = num2;
				dictionary[num3] = num3;
			}
			List<Vector3> list = new List<Vector3>();
			foreach (int key in dictionary.Keys)
			{
				list.Add(meshVertices[key]);
			}
			return list.ToArray();
		}

		private TriangleBucket FindBestBucket(Triangle tri, float thresholdAngleDeg, List<TriangleBucket> buckets)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			TriangleBucket result = null;
			float num = float.PositiveInfinity;
			foreach (TriangleBucket bucket in buckets)
			{
				float num2 = Vector3.Angle(tri.normal, bucket.GetAverageNormal());
				if (num2 < thresholdAngleDeg && num2 < num)
				{
					num = num2;
					result = bucket;
					continue;
				}
				float num3 = Vector3.Angle(tri.normal * -1f, bucket.GetAverageNormal());
				if (num3 < thresholdAngleDeg && num3 < num)
				{
					tri.normal *= -1f;
					num = num3;
					result = bucket;
				}
			}
			return result;
		}

		private void MergeClosestBuckets(List<TriangleBucket> buckets)
		{
			//IL_0033: 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)
			TriangleBucket triangleBucket = null;
			TriangleBucket triangleBucket2 = null;
			float num = float.PositiveInfinity;
			for (int i = 0; i < buckets.Count; i++)
			{
				for (int j = i + 1; j < buckets.Count; j++)
				{
					TriangleBucket triangleBucket3 = buckets[i];
					TriangleBucket triangleBucket4 = buckets[j];
					float num2 = Vector3.Angle(triangleBucket3.GetAverageNormal(), triangleBucket4.GetAverageNormal());
					if (num2 < num)
					{
						num = num2;
						triangleBucket = triangleBucket3;
						triangleBucket2 = triangleBucket4;
					}
				}
			}
			if (triangleBucket != null && triangleBucket2 != null)
			{
				buckets.Remove(triangleBucket2);
				triangleBucket.Add(triangleBucket2);
			}
		}

		private ConstructionPlane CreateConstructionPlane(TriangleBucket primaryBucket, TriangleBucket secondaryBucket, TriangleBucket tertiaryBucket)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0054: 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_0016: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007e: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			if (primaryBucket != null && secondaryBucket != null)
			{
				Vector3 averageNormal = primaryBucket.GetAverageNormal();
				Vector3 t = Vector3.Cross(averageNormal, secondaryBucket.GetAverageNormal());
				Vector3 averageCenter = primaryBucket.GetAverageCenter();
				return new ConstructionPlane(averageCenter, averageNormal, t);
			}
			if (primaryBucket != null)
			{
				Vector3 averageNormal2 = primaryBucket.GetAverageNormal();
				Vector3 averageCenter2 = primaryBucket.GetAverageCenter();
				Vector3 t2 = Vector3.Cross(averageNormal2, (!(Vector3.Dot(averageNormal2, Vector3.up) > 0.5f)) ? Vector3.up : Vector3.right);
				return new ConstructionPlane(averageCenter2, averageNormal2, t2);
			}
			return null;
		}
	}
	public class GizmoUtils
	{
		public static void ToggleGizmos(bool gizmosOn)
		{
			int num = (gizmosOn ? 1 : 0);
			Assembly assembly = Assembly.GetAssembly(typeof(Editor));
			Type type = assembly.GetType("UnityEditor.AnnotationUtility");
			if ((object)type == null)
			{
				return;
			}
			MethodInfo method = type.GetMethod("GetAnnotations", BindingFlags.Static | BindingFlags.NonPublic);
			MethodInfo method2 = type.GetMethod("SetGizmoEnabled", BindingFlags.Static | BindingFlags.NonPublic);
			MethodInfo method3 = type.GetMethod("SetIconEnabled", BindingFlags.Static | BindingFlags.NonPublic);
			object obj = method.Invoke(null, null);
			foreach (object item in (IEnumerable)obj)
			{
				Type type2 = item.GetType();
				FieldInfo field = type2.GetField("classID", BindingFlags.Instance | BindingFlags.Public);
				FieldInfo field2 = type2.GetField("scriptClass", BindingFlags.Instance | BindingFlags.Public);
				if ((object)field == null || (object)field2 == null)
				{
					continue;
				}
				int num2 = (int)field.GetValue(item);
				string text = (string)field2.GetValue(item);
				if (text == "HullPainter")
				{
					switch (method2.GetParameters().Length)
					{
					case 3:
						method2.Invoke(null, new object[3] { num2, text, num });
						break;
					case 4:
						method2.Invoke(null, new object[4] { num2, text, num, true });
						break;
					}
					int num3 = method3.GetParameters().Length;
					if (num3 == 3)
					{
						method3.Invoke(null, new object[3] { num2, text, num });
					}
				}
			}
		}
	}
	public class HullData : ScriptableObject
	{
	}
	public class HullMapping
	{
		public Hull sourceHull;

		public Collider generatedCollider;

		public MeshCollider[] autoGeneratedColliders;

		public HullPainterChild targetChild;

		public HullPainterChild[] targetAutoGeneratedChilds;

		public void AddAutoChild(HullPainterChild newChild, MeshCollider newCollider)
		{
			if ((Object)(object)newChild != (Object)null)
			{
				List<HullPainterChild> list = new List<HullPainterChild>();
				if (targetAutoGeneratedChilds != null)
				{
					list.AddRange(targetAutoGeneratedChilds);
				}
				if (!list.Contains(newChild))
				{
					list.Add(newChild);
					targetAutoGeneratedChilds = list.ToArray();
				}
			}
			if ((Object)(object)newCollider != (Object)null)
			{
				List<MeshCollider> list2 = new List<MeshCollider>();
				if (autoGeneratedColliders != null)
				{
					list2.AddRange(autoGeneratedColliders);
				}
				if (!list2.Contains(newCollider))
				{
					list2.Add(newCollider);
					autoGeneratedColliders = list2.ToArray();
				}
			}
		}
	}
	public class HullPainter : MonoBehaviour
	{
		public PaintingData paintingData;

		public HullData hullData;

		private List<HullMapping> hullMapping;

		private Mesh debugMesh;

		private void OnDestroy()
		{
			SceneView.RepaintAll();
		}

		public void CreateColliderComponents(Mesh[] autoHulls)
		{
			CreateHullMapping();
			foreach (Hull hull in paintingData.hulls)
			{
				UpdateCollider(hull);
			}
			foreach (Hull hull2 in paintingData.hulls)
			{
				CreateAutoHulls(hull2, autoHulls);
			}
		}

		public void RemoveAllColliders()
		{
			if (hullMapping == null)
			{
				return;
			}
			foreach (HullMapping item in hullMapping)
			{
				DestroyImmediateWithUndo((Object)(object)item.generatedCollider);
				if (item.autoGeneratedColliders != null)
				{
					MeshCollider[] autoGeneratedColliders = item.autoGeneratedColliders;
					foreach (MeshCollider obj in autoGeneratedColliders)
					{
						DestroyImmediateWithUndo((Object)(object)obj);
					}
				}
			}
			for (int num = hullMapping.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)hullMapping[num].targetChild != (Object)null)
				{
					hullMapping.RemoveAt(num);
				}
			}
		}

		public void RemoveAllGenerated()
		{
			CreateHullMapping();
			foreach (HullMapping item in hullMapping)
			{
				DestroyImmediateWithUndo((Object)(object)item.generatedCollider);
				if ((Object)(object)item.targetChild != (Object)null)
				{
					DestroyImmediateWithUndo((Object)(object)((Component)item.targetChild).gameObject);
				}
				if (item.autoGeneratedColliders != null)
				{
					MeshCollider[] autoGeneratedColliders = item.autoGeneratedColliders;
					foreach (MeshCollider obj in autoGeneratedColliders)
					{
						DestroyImmediateWithUndo((Object)(object)obj);
					}
				}
				if (item.targetAutoGeneratedChilds == null)
				{
					continue;
				}
				HullPainterChild[] targetAutoGeneratedChilds = item.targetAutoGeneratedChilds;
				foreach (HullPainterChild hullPainterChild in targetAutoGeneratedChilds)
				{
					GameObject gameObject = ((Component)hullPainterChild).gameObject;
					DestroyImmediateWithUndo((Object)(object)hullPainterChild);
					if (gameObject.transform.childCount == 0 && gameObject.GetComponents<Component>().Length == 1)
					{
						DestroyImmediateWithUndo((Object)(object)gameObject);
					}
				}
			}
		}

		private static bool IsDeletable(GameObject obj)
		{
			Component[] components = obj.GetComponents<Component>();
			int num = 0;
			Component[] array = components;
			foreach (Component val in array)
			{
				if (val is Transform || val is Collider || val is HullPainter || val is HullPainterChild)
				{
					num++;
				}
			}
			return components.Length == num;
		}

		private static void DestroyImmediateWithUndo(Object obj)
		{
			if (!(obj == (Object)null))
			{
				Undo.DestroyObjectImmediate(obj);
			}
		}

		private void CreateHullMapping()
		{
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: 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_05ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Unknown result type (might be due to invalid IL or missing references)
			//IL_069a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ab: 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)
			if (this.hullMapping == null)
			{
				this.hullMapping = new List<HullMapping>();
			}
			for (int num = this.hullMapping.Count - 1; num >= 0; num--)
			{
				HullMapping hullMapping = this.hullMapping[num];
				if (hullMapping == null || hullMapping.sourceHull == null || ((Object)(object)hullMapping.generatedCollider == (Object)null && (Object)(object)hullMapping.targetChild == (Object)null))
				{
					this.hullMapping.RemoveAt(num);
				}
			}
			foreach (Hull hull4 in paintingData.hulls)
			{
				if (IsMapped(hull4))
				{
					Collider val = FindExistingCollider(this.hullMapping, hull4);
					bool flag = hull4.type == HullType.ConvexHull && val is MeshCollider;
					bool flag2 = hull4.type == HullType.Box && val is BoxCollider;
					bool flag3 = hull4.type == HullType.Capsule && val is CapsuleCollider;
					bool flag4 = hull4.type == HullType.Sphere && val is SphereCollider;
					bool flag5 = hull4.type == HullType.Face && val is MeshCollider;
					bool flag6 = hull4.type == HullType.FaceAsBox && val is BoxCollider;
					bool flag7 = hull4.type == HullType.Auto && val is MeshCollider && hull4.autoMeshes != null && hull4.autoMeshes.Length > 0;
					bool flag8 = flag || flag2 || flag3 || flag4 || flag5 || flag6 || flag7;
					bool flag9 = (Object)(object)val == (Object)null || hull4.isChildCollider == ((Object)(object)((Component)val).transform.parent == (Object)(object)((Component)this).transform) || hull4.type == HullType.Auto;
					if (!flag8 || !flag9)
					{
						DestroyImmediateWithUndo((Object)(object)val);
						RemoveMapping(hull4);
					}
				}
			}
			List<Hull> list = new List<Hull>();
			List<Collider> list2 = new List<Collider>();
			List<HullPainterChild> list3 = new List<HullPainterChild>();
			foreach (Hull hull5 in paintingData.hulls)
			{
				if (!IsMapped(hull5))
				{
					list.Add(hull5);
				}
			}
			foreach (Collider item in FindLocal<Collider>())
			{
				if (!IsMapped(item))
				{
					list2.Add(item);
				}
			}
			foreach (HullPainterChild item2 in FindLocal<HullPainterChild>())
			{
				if (!IsMapped(item2))
				{
					list3.Add(item2);
				}
			}
			for (int num2 = list.Count - 1; num2 >= 0; num2--)
			{
				Hull hull = list[num2];
				bool flag10 = false;
				for (int num3 = list2.Count - 1; num3 >= 0; num3--)
				{
					Collider val2 = list2[num3];
					MeshCollider val3 = (MeshCollider)(object)((val2 is MeshCollider) ? val2 : null);
					BoxCollider val4 = (BoxCollider)(object)((val2 is BoxCollider) ? val2 : null);
					CapsuleCollider val5 = (CapsuleCollider)(object)((val2 is CapsuleCollider) ? val2 : null);
					SphereCollider val6 = (SphereCollider)(object)((val2 is SphereCollider) ? val2 : null);
					HullPainterChild hullPainterChild = null;
					if ((Object)(object)((Component)val2).transform.parent == (Object)(object)((Component)this).transform)
					{
						hullPainterChild = ((Component)val2).gameObject.GetComponent<HullPainterChild>();
					}
					bool flag11 = hull.isChildCollider && (Object)(object)((Component)val2).transform.parent == (Object)(object)((Component)this).transform;
					if ((Object)(object)hullPainterChild != (Object)null && hullPainterChild.isAutoHull && hull.type == HullType.Auto && (Object)(object)val3 != (Object)null && hull.ContainsAutoMesh(val3.sharedMesh))
					{
						HullMapping hullMapping2 = FindMapping(hull);
						if (hullMapping2 == null)
						{
							hullMapping2 = new HullMapping();
							hullMapping2.sourceHull = hull;
							this.hullMapping.Add(hullMapping2);
						}
						hullMapping2.AddAutoChild(hullPainterChild, (MeshCollider)(object)((val2 is MeshCollider) ? val2 : null));
						hullPainterChild.parent = this;
						list2.RemoveAt(num3);
						list3.Remove(hullPainterChild);
						flag10 = true;
					}
					else if (flag11)
					{
						bool flag12 = hull.type == HullType.Box && val2 is BoxCollider && Approximately(((Bounds)(ref hull.collisionBox.collisionBox)).center, val4.center) && Approximately(((Bounds)(ref hull.collisionBox.collisionBox)).size, val4.size);
						bool flag13 = hull.type == HullType.Sphere && val2 is SphereCollider && hull.collisionSphere != null && Approximately(hull.collisionSphere.center, val6.center) && Approximately(hull.collisionSphere.radius, val6.radius);
						bool flag14 = hull.type == HullType.Capsule && val2 is CapsuleCollider && Approximately(hull.collisionCapsule.capsuleCenter, val5.center) && hull.collisionCapsule.capsuleDirection == (CapsuleAxis)val5.direction && Approximately(hull.collisionCapsule.capsuleRadius, val5.radius) && Approximately(hull.collisionCapsule.capsuleHeight, val5.radius);
						bool flag15 = hull.type == HullType.ConvexHull && val2 is MeshCollider && (Object)(object)val3.sharedMesh == (Object)(object)hull.collisionMesh;
						bool flag16 = hull.type == HullType.Face && val2 is MeshCollider && (Object)(object)val3.sharedMesh == (Object)(object)hull.faceCollisionMesh;
						bool flag17 = hull.type == HullType.FaceAsBox && val2 is BoxCollider && Approximately(hull.faceBoxCenter, val4.center) && Approximately(hull.faceBoxSize, val4.size);
						if (flag12 || flag13 || flag14 || flag15 || flag16 || flag17)
						{
							AddMapping(hull, val2, hullPainterChild);
							list.RemoveAt(num2);
							list2.RemoveAt(num3);
							for (int i = 0; i < list3.Count; i++)
							{
								if ((Object)(object)list3[i] == (Object)(object)hullPainterChild)
								{
									list3.RemoveAt(i);
									break;
								}
							}
							break;
						}
					}
				}
				if (flag10)
				{
					list.RemoveAt(num2);
				}
			}
			for (int num4 = list.Count - 1; num4 >= 0; num4--)
			{
				Hull hull2 = list[num4];
				if (hull2.isChildCollider)
				{
					for (int num5 = list3.Count - 1; num5 >= 0; num5--)
					{
						HullPainterChild child = list3[num5];
						HullMapping hullMapping3 = FindMapping(child);
						if (hullMapping3 != null && hullMapping3.sourceHull != null)
						{
							if ((Object)(object)hullMapping3.generatedCollider == (Object)null)
							{
								RecreateChildCollider(hullMapping3);
							}
							list.RemoveAt(num4);
							list3.RemoveAt(num5);
							break;
						}
					}
				}
			}
			for (int num6 = list.Count - 1; num6 >= 0; num6--)
			{
				Hull hull3 = list[num6];
				if (hull3.isChildCollider && hull3.type == HullType.Auto)
				{
					bool flag18 = false;
					for (int num7 = list3.Count - 1; num7 >= 0; num7--)
					{
						HullPainterChild hullPainterChild2 = list3[num7];
						if (hullPainterChild2.isAutoHull && ((Object)((Component)hullPainterChild2).gameObject).name.StartsWith(hull3.name))
						{
							HullMapping hullMapping4 = FindMapping(hull3);
							if (hullMapping4 == null)
							{
								hullMapping4 = new HullMapping();
								hullMapping4.sourceHull = hull3;
								this.hullMapping.Add(hullMapping4);
							}
							hullMapping4.AddAutoChild(hullPainterChild2, null);
							list3.RemoveAt(num7);
							flag18 = true;
						}
					}
					if (flag18)
					{
						list.RemoveAt(num6);
					}
				}
			}
			foreach (HullMapping item3 in this.hullMapping)
			{
				if ((Object)(object)item3.targetChild != (Object)null && (Object)(object)item3.generatedCollider == (Object)null)
				{
					RecreateChildCollider(item3);
				}
			}
			foreach (HullMapping item4 in this.hullMapping)
			{
				if ((Object)(object)item4.targetChild == (Object)null && (Object)(object)item4.generatedCollider != (Object)null && (Object)(object)((Component)item4.generatedCollider).transform.parent == (Object)(object)((Component)this).transform)
				{
					HullPainterChild hullPainterChild3 = AddComponent<HullPainterChild>(((Component)item4.generatedCollider).gameObject);
					hullPainterChild3.parent = this;
					item4.targetChild = hullPainterChild3;
				}
			}
			foreach (Hull item5 in list)
			{
				if (item5.type == HullType.Box)
				{
					CreateCollider<BoxCollider>(item5);
				}
				else if (item5.type == HullType.Sphere)
				{
					CreateCollider<SphereCollider>(item5);
				}
				else if (item5.type == HullType.ConvexHull)
				{
					CreateCollider<MeshCollider>(item5);
				}
				else if (item5.type == HullType.Face)
				{
					CreateCollider<MeshCollider>(item5);
				}
				else if (item5.type == HullType.FaceAsBox)
				{
					CreateCollider<BoxCollider>(item5);
				}
				else if (item5.type == HullType.Capsule)
				{
					CreateCollider<CapsuleCollider>(item5);
				}
			}
			foreach (Collider item6 in list2)
			{
				if ((Object)(object)item6 == (Object)null)
				{
					continue;
				}
				if ((Object)(object)((Component)item6).gameObject == (Object)(object)((Component)this).gameObject)
				{
					DestroyImmediateWithUndo((Object)(object)item6);
					continue;
				}
				GameObject gameObject = ((Component)item6).gameObject;
				DestroyImmediateWithUndo((Object)(object)item6);
				DestroyImmediateWithUndo((Object)(object)gameObject.GetComponent<HullPainterChild>());
				if (IsDeletable(gameObject))
				{
					DestroyImmediateWithUndo((Object)(object)gameObject);
				}
			}
			foreach (HullPainterChild item7 in list3)
			{
				if (!((Object)(object)item7 == (Object)null))
				{
					GameObject gameObject2 = ((Component)item7).gameObject;
					DestroyImmediateWithUndo((Object)(object)item7);
					DestroyImmediateWithUndo((Object)(object)gameObject2.GetComponent<Collider>());
					if (IsDeletable(gameObject2))
					{
						DestroyImmediateWithUndo((Object)(object)gameObject2);
					}
				}
			}
		}

		private static bool Approximately(Vector3 lhs, Vector3 rhs)
		{
			return Mathf.Approximately(lhs.x, rhs.x) && Mathf.Approximately(lhs.y, rhs.y) && Mathf.Approximately(lhs.z, rhs.z);
		}

		private static bool Approximately(float lhs, float rhs)
		{
			return Mathf.Approximately(lhs, rhs);
		}

		private void CreateCollider<T>(Hull sourceHull) where T : Collider
		{
			//IL_0031: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			if (sourceHull.isChildCollider)
			{
				GameObject val = CreateGameObject(sourceHull.name);
				val.transform.SetParent(((Component)this).transform, false);
				val.transform.localPosition = Vector3.zero;
				val.transform.localRotation = Quaternion.identity;
				val.transform.localScale = Vector3.one;
				HullPainterChild hullPainterChild = AddComponent<HullPainterChild>(val);
				hullPainterChild.parent = this;
				T val2 = AddComponent<T>(val);
				AddMapping(sourceHull, (Collider)(object)val2, hullPainterChild);
			}
			else
			{
				T val3 = AddComponent<T>(((Component)this).gameObject);
				AddMapping(sourceHull, (Collider)(object)val3, null);
			}
		}

		private void RecreateChildCollider(HullMapping mapping)
		{
			if (mapping != null && mapping.sourceHull != null && mapping.sourceHull.isChildCollider)
			{
				if (mapping.sourceHull.type == HullType.Box)
				{
					RecreateChildCollider<BoxCollider>(mapping);
				}
				else if (mapping.sourceHull.type == HullType.Sphere)
				{
					RecreateChildCollider<SphereCollider>(mapping);
				}
				else if (mapping.sourceHull.type == HullType.ConvexHull)
				{
					RecreateChildCollider<MeshCollider>(mapping);
				}
				else if (mapping.sourceHull.type == HullType.Face)
				{
					RecreateChildCollider<MeshCollider>(mapping);
				}
				else if (mapping.sourceHull.type == HullType.FaceAsBox)
				{
					RecreateChildCollider<BoxCollider>(mapping);
				}
				else if (mapping.sourceHull.type == HullType.Capsule)
				{
					RecreateChildCollider<CapsuleCollider>(mapping);
				}
			}
		}

		private void RecreateChildCollider<T>(HullMapping mapping) where T : Collider
		{
			if (mapping.sourceHull != null && mapping.sourceHull.isChildCollider)
			{
				T val = AddComponent<T>(((Component)mapping.targetChild).gameObject);
				mapping.generatedCollider = (Collider)(object)val;
			}
		}

		private void UpdateCollider(Hull hull)
		{
			//IL_002d: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: 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_02c6: 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_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			Collider val = null;
			if (hull.type == HullType.Box)
			{
				Collider obj = FindExistingCollider(hullMapping, hull);
				BoxCollider val2 = (BoxCollider)(object)((obj is BoxCollider) ? obj : null);
				val2.center = ((Bounds)(ref hull.collisionBox.collisionBox)).center;
				val2.size = ((Bounds)(ref hull.collisionBox.collisionBox)).size + ((!hull.enableInflation) ? Vector3.zero : (Vector3.one * hull.inflationAmount));
				if (hull.isChildCollider)
				{
					((Component)val2).transform.localPosition = hull.collisionBox.boxPosition;
					((Component)val2).transform.localRotation = hull.collisionBox.boxRotation;
				}
				val = (Collider)(object)val2;
			}
			else if (hull.type == HullType.Sphere)
			{
				Collider obj2 = FindExistingCollider(hullMapping, hull);
				SphereCollider val3 = (SphereCollider)(object)((obj2 is SphereCollider) ? obj2 : null);
				val3.center = hull.collisionSphere.center;
				val3.radius = hull.collisionSphere.radius + ((!hull.enableInflation) ? 0f : hull.inflationAmount);
				val = (Collider)(object)val3;
			}
			else if (hull.type == HullType.Capsule)
			{
				Collider obj3 = FindExistingCollider(hullMapping, hull);
				CapsuleCollider val4 = (CapsuleCollider)(object)((obj3 is CapsuleCollider) ? obj3 : null);
				val4.center = hull.collisionCapsule.capsuleCenter;
				val4.direction = (int)hull.collisionCapsule.capsuleDirection;
				val4.radius = hull.collisionCapsule.capsuleRadius;
				val4.height = hull.collisionCapsule.capsuleHeight;
				if (hull.isChildCollider)
				{
					((Component)val4).transform.localPosition = hull.collisionCapsule.capsulePosition;
					((Component)val4).transform.localRotation = hull.collisionCapsule.capsuleRotation;
				}
				val = (Collider)(object)val4;
			}
			else if (hull.type == HullType.ConvexHull)
			{
				Collider obj4 = FindExistingCollider(hullMapping, hull);
				MeshCollider val5 = (MeshCollider)(object)((obj4 is MeshCollider) ? obj4 : null);
				val5.sharedMesh = hull.collisionMesh;
				val5.convex = true;
				val5.inflateMesh = hull.enableInflation;
				val5.skinWidth = hull.inflationAmount;
				val = (Collider)(object)val5;
			}
			else if (hull.type == HullType.Face)
			{
				Collider obj5 = FindExistingCollider(hullMapping, hull);
				MeshCollider val6 = (MeshCollider)(object)((obj5 is MeshCollider) ? obj5 : null);
				val6.sharedMesh = hull.faceCollisionMesh;
				val6.convex = true;
				val6.inflateMesh = hull.enableInflation;
				val6.skinWidth = hull.inflationAmount;
				val = (Collider)(object)val6;
			}
			else if (hull.type == HullType.FaceAsBox)
			{
				Collider obj6 = FindExistingCollider(hullMapping, hull);
				BoxCollider val7 = (BoxCollider)(object)((obj6 is BoxCollider) ? obj6 : null);
				val7.center = hull.faceBoxCenter;
				val7.size = hull.faceBoxSize + ((!hull.enableInflation) ? Vector3.zero : (Vector3.one * hull.inflationAmount));
				if (hull.isChildCollider)
				{
					((Component)val7).transform.localRotation = hull.faceAsBoxRotation;
				}
				val = (Collider)(object)val7;
			}
			else if (hull.type != HullType.Auto)
			{
			}
			if ((Object)(object)val != (Object)null)
			{
				val.material = hull.material;
				val.isTrigger = hull.isTrigger;
				if (hull.isChildCollider)
				{
					((Object)((Component)val).gameObject).name = hull.name;
				}
			}
		}

		public void SetAllTypes(HullType newType)
		{
			foreach (Hull hull in paintingData.hulls)
			{
				hull.type = newType;
			}
		}

		public void SetAllMaterials(PhysicMaterial newMaterial)
		{
			foreach (Hull hull in paintingData.hulls)
			{
				hull.material = newMaterial;
			}
		}

		public void SetAllAsChild(bool isChild)
		{
			foreach (Hull hull in paintingData.hulls)
			{
				hull.isChildCollider = isChild;
			}
		}

		public void SetAllAsTrigger(bool isTrigger)
		{
			foreach (Hull hull in paintingData.hulls)
			{
				hull.isTrigger = isTrigger;
			}
		}

		private List<T> FindLocal<T>() where T : Component
		{
			List<T> list = new List<T>();
			list.AddRange(((Component)this).gameObject.GetComponents<T>());
			for (int i = 0; i < ((Component)this).transform.childCount; i++)
			{
				list.AddRange(((Component)((Component)this).transform.GetChild(i)).GetComponents<T>());
			}
			return list;
		}

		private bool IsMapped(Hull hull)
		{
			if (hullMapping == null)
			{
				return false;
			}
			foreach (HullMapping item in hullMapping)
			{
				if (item.sourceHull == hull)
				{
					return true;
				}
			}
			return false;
		}

		private bool IsMapped(Collider col)
		{
			if (hullMapping == null)
			{
				return false;
			}
			foreach (HullMapping item in hullMapping)
			{
				if ((Object)(object)item.generatedCollider == (Object)(object)col)
				{
					return true;
				}
			}
			return false;
		}

		private bool IsMapped(HullPainterChild child)
		{
			if (hullMapping == null)
			{
				return false;
			}
			foreach (HullMapping item in hullMapping)
			{
				if ((Object)(object)item.targetChild == (Object)(object)child)
				{
					return true;
				}
			}
			return false;
		}

		private void AddMapping(Hull hull, Collider col, HullPainterChild painterChild)
		{
			HullMapping hullMapping = new HullMapping();
			hullMapping.sourceHull = hull;
			hullMapping.generatedCollider = col;
			hullMapping.targetChild = painterChild;
			HullMapping item = hullMapping;
			this.hullMapping.Add(item);
		}

		private void RemoveMapping(Hull hull)
		{
			for (int i = 0; i < hullMapping.Count; i++)
			{
				if (hullMapping[i].sourceHull == hull)
				{
					hullMapping.RemoveAt(i);
					break;
				}
			}
		}

		private HullMapping FindMapping(HullPainterChild child)
		{
			if (hullMapping == null)
			{
				return null;
			}
			foreach (HullMapping item in hullMapping)
			{
				if ((Object)(object)item.targetChild == (Object)(object)child)
				{
					return item;
				}
			}
			return null;
		}

		private HullMapping FindMapping(Hull hull)
		{
			if (hullMapping == null)
			{
				return null;
			}
			foreach (HullMapping item in hullMapping)
			{
				if (item.sourceHull == hull)
				{
					return item;
				}
			}
			return null;
		}

		public Hull FindSourceHull(HullPainterChild child)
		{
			if (hullMapping == null)
			{
				return null;
			}
			foreach (HullMapping item in hullMapping)
			{
				if ((Object)(object)item.targetChild == (Object)(object)child)
				{
					return item.sourceHull;
				}
				if (item.targetAutoGeneratedChilds == null)
				{
					continue;
				}
				HullPainterChild[] targetAutoGeneratedChilds = item.targetAutoGeneratedChilds;
				foreach (HullPainterChild hullPainterChild in targetAutoGeneratedChilds)
				{
					if ((Object)(object)hullPainterChild == (Object)(object)child)
					{
						return item.sourceHull;
					}
				}
			}
			return null;
		}

		private static Collider FindExistingCollider(List<HullMapping> mappings, Hull hull)
		{
			foreach (HullMapping mapping in mappings)
			{
				if (mapping.sourceHull == hull)
				{
					return mapping.generatedCollider;
				}
			}
			return null;
		}

		private void CreateAutoHulls(Hull hull, Mesh[] autoHulls)
		{
			if (hull.type != HullType.Auto)
			{
				return;
			}
			HullMapping hullMapping = FindMapping(hull);
			if (hullMapping == null)
			{
				hullMapping = new HullMapping();
				hullMapping.sourceHull = hull;
				this.hullMapping.Add(hullMapping);
			}
			Mesh[] autoMeshes = hull.autoMeshes;
			List<MeshCollider> list = new List<MeshCollider>();
			if (hullMapping.targetAutoGeneratedChilds != null)
			{
				for (int i = 0; i < hullMapping.targetAutoGeneratedChilds.Length; i++)
				{
					if (hullMapping.autoGeneratedColliders != null && i < hullMapping.autoGeneratedColliders.Length)
					{
						list.Add(hullMapping.autoGeneratedColliders[i]);
						continue;
					}
					MeshCollider val = ((Component)hullMapping.targetAutoGeneratedChilds[i]).gameObject.AddComponent<MeshCollider>();
					val.convex = true;
					list.Add(val);
				}
			}
			for (int num = list.Count - 1; num >= 0; num--)
			{
				bool flag = (Object)(object)((Component)list[num]).transform != (Object)(object)((Component)this).transform;
				if (flag != Object.op_Implicit((Object)(object)((Component)this).transform) && hull.isChildCollider)
				{
					if (flag)
					{
						Object.DestroyImmediate((Object)(object)((Component)list[num]).gameObject);
					}
					else
					{
						Object.DestroyImmediate((Object)(object)list[num]);
					}
					list.RemoveAt(num);
				}
			}
			for (int j = 0; j < autoMeshes.Length; j++)
			{
				Mesh sharedMesh = autoMeshes[j];
				MeshCollider val2;
				if (j < list.Count)
				{
					val2 = list[j];
				}
				else if (hull.isChildCollider)
				{
					GameObject val3 = CreateGameObject("New child");
					val3.transform.SetParent(((Component)this).transform, false);
					HullPainterChild hullPainterChild = val3.AddComponent<HullPainterChild>();
					hullPainterChild.parent = this;
					hullPainterChild.isAutoHull = true;
					val2 = val3.AddComponent<MeshCollider>();
					list.Add(val2);
				}
				else
				{
					val2 = ((Component)this).gameObject.AddComponent<MeshCollider>();
					list.Add(val2);
				}
				val2.sharedMesh = sharedMesh;
				val2.convex = true;
				((Collider)val2).isTrigger = hull.isTrigger;
				((Collider)val2).material = hull.material;
			}
			if (hull.isChildCollider)
			{
				for (int k = 0; k < list.Count; k++)
				{
					((Object)((Component)list[k]).gameObject).name = $"{hull.name}.{k + 1}";
				}
			}
			List<HullPainterChild> list2 = new List<HullPainterChild>();
			foreach (MeshCollider item in list)
			{
				list2.Add(((Component)item).GetComponent<HullPainterChild>());
			}
			hullMapping.autoGeneratedColliders = list.ToArray();
			hullMapping.targetAutoGeneratedChilds = list2.ToArray();
		}

		private static GameObject CreateGameObject(string goName)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			GameObject val = new GameObject(goName);
			Undo.RegisterCreatedObjectUndo((Object)(object)val, "Created " + goName);
			return val;
		}

		private static T AddComponent<T>(GameObject targetObj) where T : Component
		{
			return (T)(object)Undo.AddComponent(targetObj, typeof(T));
		}

		private void OnDrawGizmos()
		{
		}
	}
	public class HullPainterChild : MonoBehaviour
	{
		public HullPainter parent;

		public bool isAutoHull;
	}
}
public class CuttableMesh
{
	private MeshRenderer inputMeshRenderer;

	private bool hasUvs;

	private bool hasUv1s;

	private bool hasColours;

	private List<CuttableSubMesh> subMeshes;

	public CuttableMesh(Mesh inputMesh)
	{
		Init(inputMesh, ((Object)inputMesh).name);
	}

	public CuttableMesh(MeshRenderer input)
	{
		inputMeshRenderer = input;
		MeshFilter component = ((Component)input).GetComponent<MeshFilter>();
		Mesh sharedMesh = component.sharedMesh;
		Init(sharedMesh, ((Object)input).name);
	}

	public CuttableMesh(CuttableMesh inputMesh, List<CuttableSubMesh> newSubMeshes)
	{
		inputMeshRenderer = inputMesh.inputMeshRenderer;
		hasUvs = inputMesh.hasUvs;
		hasUv1s = inputMesh.hasUv1s;
		hasColours = inputMesh.hasColours;
		subMeshes = new List<CuttableSubMesh>();
		subMeshes.AddRange(newSubMeshes);
	}

	private void Init(Mesh inputMesh, string debugName)
	{
		subMeshes = new List<CuttableSubMesh>();
		if (inputMesh.isReadable)
		{
			Vector3[] vertices = inputMesh.vertices;
			Vector3[] normals = inputMesh.normals;
			Vector2[] uv = inputMesh.uv;
			Vector2[] uv2 = inputMesh.uv2;
			Color32[] colors = inputMesh.colors32;
			hasUvs = uv != null && uv.Length > 0;
			hasUv1s = uv2 != null && uv2.Length > 0;
			hasColours = colors != null && colors.Length > 0;
			for (int i = 0; i < inputMesh.subMeshCount; i++)
			{
				int[] indices = inputMesh.GetIndices(i);
				CuttableSubMesh item = new CuttableSubMesh(indices, vertices, normals, colors, uv, uv2);
				subMeshes.Add(item);
			}
		}
		else
		{
			Debug.LogError((object)("CuttableMesh's input mesh is not readable: " + debugName), (Object)(object)inputMesh);
		}
	}

	public void Add(CuttableMesh other)
	{
		if (subMeshes.Count != other.subMeshes.Count)
		{
			throw new Exception("Mismatched submesh count");
		}
		for (int i = 0; i < subMeshes.Count; i++)
		{
			subMeshes[i].Add(other.subMeshes[i]);
		}
	}

	public int NumSubMeshes()
	{
		return subMeshes.Count;
	}

	public bool HasUvs()
	{
		return hasUvs;
	}

	public bool HasColours()
	{
		return hasColours;
	}

	public List<CuttableSubMesh> GetSubMeshes()
	{
		return subMeshes;
	}

	public CuttableSubMesh GetSubMesh(int index)
	{
		return subMeshes[index];
	}

	public Transform GetTransform()
	{
		if ((Object)(object)inputMeshRenderer != (Object)null)
		{
			return ((Component)inputMeshRenderer).transform;
		}
		return null;
	}

	public MeshRenderer ConvertToRenderer(string newObjectName)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_003d: 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_005d: 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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		Mesh val = CreateMesh();
		if (val.vertexCount == 0)
		{
			return null;
		}
		GameObject val2 = new GameObject(newObjectName);
		val2.transform.SetParent(((Component)inputMeshRenderer).transform);
		val2.transform.localPosition = Vector3.zero;
		val2.transform.localRotation = Quaternion.identity;
		val2.transform.localScale = Vector3.one;
		MeshFilter val3 = val2.AddComponent<MeshFilter>();
		val3.mesh = val;
		MeshRenderer val4 = val2.AddComponent<MeshRenderer>();
		((Renderer)val4).shadowCastingMode = ((Renderer)inputMeshRenderer).shadowCastingMode;
		((Renderer)val4).reflectionProbeUsage = ((Renderer)inputMeshRenderer).reflectionProbeUsage;
		((Renderer)val4).lightProbeUsage = ((Renderer)inputMeshRenderer).lightProbeUsage;
		((Renderer)val4).sharedMaterials = ((Renderer)inputMeshRenderer).sharedMaterials;
		return val4;
	}

	public Mesh CreateMesh()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		Mesh val = new Mesh();
		int num = 0;
		for (int i = 0; i < subMeshes.Count; i++)
		{
			num += subMeshes[i].NumIndices();
		}
		List<Vector3> list = new List<Vector3>();
		List<Vector3> list2 = new List<Vector3>();
		List<Color32> list3 = ((!hasColours) ? null : new List<Color32>());
		List<Vector2> list4 = ((!hasUvs) ? null : new List<Vector2>());
		List<Vector2> list5 = ((!hasUv1s) ? null : new List<Vector2>());
		List<int> list6 = new List<int>();
		foreach (CuttableSubMesh subMesh in subMeshes)
		{
			list6.Add(list.Count);
			subMesh.AddTo(list, list2, list3, list4, list5);
		}
		val.vertices = list.ToArray();
		val.normals = list2.ToArray();
		val.colors32 = ((!hasColours) ? null : list3.ToArray());
		val.uv = ((!hasUvs) ? null : list4.ToArray());
		val.uv2 = ((!hasUv1s) ? null : list5.ToArray());
		val.subMeshCount = subMeshes.Count;
		for (int j = 0; j < subMeshes.Count; j++)
		{
			CuttableSubMesh cuttableSubMesh = subMeshes[j];
			int num2 = list6[j];
			int[] array = cuttableSubMesh.GenIndices();
			for (int k = 0; k < array.Length; k++)
			{
				array[k] += num2;
			}
			val.SetTriangles(array, j, true);
		}
		return val;
	}
}
public class CuttableSubMesh
{
	private List<Vector3> vertices;

	private List<Vector3> normals;

	private List<Color32> colours;

	private List<Vector2> uvs;

	private List<Vector2> uv1s;

	public CuttableSubMesh(bool hasNormals, bool hasColours, bool hasUvs, bool hasUv1)
	{
		vertices = new List<Vector3>();
		if (hasNormals)
		{
			normals = new List<Vector3>();
		}
		if (hasColours)
		{
			colours = new List<Color32>();
		}
		if (hasUvs)
		{
			uvs = new List<Vector2>();
		}
		if (hasUv1)
		{
			uv1s = new List<Vector2>();
		}
	}

	public CuttableSubMesh(int[] indices, Vector3[] inputVertices, Vector3[] inputNormals, Color32[] inputColours, Vector2[] inputUvs, Vector2[] inputUv1)
	{
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		vertices = new List<Vector3>();
		if (inputNormals != null && inputNormals.Length > 0)
		{
			normals = new List<Vector3>();
		}
		if (inputColours != null && inputColours.Length > 0)
		{
			colours = new List<Color32>();
		}
		if (inputUvs != null && inputUvs.Length > 0)
		{
			uvs = new List<Vector2>();
		}
		if (inputUv1 != null && inputUv1.Length > 0)
		{
			uv1s = new List<Vector2>();
		}
		foreach (int num in indices)
		{
			vertices.Add(inputVertices[num]);
			if (normals != null)
			{
				normals.Add(inputNormals[num]);
			}
			if (colours != null)
			{
				colours.Add(inputColours[num]);
			}
			if (uvs != null)
			{
				uvs.Add(inputUvs[num]);
			}
			if (uv1s != null)
			{
				uv1s.Add(inputUv1[num]);
			}
		}
	}

	public void Add(CuttableSubMesh other)
	{
		for (int i = 0; i < other.vertices.Count; i++)
		{
			CopyVertex(i, other);
		}
	}

	public int NumVertices()
	{
		return vertices.Count;
	}

	public Vector3 GetVertex(int index)
	{
		//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_0013: Unknown result type (might be due to invalid IL or missing references)
		return vertices[index];
	}

	public bool HasNormals()
	{
		return normals != null;
	}

	public bool HasColours()
	{
		return colours != null;
	}

	public bool HasUvs()
	{
		return uvs != null;
	}

	public bool HasUv1()
	{
		return uv1s != null;
	}

	public void CopyVertex(int srcIndex, CuttableSubMesh srcMesh)
	{
		//IL_000e: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		vertices.Add(srcMesh.vertices[srcIndex]);
		if (normals != null)
		{
			normals.Add(srcMesh.normals[srcIndex]);
		}
		if (colours != null)
		{
			colours.Add(srcMesh.colours[srcIndex]);
		}
		if (uvs != null)
		{
			uvs.Add(srcMesh.uvs[srcIndex]);
		}
		if (uv1s != null)
		{
			uv1s.Add(srcMesh.uv1s[srcIndex]);
		}
	}

	public void AddInterpolatedVertex(int i0, int i1, float weight, CuttableSubMesh srcMesh)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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_0012: 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_001a: 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_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: 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_0057: 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_007d: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
		Vector3 vertex = srcMesh.GetVertex(i0);
		Vector3 vertex2 = srcMesh.GetVertex(i1);
		vertices.Add(Vector3.Lerp(vertex, vertex2, weight));
		if (normals != null)
		{
			List<Vector3> list = normals;
			Vector3 val = Vector3.Lerp(srcMesh.normals[i0], srcMesh.normals[i1], weight);
			list.Add(((Vector3)(ref val)).normalized);
		}
		if (colours != null)
		{
			colours.Add(Color32.Lerp(srcMesh.colours[i0], srcMesh.colours[i1], weight));
		}
		if (uvs != null)
		{
			uvs.Add(Vector2.Lerp(srcMesh.uvs[i0], srcMesh.uvs[i1], weight));
		}
		if (uv1s != null)
		{
			uv1s.Add(Vector2.Lerp(srcMesh.uv1s[i0], srcMesh.uv1s[i1], weight));
		}
	}

	public void AddTo(List<Vector3> destVertices, List<Vector3> destNormals, List<Color32> destColours, List<Vector2> destUvs, List<Vector2> destUv1s)
	{
		destVertices.AddRange(vertices);
		if (normals != null)
		{
			destNormals.AddRange(normals);
		}
		if (colours != null)
		{
			destColours.AddRange(colours);
		}
		if (uvs != null)
		{
			destUvs.AddRange(uvs);
		}
		if (uv1s != null)
		{
			destUv1s.AddRange(uv1s);
		}
	}

	public int NumIndices()
	{
		return vertices.Count;
	}

	public int[] GenIndices()
	{
		int[] array = new int[vertices.Count];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = i;
		}
		return array;
	}
}
public enum VertexClassification
{
	Front = 1,
	Back = 2,
	OnPlane = 4
}
public class MeshCutter
{
	private CuttableMesh inputMesh;

	private List<CuttableSubMesh> outputFrontSubMeshes;

	private List<CuttableSubMesh> outputBackSubMeshes;

	public void Cut(CuttableMesh input, Plane worldCutPlane)
	{
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		inputMesh = input;
		outputFrontSubMeshes = new List<CuttableSubMesh>();
		outputBackSubMeshes = new List<CuttableSubMesh>();
		Transform transform = inputMesh.GetTransform();
		Plane cutPlane = default(Plane);
		if ((Object)(object)transform != (Object)null)
		{
			Vector3 val = transform.InverseTransformPoint(ClosestPointOnPlane(worldCutPlane, Vector3.zero));
			Vector3 val2 = transform.InverseTransformDirection(((Plane)(ref worldCutPlane)).normal);
			((Plane)(ref cutPlane))..ctor(val2, val);
		}
		else
		{
			cutPlane = worldCutPlane;
		}
		foreach (CuttableSubMesh subMesh in input.GetSubMeshes())
		{
			Cut(subMesh, cutPlane);
		}
	}

	private static Vector3 ClosestPointOnPlane(Plane plane, Vector3 point)
	{
		//IL_0003: 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_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0045: 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_001b: 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)
		//IL_0026: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		float distanceToPoint = ((Plane)(ref plane)).GetDistanceToPoint(point);
		if (((Plane)(ref plane)).GetSide(point))
		{
			return point - ((Plane)(ref plane)).normal * distanceToPoint;
		}
		return point + ((Plane)(ref plane)).normal * distanceToPoint;
	}

	public CuttableMesh GetFrontOutput()
	{
		return new CuttableMesh(inputMesh, outputFrontSubMeshes);
	}

	public CuttableMesh GetBackOutput()
	{
		return new CuttableMesh(inputMesh, outputBackSubMeshes);
	}

	private void Cut(CuttableSubMesh inputSubMesh, Plane cutPlane)
	{
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: 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_0121: 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_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02df: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_0261: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		bool hasNormals = inputSubMesh.HasNormals();
		bool hasColours = inputSubMesh.HasColours();
		bool hasUvs = inputSubMesh.HasUvs();
		bool hasUv = inputSubMesh.HasUv1();
		CuttableSubMesh cuttableSubMesh = new CuttableSubMesh(hasNormals, hasColours, hasUvs, hasUv);
		CuttableSubMesh cuttableSubMesh2 = new CuttableSubMesh(hasNormals, hasColours, hasUvs, hasUv);
		for (int i = 0; i < inputSubMesh.NumVertices(); i += 3)
		{
			int num = i;
			int num2 = i + 1;
			int num3 = i + 2;
			Vector3 vertex = inputSubMesh.GetVertex(num);
			Vector3 vertex2 = inputSubMesh.GetVertex(num2);
			Vector3 vertex3 = inputSubMesh.GetVertex(num3);
			VertexClassification vertexClassification = Classify(vertex, cutPlane);
			VertexClassification vertexClassification2 = Classify(vertex2, cutPlane);
			VertexClassification vertexClassification3 = Classify(vertex3, cutPlane);
			int numFront = 0;
			int numBehind = 0;
			CountSides(vertexClassification, ref numFront, ref numBehind);
			CountSides(vertexClassification2, ref numFront, ref numBehind);
			CountSides(vertexClassification3, ref numFront, ref numBehind);
			if (numFront > 0 && numBehind == 0)
			{
				KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh);
			}
			else if (numFront == 0 && numBehind > 0)
			{
				KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh2);
			}
			else if (numFront == 2 && numBehind == 1)
			{
				if (vertexClassification == VertexClassification.Back)
				{
					SplitA(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh);
				}
				else if (vertexClassification2 == VertexClassification.Back)
				{
					SplitA(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh);
				}
				else
				{
					SplitA(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh2, cuttableSubMesh);
				}
			}
			else if (numFront == 1 && numBehind == 2)
			{
				if (vertexClassification == VertexClassification.Front)
				{
					SplitA(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
				}
				else if (vertexClassification2 == VertexClassification.Front)
				{
					SplitA(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
				}
				else
				{
					SplitA(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
				}
			}
			else if (numFront == 1 && numBehind == 1)
			{
				if (vertexClassification == VertexClassification.OnPlane)
				{
					if (vertexClassification3 == VertexClassification.Front)
					{
						SplitB(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
					}
					else
					{
						SplitBFlipped(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
					}
					continue;
				}
				switch (vertexClassification2)
				{
				case VertexClassification.OnPlane:
					if (vertexClassification == VertexClassification.Front)
					{
						SplitB(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
					}
					else
					{
						SplitBFlipped(num3, num, num2, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
					}
					break;
				case VertexClassification.Front:
					SplitB(num2, num3, num, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
					break;
				default:
					SplitBFlipped(num, num2, num3, inputSubMesh, cutPlane, cuttableSubMesh, cuttableSubMesh2);
					break;
				}
			}
			else if (numFront == 0 && numBehind == 0)
			{
				Vector3 val = vertex2 - vertex;
				Vector3 val2 = vertex3 - vertex;
				Vector3 val3 = Vector3.Cross(val, val2);
				if (Vector3.Dot(val3, ((Plane)(ref cutPlane)).normal) > 0f)
				{
					KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh2);
				}
				else
				{
					KeepTriangle(num, num2, num3, inputSubMesh, cuttableSubMesh);
				}
			}
		}
		outputFrontSubMeshes.Add(cuttableSubMesh);
		outputBackSubMeshes.Add(cuttableSubMesh2);
	}

	private VertexClassification Classify(Vector3 vertex, Plane cutPlane)
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(vertex.x, vertex.y, vertex.z);
		float distanceToPoint = ((Plane)(ref cutPlane)).GetDistanceToPoint(val);
		double num = 9.999999747378752E-06;
		if ((double)distanceToPoint > 0.0 - num && (double)distanceToPoint < num)
		{
			return VertexClassification.OnPlane;
		}
		if (distanceToPoint > 0f)
		{
			return VertexClassification.Front;
		}
		return VertexClassification.Back;
	}

	private void CountSides(VertexClassification c, ref int numFront, ref int numBehind)
	{
		switch (c)
		{
		case VertexClassification.Front:
			numFront++;
			break;
		case VertexClassification.Back:
			numBehind++;
			break;
		}
	}

	private void KeepTriangle(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, CuttableSubMesh destSubMesh)
	{
		destSubMesh.CopyVertex(i0, inputSubMesh);
		destSubMesh.CopyVertex(i1, inputSubMesh);
		destSubMesh.CopyVertex(i2, inputSubMesh);
	}

	private void SplitA(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: 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_0023: 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_002c: 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)
		Vector3 vertex = inputSubMesh.GetVertex(i0);
		Vector3 vertex2 = inputSubMesh.GetVertex(i1);
		Vector3 vertex3 = inputSubMesh.GetVertex(i2);
		CalcIntersection(vertex, vertex2, cutPlane, out var weight);
		CalcIntersection(vertex3, vertex, cutPlane, out var weight2);
		frontSubMesh.CopyVertex(i0, inputSubMesh);
		frontSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
		frontSubMesh.AddInterpolatedVertex(i2, i0, weight2, inputSubMesh);
		backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
		backSubMesh.CopyVertex(i1, inputSubMesh);
		backSubMesh.CopyVertex(i2, inputSubMesh);
		backSubMesh.CopyVertex(i2, inputSubMesh);
		backSubMesh.AddInterpolatedVertex(i2, i0, weight2, inputSubMesh);
		backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
	}

	private void SplitB(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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_0012: 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_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		Vector3 vertex = inputSubMesh.GetVertex(i0);
		Vector3 vertex2 = inputSubMesh.GetVertex(i2);
		CalcIntersection(vertex2, vertex, cutPlane, out var weight);
		frontSubMesh.CopyVertex(i0, inputSubMesh);
		frontSubMesh.CopyVertex(i1, inputSubMesh);
		frontSubMesh.AddInterpolatedVertex(i2, i0, weight, inputSubMesh);
		backSubMesh.CopyVertex(i1, inputSubMesh);
		backSubMesh.CopyVertex(i2, inputSubMesh);
		backSubMesh.AddInterpolatedVertex(i2, i0, weight, inputSubMesh);
	}

	private void SplitBFlipped(int i0, int i1, int i2, CuttableSubMesh inputSubMesh, Plane cutPlane, CuttableSubMesh frontSubMesh, CuttableSubMesh backSubMesh)
	{
		//IL_0004: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: 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_0012: 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_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		Vector3 vertex = inputSubMesh.GetVertex(i0);
		Vector3 vertex2 = inputSubMesh.GetVertex(i1);
		CalcIntersection(vertex, vertex2, cutPlane, out var weight);
		frontSubMesh.CopyVertex(i0, inputSubMesh);
		frontSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
		frontSubMesh.CopyVertex(i2, inputSubMesh);
		backSubMesh.CopyVertex(i1, inputSubMesh);
		backSubMesh.CopyVertex(i2, inputSubMesh);
		backSubMesh.AddInterpolatedVertex(i0, i1, weight, inputSubMesh);
	}

	private Vector3 CalcIntersection(Vector3 v0, Vector3 v1, Plane plane, out float weight)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: 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_0016: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = v1 - v0;
		float magnitude = ((Vector3)(ref val)).magnitude;
		Ray val2 = default(Ray);
		((Ray)(ref val2))..ctor(v0, val / magnitude);
		float num = default(float);
		((Plane)(ref plane)).Raycast(val2, ref num);
		Vector3 result = ((Ray)(ref val2)).origin + ((Ray)(ref val2)).direction * num;
		weight = num / magnitude;
		return result;
	}
}
namespace Technie.PhysicsCreator
{
	public enum HullType
	{
		Box,
		ConvexHull,
		Sphere,
		Face,
		FaceAsBox,
		Auto,
		Capsule
	}
	public enum AutoHullPreset
	{
		Low,
		Medium,
		High,
		Placebo,
		Custom
	}
	public enum CapsuleAxis
	{
		X,
		Y,
		Z
	}
	public struct BoxDef
	{
		public Bounds collisionBox;

		public Vector3 boxPosition;

		public Quaternion boxRotation;
	}
	public struct CapsuleDef
	{
		public Vector3 capsuleCenter;

		public CapsuleAxis capsuleDirection;

		public float capsuleRadius;

		public float capsuleHeight;

		public Vector3 capsulePosition;

		public Quaternion capsuleRotation;
	}
	[Serializable]
	public class Hull
	{
		public string name = "<unnamed hull>";

		public bool isVisible = true;

		public HullType type = HullType.ConvexHull;

		public Color colour = Color.white;

		public PhysicMaterial material;

		public bool enableInflation = false;

		public float inflationAmount = 0.01f;

		public BoxFitMethod boxFitMethod = BoxFitMethod.MinimumVolume;

		public bool isTrigger = false;

		public bool isChildCollider = false;

		public List<int> selectedFaces = new List<int>();

		public Mesh collisionMesh;

		public BoxDef collisionBox;

		public Sphere collisionSphere;

		public Mesh faceCollisionMesh;

		public Vector3 faceBoxCenter;

		public Vector3 faceBoxSize;

		public Quaternion faceAsBoxRotation;

		public CapsuleDef collisionCapsule;

		public Mesh[] autoMeshes = (Mesh[])(object)new Mesh[0];

		public bool hasColliderError;

		public int numColliderFaces;

		public bool noInputError;

		public void Destroy()
		{
		}

		public bool ContainsAutoMesh(Mesh m)
		{
			if (autoMeshes != null)
			{
				Mesh[] array = autoMeshes;
				foreach (Mesh val in array)
				{
					if ((Object)(object)val == (Object)(object)m)
					{
						return true;
					}
				}
			}
			return false;
		}
	}
	public class PaintingData : ScriptableObject
	{
		public readonly Color[] hullColours = (Color[])(object)new Color[13]
		{
			new Color(0f, 1f, 1f, 0.7f),
			new Color(1f, 0f, 1f, 0.7f),
			new Color(1f, 1f, 0f, 0.7f),
			new Color(1f, 0f, 0f, 0.7f),
			new Color(0f, 1f, 0f, 0.7f),
			new Color(0f, 0f, 1f, 0.7f),
			new Color(1f, 1f, 1f, 0.7f),
			new Color(1f, 0.5f, 0f, 0.7f),
			new Color(1f, 0f, 0.5f, 0.7f),
			new Color(0.5f, 1f, 0f, 0.7f),
			new Color(0f, 1f, 0.5f, 0.7f),
			new Color(0.5f, 0f, 1f, 0.7f),
			new Color(0f, 0.5f, 1f, 0.7f)
		};

		public HullData hullData;

		public Mesh sourceMesh;

		public int activeHull = -1;

		public float faceThickness = 0.1f;

		public List<Hull> hulls = new List<Hull>();

		public AutoHullPreset autoHullPreset = AutoHullPreset.Medium;

		public VhacdParameters vhacdParams = new VhacdParameters();

		public bool hasLastVhacdTimings = false;

		public AutoHullPreset lastVhacdPreset = AutoHullPreset.Medium;

		public float lastVhacdDurationSecs = 0f;

		public int TotalOutputColliders
		{
			get
			{
				int num = 0;
				foreach (Hull hull in hulls)
				{
					num = ((hull.type != HullType.Auto) ? (num + 1) : (num + ((hull.autoMeshes != null) ? hull.autoMeshes.Length : 0)));
				}
				return num;
			}
		}

		public void AddHull(HullType type, PhysicMaterial material, bool isChild, bool isTrigger)
		{
			//IL_008d: 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)
			hulls.Add(new Hull());
			hulls[hulls.Count - 1].name = "Hull " + hulls.Count;
			activeHull = hulls.Count - 1;
			hulls[hulls.Count - 1].colour = hullColours[activeHull % hullColours.Length];
			hulls[hulls.Count - 1].type = type;
			hulls[hulls.Count - 1].material = material;
			hulls[hulls.Count - 1].isTrigger = isTrigger;
			hulls[hulls.Count - 1].isChildCollider = isChild;
		}

		public void RemoveHull(int index)
		{
			if (index >= 0 && index < hulls.Count)
			{
				hulls[index].Destroy();
				hulls.RemoveAt(index);
			}
		}

		public void RemoveAllHulls()
		{