Decompiled source of InstantChestsBepInEx v1.0.0

InstantChestsBepIn.dll

Decompiled 2 months ago
using System;
using System.Collections;
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.UI.InGame.Rewards;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("InstantChestsBepIn")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Instant chests but on bepinex")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+64f8341b8a25c07fe5eec2609364bf141c3fcb9e")]
[assembly: AssemblyProduct("InstantChestsBepIn")]
[assembly: AssemblyTitle("InstantChestsBepIn")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 InstantChestsBepIn
{
	[BepInPlugin("Wooshibou_InstantChestsBepIn", "InstantChestsBepIn", "1.0.0")]
	public class Plugin : BasePlugin
	{
		[HarmonyPatch(typeof(ChestWindowUi), "ShowOpenButton")]
		private static class Patch_ShowOpenButton
		{
			private static bool Prefix()
			{
				return false;
			}
		}

		[HarmonyPatch(typeof(ChestWindowUi), "Open", new Type[] { typeof(EEncounter) })]
		private static class Patch_ClickOnOpen
		{
			private static void Postfix(ChestWindowUi __instance)
			{
				__instance.OpenButton();
				currentChestWindowUiInstance = __instance;
			}
		}

		[HarmonyPatch(typeof(ChestOpening), "OpenChest", new Type[] { typeof(ItemData) })]
		private static class Patch_OpenChest
		{
			[CompilerGenerated]
			private sealed class <DelayedOpening>d__1 : IEnumerator<object>, IEnumerator, IDisposable
			{
				private int <>1__state;

				private object <>2__current;

				public ChestOpening __instance;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <DelayedOpening>d__1(int <>1__state)
				{
					this.<>1__state = <>1__state;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>2__current = null;
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						if ((Object)(object)currentChestWindowUiInstance == (Object)null)
						{
							log.LogWarning((object)"ChestWindowUi is null — skipping first chest.");
							return false;
						}
						if ((Object)(object)__instance.itemData == (Object)null)
						{
							log.LogWarning((object)"ItemData is null — skipping OpeningFinished.");
							return false;
						}
						currentChestWindowUiInstance.itemData = __instance.itemData;
						currentChestWindowUiInstance.OpeningFinished(__instance.itemData);
						return false;
					}
				}

				bool IEnumerator.MoveNext()
				{
					//ILSpy generated this explicit interface implementation from .override directive in MoveNext
					return this.MoveNext();
				}

				[DebuggerHidden]
				void IEnumerator.Reset()
				{
					throw new NotSupportedException();
				}
			}

			private static void Postfix(ChestOpening __instance, ItemData itemData)
			{
				__instance.skipped = true;
				__instance.spinning = false;
				__instance.timeBetweenTiers = 0.01f;
				MonoBehaviourExtensions.StartCoroutine((MonoBehaviour)(object)__instance, DelayedOpening(__instance));
			}

			[IteratorStateMachine(typeof(<DelayedOpening>d__1))]
			private static IEnumerator DelayedOpening(ChestOpening __instance)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <DelayedOpening>d__1(0)
				{
					__instance = __instance
				};
			}
		}

		public const string MODNAME = "InstantChestsBepIn";

		public const string AUTHOR = "Wooshibou";

		public const string GUID = "Wooshibou_InstantChestsBepIn";

		public const string VERSION = "1.0.0";

		private Harmony _harmony;

		private static ChestWindowUi currentChestWindowUiInstance;

		public static ManualLogSource log;

		public Plugin()
		{
			log = ((BasePlugin)this).Log;
		}

		public override void Load()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			ManualLogSource val = log;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(14, 3, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Loading ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("InstantChestsBepIn");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" v");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("1.0.0");
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" by ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("Wooshibou");
			}
			val.LogInfo(val2);
			_harmony = new Harmony("Wooshibou_InstantChestsBepIn");
			_harmony.PatchAll();
		}
	}
}