using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using Atlas;
using BepInEx;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
[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]
[HelpURL("https://geom.io/bakery/wiki/index.php?title=Manual#Bakery_Light_Filter")]
[DisallowMultipleComponent]
public class BakeryLightFilter : MonoBehaviour
{
public Texture2D texture;
[HideInInspector]
public int lmid = 0;
}
namespace JalexInteractive.NakatomeatTower
{
[BepInPlugin("JalexInteractive.NakatomeatTower", "NakatomeatTower", "0.9.5")]
[BepInProcess("h3vr.exe")]
[Description("Built with MeatKit")]
[BepInDependency("nrgill28.Atlas", "1.0.1")]
public class NakatomeatTowerPlugin : 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(), "JalexInteractive.NakatomeatTower");
AtlasPlugin.RegisterScene(Path.Combine(BasePath, "nakatomi tower"));
}
}
}
public class CameraController : MonoBehaviour
{
[SerializeField]
private float navigationSpeed = 2.4f;
[SerializeField]
private float shiftMultiplier = 2f;
[SerializeField]
private float sensitivity = 1f;
[SerializeField]
private float panSensitivity = 0.5f;
[SerializeField]
private float mouseWheelZoomSpeed = 1f;
private Camera cam;
private Vector3 anchorPoint;
private Quaternion anchorRot;
private bool isPanning;
private float pan_x;
private float pan_y;
private Vector3 panComplete;
private void Awake()
{
cam = ((Component)this).GetComponent<Camera>();
}
private void Update()
{
//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_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_0130: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_0146: Unknown result type (might be due to invalid IL or missing references)
//IL_014b: Unknown result type (might be due to invalid IL or missing references)
//IL_0157: Unknown result type (might be due to invalid IL or missing references)
//IL_015c: Unknown result type (might be due to invalid IL or missing references)
//IL_016f: Unknown result type (might be due to invalid IL or missing references)
//IL_0174: Unknown result type (might be due to invalid IL or missing references)
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Unknown result type (might be due to invalid IL or missing references)
//IL_018a: Unknown result type (might be due to invalid IL or missing references)
//IL_018f: Unknown result type (might be due to invalid IL or missing references)
//IL_0199: Unknown result type (might be due to invalid IL or missing references)
//IL_019e: Unknown result type (might be due to invalid IL or missing references)
//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: Unknown result type (might be due to invalid IL or missing references)
//IL_0070: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0087: 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)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_0098: Unknown result type (might be due to invalid IL or missing references)
//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
//IL_0117: Unknown result type (might be due to invalid IL or missing references)
//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: 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_010b: Unknown result type (might be due to invalid IL or missing references)
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
MousePanning();
if (isPanning)
{
return;
}
if (Input.GetMouseButton(1))
{
Vector3 val = Vector3.zero;
float num = navigationSpeed * ((!Input.GetKey((KeyCode)304)) ? 1f : shiftMultiplier) * Time.deltaTime * 9.1f;
if (Input.GetKey((KeyCode)119))
{
val += Vector3.forward * num;
}
if (Input.GetKey((KeyCode)115))
{
val -= Vector3.forward * num;
}
if (Input.GetKey((KeyCode)100))
{
val += Vector3.right * num;
}
if (Input.GetKey((KeyCode)97))
{
val -= Vector3.right * num;
}
if (Input.GetKey((KeyCode)101))
{
val += Vector3.up * num;
}
if (Input.GetKey((KeyCode)113))
{
val -= Vector3.up * num;
}
((Component)this).transform.Translate(val);
}
if (Input.GetMouseButtonDown(1))
{
anchorPoint = new Vector3(Input.mousePosition.y, 0f - Input.mousePosition.x);
anchorRot = ((Component)this).transform.rotation;
}
if (Input.GetMouseButton(1))
{
Quaternion rotation = anchorRot;
Vector3 val2 = anchorPoint - new Vector3(Input.mousePosition.y, 0f - Input.mousePosition.x);
((Quaternion)(ref rotation)).eulerAngles = ((Quaternion)(ref rotation)).eulerAngles + val2 * sensitivity;
((Component)this).transform.rotation = rotation;
}
MouseWheeling();
}
private void MouseWheeling()
{
//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_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0068: Unknown result type (might be due to invalid IL or missing references)
//IL_006d: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_009c: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
float num = 10f * (mouseWheelZoomSpeed * ((!Input.GetKey((KeyCode)304)) ? 1f : shiftMultiplier) * Time.deltaTime * 9.1f);
Vector3 val = ((Component)this).transform.position;
if (Input.GetAxis("Mouse ScrollWheel") < 0f)
{
val -= ((Component)this).transform.forward * num;
((Component)this).transform.position = val;
}
if (Input.GetAxis("Mouse ScrollWheel") > 0f)
{
val += ((Component)this).transform.forward * num;
((Component)this).transform.position = val;
}
}
private void MousePanning()
{
//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_0088: Unknown result type (might be due to invalid IL or missing references)
pan_x = (0f - Input.GetAxis("Mouse X")) * panSensitivity;
pan_y = (0f - Input.GetAxis("Mouse Y")) * panSensitivity;
panComplete = new Vector3(pan_x, pan_y, 0f);
if (Input.GetMouseButtonDown(2))
{
isPanning = true;
}
if (Input.GetMouseButtonUp(2))
{
isPanning = false;
}
if (isPanning)
{
((Component)this).transform.Translate(panComplete);
}
}
}
namespace Packer
{
[RequireComponent(typeof(AudioSource))]
public class Door : MonoBehaviour
{
[Tooltip("Switches connected to this door")]
public DoorSwitch[] switches;
[Tooltip("How fast the door opens (Meters a second)")]
public float doorMoveSpeed = 1f;
[Tooltip("How fast the door opens (Degrees a second")]
public float doorRotateSpeed = 1f;
[Tooltip("Auto close timing (>0 for no auto)")]
public float autoClose = 0f;
[Tooltip("Default State of this door")]
public bool open = false;
[Tooltip("Does this door move?")]
public bool mover = false;
[Tooltip("The closed local position of the door")]
public Vector3 closeOffset;
[Tooltip("The opened local position of the door")]
public Vector3 openOffset;
[Tooltip("Does this door rotate?")]
public bool rotator = false;
[Tooltip("The closed local rotation of the door, would reccomend not modifying these values directly unless you really know what you're doing")]
public Quaternion closeRotation;
[Tooltip("The opened local rotation of the door, would reccomend not modifying these values directly unless you really know what you're doing")]
public Quaternion openRotation;
public AudioClip openSound;
public AudioClip closeSound;
private AudioSource audioSource;
private bool moving = false;
private int doorIndex;
private List<IEnumerator> WaitList = new List<IEnumerator>();
private void Start()
{
audioSource = ((Component)this).GetComponent<AudioSource>();
((Component)this).transform.hasChanged = false;
}
private void Update()
{
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: 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_008e: 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_0194: Unknown result type (might be due to invalid IL or missing references)
//IL_014f: Unknown result type (might be due to invalid IL or missing references)
//IL_0155: Unknown result type (might be due to invalid IL or missing references)
//IL_0166: Unknown result type (might be due to invalid IL or missing references)
//IL_00d8: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
while (WaitList.Count > 0)
{
((MonoBehaviour)this).StartCoroutine(WaitList[0]);
WaitList.RemoveAt(0);
}
if (mover)
{
if (open && ((Component)this).transform.localPosition != openOffset)
{
((Component)this).transform.localPosition = Vector3.MoveTowards(((Component)this).transform.localPosition, openOffset, doorMoveSpeed * Time.deltaTime);
moving = true;
}
else if (!open && ((Component)this).transform.localPosition != closeOffset)
{
((Component)this).transform.localPosition = Vector3.MoveTowards(((Component)this).transform.localPosition, closeOffset, doorMoveSpeed * Time.deltaTime);
moving = true;
}
else
{
moving = false;
}
}
if (rotator)
{
if (open && ((Component)this).transform.rotation != openRotation)
{
((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, openRotation, doorRotateSpeed * Time.deltaTime);
moving = true;
}
else if (!open && ((Component)this).transform.rotation != closeRotation)
{
((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, closeRotation, doorRotateSpeed * Time.deltaTime);
moving = true;
}
else
{
moving = false;
}
}
if (open && autoClose > 0f && !moving)
{
new Thread((ThreadStart)delegate
{
WaitList.Add(Wait());
}).Start();
}
}
public void SetDoor(bool state)
{
open = state;
if (open)
{
if ((Object)(object)openSound != (Object)null)
{
audioSource.PlayOneShot(openSound);
}
}
else if ((Object)(object)closeSound != (Object)null)
{
audioSource.PlayOneShot(closeSound);
}
}
public void SetOpenOffset()
{
//IL_0018: 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 (!ErrorCheck())
{
openOffset = ((Component)this).transform.localPosition;
}
}
public void SetCloseOffset()
{
//IL_0018: 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 (!ErrorCheck())
{
closeOffset = ((Component)this).transform.localPosition;
}
}
public void MoveToOpenOffset()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (!ErrorCheck())
{
((Component)this).transform.localPosition = openOffset;
}
}
public void MoveToCloseOffset()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (!ErrorCheck())
{
((Component)this).transform.localPosition = closeOffset;
}
}
public void SetOpenRotation()
{
//IL_0018: 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 (!ErrorCheck())
{
openRotation = ((Component)this).transform.rotation;
}
}
public void SetCloseRotation()
{
//IL_0018: 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 (!ErrorCheck())
{
closeRotation = ((Component)this).transform.rotation;
}
}
public void MoveToOpenRotation()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (!ErrorCheck())
{
((Component)this).transform.rotation = openRotation;
}
}
public void MoveToCloseRotation()
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
if (!ErrorCheck())
{
((Component)this).transform.rotation = closeRotation;
}
}
private bool ErrorCheck()
{
if ((Object)(object)((Component)this).transform.parent == (Object)null)
{
Debug.LogError((object)(((Object)this).name + " is missing a parent gameobject"));
return true;
}
return false;
}
private IEnumerator Wait()
{
yield return (object)new WaitForSeconds(autoClose);
while (open && !moving)
{
if (!((Object)(object)switches[0] != (Object)null))
{
continue;
}
for (int i = 0; i < switches[0].doors.Length; i++)
{
if (((Object)switches[0].doors[i]).name == ((Object)this).name)
{
doorIndex = i;
}
}
switches[0].ToggleSingleDoor(doorIndex);
}
}
}
[RequireComponent(typeof(AudioSource), typeof(BoxCollider))]
public class DoorSwitch : MonoBehaviour
{
[Tooltip("All the doors that will be triggered when this switch is hit")]
public Door[] doors;
[Tooltip("All Switches that will be set to this switches state")]
public DoorSwitch[] switches;
[Tooltip("Default switch state")]
public bool switchState = false;
[Tooltip("Does this button accept only an empty hand, or any collision")]
public bool physicsActive = false;
public AudioClip openSound;
public AudioClip closeSound;
private BoxCollider triggerZone;
private LayerMask mask;
private AudioSource audioSource;
private float timeout = 0f;
private void Start()
{
audioSource = ((Component)this).GetComponent<AudioSource>();
triggerZone = ((Component)this).GetComponent<BoxCollider>();
((Collider)triggerZone).isTrigger = true;
((Component)this).gameObject.layer = LayerMask.NameToLayer("Enviroment");
}
private void Update()
{
if (timeout > 0f)
{
timeout = Mathf.Clamp(timeout -= Time.deltaTime, 0f, 1f);
}
}
public void ToggleDoors()
{
switchState = !switchState;
for (int i = 0; i < doors.Length; i++)
{
if ((Object)(object)doors[i] != (Object)null)
{
doors[i].SetDoor(!doors[i].open);
}
}
for (int j = 0; j < switches.Length; j++)
{
if ((Object)(object)switches[j] != (Object)null)
{
switches[j].switchState = switchState;
}
}
if (switchState)
{
if ((Object)(object)openSound != (Object)null)
{
audioSource.PlayOneShot(openSound);
}
}
else if ((Object)(object)closeSound != (Object)null)
{
audioSource.PlayOneShot(closeSound);
}
}
public void ToggleSingleDoor(int doorIndex)
{
doors[doorIndex].SetDoor(!doors[doorIndex].open);
}
private void OnTriggerEnter(Collider collider)
{
if (physicsActive)
{
if (!(timeout > 0f))
{
timeout = 1f;
ToggleDoors();
}
}
else if (((Component)collider).gameObject.tag == "GameController" && !(timeout > 0f))
{
timeout = 1f;
ToggleDoors();
}
}
}
public class Packer_Platform : MovingPlatformBase
{
public void Awake()
{
((MovingPlatformBase)this).Awake();
}
public void FixedUpdate()
{
//IL_000d: 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)
base.refT.position = ((Component)this).transform.position;
base.refT.rotation = ((Component)this).transform.rotation;
}
public override Vector3 PhysicsStep()
{
//IL_000d: 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_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
base.refT.position = ((Component)this).transform.position;
base.refT.rotation = ((Component)this).transform.rotation;
return ((MovingPlatformBase)this).PhysicsStep();
}
}
}
public class PlayerBodyTrigger : MonoBehaviour
{
public bool LooksForPlayerBody;
public bool LooksForPlayerHand;
public List<UnityEvent> OnPlayerHeadOrBodyEnter;
public List<UnityEvent> OnPlayerHeadOrBodyExit;
public List<UnityEvent> OnPlayerHandEnter;
public List<UnityEvent> OnPlayerHandExit;
private void OnTriggerEnter(Collider other)
{
if (LooksForPlayerBody && ((Component)other).gameObject.layer == 15)
{
if (OnPlayerHeadOrBodyEnter == null)
{
return;
}
{
foreach (UnityEvent item in OnPlayerHeadOrBodyEnter)
{
item.Invoke();
}
return;
}
}
if (((Component)other).gameObject.layer != 9 || OnPlayerHandEnter == null)
{
return;
}
foreach (UnityEvent item2 in OnPlayerHandEnter)
{
item2.Invoke();
}
}
private void OnTriggerExit(Collider other)
{
if (LooksForPlayerBody && ((Component)other).gameObject.layer == 15)
{
if (OnPlayerHeadOrBodyExit == null)
{
return;
}
{
foreach (UnityEvent item in OnPlayerHeadOrBodyExit)
{
item.Invoke();
}
return;
}
}
if (!LooksForPlayerHand || ((Component)other).gameObject.layer != 9 || OnPlayerHeadOrBodyExit == null)
{
return;
}
foreach (UnityEvent item2 in OnPlayerHandExit)
{
item2.Invoke();
}
}
}
public class ShatterableGlass : MonoBehaviour
{
private class Figure
{
public Vector2[] Points;
public int ForceScale;
public Figure(Vector2[] Points, int ForceScale)
{
this.Points = Points;
this.ForceScale = ForceScale;
}
public void GenerateCollider(float GlassThickness, GameObject Obj)
{
//IL_0014: 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_003c: 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_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_0142: Unknown result type (might be due to invalid IL or missing references)
//IL_0152: Unknown result type (might be due to invalid IL or missing references)
BoxCollider val = Obj.AddComponent<BoxCollider>();
float num = Vector2.Distance(Points[2], Points[0]);
float num2 = Vector2.Distance(Points[2], Points[1]);
float num3 = Vector2.Distance(Points[1], Points[0]);
float num4 = num + num2 + num3;
float num5 = (num * Points[0].x + num2 * Points[1].x + num3 * Points[2].x) / num4;
float num6 = (num * Points[0].y + num2 * Points[1].y + num3 * Points[2].y) / num4;
num4 /= 2f;
float num7 = Mathf.Sqrt((num4 - num) * (num4 - num2) * (num4 - num3) / num4);
num7 *= Mathf.Sqrt(2f);
val.center = new Vector3(num5, num6, 0f);
val.size = new Vector3(num7, num7, GlassThickness);
}
public Mesh GenerateMesh(bool GenerateGlassSides, float GlassHalfThickness, Vector2 UVScale)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Expected O, but got Unknown
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
//IL_00de: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
//IL_0150: Unknown result type (might be due to invalid IL or missing references)
Mesh val = new Mesh();
((Object)val).name = "GlassGib";
if (GenerateGlassSides)
{
val.subMeshCount = 2;
}
bool flag = Points.Length == 3;
Vector3[] array = (Vector3[])(object)new Vector3[flag ? ((!GenerateGlassSides) ? 3 : 9) : ((!GenerateGlassSides) ? 4 : 12)];
Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
for (int i = 0; i < Points.Length; i++)
{
ref Vector3 reference = ref array[i];
reference = Vector2.op_Implicit(Points[i]);
ref Vector2 reference2 = ref array2[i];
reference2 = new Vector2(Points[i].x / UVScale.x, Points[i].y / UVScale.y) + new Vector2(0.5f, 0.5f);
}
int[] array3 = ((!flag) ? new int[6] { 0, 1, 2, 3, 2, 1 } : new int[3] { 2, 1, 0 });
if (GenerateGlassSides)
{
int[] array4;
if (flag)
{
for (int j = 0; j < 3; j++)
{
GlassSideVertex(Points[j], ref array[j * 2 + 3], ref array[j * 2 + 4], GlassHalfThickness);
}
array4 = new int[18]
{
3, 4, 5, 4, 6, 5, 3, 4, 7, 7,
8, 4, 5, 6, 8, 8, 7, 5
};
}
else
{
for (int k = 0; k < 4; k++)
{
GlassSideVertex(Points[k], ref array[k * 2 + 4], ref array[k * 2 + 5], GlassHalfThickness);
}
array4 = new int[24]
{
7, 5, 4, 6, 7, 4, 11, 7, 6, 10,
11, 6, 10, 11, 9, 9, 8, 10, 8, 9,
5, 8, 4, 5
};
}
val.vertices = array;
val.SetTriangles(array3, 0);
val.SetTriangles(array4, 1);
}
else
{
val.vertices = array;
val.triangles = array3;
}
val.uv = array2;
return val;
}
private void GlassSideVertex(Vector2 Ref, ref Vector3 A, ref Vector3 B, float GlassHalfThickness)
{
((Vector3)(ref A))..ctor(Ref.x, Ref.y, GlassHalfThickness);
((Vector3)(ref B))..ctor(Ref.x, Ref.y, 0f - GlassHalfThickness);
}
}
private class BaseLine
{
public Vector2[] Points;
public BaseLine(Vector2 HitPoint, Vector2 End, int Count)
{
//IL_0021: 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_0033: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
//IL_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)
Points = (Vector2[])(object)new Vector2[Count + 1];
Points[0] = HitPoint;
Points[Count] = End;
float num = 1f / (float)Count;
float num2 = num;
float num3 = Mathf.Atan2(Mathf.Max(HitPoint.y, End.y) - Mathf.Min(HitPoint.y, End.y), Mathf.Max(End.x, HitPoint.x) - Mathf.Min(HitPoint.x, End.x));
float num4 = (float)Math.PI / 4f;
float num5 = (float)Math.PI / 2f;
if (num3 > num4)
{
num3 = num5 - num3;
}
float num6 = num3 / num4;
for (int i = 0; i < Count - 1; i++)
{
ref Vector2 reference = ref Points[i + 1];
reference = Vector2.Lerp(HitPoint, End, num2 * Mathf.Lerp(1f, Mathf.Sqrt(2f) / 2f, num6));
num2 += num;
}
}
}
public int Sectors = 3;
public int DetailsPerSector = 3;
public float SimplifyThreshold = 0.05f;
public bool GlassSides = true;
public Material GlassSidesMaterial;
public float GlassThickness = 0.01f;
public bool ShatterButNotBreak = false;
public bool SlightlyRotateGibs = true;
public bool DestroyGibs = true;
public float AfterSeconds = 5f;
public bool GibsOnSeparateLayer = false;
public int GibsLayer = 0;
public float Force = 100f;
public bool AdoptFragments = false;
private Vector2[] Bounds = (Vector2[])(object)new Vector2[4];
private float Area = 1f;
private Material GlassMaterial;
private AudioSource SoundEmitter;
private void Start()
{
//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_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_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
//IL_006f: 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_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)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Abs(((Component)this).transform.lossyScale.x / 2f);
float num2 = Mathf.Abs(((Component)this).transform.lossyScale.y / 2f);
Area = num * num2;
ref Vector2 reference = ref Bounds[0];
reference = new Vector2(num, num2);
ref Vector2 reference2 = ref Bounds[1];
reference2 = new Vector2(0f - num, num2);
ref Vector2 reference3 = ref Bounds[2];
reference3 = new Vector2(0f - num, 0f - num2);
ref Vector2 reference4 = ref Bounds[3];
reference4 = new Vector2(num, 0f - num2);
SoundEmitter = ((Component)this).GetComponent<AudioSource>();
if ((Object)(object)((Component)this).GetComponent<Renderer>() == (Object)null || (Object)(object)((Component)this).GetComponent<MeshFilter>() == (Object)null)
{
Debug.LogError((object)(((Object)((Component)this).gameObject).name + ": No Renderer and/or MeshFilter components!"));
Object.Destroy((Object)(object)((Component)this).gameObject);
return;
}
GlassMaterial = ((Component)this).GetComponent<Renderer>().material;
if (GlassSides && (Object)(object)GlassSidesMaterial == (Object)null)
{
Debug.LogError((object)(((Object)((Component)this).gameObject).name + ": GlassSide material must be assigned! Glass will be destroyed."));
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
public void Shatter2D(Vector2 HitPoint)
{
//IL_0002: 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)
Shatter(HitPoint, ((Component)this).transform.forward);
}
public void Shatter3D(ShatterableGlassInfo Inf)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_0038: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
//IL_014c: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0170: Unknown result type (might be due to invalid IL or missing references)
//IL_0175: Unknown result type (might be due to invalid IL or missing references)
//IL_0195: Unknown result type (might be due to invalid IL or missing references)
//IL_019a: Unknown result type (might be due to invalid IL or missing references)
//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
//IL_01cb: 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)
Transform parent = ((Component)this).gameObject.transform.parent;
bool flag = true;
while ((Object)(object)parent != (Object)null)
{
if (parent.localScale.x != 1f || parent.localScale.y != 1f || parent.localScale.y != 1f)
{
flag = false;
}
parent = parent.parent;
}
if (!flag)
{
Debug.LogWarning((object)(((Object)((Component)this).gameObject).name + ": scale of all parents in hierarchy recommended to be {1, 1, 1}. Glass may shatter weirdly."));
}
Vector3 val = ((Component)this).transform.TransformPoint(new Vector3(-0.5f, -0.5f));
Vector3 val2 = ((Component)this).transform.TransformPoint(new Vector3(0.5f, -0.5f));
float num = Vector3.Distance(Inf.HitPoint, val);
float num2 = Vector3.Distance(val2, val);
float num3 = Vector3.Distance(Inf.HitPoint, val2);
float num4 = (num3 + num + num2) / 2f;
float num5 = Mathf.Sqrt(num4 * (num4 - num3) * (num4 - num) * (num4 - num2));
float num6 = 2f / num2 * num5;
float num7 = Mathf.Sqrt(num * num - num6 * num6);
num6 -= Mathf.Abs(((Component)this).transform.lossyScale.y / 2f);
num7 -= Mathf.Abs(((Component)this).transform.lossyScale.x / 2f);
Shatter(new Vector2(num7 * Mathf.Sign(((Component)this).transform.lossyScale.x), num6 * Mathf.Sign(((Component)this).transform.lossyScale.y)), Inf.HitDirrection);
}
public void Shatter(Vector2 HitPoint, Vector3 ForceDirrection)
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
//IL_006a: 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_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: Unknown result type (might be due to invalid IL or missing references)
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0151: Unknown result type (might be due to invalid IL or missing references)
//IL_0231: Unknown result type (might be due to invalid IL or missing references)
//IL_0236: Unknown result type (might be due to invalid IL or missing references)
//IL_0251: Unknown result type (might be due to invalid IL or missing references)
//IL_0256: Unknown result type (might be due to invalid IL or missing references)
//IL_0262: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Unknown result type (might be due to invalid IL or missing references)
//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
//IL_029c: 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_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_02e6: Unknown result type (might be due to invalid IL or missing references)
//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
//IL_030e: Unknown result type (might be due to invalid IL or missing references)
//IL_0313: Unknown result type (might be due to invalid IL or missing references)
//IL_036c: Unknown result type (might be due to invalid IL or missing references)
//IL_0373: Expected O, but got Unknown
//IL_0380: Unknown result type (might be due to invalid IL or missing references)
//IL_0397: Unknown result type (might be due to invalid IL or missing references)
//IL_042b: Unknown result type (might be due to invalid IL or missing references)
//IL_0430: Unknown result type (might be due to invalid IL or missing references)
//IL_043f: Unknown result type (might be due to invalid IL or missing references)
//IL_0444: Unknown result type (might be due to invalid IL or missing references)
//IL_044d: Unknown result type (might be due to invalid IL or missing references)
//IL_0488: Unknown result type (might be due to invalid IL or missing references)
//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
//IL_04ad: Unknown result type (might be due to invalid IL or missing references)
//IL_054d: Unknown result type (might be due to invalid IL or missing references)
int num = 4 + (Sectors - 1) * 4;
BaseLine[] array = new BaseLine[num];
for (int i = 0; i < 4; i++)
{
array[i * Sectors] = new BaseLine(HitPoint, Bounds[i], DetailsPerSector);
float num2 = 1f / (float)Sectors;
float num3 = num2;
for (int j = 1; j < Sectors; j++)
{
array[i * Sectors + j] = new BaseLine(HitPoint, Vector2.Lerp(Bounds[i], Bounds[(i + 1) % 4], num3), DetailsPerSector);
num3 += num2;
}
}
List<Figure> list = new List<Figure>();
for (int k = 0; k < num; k++)
{
int num4 = (k + 1) % num;
float num5 = Vector2.Distance(HitPoint, array[k].Points[DetailsPerSector]);
float num6 = Vector2.Distance(HitPoint, array[num4].Points[DetailsPerSector]);
float num7 = Vector2.Distance(array[k].Points[DetailsPerSector], array[num4].Points[DetailsPerSector]);
float num8 = (num5 + num6 + num7) * 0.5f;
float num9 = Mathf.Sqrt(num8 * (num8 - num5) * (num8 - num6) * (num8 - num7));
if (num9 < Area * SimplifyThreshold)
{
list.Add(new Figure((Vector2[])(object)new Vector2[3]
{
array[k].Points[DetailsPerSector],
array[num4].Points[DetailsPerSector],
HitPoint
}, DetailsPerSector / 2));
continue;
}
list.Add(new Figure((Vector2[])(object)new Vector2[3]
{
array[k].Points[1],
array[num4].Points[1],
HitPoint
}, 1));
for (int l = 1; l < DetailsPerSector; l++)
{
list.Add(new Figure((Vector2[])(object)new Vector2[4]
{
array[k].Points[l],
array[(k + 1) % num].Points[l],
array[k].Points[l + 1],
array[(k + 1) % num].Points[l + 1]
}, k + 1));
}
}
foreach (Figure item in list)
{
GameObject val = new GameObject("GlassGib");
val.transform.rotation = ((Component)this).transform.rotation;
val.transform.position = ((Component)this).transform.position;
if (AdoptFragments)
{
val.transform.parent = ((Component)this).transform.parent;
}
MeshFilter val2 = val.AddComponent<MeshFilter>();
MeshRenderer val3 = val.AddComponent<MeshRenderer>();
if (GlassSides)
{
((Renderer)val3).materials = (Material[])(object)new Material[2] { GlassMaterial, GlassSidesMaterial };
}
else
{
((Renderer)val3).material = GlassMaterial;
}
Mesh sharedMesh = item.GenerateMesh(GlassSides, GlassThickness / 2f, new Vector2(((Component)this).transform.lossyScale.x, ((Component)this).transform.lossyScale.y));
val2.sharedMesh = sharedMesh;
if (!ShatterButNotBreak)
{
item.GenerateCollider(GlassThickness, val);
Rigidbody val4 = val.AddComponent<Rigidbody>();
val4.AddForce(ForceDirrection * Random.Range(Force, Force * 1.5f) / (float)item.ForceScale);
if (GibsOnSeparateLayer)
{
val.layer = GibsLayer;
}
if (DestroyGibs)
{
float num10 = AfterSeconds * 0.1f;
Object.Destroy((Object)(object)val, Random.Range(AfterSeconds - num10, AfterSeconds + num10));
}
}
else if (SlightlyRotateGibs)
{
val.transform.Rotate(new Vector3(Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f), Random.Range(-0.5f, 0.5f)));
}
}
if (Object.op_Implicit((Object)(object)SoundEmitter))
{
SoundEmitter.Play();
}
Object.Destroy((Object)(object)((Component)this).GetComponent<Renderer>());
Object.Destroy((Object)(object)((Component)this).GetComponent<MeshFilter>());
Object.Destroy((Object)(object)((Component)this).GetComponent<ShatterableGlass>());
if (ShatterButNotBreak)
{
((Component)this).gameObject.tag = "Untagged";
return;
}
Object.Destroy((Object)(object)((Component)this).GetComponent<MeshCollider>());
if (Object.op_Implicit((Object)(object)SoundEmitter))
{
if (Object.op_Implicit((Object)(object)SoundEmitter.clip))
{
Object.Destroy((Object)(object)((Component)this).gameObject, SoundEmitter.clip.length);
}
else
{
Debug.Log((object)(((Object)((Component)this).gameObject).name + ": AudioSource component is present, but SoundClip is not set."));
}
}
else
{
Object.Destroy((Object)(object)((Component)this).gameObject);
}
}
}
public class ShatterableGlassInfo
{
public Vector3 HitPoint;
public Vector3 HitDirrection;
public ShatterableGlassInfo(Vector3 HitPoint, Vector3 HitDirrection)
{
//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_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)
this.HitPoint = HitPoint;
this.HitDirrection = HitDirrection;
}
}
namespace ShatterableGlassScripts
{
public class ShatterableGlassScripts : MonoBehaviour, IFVRDamageable
{
private ShatterableGlass _glass;
private bool _smashed;
public float MeleeDamageThreshold = 9999f;
public float ExplosiveDamageThreshold = 1f;
public float ProjectileDamageThreshold = 4500f;
public float AbstractDamageThreshold = 1f;
public float EnvironmentDamageThreshold = 1f;
public float MeleeForceMultiplier = 1f;
public float ExplosiveForceMultiplier = 1f;
public float ProjectileForceMultiplier = 1f;
public float AbstractForceMultiplier = 1f;
public float EnvironmentForceMultiplier = 1f;
private const float epsilon = 0.001f;
private void Awake()
{
_glass = ((Component)this).GetComponent<ShatterableGlass>();
_smashed = false;
}
public void Damage(Damage dam)
{
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Invalid comparison between Unknown and I4
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Invalid comparison between Unknown and I4
//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Invalid comparison between Unknown and I4
//IL_0059: 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_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
//IL_01bd: Invalid comparison between Unknown and I4
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0133: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_0196: Unknown result type (might be due to invalid IL or missing references)
//IL_019c: Unknown result type (might be due to invalid IL or missing references)
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_0200: Unknown result type (might be due to invalid IL or missing references)
//IL_0206: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
if (!_smashed)
{
if ((int)dam.Class == 3 && dam.Dam_TotalKinetic > MeleeDamageThreshold + 0.001f)
{
_glass.Force = dam.Dam_TotalKinetic * MeleeForceMultiplier;
_smashed = true;
_glass.Shatter3D(new ShatterableGlassInfo(dam.point, -dam.hitNormal));
}
else if ((int)dam.Class == 2 && dam.Dam_TotalKinetic > ExplosiveDamageThreshold + 0.001f)
{
_glass.Force = dam.Dam_TotalKinetic * ExplosiveForceMultiplier;
_smashed = true;
_glass.Shatter3D(new ShatterableGlassInfo(dam.point, -dam.hitNormal));
}
else if ((int)dam.Class == 1 && dam.Dam_TotalKinetic > ProjectileDamageThreshold + 0.001f)
{
_glass.Force = dam.Dam_TotalKinetic * ProjectileForceMultiplier;
_smashed = true;
_glass.Shatter3D(new ShatterableGlassInfo(dam.point, -dam.hitNormal));
}
else if ((int)dam.Class == 0 && dam.Dam_TotalKinetic > AbstractDamageThreshold + 0.001f)
{
_glass.Force = dam.Dam_TotalKinetic * AbstractForceMultiplier;
_smashed = true;
_glass.Shatter3D(new ShatterableGlassInfo(dam.point, -dam.hitNormal));
}
else if ((int)dam.Class == 4 && dam.Dam_TotalKinetic > EnvironmentDamageThreshold + 0.001f)
{
_glass.Force = dam.Dam_TotalKinetic * EnvironmentForceMultiplier;
_smashed = true;
_glass.Shatter3D(new ShatterableGlassInfo(dam.point, -dam.hitNormal));
}
}
}
}
}
public class SpinnyFan : MonoBehaviour
{
public int Speed;
private void Start()
{
}
private void Update()
{
((Component)this).transform.Rotate(0f, (float)Speed * Time.deltaTime, 0f, (Space)0);
}
}
public class WigglyWave : MonoBehaviour
{
private MeshRenderer meshRenderer;
private MeshFilter meshFilter;
[SerializeField]
private float wavesStrength = 1f;
[SerializeField]
private float wavesSpeed = 1f;
[SerializeField]
private float wavesDirection = 0f;
[SerializeField]
private float textureScrollSpeed = 0.5f;
private void Start()
{
meshRenderer = ((Component)this).GetComponent<MeshRenderer>();
meshFilter = ((Component)this).GetComponent<MeshFilter>();
}
private void Update()
{
//IL_0031: 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_0043: 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_0052: Unknown result type (might be due to invalid IL or missing references)
float num = Mathf.Sin(wavesDirection * ((float)Math.PI / 180f));
float num2 = Mathf.Cos(wavesDirection * ((float)Math.PI / 180f));
Material material = ((Renderer)meshRenderer).material;
material.mainTextureOffset += new Vector2(num, num2) * textureScrollSpeed * Time.deltaTime;
Mesh mesh = meshFilter.mesh;
Vector3[] vertices = mesh.vertices;
for (int i = 0; i < vertices.Length; i++)
{
float num3 = vertices[i].x * num;
float num4 = vertices[i].z * num2;
float y = Mathf.Sin(num3 + num4 + Time.time * wavesSpeed) * wavesStrength;
vertices[i].y = y;
}
mesh.vertices = vertices;
}
}
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;
}
}