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 MonkeAutoKiln v0.3.1
BepInEx/plugins/MonkeAutoKiln/MonkeAutoKiln.dll
Decompiled a day agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyInformationalVersion("0.3.1")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("0.3.1.0")] namespace Monke.AutoKiln; [BepInPlugin("monke.valheim.autokiln", "Monke Auto Kiln - Gravity Wood Rack", "0.3.1")] [BepInDependency("com.jotunn.jotunn", "2.30.2")] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class AutoKilnPlugin : BaseUnityPlugin { public const string Id = "monke.valheim.autokiln"; public const string Version = "0.3.1"; public const string PrefabName = "Monke_AutoKiln_Rack"; public const int StorageSlots = 6; public const int NominalWoodCapacity = 300; internal static AutoKilnPlugin Instance; internal ConfigEntry<int> CoreWoodCost; internal ConfigEntry<int> StoneCost; internal ConfigEntry<int> CopperCost; internal ConfigEntry<int> SurtlingCoreCost; private GameObject customPrefab; private bool registered; private void Awake() { //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown Instance = this; try { RackApi.Validate(); CoreWoodCost = Cost("CoreWood", 20); StoneCost = Cost("Stone", 30); CopperCost = Cost("Copper", 5); SurtlingCoreCost = Cost("SurtlingCore", 2); ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("Internal", "CopperCost031Applied", false, new ConfigDescription("One-time migration for the Copper-five recipe update.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes { Browsable = false } })); if (!val.Value) { CopperCost.Value = 5; val.Value = true; } CoreWoodCost.SettingChanged += RecipeChanged; StoneCost.SettingChanged += RecipeChanged; CopperCost.SettingChanged += RecipeChanged; SurtlingCoreCost.SettingChanged += RecipeChanged; RegisterTranslations(); PrefabManager.OnVanillaPrefabsAvailable += RegisterPiece; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Auto Kiln 0.3.1 loaded: tall rear gravity rack, six Wood slots, vanilla front Coal output."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Auto Kiln initialization failed: " + ex)); } } private ConfigEntry<int> Cost(string item, int amount) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Expected O, but got Unknown //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Expected O, but got Unknown return ((BaseUnityPlugin)this).Config.Bind<int>("BuildCost", item, amount, new ConfigDescription("Building cost. Zero omits this ingredient. Host/admin value is synchronized by Jotunn.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 9999), new object[1] { (object)new ConfigurationManagerAttributes { IsAdminOnly = true } })); } private void RecipeChanged(object sender, EventArgs args) { if (!Object.op_Implicit((Object)(object)customPrefab)) { return; } try { ApplyRecipe(customPrefab.GetComponent<Piece>()); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Could not apply synchronized build recipe: " + ex)); } } private void ApplyRecipe(Piece piece) { List<Requirement> list = new List<Requirement>(); AddCost(list, "RoundLog", CoreWoodCost.Value); AddCost(list, "Stone", StoneCost.Value); AddCost(list, "Copper", CopperCost.Value); AddCost(list, "SurtlingCore", SurtlingCoreCost.Value); piece.m_resources = list.ToArray(); } private static void AddCost(List<Requirement> list, string prefab, int amount) { //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_0048: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown if (amount != 0) { GameObject prefab2 = PrefabManager.Instance.GetPrefab(prefab); if (!Object.op_Implicit((Object)(object)prefab2) || !Object.op_Implicit((Object)(object)prefab2.GetComponent<ItemDrop>())) { throw new InvalidOperationException("Recipe item unavailable: " + prefab); } list.Add(new Requirement { m_resItem = prefab2.GetComponent<ItemDrop>(), m_amount = amount, m_recover = true }); } } private void RegisterTranslations() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; string text2 = "monke_autokiln_name"; localization.AddTranslation(ref text, ref text2, "Auto Kiln"); text = "English"; text2 = "monke_autokiln_description"; localization.AddTranslation(ref text, ref text2, "A kiln with a tall gravity-fed rear wood rack. Six storage slots (normally 300 Wood). Put ordinary Wood in the rack; Coal drops at the front."); text = "English"; text2 = "monke_autokiln_rack"; localization.AddTranslation(ref text, ref text2, "Auto Kiln - Wood Storage (6 slots)"); text = "Thai"; text2 = "monke_autokiln_name"; localization.AddTranslation(ref text, ref text2, "เตาเผาถ\u0e48านอ\u0e31ตโนม\u0e31ต\u0e34"); text = "Thai"; text2 = "monke_autokiln_description"; localization.AddTranslation(ref text, ref text2, "ร\u0e31งไม\u0e49ส\u0e39งด\u0e49านหล\u0e31งพร\u0e49อมรางป\u0e49อนอ\u0e31ตโนม\u0e31ต\u0e34 เก\u0e47บ 6 ช\u0e48อง (ปกต\u0e34 300 Wood) ใส\u0e48 Wood ในร\u0e31ง ถ\u0e48านตกหน\u0e49าเตา"); text = "Thai"; text2 = "monke_autokiln_rack"; localization.AddTranslation(ref text, ref text2, "Auto Kiln - ร\u0e31งไม\u0e49 6 ช\u0e48อง"); } private void RegisterPiece() { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Expected O, but got Unknown if (registered) { return; } PrefabManager.OnVanillaPrefabsAvailable -= RegisterPiece; try { GameObject prefab = PrefabManager.Instance.GetPrefab("charcoal_kiln"); GameObject prefab2 = PrefabManager.Instance.GetPrefab("piece_chest_wood"); if (!Object.op_Implicit((Object)(object)prefab) || !Object.op_Implicit((Object)(object)prefab2) || !Object.op_Implicit((Object)(object)PrefabManager.Instance.GetPrefab("Wood"))) { throw new InvalidOperationException("Required vanilla kiln/chest/Wood prefab unavailable."); } GameObject val = PrefabManager.Instance.CreateClonedPrefab("Monke_AutoKiln_Rack", prefab); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("Could not clone custom kiln prefab."); } if (val.activeInHierarchy) { throw new InvalidOperationException("Prefab unexpectedly active before configuration."); } Piece component = val.GetComponent<Piece>(); Smelter component2 = val.GetComponent<Smelter>(); component.m_name = "$monke_autokiln_name"; component.m_description = "$monke_autokiln_description"; component.m_usage = (UsageTagFlags)2; ApplyRecipe(component); component2.m_name = "$monke_autokiln_name"; Container component3 = prefab2.GetComponent<Container>(); Container obj = val.AddComponent<Container>(); obj.m_name = "$monke_autokiln_rack"; obj.m_width = 6; obj.m_height = 1; obj.m_privacy = (PrivacySetting)2; obj.m_checkGuardStone = true; obj.m_bkg = component3.m_bkg; obj.m_openEffects = component3.m_openEffects; obj.m_closeEffects = component3.m_closeEffects; obj.m_autoDestroyEmpty = false; obj.m_rootObjectOverride = null; obj.m_destroyedLootPrefab = null; RackModel.Model model = RackModel.Build(val, component2); val.AddComponent<RackController>().Configure(model.Logs, model.MovingLog); CustomPiece val2 = new CustomPiece(val, "Hammer", false); val2.Usage = new string[1] { "Crafting" }; if (!PieceManager.Instance.AddPiece(val2)) { throw new InvalidOperationException("Could not register kiln in Hammer build menu."); } customPrefab = val; registered = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"Auto Kiln ready: Monke_AutoKiln_Rack registered, tall rack / 6 slots / animated chute / front Coal drops."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("Auto Kiln piece registration failed: " + ex)); } } internal static void Error(Exception e) { if (Object.op_Implicit((Object)(object)Instance)) { ((BaseUnityPlugin)Instance).Logger.LogError((object)("Automatic feeding paused for this kiln after an error: " + e)); } } private void OnDestroy() { PrefabManager.OnVanillaPrefabsAvailable -= RegisterPiece; if (CoreWoodCost != null) { CoreWoodCost.SettingChanged -= RecipeChanged; } if (StoneCost != null) { StoneCost.SettingChanged -= RecipeChanged; } if (CopperCost != null) { CopperCost.SettingChanged -= RecipeChanged; } if (SurtlingCoreCost != null) { SurtlingCoreCost.SettingChanged -= RecipeChanged; } Instance = null; } } internal static class RackApi { internal static readonly MethodInfo Load = Require(typeof(Container), "Load", Type.EmptyTypes); internal static readonly MethodInfo Size = Require(typeof(Smelter), "GetQueueSize", Type.EmptyTypes); internal static readonly MethodInfo Queue = Require(typeof(Smelter), "QueueOre", new Type[2] { typeof(string), typeof(bool) }); private static MethodInfo Require(Type type, string name, Type[] args) { MethodInfo? method = type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, args, null); if (method == null) { throw new MissingMethodException(type.Name, name); } return method; } internal static void Validate() { if (Load == null || Size == null || Queue == null) { throw new MissingMemberException("Valheim API changed."); } } internal static int QueueSize(Smelter s) { return (int)Size.Invoke(s, null); } internal static int CountWood(Inventory inv) { int num = 0; foreach (ItemData allItem in inv.GetAllItems()) { if (IsWood(allItem)) { num += allItem.m_stack; } } return num; } internal static bool IsWood(ItemData item) { if (item != null && Object.op_Implicit((Object)(object)item.m_dropPrefab)) { return ((Object)item.m_dropPrefab).name == "Wood"; } return false; } internal static bool HasWoodRecipe(Smelter kiln) { foreach (ItemConversion item in kiln.m_conversion) { if (Object.op_Implicit((Object)(object)item.m_from) && Object.op_Implicit((Object)(object)item.m_to) && ((Object)((Component)item.m_from).gameObject).name == "Wood" && ((Object)((Component)item.m_to).gameObject).name == "Coal") { return true; } } return false; } } public sealed class RackController : MonoBehaviour { internal const string FeedSerialKey = "monke_autokiln_feed_serial_v1"; [SerializeField] private Transform[] visualLogs = (Transform[])(object)new Transform[0]; [SerializeField] private Transform movingLog; private Smelter kiln; private Container rack; private ZNetView view; private float nextTick; private bool faulted; private bool serialInitialized; private int lastSerial; private int pendingSlides; private float slideStart = -1f; internal void Configure(Transform[] logs, Transform animated) { visualLogs = logs; movingLog = animated; } private void Awake() { kiln = ((Component)this).GetComponent<Smelter>(); rack = ((Component)this).GetComponent<Container>(); view = ((Component)this).GetComponent<ZNetView>(); nextTick = Time.time + 1f; } private void Update() { if (!Object.op_Implicit((Object)(object)view) || !view.IsValid() || !Object.op_Implicit((Object)(object)kiln) || !Object.op_Implicit((Object)(object)rack)) { return; } try { int num = view.GetZDO().GetInt("monke_autokiln_feed_serial_v1", 0); if (!serialInitialized) { lastSerial = num; serialInitialized = true; } if (Time.time >= nextTick) { nextTick = Time.time + 1f; RackApi.Load.Invoke(rack, null); Inventory inventory = rack.GetInventory(); if (inventory != null) { if (!faulted && view.IsOwner() && !rack.IsInUse()) { int num2 = Feed(inventory); if (num2 > 0) { view.GetZDO().Set("monke_autokiln_feed_serial_v1", num + num2); } } UpdateLogs(RackApi.CountWood(inventory)); } } ObserveFeedSerial(view.GetZDO().GetInt("monke_autokiln_feed_serial_v1", 0)); AnimateSlide(); } catch (Exception e) { faulted = true; AutoKilnPlugin.Error(e); } } private int Feed(Inventory inventory) { if (!RackApi.HasWoodRecipe(kiln)) { return 0; } int num = 0; int num2 = Math.Min(5, Math.Max(0, kiln.m_maxOre - RackApi.QueueSize(kiln))); for (int i = 0; i < num2 && view.IsOwner() && !rack.IsInUse(); i++) { ItemData val = null; foreach (ItemData allItem in inventory.GetAllItems()) { if (RackApi.IsWood(allItem)) { val = allItem; break; } } if (val == null) { break; } int num3 = RackApi.QueueSize(kiln); if (num3 >= kiln.m_maxOre) { break; } int num4 = RackApi.CountWood(inventory); ItemData val2 = val.Clone(); val2.m_stack = 1; try { if (!inventory.RemoveItem(val, 1)) { break; } RackApi.Queue.Invoke(kiln, new object[2] { "Wood", val2.m_cheated }); num++; continue; } catch { if (RackApi.QueueSize(kiln) == num3 && RackApi.CountWood(inventory) == num4 - 1) { inventory.AddItem(val2); } throw; } } return num; } private void UpdateLogs(int wood) { int num = 300; int num2 = ((wood > 0) ? Math.Min(visualLogs.Length, (wood * visualLogs.Length + num - 1) / num) : 0); for (int i = 0; i < visualLogs.Length; i++) { if (Object.op_Implicit((Object)(object)visualLogs[i]) && ((Component)visualLogs[i]).gameObject.activeSelf != i < num2) { ((Component)visualLogs[i]).gameObject.SetActive(i < num2); } } } private void ObserveFeedSerial(int serial) { int num = serial - lastSerial; lastSerial = serial; if (num > 0 && num < 128) { pendingSlides = Math.Min(8, pendingSlides + num); } } private void AnimateSlide() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)movingLog)) { return; } if (slideStart < 0f && pendingSlides > 0) { pendingSlides--; slideStart = Time.time; ((Component)movingLog).gameObject.SetActive(true); } if (!(slideStart < 0f)) { float num = Mathf.Clamp01((Time.time - slideStart) / 0.55f); movingLog.localPosition = Vector3.Lerp(RackModel.SlideTop, RackModel.SlideBottom, num * num); movingLog.localRotation = Quaternion.Euler(num * 540f, 0f, 0f); if (num >= 1f) { ((Component)movingLog).gameObject.SetActive(false); slideStart = -1f; } } } } internal static class RackModel { internal sealed class Model { internal Transform[] Logs; internal Transform MovingLog; } internal static readonly Vector3 SlideTop = new Vector3(0f, 3.14f, 1.18f); internal static readonly Vector3 SlideBottom = new Vector3(0f, 0.88f, -0.46f); internal static Model Build(GameObject kiln, Smelter smelter) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: Invalid comparison between Unknown and I4 //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: 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_0144: 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_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_0207: 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_0237: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0241: Unknown result type (might be due to invalid IL or missing references) //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025e: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: 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_03f8: Unknown result type (might be due to invalid IL or missing references) //IL_040c: Unknown result type (might be due to invalid IL or missing references) //IL_0353: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_03a0: Unknown result type (might be due to invalid IL or missing references) //IL_03b4: Unknown result type (might be due to invalid IL or missing references) //IL_045a: Unknown result type (might be due to invalid IL or missing references) //IL_046e: Unknown result type (might be due to invalid IL or missing references) //IL_04a3: Unknown result type (might be due to invalid IL or missing references) //IL_04b7: Unknown result type (might be due to invalid IL or missing references) //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_0501: Unknown result type (might be due to invalid IL or missing references) //IL_0543: Unknown result type (might be due to invalid IL or missing references) //IL_0548: 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_054f: Unknown result type (might be due to invalid IL or missing references) //IL_0554: Unknown result type (might be due to invalid IL or missing references) //IL_0556: Unknown result type (might be due to invalid IL or missing references) //IL_0587: 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_05a4: Unknown result type (might be due to invalid IL or missing references) //IL_05a9: Unknown result type (might be due to invalid IL or missing references) //IL_05c1: Unknown result type (might be due to invalid IL or missing references) //IL_05c6: Unknown result type (might be due to invalid IL or missing references) //IL_0601: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Unknown result type (might be due to invalid IL or missing references) //IL_070d: Unknown result type (might be due to invalid IL or missing references) //IL_06b9: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("RearWoodRack"); val.layer = LayerMask.NameToLayer("piece"); val.transform.SetParent(kiln.transform, false); Vector3 val2 = kiln.transform.InverseTransformPoint(smelter.m_outputPoint.position); val2.y = 0f; if (((Vector3)(ref val2)).sqrMagnitude < 0.01f) { val2 = Vector3.forward; } Vector3 val3 = -((Vector3)(ref val2)).normalized; val.transform.localPosition = val3 * 1.28f; val.transform.localRotation = Quaternion.LookRotation(val3, Vector3.up); bool flag = (int)SystemInfo.graphicsDeviceType == 4; Material material = null; Material bark = null; Material endGrain = null; Material material2 = null; if (!flag) { Shader shader = PieceShader(); Texture2D texture = WoodGrain(); material = OpaqueMaterial(shader, "AutoKiln_BlackTimber", (Texture)(object)texture, new Color(1f, 1f, 1f, 1f), 0f, 0.08f); bark = OpaqueMaterial(shader, "AutoKiln_BlackBark", (Texture)(object)texture, new Color(0.76f, 0.78f, 0.8f, 1f), 0f, 0.04f); endGrain = OpaqueMaterial(shader, "AutoKiln_DarkCutEnds", (Texture)(object)texture, new Color(1.35f, 1.32f, 1.26f, 1f), 0f, 0.06f); material2 = OpaqueMaterial(shader, "AutoKiln_DarkBands", (Texture)(object)Texture2D.whiteTexture, new Color(0.16f, 0.135f, 0.1f, 1f), 0.55f, 0.2f); } float[] array; for (int i = -1; i <= 1; i += 2) { Beam(val.transform, "RearUpright", new Vector3((float)i * 1.04f, 1.77f, 1.4f), new Vector3(0.24f, 3.54f, 0.24f), material); Beam(val.transform, "FrontSupport", new Vector3((float)i * 1.04f, 0.58f, -0.39f), new Vector3(0.24f, 1.16f, 0.24f), material); Between(val.transform, "SlopingSideRail", SlideBottom + new Vector3((float)i * 1.04f, 0.1f, 0f), SlideTop + new Vector3((float)i * 1.04f, 0.18f, 0.1f), 0.22f, 0.25f, material); Between(val.transform, "LowerCrossBrace", new Vector3((float)i * 1.1f, 0.31f, -0.36f), new Vector3((float)i * 1.1f, 2.78f, 1.42f), 0.13f, 0.14f, material); for (int j = 0; j < 3; j++) { Beam(val.transform, "LowerSidePanel", new Vector3((float)i * 1.04f, 0.38f + (float)j * 0.25f, 0.52f), new Vector3(0.13f, 0.2f, 1.65f), material); } array = new float[3] { 0.38f, 1.76f, 3.25f }; foreach (float num in array) { Beam(val.transform, "RearPostBand", new Vector3((float)i * 1.04f, num, 1.4f), new Vector3(0.268f, 0.12f, 0.268f), material2); } Beam(val.transform, "FrontPostBand", new Vector3((float)i * 1.04f, 0.83f, -0.39f), new Vector3(0.268f, 0.12f, 0.268f), material2); } for (int l = 0; l < 6; l++) { Beam(val.transform, "BackBoard", new Vector3(-0.84f + (float)l * 0.336f, 1.86f, 1.42f), new Vector3(0.305f, 3.12f, 0.13f), material); } array = new float[3] { 0.42f, 1.91f, 3.43f }; foreach (float num2 in array) { Beam(val.transform, "BackCrossBeam", new Vector3(0f, num2, 1.51f), new Vector3(2.3f, 0.19f, 0.2f), material); } Beam(val.transform, "FrontCrossBeam", new Vector3(0f, 0.69f, -0.4f), new Vector3(2.3f, 0.2f, 0.22f), material); for (int m = 0; m < 6; m++) { Beam(val.transform, "RackFloor", new Vector3(-0.84f + (float)m * 0.336f, 0.29f, 0.52f), new Vector3(0.3f, 0.12f, 1.78f), material); } Vector3 val4 = default(Vector3); for (int n = -1; n <= 1; n++) { ((Vector3)(ref val4))..ctor((float)n * 0.55f, -0.2f, 0f); Between(val.transform, "ChutePlank", SlideTop + val4, SlideBottom + val4, 0.52f, 0.12f, material); } for (int num3 = -1; num3 <= 1; num3 += 2) { Between(val.transform, "ChuteGuide", SlideTop + new Vector3((float)num3 * 0.89f, 0f, 0f), SlideBottom + new Vector3((float)num3 * 0.89f, 0f, 0f), 0.15f, 0.28f, material); } Beam(val.transform, "FeederMouth", new Vector3(0f, 0.73f, -0.48f), new Vector3(1.94f, 0.16f, 0.5f), material); if (flag) { return new Model { Logs = (Transform[])(object)new Transform[0], MovingLog = null }; } List<Transform> list = new List<Transform>(); for (int num4 = 0; num4 < 6; num4++) { for (int num5 = 0; num5 < 2; num5++) { Transform val5 = Log(val.transform, "StoredWood_" + list.Count, bark, endGrain); val5.localPosition = new Vector3(0f, 1f + (float)num4 * 0.37f + (float)num5 * 0.15f, -0.26f + (float)num4 * 0.24f + (float)num5 * 0.2f); ((Component)val5).gameObject.SetActive(false); list.Add(val5); } } Transform val6 = Log(val.transform, "SlidingWood_VisualOnly", bark, endGrain); val6.localPosition = SlideTop; ((Component)val6).gameObject.SetActive(false); return new Model { Logs = list.ToArray(), MovingLog = val6 }; } private static Shader PieceShader() { Shader val = Shader.Find("Custom/Piece"); if (Object.op_Implicit((Object)(object)val)) { return val; } string[] array = new string[4] { "wood_beam", "wood_pole", "piece_chest_wood", "charcoal_kiln" }; foreach (string text in array) { GameObject prefab = PrefabManager.Instance.GetPrefab(text); if (!Object.op_Implicit((Object)(object)prefab)) { continue; } MeshRenderer[] componentsInChildren = prefab.GetComponentsInChildren<MeshRenderer>(true); for (int j = 0; j < componentsInChildren.Length; j++) { Material[] sharedMaterials = ((Renderer)componentsInChildren[j]).sharedMaterials; foreach (Material val2 in sharedMaterials) { if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val2.shader) && ((Object)val2.shader).name == "Custom/Piece") { return val2.shader; } } } } val = Shader.Find("Standard"); if (!Object.op_Implicit((Object)(object)val)) { throw new InvalidOperationException("Opaque piece shader unavailable."); } return val; } private static Material OpaqueMaterial(Shader shader, string name, Texture texture, Color tint, float metallic, float gloss) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0180: Unknown result type (might be due to invalid IL or missing references) Material val = new Material(shader); ((Object)val).name = name; val.shaderKeywords = new string[0]; val.renderQueue = 2000; if (val.HasProperty("_MainTex")) { val.SetTexture("_MainTex", texture); } if (val.HasProperty("_Color")) { val.SetColor("_Color", tint); } string[] array = new string[8] { "_Cutoff", "_ValueNoise", "_ValueNoiseVertex", "_AddSnow", "_AddRain", "_TriplanarMap", "_MoveableObject", "_Mode" }; foreach (string text in array) { if (val.HasProperty(text)) { val.SetFloat(text, 0f); } } if (val.HasProperty("_Glossiness")) { val.SetFloat("_Glossiness", gloss); } if (val.HasProperty("_Metallic")) { val.SetFloat("_Metallic", metallic); } if (val.HasProperty("_BumpScale")) { val.SetFloat("_BumpScale", 0f); } if (val.HasProperty("_SrcBlend")) { val.SetFloat("_SrcBlend", 1f); } if (val.HasProperty("_DstBlend")) { val.SetFloat("_DstBlend", 0f); } if (val.HasProperty("_ZWrite")) { val.SetFloat("_ZWrite", 1f); } if (val.HasProperty("_EmissionColor")) { val.SetColor("_EmissionColor", Color.black); } return val; } private static Texture2D WoodGrain() { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown //IL_00bd: 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) Texture2D val = new Texture2D(64, 128, (TextureFormat)4, false); ((Object)val).name = "AutoKiln_OpaqueBlackWoodGrain"; ((Texture)val).wrapMode = (TextureWrapMode)0; ((Texture)val).filterMode = (FilterMode)1; Color[] array = (Color[])(object)new Color[8192]; for (int i = 0; i < 128; i++) { for (int j = 0; j < 64; j++) { double num = Math.Sin((double)j * 0.72 + Math.Sin((double)i * 0.047) * 0.85); int num2 = ((j * 92821) ^ (i * 68917)) & 0x1F; float num3 = 0.075f + (float)num * 0.021f + (float)num2 * 0.00065f; array[i * 64 + j] = new Color(num3 * 0.95f, num3, num3 * 1.02f, 1f); } } val.SetPixels(array); val.Apply(false, true); return val; } private static Transform Log(Transform parent, string name, Material bark, Material endGrain) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_008b: 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_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name) { layer = ((Component)parent).gameObject.layer }; val.transform.SetParent(parent, false); Cylinder(val.transform, "Bark", new Vector3(0f, 0f, 0f), new Vector3(0.34f, 0.9f, 0.34f), bark); Cylinder(val.transform, "CutEnd_L", new Vector3(-0.908f, 0f, 0f), new Vector3(0.337f, 0.009f, 0.337f), endGrain); Cylinder(val.transform, "CutEnd_R", new Vector3(0.908f, 0f, 0f), new Vector3(0.337f, 0.009f, 0.337f), endGrain); return val.transform; } private static void Cylinder(Transform parent, string name, Vector3 position, Vector3 scale, Material material) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)2); ((Object)obj).name = name; obj.layer = ((Component)parent).gameObject.layer; obj.transform.SetParent(parent, false); obj.transform.localPosition = position; obj.transform.localRotation = Quaternion.Euler(0f, 0f, 90f); obj.transform.localScale = scale; Object.DestroyImmediate((Object)(object)obj.GetComponent<Collider>()); Renderer component = obj.GetComponent<Renderer>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)material)) { component.sharedMaterial = material; } } private static GameObject Beam(Transform parent, string name, Vector3 position, Vector3 scale, Material material) { //IL_0031: 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) GameObject obj = GameObject.CreatePrimitive((PrimitiveType)3); ((Object)obj).name = name; obj.layer = ((Component)parent).gameObject.layer; obj.transform.SetParent(parent, false); obj.transform.localPosition = position; obj.transform.localScale = scale; Renderer component = obj.GetComponent<Renderer>(); if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)material)) { component.sharedMaterial = material; } return obj; } private static void Between(Transform parent, string name, Vector3 a, Vector3 b, float width, float depth, Material material) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_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) Vector3 val = b - a; Beam(parent, name, (a + b) * 0.5f, new Vector3(width, ((Vector3)(ref val)).magnitude, depth), material).transform.localRotation = Quaternion.FromToRotation(Vector3.up, ((Vector3)(ref val)).normalized); } }