Decompiled source of 000KindredFix v1.0.4

BepInEx/plugins/KindredFix.dll

Decompiled 2 weeks 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 BepInEx;
using BepInEx.Logging;
using Kindred;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using RoR2;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("KindredFix")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Fixes kindred arrow bug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("KindredFix")]
[assembly: AssemblyTitle("KindredFix")]
[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 KindredFix
{
	[BepInPlugin("000KindredFix", "Kindred Fix", "1.0.4")]
	public class KindredFixPlugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__KindredBehaviourFixedUpdate_ILHook;
		}

		public static KindredFixPlugin Instance;

		public ManualLogSource mls;

		public ILHook _ilhook3;

		private KindredFixPlugin()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0042: 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_004d: Expected O, but got Unknown
			try
			{
				Instance = this;
				mls = ((BaseUnityPlugin)this).Logger;
				MethodInfo? method = typeof(KindredBehaviour).GetMethod("FixedUpdate", BindingFlags.Instance | BindingFlags.NonPublic);
				object obj = <>O.<0>__KindredBehaviourFixedUpdate_ILHook;
				if (obj == null)
				{
					Manipulator val = KindredFixesIL.KindredBehaviourFixedUpdate_ILHook;
					<>O.<0>__KindredBehaviourFixedUpdate_ILHook = val;
					obj = (object)val;
				}
				_ilhook3 = new ILHook((MethodBase)method, (Manipulator)obj);
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Error while trying to apply fix: {arg}");
			}
		}
	}
	public static class KindredFixesIL
	{
		internal static void KindredBehaviourFixedUpdate_ILHook(ILContext ctx)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(ctx);
			ILLabel val2 = val.DefineLabel();
			if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[7]
			{
				(Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Ldsfld),
				(Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Ldc_I4_0),
				(Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Ldloc_2),
				(Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Callvirt),
				(Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Callvirt),
				(Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Callvirt),
				(Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Stloc_3)
			}))
			{
				KindredFixPlugin.Instance.mls.LogError((object)"Target 1 not found!");
				return;
			}
			int index = val.Index;
			val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.Match(x, OpCodes.Stloc_3)
			});
			val.MarkLabel(val2);
			val.Index = index;
			val.Emit(OpCodes.Ldloc_2);
			val.EmitDelegate<Func<List<CharacterBody>, bool>>((Func<List<CharacterBody>, bool>)((List<CharacterBody> list) => list.Count == 0));
			val.Emit(OpCodes.Brtrue, (object)val2);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "KindredFix";

		public const string PLUGIN_NAME = "KindredFix";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}