Decompiled source of BlastFurnacePatched v1.0.3

BlastFurnacePatched.dll

Decompiled 2 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("BlastFurnacePatched")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BlastFurnacePatched")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b023762e-3658-4556-823a-a92987f85453")]
[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 BlastFurnaceFix;

[BepInPlugin("hoobi.BlastFurnacePatched", "BlastFurnacePatched", "1.0.3")]
[BepInProcess("valheim.exe")]
[BepInProcess("valheim_server.exe")]
[HarmonyPatch]
public class BFFix : BaseUnityPlugin
{
	internal const string ModName = "BlastFurnacePatched";

	internal const string ModVersion = "1.0.3";

	internal const string Author = "hoobi";

	private const string ModGUID = "hoobi.BlastFurnacePatched";

	private static Dictionary<string, ItemDrop> metals = new Dictionary<string, ItemDrop>
	{
		{ "$item_copperore", null },
		{ "$item_copper", null },
		{ "$item_ironscrap", null },
		{ "$item_iron", null },
		{ "$item_ironore", null },
		{ "$item_tinore", null },
		{ "$item_tin", null },
		{ "$item_silverore", null },
		{ "$item_silver", null },
		{ "$item_copperscrap", null },
		{ "$item_bronzescrap", null },
		{ "$item_bronze", null }
	};

	private void Awake()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		new Harmony("hoobi.BlastFurnacePatched").PatchAll();
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Smelter), "Awake")]
	private static void BlastFurnacePatch(ref Smelter __instance)
	{
		//IL_00ab: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Expected O, but got Unknown
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Expected O, but got Unknown
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Expected O, but got Unknown
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: 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_0181: Expected O, but got Unknown
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b7: Expected O, but got Unknown
		//IL_01b9: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Expected O, but got Unknown
		//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_0209: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Expected O, but got Unknown
		if (__instance.m_name != "$piece_blastfurnace")
		{
			return;
		}
		ObjectDB instance = ObjectDB.instance;
		List<ItemDrop> allItems = instance.GetAllItems((ItemType)1, "");
		foreach (ItemDrop item in allItems)
		{
			if (metals.Keys.Contains(item.m_itemData.m_shared.m_name))
			{
				metals[item.m_itemData.m_shared.m_name] = item;
			}
		}
		List<ItemConversion> list = new List<ItemConversion>
		{
			new ItemConversion
			{
				m_from = metals["$item_copperore"],
				m_to = metals["$item_copper"]
			},
			new ItemConversion
			{
				m_from = metals["$item_tinore"],
				m_to = metals["$item_tin"]
			},
			new ItemConversion
			{
				m_from = metals["$item_ironscrap"],
				m_to = metals["$item_iron"]
			},
			new ItemConversion
			{
				m_from = metals["$item_silverore"],
				m_to = metals["$item_silver"]
			},
			new ItemConversion
			{
				m_from = metals["$item_copperscrap"],
				m_to = metals["$item_copper"]
			},
			new ItemConversion
			{
				m_from = metals["$item_bronzescrap"],
				m_to = metals["$item_bronze"]
			},
			new ItemConversion
			{
				m_from = metals["$item_ironore"],
				m_to = metals["$item_iron"]
			}
		};
		foreach (ItemConversion item2 in list)
		{
			__instance.m_conversion.Add(item2);
		}
	}
}