Decompiled source of SmeltingEfficiency v1.0.2

SmeltingEfficiency.dll

Decompiled 2 weeks ago
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 BepInEx.Logging;
using EquinoxsModUtils;
using EquinoxsModUtils.Additions;
using HarmonyLib;
using SmeltingEfficiency.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SmeltingEfficiency")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SmeltingEfficiency")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("1f19937e-8020-4414-93ee-53a013265c55")]
[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 SmeltingEfficiency
{
	[BepInPlugin("com.rober.SmeltingEfficiency", "SmeltingEfficiency", "1.0.2")]
	public class SmeltingEfficiencyPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "com.rober.SmeltingEfficiency";

		private const string PluginName = "SmeltingEfficiency";

		private const string VersionString = "1.0.2";

		private const string myUnlockName = "Smelting Efficiency";

		private static readonly Harmony Harmony = new Harmony("com.rober.SmeltingEfficiency");

		public static ManualLogSource Log = new ManualLogSource("SmeltingEfficiency");

		private void Awake()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: SmeltingEfficiency, VersionString: 1.0.2 is loading...");
			Harmony.PatchAll();
			EMUAdditions.AddNewUnlock(new NewUnlockDetails
			{
				displayName = "Smelting Efficiency",
				description = "Improves the efficiency of smelters when converting ore to ingots.",
				category = (TechCategory)5,
				requiredTier = (ResearchTier)16,
				coreTypeNeeded = (CoreType)0,
				coreCountNeeded = 20,
				treePosition = 50,
				sprite = null
			}, false);
			Harmony.PatchAll(typeof(SmeltingEfficiencyTechUnlock));
			Harmony.PatchAll(typeof(SmeltingEfficiencyTechDeactivate));
			Events.GameDefinesLoaded += OnGameDefinesLoaded;
			Events.GameLoaded += OnGameLoaded;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: SmeltingEfficiency, VersionString: 1.0.2 is loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
		}

		private void OnGameDefinesLoaded()
		{
			Unlock unlockByName = Unlocks.GetUnlockByName("Smelting Efficiency", false);
			AlignUnlockOnTechTree(unlockByName);
			ResourceInfo resourceInfoByName = Resources.GetResourceInfoByName("Smelter", false);
			unlockByName.sprite = resourceInfoByName.rawSprite;
		}

		private void AlignUnlockOnTechTree(Unlock myUnlock)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			Unlock unlockByName = Unlocks.GetUnlockByName("Shiverthorn Coolant", false);
			Unlock unlockByName2 = Unlocks.GetUnlockByName("MassCollect", false);
			myUnlock.requiredTier = unlockByName2.requiredTier;
			myUnlock.treePosition = unlockByName.treePosition;
		}

		private void OnGameLoaded()
		{
			ResourceInfo resourceInfoByName = Resources.GetResourceInfoByName("Iron Ore", false);
			ResourceInfo resourceInfoByName2 = Resources.GetResourceInfoByName("Iron Ingot", false);
			List<int> list = new List<int> { ((UniqueIdScriptableObject)resourceInfoByName).uniqueId };
			List<int> list2 = new List<int> { ((UniqueIdScriptableObject)resourceInfoByName2).uniqueId };
			SchematicsRecipeData val = Recipes.TryFindRecipe(list, list2, false);
			ResourceInfo resourceInfoByName3 = Resources.GetResourceInfoByName("Copper Ore", false);
			ResourceInfo resourceInfoByName4 = Resources.GetResourceInfoByName("Copper Ingot", false);
			List<int> list3 = new List<int> { ((UniqueIdScriptableObject)resourceInfoByName3).uniqueId };
			List<int> list4 = new List<int> { ((UniqueIdScriptableObject)resourceInfoByName4).uniqueId };
			SchematicsRecipeData val2 = Recipes.TryFindRecipe(list3, list4, false);
			if (IsMyUnlockActive())
			{
				if ((Object)(object)val != (Object)null)
				{
					val.runtimeIngQuantities[0] = 4;
					val.outputQuantities[0] = 2;
				}
				if ((Object)(object)val2 != (Object)null)
				{
					val2.runtimeIngQuantities[0] = 4;
					val2.outputQuantities[0] = 2;
				}
			}
			else
			{
				if ((Object)(object)val != (Object)null)
				{
					val.runtimeIngQuantities[0] = 4;
					val.outputQuantities[0] = 1;
				}
				if ((Object)(object)val2 != (Object)null)
				{
					val2.runtimeIngQuantities[0] = 4;
					val2.outputQuantities[0] = 1;
				}
			}
		}

		private bool IsMyUnlockActive()
		{
			Unlock unlockByName = Unlocks.GetUnlockByName("Smelting Efficiency", false);
			if ((Object)(object)unlockByName != (Object)null)
			{
				if (TechTreeState.instance.IsUnlockActive(((UniqueIdScriptableObject)unlockByName).uniqueId))
				{
					return true;
				}
				return false;
			}
			return false;
		}
	}
}
namespace SmeltingEfficiency.Patches
{
	internal class SmeltingEfficiencyTechUnlock
	{
		private const string MyGUID = "com.rober.SmeltingEfficiency";

		private const string PluginName = "SmeltingEfficiency";

		private const string VersionString = "1.0.2";

		private const string myUnlockName = "Smelting Efficiency";

		public static ManualLogSource Log = new ManualLogSource("SmeltingEfficiency");

		[HarmonyPatch(typeof(TechTreeState), "UnlockTech")]
		[HarmonyPostfix]
		private static void OnTechActivated(int unlockId)
		{
			Unlock unlockByName = Unlocks.GetUnlockByName("Smelting Efficiency", false);
			if (unlockId == ((UniqueIdScriptableObject)unlockByName).uniqueId)
			{
				ResourceInfo resourceInfoByName = Resources.GetResourceInfoByName("Iron Ore", false);
				ResourceInfo resourceInfoByName2 = Resources.GetResourceInfoByName("Iron Ingot", false);
				List<int> list = new List<int> { ((UniqueIdScriptableObject)resourceInfoByName).uniqueId };
				List<int> list2 = new List<int> { ((UniqueIdScriptableObject)resourceInfoByName2).uniqueId };
				SchematicsRecipeData val = Recipes.TryFindRecipe(list, list2, false);
				ResourceInfo resourceInfoByName3 = Resources.GetResourceInfoByName("Copper Ore", false);
				ResourceInfo resourceInfoByName4 = Resources.GetResourceInfoByName("Copper Ingot", false);
				List<int> list3 = new List<int> { ((UniqueIdScriptableObject)resourceInfoByName3).uniqueId };
				List<int> list4 = new List<int> { ((UniqueIdScriptableObject)resourceInfoByName4).uniqueId };
				SchematicsRecipeData val2 = Recipes.TryFindRecipe(list3, list4, false);
				if ((Object)(object)val != (Object)null)
				{
					val.runtimeIngQuantities[0] = 4;
					val.outputQuantities[0] = 2;
				}
				if ((Object)(object)val2 != (Object)null)
				{
					val2.runtimeIngQuantities[0] = 4;
					val2.outputQuantities[0] = 2;
				}
			}
		}
	}
	internal class SmeltingEfficiencyTechDeactivate
	{
		private const string MyGUID = "com.rober.SmeltingEfficiency";

		private const string PluginName = "SmeltingEfficiency";

		private const string VersionString = "1.0.2";

		private const string myUnlockName = "Smelting Efficiency";

		public static ManualLogSource Log = new ManualLogSource("SmeltingEfficiency");

		[HarmonyPatch(typeof(TechTreeState), "DeactivateTech")]
		[HarmonyPostfix]
		private static void OnTechDeactivated(int unlockId)
		{
			Unlock unlockByName = Unlocks.GetUnlockByName("Smelting Efficiency", false);
			if (unlockId == ((UniqueIdScriptableObject)unlockByName).uniqueId)
			{
				ResourceInfo resourceInfoByName = Resources.GetResourceInfoByName("Iron Ore", false);
				ResourceInfo resourceInfoByName2 = Resources.GetResourceInfoByName("Iron Ingot", false);
				List<int> list = new List<int> { ((UniqueIdScriptableObject)resourceInfoByName).uniqueId };
				List<int> list2 = new List<int> { ((UniqueIdScriptableObject)resourceInfoByName2).uniqueId };
				SchematicsRecipeData val = Recipes.TryFindRecipe(list, list2, false);
				ResourceInfo resourceInfoByName3 = Resources.GetResourceInfoByName("Copper Ore", false);
				ResourceInfo resourceInfoByName4 = Resources.GetResourceInfoByName("Copper Ingot", false);
				List<int> list3 = new List<int> { ((UniqueIdScriptableObject)resourceInfoByName3).uniqueId };
				List<int> list4 = new List<int> { ((UniqueIdScriptableObject)resourceInfoByName4).uniqueId };
				SchematicsRecipeData val2 = Recipes.TryFindRecipe(list3, list4, false);
				if ((Object)(object)val != (Object)null)
				{
					val.runtimeIngQuantities[0] = 4;
					val.outputQuantities[0] = 1;
				}
				if ((Object)(object)val2 != (Object)null)
				{
					val2.runtimeIngQuantities[0] = 4;
					val2.outputQuantities[0] = 1;
				}
			}
		}
	}
}
namespace SmeltingEfficiency.MonoBehaviours
{
	internal class SmeltingEfficiencyComponent : MonoBehaviour
	{
		public void Awake()
		{
		}

		public void Start()
		{
		}

		public void Update()
		{
		}

		public void LateUpdate()
		{
		}
	}
}