Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of R2API Skills v1.0.4
plugins/R2API.Skills/R2API.Skills.dll
Decompiled 3 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using IL.RoR2; using IL.RoR2.UI; using Microsoft.CodeAnalysis; using Mono.Cecil; using Mono.Cecil.Cil; using Mono.Cecil.Rocks; using MonoMod.Cil; using On.RoR2; using R2API.AutoVersionGen; using R2API.Skills.Interop; using R2API.Utils; using RoR2; using RoR2.Skills; using RoR2.UI; 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("R2API.Skills")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: AssemblyInformationalVersion("1.0.4+1a241d5d76196dd20668293ef773b18ec18572cd")] [assembly: AssemblyProduct("R2API.Skills")] [assembly: AssemblyTitle("R2API.Skills")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.4.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 System.Diagnostics.CodeAnalysis { [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal sealed class MemberNotNullAttribute : Attribute { public string[] Members { get; } public MemberNotNullAttribute(string member) { Members = new string[1] { member }; } public MemberNotNullAttribute(params string[] members) { Members = members; } } [AttributeUsage(AttributeTargets.Method | AttributeTargets.Property, Inherited = false, AllowMultiple = true)] [ExcludeFromCodeCoverage] [DebuggerNonUserCode] internal sealed class MemberNotNullWhenAttribute : Attribute { public bool ReturnValue { get; } public string[] Members { get; } public MemberNotNullWhenAttribute(bool returnValue, string member) { ReturnValue = returnValue; Members = new string[1] { member }; } public MemberNotNullWhenAttribute(bool returnValue, params string[] members) { ReturnValue = returnValue; Members = members; } } } namespace R2API { [AutoVersion] public static class SkillsAPI { [StructLayout(LayoutKind.Sequential, Size = 1)] private struct GenericSkillComparer : IComparer<GenericSkill> { public readonly int Compare(GenericSkill x, GenericSkill y) { return x.GetOrderPriority() - y.GetOrderPriority(); } } [CompilerGenerated] private static class <>O { public static Manipulator <0>__LoadoutPanelControllerRebuildHook; public static Manipulator <1>__LoadoutPanelControllerRowFromSkillSlotHook; public static Manipulator <2>__CharacterSelectControllerBuildSkillStripDisplayDataHook; public static Manipulator <3>__GenericSkill_RecalculateMaxStock; public static Manipulator <4>__SkillIcon_Update; public static <>F{00000058}<Loadout, BodyInfo, GenericSkill[], int[]> <5>__CharacterSelectControllerRemoveAndSortSkills; public static Func<List<GenericSkill>, CharacterBody, int[]> <6>__LoadoutPanelControllerRemoveAndSortSkills; public static Func<string, GenericSkill, string> <7>__LoadoutPanelControllerReplaceTitleToken; } public const string PluginGUID = "com.bepis.r2api.skills"; public const string PluginName = "R2API.Skills"; public const string PluginVersion = "1.0.4"; internal static void SetHooks() { //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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0070: 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_007b: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown object obj = <>O.<0>__LoadoutPanelControllerRebuildHook; if (obj == null) { Manipulator val = LoadoutPanelControllerRebuildHook; <>O.<0>__LoadoutPanelControllerRebuildHook = val; obj = (object)val; } LoadoutPanelController.Rebuild += (Manipulator)obj; object obj2 = <>O.<1>__LoadoutPanelControllerRowFromSkillSlotHook; if (obj2 == null) { Manipulator val2 = LoadoutPanelControllerRowFromSkillSlotHook; <>O.<1>__LoadoutPanelControllerRowFromSkillSlotHook = val2; obj2 = (object)val2; } Row.FromSkillSlot += (Manipulator)obj2; object obj3 = <>O.<2>__CharacterSelectControllerBuildSkillStripDisplayDataHook; if (obj3 == null) { Manipulator val3 = CharacterSelectControllerBuildSkillStripDisplayDataHook; <>O.<2>__CharacterSelectControllerBuildSkillStripDisplayDataHook = val3; obj3 = (object)val3; } CharacterSelectController.BuildSkillStripDisplayData += (Manipulator)obj3; object obj4 = <>O.<3>__GenericSkill_RecalculateMaxStock; if (obj4 == null) { Manipulator val4 = GenericSkill_RecalculateMaxStock; <>O.<3>__GenericSkill_RecalculateMaxStock = val4; obj4 = (object)val4; } GenericSkill.RecalculateMaxStock += (Manipulator)obj4; object obj5 = <>O.<4>__SkillIcon_Update; if (obj5 == null) { Manipulator val5 = SkillIcon_Update; <>O.<4>__SkillIcon_Update = val5; obj5 = (object)val5; } SkillIcon.Update += (Manipulator)obj5; } internal static void UnsetHooks() { //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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Expected O, but got Unknown //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Expected O, but got Unknown //IL_0070: 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_007b: Expected O, but got Unknown //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Expected O, but got Unknown object obj = <>O.<0>__LoadoutPanelControllerRebuildHook; if (obj == null) { Manipulator val = LoadoutPanelControllerRebuildHook; <>O.<0>__LoadoutPanelControllerRebuildHook = val; obj = (object)val; } LoadoutPanelController.Rebuild -= (Manipulator)obj; object obj2 = <>O.<1>__LoadoutPanelControllerRowFromSkillSlotHook; if (obj2 == null) { Manipulator val2 = LoadoutPanelControllerRowFromSkillSlotHook; <>O.<1>__LoadoutPanelControllerRowFromSkillSlotHook = val2; obj2 = (object)val2; } Row.FromSkillSlot -= (Manipulator)obj2; object obj3 = <>O.<2>__CharacterSelectControllerBuildSkillStripDisplayDataHook; if (obj3 == null) { Manipulator val3 = CharacterSelectControllerBuildSkillStripDisplayDataHook; <>O.<2>__CharacterSelectControllerBuildSkillStripDisplayDataHook = val3; obj3 = (object)val3; } CharacterSelectController.BuildSkillStripDisplayData -= (Manipulator)obj3; object obj4 = <>O.<3>__GenericSkill_RecalculateMaxStock; if (obj4 == null) { Manipulator val4 = GenericSkill_RecalculateMaxStock; <>O.<3>__GenericSkill_RecalculateMaxStock = val4; obj4 = (object)val4; } GenericSkill.RecalculateMaxStock -= (Manipulator)obj4; object obj5 = <>O.<4>__SkillIcon_Update; if (obj5 == null) { Manipulator val5 = SkillIcon_Update; <>O.<4>__SkillIcon_Update = val5; obj5 = (object)val5; } SkillIcon.Update -= (Manipulator)obj5; } public static string GetCustomCooldownRefreshSound(this SkillDef skillDef) { return SkillDefInterop.GetCustomCooldownRefreshSound(skillDef); } public static void SetCustomCooldownRefreshSound(this SkillDef skillDef, string value) { SkillDefInterop.SetCustomCooldownRefreshSound(skillDef, value); } public static int GetBonusStockMultiplier(this SkillDef skillDef) { return SkillDefInterop.GetBonusStockMultiplier(skillDef); } public static void SetBonusStockMultiplier(this SkillDef skillDef, int value) { SkillDefInterop.SetBonusStockMultiplier(skillDef, value); } public static bool GetHideInLoadout(this GenericSkill genericSkill) { return GenericSkillInterop.GetHideInLoadout(genericSkill); } public static void SetHideInLoadout(this GenericSkill genericSkill, bool value) { GenericSkillInterop.SetHideInLoadout(genericSkill, value); } public static bool GetHideInCharacterSelectIfFirstSkillSelected(this GenericSkill genericSkill) { return GenericSkillInterop.GetHideInCharacterSelectIfFirstSkillSelected(genericSkill); } public static void SetHideInCharacterSelectIfFirstSkillSelected(this GenericSkill genericSkill, bool value) { GenericSkillInterop.SetHideInCharacterSelectIfFirstSkillSelected(genericSkill, value); } public static int GetOrderPriority(this GenericSkill genericSkill) { return GenericSkillInterop.GetOrderPriority(genericSkill); } public static void SetOrderPriority(this GenericSkill genericSkill, int value) { GenericSkillInterop.SetOrderPriority(genericSkill, value); } public static string GetLoadoutTitleTokenOverride(this GenericSkill genericSkill) { return GenericSkillInterop.GetLoadoutTitleTokenOverride(genericSkill); } public static void SetLoadoutTitleTokenOverride(this GenericSkill genericSkill, string value) { GenericSkillInterop.SetLoadoutTitleTokenOverride(genericSkill, value); } private static void CharacterSelectControllerBuildSkillStripDisplayDataHook(ILContext il) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: 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_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) VariableDefinition val = new VariableDefinition((TypeReference)(object)TypeReferenceRocks.MakeArrayType(((MemberReference)il.Method).Module.TypeSystem.Int32)); il.Body.Variables.Add(val); ILCursor val2 = new ILCursor(il); int skillSlotsIndex = -1; if (val2.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 2), (Instruction x) => ILPatternMatchingExt.MatchLdfld<BodyInfo>(x, "skillSlots"), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref skillSlotsIndex) })) { val2.Emit(OpCodes.Ldarg_1); val2.Emit(OpCodes.Ldarg_2); val2.Emit(OpCodes.Ldloca, skillSlotsIndex); val2.EmitDelegate<<>F{00000058}<Loadout, BodyInfo, GenericSkill[], int[]>>((<>F{00000058}<Loadout, BodyInfo, GenericSkill[], int[]>)CharacterSelectControllerRemoveAndSortSkills); val2.Emit(OpCodes.Stloc, val); int num = default(int); if (val2.TryGotoNext((MoveType)0, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<BodyLoadoutManager>(x, "GetSkillVariant") })) { val2.Emit(OpCodes.Ldloc, val); int index = val2.Index; val2.Index = index + 1; val2.Emit(OpCodes.Ldelem_I4); } else { SkillsPlugin.Logger.LogError((object)"Failed to apply CharacterSelectControllerBuildSkillStripDisplayDataHook 2"); } } else { SkillsPlugin.Logger.LogError((object)"Failed to apply CharacterSelectControllerBuildSkillStripDisplayDataHook 1"); } } private static void LoadoutPanelControllerRebuildHook(ILContext il) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Expected O, but got Unknown //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) VariableDefinition val = new VariableDefinition((TypeReference)(object)TypeReferenceRocks.MakeArrayType(((MemberReference)il.Method).Module.TypeSystem.Int32)); il.Body.Variables.Add(val); ILCursor val2 = new ILCursor(il); int bodyIndex = -1; int genericSkillsIndex = -1; if (!val2.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(BodyCatalog), "GetBodyPrefabBodyComponent"), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref bodyIndex) })) { SkillsPlugin.Logger.LogError((object)"Failed to apply LoadoutPanelControllerRebuildHook 1"); } else if (val2.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2] { (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)typeof(GetComponentsCache<GenericSkill>).GetMethod("GetGameObjectComponents")), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref genericSkillsIndex) })) { val2.Emit(OpCodes.Ldloc, genericSkillsIndex); val2.Emit(OpCodes.Ldloc, bodyIndex); val2.EmitDelegate<Func<List<GenericSkill>, CharacterBody, int[]>>((Func<List<GenericSkill>, CharacterBody, int[]>)LoadoutPanelControllerRemoveAndSortSkills); val2.Emit(OpCodes.Stloc, val); int num2 = default(int); int num = default(int); if (val2.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num2), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Row>(x, "FromSkillSlot") })) { val2.Emit(OpCodes.Ldloc, val); int index = val2.Index; val2.Index = index + 1; val2.Emit(OpCodes.Ldelem_I4); } else { SkillsPlugin.Logger.LogError((object)"Failed to apply LoadoutPanelControllerRebuildHook 3"); } } else { SkillsPlugin.Logger.LogError((object)"Failed to apply LoadoutPanelControllerRebuildHook 2"); } } private static void LoadoutPanelControllerRowFromSkillSlotHook(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchNewobj<Row>(x) })) { val.Emit(OpCodes.Ldarg_3); val.EmitDelegate<Func<string, GenericSkill, string>>((Func<string, GenericSkill, string>)LoadoutPanelControllerReplaceTitleToken); } else { SkillsPlugin.Logger.LogError((object)"Failed to apply LoadoutPanelControllerRowFromSkillSlotHook"); } } private static int[] LoadoutPanelControllerRemoveAndSortSkills(List<GenericSkill> list, CharacterBody body) { IOrderedEnumerable<(GenericSkill, int)> source = from x in list.Select((GenericSkill skill, int index) => (skill, index)) where !x.skill.GetHideInLoadout() orderby x.skill.GetOrderPriority() select x; int[] result = source.Select<(GenericSkill, int), int>(((GenericSkill skill, int index) x) => x.index).ToArray(); GenericSkill[] collection = source.Select<(GenericSkill, int), GenericSkill>(((GenericSkill skill, int index) x) => x.skill).ToArray(); list.Clear(); list.AddRange(collection); return result; } private static int[] CharacterSelectControllerRemoveAndSortSkills(Loadout loadout, in BodyInfo bodyInfo, ref GenericSkill[] previousValue) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) Loadout loadout2 = loadout; BodyIndex bodyIndex = bodyInfo.bodyIndex; IOrderedEnumerable<(GenericSkill, int)> source = from x in previousValue.Select((GenericSkill skill, int index) => (skill, index)) where !x.skill.GetHideInCharacterSelectIfFirstSkillSelected() || loadout2.bodyLoadoutManager.GetSkillVariant(bodyIndex, x.index) != 0 orderby x.skill.GetOrderPriority() select x; previousValue = source.Select<(GenericSkill, int), GenericSkill>(((GenericSkill skill, int index) x) => x.skill).ToArray(); return source.Select<(GenericSkill, int), int>(((GenericSkill skill, int index) x) => x.index).ToArray(); } private static void GenericSkill_SetBonusStockFromBody(orig_SetBonusStockFromBody orig, GenericSkill self, int newBonusStockFromBody) { if (Object.op_Implicit((Object)(object)self.skillDef)) { newBonusStockFromBody *= (int)MathF.Max(1f, self.skillDef.GetBonusStockMultiplier()); } orig.Invoke(self, newBonusStockFromBody); } private static string LoadoutPanelControllerReplaceTitleToken(string token, GenericSkill skill) { string loadoutTitleTokenOverride = skill.GetLoadoutTitleTokenOverride(); if (!string.IsNullOrEmpty(loadoutTitleTokenOverride)) { return loadoutTitleTokenOverride; } return token; } private static void GenericSkill_RecalculateMaxStock(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[6] { (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)Reflection.GetPropertyGetter(typeof(GenericSkill), "maxStock")), (Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0), (Instruction x) => ILPatternMatchingExt.MatchLdfld<GenericSkill>(x, "bonusStockFromBody"), (Instruction x) => ILPatternMatchingExt.MatchAdd(x) })) { int index = val.Index; val.Index = index - 1; val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<GenericSkill, int>>((Func<GenericSkill, int>)MultiplyBonusStock); val.Emit(OpCodes.Mul); } else { SkillsPlugin.Logger.LogError((object)"Failed to apply GenericSkill_RecalculateMaxStock"); } static int MultiplyBonusStock(GenericSkill genericSkill) { SkillDef skillDef = genericSkill.skillDef; int num = ((!Object.op_Implicit((Object)(object)skillDef)) ? 1 : skillDef.GetBonusStockMultiplier()); if (num != 0) { return num; } return 1; } } private static void SkillIcon_Update(ILContext il) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); string text = default(string); if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[4] { (Instruction x) => ILPatternMatchingExt.MatchLdstr(x, ref text), (Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)Reflection.GetPropertyGetter(typeof(RoR2Application), "instance")), (Instruction x) => ILPatternMatchingExt.MatchCallvirt(x, (MethodBase)Reflection.GetPropertyGetter(typeof(Component), "gameObject")), (Instruction x) => ILPatternMatchingExt.MatchCall(x, typeof(Util), "PlaySound") })) { Instruction next = val.Next; Instruction next2 = val.Next.Next; val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<SkillIcon, bool>>((Func<SkillIcon, bool>)CheckCustomCooldownRefreshSound); val.Emit(OpCodes.Brtrue_S, next); val.Emit(OpCodes.Ldarg_0); val.EmitDelegate<Func<SkillIcon, string>>((Func<SkillIcon, string>)GetCustomCooldownRefreshSound); val.Emit(OpCodes.Br, next2); } else { SkillsPlugin.Logger.LogError((object)"Failed to apply SkillIcon_Update"); } static bool CheckCustomCooldownRefreshSound(SkillIcon skillIcon) { return skillIcon.targetSkill.skillDef.GetCustomCooldownRefreshSound() == null; } static string GetCustomCooldownRefreshSound(SkillIcon skillIcon) { return skillIcon.targetSkill.skillDef.GetCustomCooldownRefreshSound(); } } } [BepInPlugin("com.bepis.r2api.skills", "R2API.Skills", "1.0.4")] public sealed class SkillsPlugin : BaseUnityPlugin { internal static ManualLogSource Logger { get; set; } private void Awake() { Logger = ((BaseUnityPlugin)this).Logger; SkillsAPI.SetHooks(); } private void OnDestroy() { SkillsAPI.UnsetHooks(); } } } namespace R2API.AutoVersionGen { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] internal class AutoVersionAttribute : Attribute { } }
plugins/R2API.Skills/R2API.Skills.Interop.dll
Decompiled 3 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using Microsoft.CodeAnalysis; using RoR2; using RoR2.Skills; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: InternalsVisibleTo("R2API.Skills")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("R2API.Skills.Interop")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+1a241d5d76196dd20668293ef773b18ec18572cd")] [assembly: AssemblyProduct("R2API.Skills.Interop")] [assembly: AssemblyTitle("R2API.Skills.Interop")] [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 R2API.Skills.Interop { public static class GenericSkillInterop { public static bool GetHideInLoadout(GenericSkill genericSkill) { return genericSkill.r2api_hideInLoadout; } public static void SetHideInLoadout(GenericSkill genericSkill, bool value) { genericSkill.r2api_hideInLoadout = value; } public static bool GetHideInCharacterSelectIfFirstSkillSelected(GenericSkill genericSkill) { return genericSkill.r2api_hideInCharacterSelectIfFirstSkillSelected; } public static void SetHideInCharacterSelectIfFirstSkillSelected(GenericSkill genericSkill, bool value) { genericSkill.r2api_hideInCharacterSelectIfFirstSkillSelected = value; } public static int GetOrderPriority(GenericSkill genericSkill) { return genericSkill.r2api_orderPriority; } public static void SetOrderPriority(GenericSkill genericSkill, int value) { genericSkill.r2api_orderPriority = value; } public static string GetLoadoutTitleTokenOverride(GenericSkill genericSkill) { return genericSkill.r2api_loadoutTitleTokenOverride; } public static void SetLoadoutTitleTokenOverride(GenericSkill genericSkill, string value) { genericSkill.r2api_loadoutTitleTokenOverride = value; } } public static class SkillDefInterop { public static int GetBonusStockMultiplier(SkillDef skillDef) { return skillDef.r2api_bonusStockMultiplier; } public static void SetBonusStockMultiplier(SkillDef skillDef, int value) { skillDef.r2api_bonusStockMultiplier = value; } public static string GetCustomCooldownRefreshSound(SkillDef skillDef) { return skillDef.r2api_customCooldownRefreshSound; } public static void SetCustomCooldownRefreshSound(SkillDef skillDef, string value) { skillDef.r2api_customCooldownRefreshSound = value; } } }
patchers/R2API.Skills/R2API.Skills.Patcher.dll
Decompiled 3 months agousing 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 Microsoft.CodeAnalysis; using Mono.Cecil; [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("R2API.Skills.Patcher")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+1a241d5d76196dd20668293ef773b18ec18572cd")] [assembly: AssemblyProduct("R2API.Skills.Patcher")] [assembly: AssemblyTitle("R2API.Skills.Patcher")] [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 R2API { internal static class SkillsPatcher { public static IEnumerable<string> TargetDLLs { get { yield return "RoR2.dll"; } } public static void Patch(AssemblyDefinition assembly) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown TypeDefinition type = assembly.MainModule.GetType("RoR2", "GenericSkill"); if (type != null) { type.Fields.Add(new FieldDefinition("r2api_hideInLoadout", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(bool)))); type.Fields.Add(new FieldDefinition("r2api_hideInCharacterSelectIfFirstSkillSelected", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(bool)))); type.Fields.Add(new FieldDefinition("r2api_orderPriority", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(int)))); type.Fields.Add(new FieldDefinition("r2api_loadoutTitleTokenOverride", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(string)))); } TypeDefinition type2 = assembly.MainModule.GetType("RoR2.Skills", "SkillDef"); if (type2 != null) { type2.Fields.Add(new FieldDefinition("r2api_bonusStockMultiplier", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(int)))); type2.Fields.Add(new FieldDefinition("r2api_customCooldownRefreshSound", (FieldAttributes)6, assembly.MainModule.ImportReference(typeof(string)))); } } } }