Some mods may be broken due to the recent Alloyed Collective update.
Decompiled source of HuntersHarpoonReworked v1.1.0
ReworkedHuntersHarpoon.dll
Decompiled 6 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using IL.RoR2; using Microsoft.CodeAnalysis; using Mono.Cecil.Cil; using MonoMod.Cil; using On.RoR2; using R2API; using RoR2; 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: AssemblyCompany("ReworkedHuntersHarpoon")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ReworkedHuntersHarpoon")] [assembly: AssemblyTitle("ReworkedHuntersHarpoon")] [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 ReworkedHuntersHarpoon { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("IrrationalIntegral.ReworkedHuntersHarpoon", "ReworkedHuntersHarpoon", "1.1.0")] public class ReworkedHuntersHarpoon : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static hook_OnCrit <0>__OnOnCrit; public static hook_AddTimedBuff_BuffDef_float <1>__OnAddTimedBuff; public static Manipulator <2>__ILRecalculateStatsHook; public static Manipulator <3>__ILOnCharacterDeathHook; } public const string PluginGUID = "IrrationalIntegral.ReworkedHuntersHarpoon"; public const string PluginAuthor = "IrrationalIntegral"; public const string PluginName = "ReworkedHuntersHarpoon"; public const string PluginVersion = "1.1.0"; public static float SpeedPerBuff; public static float BuffDuration; public void Awake() { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Expected O, but got Unknown //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown LoadConfig(); CharacterBody.RecalculateStats += new hook_RecalculateStats(OnReCalculateStatsHook); object obj = <>O.<0>__OnOnCrit; if (obj == null) { hook_OnCrit val = OnOnCrit; <>O.<0>__OnOnCrit = val; obj = (object)val; } GlobalEventManager.OnCrit += (hook_OnCrit)obj; object obj2 = <>O.<1>__OnAddTimedBuff; if (obj2 == null) { hook_AddTimedBuff_BuffDef_float val2 = OnAddTimedBuff; <>O.<1>__OnAddTimedBuff = val2; obj2 = (object)val2; } CharacterBody.AddTimedBuff_BuffDef_float += (hook_AddTimedBuff_BuffDef_float)obj2; object obj3 = <>O.<2>__ILRecalculateStatsHook; if (obj3 == null) { Manipulator val3 = ILRecalculateStatsHook; <>O.<2>__ILRecalculateStatsHook = val3; obj3 = (object)val3; } CharacterBody.RecalculateStats += (Manipulator)obj3; object obj4 = <>O.<3>__ILOnCharacterDeathHook; if (obj4 == null) { Manipulator val4 = ILOnCharacterDeathHook; <>O.<3>__ILOnCharacterDeathHook = val4; obj4 = (object)val4; } GlobalEventManager.OnCharacterDeath += (Manipulator)obj4; UpdateText(); } private void OnReCalculateStatsHook(orig_RecalculateStats orig, CharacterBody self) { orig.Invoke(self); if (Object.op_Implicit((Object)(object)self.inventory)) { int itemCount = self.inventory.GetItemCount(Items.MoveSpeedOnKill); if (itemCount > 0) { self.crit += 5f; } } } public static void OnOnCrit(orig_OnCrit orig, GlobalEventManager self, CharacterBody body, DamageInfo damageInfo, CharacterMaster master, float procCoefficient, ProcChainMask procChainMask) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) orig.Invoke(self, body, damageInfo, master, procCoefficient, procChainMask); if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body) && procCoefficient > 0f && Object.op_Implicit((Object)(object)master) && Object.op_Implicit((Object)(object)master.inventory)) { Inventory inventory = master.inventory; if (inventory.GetItemCount(Items.MoveSpeedOnKill) > 0) { body.AddTimedBuff(Buffs.KillMoveSpeed, BuffDuration * procCoefficient); } } } public static void OnAddTimedBuff(orig_AddTimedBuff_BuffDef_float orig, CharacterBody self, BuffDef buffDef, float duration) { //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) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) BuffIndex buffIndex = buffDef.buffIndex; if ((Object)(object)buffDef == (Object)(object)Buffs.KillMoveSpeed) { int num = (Object.op_Implicit((Object)(object)self.inventory) ? self.inventory.GetItemCount(Items.MoveSpeedOnKill) : 0); int num2 = 1 + num * 2; int num3 = 0; int num4 = -1; float num5 = 999f; for (int i = 0; i < self.timedBuffs.Count; i++) { if (self.timedBuffs[i].buffIndex == buffIndex) { num3++; if (self.timedBuffs[i].timer < num5) { num4 = i; num5 = self.timedBuffs[i].timer; } } } if (num3 < num2) { self.timedBuffs.Add(new TimedBuff { buffIndex = buffIndex, timer = duration }); self.AddBuff(buffIndex); EffectData val = new EffectData(); val.origin = self.corePosition; CharacterMotor characterMotor = self.characterMotor; bool flag = false; if (Object.op_Implicit((Object)(object)characterMotor)) { Vector3 moveDirection = characterMotor.moveDirection; if (moveDirection != Vector3.zero) { val.rotation = Util.QuaternionSafeLookRotation(moveDirection); flag = true; } } if (!flag) { val.rotation = self.transform.rotation; } EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/MoveSpeedOnKillActivate"), val, true); } else if (num4 > -1) { self.timedBuffs[num4].timer = duration; } } else { orig.Invoke(self, buffDef, duration); } } public static void ILRecalculateStatsHook(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); int num2 = default(int); int num = default(int); if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[5] { (Instruction x) => ILPatternMatchingExt.MatchMul(x), (Instruction x) => ILPatternMatchingExt.MatchAdd(x), (Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num2), (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num), (Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, 0.25f) })) { val.Index += 4; val.Next.Operand = SpeedPerBuff; } else { Debug.LogWarning((object)"Failed to apply RecalculateStats Il hook."); } } public static void ILOnCharacterDeathHook(ILContext il) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Expected O, but got Unknown //IL_0097: Unknown result type (might be due to invalid IL or missing references) ILCursor val = new ILCursor(il); ILLabel val2 = val.DefineLabel(); ILLabel val3 = default(ILLabel); if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 52), (Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0), (Instruction x) => ILPatternMatchingExt.MatchBle(x, ref val3) })) { val.Index += 3; val.Emit(OpCodes.Br, (object)val2); if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1] { (Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 12) })) { val.MarkLabel(val2); } } else { Debug.LogWarning((object)"Failed to apply OnCharacterDeath Il hook."); } } private void UpdateText() { string token = "ITEM_MOVESPEEDONKILL_DESC"; string text = "<style=cIsDamage>Gain 5% critical chance</style>. <style=cIsDamage>Critical strikes</style> improves <style=cIsUtility>Movement Speed</style> by <style=cIsUtility>" + d(SpeedPerBuff) + "</style>. Maximum cap of <style=cIsUtility>" + d(3f * SpeedPerBuff) + "</style> (+<style=cIsUtility>" + d(2f * SpeedPerBuff) + "</style> per stack)"; string token2 = "ITEM_MOVESPEEDONKILL_PICKUP"; ReplaceString(token, text, token2, text); } private void ReplaceString(string token, string Desc, string token2, string pickup) { LanguageAPI.Add(token, Desc); LanguageAPI.Add(token2, Desc); } private string d(float percentage) { return percentage * 100f + "%"; } private void LoadConfig() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0030: Expected O, but got Unknown //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_0069: Expected O, but got Unknown SpeedPerBuff = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Hunters Harpoon", "Speed Per Buff Stack"), 0.1f, new ConfigDescription("Gain Movement speed when scoring critical hits, default is 10% per stack", (AcceptableValueBase)null, Array.Empty<object>())).Value; BuffDuration = ((BaseUnityPlugin)this).Config.Bind<float>(new ConfigDefinition("Hunters Harpoon", "Buff Duration"), 8f, new ConfigDescription("Defaul Buff duration is 8 seconds", (AcceptableValueBase)null, Array.Empty<object>())).Value; } } } namespace ExamplePlugin { internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; } internal static void Debug(object data) { _logSource.LogDebug(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); } } }