Decompiled source of HungryChests v2.0.0

plugins/HungryChests/HungryChests.dll

Decompiled a year ago
using System;
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 BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using HungryChests.Patches;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("HungryChests")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HungryChests")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("437c1ed4-7b5e-48b5-b612-fa63324e7beb")]
[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 HungryChests
{
	[BepInPlugin("com.equinox.HungryChests", "HungryChests", "2.0.0")]
	public class HungryChestsPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "com.equinox.HungryChests";

		private const string PluginName = "HungryChests";

		private const string VersionString = "2.0.0";

		private const string VoidableItemsKey = "VoidableItems";

		public static ConfigEntry<string> VoidableItems;

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

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

		private void Awake()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			VoidableItems = ((BaseUnityPlugin)this).Config.Bind<string>("General", "VoidableItems", "Limestone,Plantmatter,Kindlevine Extract,Shiverthorn Extract", new ConfigDescription("Items that will be auto-voided from the last slot in a chest", (AcceptableValueBase)null, Array.Empty<object>()));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: HungryChests, VersionString: 2.0.0 is loading...");
			Harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PluginName: HungryChests, VersionString: 2.0.0 is loaded.");
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.PatchAll(typeof(InserterPatch));
		}
	}
}
namespace HungryChests.Patches
{
	public class InserterPatch
	{
		[HarmonyPatch(typeof(InserterInstance), "Give")]
		[HarmonyPrefix]
		private static void deleteLastChestSlot(InserterInstance __instance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			if ((int)__instance.giveResourceContainer.typeIndex == 3)
			{
				Inventory inventory = __instance.giveResourceContainer.GetInventory(0);
				int num = inventory.numSlots - 1;
				if (!((ResourceStack)(ref inventory.myStacks[num])).isEmpty && getVoidableItems().Contains(((ResourceStack)(ref inventory.myStacks[num])).info.displayName))
				{
					((Inventory)(ref inventory)).RemoveResourcesFromSlot(num, inventory.myStacks[num].count);
				}
			}
		}

		private static List<string> getVoidableItems()
		{
			return HungryChestsPlugin.VoidableItems.Value.Split(new char[1] { ',' }).ToList();
		}
	}
}