Decompiled source of SeekersPatcher v1.3.2

BepInEx/patchers/SeekersPatcher/SeekersPatcher.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using Mono.Cecil;
using Mono.Cecil.Cil;
using Mono.Cecil.Rocks;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("SeekersPatcher")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SeekersPatcher")]
[assembly: AssemblyTitle("SeekersPatcher")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
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 _SeekersPatcher
{
	public static class _SeekersPatcher
	{
		internal static class Logger
		{
			private static readonly ManualLogSource logSource = Logger.CreateLogSource("SeekersPatcher");

			public static void Info(object data)
			{
				logSource.LogInfo(data);
			}

			public static void Error(object data)
			{
				logSource.LogError(data);
			}

			public static void Warn(object data)
			{
				logSource.LogWarning(data);
			}

			public static void Fatal(object data)
			{
				logSource.LogFatal(data);
			}

			public static void Message(object data)
			{
				logSource.LogMessage(data);
			}

			public static void Debug(object data)
			{
				logSource.LogDebug(data);
			}
		}

		public static MethodReference fixedDeltaTime;

		public static IEnumerable<string> TargetDLLs => new string[1] { "RoR2.dll" };

		public static void Patch(AssemblyDefinition def)
		{
			if (((AssemblyNameReference)def.Name).Name == "RoR2")
			{
				PatchRoR2(def);
			}
		}

		private static void PatchRoR2(AssemblyDefinition def)
		{
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Expected O, but got Unknown
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Expected O, but got Unknown
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Expected O, but got Unknown
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Expected O, but got Unknown
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Expected O, but got Unknown
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Expected O, but got Unknown
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Expected O, but got Unknown
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Expected O, but got Unknown
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Expected O, but got Unknown
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Expected O, but got Unknown
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Expected O, but got Unknown
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a6: Expected O, but got Unknown
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Expected O, but got Unknown
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Expected O, but got Unknown
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Expected O, but got Unknown
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Expected O, but got Unknown
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Expected O, but got Unknown
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Expected O, but got Unknown
			//IL_048d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Expected O, but got Unknown
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Expected O, but got Unknown
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			AssemblyDefinition val = AssemblyDefinition.ReadAssembly(typeof(void).Assembly.Location);
			TypeReference val2 = val.MainModule.ImportReference(typeof(void));
			AssemblyDefinition val3 = AssemblyDefinition.ReadAssembly(Path.Combine(Paths.ManagedPath, "UnityEngine.CoreModule.dll"));
			TypeDefinition type = def.MainModule.GetType("RoR2.ItemDef");
			TypeDefinition type2 = def.MainModule.GetType("RoR2.BuffDef");
			TypeReference val4 = val.MainModule.ImportReference(typeof(float));
			TypeReference val5 = val.MainModule.ImportReference(typeof(bool));
			TypeReference val6 = def.MainModule.ImportReference((TypeReference)(object)def.MainModule.GetType("RoR2.DamageColorIndex"));
			TypeReference val7 = def.MainModule.ImportReference((TypeReference)(object)val3.MainModule.GetType("UnityEngine.Vector3"));
			TypeReference val8 = def.MainModule.ImportReference((TypeReference)(object)val3.MainModule.GetType("UnityEngine.Quaternion"));
			TypeReference val9 = def.MainModule.ImportReference((TypeReference)(object)val3.MainModule.GetType("UnityEngine.GameObject"));
			TypeDefinition type3 = def.MainModule.GetType("RoR2.DamageType");
			TypeDefinition type4 = def.MainModule.GetType("RoR2.DLC2Content/Items");
			type4.Fields.Add(new FieldDefinition("NegateAttack", (FieldAttributes)22, def.MainModule.ImportReference((TypeReference)(object)type)));
			type4.Fields.Add(new FieldDefinition("LowerHealthHigherDamage", (FieldAttributes)22, def.MainModule.ImportReference((TypeReference)(object)type)));
			type4.Fields.Add(new FieldDefinition("GoldOnStageStart", (FieldAttributes)22, def.MainModule.ImportReference((TypeReference)(object)type)));
			type4.Fields.Add(new FieldDefinition("ResetChests", (FieldAttributes)22, def.MainModule.ImportReference((TypeReference)(object)type)));
			TypeDefinition type5 = def.MainModule.GetType("RoR2.DLC2Content/Buffs");
			type5.Fields.Add(new FieldDefinition("LowerHealthHigherDamageBuff", (FieldAttributes)22, def.MainModule.ImportReference((TypeReference)(object)type2)));
			TypeDefinition type6 = def.MainModule.GetType("RoR2.Projectile.ProjectileManager");
			MethodDefinition val10 = new MethodDefinition("FireProjectile", (MethodAttributes)6, val2);
			((MethodReference)val10).Parameters.Add(new ParameterDefinition(val9));
			((MethodReference)val10).Parameters.Add(new ParameterDefinition(val7));
			((MethodReference)val10).Parameters.Add(new ParameterDefinition(val8));
			((MethodReference)val10).Parameters.Add(new ParameterDefinition(val9));
			((MethodReference)val10).Parameters.Add(new ParameterDefinition(val4));
			((MethodReference)val10).Parameters.Add(new ParameterDefinition(val4));
			((MethodReference)val10).Parameters.Add(new ParameterDefinition(val5));
			((MethodReference)val10).Parameters.Add(new ParameterDefinition(val6));
			((MethodReference)val10).Parameters.Add(new ParameterDefinition(val9));
			((MethodReference)val10).Parameters.Add(new ParameterDefinition(val4));
			val10.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));
			type6.Methods.Add(val10);
			TypeDefinition type7 = def.MainModule.GetType("RoR2.PlayerCharacterMasterController");
			type7.Fields.Add(new FieldDefinition("wasClaimed", (FieldAttributes)6, val5));
			MethodDefinition val11 = TypeDefinitionRocks.GetMethods(type7).First((MethodDefinition x) => ((MemberReference)x).Name == "Update");
			int num = val11.Body.Instructions.Count - 1;
			val11.Body.Instructions.Insert(num, Instruction.Create(OpCodes.Ldarg_0));
			val11.Body.Instructions.Insert(num + 1, Instruction.Create(OpCodes.Ldarg_0));
			val11.Body.Instructions.Insert(num + 2, Instruction.Create(OpCodes.Ldfld, (FieldReference)(object)((IEnumerable<FieldDefinition>)type7.Fields).First((FieldDefinition x) => ((MemberReference)x).Name == "jumpWasClaimed")));
			val11.Body.Instructions.Insert(num + 3, Instruction.Create(OpCodes.Stfld, (FieldReference)(object)((IEnumerable<FieldDefinition>)type7.Fields).First((FieldDefinition x) => ((MemberReference)x).Name == "wasClaimed")));
			TypeDefinition type8 = def.MainModule.GetType("RoR2.HealthComponent");
			MethodDefinition val12 = new MethodDefinition("Suicide", (MethodAttributes)6, val2);
			((MethodReference)val12).Parameters.Add(new ParameterDefinition(val9));
			((MethodReference)val12).Parameters.Add(new ParameterDefinition(val9));
			((MethodReference)val12).Parameters.Add(new ParameterDefinition((TypeReference)(object)type3));
			val12.Body.Instructions.Add(Instruction.Create(OpCodes.Ret));
			type8.Methods.Add(val12);
		}
	}
}

SeekersPatcherDLL.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using MonoMod.RuntimeDetour;
using On.RoR2;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Projectile;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("SeekersPatcherDLL")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SeekersPatcherDLL")]
[assembly: AssemblyTitle("SeekersPatcherDLL")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
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 SeekersPatcherDLL
{
	[BepInPlugin("___0pseudopulse.__SeekersPatcherDLL", "__SeekersPatcherDLL", "1.0.0")]
	public class _0Main : BaseUnityPlugin
	{
		public delegate void orig_ctor(Hook hook, MethodBase from, MethodBase to, object delegTarg, ref HookConfig conf);

		public delegate void orig_Add(MethodBase method, Delegate hookDelegate);

		public delegate void orig_Suicide(HealthComponent instance, GameObject p1, GameObject p2, DamageType dt);

		public delegate void orig_FireProjectile(ProjectileManager instance, GameObject p1, Vector3 p2, Quaternion p3, GameObject p4, float p5, float p6, bool p7, DamageColorIndex p8, GameObject p9, float p10);

		public const string PluginGUID = "___0pseudopulse.__SeekersPatcherDLL";

		public const string PluginAuthor = "___0pseudopulse";

		public const string PluginName = "__SeekersPatcherDLL";

		public const string PluginVersion = "1.0.0";

		public static ManualLogSource ModLogger;

		public static MethodInfo Update;

		public void Awake()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Expected O, but got Unknown
			ModLogger = ((BaseUnityPlugin)this).Logger;
			DLC2Content.LoadStaticContentAsync += new hook_LoadStaticContentAsync(OnLoadContent);
			((BaseUnityPlugin)this).Logger.LogError((object)(from x in typeof(ProjectileManager).GetMethods(BindingFlags.Instance | BindingFlags.Public)
				where x.Name == "FireProjectile"
				orderby x.GetParameters().Length
				select x).ElementAt(1));
			Hook val = new Hook((MethodBase)(from x in typeof(ProjectileManager).GetMethods(BindingFlags.Instance | BindingFlags.Public)
				where x.Name == "FireProjectile"
				orderby x.GetParameters().Length
				select x).ElementAt(1), typeof(_0Main).GetMethod("FireProjectile", BindingFlags.Static | BindingFlags.Public));
			Hook val2 = new Hook((MethodBase)(from x in typeof(HealthComponent).GetMethods(BindingFlags.Instance | BindingFlags.Public)
				where x.Name == "Suicide"
				select x).FirstOrDefault((MethodInfo x) => x.GetParameters()[x.GetParameters().Length - 1].ParameterType == typeof(DamageType)), typeof(_0Main).GetMethod("Suicide", BindingFlags.Static | BindingFlags.Public));
		}

		public static void OnAdd(orig_Add orig, MethodBase method, Delegate hook)
		{
			if (method.Name == "FixedUpdate" && method.DeclaringType.Name == "Stage")
			{
				orig(Update, hook);
			}
			else
			{
				orig(method, hook);
			}
		}

		public static void Suicide(orig_Suicide orig, HealthComponent self, GameObject p1, GameObject p2, DamageType p3)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			self.Suicide(p1, p2, DamageTypeCombo.op_Implicit(p3));
		}

		public static void FireProjectile(orig_FireProjectile orig, ProjectileManager instance, GameObject p1, Vector3 p2, Quaternion p3, GameObject p4, float p5, float p6, bool p7, DamageColorIndex p8, GameObject p9, float p10)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			ProjectileManager.instance.FireProjectile(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10, (DamageTypeCombo?)null);
		}

		private IEnumerator OnLoadContent(orig_LoadStaticContentAsync orig, DLC2Content self, LoadStaticContentAsyncArgs args)
		{
			yield return orig.Invoke(self, args);
			typeof(Items).GetField("NegateAttack").SetValue(null, Items.SpeedBoostPickup);
			typeof(Items).GetField("GoldOnStageStart").SetValue(null, Items.BarrageOnBoss);
			typeof(Items).GetField("ResetChests").SetValue(null, Items.ItemDropChanceOnKill);
			typeof(Items).GetField("LowerHealthHigherDamage").SetValue(null, Items.AttackSpeedPerNearbyAllyOrEnemy);
			typeof(Buffs).GetField("LowerHealthHigherDamageBuff").SetValue(null, Buffs.AttackSpeedPerNearbyAllyOrEnemyBuff);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}