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 BulkSmelt v2.1.0
BulkSmelt.dll
Decompiled 2 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")] [assembly: AssemblyCompany("BulkSmelt")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Bulk Smelter Loading Mod")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("BulkSmelt")] [assembly: AssemblyTitle("BulkSmelt")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 BulkSmelt { [BepInPlugin("offChuma.BulkSmelt", "BulkSmelt", "2.1.0")] public class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(Smelter), "OnAddFuel")] private static class FuelPatch { private static bool Prefix(Smelter __instance, Humanoid user) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (ModEnabled.Value) { KeyboardShortcut value = FillShortcut.Value; if (((KeyboardShortcut)(ref value)).IsPressed() && !_isProcessing) { _isProcessing = true; try { string name = __instance.m_fuelItem.m_itemData.m_shared.m_name; int num = (name.ToLower().Contains("wood") ? MaxWood.Value : MaxCoal.Value); if (num <= 0) { num = __instance.m_maxFuel; } ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); int num2 = 0; MethodInfo method = typeof(Smelter).GetMethod("OnAddFuel", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); int num3 = method.GetParameters().Length; while (component.GetZDO().GetFloat("fuel", 0f) < (float)num && num2 < 100) { object[] array = new object[num3]; if (num3 == 3) { array[0] = null; array[1] = user; array[2] = null; } else { array[0] = user; array[1] = null; } if (!(bool)method.Invoke(__instance, array)) { break; } num2++; } if (num2 > 0) { ((Character)user).Message((MessageType)1, $"Bulk added: {num2} fuel", 0, (Sprite)null); } } finally { _isProcessing = false; } return false; } } return true; } } [HarmonyPatch(typeof(Smelter), "OnAddOre")] private static class OrePatch { private static bool Prefix(Smelter __instance, Humanoid user) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (ModEnabled.Value) { KeyboardShortcut value = FillShortcut.Value; if (((KeyboardShortcut)(ref value)).IsPressed() && !_isProcessing) { _isProcessing = true; try { int num = 0; foreach (ItemConversion item in __instance.m_conversion) { string name = ((Object)item.m_from.m_itemData.m_dropPrefab).name; if (OreConfigs.ContainsKey(name)) { num = OreConfigs[name].Value; break; } } if (num <= 0) { num = __instance.m_maxOre; } ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); int num2 = 0; MethodInfo method = typeof(Smelter).GetMethod("OnAddOre", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); int num3 = method.GetParameters().Length; while (component.GetZDO().GetInt("queued", 0) < num && num2 < 100) { object[] array = new object[num3]; if (num3 == 3) { array[0] = null; array[1] = user; array[2] = null; } else { array[0] = user; array[1] = null; } if (!(bool)method.Invoke(__instance, array)) { break; } num2++; } if (num2 > 0) { ((Character)user).Message((MessageType)1, $"Bulk inserted: {num2} items", 0, (Sprite)null); } } finally { _isProcessing = false; } return false; } } return true; } } public static ConfigEntry<bool> ModEnabled; public static ConfigEntry<KeyboardShortcut> ToggleKey; public static ConfigEntry<KeyboardShortcut> FillShortcut; public static ConfigEntry<int> MaxWood; public static ConfigEntry<int> MaxCoal; public static Dictionary<string, ConfigEntry<int>> OreConfigs = new Dictionary<string, ConfigEntry<int>>(); private static bool _isProcessing = false; private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) InitConfigs(); new Harmony("offChuma.BulkSmelt").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"BulkSmelt 2.1.0: Final Build Loaded!"); } private void InitConfigs() { //IL_0047: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Expected O, but got Unknown //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Expected O, but got Unknown //IL_01a5: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Expected O, but got Unknown //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Expected O, but got Unknown string text = "0. System"; string text2 = "1. Fuel"; string text3 = "2. Furnaces"; string text4 = "3. Farming"; ModEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>(text, "Mod Enabled", true, "Enable or disable the mod"); ToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(text, "Toggle Key", new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()), "Key to toggle mod status in-game"); FillShortcut = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>(text, "Modifier Key", new KeyboardShortcut((KeyCode)101, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), "Hold this + E to bulk fill."); MaxWood = ((BaseUnityPlugin)this).Config.Bind<int>(text2, "Wood_Limit", 25, new ConfigDescription("Kiln limit. 0 = Full.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 25), Array.Empty<object>())); MaxCoal = ((BaseUnityPlugin)this).Config.Bind<int>(text2, "Coal_Limit", 20, new ConfigDescription("Smelter limit. 0 = Full.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>())); string[] array = new string[6] { "CopperOre", "TinOre", "IronScrap", "SilverOre", "BlackMetalScrap", "FlametalOre" }; string[] array2 = array; foreach (string text5 in array2) { OreConfigs[text5] = ((BaseUnityPlugin)this).Config.Bind<int>(text3, text5, 10, new ConfigDescription(text5 + " limit. 0 = Full.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 20), Array.Empty<object>())); } OreConfigs["Barley"] = ((BaseUnityPlugin)this).Config.Bind<int>(text4, "Barley", 50, new ConfigDescription("Windmill limit. 0 = Full.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 50), Array.Empty<object>())); OreConfigs["Flax"] = ((BaseUnityPlugin)this).Config.Bind<int>(text4, "Flax", 40, new ConfigDescription("Spinning wheel limit. 0 = Full.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 40), Array.Empty<object>())); } private void Update() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value = ToggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { ModEnabled.Value = !ModEnabled.Value; Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, "BulkSmelt: " + (ModEnabled.Value ? "Enabled" : "Disabled"), 0, (Sprite)null); } } } } }