Decompiled source of HungryThreshers v1.0.0

plugins/HungryThreshers/HungryThreshers.dll

Decompiled 5 months ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HungryThreshers.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HungryThreshers")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HungryThreshers")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("dc08a998-3c31-44f0-9a0c-894be6f1913c")]
[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 HungryThreshers
{
	[BepInPlugin("com.equinox.HungryThreshers", "HungryThreshers", "1.1.0")]
	public class HungryThreshersPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "com.equinox.HungryThreshers";

		private const string PluginName = "HungryThreshers";

		private const string VersionString = "1.1.0";

		private const string PauseIfBothFullKey = "PauseIfBothFull";

		public static ConfigEntry<bool> PauseIfBothFull;

		private static readonly Harmony Harmony = new Harmony("com.equinox.HungryThreshers");

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

		private void Awake()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: HungryThreshers, VersionString: 1.1.0 is loading...");
			PauseIfBothFull = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "PauseIfBothFull", false, new ConfigDescription("When enabled, threshers will not void items if both outputs are full", (AcceptableValueBase)null, Array.Empty<object>()));
			Harmony.PatchAll();
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.PatchAll(typeof(ThresherInstancePatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: HungryThreshers, VersionString: 1.1.0 is loaded.");
		}
	}
}
namespace HungryThreshers.Patches
{
	public class ThresherInstancePatch
	{
		[HarmonyPatch(typeof(ThresherInstance), "UpdateCrafting")]
		[HarmonyPrefix]
		private static void clearOutputsForCrafting(ThresherInstance __instance)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			Inventory outputInventory = ((ThresherInstance)(ref __instance)).GetOutputInventory();
			if (!((ResourceStack)(ref outputInventory.myStacks[0])).isEmpty && !((ResourceStack)(ref outputInventory.myStacks[1])).isEmpty && outputInventory.myStacks[0].count >= 490 && outputInventory.myStacks[1].count >= 490 && HungryThreshersPlugin.PauseIfBothFull.Value)
			{
				return;
			}
			for (int i = 0; i < outputInventory.myStacks.Count(); i++)
			{
				if (!((ResourceStack)(ref outputInventory.myStacks[i])).isEmpty && outputInventory.myStacks[i].count >= 490)
				{
					((Inventory)(ref outputInventory)).RemoveResourcesFromSlot(i, 10);
				}
			}
		}
	}
}