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 AshlandsGeothermalFoundry v0.2.8
plugins/AshlandsGeothermalFoundry/AshlandsGeothermalFoundry.dll
Decompiled a day 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.IO; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using AshlandsGeothermalFoundry.Core; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("AshlandsGeothermalFoundry")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.8.0")] [assembly: AssemblyInformationalVersion("0.2.8")] [assembly: AssemblyProduct("AshlandsGeothermalFoundry")] [assembly: AssemblyTitle("AshlandsGeothermalFoundry")] [assembly: AssemblyVersion("0.2.8.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 AshlandsGeothermalFoundry { public sealed class Foundry : MonoBehaviour { public Light WorkLight; private FoundryStorage storage; private ThermalNode node; private ZNetView view; private bool faulted; private const string ProgressKey = "agf_progress_v1"; private const string RecipeKey = "agf_recipe_v1"; private const string ActiveKey = "agf_active_v1"; private void Start() { storage = ((Component)this).GetComponent<FoundryStorage>(); node = ((Component)this).GetComponent<ThermalNode>(); view = ((Component)this).GetComponent<ZNetView>(); if (Object.op_Implicit((Object)(object)view) && view.IsValid()) { ((MonoBehaviour)this).InvokeRepeating("Tick", 1f, 1f); } } private void Tick() { if (!Object.op_Implicit((Object)(object)view) || !view.IsValid()) { return; } ZDO zDO = view.GetZDO(); if (Object.op_Implicit((Object)(object)WorkLight)) { WorkLight.intensity = ((zDO.GetBool("agf_active_v1", false) && node.Heat.Power > 0f) ? 2f : 0f); } if (!view.IsOwner() || faulted) { return; } try { zDO.Set("agf_active_v1", false); if (storage.Busy) { return; } storage.Load(); storage.Upgrade(); Inventory inventory = storage.Input.GetInventory(); Inventory inventory2 = storage.Output.GetInventory(); if (inventory == null || inventory2 == null) { return; } List<ItemData> allItems = inventory.GetAllItems(); int num = (from i in inventory2.GetAllItems() where Object.op_Implicit((Object)(object)i.m_dropPrefab) && Pieces.Products.Contains(((Object)i.m_dropPrefab).name) select i).Sum((ItemData i) => i.m_stack); ItemData val = ((IEnumerable<ItemData>)allItems).FirstOrDefault((Func<ItemData, bool>)((ItemData i) => Object.op_Implicit((Object)(object)i.m_dropPrefab) && Pieces.Recipes.ContainsKey(((Object)i.m_dropPrefab).name))); if (val == null || num >= Plugin.OutputLimit.Value || node.Heat.Power <= 0f) { return; } string name = ((Object)val.m_dropPrefab).name; ItemDrop val2 = Pieces.Recipes[name]; float progress = ((zDO.GetString("agf_recipe_v1", "") == name) ? zDO.GetFloat("agf_progress_v1", 0f) : 0f); progress = ProcessingRules.Advance(progress, 1f, node.Heat.Power, Plugin.SecondsPerBar.Value, canProcess: true); zDO.Set("agf_recipe_v1", name); zDO.Set("agf_progress_v1", progress); zDO.Set("agf_active_v1", true); if (!(progress < Plugin.SecondsPerBar.Value)) { ItemData val3 = val2.m_itemData.Clone(); val3.m_dropPrefab = ((Component)val2).gameObject; val3.m_stack = 1; val3.m_quality = 1; val3.m_cheated = val.m_cheated; if (!ProcessingInventory.TryConvert(inventory, inventory2, val, val3, out var stagedInput, out var stagedOutput)) { zDO.Set("agf_active_v1", false); return; } storage.Commit(stagedInput, stagedOutput); zDO.Set("agf_progress_v1", 0f); } } catch (Exception innerException) { faulted = true; zDO.Set("agf_active_v1", false); Plugin.Error(new InvalidOperationException("Foundry paused after processing error; reload after resolving the error.", innerException)); } } internal string Status() { if (faulted) { return "Paused: processing error (see BepInEx log)"; } if (Object.op_Implicit((Object)(object)storage) && storage.Busy) { return "Paused while a storage bin is open"; } if ((Object)(object)node == (Object)null || node.Heat.Probes == 0) { return "No heat — connect a submerged lava probe"; } return $"Heat {node.Heat.Power:P0} | {node.Heat.Probes} probes / {node.Heat.Foundries} foundries\n" + $"{Plugin.SecondsPerBar.Value / Math.Max(node.Heat.Power, 0.001f):0.#} sec/bar | Output limit {Plugin.OutputLimit.Value:N0}"; } } [HarmonyPatch(typeof(Container), "GetHoverText")] internal static class HopperHover { private static void Postfix(Container __instance, ref string __result) { Foundry component = ((Component)__instance).GetComponent<Foundry>(); if (Object.op_Implicit((Object)(object)component)) { __result = __result + "\n" + component.Status(); } } } internal static class FoundryAppearance { internal static Material PipeMaterial(GameObject furnace) { //IL_0062: 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_0073: Expected O, but got Unknown //IL_00af: 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_0100: Unknown result type (might be due to invalid IL or missing references) Material? obj = furnace.GetComponentsInChildren<Renderer>(true).SelectMany((Renderer r) => r.sharedMaterials).FirstOrDefault((Func<Material, bool>)((Material m) => Object.op_Implicit((Object)(object)m) && ((Object)m).name == "BlastFurnace_mat")); if (!Object.op_Implicit((Object)(object)obj)) { throw new InvalidOperationException("BlastFurnace_mat is missing; refusing to use a snow/wood material."); } Material val = new Material(obj) { name = "AGF_DarkFurnacePipe" }; string[] array = new string[3] { "_MainTex", "_BumpMap", "_MetallicGlossMap" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetTextureScale(text, new Vector2(0.18f, 0.42f)); val.SetTextureOffset(text, new Vector2(0.8f, 0.05f)); } } if (val.HasProperty("_Color")) { val.SetColor("_Color", new Color(0.72f, 0.75f, 0.78f, 1f)); } Stable(val); return val; } private static void Stable(Material material) { string[] array = new string[2] { "_AddSnow", "_ValueNoiseVertex" }; foreach (string text in array) { if (material.HasProperty(text)) { material.SetFloat(text, 0f); } } material.DisableKeyword("_VALUENOISEVERTEX_ON"); material.DisableKeyword("_ADDSNOW_ON"); } internal static Vector3 RemoveWood(GameObject root, Material pipeMetal) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: 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_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_00a7: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: 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_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_016f: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Unknown result type (might be due to invalid IL or missing references) //IL_02fe: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0225: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0447: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_0457: Unknown result type (might be due to invalid IL or missing references) //IL_045c: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_0756: Unknown result type (might be due to invalid IL or missing references) //IL_075d: Expected O, but got Unknown //IL_082b: Unknown result type (might be due to invalid IL or missing references) //IL_0830: Unknown result type (might be due to invalid IL or missing references) //IL_088c: Unknown result type (might be due to invalid IL or missing references) //IL_08a4: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_0486: Unknown result type (might be due to invalid IL or missing references) //IL_048b: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_049b: Unknown result type (might be due to invalid IL or missing references) //IL_04a1: Unknown result type (might be due to invalid IL or missing references) //IL_04c9: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e3: Unknown result type (might be due to invalid IL or missing references) //IL_04f8: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_0512: Unknown result type (might be due to invalid IL or missing references) //IL_0517: Unknown result type (might be due to invalid IL or missing references) //IL_051c: Unknown result type (might be due to invalid IL or missing references) //IL_0520: Unknown result type (might be due to invalid IL or missing references) //IL_0525: Unknown result type (might be due to invalid IL or missing references) //IL_0527: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Unknown result type (might be due to invalid IL or missing references) //IL_0530: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_054a: Unknown result type (might be due to invalid IL or missing references) //IL_0578: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_0584: Unknown result type (might be due to invalid IL or missing references) //IL_0589: Unknown result type (might be due to invalid IL or missing references) //IL_058e: Unknown result type (might be due to invalid IL or missing references) //IL_059a: Unknown result type (might be due to invalid IL or missing references) //IL_059f: Unknown result type (might be due to invalid IL or missing references) //IL_05a6: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05af: Unknown result type (might be due to invalid IL or missing references) //IL_05b6: Unknown result type (might be due to invalid IL or missing references) //IL_05c2: Unknown result type (might be due to invalid IL or missing references) //IL_05c7: Unknown result type (might be due to invalid IL or missing references) //IL_05d0: Unknown result type (might be due to invalid IL or missing references) //IL_05dc: Unknown result type (might be due to invalid IL or missing references) //IL_05e1: Unknown result type (might be due to invalid IL or missing references) //IL_05f4: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_060c: Unknown result type (might be due to invalid IL or missing references) //IL_0611: Unknown result type (might be due to invalid IL or missing references) //IL_0626: Unknown result type (might be due to invalid IL or missing references) //IL_062f: Unknown result type (might be due to invalid IL or missing references) //IL_06e7: Unknown result type (might be due to invalid IL or missing references) //IL_06ec: Unknown result type (might be due to invalid IL or missing references) //IL_06f3: Unknown result type (might be due to invalid IL or missing references) //IL_06f8: Unknown result type (might be due to invalid IL or missing references) //IL_06ff: Unknown result type (might be due to invalid IL or missing references) //IL_0704: Unknown result type (might be due to invalid IL or missing references) //IL_070b: Unknown result type (might be due to invalid IL or missing references) //IL_0710: Unknown result type (might be due to invalid IL or missing references) //IL_064a: Unknown result type (might be due to invalid IL or missing references) //IL_0653: Unknown result type (might be due to invalid IL or missing references) //IL_0692: Unknown result type (might be due to invalid IL or missing references) //IL_06a2: Unknown result type (might be due to invalid IL or missing references) //IL_06a9: Unknown result type (might be due to invalid IL or missing references) //IL_06b3: Unknown result type (might be due to invalid IL or missing references) Transform val = root.transform.Find("colliders/Cube (2)"); BoxCollider val2 = (Object.op_Implicit((Object)(object)val) ? ((Component)val).GetComponent<BoxCollider>() : null); if (!Object.op_Implicit((Object)(object)val2)) { throw new InvalidOperationException("The vanilla furnace pillar collider is missing."); } Vector3 val3 = root.transform.InverseTransformPoint(val.TransformPoint(val2.center)); SkinnedMeshRenderer val4 = ((IEnumerable<SkinnedMeshRenderer>)root.GetComponentsInChildren<SkinnedMeshRenderer>(true)).FirstOrDefault((Func<SkinnedMeshRenderer, bool>)((SkinnedMeshRenderer r) => ((Renderer)r).sharedMaterials.Any((Material m) => Object.op_Implicit((Object)(object)m) && ((Object)m).name == "BlastFurnace_mat"))); if (!Object.op_Implicit((Object)(object)val4)) { throw new InvalidOperationException("Could not find the vanilla furnace body for wood removal."); } Mesh val5 = new Mesh { name = "AGF_StoneAndMetalBody" }; val4.BakeMesh(val5, true); Matrix4x4 val6 = root.transform.worldToLocalMatrix * ((Component)val4).transform.localToWorldMatrix; Vector3[] vertices = val5.vertices; if (vertices.Length != 11676) { throw new InvalidOperationException("The vanilla furnace mesh changed; its legacy pipe removal map needs updating."); } for (int num = 0; num < vertices.Length; num++) { vertices[num] = ((Matrix4x4)(ref val6)).MultiplyPoint3x4(vertices[num]); } val5.vertices = vertices; Vector3[] normals = val5.normals; Matrix4x4 inverse = ((Matrix4x4)(ref val6)).inverse; Matrix4x4 transpose = ((Matrix4x4)(ref inverse)).transpose; Vector3 val7; for (int num2 = 0; num2 < normals.Length; num2++) { int num3 = num2; val7 = ((Matrix4x4)(ref transpose)).MultiplyVector(normals[num2]); normals[num3] = ((Vector3)(ref val7)).normalized; } val5.normals = normals; Vector2[] uv = val5.uv; int num4 = 0; for (int num5 = 0; num5 < val5.subMeshCount; num5++) { if (num5 >= ((Renderer)val4).sharedMaterials.Length || !Object.op_Implicit((Object)(object)((Renderer)val4).sharedMaterials[num5]) || ((Object)((Renderer)val4).sharedMaterials[num5]).name != "BlastFurnace_mat") { val5.SetTriangles(Array.Empty<int>(), num5); continue; } int[] triangles = val5.GetTriangles(num5); List<int> list = new List<int>(); for (int num6 = 0; num6 < triangles.Length; num6 += 3) { bool flag = true; for (int num7 = 0; num7 < 3; num7++) { Vector2 val8 = uv[triangles[num6 + num7]]; flag &= FurnaceSurface.IsWood(val8.x, val8.y); } if (flag || LegacyFurnaceParts.RemoveTriangle(triangles[num6], triangles[num6 + 1], triangles[num6 + 2])) { num4++; continue; } list.Add(triangles[num6]); list.Add(triangles[num6 + 1]); list.Add(triangles[num6 + 2]); } val5.SetTriangles(list, num5); } if (num4 == 0) { throw new InvalidOperationException("Furnace atlas changed: no wood triangles identified."); } val5.RecalculateBounds(); val5.RecalculateTangents(); Bounds bounds = val5.bounds; Vector3 size = ((Bounds)(ref bounds)).size; if (!AppearanceRules.ValidBodySize(size.x, size.y, size.z)) { throw new InvalidOperationException($"Unexpected furnace body size {size}; refusing to register an incorrectly scaled collider."); } Material[] sharedMaterials = ((Renderer)val4).sharedMaterials.Select(delegate(Material m) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) Material val17 = new Material(m); Stable(val17); if (val17.HasProperty("_EmissionColor")) { val17.SetColor("_EmissionColor", Color.black); } val17.DisableKeyword("_EMISSION"); return val17; }).ToArray(); LODGroup[] componentsInChildren = root.GetComponentsInChildren<LODGroup>(true); for (int num8 = 0; num8 < componentsInChildren.Length; num8++) { Object.DestroyImmediate((Object)(object)componentsInChildren[num8]); } string[] array = new string[9] { "New", "Worn", "Broken", "BlastFurnace_Destruction", "floor_2x2_snow", "add_wood", "add_ore", "colliders", "_enabled" }; foreach (string text in array) { Transform val9 = root.transform.Find(text); if (Object.op_Implicit((Object)(object)val9)) { Object.DestroyImmediate((Object)(object)((Component)val9).gameObject); } } for (int num9 = 0; num9 < FurnacePipeEnds.Rings.Length; num9 += 2) { int[] array2 = FurnacePipeEnds.Rings[num9]; int[] array3 = FurnacePipeEnds.Rings[num9 + 1]; Vector3 val10 = Centre(array2); Vector3 val11 = Centre(array3); int[] array4 = ((val10.z < val11.z) ? array2 : array3); Vector3 centre = Centre(array4); Vector3 val12 = ((val10.z < val11.z) ? val11 : val10); float num10 = array4.Max((int i) => Vector3.Distance(centre, vertices[i])); val7 = Vector3.Cross(vertices[array4[1]] - vertices[array4[0]], vertices[array4[2]] - vertices[array4[0]]); Vector3 val13 = ((Vector3)(ref val7)).normalized; if (Vector3.Dot(val13, centre - val12) < 0f) { val13 = -val13; } float num11 = num9 switch { 4 => -0.71f, 2 => 0.71f, 0 => -0.98f, _ => -0.44f, }; Vector3 val14 = centre + val13 * 0.12f; Vector3[] array5 = (Vector3[])(object)new Vector3[6] { centre, val14, new Vector3(val14.x, val14.y, -0.85f), new Vector3(num11, val14.y, -0.85f), new Vector3(num11, 0.78f, -0.85f), new Vector3(num11, 0.78f, -1.05f) }; for (int num12 = 1; num12 < array5.Length; num12++) { if (!(Vector3.Distance(array5[num12 - 1], array5[num12]) < 0.001f)) { Pieces.Tube(root, array5[num12 - 1], array5[num12], num10, pipeMetal, "original_pipe_to_bin"); GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)obj).name = "pipe_elbow_joint"; obj.transform.SetParent(root.transform, false); obj.transform.localPosition = array5[num12]; obj.transform.localScale = Vector3.one * num10 * 2.04f; obj.GetComponent<Renderer>().sharedMaterial = pipeMetal; Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>()); } } Pieces.Tube(root, centre - val13 * 0.04f, centre + val13 * 0.08f, num10 * 1.12f, pipeMetal, "original_pipe_union"); } Plugin.LogInfo($"Pillar collider centre for heat sockets: {val3}"); GameObject val15 = new GameObject("agf_stone_metal_body"); val15.transform.SetParent(root.transform, false); val15.AddComponent<MeshFilter>().sharedMesh = val5; ((Renderer)val15.AddComponent<MeshRenderer>()).sharedMaterials = sharedMaterials; val15.AddComponent<MeshCollider>().sharedMesh = val5; WearNTear component = root.GetComponent<WearNTear>(); component.m_new = val15; component.m_worn = Object.Instantiate<GameObject>(val15, root.transform); ((Object)component.m_worn).name = "agf_body_worn"; component.m_broken = Object.Instantiate<GameObject>(val15, root.transform); ((Object)component.m_broken).name = "agf_body_broken"; Object.DestroyImmediate((Object)(object)component.m_worn.GetComponent<MeshCollider>()); Object.DestroyImmediate((Object)(object)component.m_broken.GetComponent<MeshCollider>()); component.m_worn.SetActive(false); component.m_broken.SetActive(false); GameObject val16 = new GameObject("agf_body_collision"); val16.transform.SetParent(root.transform, false); val16.AddComponent<MeshCollider>().sharedMesh = val5; Object.DestroyImmediate((Object)(object)val15.GetComponent<MeshCollider>()); component.m_snow = null; component.m_snowWorn = null; component.m_snowBroken = null; component.m_wet = null; component.m_fragmentRoots = Array.Empty<GameObject>(); component.m_autoCreateFragments = false; Plugin.LogInfo($"Furnace appearance: body size {size}; removed {num4} wood/leather triangles and additive glow submesh."); return val3; Vector3 Centre(int[] ring) { //IL_0012: 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_003f: Unknown result type (might be due to invalid IL or missing references) return ring.Select((int i) => vertices[i]).Aggregate(Vector3.zero, (Vector3 a, Vector3 b) => a + b) / (float)ring.Length; } } } public sealed class FoundryStorage : MonoBehaviour { public Container Input; public Container Output; private ZNetView view; private byte[] lastBlob; private bool loaded; private bool applying; private bool upgraded; private const string Key = "agf_storages_v2"; private static readonly MethodInfo Changed = AccessTools.Method(typeof(Inventory), "Changed", new Type[2] { typeof(bool), typeof(bool) }, (Type[])null); private static readonly MethodInfo UpdateRows = AccessTools.Method(typeof(Container), "UpdateRows", (Type[])null, (Type[])null); internal bool Busy { get { if (!Object.op_Implicit((Object)(object)Input) || !Input.IsInUse()) { if (Object.op_Implicit((Object)(object)Output)) { return Output.IsInUse(); } return false; } return true; } } private bool Ready() { if (!Object.op_Implicit((Object)(object)view)) { view = ((Component)this).GetComponent<ZNetView>(); } if (Object.op_Implicit((Object)(object)view) && view.IsValid() && Object.op_Implicit((Object)(object)Input) && Object.op_Implicit((Object)(object)Output) && Input.GetInventory() != null) { return Output.GetInventory() != null; } return false; } private void Start() { try { Load(); } catch (Exception ex) { Plugin.Error(ex); } } internal bool Load() { //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Expected O, but got Unknown //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Expected O, but got Unknown if (!Ready() || Busy || applying) { return false; } ZDO zDO = view.GetZDO(); byte[] byteArray = zDO.GetByteArray("agf_storages_v2", (byte[])null); if (loaded && byteArray != null && lastBlob != null && ((ReadOnlySpan<byte>)byteArray).SequenceEqual((ReadOnlySpan<byte>)lastBlob)) { return false; } if (byteArray == null && loaded) { return false; } Inventory val = new Inventory("Input", (Sprite)null, Input.m_width, Input.m_height); Inventory val2 = new Inventory("Output", (Sprite)null, Output.m_width, Output.m_height); if (byteArray != null) { (byte[], byte[]) tuple = StorageEnvelope.Unpack(byteArray); val.Load(new ZPackage(tuple.Item1)); val2.Load(new ZPackage(tuple.Item2)); upgraded = true; } else { byte[] byteArray2 = zDO.GetByteArray(ZDOVars.s_items, (byte[])null); if (byteArray2 != null && byteArray2.Length != 0) { val.Load(new ZPackage(byteArray2)); } } Apply(val, val2); loaded = true; lastBlob = byteArray; return true; } internal void Upgrade() { if (Ready() && loaded && !upgraded && !Busy && view.IsOwner()) { Inventory input = ProcessingInventory.Clone(Input.GetInventory()); Inventory output = ProcessingInventory.Clone(Output.GetInventory()); ProcessingInventory.MoveMatching(input, output, (ItemData item) => Object.op_Implicit((Object)(object)item.m_dropPrefab) && Pieces.Products.Contains(((Object)item.m_dropPrefab).name)); Commit(input, output); upgraded = true; } } internal void Save() { if (!applying && Ready() && loaded && view.IsOwner()) { byte[] array = Pack(Input.GetInventory(), Output.GetInventory()); view.GetZDO().Set("agf_storages_v2", array); lastBlob = array; } } private static byte[] Pack(Inventory input, Inventory output) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown ZPackage val = new ZPackage(); ZPackage val2 = new ZPackage(); input.Save(val); output.Save(val2); return StorageEnvelope.Pack(val.GetArray(), val2.GetArray()); } internal void Commit(Inventory input, Inventory output) { if (!Ready() || Busy || !view.IsOwner()) { throw new InvalidOperationException("Foundry storage is not available for processing."); } byte[] array = Pack(input, output); Inventory input2 = ProcessingInventory.Clone(Input.GetInventory()); Inventory output2 = ProcessingInventory.Clone(Output.GetInventory()); try { Apply(input, output); view.GetZDO().Set("agf_storages_v2", array); lastBlob = array; } catch { Apply(input2, output2); throw; } } private void Apply(Inventory input, Inventory output) { applying = true; try { Replace(Input.GetInventory(), input); Replace(Output.GetInventory(), output); Changed.Invoke(Input.GetInventory(), new object[2] { false, false }); Changed.Invoke(Output.GetInventory(), new object[2] { false, false }); UpdateRows.Invoke(Input, null); UpdateRows.Invoke(Output, null); } finally { applying = false; } } private static void Replace(Inventory live, Inventory staged) { ItemData[] collection = (from i in staged.GetAllItems() select i.Clone()).ToArray(); live.GetAllItems().Clear(); live.GetAllItems().AddRange(collection); } internal static string Rpc(string original, Container container) { FoundryStorage component = ((Component)container).GetComponent<FoundryStorage>(); return StorageEnvelope.RpcName(original, Object.op_Implicit((Object)(object)component) && (Object)(object)component.Output == (Object)(object)container); } } [HarmonyPatch] internal static class StorageRpcPatch { private static IEnumerable<MethodBase> TargetMethods() { return from m in typeof(Container).GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) where m.GetMethodBody() != null select m; } private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions) { MethodInfo map = AccessTools.Method(typeof(FoundryStorage), "Rpc", (Type[])null, (Type[])null); foreach (CodeInstruction instruction in instructions) { yield return instruction; if (instruction.opcode == OpCodes.Ldstr && instruction.operand is string text && text.StartsWith("RPC_", StringComparison.Ordinal)) { yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null); yield return new CodeInstruction(OpCodes.Call, (object)map); } } } } [HarmonyPatch(typeof(Container), "Save")] internal static class StorageSavePatch { private static bool Prefix(Container __instance) { FoundryStorage component = ((Component)__instance).GetComponent<FoundryStorage>(); if (!Object.op_Implicit((Object)(object)component)) { return true; } component.Save(); return false; } } [HarmonyPatch(typeof(Container), "Load", new Type[] { })] internal static class StorageLoadPatch { private static bool Prefix(Container __instance, ref bool __result) { FoundryStorage component = ((Component)__instance).GetComponent<FoundryStorage>(); if (!Object.op_Implicit((Object)(object)component)) { return true; } __result = component.Load(); return false; } } [HarmonyPatch] internal static class StorageAccessLockPatch { private static IEnumerable<MethodBase> TargetMethods() { return ((IEnumerable<string>)new string[3] { "RPC_RequestOpen", "RPC_RequestStack", "RPC_RequestTakeAll" }).Select((Func<string, MethodBase>)((string n) => AccessTools.Method(typeof(Container), n, (Type[])null, (Type[])null))); } private static bool Prefix(Container __instance, long __0, MethodBase __originalMethod) { FoundryStorage component = ((Component)__instance).GetComponent<FoundryStorage>(); if (!Object.op_Implicit((Object)(object)component) || !component.Busy || __0 == ZNet.GetUID()) { return true; } ZNetView component2 = ((Component)__instance).GetComponent<ZNetView>(); if (!Object.op_Implicit((Object)(object)component2) || !component2.IsValid() || !component2.IsOwner()) { return true; } string original = ((__originalMethod.Name == "RPC_RequestOpen") ? "RPC_OpenResponse" : ((__originalMethod.Name == "RPC_RequestStack") ? "RPC_StackResponse" : "RPC_TakeAllResponse")); component2.InvokeRPC(__0, FoundryStorage.Rpc(original, __instance), new object[1] { false }); return false; } } [HarmonyPatch] internal static class StorageOpenHydrationPatch { private static IEnumerable<MethodBase> TargetMethods() { return ((IEnumerable<string>)new string[3] { "RPC_OpenResponse", "RPC_StackResponse", "RPC_TakeAllResponse" }).Select((Func<string, MethodBase>)((string n) => AccessTools.Method(typeof(Container), n, (Type[])null, (Type[])null))); } private static void Prefix(Container __instance, bool __1) { FoundryStorage component = ((Component)__instance).GetComponent<FoundryStorage>(); if (Object.op_Implicit((Object)(object)component) && __1) { component.Load(); } } } public sealed class FoundryBodyAccess : MonoBehaviour, Interactable, Hoverable { public bool Interact(Humanoid user, bool hold, bool alt) { return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverText() { return "Geothermal foundry\nUse the front INPUT or OUTPUT bin"; } public string GetHoverName() { return "Geothermal foundry"; } public float GetHoverOffset() { return 0f; } } public sealed class StorageAccess : MonoBehaviour, Interactable, Hoverable { public Container Target; public bool Interact(Humanoid user, bool hold, bool alt) { if (Object.op_Implicit((Object)(object)Target)) { return Target.Interact(user, hold, alt); } return false; } public bool UseItem(Humanoid user, ItemData item) { return false; } public string GetHoverText() { if (!Object.op_Implicit((Object)(object)Target)) { return ""; } return Target.GetHoverText(); } public string GetHoverName() { if (!Object.op_Implicit((Object)(object)Target)) { return "Storage"; } return Target.m_name; } public float GetHoverOffset() { return 0f; } } public enum NodeKind { Conduit, Probe, Foundry } public sealed class ThermalNode : MonoBehaviour, Hoverable { internal static readonly HashSet<ThermalNode> Live = new HashSet<ThermalNode>(); public NodeKind Kind; public Vector3 Tip = new Vector3(0f, -4f, 0f); public string DisplayName; internal ZNetView View; internal Transform[] Ports; internal HeatResult Heat; internal bool Submerged; private Renderer[] glow; private MaterialPropertyBlock properties; private void Start() { //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Expected O, but got Unknown View = ((Component)this).GetComponent<ZNetView>(); Ports = (from Transform t in (IEnumerable)((Component)this).transform where ((Object)t).name.StartsWith("heat_port_", StringComparison.Ordinal) select t).ToArray(); glow = (from r in ((Component)this).GetComponentsInChildren<Renderer>(true) where ((Object)r).name.StartsWith("heat_glow", StringComparison.Ordinal) select r).ToArray(); properties = new MaterialPropertyBlock(); if (Object.op_Implicit((Object)(object)View) && View.IsValid()) { Live.Add(this); } } private void OnDestroy() { Live.Remove(this); } internal HeatNode Snapshot() { //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_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) Submerged = false; if (Kind == NodeKind.Probe) { Vector3 val = ((Component)this).transform.TransformPoint(Tip); Heightmap val2 = Heightmap.FindHeightmap(val); float surfaceY = default(float); if (Object.op_Implicit((Object)(object)val2) && val2.GetWorldHeight(val, ref surfaceY)) { Submerged = ProcessingRules.IsSubmerged(val2.IsLava(val, 0.2f), val.y, surfaceY, 4f); } } return new HeatNode { Foundry = (Kind == NodeKind.Foundry), SubmergedProbe = Submerged, Ports = Ports.Select((Transform t) => new Port(ToPoint(t.position), ToPoint(t.forward))).ToArray() }; } private static Point ToPoint(Vector3 v) { //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_000c: Unknown result type (might be due to invalid IL or missing references) return new Point(v.x, v.y, v.z); } internal void Apply(HeatResult heat) { //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) //IL_0014: 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_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_0097: 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_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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) Heat = heat; Color val = ((heat.Power > 0f) ? (new Color(2.1f, 0.4125f, 0.03f) * heat.Power) : Color.black); properties.SetColor("_EmissionColor", val); properties.SetColor("_EmissiveColor", val); Renderer[] array = glow; foreach (Renderer val2 in array) { if (Object.op_Implicit((Object)(object)val2)) { Color val3 = ((((Object)val2).name.StartsWith("heat_glow_ground", StringComparison.Ordinal) && heat.Power > 0f) ? (new Color(1.6f, 0.025f, 0.01f) * heat.Power) : val); properties.SetColor("_EmissionColor", val3); properties.SetColor("_EmissiveColor", val3); val2.SetPropertyBlock(properties); } } } public string GetHoverName() { return DisplayName; } public float GetHoverOffset() { return 0f; } public string GetHoverText() { return DisplayName + "\n" + ((Kind == NodeKind.Probe) ? ((Submerged ? "Probe submerged in natural lava" : "Lower the probe tip into natural lava") + "\n") : "") + ((Heat.Probes == 0) ? "No connected lava source" : $"Heat: {Heat.Power:P0} | {Heat.Probes} probes / {Heat.Foundries} foundries"); } } public sealed class HeatNetwork : MonoBehaviour { private float next; private void Update() { if (Time.time < next) { return; } next = Time.time + 0.5f; ThermalNode[] array = ThermalNode.Live.Where((ThermalNode n) => Object.op_Implicit((Object)(object)n) && Object.op_Implicit((Object)(object)n.View) && n.View.IsValid() && ((Behaviour)n).isActiveAndEnabled).ToArray(); if (array.Length == 0) { return; } try { HeatResult[] array2 = HeatGraph.Solve(array.Select((ThermalNode n) => n.Snapshot()).ToArray(), 0.12f, Plugin.FurnacesPerProbe.Value); for (int num = 0; num < array.Length; num++) { array[num].Apply(array2[num]); } } catch (Exception ex) { ThermalNode[] array3 = array; for (int num2 = 0; num2 < array3.Length; num2++) { array3[num2].Apply(default(HeatResult)); } Plugin.Error(ex); next = Time.time + 5f; } } } internal static class MasonryRepair { internal static void CloseOpenings(Mesh mesh, Vector3[] original, Vector2[] originalUv) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: 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_0114: 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_0122: 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_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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_025a: 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_0267: 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_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027b: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_045f: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0476: Unknown result type (might be due to invalid IL or missing references) //IL_047e: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_02dc: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_0413: Unknown result type (might be due to invalid IL or missing references) //IL_0442: Unknown result type (might be due to invalid IL or missing references) Vector3[] stone = original.Where((Vector3 p, int i) => originalUv[i].x < 0.42f && p.y > 0.6f).ToArray(); Bounds pillar = new Bounds(stone[0], Vector3.zero); Vector3[] array = stone; foreach (Vector3 val in array) { ((Bounds)(ref pillar)).Encapsulate(val); } List<Vector3> list = original.ToList(); List<Vector2> list2 = originalUv.ToList(); List<int> list3 = mesh.GetTriangles(0).ToList(); int[][] groups = FurnaceOpeningBounds.Groups; Bounds val2 = default(Bounds); foreach (int[] array2 in groups) { ((Bounds)(ref val2))..ctor(original[array2[0]], Vector3.zero); int[] array3 = array2; foreach (int num3 in array3) { ((Bounds)(ref val2)).Encapsulate(original[num3]); } Vector3 val3 = ((Bounds)(ref val2)).center - ((Bounds)(ref pillar)).center; int axis = ((!(Mathf.Abs(val3.x) > Mathf.Abs(val3.z))) ? 2 : 0); int tangent = ((axis == 0) ? 2 : 0); float sign = ((!(((Vector3)(ref val3))[axis] < 0f)) ? 1 : (-1)); Vector3 val4 = ((Bounds)(ref val2)).min; float lo = ((Vector3)(ref val4))[tangent] - 0.035f; val4 = ((Bounds)(ref val2)).max; float hi = ((Vector3)(ref val4))[tangent] + 0.035f; float num4 = ((Bounds)(ref val2)).min.y - 0.035f; float num5 = ((Bounds)(ref val2)).max.y + 0.035f; float num6 = Surface(num4); float num7 = Surface(num5); for (int num8 = list3.Count - 3; num8 >= 0; num8 -= 3) { int num9 = list3[num8]; int num10 = list3[num8 + 1]; int num11 = list3[num8 + 2]; if (num9 < original.Length && num10 < original.Length && num11 < original.Length) { Vector3 val5 = (original[num9] + original[num10] + original[num11]) / 3f; if (val5.y > num4 && val5.y < num5 && ((Vector3)(ref val5))[tangent] > lo && ((Vector3)(ref val5))[tangent] < hi) { float num12 = ((Vector3)(ref val5))[axis]; val4 = ((Bounds)(ref val2)).center; float num13 = Mathf.Abs(num12 - ((Vector3)(ref val4))[axis]); val4 = ((Bounds)(ref val2)).extents; if (num13 < ((Vector3)(ref val4))[axis] + 0.1f) { list3.RemoveRange(num8, 3); } } } } int num14 = Math.Max(1, Mathf.CeilToInt((num5 - num4) / 0.4f)); int num15 = Math.Max(1, Mathf.CeilToInt((hi - lo) / 0.45f)); for (int num16 = 0; num16 < num14; num16++) { for (int num17 = 0; num17 < num15; num17++) { int count = list.Count; for (int num18 = 0; num18 < 4; num18++) { float num19 = ((float)num16 + ((num18 >= 2) ? 1f : 0f)) / (float)num14; float num20 = ((float)num17 + ((num18 == 1 || num18 == 2) ? 1f : 0f)) / (float)num15; Vector3 zero = Vector3.zero; zero.y = Mathf.Lerp(num4, num5, num19); ((Vector3)(ref zero))[tangent] = Mathf.Lerp(lo, hi, num20); ((Vector3)(ref zero))[axis] = Mathf.Lerp(num6, num7, num19); list.Add(zero); list2.Add(new Vector2((num18 == 1 || num18 == 2) ? 0.25f : 0.025f, (num18 >= 2) ? 0.63f : 0.36f)); } Vector3 val6 = Vector3.Cross(list[count + 1] - list[count], list[count + 2] - list[count]); bool flag = ((Vector3)(ref val6))[axis] * sign < 0f; list3.AddRange(flag ? new int[6] { count, count + 2, count + 1, count, count + 3, count + 2 } : new int[6] { count, count + 1, count + 2, count, count + 2, count + 3 }); } } float Surface(float y) { float[] array4 = (from p in stone.Where(delegate(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) if (Mathf.Abs(p.y - y) < 0.35f) { float num21 = ((Vector3)(ref p))[axis]; Vector3 center = ((Bounds)(ref pillar)).center; if ((num21 - ((Vector3)(ref center))[axis]) * sign > 0.45f && ((Vector3)(ref p))[tangent] > lo - 0.45f && ((Vector3)(ref p))[tangent] < hi + 0.45f) { if (!(((Vector3)(ref p))[tangent] < lo)) { return ((Vector3)(ref p))[tangent] > hi; } return true; } } return false; }) select ((Vector3)(ref p))[axis] * sign into v orderby v select v).ToArray(); if (array4.Length == 0) { array4 = (from p in stone.Where(delegate(Vector3 p) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) if (Mathf.Abs(p.y - y) < 0.65f) { float num21 = ((Vector3)(ref p))[axis]; Vector3 center = ((Bounds)(ref pillar)).center; return (num21 - ((Vector3)(ref center))[axis]) * sign > 0.25f; } return false; }) select ((Vector3)(ref p))[axis] * sign into v orderby v select v).ToArray(); } if (array4.Length == 0) { throw new InvalidOperationException("No adjacent masonry available to repair a furnace opening."); } return array4[(int)((float)(array4.Length - 1) * 0.65f)] * sign; } } mesh.SetVertices(list); mesh.SetUVs(0, list2); mesh.SetTriangles(list3, 0); } } internal static class Pieces { private static Material metal; private static Material hot; internal static readonly Dictionary<string, ItemDrop> Recipes = new Dictionary<string, ItemDrop>(StringComparer.Ordinal); internal static readonly HashSet<string> Products = new HashSet<string>(StringComparer.Ordinal); internal static void Register() { //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0156: 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_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: 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_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01f1: 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_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_021a: 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) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_022b: 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_0237: 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_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024a: Unknown result type (might be due to invalid IL or missing references) //IL_024f: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) GameObject prefab = PrefabManager.Instance.GetPrefab("blastfurnace"); GameObject prefab2 = PrefabManager.Instance.GetPrefab("smelter"); if (!Object.op_Implicit((Object)(object)prefab) || !Object.op_Implicit((Object)(object)prefab2)) { throw new InvalidOperationException("Required vanilla furnace prefabs are unavailable."); } GameObject[] array = (GameObject[])(object)new GameObject[2] { prefab2, prefab }; for (int i = 0; i < array.Length; i++) { foreach (ItemConversion item in array[i].GetComponent<Smelter>().m_conversion) { if (Object.op_Implicit((Object)(object)item.m_from) && Object.op_Implicit((Object)(object)item.m_to)) { Recipes[((Object)item.m_from).name] = item.m_to; Products.Add(((Object)item.m_to).name); } } } metal = FoundryAppearance.PipeMaterial(prefab); hot = new Material(metal); hot.EnableKeyword("_EMISSION"); hot.SetColor("_EmissionColor", new Color(2.1f, 0.4125f, 0.03f)); RegisterFoundry(); RegisterPipe("agf_lava_probe", "Lava probe", NodeKind.Probe, (Vector3[])(object)new Vector3[4] { Vector3.left, Vector3.right, Vector3.forward, Vector3.back }); RegisterPipe("agf_conduit", "Heat conduit — straight", NodeKind.Conduit, (Vector3[])(object)new Vector3[2] { Vector3.left, Vector3.right }); RegisterPipe("agf_conduit_vertical", "Heat conduit — vertical", NodeKind.Conduit, (Vector3[])(object)new Vector3[2] { Vector3.down, Vector3.up }); RegisterPipe("agf_conduit_elbow", "Heat conduit — elbow", NodeKind.Conduit, (Vector3[])(object)new Vector3[2] { Vector3.left, Vector3.forward }); RegisterPipe("agf_conduit_junction", "Heat conduit — junction", NodeKind.Conduit, (Vector3[])(object)new Vector3[6] { Vector3.left, Vector3.right, Vector3.forward, Vector3.back, Vector3.up, Vector3.down }); } private static PieceConfig Config(string name, bool foundry, bool probe = false) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Expected O, but got Unknown //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Expected O, but got Unknown //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Expected O, but got Unknown PieceConfig val = new PieceConfig(); val.Name = name; val.Description = (foundry ? "Lava-powered smelting. Load ore into the IN hopper; collect bars from the separate OUT bin." : (probe ? "Submerge the four-metre rod in natural lava. Snap heat conduits to its collar." : "Snap matching ports together to transfer geothermal heat.")); val.PieceTable = "Hammer"; val.Category = "Crafting"; val.CraftingStation = "piece_workbench"; val.Requirements = (RequirementConfig[])(object)((!foundry) ? ((!probe) ? new RequirementConfig[2] { new RequirementConfig("Iron", 2, 0, true), new RequirementConfig("Stone", 2, 0, true) } : new RequirementConfig[3] { new RequirementConfig("Iron", 10, 0, true), new RequirementConfig("BlackMetal", 5, 0, true), new RequirementConfig("SurtlingCore", 2, 0, true) }) : new RequirementConfig[4] { new RequirementConfig("Iron", 30, 0, true), new RequirementConfig("BlackMetal", 20, 0, true), new RequirementConfig("Stone", 40, 0, true), new RequirementConfig("SurtlingCore", 10, 0, true) }); return val; } private static void RegisterFoundry() { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Expected O, but got Unknown //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0206: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_021e: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022a: Unknown result type (might be due to invalid IL or missing references) //IL_022f: Unknown result type (might be due to invalid IL or missing references) //IL_0242: 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_0249: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025c: 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_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02a8: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0325: Unknown result type (might be due to invalid IL or missing references) //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_035d: Unknown result type (might be due to invalid IL or missing references) //IL_0371: Unknown result type (might be due to invalid IL or missing references) //IL_039c: Unknown result type (might be due to invalid IL or missing references) //IL_03c3: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0468: Unknown result type (might be due to invalid IL or missing references) //IL_0475: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_049f: Unknown result type (might be due to invalid IL or missing references) //IL_04b1: Unknown result type (might be due to invalid IL or missing references) //IL_04bd: Unknown result type (might be due to invalid IL or missing references) //IL_04df: Unknown result type (might be due to invalid IL or missing references) //IL_04e6: Expected O, but got Unknown //IL_0523: Unknown result type (might be due to invalid IL or missing references) //IL_0528: Unknown result type (might be due to invalid IL or missing references) //IL_052a: Unknown result type (might be due to invalid IL or missing references) CustomPiece val = new CustomPiece("agf_foundry", "blastfurnace", Config("Geothermal foundry", foundry: true)); GameObject piecePrefab = val.PiecePrefab; Vector3 localPosition = piecePrefab.transform.Find("add_ore").localPosition; Vector3 localPosition2 = piecePrefab.transform.Find("add_wood").localPosition; Smelter component = piecePrefab.GetComponent<Smelter>(); if (Object.op_Implicit((Object)(object)component.m_enabledObject)) { component.m_enabledObject.SetActive(false); } Switch[] componentsInChildren = piecePrefab.GetComponentsInChildren<Switch>(true); for (int i = 0; i < componentsInChildren.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren[i]); } Object.DestroyImmediate((Object)(object)component); SmokeSpawner[] componentsInChildren2 = piecePrefab.GetComponentsInChildren<SmokeSpawner>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { Object.DestroyImmediate((Object)(object)componentsInChildren2[i]); } ParticleSystem[] componentsInChildren3 = piecePrefab.GetComponentsInChildren<ParticleSystem>(true); for (int i = 0; i < componentsInChildren3.Length; i++) { ((Component)componentsInChildren3[i]).gameObject.SetActive(false); } AudioSource[] componentsInChildren4 = piecePrefab.GetComponentsInChildren<AudioSource>(true); for (int i = 0; i < componentsInChildren4.Length; i++) { ((Behaviour)componentsInChildren4[i]).enabled = false; } Light[] componentsInChildren5 = piecePrefab.GetComponentsInChildren<Light>(true); for (int i = 0; i < componentsInChildren5.Length; i++) { ((Behaviour)componentsInChildren5[i]).enabled = false; } Vector3 val2 = FoundryAppearance.RemoveWood(piecePrefab, metal); GameObject prefab = PrefabManager.Instance.GetPrefab("piece_chest_blackmetal"); if (!Object.op_Implicit((Object)(object)prefab)) { prefab = PrefabManager.Instance.GetPrefab("piece_chest_wood"); } Container component2 = prefab.GetComponent<Container>(); piecePrefab.AddComponent<FoundryBodyAccess>(); FoundryStorage foundryStorage = piecePrefab.AddComponent<FoundryStorage>(); foundryStorage.Input = AddStorage(piecePrefab, component2, "Geothermal — INPUT ore", Plugin.HopperRows.Value); foundryStorage.Output = AddStorage(piecePrefab, component2, "Geothermal — OUTPUT bars", Plugin.OutputRows.Value); ThermalNode thermalNode = piecePrefab.AddComponent<ThermalNode>(); thermalNode.Kind = NodeKind.Foundry; thermalNode.DisplayName = "Geothermal foundry"; ClearSnapPoints(piecePrefab); Vector3 val3 = default(Vector3); ((Vector3)(ref val3))..ctor(0f, 2.75f, 0f); Vector3[] array = (Vector3[])(object)new Vector3[4] { Vector3.left, Vector3.right, Vector3.back, Vector3.forward }; for (int j = 0; j < 4; j++) { Vector3 val4 = array[j]; Vector3 val5 = val3 + val4 * 2f; AddPort(piecePrefab, val5, val4, j); Tube(piecePrefab, val3 + val4 * 0.5f, val5, 0.18f, metal, "heat_socket"); Tube(piecePrefab, val3 + val4 * 1.75f, val3 + val4 * 1.9f, 0.23f, hot, "heat_glow_socket"); } Box(piecePrefab, new Vector3(0f, 0.2f, -1.2f), new Vector3(2.85f, 0.25f, 1.9f), metal, "front_bin_plinth"); Box(piecePrefab, new Vector3(0f, 0.65f, -0.8f), new Vector3(2.85f, 0.6f, 0.4f), metal, "front_bin_backplate"); Box(piecePrefab, new Vector3(0f, 0.65f, -1.55f), new Vector3(0.1f, 0.65f, 1.1f), metal, "front_bin_divider"); AccessBin(piecePrefab, foundryStorage.Input, new Vector3(-0.71f, 0.65f, -1.55f), "input", input: true); AccessBin(piecePrefab, foundryStorage.Output, new Vector3(0.71f, 0.65f, -1.55f), "output", input: false); Foundry foundry = piecePrefab.AddComponent<Foundry>(); foundry.WorkLight = new GameObject("foundry_heat_light").AddComponent<Light>(); ((Component)foundry.WorkLight).transform.SetParent(piecePrefab.transform, false); ((Component)foundry.WorkLight).transform.localPosition = new Vector3(0f, 1.3f, 0f); foundry.WorkLight.color = new Color(1f, 0.35f, 0.05f); foundry.WorkLight.range = 5f; foundry.WorkLight.intensity = 0f; AddGroundPipe(piecePrefab, localPosition, square: true); AddGroundPipe(piecePrefab, localPosition2, square: false); AddGroundPipe(piecePrefab, new Vector3((localPosition.x + localPosition2.x) * 0.5f, 0.66f, 1.55f), square: false, 0.24f); Vector3 val6 = default(Vector3); ((Vector3)(ref val6))..ctor(val2.x, 0f, val2.z); foreach (Transform item in piecePrefab.transform) { Transform val7 = item; if (!((Object)val7).name.StartsWith("heat_port_", StringComparison.Ordinal) && ((Object)val7).name != "heat_socket" && ((Object)val7).name != "heat_glow_socket") { val7.localPosition -= val6; } } Finish(piecePrefab, submerged: false); PieceManager.Instance.AddPiece(val); } private static void AddGroundPipe(GameObject root, Vector3 opening, bool square, float radius = 0.28f) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0058: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: 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_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_0104: 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_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: 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_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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0158: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: 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_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018c: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(metal); val.EnableKeyword("_EMISSION"); val.SetColor("_EmissionColor", Color.black); bool flag = radius >= 0.26f; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(opening.x, opening.y, flag ? 1.86f : 1.55f); if (square) { Box(root, new Vector3(opening.x, opening.y + 0.1f, 1.68f), new Vector3(1.04f, 1.05f, 0.36f), metal, "ground_pipe_square_adapter"); } else if (flag) { Tube(root, new Vector3(opening.x, opening.y + 0.1f, 1.5f), new Vector3(opening.x, opening.y + 0.1f, 1.86f), 0.54f, metal, "ground_pipe_round_adapter"); } else { Tube(root, val2 - Vector3.forward * 0.08f, val2 + Vector3.forward * 0.08f, radius * 1.18f, metal, "ground_pipe_round_adapter"); } float num = ((radius < 0.26f) ? 1.05f : 0.65f); PipeGeometry.Add(root, (Vector3[])(object)new Vector3[3] { val2 - Vector3.forward * 0.1f, val2 + Vector3.forward * num, new Vector3(val2.x, -0.6f, val2.z + num) }, radius, val, "heat_glow_ground_return"); } private static Container AddStorage(GameObject root, Container source, string name, int rows) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) Container obj = root.AddComponent<Container>(); obj.m_name = name; obj.m_width = 8; obj.m_height = rows; obj.m_bkg = source.m_bkg; obj.m_checkGuardStone = true; obj.m_privacy = source.m_privacy; obj.m_destroyedLootPrefab = source.m_destroyedLootPrefab; obj.m_openEffects = source.m_openEffects; obj.m_closeEffects = source.m_closeEffects; return obj; } private static void AccessBin(GameObject root, Container target, Vector3 position, string name, bool input) { //IL_0001: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown Box(root, position, new Vector3(1.32f, 0.65f, 1.1f), metal, "agf_" + name + "_bin"); ((Component)root.transform.Find("agf_" + name + "_bin")).gameObject.AddComponent<StorageAccess>().Target = target; Box(root, position + new Vector3(-0.15f, 0.35f, 0f), new Vector3(0.08f, 0.08f, 0.6f), hot, "heat_glow_" + name + "_marker"); if (!input) { Box(root, position + new Vector3(0.15f, 0.35f, 0f), new Vector3(0.08f, 0.08f, 0.6f), hot, "heat_glow_output_marker2"); } foreach (Transform item in root.transform) { Transform val = item; if (((Object)val).name.StartsWith("heat_glow_" + name + "_marker", StringComparison.Ordinal)) { Object.DestroyImmediate((Object)(object)((Component)val).GetComponent<Collider>()); } } } private static void RegisterPipe(string id, string name, NodeKind kind, Vector3[] directions) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_00cd: 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_00d5: 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_00f1: 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_00fd: 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_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: 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_01f0: Unknown result type (might be due to invalid IL or missing references) CustomPiece val = new CustomPiece(id, "stone_floor_2x2", Config(name, foundry: false, kind == NodeKind.Probe)); GameObject piecePrefab = val.PiecePrefab; Transform[] array = ((IEnumerable)piecePrefab.transform).Cast<Transform>().ToArray(); for (int i = 0; i < array.Length; i++) { Object.DestroyImmediate((Object)(object)((Component)array[i]).gameObject); } Collider[] components = piecePrefab.GetComponents<Collider>(); for (int i = 0; i < components.Length; i++) { Object.DestroyImmediate((Object)(object)components[i]); } ThermalNode thermalNode = piecePrefab.AddComponent<ThermalNode>(); thermalNode.Kind = kind; thermalNode.DisplayName = name; WearNTear component = piecePrefab.GetComponent<WearNTear>(); component.m_new = null; component.m_worn = null; component.m_broken = null; component.m_wet = null; component.m_snow = null; component.m_snowWorn = null; component.m_snowBroken = null; component.m_fragmentRoots = Array.Empty<GameObject>(); component.m_autoCreateFragments = false; for (int j = 0; j < directions.Length; j++) { Vector3 val2 = directions[j]; Tube(piecePrefab, Vector3.zero, val2, 0.14f, metal, "conduit"); Tube(piecePrefab, val2 * 0.8f, val2 * 0.95f, 0.2f, hot, "heat_glow_collar"); AddPort(piecePrefab, val2, val2, j); } Box(piecePrefab, Vector3.zero, Vector3.one * 0.42f, metal, "junction_hub"); if (kind == NodeKind.Probe) { Tube(piecePrefab, Vector3.zero, new Vector3(0f, -4f, 0f), 0.21f, metal, "lava_rod"); Tube(piecePrefab, new Vector3(0f, -3.7f, 0f), new Vector3(0f, -4f, 0f), 0.24f, hot, "heat_glow_probe_tip"); Box(piecePrefab, new Vector3(0f, -0.18f, 0f), new Vector3(0.8f, 0.25f, 0.8f), metal, "probe_mount"); } Finish(piecePrefab, submerged: true); PieceManager.Instance.AddPiece(val); } private static void Finish(GameObject root, bool submerged) { //IL_0056: 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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_011b: 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_0135: Expected O, but got Unknown Piece component = root.GetComponent<Piece>(); component.m_groundOnly = false; component.m_groundPiece = false; component.m_noInWater = false; component.m_clipGround = submerged; component.m_canRotate = true; component.m_notOnWood = false; component.m_notOnTiltingSurface = false; component.m_inCeilingOnly = false; component.m_notOnFloor = false; component.m_mustConnectTo = null; component.m_onlyInTeleportArea = false; component.m_onlyInBiome = (Biome)0; component.m_cultivatedGroundOnly = false; component.m_vegetationGroundOnly = false; component.m_requireDeepSnow = false; component.m_usage = (UsageTagFlags)2; component.m_noClipping = false; WearNTear component2 = root.GetComponent<WearNTear>(); component2.m_ashDamageImmune = true; component2.m_burnable = false; component2.m_noRoofWear = false; component2.m_noSupportWear = true; component2.m_health = 2000f; root.GetComponent<ZNetView>().m_persistent = true; Collider[] componentsInChildren = root.GetComponentsInChildren<Collider>(true); for (int i = 0; i < componentsInChildren.Length; i++) { ((Component)componentsInChildren[i]).gameObject.layer = LayerMask.NameToLayer("piece"); } Sprite val = RenderManager.Instance.Render(new RenderRequest(root) { Width = 128, Height = 128, UseCache = false, Rotation = Quaternion.Euler(20f, 35f, 0f), DistanceMultiplier = 1.15f }); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("Could not render build icon for " + ((Object)root).name); } component.m_icon = val; } private static void ClearSnapPoints(GameObject root) { Transform[] array = (from Transform t in (IEnumerable)root.transform where ((Component)t).CompareTag("snappoint") select t).ToArray(); for (int num = 0; num < array.Length; num++) { Object.DestroyImmediate((Object)(object)((Component)array[num]).gameObject); } } private static void AddPort(GameObject root, Vector3 position, Vector3 direction, int number) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) Transform transform = new GameObject("heat_port_" + number).transform; transform.SetParent(root.transform, false); transform.localPosition = position; transform.localRotation = Quaternion.LookRotation(direction, (Mathf.Abs(direction.y) > 0.9f) ? Vector3.forward : Vector3.up); ((Component)transform).gameObject.tag = "snappoint"; } internal static void Tube(GameObject root, Vector3 a, Vector3 b, float radius, Material material, string name) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0028: 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_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_006d: 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_0081: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)obj).name = name; obj.transform.SetParent(root.transform, false); obj.transform.localPosition = (a + b) / 2f; Transform transform = obj.transform; Vector3 up = Vector3.up; Vector3 val = b - a; transform.localRotation = Quaternion.FromToRotation(up, ((Vector3)(ref val)).normalized); obj.transform.localScale = new Vector3(radius * 2f, Vector3.Distance(a, b) / 2f, radius * 2f); obj.GetComponent<Renderer>().sharedMaterial = material; } internal static void Box(GameObject root, Vector3 position, Vector3 size, Material material, string name) { //IL_0026: 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) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = name; obj.transform.SetParent(root.transform, false); obj.transform.localPosition = position; obj.transform.localScale = size; obj.GetComponent<Renderer>().sharedMaterial = material; } } internal static class PipeGeometry { internal static void Add(GameObject root, Vector3[] corners, float radius, Material material, string name) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0073: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_013c: 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_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_0187: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0190: 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_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_00fd: 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_0109: 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_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: 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_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: 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_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_02f0: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Expected O, but got Unknown //IL_0330: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_0347: 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_0228: 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_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) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) List<Vector3> list = new List<Vector3> { corners[0] }; Vector3 val2; for (int i = 1; i < corners.Length - 1; i++) { Vector3 val = corners[i]; float num = Mathf.Min(radius * 1.5f, Mathf.Min(Vector3.Distance(val, corners[i - 1]), Vector3.Distance(val, corners[i + 1])) * 0.45f); val2 = corners[i - 1] - val; Vector3 val3 = val + ((Vector3)(ref val2)).normalized * num; val2 = corners[i + 1] - val; Vector3 val4 = val + ((Vector3)(ref val2)).normalized * num; list.Add(val3); for (int j = 1; j <= 8; j++) { float num2 = (float)j / 8f; list.Add((1f - num2) * (1f - num2) * val3 + 2f * (1f - num2) * num2 * val + num2 * num2 * val4); } } list.Add(corners[^1]); List<Vector3> list2 = new List<Vector3>(); List<Vector2> list3 = new List<Vector2>(); List<int> list4 = new List<int>(); val2 = Vector3.Cross(corners[1] - corners[0], corners[^1] - corners[1]); Vector3 val5 = ((Vector3)(ref val2)).normalized; if (((Vector3)(ref val5)).sqrMagnitude < 0.5f) { val5 = Vector3.right; } for (int k = 0; k < list.Count; k++) { val2 = list[Mathf.Min(k + 1, list.Count - 1)] - list[Mathf.Max(k - 1, 0)]; val2 = Vector3.Cross(((Vector3)(ref val2)).normalized, val5); Vector3 normalized = ((Vector3)(ref val2)).normalized; for (int l = 0; l < 12; l++) { float num3 = (float)l * MathF.PI * 2f / 12f; list2.Add(list[k] + radius * (Mathf.Cos(num3) * val5 + Mathf.Sin(num3) * normalized)); list3.Add(new Vector2((float)l / 12f, (float)k / (float)(list.Count - 1))); if (k > 0) { int num4 = (k - 1) * 12 + l; int num5 = (l + 1) % 12; list4.AddRange(new int[6] { num4, k * 12 + num5, k * 12 + l, num4, (k - 1) * 12 + num5, k * 12 + num5 }); } } } Mesh val6 = new Mesh { name = name }; val6.SetVertices(list2); val6.SetUVs(0, list3); val6.SetTriangles(list4, 0); val6.RecalculateNormals(); val6.RecalculateBounds(); val6.RecalculateTangents(); GameObject val7 = new GameObject(name); val7.transform.SetParent(root.transform, false); val7.AddComponent<MeshFilter>().sharedMesh = val6; ((Renderer)val7.AddComponent<MeshRenderer>()).sharedMaterial = material; } } [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] internal static class PlacementDiagnostics { private static string last; private static float next; private static void Postfix(Player __instance, GameObject ___m_placementGhost) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)___m_placementGhost) && Object.op_Implicit((Object)(object)___m_placementGhost.GetComponent<ThermalNode>()) && !(Time.unscaledTime < next)) { next = Time.unscaledTime + 1f; Piece component = ___m_placementGhost.GetComponent<Piece>(); string text = $"Placement {((Object)component).name}: {__instance.GetPlacementStatus()}; nocost={__instance.NoCostCheat()}; " + $"slopeRestricted={component.m_notOnTiltingSurface}; clippingRestricted={component.m_noClipping}; " + "requiredConnection=" + (Object.op_Implicit((Object)(object)component.m_mustConnectTo) ? ((Object)component.m_mustConnectTo).name : "none"); if (!(text == last)) { last = text; Plugin.LogInfo(text); } } } } [BepInPlugin("local.ashlands.geothermalfoundry", "Ashlands Geothermal Foundry", "0.2.8")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string Guid = "local.ashlands.geothermalfoundry"; public const string Version = "0.2.8"; internal static Plugin Instance; internal static ConfigEntry<int> HopperRows; internal static ConfigEntry<int> OutputRows; internal static ConfigEntry<int> OutputLimit; internal static ConfigEntry<int> FurnacesPerProbe; internal static ConfigEntry<float> SecondsPerBar; private Harmony harmony; private void Awake() { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Expected O, but got Unknown //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Expected O, but got Unknown //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Expected O, but got Unknown Instance = this; HopperRows = ((BaseUnityPlugin)this).Config.Bind<int>("Foundry", "HopperRows", 10, new ConfigDescription("Input hopper rows, 8 columns. Restart required. Do not shrink populated hoppers.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(4, 20), Array.Empty<object>())); OutputRows = ((BaseUnityPlugin)this).Config.Bind<int>("Foundry", "OutputRows", 10, new ConfigDescription("Separate output storage rows, 8 columns. Restart required. Do not shrink populated bins.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(4, 20), Array.Empty<object>())); OutputLimit = ((BaseUnityPlugin)this).Config.Bind<int>("Foundry", "OutputBarLimit", 1000, new ConfigDescription("Pause at this many finished bars in the hopper.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10000), Array.Empty<object>())); SecondsPerBar = ((BaseUnityPlugin)this).Config.Bind<float>("Foundry", "SecondsPerBar", 10f, new ConfigDescription("Seconds per bar at full heat.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 120f), Array.Empty<object>())); FurnacesPerProbe = ((BaseUnityPlugin)this).Config.Bind<int>("Heat", "FoundriesPerProbe", 4, new ConfigDescription("Each submerged probe supplies this many connected foundries at full speed. Extra foundries share heat equally.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>())); harmony = new Harmony("local.ashlands.geothermalfoundry"); harmony.PatchAll(); PrefabManager.OnVanillaPrefabsAvailable += Register; ((Component)this).gameObject.AddComponent<HeatNetwork>(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Geothermal Foundry 0.2.8 loaded. Pieces use the native Crafting filter. Prototype; use matching configs on all peers."); } private void Register() { PrefabManager.OnVanillaPrefabsAvailable -= Register; try { Pieces.Register(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Registered geothermal foundry, probe and four conduit pieces."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Geothermal piece registration failed: " + ex)); } } internal static void Error(Exception ex) { ((BaseUnityPlugin)Instance).Logger.LogError((object)ex); } internal static void LogInfo(string message) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)message); } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= Register; Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } internal static class ProcessingInventory { internal static bool TryConvert(Inventory input, Inventory output, ItemData ore, ItemData bar, out Inventory stagedInput, out Inventory stagedOutput) { stagedInput = Clone(input); stagedOutput = Clone(output); int num = input.GetAllItems().IndexOf(ore); if (num < 0 || !stagedInput.RemoveItem(stagedInput.GetAllItems()[num], 1)) { return false; } ItemData val = bar.Clone(); val.m_stack = 1; if (stagedOutput.CanAddItem(val, 1)) { return stagedOutput.AddItem(val); } return false; } internal static void MoveMatching(Inventory input, Inventory output, Func<ItemData, bool> match) { ItemData[] array = input.GetAllItems().ToArray(); foreach (ItemData val in array) { if (match(val)) { Inventory val2 = Clone(output); ItemData val3 = val.Clone(); if (val2.CanAddItem(val3, val3.m_stack) && val2.AddItem(val3)) { input.RemoveItem(val); output.GetAllItems().Clear(); output.GetAllItems().AddRange(val2.GetAllItems()); } } } } internal static Inventory Clone(Inventory source) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Expected O, but got Unknown Inventory val = new Inventory("Geothermal transaction", (Sprite)null, source.GetWidth(), source.GetHeight()); foreach (ItemData allItem in source.GetAllItems()) { if (allItem == null || allItem.m_shared == null) { throw new InvalidOperationException("Hopper contains an uninitialized item; conversion cancelled without changing its contents."); } val.GetAllItems().Add(allItem.Clone()); } return val; } } } namespace AshlandsGeothermalFoundry.Core { internal static class AppearanceRules { internal static bool ValidBodySize(float x, float y, float z) { if (x > 1f && x < 8f && y > 3f && y < 12f && z > 1f) { return z < 8f; } return false; } } internal static class FurnaceOpeningBounds { internal static readonly int[][] Groups = new int[5][] { new int[120] { 1128, 1129, 1130, 1131, 1132, 1133, 1134, 1135, 1136, 1137, 1138, 1139, 1140, 1141, 1142, 1143, 1144, 1145, 1146, 1147, 1148, 1149, 1150, 1151, 1152, 1153, 1154, 1155, 1156, 1157, 1158, 1159, 1160, 1161, 1162, 1163, 1164, 1165, 1166, 1167, 1168, 1169, 1170, 1171, 1172, 1173, 1174, 1175, 1176, 1177, 1178, 1179, 1180, 1181, 1182, 1183, 1184, 1185, 1186, 1187, 1188, 11