Decompiled source of BlastFurnaceTakesAll v1.0.6

BlastFurnaceTakesAll.dll

Decompiled a week 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;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BlastFurnaceTakesAll")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BlastFurnaceTakesAll")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a2593121-5cf1-470c-aee4-2f969f458c0e")]
[assembly: AssemblyFileVersion("1.0.6.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.6.0")]
namespace BlastFurnaceFix;

[BepInPlugin("tastychickenlegs.BlastFurnaceTakesAll", "BlastFurnaceTakesAll", "1.0.3")]
[BepInProcess("valheim.exe")]
[BepInProcess("valheim_server.exe")]
[HarmonyPatch]
public class BFFix : BaseUnityPlugin
{
	private const string GUID = "BlastFurnaceTakesAll";

	private const string VERSION = "1.0.6";

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

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

	private void destroy()
	{
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Smelter), "Awake")]
	private static void BlastFurnacePatch(ref Smelter __instance)
	{
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Expected O, but got Unknown
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Expected O, but got Unknown
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: 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_0165: Expected O, but got Unknown
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: 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)
		//IL_019a: Expected O, but got Unknown
		//IL_019b: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Expected O, but got Unknown
		if (__instance.m_name != "$piece_blastfurnace")
		{
			Debug.Log((object)"Ignored non-blast furnace smelter.");
			return;
		}
		Debug.Log((object)"Found a blast furnace! Applying fix.");
		foreach (ItemDrop allItem in ObjectDB.instance.GetAllItems((ItemType)1, ""))
		{
			if (metals.Keys.Contains(allItem.m_itemData.m_shared.m_name))
			{
				Debug.Log((object)("Adding " + allItem.m_itemData.m_shared.m_name + " to list of materials."));
				metals[allItem.m_itemData.m_shared.m_name] = allItem;
			}
		}
		foreach (ItemConversion item in 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"]
			}
		})
		{
			__instance.m_conversion.Add(item);
		}
	}
}