Decompiled source of FirstChestCreditCard BepInEx v1.1.0

LuckyCard-BepinEx.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Assets.Scripts.Actors.Player;
using Assets.Scripts.Inventory__Items__Pickups.Chests;
using Assets.Scripts.Inventory__Items__Pickups.Items;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("LuckyCard-BepinEx")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("Lucky Card")]
[assembly: AssemblyTitle("LuckyCard-BepinEx")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepinLuck
{
	[BepInPlugin("com.twinzet.luckycard", "LuckyCard", "1.1.0")]
	public class Core : BasePlugin
	{
		[HarmonyPatch(typeof(GameManager), "StartPlaying")]
		public static class TogglePatch
		{
			[HarmonyPostfix]
			public static void Postfix()
			{
				hasProcessed = false;
			}
		}

		[HarmonyPatch(typeof(InteractableChest), "OnChestWindowClose")]
		public static class LuckyCardPatch
		{
			[HarmonyPostfix]
			public static void Postfix()
			{
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Expected O, but got Unknown
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				if (hasProcessed)
				{
					return;
				}
				hasProcessed = true;
				try
				{
					MyPlayer instance = MyPlayer.Instance;
					object obj;
					if (instance == null)
					{
						obj = null;
					}
					else
					{
						PlayerInventory inventory = instance.inventory;
						obj = ((inventory != null) ? inventory.itemInventory : null);
					}
					ItemInventory val = (ItemInventory)obj;
					if (val == null)
					{
						hasProcessed = false;
						return;
					}
					foreach (KeyValuePair<EItem, ConfigEntry<bool>> item in ItemToggle)
					{
						if (item.Value.Value)
						{
							val.AddItem(item.Key);
						}
					}
					((BasePlugin)Instance).Log.LogInfo((object)"Items Given");
				}
				catch (Exception ex)
				{
					ManualLogSource log = ((BasePlugin)Instance).Log;
					bool flag = default(bool);
					BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(11, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Exception: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
					}
					log.LogError(val2);
					hasProcessed = false;
				}
			}
		}

		public static Core Instance;

		public static bool hasProcessed;

		public static Dictionary<EItem, ConfigEntry<bool>> ItemToggle;

		private Harmony _harmony;

		public override void Load()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Invalid comparison between Unknown and I4
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			Instance = this;
			ItemToggle = new Dictionary<EItem, ConfigEntry<bool>>();
			foreach (EItem value3 in Enum.GetValues(typeof(EItem)))
			{
				EItem val = value3;
				if ((int)val != 64)
				{
					ConfigEntry<bool> value = ((BasePlugin)this).Config.Bind<bool>("LuckyCard", ((object)(EItem)(ref val)).ToString(), false, $"Enable{val}");
					ItemToggle[val] = value;
				}
				else
				{
					ConfigEntry<bool> value2 = ((BasePlugin)this).Config.Bind<bool>("LuckyCard", ((object)(EItem)(ref val)).ToString(), true, $"Enable{val}");
					ItemToggle[val] = value2;
				}
			}
			_harmony = new Harmony("com.twinzet.luckycard");
			_harmony.PatchAll();
			((BasePlugin)this).Log.LogInfo((object)"LuckyCard Initialized.");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LuckyCard-BepinEx";

		public const string PLUGIN_NAME = "Lucky Card";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}