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 InstaSmelt v0.1.0
plugins/InstaSmelt.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("InstaSmelt")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("InstaSmelt")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("ee0ccb4c-4389-47c4-967d-f37b5dbe65b1")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] namespace InstaSmelt; [BepInPlugin("com.oathorse.InstaSmelt", "InstaSmelt", "0.1.0")] public class InstaSmelt : BaseUnityPlugin { [HarmonyPatch(typeof(ItemData), "GetWeight")] public class Humanoid_ItemDrop_ItemData_GetWeight_Patch { private static bool Prefix(ItemData __instance, ref float __result) { if (__instance == null) { return true; } if ((Object)(object)__instance.m_dropPrefab == (Object)null) { return true; } if (__m_oreNameToBarPrefabName.TryGetValue(((Object)__instance.m_dropPrefab).name, out var value)) { ItemData itemData = ZNetScene.instance.GetPrefab(value).GetComponent<ItemDrop>().m_itemData; if (itemData != null) { __result = itemData.m_shared.m_weight * (float)__instance.m_stack; } return false; } return true; } } [HarmonyPatch(typeof(ItemData), "GetNonStackedWeight")] public class Humanoid_ItemDrop_ItemData_GetNonStackedWeight_Patch { private static bool Prefix(ItemData __instance, ref float __result) { if (__instance == null) { return true; } if ((Object)(object)__instance.m_dropPrefab == (Object)null) { return true; } if (__m_oreNameToBarPrefabName.TryGetValue(((Object)__instance.m_dropPrefab).name, out var value)) { ItemData itemData = ZNetScene.instance.GetPrefab(value).GetComponent<ItemDrop>().m_itemData; if (itemData != null) { __result = itemData.m_shared.m_weight; } return false; } return true; } } [HarmonyPatch(typeof(Inventory), "AddItem", new Type[] { typeof(ItemData) })] public static class Inventory_AddItem_Patch { private static void Prefix(Inventory __instance, ref ItemData item, bool __result) { if (__instance != null && (Object)(object)Player.m_localPlayer != (Object)null && __instance == ((Humanoid)Player.m_localPlayer).GetInventory()) { ConvertMetal(ref item); } } } [HarmonyPatch(typeof(Inventory), "CanAddItem", new Type[] { typeof(ItemData), typeof(int) })] public static class Inventory_CanAddItem_Patch { private static bool Prefix(Inventory __instance, ref ItemData item, int stack, ref bool __result) { if (__instance != null && (Object)(object)Player.m_localPlayer != (Object)null && __instance == ((Humanoid)Player.m_localPlayer).GetInventory() && item != null && (Object)(object)item.m_dropPrefab != (Object)null) { string name = ((Object)item.m_dropPrefab).name; if (__m_oreNameToBarItemName.TryGetValue(name, out var value)) { if (stack <= 0) { stack = item.m_stack; } __result = __instance.FindFreeStackSpace(value, 0f) + (__instance.GetWidth() * __instance.GetHeight() - __instance.GetAllItems().Count) * item.m_shared.m_maxStackSize >= stack; return false; } } return true; } } [HarmonyPatch(typeof(Humanoid), "Pickup")] public class Humanoid_Pickup_Patch { private static void Prefix(Humanoid __instance, GameObject go, bool autoequip, bool autoPickupDelay, bool __result) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { ItemDrop component = go.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { ConvertMetal(ref component.m_itemData); } } } } public const string PluginGUID = "com.oathorse.InstaSmelt"; public const string PluginName = "InstaSmelt"; public const string PluginVersion = "0.1.0"; private readonly Harmony harmony = new Harmony("com.oathorse.InstaSmelt"); private List<PinData> __m_pins = new List<PinData>(); public static bool __m_createPinOnTeleport = false; public static Dictionary<string, string> __m_oreNameToBarPrefabName = new Dictionary<string, string> { { "CopperOre", "Copper" }, { "TinOre", "Tin" }, { "IronScrap", "Iron" }, { "SilverOre", "Silver" }, { "BlackMetalScrap", "BlackMetal" }, { "FlametalOreNew", "FlametalNew" }, { "BronzeScrap", "Bronze" }, { "CopperScrap", "Copper" } }; public static Dictionary<string, string> __m_oreNameToBarItemName = new Dictionary<string, string> { { "CopperOre", "$item_copper" }, { "TinOre", "$item_tin" }, { "IronScrap", "$item_iron" }, { "SilverOre", "$item_silver" }, { "BlackMetalScrap", "$item_blackmetal" }, { "FlametalOreNew", "$item_flametal" }, { "BronzeScrap", "$item_bronze" }, { "CopperScrap", "$item_copper" } }; public void Awake() { harmony.PatchAll(); } public static void ConvertMetal(ref ItemData itemData) { if (itemData == null) { return; } ZNetScene instance = ZNetScene.instance; if ((Object)(object)instance == (Object)null || !__m_oreNameToBarPrefabName.TryGetValue(((Object)itemData.m_dropPrefab).name, out var value)) { return; } GameObject prefab = instance.GetPrefab(value); if (!((Object)(object)prefab == (Object)null)) { ItemDrop component = prefab.GetComponent<ItemDrop>(); if ((Object)(object)component != (Object)null) { int stack = itemData.m_stack; ItemData itemData2 = component.m_itemData; itemData = itemData2.Clone(); itemData.m_stack = stack; itemData.m_dropPrefab = prefab; } } } }