Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of CornerFloors v1.1.1
plugins/CornerFloors/CornerFloors.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Corner Floors")] [assembly: AssemblyDescription("Triangular wood and stone floors for Valheim")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyVersion("1.1.1.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace CornerFloors { internal static class CornerTipFitter { internal const float TipRadius = 0.125f; internal const float BlendRadius = 0.25f; private static readonly Vector3[] Corners = (Vector3[])(object)new Vector3[3] { new Vector3(-1f, 0f, -1f), new Vector3(1f, 0f, -1f), new Vector3(-1f, 0f, 1f) }; internal static Vector3 Fit(Vector3 point) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_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_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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) Vector3[] corners = Corners; foreach (Vector3 val in corners) { float num = point.x - val.x; float num2 = point.z - val.z; float num3 = Mathf.Sqrt(num * num + num2 * num2); if (!(num3 >= 0.25f)) { if (num3 <= 0.125f) { point.x = val.x; point.z = val.z; return point; } float num4 = (num3 - 0.125f) / 0.125f; float num5 = 1f - num4 * num4 * (3f - 2f * num4); point.x = Mathf.Lerp(point.x, val.x, num5); point.z = Mathf.Lerp(point.z, val.z, num5); break; } } return point; } internal static void Apply(Mesh mesh, Matrix4x4 localToRoot) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_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_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) Vector3[] vertices = mesh.vertices; Vector3[] array = (Vector3[])(object)new Vector3[vertices.Length]; Matrix4x4 inverse = ((Matrix4x4)(ref localToRoot)).inverse; for (int i = 0; i < vertices.Length; i++) { array[i] = Fit(((Matrix4x4)(ref localToRoot)).MultiplyPoint3x4(vertices[i])); vertices[i] = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(array[i]); } mesh.vertices = vertices; for (int j = 0; j < mesh.subMeshCount; j++) { int[] triangles = mesh.GetTriangles(j); List<int> list = new List<int>(triangles.Length); for (int k = 0; k < triangles.Length; k += 3) { int num = triangles[k]; int num2 = triangles[k + 1]; int num3 = triangles[k + 2]; Vector3 val = Vector3.Cross(array[num2] - array[num], array[num3] - array[num]); if (!(((Vector3)(ref val)).sqrMagnitude < 1E-12f)) { list.Add(num); list.Add(num2); list.Add(num3); } } mesh.SetTriangles(list, j, false); } mesh.RecalculateBounds(); } } internal static class FloorIcon { private const int Size = 128; private static Sprite woodIcon; private static Sprite stoneIcon; internal static Sprite Create(GameObject prefab, bool wood) { //IL_0087: 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) Sprite val = (wood ? woodIcon : stoneIcon); if (Object.op_Implicit((Object)(object)val)) { return val; } Texture2D val2; try { val2 = LoadEmbedded(wood); } catch (Exception ex) { Debug.LogWarning((object)("Corner Floors: using drawn corner icon: " + ex.Message)); val2 = Draw(wood); } ((Object)val2).name = (wood ? "CornerFloors_WoodCorner_Icon" : "CornerFloors_StoneCorner_Icon"); ((Object)val2).hideFlags = (HideFlags)61; ((Texture)val2).wrapMode = (TextureWrapMode)1; ((Texture)val2).filterMode = (FilterMode)1; Sprite val3 = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); ((Object)val3).name = ((Object)val2).name; ((Object)val3).hideFlags = (HideFlags)61; if (wood) { woodIcon = val3; } else { stoneIcon = val3; } return val3; } private static Texture2D LoadEmbedded(bool wood) { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown string text = "CornerFloors.Assets." + (wood ? "wood-corner.png" : "stone-corner.png"); using Stream stream = typeof(FloorIcon).Assembly.GetManifestResourceStream(text); if (stream == null) { throw new InvalidOperationException("Missing icon resource: " + text); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); try { if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), false)) { throw new InvalidOperationException("Could not decode icon resource: " + text); } return val; } catch { Object.DestroyImmediate((Object)(object)val); throw; } } private static Texture2D Draw(bool wood) { //IL_0400: Unknown result type (might be due to invalid IL or missing references) //IL_0405: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Expected O, but got Unknown //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_0366: Unknown result type (might be due to invalid IL or missing references) //IL_036d: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0374: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03af: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: 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: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02be: Unknown result type (might be due to invalid IL or missing references) //IL_029f: 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_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_02fb: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) //IL_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Unknown result type (might be due to invalid IL or missing references) //IL_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_017f: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_0309: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0278: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0317: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])(object)new Color32[16384]; Vector2 a = default(Vector2); ((Vector2)(ref a))..ctor(128f, 236f); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(15f, 79f); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(241f, 79f); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(241f, 51f); Vector2 c = default(Vector2); ((Vector2)(ref c))..ctor(15f, 51f); Vector2 val5 = default(Vector2); for (int i = 0; i < 128; i++) { for (int j = 0; j < 128; j++) { Color val4 = Color.clear; for (int k = 0; k < 2; k++) { for (int l = 0; l < 2; l++) { ((Vector2)(ref val5))..ctor((float)(j * 2 + l) + 0.5f, (float)(i * 2 + k) + 0.5f); Color val6 = Color.clear; if (Inside(val5, a, val, val2, out var w)) { float z = w.z; float y = w.y; float num = Noise(val5.x, val5.y); if (wood) { float num2 = Mathf.Floor(z * 5f); float num3 = Mathf.Sin(y * 160f + Mathf.Sin(z * 40f) * 2f) * 0.035f; float num4 = 0.92f + 0.12f * Noise(num2, 13f) + num3 + num * 0.045f; val6 = new Color(0.61f, 0.41f, 0.22f) * num4; if (z * 5f - num2 < 0.035f) { val6 *= 0.48f; } } else { float num5 = Mathf.Floor(y * 4f); float x = Mathf.Floor(z * 4f + (float)((int)num5 % 2) * 0.5f); float num6 = 0.82f + 0.19f * Noise(x, num5) + num * 0.085f; val6 = new Color(0.58f, 0.59f, 0.57f) * num6; float num7 = Mathf.Repeat(z * 4f + (float)((int)num5 % 2) * 0.5f, 1f); float num8 = Mathf.Repeat(y * 4f, 1f); if (num7 < 0.045f || num8 < 0.045f) { val6 *= 0.53f; } } if (Mathf.Min(w.x, Mathf.Min(w.y, w.z)) < 0.009f) { val6 *= 0.65f; } val6.a = 1f; } else if (Inside(val5, val, val2, val3, out w) || Inside(val5, val, val3, c, out w)) { float num9 = 0.75f + Noise(val5.x, val5.y) * 0.14f; val6 = (wood ? new Color(0.35f, 0.22f, 0.11f) : new Color(0.32f, 0.33f, 0.31f)) * num9; if (val5.y < 54f || val5.y > 76f) { val6 *= 0.65f; } val6.a = 1f; } val4 += val6; } } val4 *= 0.25f; if (val4.a > 0f) { val4.r /= val4.a; val4.g /= val4.a; val4.b /= val4.a; } array[i * 128 + j] = Color32.op_Implicit(val4); } } Texture2D val7 = new Texture2D(128, 128, (TextureFormat)4, false); val7.SetPixels32(array); val7.Apply(false, false); return val7; } private static float Noise(float x, float y) { return Mathf.Repeat(Mathf.Sin(x * 127.1f + y * 311.7f) * 43758.547f, 1f); } private static bool Inside(Vector2 p, Vector2 a, Vector2 b, Vector2 c, out Vector3 w) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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) //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_0028: 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_0038: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_007f: 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_008d: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: 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) float num = (b.y - c.y) * (a.x - c.x) + (c.x - b.x) * (a.y - c.y); float num2 = ((b.y - c.y) * (p.x - c.x) + (c.x - b.x) * (p.y - c.y)) / num; float num3 = ((c.y - a.y) * (p.x - c.x) + (a.x - c.x) * (p.y - c.y)) / num; w = new Vector3(num2, num3, 1f - num2 - num3); if (w.x >= 0f && w.y >= 0f) { return w.z >= 0f; } return false; } } internal static class MeshClipper { internal sealed class Result { internal Mesh Mesh; internal int InputTriangles; internal int OutputTriangles; internal int CapTriangles; internal int OpenCutEdges; internal int SourceOpenEdges; internal int PreservedOpenCutEdges; internal readonly List<string> Diagnostics = new List<string>(); } private struct Vertex { internal Vector3 Position; internal Vector3 Root; internal Vector3 Normal; internal Vector4 Tangent; internal Color Color; internal Vector4 UV0; internal Vector4 UV1; internal Vector4 UV2; internal Vector4 UV3; internal static Vertex Lerp(Vertex a, Vertex b, float t) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0057: 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_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_0070: 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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_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_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00d4: 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_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_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_00fa: 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_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_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) Vector4 val = Vector4.LerpUnclamped(a.Tangent, b.Tangent, t); Vector3 val2 = new Vector3(val.x, val.y, val.z); Vector3 normalized = ((Vector3)(ref val2)).normalized; Vertex result = new Vertex { Position = Vector3.LerpUnclamped(a.Position, b.Position, t), Root = Vector3.LerpUnclamped(a.Root, b.Root, t) }; val2 = Vector3.LerpUnclamped(a.Normal, b.Normal, t); result.Normal = ((Vector3)(ref val2)).normalized; result.Tangent = new Vector4(normalized.x, normalized.y, normalized.z, (val.w < 0f) ? (-1f) : 1f); result.Color = Color.LerpUnclamped(a.Color, b.Color, t); result.UV0 = Vector4.LerpUnclamped(a.UV0, b.UV0, t); result.UV1 = Vector4.LerpUnclamped(a.UV1, b.UV1, t); result.UV2 = Vector4.LerpUnclamped(a.UV2, b.UV2, t); result.UV3 = Vector4.LerpUnclamped(a.UV3, b.UV3, t); return result; } } private sealed class Node { internal Vector2 Plane; internal readonly List<int> Edges = new List<int>(); } private sealed class Edge { internal int A; internal int B; internal int Count; internal bool Used; } private sealed class Boundary { internal readonly List<Node> Nodes = new List<Node>(); internal readonly List<Edge> Edges = new List<Edge>(); internal readonly Dictionary<long, int> EdgeLookup = new Dictionary<long, int>(); internal readonly Dictionary<string, List<int>> NodeLookup = new Dictionary<string, List<int>>(); } private sealed class SourceEdge { internal int FirstTriangle; internal int Count; } private sealed class Topology { internal int[] Components; internal readonly HashSet<int> OpenComponents = new HashSet<int>(); internal int OpenEdges; } private sealed class SideSample { internal int Submesh; internal int Component; internal Vertex A; internal Vertex B; internal Vertex C; internal Vector3 Horizontal; internal float HMin; internal float HMax; internal float YMin; internal float YMax; internal float Determinant; internal float Score; internal float AH; internal float BH; internal float CH; internal Vertex Sample(float u, float v) { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: 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_01bd: 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_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0218: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Lerp(HMin, HMax, u); float num2 = Mathf.Lerp(YMin, YMax, v); float num3 = ((num - AH) * (C.Root.y - A.Root.y) - (num2 - A.Root.y) * (CH - AH)) / Determinant; float num4 = ((BH - AH) * (num2 - A.Root.y) - (B.Root.y - A.Root.y) * (num - AH)) / Determinant; float num5 = 1f - num3 - num4; return new Vertex { Color = A.Color * num5 + B.Color * num3 + C.Color * num4, UV0 = A.UV0 * num5 + B.UV0 * num3 + C.UV0 * num4, UV1 = A.UV1 * num5 + B.UV1 * num3 + C.UV1 * num4, UV2 = A.UV2 * num5 + B.UV2 * num3 + C.UV2 * num4, UV3 = A.UV3 * num5 + B.UV3 * num3 + C.UV3 * num4 }; } } private sealed class Builder { internal readonly List<Vertex> Vertices = new List<Vertex>(); internal readonly List<int>[] Indices; internal Builder(int submeshes) { Indices = new List<int>[submeshes]; for (int i = 0; i < submeshes; i++) { Indices[i] = new List<int>(); } } internal bool Triangle(Vertex a, Vertex b, Vertex c, int submesh) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(b.Position - a.Position, c.Position - a.Position); if (((Vector3)(ref val)).sqrMagnitude < 1E-16f) { return false; } int count = Vertices.Count; Vertices.Add(a); Vertices.Add(b); Vertices.Add(c); Indices[submesh].Add(count); Indices[submesh].Add(count + 1); Indices[submesh].Add(count + 2); return true; } } private const float Epsilon = 1E-05f; private const float WeldTolerance = 0.0001f; private static readonly Vector3 CutNormal; private static readonly Vector3 CutRight; internal static Result Clip(Mesh source, Matrix4x4 localToRoot, bool sealCuts = true) { //IL_00f1: 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_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: 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_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_013b: 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_0140: Unknown result type (might be due to invalid IL or missing references) //IL_051e: Unknown result type (might be due to invalid IL or missing references) //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_052c: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0535: Unknown result type (might be due to invalid IL or missing references) //IL_053a: Unknown result type (might be due to invalid IL or missing references) //IL_053e: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0547: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Unknown result type (might be due to invalid IL or missing references) //IL_0551: Unknown result type (might be due to invalid IL or missing references) //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_055a: Unknown result type (might be due to invalid IL or missing references) //IL_055c: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) //IL_0560: Unknown result type (might be due to invalid IL or missing references) //IL_0567: Unknown result type (might be due to invalid IL or missing references) //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_014b: 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_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: 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_037f: Unknown result type (might be due to invalid IL or missing references) //IL_038d: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_0a69: Unknown result type (might be due to invalid IL or missing references) //IL_0a6e: Unknown result type (might be due to invalid IL or missing references) //IL_0a86: Expected O, but got Unknown //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: 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_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_0480: Unknown result type (might be due to invalid IL or missing references) //IL_0498: Unknown result type (might be due to invalid IL or missing references) //IL_04b2: Unknown result type (might be due to invalid IL or missing references) //IL_0b3b: Unknown result type (might be due to invalid IL or missing references) //IL_0b49: Unknown result type (might be due to invalid IL or missing references) //IL_0b57: Unknown result type (might be due to invalid IL or missing references) //IL_0b65: Unknown result type (might be due to invalid IL or missing references) //IL_0b75: Unknown result type (might be due to invalid IL or missing references) //IL_0b85: Unknown result type (might be due to invalid IL or missing references) //IL_0b95: Unknown result type (might be due to invalid IL or missing references) //IL_0ba5: Unknown result type (might be due to invalid IL or missing references) //IL_06ae: Unknown result type (might be due to invalid IL or missing references) //IL_0830: Unknown result type (might be due to invalid IL or missing references) //IL_0835: Unknown result type (might be due to invalid IL or missing references) //IL_0839: Unknown result type (might be due to invalid IL or missing references) //IL_0849: Unknown result type (might be due to invalid IL or missing references) //IL_0859: Unknown result type (might be due to invalid IL or missing references) //IL_0869: Unknown result type (might be due to invalid IL or missing references) //IL_08cc: Unknown result type (might be due to invalid IL or missing references) //IL_08d1: Unknown result type (might be due to invalid IL or missing references) //IL_08f1: Unknown result type (might be due to invalid IL or missing references) //IL_090b: Unknown result type (might be due to invalid IL or missing references) //IL_08e1: Unknown result type (might be due to invalid IL or missing references) //IL_08e6: Unknown result type (might be due to invalid IL or missing references) //IL_092e: Unknown result type (might be due to invalid IL or missing references) //IL_0933: Unknown result type (might be due to invalid IL or missing references) //IL_093a: Unknown result type (might be due to invalid IL or missing references) //IL_093f: Unknown result type (might be due to invalid IL or missing references) //IL_0944: Unknown result type (might be due to invalid IL or missing references) //IL_094b: Unknown result type (might be due to invalid IL or missing references) //IL_0950: Unknown result type (might be due to invalid IL or missing references) //IL_0955: Unknown result type (might be due to invalid IL or missing references) //IL_0960: Unknown result type (might be due to invalid IL or missing references) //IL_0965: Unknown result type (might be due to invalid IL or missing references) //IL_096a: Unknown result type (might be due to invalid IL or missing references) //IL_0971: Unknown result type (might be due to invalid IL or missing references) //IL_0973: Unknown result type (might be due to invalid IL or missing references) //IL_097a: Unknown result type (might be due to invalid IL or missing references) //IL_0981: Unknown result type (might be due to invalid IL or missing references) //IL_0988: Unknown result type (might be due to invalid IL or missing references) //IL_0991: Unknown result type (might be due to invalid IL or missing references) //IL_0996: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)source)) { throw new ArgumentNullException("source"); } if (!source.isReadable) { throw new InvalidOperationException("Vanilla floor mesh is not CPU-readable: " + ((Object)source).name); } if (Mathf.Abs(((Matrix4x4)(ref localToRoot)).determinant) < 1E-12f) { throw new InvalidOperationException("A floor mesh has a singular transform: " + ((Object)source).name); } Result result = new Result(); Vector3[] vertices = source.vertices; Vector3[] normals = source.normals; Vector4[] tangents = source.tangents; Color[] colors = source.colors; List<Vector4>[] array = new List<Vector4>[4]; for (int i = 0; i < array.Length; i++) { array[i] = new List<Vector4>(); source.GetUVs(i, array[i]); } bool flag = normals.Length == vertices.Length; bool flag2 = tangents.Length == vertices.Length; bool flag3 = colors.Length == vertices.Length; Vertex[] array2 = new Vertex[vertices.Length]; for (int j = 0; j < array2.Length; j++) { array2[j] = new Vertex { Position = vertices[j], Root = ((Matrix4x4)(ref localToRoot)).MultiplyPoint3x4(vertices[j]), Normal = (flag ? normals[j] : Vector3.zero), Tangent = (flag2 ? tangents[j] : Vector4.zero), Color = (flag3 ? colors[j] : Color.white), UV0 = ((array[0].Count == array2.Length) ? array[0][j] : Vector4.zero), UV1 = ((array[1].Count == array2.Length) ? array[1][j] : Vector4.zero), UV2 = ((array[2].Count == array2.Length) ? array[2][j] : Vector4.zero), UV3 = ((array[3].Count == array2.Length) ? array[3][j] : Vector4.zero) }; } int num = Math.Max(1, source.subMeshCount); int[][] array3 = new int[source.subMeshCount][]; for (int k = 0; k < source.subMeshCount; k++) { if ((int)source.GetTopology(k) != 0) { throw new InvalidOperationException("Floor mesh is not a triangle mesh: " + ((Object)source).name); } array3[k] = source.GetTriangles(k); } Topology topology = SourceTopology(array2, array3); result.SourceOpenEdges = topology.OpenEdges; Builder builder = new Builder(num); Dictionary<int, Boundary> dictionary = new Dictionary<int, Boundary>(); List<SideSample> samples = new List<SideSample>(); Vertex[] array4 = new Vertex[3]; List<Vertex> list = new List<Vertex>(4); for (int l = 0; l < source.subMeshCount; l++) { int[] array5 = array3[l]; for (int m = 0; m < array5.Length; m += 3) { int num2 = topology.Components[result.InputTriangles]; if (!dictionary.TryGetValue(num2, out var value)) { dictionary.Add(num2, value = new Boundary()); } result.InputTriangles++; array4[0] = array2[array5[m]]; array4[1] = array2[array5[m + 1]]; array4[2] = array2[array5[m + 2]]; RememberSideSample(array4, l, num2, samples); list.Clear(); for (int n = 0; n < 3; n++) { Vertex vertex = array4[n]; Vertex b = array4[(n + 1) % 3]; float num3 = Distance(vertex.Root); float num4 = Distance(b.Root); bool num5 = num3 <= 1E-05f; bool flag4 = num4 <= 1E-05f; if (num5) { list.Add(vertex); } if (num5 != flag4) { Vertex item = Vertex.Lerp(vertex, b, Mathf.Clamp01(num3 / (num3 - num4))); list.Add(item); } } bool flag5 = false; for (int num6 = 1; num6 + 1 < list.Count; num6++) { flag5 |= builder.Triangle(list[0], list[num6], list[num6 + 1], l); } if (!flag5) { continue; } for (int num7 = 0; num7 < list.Count; num7++) { Vertex vertex2 = list[num7]; Vertex vertex3 = list[(num7 + 1) % list.Count]; if (Mathf.Abs(Distance(vertex2.Root)) <= 2E-05f && Mathf.Abs(Distance(vertex3.Root)) <= 2E-05f) { AddEdge(GetNode(vertex2.Root, value.Nodes, value.NodeLookup), GetNode(vertex3.Root, value.Nodes, value.NodeLookup), value.Nodes, value.Edges, value.EdgeLookup); } } } } Matrix4x4 inverse = ((Matrix4x4)(ref localToRoot)).inverse; Matrix4x4 transpose = ((Matrix4x4)(ref localToRoot)).transpose; Vector3 val = ((Matrix4x4)(ref transpose)).MultiplyVector(CutNormal); Vector3 normalized = ((Vector3)(ref val)).normalized; val = ((Matrix4x4)(ref inverse)).MultiplyVector(CutRight); Vector3 normalized2 = ((Vector3)(ref val)).normalized; float num8 = ((Vector3.Dot(Vector3.Cross(normalized, normalized2), ((Matrix4x4)(ref inverse)).MultiplyVector(Vector3.up)) < 0f) ? (-1f) : 1f); bool flag6 = ((Matrix4x4)(ref localToRoot)).determinant < 0f; foreach (KeyValuePair<int, Boundary> item2 in dictionary) { if (!sealCuts) { continue; } Boundary value2 = item2.Value; if (topology.OpenComponents.Contains(item2.Key)) { foreach (Edge edge in value2.Edges) { if ((edge.Count & 1) != 0) { result.PreservedOpenCutEdges++; } } result.Diagnostics.Add("Preserved a source component with an intentionally open boundary."); continue; } List<List<Vector2>> list2 = TraceLoops(value2.Nodes, value2.Edges, result); for (int num9 = 0; num9 < list2.Count; num9++) { int num10 = NestingDepth(num9, list2); if ((num10 & 1) != 0) { continue; } List<Vector2> list3 = new List<Vector2>(list2[num9]); if (SignedArea(list3) < 0f) { list3.Reverse(); } List<List<Vector2>> list4 = new List<List<Vector2>>(); for (int num11 = 0; num11 < list2.Count; num11++) { if (NestingDepth(num11, list2) == num10 + 1 && PointInPolygon(list2[num11][0], list2[num9])) { List<Vector2> list5 = new List<Vector2>(list2[num11]); if (SignedArea(list5) > 0f) { list5.Reverse(); } list4.Add(list5); } } bool flag7 = true; list4.Sort((List<Vector2> a, List<Vector2> loop) => MaximumX(loop).CompareTo(MaximumX(a))); foreach (List<Vector2> item3 in list4) { if (!BridgeHole(list3, item3, list4)) { flag7 = false; break; } } if (!flag7) { result.OpenCutEdges += list3.Count; result.Diagnostics.Add("Could not bridge a cap hole."); continue; } List<int> list6 = Triangulate(list3); if (list6 == null) { result.OpenCutEdges += list3.Count; result.Diagnostics.Add("Could not triangulate cap contour: " + string.Join(";", list3.ConvertAll((Vector2 p) => p.x.ToString("G9") + "," + p.y.ToString("G9")).ToArray())); continue; } float num12 = float.PositiveInfinity; float num13 = float.NegativeInfinity; float num14 = float.PositiveInfinity; float num15 = float.NegativeInfinity; foreach (Vector2 item4 in list3) { num12 = Mathf.Min(num12, item4.x); num13 = Mathf.Max(num13, item4.x); num14 = Mathf.Min(num14, item4.y); num15 = Mathf.Max(num15, item4.y); } SideSample sideSample = ChooseSideSample(samples, list3, item2.Key); int submesh = sideSample?.Submesh ?? 0; Vertex[] array6 = new Vertex[list3.Count]; for (int num16 = 0; num16 < list3.Count; num16++) { Vector2 val2 = list3[num16]; Vertex vertex4 = sideSample?.Sample((val2.x - num12) / Mathf.Max(1E-05f, num13 - num12), (val2.y - num14) / Mathf.Max(1E-05f, num15 - num14)) ?? new Vertex { Color = Color.white }; vertex4.Root = CutRight * val2.x + Vector3.up * val2.y; vertex4.Position = ((Matrix4x4)(ref inverse)).MultiplyPoint3x4(vertex4.Root); vertex4.Normal = normalized; vertex4.Tangent = new Vector4(normalized2.x, normalized2.y, normalized2.z, num8); array6[num16] = vertex4; } for (int num17 = 0; num17 < list6.Count; num17 += 3) { int num18 = list6[num17]; int num19 = list6[num17 + 1]; int num20 = list6[num17 + 2]; if (builder.Triangle(array6[num18], array6[flag6 ? num20 : num19], array6[flag6 ? num19 : num20], submesh)) { result.CapTriangles++; } } } } Mesh val3 = new Mesh { name = ((Object)source).name + "_CornerCut" }; if (builder.Vertices.Count > 65535) { val3.indexFormat = (IndexFormat)1; } List<Vector3> list7 = new List<Vector3>(builder.Vertices.Count); List<Vector3> list8 = new List<Vector3>(builder.Vertices.Count); List<Vector4> list9 = new List<Vector4>(builder.Vertices.Count); List<Color> list10 = new List<Color>(builder.Vertices.Count); List<Vector4>[] array7 = new List<Vector4>[4]; for (int num21 = 0; num21 < 4; num21++) { array7[num21] = new List<Vector4>(builder.Vertices.Count); } foreach (Vertex vertex5 in builder.Vertices) { list7.Add(vertex5.Position); list8.Add(vertex5.Normal); list9.Add(vertex5.Tangent); list10.Add(vertex5.Color); array7[0].Add(vertex5.UV0); array7[1].Add(vertex5.UV1); array7[2].Add(vertex5.UV2); array7[3].Add(vertex5.UV3); } val3.SetVertices(list7); val3.subMeshCount = num; for (int num22 = 0; num22 < num; num22++) { val3.SetTriangles(builder.Indices[num22], num22, false); result.OutputTriangles += builder.Indices[num22].Count / 3; } if (flag) { val3.SetNormals(list8); } else { val3.RecalculateNormals(); } if (flag2) { val3.SetTangents(list9); } if (flag3) { val3.SetColors(list10); } for (int num23 = 0; num23 < 4; num23++) { if (array[num23].Count == array2.Length && array2.Length != 0) { val3.SetUVs(num23, array7[num23]); } } if (!flag2 && array[0].Count == array2.Length && array2.Length != 0 && builder.Vertices.Count > 0) { val3.RecalculateTangents(); } val3.RecalculateBounds(); result.Mesh = val3; return result; } private static float Distance(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) return p.x + p.z; } private static Vector2 PlanePoint(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) return new Vector2(Vector3.Dot(p, CutRight), p.y); } private static Topology SourceTopology(Vertex[] input, int[][] submeshes) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) int num = 0; int[][] array = submeshes; foreach (int[] array2 in array) { num += array2.Length / 3; } int[] array3 = new int[num]; for (int j = 0; j < array3.Length; j++) { array3[j] = j; } List<Vector3> positions = new List<Vector3>(); Dictionary<string, List<int>> lookup = new Dictionary<string, List<int>>(); int[] array4 = new int[input.Length]; for (int k = 0; k < input.Length; k++) { array4[k] = WeldSourcePosition(input[k].Root, positions, lookup); } Dictionary<long, SourceEdge> dictionary = new Dictionary<long, SourceEdge>(); int num2 = 0; array = submeshes; foreach (int[] array5 in array) { int num3 = 0; while (num3 < array5.Length) { for (int l = 0; l < 3; l++) { int num4 = array4[array5[num3 + l]]; int num5 = array4[array5[num3 + (l + 1) % 3]]; if (num4 == num5) { continue; } long key = ((long)Math.Min(num4, num5) << 32) | (uint)Math.Max(num4, num5); if (!dictionary.TryGetValue(key, out var value)) { dictionary.Add(key, new SourceEdge { FirstTriangle = num2, Count = 1 }); continue; } value.Count++; int num6 = Find(array3, value.FirstTriangle); int num7 = Find(array3, num2); if (num6 != num7) { array3[num7] = num6; } } num3 += 3; num2++; } } Topology topology = new Topology { Components = new int[num] }; for (int m = 0; m < num; m++) { topology.Components[m] = Find(array3, m); } foreach (SourceEdge value2 in dictionary.Values) { if (value2.Count != 2) { topology.OpenEdges++; topology.OpenComponents.Add(Find(array3, value2.FirstTriangle)); } } return topology; } private static int Find(int[] parent, int i) { while (parent[i] != i) { parent[i] = parent[parent[i]]; i = parent[i]; } return i; } private static int WeldSourcePosition(Vector3 point, List<Vector3> positions, Dictionary<string, List<int>> lookup) { //IL_0000: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_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) long num = (long)Math.Floor(point.x / 0.0001f); long num2 = (long)Math.Floor(point.y / 0.0001f); long num3 = (long)Math.Floor(point.z / 0.0001f); for (long num4 = -1L; num4 <= 1; num4++) { for (long num5 = -1L; num5 <= 1; num5++) { for (long num6 = -1L; num6 <= 1; num6++) { if (!lookup.TryGetValue(num + num4 + ":" + (num2 + num5) + ":" + (num3 + num6), out var value)) { continue; } foreach (int item in value) { Vector3 val = positions[item] - point; if (((Vector3)(ref val)).sqrMagnitude <= 9.999999E-09f) { return item; } } } } } string key = num + ":" + num2 + ":" + num3; if (!lookup.TryGetValue(key, out var value2)) { lookup.Add(key, value2 = new List<int>()); } int count = positions.Count; positions.Add(point); value2.Add(count); return count; } private static int GetNode(Vector3 root, List<Node> nodes, Dictionary<string, List<int>> lookup) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) Vector2 val = PlanePoint(root); long num = (long)Math.Floor(val.x / 0.0001f); long num2 = (long)Math.Floor(val.y / 0.0001f); for (long num3 = -1L; num3 <= 1; num3++) { for (long num4 = -1L; num4 <= 1; num4++) { if (!lookup.TryGetValue(num + num3 + ":" + (num2 + num4), out var value)) { continue; } foreach (int item in value) { Vector2 val2 = nodes[item].Plane - val; if (((Vector2)(ref val2)).sqrMagnitude <= 9.999999E-09f) { return item; } } } } string key = num + ":" + num2; if (!lookup.TryGetValue(key, out var value2)) { lookup.Add(key, value2 = new List<int>()); } int count = nodes.Count; nodes.Add(new Node { Plane = val }); value2.Add(count); return count; } private static void AddEdge(int a, int b, List<Node> nodes, List<Edge> edges, Dictionary<long, int> lookup) { if (a != b) { long key = ((long)Math.Min(a, b) << 32) | (uint)Math.Max(a, b); if (lookup.TryGetValue(key, out var value)) { edges[value].Count++; return; } value = edges.Count; edges.Add(new Edge { A = a, B = b, Count = 1 }); lookup.Add(key, value); nodes[a].Edges.Add(value); nodes[b].Edges.Add(value); } } private static List<List<Vector2>> TraceLoops(List<Node> nodes, List<Edge> edges, Result result) { //IL_006a: 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_00b1: 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_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) List<List<Vector2>> list = new List<List<Vector2>>(); for (int i = 0; i < edges.Count; i++) { if (edges[i].Used || (edges[i].Count & 1) == 0) { continue; } List<Vector2> list2 = new List<Vector2>(); int a = edges[i].A; int index = a; int num = edges[i].B; edges[i].Used = true; list2.Add(nodes[a].Plane); bool flag = false; for (int j = 0; j <= edges.Count; j++) { if (num == a) { flag = true; break; } list2.Add(nodes[num].Plane); int num2 = -1; float num3 = float.PositiveInfinity; Vector2 val = nodes[num].Plane - nodes[index].Plane; foreach (int edge2 in nodes[num].Edges) { Edge edge = edges[edge2]; if (!edge.Used && (edge.Count & 1) != 0) { int index2 = ((edge.A == num) ? edge.B : edge.A); Vector2 val2 = nodes[index2].Plane - nodes[num].Plane; float num4 = Mathf.Atan2(Cross(val, val2), Vector2.Dot(val, val2)); if (num4 < -1E-05f) { num4 += (float)Math.PI * 2f; } if (num4 < num3) { num3 = num4; num2 = edge2; } } } if (num2 < 0) { break; } edges[num2].Used = true; int num5 = ((edges[num2].A == num) ? edges[num2].B : edges[num2].A); index = num; num = num5; } CleanContour(list2); if (flag && list2.Count >= 3 && Mathf.Abs(SignedArea(list2)) > 9.9999994E-11f) { list.Add(list2); continue; } result.OpenCutEdges += list2.Count; result.Diagnostics.Add("Open cut path (" + list2.Count + " points): " + string.Join(";", list2.ConvertAll((Vector2 p) => p.x.ToString("G9") + "," + p.y.ToString("G9")).ToArray())); } return list; } private static void CleanContour(List<Vector2> points) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_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) bool flag = true; while (flag && points.Count >= 3) { flag = false; int num = 0; while (num < points.Count) { Vector2 val = points[(num + points.Count - 1) % points.Count]; Vector2 val2 = points[num]; Vector2 val3 = points[(num + 1) % points.Count]; Vector2 val4 = val2 - val; if (!(((Vector2)(ref val4)).sqrMagnitude < 9.999999E-09f)) { float num2 = Mathf.Abs(Cross(val2 - val, val3 - val2)); val4 = val3 - val; if (!(num2 < 1E-05f * Mathf.Max(1E-05f, ((Vector2)(ref val4)).magnitude))) { num++; continue; } } points.RemoveAt(num); flag = true; break; } } } private static void RememberSideSample(Vertex[] triangle, int material, int component, List<SideSample> samples) { //IL_0007: 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_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_009a: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_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_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) Vector3 val = Vector3.Cross(triangle[1].Root - triangle[0].Root, triangle[2].Root - triangle[0].Root); float magnitude = ((Vector3)(ref val)).magnitude; if (!(magnitude < 9.9999994E-11f) && !(Mathf.Abs(val.y) / magnitude > 0.5f)) { Vector3 val2 = Vector3.Cross(Vector3.up, ((Vector3)(ref val)).normalized); Vector3 normalized = ((Vector3)(ref val2)).normalized; float num = Vector3.Dot(triangle[0].Root, normalized); float num2 = Vector3.Dot(triangle[1].Root, normalized); float num3 = Vector3.Dot(triangle[2].Root, normalized); float num4 = (num2 - num) * (triangle[2].Root.y - triangle[0].Root.y) - (num3 - num) * (triangle[1].Root.y - triangle[0].Root.y); if (!(Mathf.Abs(num4) < 9.9999994E-11f)) { samples.Add(new SideSample { Submesh = material, Component = component, A = triangle[0], B = triangle[1], C = triangle[2], Horizontal = normalized, AH = num, BH = num2, CH = num3, HMin = Mathf.Min(num, Mathf.Min(num2, num3)), HMax = Mathf.Max(num, Mathf.Max(num2, num3)), YMin = Mathf.Min(triangle[0].Root.y, Mathf.Min(triangle[1].Root.y, triangle[2].Root.y)), YMax = Mathf.Max(triangle[0].Root.y, Mathf.Max(triangle[1].Root.y, triangle[2].Root.y)), Determinant = num4, Score = magnitude * (1f - Mathf.Abs(val.y) / magnitude) }); } } } private static SideSample ChooseSideSample(List<SideSample> samples, List<Vector2> contour, int component) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) Vector2 val = Vector2.zero; foreach (Vector2 item in contour) { val += item; } val /= (float)contour.Count; SideSample result = null; float num = float.NegativeInfinity; foreach (SideSample sample in samples) { if (sample.Component == component) { Vector2 val2 = PlanePoint((sample.A.Root + sample.B.Root + sample.C.Root) / 3f) - val; float sqrMagnitude = ((Vector2)(ref val2)).sqrMagnitude; float num2 = sample.Score / (0.01f + sqrMagnitude); if (num2 > num) { num = num2; result = sample; } } } return result; } private static float Cross(Vector2 a, Vector2 b) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_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 a.x * b.y - a.y * b.x; } private static float SignedArea(List<Vector2> contour) { //IL_000d: 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) float num = 0f; for (int i = 0; i < contour.Count; i++) { num += Cross(contour[i], contour[(i + 1) % contour.Count]); } return num * 0.5f; } private static bool PointInPolygon(Vector2 p, List<Vector2> contour) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: 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_0053: 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_0061: 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_0070: Unknown result type (might be due to invalid IL or missing references) bool flag = false; int num = 0; int index = contour.Count - 1; while (num < contour.Count) { Vector2 val = contour[num]; Vector2 val2 = contour[index]; if (val.y > p.y != val2.y > p.y && p.x < (val2.x - val.x) * (p.y - val.y) / (val2.y - val.y) + val.x) { flag = !flag; } index = num++; } return flag; } private static int NestingDepth(int index, List<List<Vector2>> loops) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) int num = 0; float num2 = Mathf.Abs(SignedArea(loops[index])); for (int i = 0; i < loops.Count; i++) { if (i != index && Mathf.Abs(SignedArea(loops[i])) > num2 && PointInPolygon(loops[index][0], loops[i])) { num++; } } return num; } private static float MaximumX(List<Vector2> loop) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) float num = float.NegativeInfinity; foreach (Vector2 item in loop) { num = Mathf.Max(num, item.x); } return num; } private static bool BridgeHole(List<Vector2> outer, List<Vector2> hole, List<List<Vector2>> allHoles) { //IL_000a: 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_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0040: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) int num = 0; for (int i = 1; i < hole.Count; i++) { if (hole[i].x > hole[num].x || (hole[i].x == hole[num].x && hole[i].y < hole[num].y)) { num = i; } } int num2 = -1; float num3 = float.PositiveInfinity; for (int j = 0; j < outer.Count; j++) { Vector2 val = outer[j] - hole[num]; float sqrMagnitude = ((Vector2)(ref val)).sqrMagnitude; if (!(sqrMagnitude >= num3) && VisibleBridge(hole[num], outer[j], outer, allHoles)) { num2 = j; num3 = sqrMagnitude; } } if (num2 < 0) { return false; } List<Vector2> list = new List<Vector2>(outer.Count + hole.Count + 2); for (int k = 0; k <= num2; k++) { list.Add(outer[k]); } for (int l = 0; l < hole.Count; l++) { list.Add(hole[(num + l) % hole.Count]); } list.Add(hole[num]); list.Add(outer[num2]); for (int m = num2 + 1; m < outer.Count; m++) { list.Add(outer[m]); } outer.Clear(); outer.AddRange(list); return true; } private static bool VisibleBridge(Vector2 a, Vector2 b, List<Vector2> outer, List<List<Vector2>> holes) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_000c: 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_001c: 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_003a: 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_0051: 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) if (!PointInPolygon((a + b) * 0.5f, outer)) { return false; } if (CrossesContour(a, b, outer)) { return false; } foreach (List<Vector2> hole in holes) { if (PointInPolygon((a + b) * 0.5f, hole) || CrossesContour(a, b, hole)) { return false; } } return true; } private static bool CrossesContour(Vector2 a, Vector2 b, List<Vector2> contour) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_0020: 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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_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_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_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_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < contour.Count; i++) { Vector2 val = contour[i]; Vector2 val2 = contour[(i + 1) % contour.Count]; Vector2 val3 = a - val; if (((Vector2)(ref val3)).sqrMagnitude < 9.9999994E-11f) { continue; } val3 = a - val2; if (((Vector2)(ref val3)).sqrMagnitude < 9.9999994E-11f) { continue; } val3 = b - val; if (((Vector2)(ref val3)).sqrMagnitude < 9.9999994E-11f) { continue; } val3 = b - val2; if (!(((Vector2)(ref val3)).sqrMagnitude < 9.9999994E-11f)) { float num = Cross(b - a, val - a); float num2 = Cross(b - a, val2 - a); float num3 = Cross(val2 - val, a - val); float num4 = Cross(val2 - val, b - val); if (num * num2 <= 0f && num3 * num4 <= 0f) { return true; } } } return false; } private static List<int> Triangulate(List<Vector2> contour) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) List<int> list = new List<int>(contour.Count); List<int> list2 = new List<int>(); for (int i = 0; i < contour.Count; i++) { list.Add(i); } int num = contour.Count * contour.Count; while (list.Count > 3 && --num >= 0) { bool flag = false; for (int j = 0; j < list.Count; j++) { int num2 = list[(j + list.Count - 1) % list.Count]; int num3 = list[j]; int num4 = list[(j + 1) % list.Count]; if (Cross(contour[num3] - contour[num2], contour[num4] - contour[num3]) <= 9.9999994E-11f) { continue; } bool flag2 = false; foreach (int item in list) { if (item == num2 || item == num3 || item == num4) { continue; } Vector2 val = contour[item] - contour[num2]; if (((Vector2)(ref val)).sqrMagnitude < 9.9999994E-11f) { continue; } val = contour[item] - contour[num3]; if (!(((Vector2)(ref val)).sqrMagnitude < 9.9999994E-11f)) { val = contour[item] - contour[num4]; if (!(((Vector2)(ref val)).sqrMagnitude < 9.9999994E-11f) && InsideTriangle(contour[item], contour[num2], contour[num3], contour[num4])) { flag2 = true; break; } } } if (!flag2) { list2.Add(num2); list2.Add(num3); list2.Add(num4); list.RemoveAt(j); flag = true; break; } } if (!flag) { return null; } } if (list.Count == 3) { list2.Add(list[0]); list2.Add(list[1]); list2.Add(list[2]); } return list2; } private static bool InsideTriangle(Vector2 p, Vector2 a, Vector2 b, Vector2 c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //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_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_001a: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0034: 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_0036: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) if (Cross(b - a, p - a) >= -9.9999994E-11f && Cross(c - b, p - b) >= -9.9999994E-11f) { return Cross(a - c, p - c) >= -9.9999994E-11f; } return false; } static MeshClipper() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) Vector3 val = new Vector3(1f, 0f, 1f); CutNormal = ((Vector3)(ref val)).normalized; val = new Vector3(1f, 0f, -1f); CutRight = ((Vector3)(ref val)).normalized; } } [BepInPlugin("local.cornerfloors", "Corner Floors", "1.1.1")] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(ZNetScene), "Awake")] private static class Register { private static void Postfix(ZNetScene __instance) { RegisterOne(__instance, "wood_floor", "cf_wood_corner", "Wood floor corner"); RegisterOne(__instance, "stone_floor_2x2", "cf_stone_corner", "Stone floor corner"); } } internal static Plugin Instance; private Harmony patches; private void Awake() { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown Instance = this; patches = new Harmony("local.cornerfloors"); patches.PatchAll(); } private void OnDestroy() { Harmony obj = patches; if (obj != null) { obj.UnpatchSelf(); } } private static void RegisterOne(ZNetScene scene, string sourceName, string name, string title) { if (Object.op_Implicit((Object)(object)scene.GetPrefab(name))) { return; } try { GameObject prefab = scene.GetPrefab(sourceName); if (!Object.op_Implicit((Object)(object)prefab)) { throw new InvalidOperationException("Missing vanilla prefab: " + sourceName); } GameObject val = CreatePrefab(prefab, name, title); ((Dictionary<int, GameObject>)AccessTools.Field(typeof(ZNetScene), "m_namedPrefabs").GetValue(scene)).Add(StringExtensionMethods.GetStableHashCode(name), val); scene.m_prefabs.Add(val); PieceTable buildPieces = ObjectDB.instance.GetItemPrefab("Hammer").GetComponent<ItemDrop>().m_itemData.m_shared.m_buildPieces; buildPieces.m_pieces.RemoveAll((GameObject p) => !Object.op_Implicit((Object)(object)p) || ((Object)p).name == name); buildPieces.m_pieces.Add(val); ((BaseUnityPlugin)Instance).Logger.LogInfo((object)("Registered " + name + " (1.1.1)")); } catch (Exception ex) { ((BaseUnityPlugin)Instance).Logger.LogError((object)("Could not register " + name + ": " + ex)); } } internal static GameObject CreatePrefab(GameObject source, string name, string title) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: 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_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_035b: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_02cc: Unknown result type (might be due to invalid IL or missing references) //IL_02d8: 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_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03e6: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027a: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0290: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_0490: Unknown result type (might be due to invalid IL or missing references) //IL_0495: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b0: Unknown result type (might be due to invalid IL or missing references) //IL_04c6: Unknown result type (might be due to invalid IL or missing references) //IL_04cb: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Unknown result type (might be due to invalid IL or missing references) //IL_04fc: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_02b5: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02a4: 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) //IL_0552: Unknown result type (might be due to invalid IL or missing references) //IL_055d: Unknown result type (might be due to invalid IL or missing references) //IL_0578: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_0589: Unknown result type (might be due to invalid IL or missing references) //IL_061a: Unknown result type (might be due to invalid IL or missing references) //IL_061f: Unknown result type (might be due to invalid IL or missing references) //IL_062c: Unknown result type (might be due to invalid IL or missing references) //IL_0643: Unknown result type (might be due to invalid IL or missing references) //IL_0650: Unknown result type (might be due to invalid IL or missing references) //IL_0662: Expected O, but got Unknown GameObject val = new GameObject(name + "_template"); val.SetActive(false); try { GameObject val2 = Object.Instantiate<GameObject>(source, val.transform); ((Object)val2).name = name; val2.SetActive(true); MeshFilter[] componentsInChildren = val2.GetComponentsInChildren<MeshFilter>(true); int num = 0; int num2 = 0; MeshFilter[] array = componentsInChildren; foreach (MeshFilter val3 in array) { if (!Object.op_Implicit((Object)(object)val3.sharedMesh)) { continue; } Matrix4x4 localToRoot = val2.transform.worldToLocalMatrix * ((Component)val3).transform.localToWorldMatrix; bool flag = ((Object)val3).name.IndexOf("snow", StringComparison.OrdinalIgnoreCase) >= 0 || ((Object)val3.sharedMesh).name.IndexOf("snow", StringComparison.OrdinalIgnoreCase) >= 0; MeshClipper.Result result = MeshClipper.Clip(val3.sharedMesh, localToRoot, !flag); if (result.OpenCutEdges != 0) { throw new InvalidOperationException("Unsealed cut on " + ((Object)val3).name + ": " + result.OpenCutEdges + " edges"); } CornerTipFitter.Apply(result.Mesh, localToRoot); val3.sharedMesh = result.Mesh; int num3 = 0; for (int j = 0; j < result.Mesh.subMeshCount; j++) { num3 += result.Mesh.GetTriangles(j).Length / 3; } num += num3; num2 += result.CapTriangles; if (num3 == 0) { Renderer component = ((Component)val3).GetComponent<Renderer>(); if (Object.op_Implicit((Object)(object)component)) { component.enabled = false; } } } if (num == 0) { throw new InvalidOperationException("No clipped floor geometry: " + ((Object)source).name); } Bounds val4 = default(Bounds); ((Bounds)(ref val4))..ctor(new Vector3(0f, -0.075f, 0f), new Vector3(2f, 0.15f, 2f)); int layer = val2.layer; float num4 = 0f; BoxCollider[] componentsInChildren2 = val2.GetComponentsInChildren<BoxCollider>(true); foreach (BoxCollider val5 in componentsInChildren2) { if (((Collider)val5).isTrigger) { continue; } Bounds val6 = default(Bounds); bool flag2 = true; for (int k = 0; k < 8; k++) { Vector3 val7 = val5.center + Vector3.Scale(val5.size * 0.5f, new Vector3((float)(((k & 1) != 0) ? 1 : (-1)), (float)(((k & 2) != 0) ? 1 : (-1)), (float)(((k & 4) != 0) ? 1 : (-1)))); val7 = val2.transform.InverseTransformPoint(((Component)val5).transform.TransformPoint(val7)); if (flag2) { ((Bounds)(ref val6))..ctor(val7, Vector3.zero); flag2 = false; } else { ((Bounds)(ref val6)).Encapsulate(val7); } } float num5 = ((Bounds)(ref val6)).size.x * ((Bounds)(ref val6)).size.z; if (num5 > num4) { val4 = val6; num4 = num5; layer = ((Component)val5).gameObject.layer; } } Collider[] componentsInChildren3 = val2.GetComponentsInChildren<Collider>(true); foreach (Collider obj in componentsInChildren3) { obj.enabled = false; Object.DestroyImmediate((Object)(object)obj); } GameObject val8 = new GameObject("_cf_collision"); val8.transform.SetParent(val2.transform, false); val8.layer = layer; MeshCollider obj2 = val8.AddComponent<MeshCollider>(); obj2.sharedMesh = CollisionPrism(((Bounds)(ref val4)).min.y, ((Bounds)(ref val4)).max.y); obj2.convex = true; List<GameObject> list = new List<GameObject>(); List<float> list2 = new List<float>(); Transform[] componentsInChildren4 = val2.GetComponentsInChildren<Transform>(true); foreach (Transform val9 in componentsInChildren4) { if (((Component)val9).CompareTag("snappoint")) { list.Add(((Component)val9).gameObject); float y = val2.transform.InverseTransformPoint(val9.position).y; if (!list2.Exists((float h) => Math.Abs(h - y) < 0.001f)) { list2.Add(y); } } } foreach (GameObject item in list) { if (Object.op_Implicit((Object)(object)item)) { Object.DestroyImmediate((Object)(object)item); } } if (list2.Count == 0) { list2.Add(0f); } Vector3[] array2 = (Vector3[])(object)new Vector3[6] { new Vector3(-1f, 0f, -1f), new Vector3(1f, 0f, -1f), new Vector3(-1f, 0f, 1f), new Vector3(0f, 0f, -1f), new Vector3(-1f, 0f, 0f), new Vector3(0f, 0f, 0f) }; foreach (float item2 in list2) { for (int num6 = 0; num6 < array2.Length; num6++) { GameObject val10 = new GameObject("_snappoint" + num6) { tag = "snappoint" }; val10.transform.SetParent(val2.transform, false); val10.transform.localPosition = array2[num6] + Vector3.up * item2; } } LODGroup[] componentsInChildren5 = val2.GetComponentsInChildren<LODGroup>(true); for (int i = 0; i < componentsInChildren5.Length; i++) { componentsInChildren5[i].RecalculateBounds(); } Piece component2 = val2.GetComponent<Piece>(); component2.m_name = title; component2.m_description = "Triangular half of a 2 x 2 m floor. Rotate with the hammer."; List<Requirement> list3 = new List<Requirement>(); Requirement[] resources = component2.m_resources; foreach (Requirement val11 in resources) { list3.Add(new Requirement { m_resItem = val11.m_resItem, m_amount = Math.Max(1, (val11.m_amount + 1) / 2), m_amountPerLevel = val11.m_amountPerLevel, m_recover = val11.m_recover }); } component2.m_resources = list3.ToArray(); component2.m_icon = FloorIcon.Create(val2, ((Object)source).name == "wood_floor"); ((BaseUnityPlugin)Instance).Logger.LogInfo((object)(name + ": " + componentsInChildren.Length + " meshes, " + num + " triangles, " + num2 + " cut-face triangles")); return val2; } catch { Object.DestroyImmediate((Object)(object)val); throw; } } internal static Mesh CollisionPrism(float bottom, float top) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) Mesh val = new Mesh { name = "CornerFloors_Collision" }; val.vertices = (Vector3[])(object)new Vector3[6] { new Vector3(-1f, top, -1f), new Vector3(1f, top, -1f), new Vector3(-1f, top, 1f), new Vector3(-1f, bottom, -1f), new Vector3(1f, bottom, -1f), new Vector3(-1f, bottom, 1f) }; val.triangles = new int[24] { 0, 2, 1, 3, 4, 5, 0, 1, 4, 0, 4, 3, 1, 2, 5, 1, 5