Decompiled source of SR Brutalist v0.1.2

SR_Brutalist.dll

Decompiled 5 months ago
using System;
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 HarmonyLib;
using ProBuilder2.Common;
using ProBuilder2.MeshOperations;
using UnityEditor;
using UnityEngine;
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]
public class LookCamera : MonoBehaviour
{
	public float speedNormal = 10f;

	public float speedFast = 50f;

	public float mouseSensitivityX = 5f;

	public float mouseSensitivityY = 5f;

	private float rotY = 0f;

	private void Start()
	{
		if (Object.op_Implicit((Object)(object)((Component)this).GetComponent<Rigidbody>()))
		{
			((Component)this).GetComponent<Rigidbody>().freezeRotation = true;
		}
	}

	private void Update()
	{
		//IL_0013: 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_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		if (Input.GetMouseButton(1))
		{
			float num = ((Component)this).transform.localEulerAngles.y + Input.GetAxis("Mouse X") * mouseSensitivityX;
			rotY += Input.GetAxis("Mouse Y") * mouseSensitivityY;
			rotY = Mathf.Clamp(rotY, -89.5f, 89.5f);
			((Component)this).transform.localEulerAngles = new Vector3(0f - rotY, num, 0f);
		}
		if (Input.GetKey((KeyCode)117))
		{
			((Component)this).gameObject.transform.localPosition = new Vector3(0f, 3500f, 0f);
		}
	}
}
public class SkyboxChanger : MonoBehaviour
{
	public Material[] Skyboxes;

	private Dropdown _dropdown;

	public void Awake()
	{
		_dropdown = ((Component)this).GetComponent<Dropdown>();
	}

	public void ChangeSkybox()
	{
		RenderSettings.skybox = Skyboxes[_dropdown.value];
	}
}
namespace Prometheuz.SR_Brutalist;

[BepInPlugin("Prometheuz.SR_Brutalist", "SR_Brutalist", "0.1.2")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("nrgill28.Atlas", "1.0.1")]
public class SR_BrutalistPlugin : 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(), "Prometheuz.SR_Brutalist");
		AtlasPlugin.RegisterScene(Path.Combine(BasePath, "brutalistsr"));
	}
}
[RequireComponent(typeof(MeshFilter))]
[RequireComponent(typeof(MeshRenderer))]
public class MeshCombiner : MonoBehaviour
{
	private const int Mesh16BitBufferVertexLimit = 65535;

	[SerializeField]
	private bool createMultiMaterialMesh = false;

	[SerializeField]
	private bool combineInactiveChildren = false;

	[SerializeField]
	private bool deactivateCombinedChildren = true;

	[SerializeField]
	private bool deactivateCombinedChildrenMeshRenderers = false;

	[SerializeField]
	private bool generateUVMap = false;

	[SerializeField]
	private bool destroyCombinedChildren = false;

	[SerializeField]
	private string folderPath = "Prefabs/CombinedMeshes";

	[SerializeField]
	[Tooltip("MeshFilters with Meshes which we don't want to combine into one Mesh.")]
	private MeshFilter[] meshFiltersToSkip = (MeshFilter[])(object)new MeshFilter[0];

	public bool CreateMultiMaterialMesh
	{
		get
		{
			return createMultiMaterialMesh;
		}
		set
		{
			createMultiMaterialMesh = value;
		}
	}

	public bool CombineInactiveChildren
	{
		get
		{
			return combineInactiveChildren;
		}
		set
		{
			combineInactiveChildren = value;
		}
	}

	public bool DeactivateCombinedChildren
	{
		get
		{
			return deactivateCombinedChildren;
		}
		set
		{
			deactivateCombinedChildren = value;
			CheckDeactivateCombinedChildren();
		}
	}

	public bool DeactivateCombinedChildrenMeshRenderers
	{
		get
		{
			return deactivateCombinedChildrenMeshRenderers;
		}
		set
		{
			deactivateCombinedChildrenMeshRenderers = value;
			CheckDeactivateCombinedChildren();
		}
	}

	public bool GenerateUVMap
	{
		get
		{
			return generateUVMap;
		}
		set
		{
			generateUVMap = value;
		}
	}

	public bool DestroyCombinedChildren
	{
		get
		{
			return destroyCombinedChildren;
		}
		set
		{
			destroyCombinedChildren = value;
			CheckDestroyCombinedChildren();
		}
	}

	public string FolderPath
	{
		get
		{
			return folderPath;
		}
		set
		{
			folderPath = value;
		}
	}

	private void CheckDeactivateCombinedChildren()
	{
		if (deactivateCombinedChildren || deactivateCombinedChildrenMeshRenderers)
		{
			destroyCombinedChildren = false;
		}
	}

	private void CheckDestroyCombinedChildren()
	{
		if (destroyCombinedChildren)
		{
			deactivateCombinedChildren = false;
			deactivateCombinedChildrenMeshRenderers = false;
		}
	}

	public void CombineMeshes(bool showCreatedMeshInfo)
	{
		//IL_0007: 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_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_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_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_005d: 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_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		Vector3 localScale = ((Component)this).transform.localScale;
		int siblingIndex = ((Component)this).transform.GetSiblingIndex();
		Transform parent = ((Component)this).transform.parent;
		((Component)this).transform.parent = null;
		Quaternion rotation = ((Component)this).transform.rotation;
		Vector3 position = ((Component)this).transform.position;
		Vector3 localScale2 = ((Component)this).transform.localScale;
		((Component)this).transform.rotation = Quaternion.identity;
		((Component)this).transform.position = Vector3.zero;
		((Component)this).transform.localScale = Vector3.one;
		if (!createMultiMaterialMesh)
		{
			CombineMeshesWithSingleMaterial(showCreatedMeshInfo);
		}
		else
		{
			CombineMeshesWithMutliMaterial(showCreatedMeshInfo);
		}
		((Component)this).transform.rotation = rotation;
		((Component)this).transform.position = position;
		((Component)this).transform.localScale = localScale2;
		((Component)this).transform.parent = parent;
		((Component)this).transform.SetSiblingIndex(siblingIndex);
		((Component)this).transform.localScale = localScale;
	}

	private MeshFilter[] GetMeshFiltersToCombine()
	{
		MeshFilter[] meshFilters = ((Component)this).GetComponentsInChildren<MeshFilter>(combineInactiveChildren);
		meshFiltersToSkip = meshFiltersToSkip.Where((MeshFilter meshFilter) => (Object)(object)meshFilter != (Object)(object)meshFilters[0]).ToArray();
		meshFiltersToSkip = meshFiltersToSkip.Where((MeshFilter meshFilter) => (Object)(object)meshFilter != (Object)null).ToArray();
		for (int i = 0; i < meshFiltersToSkip.Length; i++)
		{
			meshFilters = meshFilters.Where((MeshFilter meshFilter) => (Object)(object)meshFilter != (Object)(object)meshFiltersToSkip[i]).ToArray();
		}
		return meshFilters;
	}

	private void CombineMeshesWithSingleMaterial(bool showCreatedMeshInfo)
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Expected O, but got Unknown
		MeshFilter[] meshFiltersToCombine = GetMeshFiltersToCombine();
		CombineInstance[] array = (CombineInstance[])(object)new CombineInstance[meshFiltersToCombine.Length - 1];
		long num = 0L;
		for (int i = 0; i < meshFiltersToCombine.Length - 1; i++)
		{
			((CombineInstance)(ref array[i])).subMeshIndex = 0;
			((CombineInstance)(ref array[i])).mesh = meshFiltersToCombine[i + 1].sharedMesh;
			((CombineInstance)(ref array[i])).transform = ((Component)meshFiltersToCombine[i + 1]).transform.localToWorldMatrix;
			num += ((CombineInstance)(ref array[i])).mesh.vertices.Length;
		}
		MeshRenderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<MeshRenderer>(combineInactiveChildren);
		if (componentsInChildren.Length >= 2)
		{
			((Renderer)componentsInChildren[0]).sharedMaterials = (Material[])(object)new Material[1];
			((Renderer)componentsInChildren[0]).sharedMaterial = ((Renderer)componentsInChildren[1]).sharedMaterial;
		}
		else
		{
			((Renderer)componentsInChildren[0]).sharedMaterials = (Material[])(object)new Material[0];
		}
		Mesh val = new Mesh();
		((Object)val).name = ((Object)this).name;
		if (num <= 65535)
		{
			val.CombineMeshes(array);
			GenerateUV(val);
			meshFiltersToCombine[0].sharedMesh = val;
			DeactivateCombinedGameObjects(meshFiltersToCombine);
			if (showCreatedMeshInfo)
			{
				Debug.Log((object)("<color=#00cc00><b>Mesh \"" + ((Object)this).name + "\" was created from " + array.Length + " children meshes and has " + num + " vertices.</b></color>"));
			}
		}
		else if (showCreatedMeshInfo)
		{
			Debug.Log((object)("<color=red><b>The mesh vertex limit is 65535! The created mesh had " + num + " vertices. Upgrade Unity version to 2017.3 or higher to avoid this limit (some old devices, like Android with Mali-400 GPU, do not support over 65535 vertices).</b></color>"));
		}
	}

	private void CombineMeshesWithMutliMaterial(bool showCreatedMeshInfo)
	{
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Expected O, but got Unknown
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Expected O, but got Unknown
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		MeshFilter[] meshFiltersToCombine = GetMeshFiltersToCombine();
		MeshRenderer[] array = (MeshRenderer[])(object)new MeshRenderer[meshFiltersToCombine.Length];
		array[0] = ((Component)this).GetComponent<MeshRenderer>();
		List<Material> list = new List<Material>();
		for (int i = 0; i < meshFiltersToCombine.Length - 1; i++)
		{
			array[i + 1] = ((Component)meshFiltersToCombine[i + 1]).GetComponent<MeshRenderer>();
			if (!((Object)(object)array[i + 1] != (Object)null))
			{
				continue;
			}
			Material[] sharedMaterials = ((Renderer)array[i + 1]).sharedMaterials;
			for (int j = 0; j < sharedMaterials.Length; j++)
			{
				if (!list.Contains(sharedMaterials[j]))
				{
					list.Add(sharedMaterials[j]);
				}
			}
		}
		List<CombineInstance> list2 = new List<CombineInstance>();
		long num = 0L;
		for (int k = 0; k < list.Count; k++)
		{
			List<CombineInstance> list3 = new List<CombineInstance>();
			for (int l = 0; l < meshFiltersToCombine.Length - 1; l++)
			{
				if (!((Object)(object)array[l + 1] != (Object)null))
				{
					continue;
				}
				Material[] sharedMaterials2 = ((Renderer)array[l + 1]).sharedMaterials;
				for (int m = 0; m < sharedMaterials2.Length; m++)
				{
					if ((Object)(object)list[k] == (Object)(object)sharedMaterials2[m])
					{
						CombineInstance item = default(CombineInstance);
						((CombineInstance)(ref item)).subMeshIndex = m;
						((CombineInstance)(ref item)).mesh = meshFiltersToCombine[l + 1].sharedMesh;
						((CombineInstance)(ref item)).transform = ((Component)meshFiltersToCombine[l + 1]).transform.localToWorldMatrix;
						list3.Add(item);
						num += ((CombineInstance)(ref item)).mesh.vertices.Length;
					}
				}
			}
			Mesh val = new Mesh();
			if (num <= 65535)
			{
				val.CombineMeshes(list3.ToArray(), true);
			}
			CombineInstance item2 = default(CombineInstance);
			((CombineInstance)(ref item2)).subMeshIndex = 0;
			((CombineInstance)(ref item2)).mesh = val;
			((CombineInstance)(ref item2)).transform = Matrix4x4.identity;
			list2.Add(item2);
		}
		((Renderer)array[0]).sharedMaterials = list.ToArray();
		Mesh val2 = new Mesh();
		((Object)val2).name = ((Object)this).name;
		if (num <= 65535)
		{
			val2.CombineMeshes(list2.ToArray(), false);
			GenerateUV(val2);
			meshFiltersToCombine[0].sharedMesh = val2;
			DeactivateCombinedGameObjects(meshFiltersToCombine);
			if (showCreatedMeshInfo)
			{
				Debug.Log((object)("<color=#00cc00><b>Mesh \"" + ((Object)this).name + "\" was created from " + (meshFiltersToCombine.Length - 1) + " children meshes and has " + list2.Count + " submeshes, and " + num + " vertices.</b></color>"));
			}
		}
		else if (showCreatedMeshInfo)
		{
			Debug.Log((object)("<color=red><b>The mesh vertex limit is 65535! The created mesh had " + num + " vertices. Upgrade Unity version to 2017.3 or higher to avoid this limit (some old devices, like Android with Mali-400 GPU, do not support over 65535 vertices).</b></color>"));
		}
	}

	private void DeactivateCombinedGameObjects(MeshFilter[] meshFilters)
	{
		for (int i = 0; i < meshFilters.Length - 1; i++)
		{
			if (!destroyCombinedChildren)
			{
				if (deactivateCombinedChildren)
				{
					((Component)meshFilters[i + 1]).gameObject.SetActive(false);
				}
				if (deactivateCombinedChildrenMeshRenderers)
				{
					MeshRenderer component = ((Component)meshFilters[i + 1]).gameObject.GetComponent<MeshRenderer>();
					if ((Object)(object)component != (Object)null)
					{
						((Renderer)component).enabled = false;
					}
				}
			}
			else
			{
				Object.DestroyImmediate((Object)(object)((Component)meshFilters[i + 1]).gameObject);
			}
		}
	}

	private void GenerateUV(Mesh combinedMesh)
	{
		//IL_000f: 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)
		if (generateUVMap)
		{
			UnwrapParam val = default(UnwrapParam);
			UnwrapParam.SetDefaults(ref val);
			Unwrapping.GenerateSecondaryUVSet(combinedMesh, val);
		}
	}
}
public class ExtrudeRandomEdges : MonoBehaviour
{
	private pb_Object pb;

	private pb_Face lastExtrudedFace = null;

	public float distance = 1f;

	private void Start()
	{
		pb = pb_ShapeGenerator.PlaneGenerator(1f, 1f, 0, 0, (Axis)2, false);
		pb.SetFaceMaterial(pb.faces, pb_Constant.DefaultMaterial);
		lastExtrudedFace = pb.faces[0];
	}

	private void OnGUI()
	{
		if (GUILayout.Button("Extrude Random Edge", (GUILayoutOption[])(object)new GUILayoutOption[0]))
		{
			ExtrudeEdge();
		}
	}

	private void ExtrudeEdge()
	{
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		pb_Face sourceFace = lastExtrudedFace;
		List<pb_WingedEdge> wingedEdges = pb_WingedEdge.GetWingedEdges(pb, false);
		IEnumerable<pb_WingedEdge> source = wingedEdges.Where((pb_WingedEdge x) => x.face == sourceFace);
		List<pb_Edge> list = (from x in source
			where x.opposite == null
			select x into y
			select y.edge.local).ToList();
		int index = Random.Range(0, list.Count);
		pb_Edge val = list[index];
		Vector3 val2 = (pb.vertices[val.x] + pb.vertices[val.y]) * 0.5f - pb_Math.Average<int>((IList<int>)sourceFace.distinctIndices, (Func<int, Vector3>)((int x) => pb.vertices[x]), (IList<int>)null);
		((Vector3)(ref val2)).Normalize();
		pb_Edge[] selectedEdges = default(pb_Edge[]);
		pbMeshOps.Extrude(pb, (pb_Edge[])(object)new pb_Edge[1] { val }, 0f, false, true, ref selectedEdges);
		lastExtrudedFace = pb.faces.Last();
		pb.SetSelectedEdges((IEnumerable<pb_Edge>)selectedEdges);
		pb_Object_Utility.TranslateVertices(pb, pb.SelectedTriangles, val2 * distance);
		pb.ToMesh();
		pb.Refresh((RefreshMask)255);
	}
}
public class HighlightNearestFace : MonoBehaviour
{
	public float travel = 50f;

	public float speed = 0.2f;

	private pb_Object target;

	private pb_Face nearest = null;

	private void Start()
	{
		//IL_0061: 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)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		target = pb_ShapeGenerator.PlaneGenerator(travel, travel, 25, 25, (Axis)2, false);
		target.SetFaceMaterial(target.faces, pb_Constant.DefaultMaterial);
		((Component)target).transform.position = new Vector3(travel * 0.5f, 0f, travel * 0.5f);
		target.ToMesh();
		target.Refresh((RefreshMask)255);
		Camera main = Camera.main;
		((Component)main).transform.position = new Vector3(25f, 40f, 0f);
		((Component)main).transform.localRotation = Quaternion.Euler(new Vector3(65f, 0f, 0f));
	}

	private void Update()
	{
		//IL_0048: 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_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		float num = Time.time * speed;
		Vector3 position = default(Vector3);
		((Vector3)(ref position))..ctor(Mathf.PerlinNoise(num, num) * travel, 2f, Mathf.PerlinNoise(num + 1f, num + 1f) * travel);
		((Component)this).transform.position = position;
		if ((Object)(object)target == (Object)null)
		{
			Debug.LogWarning((object)"Missing the ProBuilder Mesh target!");
			return;
		}
		Vector3 val = ((Component)target).transform.InverseTransformPoint(((Component)this).transform.position);
		if (nearest != null)
		{
			target.SetFaceColor(nearest, Color.white);
		}
		int num2 = target.faces.Length;
		float num3 = float.PositiveInfinity;
		nearest = target.faces[0];
		for (int i = 0; i < num2; i++)
		{
			float num4 = Vector3.Distance(val, FaceCenter(target, target.faces[i]));
			if (num4 < num3)
			{
				num3 = num4;
				nearest = target.faces[i];
			}
		}
		target.SetFaceColor(nearest, Color.blue);
		target.RefreshColors();
	}

	private Vector3 FaceCenter(pb_Object pb, pb_Face face)
	{
		//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_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		Vector3[] vertices = pb.vertices;
		Vector3 zero = Vector3.zero;
		int[] distinctIndices = face.distinctIndices;
		foreach (int num in distinctIndices)
		{
			zero.x += vertices[num].x;
			zero.y += vertices[num].y;
			zero.z += vertices[num].z;
		}
		float num2 = face.distinctIndices.Length;
		zero.x /= num2;
		zero.y /= num2;
		zero.z /= num2;
		return zero;
	}
}
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;
	}
}