Decompiled source of JustRetry v1.0.1

JustRetry.dll

Decompiled 10 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("JustRetry")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("JustRetry")]
[assembly: AssemblyTitle("JustRetry")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 JustRetry
{
	[BepInPlugin("nickklmao.justretry", "Just Retry", "1.0.1")]
	internal sealed class Entry : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__RunManager_ChangeLevelILHook;
		}

		private const string MOD_NAME = "Just Retry";

		internal static readonly ManualLogSource logger = Logger.CreateLogSource("Just Retry");

		private static void RunManager_ChangeLevelILHook(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.GotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction instruction) => ILPatternMatchingExt.MatchStfld<RunManager>(instruction, "gameOver")
			});
			val.Index -= 2;
			int index = val.Index;
			val.Emit(OpCodes.Ldarg_2);
			val.EmitDelegate<Func<bool, bool>>((Func<bool, bool>)delegate(bool levelFailed)
			{
				if (!levelFailed)
				{
					return false;
				}
				RunManager.instance.RestartScene();
				return true;
			});
			ILLabel val2 = val.DefineLabel();
			val.Emit(OpCodes.Brfalse_S, (object)val2);
			val.Emit(OpCodes.Ret);
			val.MarkLabel(val2);
			val.Index -= 8;
			ILLabel val3 = val.DefineLabel();
			val.Remove();
			val.Emit(OpCodes.Brfalse_S, (object)val3);
			val.Index = index;
			val.MarkLabel(val3);
		}

		private void Awake()
		{
			//IL_0040: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			logger.LogDebug((object)"Hooking `RunManager.ChangeLevel`");
			MethodInfo methodInfo = AccessTools.Method(typeof(RunManager), "ChangeLevel", (Type[])null, (Type[])null);
			object obj = <>O.<0>__RunManager_ChangeLevelILHook;
			if (obj == null)
			{
				Manipulator val = RunManager_ChangeLevelILHook;
				<>O.<0>__RunManager_ChangeLevelILHook = val;
				obj = (object)val;
			}
			new ILHook((MethodBase)methodInfo, (Manipulator)obj);
		}
	}
}