Decompiled source of BepInExResoniteShim v0.9.1

plugins/BepInExResoniteShim/BepInExResoniteShim.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.NET.Common;
using Elements.Core;
using FrooxEngine;
using HarmonyLib;
using Renderite.Shared;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
[assembly: IgnoresAccessChecksTo("Renderite.Host")]
[assembly: AssemblyCompany("ResoniteModding")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.9.1.0")]
[assembly: AssemblyInformationalVersion("0.9.1+d51f89b852ea13358f13968bd4cae1ba07a6a3a5")]
[assembly: AssemblyProduct("BepInEx Resonite Shim")]
[assembly: AssemblyTitle("BepInExResoniteShim")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/ResoniteModding/BepInExResoniteShim")]
[assembly: SecurityPermission(8, SkipVerification = true)]
[assembly: AssemblyVersion("0.9.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace BepInExResoniteShim
{
	public class ResonitePlugin : BepInPlugin
	{
		[field: CompilerGenerated]
		public string Author
		{
			[CompilerGenerated]
			get;
			[CompilerGenerated]
			protected set;
		}

		[field: CompilerGenerated]
		public string Link
		{
			[CompilerGenerated]
			get;
			[CompilerGenerated]
			protected set;
		}

		public ResonitePlugin(string GUID, string Name, string Version, string Author, string Link)
			: base(GUID, Name, Version)
		{
			this.Author = Author;
			this.Link = Link;
		}
	}
	[ResonitePlugin("ResoniteModding.BepInExResoniteShim", "BepInEx Resonite Shim", "0.9.1", "ResoniteModding", "https://github.com/ResoniteModding/BepInExResoniteShim")]
	internal class BepInExResoniteShim : BasePlugin
	{
		[HarmonyPatch]
		private class LocationFixer
		{
			[CompilerGenerated]
			private sealed class <Transpiler>d__1 : System.Collections.Generic.IEnumerable<CodeInstruction>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<CodeInstruction>, System.Collections.IEnumerator, System.IDisposable
			{
				private int <>1__state;

				private CodeInstruction <>2__current;

				private int <>l__initialThreadId;

				private System.Collections.Generic.IEnumerable<CodeInstruction> codes;

				public System.Collections.Generic.IEnumerable<CodeInstruction> <>3__codes;

				private int <killCount>5__2;

				private MethodInfo <cachePath>5__3;

				private MethodInfo <asmLoc>5__4;

				private System.Collections.Generic.IEnumerator<CodeInstruction> <>7__wrap4;

				private CodeInstruction <code>5__6;

				CodeInstruction System.Collections.Generic.IEnumerator<CodeInstruction>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

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

				[DebuggerHidden]
				public <Transpiler>d__1(int <>1__state)
				{
					this.<>1__state = <>1__state;
					<>l__initialThreadId = Environment.CurrentManagedThreadId;
				}

				[DebuggerHidden]
				void System.IDisposable.Dispose()
				{
					int num = <>1__state;
					if (num == -3 || (uint)(num - 1) <= 3u)
					{
						try
						{
						}
						finally
						{
							<>m__Finally1();
						}
					}
					<cachePath>5__3 = null;
					<asmLoc>5__4 = null;
					<>7__wrap4 = null;
					<code>5__6 = null;
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_0187: Unknown result type (might be due to invalid IL or missing references)
					//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
					//IL_01ac: Expected O, but got Unknown
					//IL_0163: Unknown result type (might be due to invalid IL or missing references)
					//IL_0169: Unknown result type (might be due to invalid IL or missing references)
					//IL_0173: Expected O, but got Unknown
					//IL_00da: Unknown result type (might be due to invalid IL or missing references)
					//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ff: Expected O, but got Unknown
					try
					{
						switch (<>1__state)
						{
						default:
							return false;
						case 0:
							<>1__state = -1;
							<killCount>5__2 = 0;
							<cachePath>5__3 = AccessTools.PropertyGetter(typeof(GlobalTypeRegistry), "MetadataCachePath");
							<asmLoc>5__4 = AccessTools.PropertyGetter(typeof(Assembly), "Location");
							<>7__wrap4 = codes.GetEnumerator();
							<>1__state = -3;
							break;
						case 1:
							<>1__state = -3;
							<killCount>5__2 = 2;
							goto IL_0140;
						case 2:
							<>1__state = -3;
							goto IL_0140;
						case 3:
							<>1__state = -3;
							<>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LocationFixer), "ProcessCachePath", (System.Type[])null, (System.Type[])null));
							<>1__state = 4;
							return true;
						case 4:
							{
								<>1__state = -3;
								goto IL_01bf;
							}
							IL_0140:
							if (CodeInstructionExtensions.Calls(<code>5__6, <cachePath>5__3))
							{
								Log.LogDebug((object)"Patched CachePath");
								<>2__current = new CodeInstruction(OpCodes.Ldarg_1, (object)null);
								<>1__state = 3;
								return true;
							}
							goto IL_01bf;
							IL_01bf:
							<code>5__6 = null;
							break;
						}
						while (((System.Collections.IEnumerator)<>7__wrap4).MoveNext())
						{
							<code>5__6 = <>7__wrap4.Current;
							if (<killCount>5__2 > 0)
							{
								<killCount>5__2--;
								continue;
							}
							if (CodeInstructionExtensions.Calls(<code>5__6, <asmLoc>5__4))
							{
								Log.LogDebug((object)"Patched AsmLoc");
								<>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(LocationFixer), "ProcessCacheTime", (System.Type[])null, (System.Type[])null));
								<>1__state = 1;
								return true;
							}
							<>2__current = <code>5__6;
							<>1__state = 2;
							return true;
						}
						<>m__Finally1();
						<>7__wrap4 = null;
						return false;
					}
					catch
					{
						//try-fault
						((System.IDisposable)this).Dispose();
						throw;
					}
				}

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

				private void <>m__Finally1()
				{
					<>1__state = -1;
					if (<>7__wrap4 != null)
					{
						((System.IDisposable)<>7__wrap4).Dispose();
					}
				}

				[DebuggerHidden]
				void System.Collections.IEnumerator.Reset()
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					throw new NotSupportedException();
				}

				[DebuggerHidden]
				System.Collections.Generic.IEnumerator<CodeInstruction> System.Collections.Generic.IEnumerable<CodeInstruction>.GetEnumerator()
				{
					<Transpiler>d__1 <Transpiler>d__;
					if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
					{
						<>1__state = 0;
						<Transpiler>d__ = this;
					}
					else
					{
						<Transpiler>d__ = new <Transpiler>d__1(0);
					}
					<Transpiler>d__.codes = <>3__codes;
					return <Transpiler>d__;
				}

				[DebuggerHidden]
				System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
				{
					return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<CodeInstruction>)this).GetEnumerator();
				}
			}

			public static MethodBase TargetMethod()
			{
				return (MethodBase)(object)AccessTools.FirstConstructor(typeof(AssemblyTypeRegistry), (Func<ConstructorInfo, bool>)((ConstructorInfo x) => ((MethodBase)x).GetParameters().Length > 3));
			}

			[IteratorStateMachine(typeof(<Transpiler>d__1))]
			public static System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(System.Collections.Generic.IEnumerable<CodeInstruction> codes)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Transpiler>d__1(-2)
				{
					<>3__codes = codes
				};
			}

			public static string? ProcessCachePath(string cachePath, Assembly asm)
			{
				if (string.IsNullOrWhiteSpace(asm.Location))
				{
					return null;
				}
				return cachePath;
			}

			public static System.DateTime ProcessCacheTime(Assembly asm)
			{
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				if (string.IsNullOrWhiteSpace(asm.Location))
				{
					return System.DateTime.UtcNow;
				}
				return ((FileSystemInfo)new FileInfo(asm.Location)).LastWriteTimeUtc;
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private class AssemblyLoadFixer
		{
			[CompilerGenerated]
			private sealed class <Transpiler>d__0 : System.Collections.Generic.IEnumerable<CodeInstruction>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<CodeInstruction>, System.Collections.IEnumerator, System.IDisposable
			{
				private int <>1__state;

				private CodeInstruction <>2__current;

				private int <>l__initialThreadId;

				private System.Collections.Generic.IEnumerable<CodeInstruction> codes;

				public System.Collections.Generic.IEnumerable<CodeInstruction> <>3__codes;

				private MethodInfo <loadFrom>5__2;

				private System.Collections.Generic.IEnumerator<CodeInstruction> <>7__wrap2;

				CodeInstruction System.Collections.Generic.IEnumerator<CodeInstruction>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

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

				[DebuggerHidden]
				public <Transpiler>d__0(int <>1__state)
				{
					this.<>1__state = <>1__state;
					<>l__initialThreadId = Environment.CurrentManagedThreadId;
				}

				[DebuggerHidden]
				void System.IDisposable.Dispose()
				{
					int num = <>1__state;
					if (num == -3 || (uint)(num - 1) <= 1u)
					{
						try
						{
						}
						finally
						{
							<>m__Finally1();
						}
					}
					<loadFrom>5__2 = null;
					<>7__wrap2 = null;
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_008b: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b0: Expected O, but got Unknown
					try
					{
						switch (<>1__state)
						{
						default:
							return false;
						case 0:
							<>1__state = -1;
							<loadFrom>5__2 = AccessTools.Method(typeof(Assembly), "LoadFrom", new System.Type[1] { typeof(string) }, (System.Type[])null);
							<>7__wrap2 = codes.GetEnumerator();
							<>1__state = -3;
							break;
						case 1:
							<>1__state = -3;
							break;
						case 2:
							<>1__state = -3;
							break;
						}
						if (((System.Collections.IEnumerator)<>7__wrap2).MoveNext())
						{
							CodeInstruction current = <>7__wrap2.Current;
							if (CodeInstructionExtensions.Calls(current, <loadFrom>5__2))
							{
								<>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(AssemblyLoadFixer), "LoadFrom", (System.Type[])null, (System.Type[])null));
								<>1__state = 1;
								return true;
							}
							<>2__current = current;
							<>1__state = 2;
							return true;
						}
						<>m__Finally1();
						<>7__wrap2 = null;
						return false;
					}
					catch
					{
						//try-fault
						((System.IDisposable)this).Dispose();
						throw;
					}
				}

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

				private void <>m__Finally1()
				{
					<>1__state = -1;
					if (<>7__wrap2 != null)
					{
						((System.IDisposable)<>7__wrap2).Dispose();
					}
				}

				[DebuggerHidden]
				void System.Collections.IEnumerator.Reset()
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					throw new NotSupportedException();
				}

				[DebuggerHidden]
				System.Collections.Generic.IEnumerator<CodeInstruction> System.Collections.Generic.IEnumerable<CodeInstruction>.GetEnumerator()
				{
					<Transpiler>d__0 <Transpiler>d__;
					if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
					{
						<>1__state = 0;
						<Transpiler>d__ = this;
					}
					else
					{
						<Transpiler>d__ = new <Transpiler>d__0(0);
					}
					<Transpiler>d__.codes = <>3__codes;
					return <Transpiler>d__;
				}

				[DebuggerHidden]
				System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
				{
					return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<CodeInstruction>)this).GetEnumerator();
				}
			}

			[IteratorStateMachine(typeof(<Transpiler>d__0))]
			public static System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(System.Collections.Generic.IEnumerable<CodeInstruction> codes)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Transpiler>d__0(-2)
				{
					<>3__codes = codes
				};
			}

			public static Assembly? LoadFrom(string path)
			{
				Log.LogDebug((object)("Bypassing LoadFrom: " + path));
				return null;
			}
		}

		[HarmonyPatchCategory("WindowTitlePatcher")]
		[HarmonyPatch(typeof(RendererInitData), "Pack")]
		private class WindowTitlePatcher
		{
			private static string? GetBepisLoaderVersion()
			{
				//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Expected O, but got Unknown
				try
				{
					Assembly val = Enumerable.FirstOrDefault<Assembly>((System.Collections.Generic.IEnumerable<Assembly>)AppDomain.CurrentDomain.GetAssemblies(), (Func<Assembly, bool>)((Assembly a) => a.GetName().Name == "BepisLoader"));
					if (val != (Assembly)null)
					{
						Version version = val.GetName().Version;
						if (version != (Version)null)
						{
							return $" v{version.Major}.{version.Minor}.{version.Build}";
						}
					}
				}
				catch (System.Exception ex)
				{
					ManualLogSource log = Log;
					bool flag = default(bool);
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(35, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Failed to get BepisLoader version: ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					}
					log.LogWarning(val2);
				}
				return null;
			}

			public static void Prefix(RendererInitData __instance)
			{
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Expected O, but got Unknown
				if (ShowWatermark.Value && __instance.windowTitle == "Resonite")
				{
					string bepisLoaderVersion = GetBepisLoaderVersion();
					string text = (__instance.windowTitle = "Resonite - BepisLoader" + bepisLoaderVersion);
					ManualLogSource log = Log;
					bool flag = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Successfully patched window title to: ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text);
					}
					log.LogInfo(val);
				}
			}
		}

		internal static ManualLogSource Log;

		private static ConfigEntry<bool> ShowWatermark;

		public override void Load()
		{
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_009b: Expected O, but got Unknown
			Log = ((BasePlugin)this).Log;
			ShowWatermark = ((BasePlugin)this).Config.Bind<bool>("General", "ShowWatermark", true, "Shows 'BepisLoader' watermark in the window title");
			System.Type type2 = null;
			try
			{
				System.Type[] types = GenericTypesAttribute.GetTypes((Group)1);
				foreach (System.Type type3 in types)
				{
					type2 = type3;
					if (!TomlTypeConverter.CanConvert(type3))
					{
						TomlTypeConverter.AddConverter(type3, new TypeConverter
						{
							ConvertToString = (object obj, System.Type type) => (string)((MethodBase)typeof(Coder<>).MakeGenericType(new System.Type[1] { type }).GetMethod("EncodeToString")).Invoke((object)null, new object[1] { obj }),
							ConvertToObject = (string str, System.Type type) => ((MethodBase)typeof(Coder<>).MakeGenericType(new System.Type[1] { type }).GetMethod("DecodeFromString")).Invoke((object)null, new object[1] { str })
						});
					}
				}
				type2 = typeof(dummy);
				TomlTypeConverter.AddConverter(typeof(dummy), new TypeConverter
				{
					ConvertToString = (object _, System.Type _) => "dummy",
					ConvertToObject = (string _, System.Type _) => (object)default(dummy)
				});
			}
			catch (System.Exception ex)
			{
				Log.LogError((object)("Failed to register generic type converters (Last attempted = " + (((object)type2)?.ToString() ?? "NULL") + "): " + (object)ex));
			}
			RunPatches();
		}

		private void RunPatches()
		{
			((BasePlugin)this).HarmonyInstance.PatchAllUncategorized();
			((BasePlugin)this).HarmonyInstance.SafePatchCategory("GraphicalClientPatch");
			((BasePlugin)this).HarmonyInstance.SafePatchCategory("WindowTitlePatcher");
			((BasePlugin)this).HarmonyInstance.SafePatchCategory("LogAlerter");
			((BasePlugin)this).HarmonyInstance.SafePatchCategory("RelativePathFixer");
		}
	}
	internal static class HarmonyExtensions
	{
		[field: CompilerGenerated]
		public static bool AnyPatchFailed
		{
			[CompilerGenerated]
			get;
			[CompilerGenerated]
			private set;
		}

		public static void SafePatchCategory(this Harmony instance, string categoryName)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			try
			{
				instance.PatchCategory(categoryName);
			}
			catch (System.Exception ex)
			{
				ManualLogSource log = BepInExResoniteShim.Log;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(18, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Failed to patch ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(categoryName);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<System.Exception>(ex);
				}
				log.LogError(val);
				AnyPatchFailed = true;
			}
		}
	}
	[HarmonyPatchCategory("GraphicalClientPatch")]
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal class GraphicalClientPatch
	{
		public static void Postfix(ref string ___AssemblyDirectory)
		{
			___AssemblyDirectory = Paths.GameRootPath;
		}
	}
	[HarmonyPatchCategory("LogAlerter")]
	[HarmonyPatch(typeof(UniLog), "add_OnLog")]
	internal class LogAlerter
	{
		private static void Postfix(Action<string> value)
		{
			if (HarmonyExtensions.AnyPatchFailed)
			{
				value.Invoke("[BepisLoader] BepInExResoniteShim partially loaded.");
			}
			else
			{
				value.Invoke("[BepisLoader] BepInExResoniteShim loaded successfully.");
			}
		}
	}
	internal class RelativePathFixer
	{
		[HarmonyPatchCategory("RelativePathFixer")]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		private class RenderiteHostPathFixes
		{
			[CompilerGenerated]
			private sealed class <Transpiler>d__0 : System.Collections.Generic.IEnumerable<CodeInstruction>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<CodeInstruction>, System.Collections.IEnumerator, System.IDisposable
			{
				private int <>1__state;

				private CodeInstruction <>2__current;

				private int <>l__initialThreadId;

				private System.Collections.Generic.IEnumerable<CodeInstruction> codes;

				public System.Collections.Generic.IEnumerable<CodeInstruction> <>3__codes;

				private System.Collections.Generic.IEnumerator<CodeInstruction> <>7__wrap1;

				CodeInstruction System.Collections.Generic.IEnumerator<CodeInstruction>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

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

				[DebuggerHidden]
				public <Transpiler>d__0(int <>1__state)
				{
					this.<>1__state = <>1__state;
					<>l__initialThreadId = Environment.CurrentManagedThreadId;
				}

				[DebuggerHidden]
				void System.IDisposable.Dispose()
				{
					int num = <>1__state;
					if (num == -3 || (uint)(num - 1) <= 3u)
					{
						try
						{
						}
						finally
						{
							<>m__Finally1();
						}
					}
					<>7__wrap1 = null;
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_005a: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
					//IL_006c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0080: Unknown result type (might be due to invalid IL or missing references)
					//IL_008a: Expected O, but got Unknown
					//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d6: Expected O, but got Unknown
					//IL_0110: Unknown result type (might be due to invalid IL or missing references)
					//IL_012b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0135: Expected O, but got Unknown
					try
					{
						switch (<>1__state)
						{
						default:
							return false;
						case 0:
							<>1__state = -1;
							<>7__wrap1 = codes.GetEnumerator();
							<>1__state = -3;
							break;
						case 1:
							<>1__state = -3;
							break;
						case 2:
							<>1__state = -3;
							break;
						case 3:
							<>1__state = -3;
							break;
						case 4:
							<>1__state = -3;
							break;
						}
						if (((System.Collections.IEnumerator)<>7__wrap1).MoveNext())
						{
							CodeInstruction current = <>7__wrap1.Current;
							if (CodeInstructionExtensions.Is(current, OpCodes.Ldstr, (object)"Logs"))
							{
								<>2__current = new CodeInstruction(OpCodes.Ldstr, (object)Path.Combine(Paths.GameRootPath, "Logs"));
								<>1__state = 1;
								return true;
							}
							if (CodeInstructionExtensions.Is(current, OpCodes.Ldstr, (object)"Icon.png"))
							{
								<>2__current = new CodeInstruction(OpCodes.Ldstr, (object)Path.Combine(Paths.GameRootPath, "Icon.png"));
								<>1__state = 2;
								return true;
							}
							object operand = current.operand;
							MethodInfo val = (MethodInfo)((operand is MethodInfo) ? operand : null);
							if (val != null && ((MemberInfo)val).Name == "WriteAllText")
							{
								<>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RenderiteHostPathFixes), "FileWriteInjected", (System.Type[])null, (System.Type[])null));
								<>1__state = 3;
								return true;
							}
							<>2__current = current;
							<>1__state = 4;
							return true;
						}
						<>m__Finally1();
						<>7__wrap1 = null;
						return false;
					}
					catch
					{
						//try-fault
						((System.IDisposable)this).Dispose();
						throw;
					}
				}

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

				private void <>m__Finally1()
				{
					<>1__state = -1;
					if (<>7__wrap1 != null)
					{
						((System.IDisposable)<>7__wrap1).Dispose();
					}
				}

				[DebuggerHidden]
				void System.Collections.IEnumerator.Reset()
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					throw new NotSupportedException();
				}

				[DebuggerHidden]
				System.Collections.Generic.IEnumerator<CodeInstruction> System.Collections.Generic.IEnumerable<CodeInstruction>.GetEnumerator()
				{
					<Transpiler>d__0 <Transpiler>d__;
					if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
					{
						<>1__state = 0;
						<Transpiler>d__ = this;
					}
					else
					{
						<Transpiler>d__ = new <Transpiler>d__0(0);
					}
					<Transpiler>d__.codes = <>3__codes;
					return <Transpiler>d__;
				}

				[DebuggerHidden]
				System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
				{
					return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<CodeInstruction>)this).GetEnumerator();
				}
			}

			[IteratorStateMachine(typeof(<Transpiler>d__0))]
			public static System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(System.Collections.Generic.IEnumerable<CodeInstruction> codes)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Transpiler>d__0(-2)
				{
					<>3__codes = codes
				};
			}

			public static void FileWriteInjected(string path, string? contents)
			{
				if (!Path.IsPathRooted(path))
				{
					path = Path.Combine(Paths.GameRootPath, path);
				}
				File.WriteAllText(path, contents);
			}
		}

		[HarmonyPatchCategory("RelativePathFixer")]
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		public class RenderiteWorkingDirectoryFix
		{
			[CompilerGenerated]
			private sealed class <Transpiler>d__0 : System.Collections.Generic.IEnumerable<CodeInstruction>, System.Collections.IEnumerable, System.Collections.Generic.IEnumerator<CodeInstruction>, System.Collections.IEnumerator, System.IDisposable
			{
				private int <>1__state;

				private CodeInstruction <>2__current;

				private int <>l__initialThreadId;

				private System.Collections.Generic.IEnumerable<CodeInstruction> codes;

				public System.Collections.Generic.IEnumerable<CodeInstruction> <>3__codes;

				private System.Collections.Generic.IEnumerator<CodeInstruction> <>7__wrap1;

				CodeInstruction System.Collections.Generic.IEnumerator<CodeInstruction>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

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

				[DebuggerHidden]
				public <Transpiler>d__0(int <>1__state)
				{
					this.<>1__state = <>1__state;
					<>l__initialThreadId = Environment.CurrentManagedThreadId;
				}

				[DebuggerHidden]
				void System.IDisposable.Dispose()
				{
					int num = <>1__state;
					if (num == -3 || (uint)(num - 1) <= 1u)
					{
						try
						{
						}
						finally
						{
							<>m__Finally1();
						}
					}
					<>7__wrap1 = null;
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_004f: 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_0075: Unknown result type (might be due to invalid IL or missing references)
					//IL_007f: Expected O, but got Unknown
					try
					{
						switch (<>1__state)
						{
						default:
							return false;
						case 0:
							<>1__state = -1;
							<>7__wrap1 = codes.GetEnumerator();
							<>1__state = -3;
							break;
						case 1:
							<>1__state = -3;
							break;
						case 2:
							<>1__state = -3;
							break;
						}
						if (((System.Collections.IEnumerator)<>7__wrap1).MoveNext())
						{
							CodeInstruction current = <>7__wrap1.Current;
							if (CodeInstructionExtensions.Is(current, OpCodes.Ldstr, (object)"Renderer"))
							{
								<>2__current = new CodeInstruction(OpCodes.Ldstr, (object)Path.Combine(Paths.GameRootPath, "Renderer"));
								<>1__state = 1;
								return true;
							}
							<>2__current = current;
							<>1__state = 2;
							return true;
						}
						<>m__Finally1();
						<>7__wrap1 = null;
						return false;
					}
					catch
					{
						//try-fault
						((System.IDisposable)this).Dispose();
						throw;
					}
				}

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

				private void <>m__Finally1()
				{
					<>1__state = -1;
					if (<>7__wrap1 != null)
					{
						((System.IDisposable)<>7__wrap1).Dispose();
					}
				}

				[DebuggerHidden]
				void System.Collections.IEnumerator.Reset()
				{
					//IL_0000: Unknown result type (might be due to invalid IL or missing references)
					throw new NotSupportedException();
				}

				[DebuggerHidden]
				System.Collections.Generic.IEnumerator<CodeInstruction> System.Collections.Generic.IEnumerable<CodeInstruction>.GetEnumerator()
				{
					<Transpiler>d__0 <Transpiler>d__;
					if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
					{
						<>1__state = 0;
						<Transpiler>d__ = this;
					}
					else
					{
						<Transpiler>d__ = new <Transpiler>d__0(0);
					}
					<Transpiler>d__.codes = <>3__codes;
					return <Transpiler>d__;
				}

				[DebuggerHidden]
				System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
				{
					return (System.Collections.IEnumerator)((System.Collections.Generic.IEnumerable<CodeInstruction>)this).GetEnumerator();
				}
			}

			[IteratorStateMachine(typeof(<Transpiler>d__0))]
			public static System.Collections.Generic.IEnumerable<CodeInstruction> Transpiler(System.Collections.Generic.IEnumerable<CodeInstruction> codes)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Transpiler>d__0(-2)
				{
					<>3__codes = codes
				};
			}
		}
	}
	public static class PluginMetadata
	{
		public const string GUID = "ResoniteModding.BepInExResoniteShim";

		public const string NAME = "BepInEx Resonite Shim";

		public const string VERSION = "0.9.1";

		public const string AUTHORS = "ResoniteModding";

		public const string REPOSITORY_URL = "https://github.com/ResoniteModding/BepInExResoniteShim";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(/*Could not decode attribute arguments.*/)]
	internal sealed class IgnoresAccessChecksToAttribute : System.Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}