Decompiled source of SeekersPatcher v1.3.7
BepInEx/patchers/SeekersPatcher/SeekersPatcher.dll
Decompiled 5 days agousing 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_0172: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Expected O, but got Unknown //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: Expected O, but got Unknown //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Expected O, but got Unknown //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Expected O, but got Unknown //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0223: Expected O, but got Unknown //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown //IL_024d: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_026b: Expected O, but got Unknown //IL_0275: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Expected O, but got Unknown //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Expected O, but got Unknown //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: Expected O, but got Unknown //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Expected O, but got Unknown //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Expected O, but got Unknown //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Expected O, but got Unknown //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_02f7: Expected O, but got Unknown //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_030b: Expected O, but got Unknown //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0358: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Expected O, but got Unknown //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_03d3: Unknown result type (might be due to invalid IL or missing references) //IL_03f3: Unknown result type (might be due to invalid IL or missing references) //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0492: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Expected O, but got Unknown //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04ac: Expected O, but got Unknown //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04c0: Expected O, but got Unknown //IL_04ca: Unknown result type (might be due to invalid IL or missing references) //IL_04d4: Expected O, but got Unknown //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_052b: Expected O, but got Unknown //IL_0545: Unknown result type (might be due to invalid IL or missing references) //IL_054c: Expected O, but got Unknown //IL_0555: Unknown result type (might be due to invalid IL or missing references) //IL_055f: Expected O, but got Unknown //IL_056c: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Expected O, but got Unknown 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(int)); TypeReference val6 = val.MainModule.ImportReference(typeof(bool)); TypeReference val7 = def.MainModule.ImportReference((TypeReference)(object)def.MainModule.GetType("RoR2.DamageColorIndex")); TypeReference val8 = def.MainModule.ImportReference((TypeReference)(object)val3.MainModule.GetType("UnityEngine.Vector3")); TypeReference val9 = def.MainModule.ImportReference((TypeReference)(object)val3.MainModule.GetType("UnityEngine.Quaternion")); TypeReference val10 = def.MainModule.ImportReference((TypeReference)(object)val3.MainModule.GetType("UnityEngine.GameObject")); TypeDefinition type3 = def.MainModule.GetType("RoR2.DamageType"); TypeDefinition type4 = def.MainModule.GetType("RoR2.Skills.SkillDef"); TypeDefinition type5 = def.MainModule.GetType("RoR2.DLC2Content/Items"); type5.Fields.Add(new FieldDefinition("NegateAttack", (FieldAttributes)22, def.MainModule.ImportReference((TypeReference)(object)type))); type5.Fields.Add(new FieldDefinition("LowerHealthHigherDamage", (FieldAttributes)22, def.MainModule.ImportReference((TypeReference)(object)type))); type5.Fields.Add(new FieldDefinition("GoldOnStageStart", (FieldAttributes)22, def.MainModule.ImportReference((TypeReference)(object)type))); type5.Fields.Add(new FieldDefinition("ResetChests", (FieldAttributes)22, def.MainModule.ImportReference((TypeReference)(object)type))); TypeDefinition type6 = def.MainModule.GetType("RoR2.DLC2Content/Buffs"); type6.Fields.Add(new FieldDefinition("LowerHealthHigherDamageBuff", (FieldAttributes)22, def.MainModule.ImportReference((TypeReference)(object)type2))); TypeDefinition type7 = def.MainModule.GetType("RoR2.Projectile.ProjectileManager"); MethodDefinition val11 = new MethodDefinition("FireProjectile", (MethodAttributes)6, val2); ((MethodReference)val11).Parameters.Add(new ParameterDefinition(val10)); ((MethodReference)val11).Parameters.Add(new ParameterDefinition(val8)); ((MethodReference)val11).Parameters.Add(new ParameterDefinition(val9)); ((MethodReference)val11).Parameters.Add(new ParameterDefinition(val10)); ((MethodReference)val11).Parameters.Add(new ParameterDefinition(val4)); ((MethodReference)val11).Parameters.Add(new ParameterDefinition(val4)); ((MethodReference)val11).Parameters.Add(new ParameterDefinition(val6)); ((MethodReference)val11).Parameters.Add(new ParameterDefinition(val7)); ((MethodReference)val11).Parameters.Add(new ParameterDefinition(val10)); ((MethodReference)val11).Parameters.Add(new ParameterDefinition(val4)); val11.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); type7.Methods.Add(val11); TypeDefinition type8 = def.MainModule.GetType("RoR2.PlayerCharacterMasterController"); type8.Fields.Add(new FieldDefinition("wasClaimed", (FieldAttributes)6, val6)); MethodDefinition val12 = TypeDefinitionRocks.GetMethods(type8).First((MethodDefinition x) => ((MemberReference)x).Name == "Update"); int num = val12.Body.Instructions.Count - 1; val12.Body.Instructions.Insert(num, Instruction.Create(OpCodes.Ldarg_0)); val12.Body.Instructions.Insert(num + 1, Instruction.Create(OpCodes.Ldarg_0)); val12.Body.Instructions.Insert(num + 2, Instruction.Create(OpCodes.Ldfld, (FieldReference)(object)((IEnumerable<FieldDefinition>)type8.Fields).First((FieldDefinition x) => ((MemberReference)x).Name == "jumpWasClaimed"))); val12.Body.Instructions.Insert(num + 3, Instruction.Create(OpCodes.Stfld, (FieldReference)(object)((IEnumerable<FieldDefinition>)type8.Fields).First((FieldDefinition x) => ((MemberReference)x).Name == "wasClaimed"))); TypeDefinition type9 = def.MainModule.GetType("RoR2.HealthComponent"); MethodDefinition val13 = new MethodDefinition("Suicide", (MethodAttributes)6, val2); ((MethodReference)val13).Parameters.Add(new ParameterDefinition(val10)); ((MethodReference)val13).Parameters.Add(new ParameterDefinition(val10)); ((MethodReference)val13).Parameters.Add(new ParameterDefinition((TypeReference)(object)type3)); val13.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); type9.Methods.Add(val13); TypeDefinition type10 = def.MainModule.GetType("RoR2.CharacterModel"); type10.Fields.Add(new FieldDefinition("invisibilityCount", (FieldAttributes)6, val5)); TypeDefinition type11 = def.MainModule.GetType("RoR2.GenericSkill"); MethodDefinition val14 = new MethodDefinition("AssignSkill", (MethodAttributes)6, val2); ((MethodReference)val14).Parameters.Add(new ParameterDefinition((TypeReference)(object)type4)); val14.Body.Instructions.Add(Instruction.Create(OpCodes.Ret)); type11.Methods.Add(val14); TypeDefinition type12 = def.MainModule.GetType("RoR2.CharacterBody"); type12.Fields.Add(new FieldDefinition("damageFromRecalculateStats", (FieldAttributes)6, val4)); } } }
SeekersPatcherDLL.dll
Decompiled 5 days agousing 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 IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using MonoMod.Cil; using MonoMod.RuntimeDetour; using On.RoR2; using RoR2; using RoR2.ContentManagement; using RoR2.Projectile; using RoR2.Skills; 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("RoR2")] [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_AssignSkill(GenericSkill skill, SkillDef p1); 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); [CompilerGenerated] private static class <>O { public static Manipulator <0>__Invisibility; public static Manipulator <1>__InvisibilitySet; } 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 FieldInfo invisCount; public static MethodInfo Update; public static FieldInfo damageFromRecalculateStats; public void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Expected O, but got Unknown //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_025d: Expected O, but got Unknown //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Expected O, but got Unknown //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown //IL_029b: Unknown result type (might be due to invalid IL or missing references) //IL_02a5: Expected O, but got Unknown //IL_0282: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Expected O, but got Unknown ModLogger = ((BaseUnityPlugin)this).Logger; invisCount = typeof(CharacterModel).GetField("invisibilityCount", (BindingFlags)(-1)); damageFromRecalculateStats = typeof(CharacterBody).GetField("damageFromRecalculateStats", (BindingFlags)(-1)); 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)); Hook val3 = new Hook((MethodBase)(from x in typeof(GenericSkill).GetMethods((BindingFlags)(-1)) where x.Name == "AssignSkill" orderby x.GetParameters().Length select x).ElementAt(0), typeof(_0Main).GetMethod("AssignSkill", BindingFlags.Static | BindingFlags.Public)); MethodInfo? method = typeof(CharacterModel).GetMethod("get_invisibilityCount", (BindingFlags)(-1)); object obj = <>O.<0>__Invisibility; if (obj == null) { Manipulator val4 = Invisibility; <>O.<0>__Invisibility = val4; obj = (object)val4; } ILHook val5 = new ILHook((MethodBase)method, (Manipulator)obj); MethodInfo? method2 = typeof(CharacterModel).GetMethod("set_invisibilityCount", (BindingFlags)(-1)); object obj2 = <>O.<1>__InvisibilitySet; if (obj2 == null) { Manipulator val6 = InvisibilitySet; <>O.<1>__InvisibilitySet = val6; obj2 = (object)val6; } ILHook val7 = new ILHook((MethodBase)method2, (Manipulator)obj2); CharacterBody.RecalculateStats += new Manipulator(DamageFromRecalc); } private void DamageFromRecalc(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStfld(x, "RoR2.CharacterBody", "statsDirty") }); val.Emit(OpCodes.Ldarg_0); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<CharacterBody, float>>((Func<CharacterBody, float>)((CharacterBody cb) => cb.damage)); val.Emit(OpCodes.Stfld, damageFromRecalculateStats); } public static void Invisibility(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); FieldReference val2 = default(FieldReference); val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val2) }); val.Next.Operand = invisCount; } public static void InvisibilitySet(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown ILCursor val = new ILCursor(il); FieldReference val3 = default(FieldReference); val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val3) }); val.Next.Operand = invisCount; FieldReference val2 = default(FieldReference); val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchStfld(x, ref val2) }); val.Next.Operand = invisCount; } public static void UselessMethod(string y) { } 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 AssignSkill(orig_AssignSkill orig, GenericSkill self, SkillDef p1) { self.AssignSkill(p1, false); } 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) { } } }