Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of AddRunicLensToProcChain v1.0.4
plugins/AddRunicLensToProcChain.dll
Decompiled 4 months agousing System; using System.Collections; 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 Mdh.RoR2.GlobalEventManager; using Mdh.RoR2.MeteorAttackOnHighDamageBodyBehavior; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoDetour; using MonoDetour.Cil; using MonoDetour.DetourTypes; using MonoDetour.HookGen; using MonoMod.Cil; using RoR2; using UnityEngine; [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("AddRunicLensToProcChain")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+fb5d80210d9b23f8be1210fe8538b82d30dbac3e")] [assembly: AssemblyProduct("AddRunicLensToProcChain")] [assembly: AssemblyTitle("AddRunicLensToProcChain")] [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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 Mdh.RoR2.MeteorAttackOnHighDamageBodyBehavior { internal static class DetonateRunicLensMeteor { public delegate void PrefixSignature(MeteorAttackOnHighDamageBodyBehavior self); public delegate void PostfixSignature(MeteorAttackOnHighDamageBodyBehavior self); public static MonoDetourHook Prefix(PrefixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PrefixDetour>(Target(), (Delegate)hook, config, applyByDefault); } public static MonoDetourHook Postfix(PostfixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PostfixDetour>(Target(), (Delegate)hook, config, applyByDefault); } public static MonoDetourHook ILHook(Manipulator manipulator, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).ILHook(Target(), manipulator, config, applyByDefault); } public static MethodBase Target() { return typeof(MeteorAttackOnHighDamageBodyBehavior).GetMethod("DetonateRunicLensMeteor", (BindingFlags)(-1), null, Array.Empty<Type>(), null) ?? throw new MissingMethodException("RoR2.MeteorAttackOnHighDamageBodyBehavior", "DetonateRunicLensMeteor"); } } internal static class OnEnable { } internal static class GetAttackerInformation { } internal static class CalculateDamage { } internal static class FixedUpdate { } internal static class _ctor { } } namespace Mdh.RoR2.GlobalEventManager { internal static class Init { public delegate void PrefixSignature(); public delegate void PostfixSignature(); public static MonoDetourHook Prefix(PrefixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PrefixDetour>(Target(), (Delegate)hook, config, applyByDefault); } public static MonoDetourHook Postfix(PostfixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PostfixDetour>(Target(), (Delegate)hook, config, applyByDefault); } public static MonoDetourHook ILHook(Manipulator manipulator, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).ILHook(Target(), manipulator, config, applyByDefault); } public static MethodBase Target() { return typeof(GlobalEventManager).GetMethod("Init", (BindingFlags)(-1), null, Array.Empty<Type>(), null) ?? throw new MissingMethodException("RoR2.GlobalEventManager", "Init"); } } internal static class ProcessHitEnemy { public delegate void PrefixSignature(GlobalEventManager self, ref DamageInfo damageInfo, ref GameObject victim); public delegate void PostfixSignature(GlobalEventManager self, ref DamageInfo damageInfo, ref GameObject victim); public static MonoDetourHook Prefix(PrefixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PrefixDetour>(Target(), (Delegate)hook, config, applyByDefault); } public static MonoDetourHook Postfix(PostfixSignature hook, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).Hook<PostfixDetour>(Target(), (Delegate)hook, config, applyByDefault); } public static MonoDetourHook ILHook(Manipulator manipulator, MonoDetourConfig? config = null, bool applyByDefault = true, MonoDetourManager? manager = null) { return (manager ?? DefaultMonoDetourManager.Instance).ILHook(Target(), manipulator, config, applyByDefault); } public static MethodBase Target() { return typeof(GlobalEventManager).GetMethod("ProcessHitEnemy", (BindingFlags)(-1), null, new Type[2] { typeof(DamageInfo), typeof(GameObject) }, null) ?? throw new MissingMethodException("RoR2.GlobalEventManager", "ProcessHitEnemy"); } } internal static class OnEnable { } internal static class OnDisable { } internal static class IsImmuneToFallDamage { } internal static class OnHitEnemy { } internal static class ProcDeathMark { } internal static class FrozenExplosion { } internal static class HandleDamageWithNoAttacker { } internal static class OnCharacterHitGroundServer { } internal static class OnCharacterHitGroundSFX { } internal static class OnCharacterHitGround { } internal static class OnPlayerCharacterDeath { } internal static class add_onCharacterDeathGlobal { } internal static class remove_onCharacterDeathGlobal { } internal static class ProcIgniteOnKill { } internal static class OnCharacterDeath { } internal static class OnHitAll { } internal static class OnHitAllProcess { } internal static class OnCrit { } internal static class OnTeamLevelUp { } internal static class add_onTeamLevelUp { } internal static class remove_onTeamLevelUp { } internal static class OnCharacterLevelUp { } internal static class add_onCharacterLevelUp { } internal static class remove_onCharacterLevelUp { } internal static class add_OnInteractionsGlobal { } internal static class remove_OnInteractionsGlobal { } internal static class OnInteractionBegin { } internal static class add_onClientDamageNotified { } internal static class remove_onClientDamageNotified { } internal static class ClientDamageNotified { } internal static class add_onServerDamageDealt { } internal static class remove_onServerDamageDealt { } internal static class ServerDamageDealt { } internal static class add_onServerCharacterExecuted { } internal static class remove_onServerCharacterExecuted { } internal static class ServerCharacterExecuted { } internal static class _ctor { } internal static class _cctor { } internal static class _ProcessHitEnemy_g__LocalCheckRoll_10_0 { } internal static class _OnCharacterDeath_g__LocalCheckRoll_26_0 { } internal static class CommonAssets { internal static class Load { } internal static class __c { internal static class _cctor { } internal static class _ctor { } internal static class _Load_b__18_0 { } internal static class _Load_b__18_1 { } internal static class _Load_b__18_2 { } internal static class _Load_b__18_3 { } internal static class _Load_b__18_4 { } internal static class _Load_b__18_5 { } internal static class _Load_b__18_6 { } internal static class _Load_b__18_7 { } internal static class _Load_b__18_8 { } internal static class _Load_b__18_9 { } internal static class _Load_b__18_10 { } internal static class _Load_b__18_11 { } internal static class _Load_b__18_12 { } internal static class _Load_b__18_13 { } internal static class _Load_b__18_14 { } internal static class _Load_b__18_15 { } internal static class _Load_b__18_16 { } internal static class _Load_b__18_17 { } } } internal static class __c__DisplayClass10_0 { internal static class _ctor { } } internal static class __c__DisplayClass26_0 { internal static class _ctor { } } internal static class __c__DisplayClass26_1 { internal static class _ctor { } internal static class _OnCharacterDeath_b__1 { } } internal static class __c__DisplayClass41_0 { internal static class _ctor { } } internal static class __c__DisplayClass41_1 { internal static class _ctor { } internal static class _OnInteractionBegin_g__InteractableIsPermittedForSpawn_0 { } internal static class _OnInteractionBegin_b__1 { } } internal static class __c { internal static class _cctor { } internal static class _ctor { } internal static class __cctor_b__55_0 { } internal static class __cctor_b__55_1 { } } } namespace MonoDetour.HookGen { internal static class DefaultMonoDetourManager { internal static MonoDetourManager Instance { get; } = New(); internal static MonoDetourManager New() { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown return new MonoDetourManager(typeof(DefaultMonoDetourManager).Assembly.GetName().Name); } } [AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, AllowMultiple = true, Inherited = false)] internal class MonoDetourTargetsAttribute : Attribute, IMonoDetourTargets { public Type? TargetType { get; } public bool IncludeNestedTypes { get; set; } public string[]? Members { get; set; } public string[]? MemberNamePrefixes { get; set; } public string[]? MemberNameSuffixes { get; set; } public bool GenerateControlFlowVariants { get; set; } public MonoDetourTargetsAttribute(Type? targetType = null) { TargetType = targetType; IncludeNestedTypes = true; base..ctor(); } } } namespace AddRunicLensToProcChain { internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { } internal static void Error(object data) { _logSource.LogError(data); } internal static void Fatal(object data) { _logSource.LogFatal(data); } internal static void Info(object data) { _logSource.LogInfo(data); } internal static void Message(object data) { _logSource.LogMessage(data); } internal static void Warning(object data) { _logSource.LogWarning(data); } } internal static class Main { internal static void AddRunicLensToProcChainMask(ILManipulationInfo info) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_00d4: Unknown result type (might be due to invalid IL or missing references) ILWeaver w = new ILWeaver(info); int num4 = default(int); int num3 = default(int); int num2 = default(int); int num = default(int); w.MatchRelaxed(new Predicate<Instruction>[5] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num4) && w.SetCurrentTo(x), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num3), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num2), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "RunicLensUpdateVariables") }).ThrowIfFailure(); w.InsertBeforeCurrent((IEnumerable<InstructionOrEnumerable>)new <>z__ReadOnlyArray<InstructionOrEnumerable>((InstructionOrEnumerable[])(object)new InstructionOrEnumerable[2] { InstructionOrEnumerable.op_Implicit(w.Create(OpCodes.Ldarg_1)), InstructionOrEnumerable.op_Implicit(w.CreateDelegateCall<Action<DamageInfo>>((Action<DamageInfo>)delegate(DamageInfo damageInfo) { ((ProcChainMask)(ref damageInfo.procChainMask)).AddProc((ProcType)22); })) })); } internal static void UseTheActualProcChainMaskGodDamnit(ILManipulationInfo info) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) ILWeaver w = new ILWeaver(info); w.MatchRelaxed(new Predicate<Instruction>[3] { (Instruction x) => ILPatternMatchingExt.MatchDup(x), (Instruction x) => ILPatternMatchingExt.MatchLdflda<BlastAttack>(x, "procChainMask"), (Instruction x) => ILPatternMatchingExt.MatchInitobj<ProcChainMask>(x) && w.SetCurrentTo(x) }).ThrowIfFailure(); w.InsertAfterCurrent((IEnumerable<InstructionOrEnumerable>)new <>z__ReadOnlyArray<InstructionOrEnumerable>((InstructionOrEnumerable[])(object)new InstructionOrEnumerable[3] { InstructionOrEnumerable.op_Implicit(w.Create(OpCodes.Dup)), InstructionOrEnumerable.op_Implicit(w.Create(OpCodes.Ldloc_0)), InstructionOrEnumerable.op_Implicit(w.CreateDelegateCall<Action<BlastAttack, DamageInfo>>((Action<BlastAttack, DamageInfo>)delegate(BlastAttack blastAttack, DamageInfo damageInfo) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) blastAttack.procChainMask = damageInfo.procChainMask; })) })); } internal static void DebugLogProcChainMask(HealthComponent self, ref DamageInfo damageInfo) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) Log.Warning($"ProcChainMask is {damageInfo.procChainMask}"); } } [BepInPlugin("LordVGames.AddRunicLensToProcChain", "AddRunicLensToProcChain", "1.0.4")] public class Plugin : BaseUnityPlugin { [MonoDetourTargets(typeof(GlobalEventManager))] [MonoDetourTargets(typeof(MeteorAttackOnHighDamageBodyBehavior))] private static class Hooks { [CompilerGenerated] private static class <>O { public static Manipulator <0>__AddRunicLensToProcChainMask; public static Manipulator <1>__UseTheActualProcChainMaskGodDamnit; } [MonoDetourHookInitialize] private static void Setup() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown object obj = <>O.<0>__AddRunicLensToProcChainMask; if (obj == null) { Manipulator val = Main.AddRunicLensToProcChainMask; <>O.<0>__AddRunicLensToProcChainMask = val; obj = (object)val; } ProcessHitEnemy.ILHook((Manipulator)obj); object obj2 = <>O.<1>__UseTheActualProcChainMaskGodDamnit; if (obj2 == null) { Manipulator val2 = Main.UseTheActualProcChainMaskGodDamnit; <>O.<1>__UseTheActualProcChainMaskGodDamnit = val2; obj2 = (object)val2; } DetonateRunicLensMeteor.ILHook((Manipulator)obj2); } } public const string PluginGUID = "LordVGames.AddRunicLensToProcChain"; public const string PluginAuthor = "LordVGames"; public const string PluginName = "AddRunicLensToProcChain"; public const string PluginVersion = "1.0.4"; public void Awake() { Log.Init(((BaseUnityPlugin)this).Logger); MonoDetourManager.InvokeHookInitializers(typeof(Plugin).Assembly); } } } [CompilerGenerated] internal sealed class <>z__ReadOnlyArray<T> : IEnumerable, ICollection, IList, IEnumerable<T>, IReadOnlyCollection<T>, IReadOnlyList<T>, ICollection<T>, IList<T> { int ICollection.Count => _items.Length; bool ICollection.IsSynchronized => false; object ICollection.SyncRoot => this; object IList.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } bool IList.IsFixedSize => true; bool IList.IsReadOnly => true; int IReadOnlyCollection<T>.Count => _items.Length; T IReadOnlyList<T>.this[int index] => _items[index]; int ICollection<T>.Count => _items.Length; bool ICollection<T>.IsReadOnly => true; T IList<T>.this[int index] { get { return _items[index]; } set { throw new NotSupportedException(); } } public <>z__ReadOnlyArray(T[] items) { _items = items; } IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)_items).GetEnumerator(); } void ICollection.CopyTo(Array array, int index) { ((ICollection)_items).CopyTo(array, index); } int IList.Add(object value) { throw new NotSupportedException(); } void IList.Clear() { throw new NotSupportedException(); } bool IList.Contains(object value) { return ((IList)_items).Contains(value); } int IList.IndexOf(object value) { return ((IList)_items).IndexOf(value); } void IList.Insert(int index, object value) { throw new NotSupportedException(); } void IList.Remove(object value) { throw new NotSupportedException(); } void IList.RemoveAt(int index) { throw new NotSupportedException(); } IEnumerator<T> IEnumerable<T>.GetEnumerator() { return ((IEnumerable<T>)_items).GetEnumerator(); } void ICollection<T>.Add(T item) { throw new NotSupportedException(); } void ICollection<T>.Clear() { throw new NotSupportedException(); } bool ICollection<T>.Contains(T item) { return ((ICollection<T>)_items).Contains(item); } void ICollection<T>.CopyTo(T[] array, int arrayIndex) { ((ICollection<T>)_items).CopyTo(array, arrayIndex); } bool ICollection<T>.Remove(T item) { throw new NotSupportedException(); } int IList<T>.IndexOf(T item) { return ((IList<T>)_items).IndexOf(item); } void IList<T>.Insert(int index, T item) { throw new NotSupportedException(); } void IList<T>.RemoveAt(int index) { throw new NotSupportedException(); } }