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 QuanPieces v1.1.0
QuanPieces.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using QuanPieces.Meshes; using QuanPieces.Pieces; using UnityEngine; using UnityEngine.Rendering; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("QuanPieces")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.0.0")] [assembly: AssemblyInformationalVersion("1.1.0+f07ea74997661ada4e005890a48630149cf79f69")] [assembly: AssemblyProduct("QuanPieces")] [assembly: AssemblyTitle("QuanPieces")] [assembly: AssemblyVersion("1.1.0.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 QuanPieces { [BepInPlugin("quandru.QuanPieces", "QuanPieces", "1.1.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public class QuanPiecesPlugin : BaseUnityPlugin { public const string PluginGuid = "quandru.QuanPieces"; public const string PluginName = "QuanPieces"; public const string PluginVersion = "1.1.0"; internal const string HammerCategory = "QuanPieces"; internal static ManualLogSource Log; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; PrefabManager.OnVanillaPrefabsAvailable += AddPieces; } private void AddPieces() { PrefabManager.OnVanillaPrefabsAvailable -= AddPieces; Register("chimney flue", ChimneyFlue.Register); Register("brazier street light", BrazierStreetlight.Register); Register("lantern street light", LanternStreetlight.Register); } private static void Register(string piece, Action register) { try { register(); } catch (Exception arg) { Log.LogError((object)$"Couldn't add the {piece}: {arg}"); } } } internal static class PluginInfo { public const string Version = "1.1.0"; } } namespace QuanPieces.Pieces { internal static class BrazierStreetlight { private const string PrefabName = "Quan_streetlight_brazier"; private const string BasePrefab = "piece_brazierceiling01"; private const string PostPrefab = "wood_pole2"; private const string BeamPrefab = "wood_beam"; private const float PoleWidth = 0.4f; private const float PostHeight = 4f; private const float ArmLength = 2f; private const float BraceScale = 0.75f; private const float FootHeight = 2f; private const float FootOverlap = 0.75f; private const float FootInset = 0.002f; private const float BrazierOut = 1.6f; private const float KeepChainBelow = -0.7f; private const float ChainHangPoint = -0.6845f; private const float ChainAxisTolerance = 0.02f; private const float LightRange = 12f; public static void Register() { //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_013d: Expected O, but got Unknown //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = PrefabManager.Instance.GetPrefab("piece_brazierceiling01"); Piece val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Piece>() : null); GameObject prefab2 = PrefabManager.Instance.GetPrefab("wood_pole2"); GameObject prefab3 = PrefabManager.Instance.GetPrefab("wood_beam"); if ((Object)(object)val == (Object)null || (Object)(object)prefab2 == (Object)null || (Object)(object)prefab3 == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)"'piece_brazierceiling01', 'wood_pole2' or 'wood_beam' not found; brazier street light skipped."); return; } RequirementConfig[] requirements = val.m_resources.Where((Requirement r) => r != null && (Object)(object)r.m_resItem != (Object)null).Select((Func<Requirement, RequirementConfig>)((Requirement r) => new RequirementConfig(((Object)r.m_resItem).name, r.m_amount, r.m_amountPerLevel, r.m_recover))).Concat((IEnumerable<RequirementConfig>)(object)new RequirementConfig[1] { new RequirementConfig("Wood", 4, 0, true) }) .ToArray(); PieceConfig val2 = new PieceConfig { Name = "Quan's Brazier Street Light", Description = "A coal-fired brazier hung from a wooden post, for lighting paths and streets.", PieceTable = PieceTables.Hammer, Category = "QuanPieces", CraftingStation = (Object.op_Implicit((Object)(object)val.m_craftingStation) ? ((Object)val.m_craftingStation).name : string.Empty), Requirements = requirements }; CustomPiece val3 = new CustomPiece("Quan_streetlight_brazier", "piece_brazierceiling01", val2); if (Build(val3.PiecePrefab, prefab2, prefab3)) { Sprite val4 = RenderManager.Instance.Render(val3.PiecePrefab, RenderManager.IsometricRotation); if ((Object)(object)val4 != (Object)null) { val3.Piece.m_icon = val4; } else { QuanPiecesPlugin.Log.LogWarning((object)"Brazier street light: icon render failed; using the hanging brazier's icon."); } PieceManager.Instance.AddPiece(val3); } } private static bool Build(GameObject prefab, GameObject post, GameObject beam) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_01c9: Unknown result type (might be due to invalid IL or missing references) Fireplace component = prefab.GetComponent<Fireplace>(); Transform val = FindVisual(post); Transform val2 = FindVisual(beam); if ((Object)(object)component == (Object)null || (Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)"Brazier street light: Fireplace or the pole/beam visuals not found; skipped."); return false; } float num = 3.8f; Transform transform = new GameObject("brazier").transform; List<Transform> list = ((IEnumerable)prefab.transform).Cast<Transform>().ToList(); transform.SetParent(prefab.transform, false); foreach (Transform item in list) { item.SetParent(transform, false); } Transform val3 = transform.Find("New"); if ((Object)(object)val3 == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)"Brazier street light: the brazier's 'New' mesh wasn't found; skipped."); return false; } transform.localPosition = new Vector3(1.6f, num - (val3.localPosition.y + -0.6845f), 0f); ShortenChain(val3); Transform val4 = transform.Find("_enabled_high/Point light"); if ((Object)(object)val4 != (Object)null) { Light component2 = ((Component)val4).GetComponent<Light>(); if (component2 != null) { component2.range = 12f; } } Transform val5 = transform.Find("collider (5)"); if ((Object)(object)val5 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val5).gameObject); } List<Renderer> frame = BuildFrame(prefab.transform, val, val2); AddFrameColliders(prefab.transform); IncludeInLods(prefab, frame); CopyPlacementRules(prefab.GetComponent<Piece>(), post.GetComponent<Piece>()); component.m_disableCoverCheck = true; if ((Object)(object)component.m_smokeSpawner == (Object)null) { component.m_smokeSpawner = ((Component)transform).GetComponentInChildren<SmokeSpawner>(true); } WearNTear component3 = prefab.GetComponent<WearNTear>(); WearNTear component4 = post.GetComponent<WearNTear>(); if ((Object)(object)component3 != (Object)null) { component3.m_materialType = (MaterialType)0; if ((Object)(object)component4 != (Object)null) { component3.m_hitEffect = component4.m_hitEffect; component3.m_destroyedEffect = component4.m_destroyedEffect; } } prefab.GetComponent<Piece>().m_placeEffect = post.GetComponent<Piece>().m_placeEffect; return true; } private static void ShortenChain(Transform meshObject) { //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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) MeshFilter component = ((Component)meshObject).GetComponent<MeshFilter>(); Mesh val = (Object.op_Implicit((Object)(object)component) ? component.sharedMesh : null); if ((Object)(object)val == (Object)null || !val.isReadable) { QuanPiecesPlugin.Log.LogWarning((object)"Brazier street light: the brazier mesh can't be read; keeping its full chain."); return; } Vector3[] vertices = val.vertices; int[] parent = Enumerable.Range(0, vertices.Length).ToArray(); Dictionary<Vector3Int, int> dictionary = new Dictionary<Vector3Int, int>(); for (int i = 0; i < vertices.Length; i++) { Vector3Int key = Vector3Int.RoundToInt(vertices[i] * 10000f); if (dictionary.TryGetValue(key, out var value)) { Join(i, value); } else { dictionary[key] = i; } } List<int[]> list = Enumerable.Range(0, val.subMeshCount).Select((Func<int, int[]>)val.GetTriangles).ToList(); foreach (int[] item in list) { for (int j = 0; j < item.Length; j += 3) { Join(item[j], item[j + 1]); Join(item[j], item[j + 2]); } } Dictionary<int, Bounds> dictionary2 = new Dictionary<int, Bounds>(); for (int k = 0; k < vertices.Length; k++) { int key2 = Root(k); if (dictionary2.TryGetValue(key2, out var value2)) { ((Bounds)(ref value2)).Encapsulate(vertices[k]); dictionary2[key2] = value2; } else { dictionary2[key2] = new Bounds(vertices[k], Vector3.zero); } } HashSet<int> hashSet = new HashSet<int>(from island in dictionary2.Where(delegate(KeyValuePair<int, Bounds> island) { //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_000a: 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_0025: 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) //IL_0042: 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) Bounds value3 = island.Value; if (((Bounds)(ref value3)).min.y > -0.7f) { value3 = island.Value; if (Mathf.Abs(((Bounds)(ref value3)).center.x) < 0.02f) { value3 = island.Value; return Mathf.Abs(((Bounds)(ref value3)).center.z) < 0.02f; } } return false; }) select island.Key); Mesh val2 = Object.Instantiate<Mesh>(val); ((Object)val2).name = ((Object)val).name + "_quan_shortchain"; for (int num = 0; num < list.Count; num++) { List<int> list2 = new List<int>(list[num].Length); int[] array = list[num]; for (int num2 = 0; num2 < array.Length; num2 += 3) { if (!hashSet.Contains(Root(array[num2]))) { list2.Add(array[num2]); list2.Add(array[num2 + 1]); list2.Add(array[num2 + 2]); } } val2.SetTriangles(list2, num); } val2.RecalculateBounds(); component.sharedMesh = val2; QuanPiecesPlugin.Log.LogDebug((object)$"Brazier street light: removed {hashSet.Count} chain links from the brazier mesh."); void Join(int a, int b) { parent[Root(a)] = Root(b); } int Root(int num3) { while (parent[num3] != num3) { parent[num3] = parent[parent[num3]]; num3 = parent[num3]; } return num3; } } private static List<Renderer> BuildFrame(Transform parent, Transform postVisual, Transform beamVisual) { //IL_0015: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004c: 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_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_0101: 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_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010e: 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_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0129: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: 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_020d: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) List<Renderer> list = new List<Renderer>(); Quaternion rotation = Quaternion.Euler(0f, 0f, 90f); float num = 0.2f; AddPart(parent, "post_lower", postVisual, new Vector3(0f, 1f, 0f), rotation, new Vector3(2f, 0.4f, 0.4f), list); AddPart(parent, "post_upper", postVisual, new Vector3(0f, 3f, 0f), rotation, new Vector3(2f, 0.4f, 0.4f), list); AddPart(parent, "arm", beamVisual, new Vector3(1f, 4f, 0f), Quaternion.identity, new Vector3(2f, 0.4f, 0.4f), list); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(0f, 3f); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(1f, 4f); Vector2 val3 = val2 - val; float num2 = 0.3f; AddPart(parent, "brace", postVisual, Vector2.op_Implicit((val + val2) / 2f), Quaternion.Euler(0f, 0f, Mathf.Atan2(val3.y, val3.x) * 57.29578f), new Vector3(((Vector2)(ref val3)).magnitude, num2, num2), list); float num3 = num - 0.3f + num; float num4 = 0.396f; AddPart(parent, "foot_east", postVisual, new Vector3(num3, 1f, 0f), rotation, new Vector3(2f, 0.4f, num4), list); AddPart(parent, "foot_west", postVisual, new Vector3(0f - num3, 1f, 0f), rotation, new Vector3(2f, 0.4f, num4), list); AddPart(parent, "foot_north", postVisual, new Vector3(0f, 1f, num3), rotation, new Vector3(2f, num4, 0.4f), list); AddPart(parent, "foot_south", postVisual, new Vector3(0f, 1f, 0f - num3), rotation, new Vector3(2f, num4, 0.4f), list); return list; } private static void AddFrameColliders(Transform parent) { //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_0034: 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_0064: 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_00ac: Unknown result type (might be due to invalid IL or missing references) float num = 0.6f; AddCollider(parent, "collider_post", new Vector3(0f, 2f, 0f), Quaternion.identity, new Vector3(0.4f, 4f, 0.4f)); AddCollider(parent, "collider_foot", new Vector3(0f, 1f, 0f), Quaternion.identity, new Vector3(num, 2f, num)); float num2 = -0.2f; AddCollider(parent, "collider_arm", new Vector3((num2 + 2f) / 2f, 4f, 0f), Quaternion.identity, new Vector3(2f - num2, 0.4f, 0.4f)); } private static void AddPart(Transform parent, string name, Transform visual, Vector3 position, Quaternion rotation, Vector3 scale, List<Renderer> renderers) { //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_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_002c: 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_0039: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = position; val.transform.localRotation = rotation; val.transform.localScale = scale; val.AddComponent<MeshFilter>().sharedMesh = ((Component)visual).GetComponent<MeshFilter>().sharedMesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); ((Renderer)val2).sharedMaterials = ((Renderer)((Component)visual).GetComponent<MeshRenderer>()).sharedMaterials; renderers.Add((Renderer)(object)val2); } private static void AddCollider(Transform parent, string name, Vector3 position, Quaternion rotation, Vector3 size) { //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_0017: 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_002a: 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_0036: 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) GameObject val = new GameObject(name) { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); val.transform.localPosition = position; val.transform.localRotation = rotation; val.AddComponent<BoxCollider>().size = size; } private static void IncludeInLods(GameObject prefab, List<Renderer> frame) { LODGroup component = prefab.GetComponent<LODGroup>(); if ((Object)(object)component == (Object)null) { return; } LOD[] lODs = component.GetLODs(); for (int i = 0; i < lODs.Length; i++) { lODs[i].renderers = lODs[i].renderers.Where((Renderer r) => (Object)(object)r != (Object)null).Concat(frame).ToArray(); } component.SetLODs(lODs); component.RecalculateBounds(); } private static void CopyPlacementRules(Piece piece, Piece post) { piece.m_groundPiece = post.m_groundPiece; piece.m_allowAltGroundPlacement = post.m_allowAltGroundPlacement; piece.m_groundOnly = post.m_groundOnly; piece.m_noInWater = post.m_noInWater; piece.m_notOnWood = post.m_notOnWood; piece.m_notOnTiltingSurface = post.m_notOnTiltingSurface; piece.m_inCeilingOnly = post.m_inCeilingOnly; piece.m_notOnFloor = post.m_notOnFloor; piece.m_noClipping = post.m_noClipping; piece.m_clipGround = post.m_clipGround; piece.m_clipEverything = post.m_clipEverything; piece.m_mustBeAboveConnected = post.m_mustBeAboveConnected; } private static Transform FindVisual(GameObject piece) { return (from f in piece.GetComponentsInChildren<MeshFilter>(true) select ((Component)f).transform).FirstOrDefault((Func<Transform, bool>)((Transform t) => (((Object)t).name == "New" || ((Object)t).name == "new") && (Object)(object)((Component)t).GetComponent<MeshRenderer>() != (Object)null)); } } internal static class ChimneyFlue { private const string PrefabName = "Quan_chimney_flue"; private const string BasePrefab = "iron_floor_2x2"; private const string StoneSource = "stone_floor_2x2"; private const string PieceShader = "Custom/Piece"; private const float HalfTile = 1f; private const float StripWidth = 0.1f; private const float StripHeight = 0.1f; private const float FrameWidth = 0.08f; private const float FrameTop = 0.12f; private const int SlatCount = 6; private const float SlatAngle = 40f; private const float SlatChord = 0.28f; private const float SlatThickness = 0.04f; private static readonly Rect StoneEdgeBlocks = new Rect(0.01f, 0.01f, 0.98f, 0.11f); private static readonly Rect StoneTile = new Rect(0.01f, 0.145f, 0.24f, 0.24f); public static void Register() { //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_0106: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = PrefabManager.Instance.GetPrefab("iron_floor_2x2"); if ((Object)(object)(Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Piece>() : null) == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)"Base prefab 'iron_floor_2x2' not found or has no Piece component; chimney flue skipped."); return; } GameObject prefab2 = PrefabManager.Instance.GetPrefab("stone_floor_2x2"); Material val = FindPieceMaterial(prefab2); if ((Object)(object)val == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)"No 'Custom/Piece' material found on 'stone_floor_2x2'; chimney flue keeps the iron look."); } PieceConfig val2 = new PieceConfig(); val2.Name = "Quan's Chimney Flue"; val2.Description = "Blocks rain but not smoke. Must be 1.5m or more above a fireplace. For Valyyn."; val2.PieceTable = PieceTables.Hammer; val2.Category = "QuanPieces"; val2.CraftingStation = CraftingStations.Workbench; val2.Requirements = (RequirementConfig[])(object)new RequirementConfig[1] { new RequirementConfig("Stone", 5, 0, true) }; PieceConfig val3 = val2; CustomPiece val4 = new CustomPiece("Quan_chimney_flue", "iron_floor_2x2", val3); if (Reshape(val4.PiecePrefab, val)) { UseStoneEffects(val4.PiecePrefab, prefab2); Sprite val5 = RenderManager.Instance.Render(val4.PiecePrefab, RenderManager.IsometricRotation); if ((Object)(object)val5 != (Object)null) { val4.Piece.m_icon = val5; } else { QuanPiecesPlugin.Log.LogWarning((object)"Chimney flue: icon render failed; using the iron cage floor's icon."); } PieceManager.Instance.AddPiece(val4); } } private static bool Reshape(GameObject prefab, Material stoneMaterial) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) BoxCollider component = prefab.GetComponent<BoxCollider>(); if ((Object)(object)component == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)"'iron_floor_2x2' has no root BoxCollider any more; chimney flue skipped."); return false; } ((Collider)component).isTrigger = true; prefab.tag = "Untagged"; AddSupportStrips(prefab, component); if (!ReplaceVisual(prefab, stoneMaterial)) { return false; } WearNTear component2 = prefab.GetComponent<WearNTear>(); if ((Object)(object)component2 != (Object)null) { component2.m_materialType = (MaterialType)0; } return true; } private static void UseStoneEffects(GameObject prefab, GameObject stonePrefab) { Piece val = (Object.op_Implicit((Object)(object)stonePrefab) ? stonePrefab.GetComponent<Piece>() : null); WearNTear val2 = (Object.op_Implicit((Object)(object)stonePrefab) ? stonePrefab.GetComponent<WearNTear>() : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)"'stone_floor_2x2' has no Piece or WearNTear; chimney flue keeps the iron sounds."); return; } prefab.GetComponent<Piece>().m_placeEffect = val.m_placeEffect; WearNTear component = prefab.GetComponent<WearNTear>(); if ((Object)(object)component != (Object)null) { component.m_hitEffect = val2.m_hitEffect; component.m_destroyedEffect = val2.m_destroyedEffect; component.m_switchEffect = val2.m_switchEffect; } } private static void AddSupportStrips(GameObject prefab, BoxCollider roof) { //IL_001e: 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_004b: 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_0077: 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_00a4: 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) float num = 0.95f; float num2 = 2f; AddStrip(prefab, roof, "support_north", new Vector3(0f, 0f, num), new Vector3(num2, 0.1f, 0.1f)); AddStrip(prefab, roof, "support_south", new Vector3(0f, 0f, 0f - num), new Vector3(num2, 0.1f, 0.1f)); AddStrip(prefab, roof, "support_east", new Vector3(num, 0f, 0f), new Vector3(0.1f, 0.1f, num2)); AddStrip(prefab, roof, "support_west", new Vector3(0f - num, 0f, 0f), new Vector3(0.1f, 0.1f, num2)); } private static void AddStrip(GameObject prefab, BoxCollider roof, string name, Vector3 position, Vector3 size) { //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_0012: 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_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_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) GameObject val = new GameObject(name) { layer = prefab.layer }; val.transform.SetParent(prefab.transform, false); val.transform.localPosition = roof.center + position; val.AddComponent<BoxCollider>().size = size; } private static bool ReplaceVisual(GameObject prefab, Material stoneMaterial) { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019b: Unknown result type (might be due to invalid IL or missing references) WearNTear component = prefab.GetComponent<WearNTear>(); Transform val = prefab.transform.Find("New"); if ((Object)(object)component == (Object)null || (Object)(object)val == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)"Chimney flue: couldn't find WearNTear or the 'New' visual; chimney flue skipped."); return false; } Material val2 = stoneMaterial; if ((Object)(object)val2 == (Object)null) { MeshRenderer componentInChildren = ((Component)val).GetComponentInChildren<MeshRenderer>(true); val2 = (Object.op_Implicit((Object)(object)componentInChildren) ? ((Renderer)componentInChildren).sharedMaterial : null); } Material material = WithoutRipple(val2); string[] array = new string[3] { "Worn", "Broken", "Destruction" }; foreach (string text in array) { Transform val3 = prefab.transform.Find(text); if ((Object)(object)val3 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val3).gameObject); } } component.m_fragmentRoots = null; List<GameObject> list = new List<GameObject>(); foreach (Transform item in val) { Transform val4 = item; list.Add(((Component)val4).gameObject); } list.ForEach((Action<GameObject>)Object.DestroyImmediate); List<Renderer> list2 = BuildFrameAndLouvres(val, material); LODGroup component2 = prefab.GetComponent<LODGroup>(); if ((Object)(object)component2 != (Object)null) { LOD[] lODs = component2.GetLODs(); float num = ((lODs.Length != 0) ? lODs[^1].screenRelativeTransitionHeight : 0.02f); component2.SetLODs((LOD[])(object)new LOD[1] { new LOD(num, list2.ToArray()) }); component2.RecalculateBounds(); } component.m_new = ((Component)val).gameObject; component.m_worn = ((Component)val).gameObject; component.m_broken = ((Component)val).gameObject; return true; } private static List<Renderer> BuildFrameAndLouvres(Transform parent, Material material) { //IL_005c: 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_0066: 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_009a: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_010a: 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_0157: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Unknown result type (might be due to invalid IL or missing references) List<Renderer> list = new List<Renderer>(); float num = 2f; float num2 = num - 0.16f; float num3 = 0.96f; float num4 = 0.12f; float num5 = 0.6981317f; float num6 = 0.28f * Mathf.Sin(num5) + 0.04f * Mathf.Cos(num5); float num7 = num4 - num6; Mesh mesh = BoxMesh.Create("quan_flue_side_plate", new Vector3(0.08f, num4 - num7, num), StoneEdgeBlocks, StoneTile); float num8 = (num4 + num7) / 2f; AddPart(parent, "frame_east", mesh, material, new Vector3(num3, num8, 0f), Quaternion.identity, list); AddPart(parent, "frame_west", mesh, material, new Vector3(0f - num3, num8, 0f), Quaternion.identity, list); Mesh mesh2 = BoxMesh.Create("quan_flue_slat", new Vector3(num2, 0.04f, 0.28f), StoneEdgeBlocks, StoneTile); float num9 = num / 6f; Quaternion rotation = Quaternion.Euler(40f, 0f, 0f); float num10 = num4 - num6 / 2f; for (int i = 0; i < 6; i++) { float num11 = -1f + num9 * ((float)i + 0.5f); AddPart(parent, $"louvre_{i + 1}", mesh2, material, new Vector3(0f, num10, num11), rotation, list); } return list; } private static void AddPart(Transform parent, string name, Mesh mesh, Material material, Vector3 position, Quaternion rotation, List<Renderer> renderers) { //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_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_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_002d: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.transform.localPosition = position; val.transform.localRotation = rotation; val.AddComponent<MeshFilter>().sharedMesh = mesh; MeshRenderer val2 = val.AddComponent<MeshRenderer>(); ((Renderer)val2).sharedMaterial = material; renderers.Add((Renderer)(object)val2); } private static Material WithoutRipple(Material material) { //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_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown if ((Object)(object)material == (Object)null || !material.HasProperty("_RippleDistance")) { return material; } Material val = new Material(material) { name = ((Object)material).name + "_quan_noripple" }; val.SetFloat("_RippleDistance", 0f); return val; } private static Material FindPieceMaterial(GameObject source) { if ((Object)(object)source == (Object)null) { return null; } return (from r in source.GetComponentsInChildren<MeshRenderer>(true) select ((Renderer)r).sharedMaterial).FirstOrDefault((Func<Material, bool>)((Material m) => (Object)(object)m != (Object)null && ((Object)m.shader).name == "Custom/Piece")); } } public class LanternGlass : MonoBehaviour { public GameObject m_litWhileActive; public MeshRenderer m_renderer; public Material m_lit; public Material m_unlit; private bool m_known; private bool m_wasLit; private void Update() { if (!((Object)(object)m_litWhileActive == (Object)null) && !((Object)(object)m_renderer == (Object)null)) { bool activeInHierarchy = m_litWhileActive.activeInHierarchy; if (!m_known || activeInHierarchy != m_wasLit) { m_known = true; m_wasLit = activeInHierarchy; ((Renderer)m_renderer).sharedMaterial = (activeInHierarchy ? m_lit : m_unlit); } } } } internal static class LanternStreetlight { private const string PrefabName = "Quan_streetlight_lantern"; private const string BasePrefab = "piece_brazierceiling01"; private const string LanternPrefab = "piece_dvergr_lantern_pole"; private const string TaperedPrefab = "Piece_grausten_pillarbase_tapered"; private const string GraustenPrefab = "Piece_grausten_pillarbase_small"; private const string AshPolePrefab = "ashwood_pole_2m"; private const string ArchPrefab = "ashwood_arch_big"; private const string FuelItem = "Wisp"; private const float TaperedHeight = 2f; private const float TaperedJoin = 1.986f; private const float GraustenTilesPerMetre = 0.27f; private const float NotchHalfAngle = 15f; private const float AshDarkBandStart = 0.5f; private const float AshDarkBandWidth = 0.45f; private const float AshGrainPerMetre = 0.5f; private const float GraustenHalf = 0.25f; private const float BeamY = 4f; private const float PostTop = 4.25f; private const float BeamEnd = 1.95f; private const float AshPostHeight = 4f; private const float AshBeamStart = -0.2f; private const float AshBeamEnd = 2f; private const float ArchScale = 0.9f; private const float ArchDepthScale = 0.75f; private const float ArchPostCentreX = -0.0085f; private const float ArchBeamCentreY = 2.009f; private const float LanternScale = 2f; private const float LanternInset = 0.03f; private const float PanelHalfWidth = 0.104f; private const float EndBevel = 0.023f; private const float LanternSetback = 0.127f; private const float WarmthRadius = 50f; private const float LightRange = 60f; private const float LightIntensity = 1.5f; private const float LightSwitchOffDistance = 80f; public static void Register() { //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Expected O, but got Unknown //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Expected O, but got Unknown //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: 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_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Expected O, but got Unknown //IL_01f1: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Expected O, but got Unknown //IL_021c: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = PrefabManager.Instance.GetPrefab("piece_brazierceiling01"); GameObject prefab2 = PrefabManager.Instance.GetPrefab("piece_dvergr_lantern_pole"); Piece val = (Object.op_Implicit((Object)(object)prefab2) ? prefab2.GetComponent<Piece>() : null); GameObject prefab3 = PrefabManager.Instance.GetPrefab("Wisp"); Dictionary<string, GameObject> dictionary = new string[4] { "Piece_grausten_pillarbase_tapered", "Piece_grausten_pillarbase_small", "ashwood_pole_2m", "ashwood_arch_big" }.ToDictionary((string n) => n, (string n) => PrefabManager.Instance.GetPrefab(n)); if ((Object)(object)prefab == (Object)null || (Object)(object)val == (Object)null || (Object)(object)prefab3 == (Object)null || dictionary.Values.Any((GameObject p) => (Object)(object)p == (Object)null)) { QuanPiecesPlugin.Log.LogWarning((object)"Lantern street light: a vanilla prefab it's built from wasn't found; skipped."); return; } RequirementConfig[] requirements = val.m_resources.Where((Requirement r) => r != null && (Object)(object)r.m_resItem != (Object)null).Select((Func<Requirement, RequirementConfig>)((Requirement r) => new RequirementConfig(((Object)r.m_resItem).name, r.m_amount, r.m_amountPerLevel, r.m_recover))).Concat((IEnumerable<RequirementConfig>)(object)new RequirementConfig[2] { new RequirementConfig("Grausten", 6, 0, true), new RequirementConfig("Blackwood", 4, 0, true) }) .ToArray(); PieceConfig val2 = new PieceConfig { Name = "Quan's Dvergr Street Light", Description = "A Dvergr lantern hung from a Grausten and Ashwood post. Burns wisps, and shrugs off any weather.", PieceTable = PieceTables.Hammer, Category = "QuanPieces", CraftingStation = (Object.op_Implicit((Object)(object)val.m_craftingStation) ? ((Object)val.m_craftingStation).name : string.Empty), Requirements = requirements }; CustomPiece val3 = new CustomPiece("Quan_streetlight_lantern", "piece_brazierceiling01", val2); if (Build(val3.PiecePrefab, prefab2, prefab3.GetComponent<ItemDrop>(), dictionary)) { Sprite val4 = RenderManager.Instance.Render(val3.PiecePrefab, RenderManager.IsometricRotation); if ((Object)(object)val4 != (Object)null) { val3.Piece.m_icon = val4; } else { QuanPiecesPlugin.Log.LogWarning((object)"Lantern street light: icon render failed; using the hanging brazier's icon."); } PieceManager.Instance.AddPiece(val3); } } private static bool Build(GameObject prefab, GameObject lanternPrefab, ItemDrop fuel, Dictionary<string, GameObject> sources) { //IL_0104: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) Fireplace component = prefab.GetComponent<Fireplace>(); Transform val = prefab.transform.Find("_enabled"); if ((Object)(object)component == (Object)null || (Object)(object)val == (Object)null || (Object)(object)fuel == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)"Lantern street light: the brazier's Fireplace or its '_enabled' object wasn't found; skipped."); return false; } Material material; MeshData meshData = Source(sources["Piece_grausten_pillarbase_tapered"], "new/default_high", out material); Material material2; MeshData meshData2 = Source(sources["Piece_grausten_pillarbase_small"], "new/default_high", out material2); Material material3; MeshData meshData3 = Source(sources["ashwood_pole_2m"], "New/default", out material3); Material material4; MeshData meshData4 = Source(lanternPrefab, "New/default", out material4); if (meshData == null || meshData2 == null || meshData3 == null || meshData4 == null) { QuanPiecesPlugin.Log.LogWarning((object)"Lantern street light: a source mesh is missing or unreadable; skipped."); return false; } StripBrazier(prefab, val, component, fuel); MeshData notches; List<Renderer> list = new List<Renderer> { (Renderer)(object)AddMesh(prefab.transform, "frame_grausten", BuildGrausten(meshData, meshData2, out notches), Triplanar(material2)), (Renderer)(object)AddMesh(prefab.transform, "frame_ashwood", BuildAshwood(meshData3).Append(notches, Matrix4x4.identity), material3) }; AddArch(prefab.transform, sources["ashwood_arch_big"]); Bounds lanternBounds; MeshRenderer val2 = AddLantern(prefab, val, lanternPrefab, meshData4, material4, out lanternBounds); if ((Object)(object)val2 == (Object)null) { return false; } list.Add((Renderer)(object)val2); AddWarmth(val, ((Bounds)(ref lanternBounds)).center); AddFrameColliders(prefab.transform, lanternBounds); SetLods(prefab, list); Piece component2 = prefab.GetComponent<Piece>(); Piece component3 = sources["Piece_grausten_pillarbase_tapered"].GetComponent<Piece>(); CopyPlacementRules(component2, component3); component2.m_placeEffect = component3.m_placeEffect; WearNTear component4 = prefab.GetComponent<WearNTear>(); WearNTear component5 = sources["Piece_grausten_pillarbase_tapered"].GetComponent<WearNTear>(); if ((Object)(object)component4 != (Object)null) { component4.m_materialType = (MaterialType)0; component4.m_new = null; component4.m_worn = null; component4.m_broken = null; component4.m_fragmentRoots = null; if ((Object)(object)component5 != (Object)null) { component4.m_hitEffect = component5.m_hitEffect; component4.m_destroyedEffect = component5.m_destroyedEffect; } } return true; } private static void StripBrazier(GameObject prefab, Transform lit, Fireplace fireplace, ItemDrop fuel) { //IL_009d: Unknown result type (might be due to invalid IL or missing references) foreach (Transform item in ((IEnumerable)prefab.transform).Cast<Transform>().ToList()) { if ((Object)(object)item != (Object)(object)lit && ((Object)item).name != "PlayerBase") { Object.DestroyImmediate((Object)(object)((Component)item).gameObject); } } foreach (Transform item2 in ((IEnumerable)lit).Cast<Transform>().ToList()) { Object.DestroyImmediate((Object)(object)((Component)item2).gameObject); } lit.localPosition = Vector3.zero; fireplace.m_enabledObjectHigh = null; fireplace.m_enabledObjectLow = null; fireplace.m_disableCoverCheck = true; fireplace.m_smokeSpawner = null; fireplace.m_fuelItem = fuel; } private static MeshData BuildGrausten(MeshData tapered, MeshData pillar, out MeshData notches) { //IL_0028: 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_0046: 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_008e: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) MeshData meshData = new MeshData().Append(pillar.ResizeAlongY(2.264f, repeat: true, keepStartCap: false, keepEndCap: true, mirrorAlternate: true), Matrix4x4.Translate(new Vector3(0f, 1.986f, 0f))).Clip(new Vector3(1f, 1f, 0f), 4f); MeshData meshData2 = WeldEdge(tapered.Clip(Vector3.up, 1.986f), meshData, 1.986f); meshData = WeldEdge(meshData, meshData2, 1.986f); Matrix4x4 transform = Matrix4x4.TRS(new Vector3(1.95f, 4f, 0f), Quaternion.Euler(0f, 0f, 90f), Vector3.one); MeshData other = new MeshData().Append(pillar.ResizeAlongY(2.2f, repeat: true, keepStartCap: true, keepEndCap: true, mirrorAlternate: true), transform).Clip(new Vector3(-1f, -1f, 0f), -4f); notches = Notches(meshData2, inNotch: true); return new MeshData().Append(Notches(meshData2, inNotch: false), Matrix4x4.identity).Append(meshData, Matrix4x4.identity).Append(other, Matrix4x4.identity); } private static MeshData WeldEdge(MeshData moving, MeshData target, float y) { //IL_004b: 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_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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_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_008e: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_013b: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: 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_0184: 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_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01a6: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: 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_025f: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0285: 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_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0219: 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_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_0236: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) List<int> list = new List<int>(); Vector3 val; for (int i = 0; i < target.Triangles.Count; i += 3) { for (int j = 0; j < 3; j++) { int num = target.Triangles[i + j]; int num2 = target.Triangles[i + (j + 1) % 3]; if (OnEdge(target.Positions[num]) && OnEdge(target.Positions[num2])) { val = target.Positions[num] - target.Positions[num2]; if (((Vector3)(ref val)).sqrMagnitude > 1E-08f) { list.Add(num); list.Add(num2); } } } } if (list.Count == 0) { QuanPiecesPlugin.Log.LogWarning((object)"Lantern street light: no edge found to weld the tapered pillar to."); return moving; } int num3 = 0; for (int k = 0; k < moving.Positions.Count; k++) { Vector3 val2 = moving.Positions[k]; if (!OnEdge(val2)) { continue; } Vector3 val3 = Flat(moving.Normals[k]); float num4 = 0.0001f; bool flag = false; Vector3 val4 = val2; Vector3 value = moving.Normals[k]; for (int l = 0; l < list.Count; l += 2) { int index = list[l]; int index2 = list[l + 1]; Vector3 val5 = Flat(target.Normals[index] + target.Normals[index2]); if (!(Vector3.Dot(val3, val5) < 0.8f)) { Vector3 val6 = target.Positions[index]; Vector3 val7 = target.Positions[index2] - val6; float num5 = Mathf.Clamp01(Vector3.Dot(val2 - val6, val7) / ((Vector3)(ref val7)).sqrMagnitude); Vector3 val8 = val6 + val7 * num5; val = val8 - val2; float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude; if (sqrMagnitude < num4) { num4 = sqrMagnitude; val4 = val8; val = Vector3.Lerp(target.Normals[index], target.Normals[index2], num5); value = ((Vector3)(ref val)).normalized; flag = true; } } } if (flag) { moving.Positions[k] = new Vector3(val4.x, y, val4.z); moving.Normals[k] = value; num3++; } } QuanPiecesPlugin.Log.LogDebug((object)$"Lantern street light: welded {num3} edge vertices at {y} m."); return moving; static Vector3 Flat(Vector3 v) { //IL_0000: 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) //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) Vector3 val9 = new Vector3(v.x, 0f, v.z); return ((Vector3)(ref val9)).normalized; } bool OnEdge(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) return Mathf.Abs(p.y - y) < 0.0005f; } } private static MeshData Notches(MeshData pillar, bool inNotch) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01aa: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_024e: Unknown result type (might be due to invalid IL or missing references) //IL_0255: 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_02ae: Unknown result type (might be due to invalid IL or missing references) int[] faces = pillar.FlatFaces(); Dictionary<int, Vector3> dictionary = new Dictionary<int, Vector3>(); Dictionary<int, float> dictionary2 = new Dictionary<int, float>(); Dictionary<int, bool> dictionary3 = new Dictionary<int, bool>(); for (int i = 0; i < faces.Length; i++) { Vector3 val = pillar.Positions[pillar.Triangles[3 * i]]; Vector3 val2 = pillar.Positions[pillar.Triangles[3 * i + 1]]; Vector3 val3 = pillar.Positions[pillar.Triangles[3 * i + 2]]; Vector3 val4 = Vector3.Cross(val2 - val, val3 - val); float num = ((Vector3)(ref val4)).magnitude * 0.5f; int key = faces[i]; dictionary[key] = (dictionary.TryGetValue(key, out var value) ? value : Vector3.zero) + (val + val2 + val3) / 3f * num; dictionary2[key] = (dictionary2.TryGetValue(key, out var value2) ? value2 : 0f) + num; dictionary3[key] = Mathf.Abs(((Vector3)(ref val4)).normalized.y) <= 0.7f; } HashSet<int> notchFaces = new HashSet<int>(); foreach (int key2 in dictionary2.Keys) { if (dictionary3[key2] && !(dictionary2[key2] <= 0f)) { Vector3 val5 = dictionary[key2] / dictionary2[key2]; if (Mathf.Abs(Mathf.Repeat(Mathf.Atan2(val5.z, val5.x) * 57.29578f, 90f) - 45f) <= 15f) { notchFaces.Add(key2); } } } int triangle = 0; MeshData meshData = pillar.Where((Vector3[] p, Vector3[] n) => notchFaces.Contains(faces[triangle++]) == inNotch); if (!inNotch) { return meshData; } for (int num2 = 0; num2 < meshData.Positions.Count; num2++) { Vector3 val6 = meshData.Positions[num2]; float num3 = Mathf.Clamp01((Mathf.Repeat(Mathf.Atan2(val6.z, val6.x) * 57.29578f, 90f) - 45f + 15f) / 30f); meshData.Uvs[num2] = new Vector2(0.5f + num3 * 0.45f, val6.y * 0.5f); } return meshData; } private static Material Triplanar(Material material) { //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_001c: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown Material val = new Material(material) { name = ((Object)material).name + "_quan_triplanar" }; val.SetFloat("_TriplanarMap", 1f); val.SetFloat("_TriplanarScale", 0.27f); val.SetFloat("_TriplanarLocalPos", 1f); return val; } private static MeshData BuildAshwood(MeshData pole) { //IL_0030: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) MeshData other = pole.ResizeAlongY(4f, repeat: false, keepStartCap: true, keepEndCap: true); MeshData other2 = pole.ResizeAlongY(2.2f, repeat: false, keepStartCap: true, keepEndCap: true); return new MeshData().Append(other, Matrix4x4.identity).Append(other2, Matrix4x4.TRS(new Vector3(-0.2f, 4f, 0f), Quaternion.Euler(0f, 0f, -90f), Vector3.one)); } private static void AddArch(Transform parent, GameObject archPrefab) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) Transform val = archPrefab.transform.Find("New"); if ((Object)(object)val == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)"Lantern street light: the Ashwood Arch's visual wasn't found; built without it."); return; } Transform transform = new GameObject("arch").transform; transform.SetParent(parent, false); transform.localPosition = new Vector3(0.00765f, 2.1919f, 0f); transform.localScale = new Vector3(0.9f, 0.9f, 0.75f); ((Object)Object.Instantiate<GameObject>(((Component)val).gameObject, transform, false)).name = "New"; } private static MeshRenderer AddLantern(GameObject prefab, Transform lit, GameObject lanternPrefab, MeshData source, Material litMaterial, out Bounds lanternBounds) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_010e: 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_0125: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: 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_013f: 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_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_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_0190: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01ac: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Expected O, but got Unknown //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_023e: 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) lanternBounds = default(Bounds); List<Bounds> kept; MeshData meshData = source.KeepIslands((Bounds b) => ((Bounds)(ref b)).min.z >= 0.27f && ((Bounds)(ref b)).min.y >= 1.1f, out kept); if (kept.Count == 0) { QuanPiecesPlugin.Log.LogWarning((object)"Lantern street light: couldn't find the lantern in the Dvergr pole lantern's mesh; skipped."); return null; } Bounds val = kept.OrderByDescending((Bounds b) => ((Bounds)(ref b)).max.y).First(); Bounds val2 = kept.Where((Bounds b) => ((Bounds)(ref b)).max.y < 1.46f).Aggregate(delegate(Bounds a, Bounds b) { //IL_0002: 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) ((Bounds)(ref a)).Encapsulate(b); return a; }); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(1.8230001f, 3.78f, 0f); Vector3 val4 = new Vector3(((Bounds)(ref val)).center.x, ((Bounds)(ref val)).max.y, ((Bounds)(ref val)).center.z) * 2f; GameObject val5 = new GameObject("lantern"); val5.transform.SetParent(prefab.transform, false); val5.transform.localPosition = val3 - val4; val5.transform.localScale = Vector3.one * 2f; val5.AddComponent<MeshFilter>().sharedMesh = meshData.ToMesh("quan_streetlight_lantern"); MeshRenderer val6 = val5.AddComponent<MeshRenderer>(); ((Renderer)val6).sharedMaterial = litMaterial; Vector3 val7 = val5.transform.localPosition + ((Bounds)(ref val2)).center * 2f; lanternBounds = new Bounds(val7, ((Bounds)(ref val2)).size * 2f); string[] array = new string[2] { "Point Light", "flare" }; foreach (string text in array) { Transform val8 = lanternPrefab.transform.Find("New/" + text); if ((Object)(object)val8 == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)("Lantern street light: the Dvergr lantern's '" + text + "' wasn't found.")); continue; } GameObject obj = Object.Instantiate<GameObject>(((Component)val8).gameObject, lit, false); ((Object)obj).name = text; obj.transform.localPosition = val7; obj.transform.localRotation = Quaternion.identity; Light component = obj.GetComponent<Light>(); if ((Object)(object)component != (Object)null) { component.range = 60f; component.intensity = 1.5f; } LightLod component2 = obj.GetComponent<LightLod>(); if ((Object)(object)component2 != (Object)null) { component2.m_lightDistance = 80f; } } Material val9 = new Material(litMaterial) { name = ((Object)litMaterial).name + "_quan_off" }; val9.DisableKeyword("_EMISSION"); val9.SetColor("_EmissionColor", Color.black); LanternGlass lanternGlass = prefab.AddComponent<LanternGlass>(); lanternGlass.m_litWhileActive = ((Component)lit).gameObject; lanternGlass.m_renderer = val6; lanternGlass.m_lit = litMaterial; lanternGlass.m_unlit = val9; return val6; } private static void AddWarmth(Transform lit, Vector3 centre) { //IL_0056: 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) Transform val = PrefabManager.Instance.GetPrefab("piece_brazierceiling01").transform.Find("_enabled_high/FireWarmth"); if ((Object)(object)val == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)"Lantern street light: the hanging brazier's warmth area wasn't found; built without warmth."); return; } GameObject obj = Object.Instantiate<GameObject>(((Component)val).gameObject, lit, false); ((Object)obj).name = "FireWarmth"; obj.transform.localPosition = centre; obj.transform.localScale = Vector3.one; SphereCollider component = obj.GetComponent<SphereCollider>(); if ((Object)(object)component != (Object)null) { component.radius = 50f; } } private static void AddFrameColliders(Transform parent, Bounds lantern) { //IL_001b: 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_004e: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) float num = 0.5f; AddCollider(parent, "collider_base", new Vector3(0f, 1f, 0f), new Vector3(0.8f, 2f, 0.8f)); AddCollider(parent, "collider_post", new Vector3(0f, 3.125f, 0f), new Vector3(num, 2.25f, num)); AddCollider(parent, "collider_beam", new Vector3(0.85f, 4f, 0f), new Vector3(2.2f, num, num)); AddCollider(parent, "collider_lantern", ((Bounds)(ref lantern)).center, ((Bounds)(ref lantern)).size); } private static void AddCollider(Transform parent, string name, Vector3 centre, Vector3 size) { //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_0017: 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_002a: 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) GameObject val = new GameObject(name) { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); val.transform.localPosition = centre; val.AddComponent<BoxCollider>().size = size; } private static MeshRenderer AddMesh(Transform parent, string name, MeshData data, Material material) { //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_0013: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name); val.transform.SetParent(parent, false); val.AddComponent<MeshFilter>().sharedMesh = data.ToMesh("quan_streetlight_lantern_" + name); MeshRenderer obj = val.AddComponent<MeshRenderer>(); ((Renderer)obj).sharedMaterial = material; return obj; } private static void SetLods(GameObject prefab, List<Renderer> renderers) { //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) LODGroup component = prefab.GetComponent<LODGroup>(); if (!((Object)(object)component == (Object)null)) { LOD[] lODs = component.GetLODs(); float num = ((lODs.Length != 0) ? lODs[^1].screenRelativeTransitionHeight : 0.02f); component.SetLODs((LOD[])(object)new LOD[1] { new LOD(num, renderers.ToArray()) }); component.RecalculateBounds(); } } private static void CopyPlacementRules(Piece piece, Piece from) { piece.m_groundPiece = from.m_groundPiece; piece.m_allowAltGroundPlacement = from.m_allowAltGroundPlacement; piece.m_groundOnly = from.m_groundOnly; piece.m_noInWater = from.m_noInWater; piece.m_notOnWood = from.m_notOnWood; piece.m_notOnTiltingSurface = from.m_notOnTiltingSurface; piece.m_inCeilingOnly = from.m_inCeilingOnly; piece.m_notOnFloor = from.m_notOnFloor; piece.m_noClipping = from.m_noClipping; piece.m_clipGround = from.m_clipGround; piece.m_clipEverything = from.m_clipEverything; piece.m_mustBeAboveConnected = from.m_mustBeAboveConnected; } private static MeshData Source(GameObject prefab, string path, out Material material) { material = null; Transform val = prefab.transform.Find(path); MeshFilter val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<MeshFilter>() : null); MeshRenderer val3 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<MeshRenderer>() : null); if ((Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null) { QuanPiecesPlugin.Log.LogWarning((object)("Lantern street light: '" + ((Object)prefab).name + "/" + path + "' has no mesh.")); return null; } MeshData meshData = MeshData.From(val2.sharedMesh); if (meshData == null) { QuanPiecesPlugin.Log.LogWarning((object)("Lantern street light: '" + ((Object)prefab).name + "/" + path + "' mesh is unreadable.")); } material = ((Renderer)val3).sharedMaterial; return meshData; } } } namespace QuanPieces.Meshes { internal static class BoxMesh { private static readonly Vector3[] FaceNormals = (Vector3[])(object)new Vector3[6] { Vector3.right, Vector3.left, Vector3.up, Vector3.down, Vector3.forward, Vector3.back }; public static Mesh Create(string name, Vector3 size, Rect longRegion, Rect squareRegion, float elongation = 3f) { //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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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_006e: 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_007d: 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_029f: 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_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c1: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Expected O, but got Unknown //IL_00b6: 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_00b7: 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_00bb: 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_00c3: 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_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015b: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: 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_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) Vector3 val = size / 2f; List<Vector3> list = new List<Vector3>(24); List<Vector3> list2 = new List<Vector3>(24); List<Vector2> list3 = new List<Vector2>(24); List<int> list4 = new List<int>(36); Vector3[] faceNormals = FaceNormals; Vector3 val3 = default(Vector3); foreach (Vector3 val2 in faceNormals) { ((Vector3)(ref val3))..ctor(val2.y, val2.z, val2.x); Vector3 val4 = Vector3.Cross(val2, val3); float num = Mathf.Abs(Vector3.Dot(size, val3)); float num2 = Mathf.Abs(Vector3.Dot(size, val4)); bool flag = num >= num2; Rect val5 = ((Mathf.Max(num, num2) >= elongation * Mathf.Min(num, num2)) ? longRegion : squareRegion); Vector3 val6 = Vector3.Scale(val2, val); Vector3 val7 = Vector3.Scale(val3, val); Vector3 val8 = Vector3.Scale(val4, val); Vector3[] array = (Vector3[])(object)new Vector3[4] { val6 - val7 - val8, val6 + val7 - val8, val6 + val7 + val8, val6 - val7 + val8 }; int count = list.Count; Vector3[] array2 = array; foreach (Vector3 val9 in array2) { list.Add(val9); list2.Add(val2); float num3 = Vector3.Dot(val9, val3) / num + 0.5f; float num4 = Vector3.Dot(val9, val4) / num2 + 0.5f; float num5 = (flag ? num3 : num4); float num6 = (flag ? num4 : num3); list3.Add(new Vector2(((Rect)(ref val5)).x + num5 * ((Rect)(ref val5)).width, ((Rect)(ref val5)).y + num6 * ((Rect)(ref val5)).height)); } bool flag2 = Vector3.Dot(Vector3.Cross(array[1] - array[0], array[2] - array[0]), val2) > 0f; list4.AddRange(flag2 ? new int[6] { count, count + 1, count + 2, count, count + 2, count + 3 } : new int[6] { count, count + 2, count + 1, count, count + 3, count + 2 }); } Mesh val10 = new Mesh { name = name }; val10.SetVertices(list); val10.SetNormals(list2); val10.SetUVs(0, list3); val10.SetTriangles(list4, 0); val10.RecalculateTangents(); val10.RecalculateBounds(); return val10; } } internal sealed class MeshData { private struct Corner { public Vector3 Position; public Vector3 Normal; public Vector2 Uv; public Corner(Vector3 position, Vector3 normal, Vector2 uv) { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) Position = position; Normal = normal; Uv = uv; } } public readonly List<Vector3> Positions = new List<Vector3>(); public readonly List<Vector3> Normals = new List<Vector3>(); public readonly List<Vector2> Uvs = new List<Vector2>(); public readonly List<int> Triangles = new List<int>(); public int TriangleCount => Triangles.Count / 3; public static MeshData From(Mesh mesh) { if ((Object)(object)mesh == (Object)null || !mesh.isReadable) { return null; } MeshData meshData = new MeshData(); meshData.Positions.AddRange(mesh.vertices); Vector3[] normals = mesh.normals; meshData.Normals.AddRange((IEnumerable<Vector3>)((normals.Length == meshData.Positions.Count) ? ((Array)normals) : ((Array)new Vector3[meshData.Positions.Count]))); Vector2[] uv = mesh.uv; meshData.Uvs.AddRange((IEnumerable<Vector2>)((uv.Length == meshData.Positions.Count) ? ((Array)uv) : ((Array)new Vector2[meshData.Positions.Count]))); for (int i = 0; i < mesh.subMeshCount; i++) { meshData.Triangles.AddRange(mesh.GetTriangles(i)); } return meshData; } private int AddVertex(Vector3 position, Vector3 normal, Vector2 uv) { //IL_0006: 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_001e: Unknown result type (might be due to invalid IL or missing references) Positions.Add(position); Normals.Add(normal); Uvs.Add(uv); return Positions.Count - 1; } public MeshData Append(MeshData other, Matrix4x4 transform) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_0062: Unknown result type (might be due to invalid IL or missing references) Matrix4x4 inverse = ((Matrix4x4)(ref transform)).inverse; Matrix4x4 transpose = ((Matrix4x4)(ref inverse)).transpose; int offset = Positions.Count; for (int i = 0; i < other.Positions.Count; i++) { Vector3 position = ((Matrix4x4)(ref transform)).MultiplyPoint3x4(other.Positions[i]); Vector3 val = ((Matrix4x4)(ref transpose)).MultiplyVector(other.Normals[i]); AddVertex(position, ((Vector3)(ref val)).normalized, other.Uvs[i]); } Triangles.AddRange(other.Triangles.Select((int t) => t + offset)); return this; } public Mesh ToMesh(string name) { //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_000d: Expected O, but got Unknown Mesh val = new Mesh { name = name }; if (Positions.Count > 65535) { val.indexFormat = (IndexFormat)1; } val.SetVertices(Positions); val.SetNormals(Normals); val.SetUVs(0, Uvs); val.SetTriangles(Triangles, 0); val.RecalculateTangents(); val.RecalculateBounds(); return val; } public MeshData KeepIslands(Func<Bounds, bool> keep, out List<Bounds> kept) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) int[] parent = Enumerable.Range(0, Positions.Count).ToArray(); Dictionary<Vector3Int, int> dictionary = new Dictionary<Vector3Int, int>(); for (int i = 0; i < Positions.Count; i++) { Vector3Int key = Vector3Int.RoundToInt(Positions[i] * 10000f); if (dictionary.TryGetValue(key, out var value)) { Join(i, value); } else { dictionary[key] = i; } } for (int j = 0; j < Triangles.Count; j += 3) { Join(Triangles[j], Triangles[j + 1]); Join(Triangles[j], Triangles[j + 2]); } Dictionary<int, Bounds> islands = new Dictionary<int, Bounds>(); for (int k = 0; k < Positions.Count; k++) { int key2 = Root(k); if (islands.TryGetValue(key2, out var value2)) { ((Bounds)(ref value2)).Encapsulate(Positions[k]); islands[key2] = value2; } else { islands[key2] = new Bounds(Positions[k], Vector3.zero); } } HashSet<int> hashSet = new HashSet<int>(from island in islands where keep(island.Value) select island.Key); kept = hashSet.Select((int root) => islands[root]).ToList(); MeshData meshData = new MeshData(); Dictionary<int, int> dictionary2 = new Dictionary<int, int>(); for (int num = 0; num < Triangles.Count; num += 3) { if (!hashSet.Contains(Root(Triangles[num]))) { continue; } for (int num2 = 0; num2 < 3; num2++) { int num3 = Triangles[num + num2]; if (!dictionary2.TryGetValue(num3, out var value3)) { value3 = (dictionary2[num3] = meshData.AddVertex(Positions[num3], Normals[num3], Uvs[num3])); } meshData.Triangles.Add(value3); } } return meshData; void Join(int a, int b) { parent[Root(a)] = Root(b); } int Root(int num5) { while (parent[num5] != num5) { parent[num5] = parent[parent[num5]]; num5 = parent[num5]; } return num5; } } public MeshData ResizeAlongY(float length, bool repeat, bool keepStartCap, bool keepEndCap, bool mirrorAlternate = false, float capBand = 0.05f) { //IL_009e: 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_00e2: Unknown result type (might be due to invalid IL or missing references) float minY = Positions.Min((Vector3 p) => p.y); float num = Positions.Max((Vector3 p) => p.y); List<int> list = new List<int>(); List<int> list2 = new List<int>(); List<int> list3 = new List<int>(); for (int num2 = 0; num2 < Triangles.Count; num2 += 3) { float[] source = new float[3] { Positions[Triangles[num2]].y, Positions[Triangles[num2 + 1]].y, Positions[Triangles[num2 + 2]].y }; ((source.Max() <= minY + capBand) ? list : ((source.Min() >= num - capBand) ? list2 : list3)).Add(num2); } if (list3.Count == 0) { throw new InvalidOperationException("Mesh has no faces spanning its length; it isn't a simple extrusion."); } float a = list3.SelectMany((int t) => new float[3] { Positions[Triangles[t]].y, Positions[Triangles[t + 1]].y, Positions[Triangles[t + 2]].y }).Min(); float b = list3.SelectMany((int t) => new float[3] { Positions[Triangles[t]].y, Positions[Triangles[t + 1]].y, Positions[Triangles[t + 2]].y }).Max(); float num3 = b - a; float start = (keepStartCap ? (a - minY) : 0f); float middleLength = length - start - (keepEndCap ? (num - b) : 0f); int num4 = ((!repeat) ? 1 : Mathf.Max(1, Mathf.RoundToInt(middleLength / num3))); float scale = middleLength / ((float)num4 * num3); MeshData result = new MeshData(); if (keepStartCap) { list.ForEach(delegate(int t) { AddTriangle(t, (float y) => y - minY); }); } for (int num5 = 0; num5 < num4; num5++) { float offset = (float)num5 * num3; if (mirrorAlternate && num5 % 2 == 1) { list3.ForEach(delegate(int t) { AddTriangle(t, (float y) => start + (offset + b - y) * scale, flipped: true); }); continue; } list3.ForEach(delegate(int t) { AddTriangle(t, (float y) => start + (offset + y - a) * scale); }); } if (keepEndCap) { list2.ForEach(delegate(int t) { AddTriangle(t, (float y) => start + middleLength + (y - b)); }); } return result; void AddTriangle(int t, Func<float, float> mapY, bool flipped = false) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0078: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00ae: 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_009b: 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) int[] array = ((!flipped) ? new int[3] { 0, 1, 2 } : new int[3] { 0, 2, 1 }); foreach (int num6 in array) { int index = Triangles[t + num6]; Vector3 val = Positions[index]; Vector3 val2 = Normals[index]; result.Triangles.Add(result.AddVertex(new Vector3(val.x, mapY(val.y), val.z), (Vector3)(flipped ? new Vector3(val2.x, 0f - val2.y, val2.z) : val2), Uvs[index])); } } } public int[] FlatFaces(float minAlignment = 0.999f) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_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_0094: 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_00a1: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: 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) int num = Triangles.Count / 3; int[] parent = Enumerable.Range(0, num).ToArray(); Vector3[] array = (Vector3[])(object)new Vector3[num]; Dictionary<string, int> dictionary = new Dictionary<string, int>(); Vector3[] array2 = (Vector3[])(object)new Vector3[3]; for (int i = 0; i < num; i++) { for (int j = 0; j < 3; j++) { array2[j] = Positions[Triangles[3 * i + j]]; } int num2 = i; Vector3 val = Vector3.Cross(array2[1] - array2[0], array2[2] - array2[0]); array[num2] = ((Vector3)(ref val)).normalized; for (int k = 0; k < 3; k++) { string key = EdgeKey(array2[k], array2[(k + 1) % 3]); if (dictionary.TryGetValue(key, out var value)) { if (Vector3.Dot(array[i], array[value]) >= minAlignment) { parent[Root(i)] = Root(value); } } else { dictionary[key] = i; } } } return Enumerable.Range(0, num).Select(Root).ToArray(); int Root(int num3) { while (parent[num3] != num3) { parent[num3] = parent[parent[num3]]; num3 = parent[num3]; } return num3; } } private static string EdgeKey(Vector3 a, Vector3 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_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0087: 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_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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) Vector3Int val = Vector3Int.RoundToInt(a * 10000f); Vector3Int val2 = Vector3Int.RoundToInt(b * 10000f); int num; Vector3I