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 DivineFavorPowers v1.0.8
Cjayride.DivineFavorPowers.dll
Decompiled 2 weeks 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 BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyCompany("Cjayride.DivineFavorPowers")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.8.0")] [assembly: AssemblyInformationalVersion("1.0.8+e6760aeba20234a63d08265b36258a7e20065e64")] [assembly: AssemblyProduct("Cjayride.DivineFavorPowers")] [assembly: AssemblyTitle("Cjayride.DivineFavorPowers")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.8.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 Cjayride.DivineFavorPowers { [BepInPlugin("cjayride.divinefavorpowers", "DivineFavorPowers", "1.0.8")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { private struct CachedEffects { public StatusEffect Vanilla; public StatusEffect Passive; } [HarmonyPatch] private static class FirePatch { [HarmonyPrefix] [HarmonyPatch(typeof(Player), "Update")] private static void CatchPress(Player __instance) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } _pending = -1; if (((Character)__instance).TakeInput() && !Hud.InRadial() && !Hud.IsPieceSelectionVisible()) { bool buttonDown = ZInput.GetButtonDown("GP"); if (Matches(_secondMain, _secondMods, _secondNeedsMod, buttonDown)) { _pending = 1; } else if (Matches(_firstMain, _firstMods, _firstNeedsMod, buttonDown)) { _pending = 0; } } } [HarmonyPostfix] [HarmonyPatch(typeof(Player), "Update")] private static void Fire(Player __instance) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer)) { int pending = _pending; _pending = -1; if (pending >= 0) { Activate(__instance, pending); } } } [HarmonyPrefix] [HarmonyPatch(typeof(Player), "StartGuardianPower")] private static bool BlockVanilla(Player __instance) { if (_activating) { return true; } if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { string guardianPower = __instance.m_guardianPower; if (guardianPower != null && guardianPower.Contains(",")) { return false; } } if (ModifierHeld() && ZInput.GetButton("GP")) { return false; } return true; } } public const string PluginGUID = "cjayride.divinefavorpowers"; public const string PluginName = "DivineFavorPowers"; public const string PluginVersion = "1.0.8"; private const string TalentTreeGuid = "M2Valheim.TalentTree"; private const string PassivePowersGuid = "org.bepinex.plugins.passivepowers"; private static ConfigEntry<KeyboardShortcut> _first; private static ConfigEntry<KeyboardShortcut> _second; private static Func<Player, List<string>> _getPowers; private static int _pending = -1; private static bool _activating; private static KeyCode _firstMain; private static KeyCode[] _firstMods = Array.Empty<KeyCode>(); private static bool _firstNeedsMod; private static KeyCode _secondMain; private static KeyCode[] _secondMods = Array.Empty<KeyCode>(); private static bool _secondNeedsMod; private static ObjectDB _cachedDb; private static readonly Dictionary<string, CachedEffects> _effectCache = new Dictionary<string, CachedEffects>(8); private void Awake() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) _first = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "First ability", new KeyboardShortcut((KeyCode)102, Array.Empty<KeyCode>()), "Activates the first boss power equipped on the stones."); _second = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Second ability", new KeyboardShortcut((KeyCode)102, (KeyCode[])(object)new KeyCode[1] { (KeyCode)304 }), "Activates the second boss power equipped on the stones."); _first.SettingChanged += delegate { PushShortcuts(); }; _second.SettingChanged += delegate { PushShortcuts(); }; CacheShortcuts(); if (Application.isBatchMode) { return; } Dictionary<string, PluginInfo> pluginInfos = Chainloader.PluginInfos; if (!pluginInfos.TryGetValue("M2Valheim.TalentTree", out var value) || !pluginInfos.TryGetValue("org.bepinex.plugins.passivepowers", out var value2)) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"DivineFavorPowers idle. Needs TalentTree and Passive Powers."); return; } MethodInfo methodInfo = AccessTools.Method(((object)value2.Instance).GetType().Assembly.GetType("PassivePowers.Utils"), "getPassivePowers", new Type[1] { typeof(Player) }, (Type[])null); if (methodInfo != null) { _getPowers = AccessTools.MethodDelegate<Func<Player, List<string>>>(methodInfo, (object)null, true); } PushShortcuts(); RemoveTalentTreeCycle(((object)value.Instance).GetType().Assembly); new Harmony("cjayride.divinefavorpowers").PatchAll(typeof(FirePatch)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"DivineFavorPowers 1.0.8 loaded. Stones set the powers. Hotkeys fire them."); } private static void PushShortcuts() { //IL_002a: 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) CacheShortcuts(); if (Chainloader.PluginInfos.TryGetValue("org.bepinex.plugins.passivepowers", out var value)) { SetShortcut(value.Instance.Config, 1, _first.Value); SetShortcut(value.Instance.Config, 2, _second.Value); } } private static void CacheShortcuts() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) CacheOne(_first.Value, out _firstMain, out _firstMods, out _firstNeedsMod); CacheOne(_second.Value, out _secondMain, out _secondMods, out _secondNeedsMod); } private static void CacheOne(KeyboardShortcut shortcut, out KeyCode main, out KeyCode[] mods, out bool needsMod) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected I4, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: 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_002a: Unknown result type (might be due to invalid IL or missing references) main = (KeyCode)(int)((KeyboardShortcut)(ref shortcut)).MainKey; List<KeyCode> list = new List<KeyCode>(2); foreach (KeyCode modifier in ((KeyboardShortcut)(ref shortcut)).Modifiers) { if ((int)modifier != 0) { list.Add(modifier); } } mods = list.ToArray(); needsMod = mods.Length != 0; } private static void SetShortcut(ConfigFile config, int slot, KeyboardShortcut key) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<KeyboardShortcut> val = default(ConfigEntry<KeyboardShortcut>); if (config.TryGetEntry<KeyboardShortcut>("2 - Active Powers", "Shortcut for boss power " + slot, ref val)) { val.Value = key; } } private void RemoveTalentTreeCycle(Assembly talentAssembly) { //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) Type? type = talentAssembly.GetType("Talents.Warcaller.Patches.DivineFavorCyclePatch"); MethodInfo methodInfo = AccessTools.Method(type, "StartGuardianPowerPrefix", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method(type, "UpdatePostfix", (Type[])null, (Type[])null); if (methodInfo == null || methodInfo2 == null) { ((BaseUnityPlugin)this).Logger.LogError((object)"TalentTree Divine Favor cycle patches were not found. Cycling was not replaced."); return; } MethodInfo methodInfo3 = AccessTools.DeclaredMethod(typeof(Player), "StartGuardianPower", (Type[])null, (Type[])null); MethodInfo methodInfo4 = AccessTools.DeclaredMethod(typeof(Player), "Update", (Type[])null, (Type[])null); Harmony val = new Harmony("M2Valheim.TalentTree"); val.Unpatch((MethodBase)methodInfo3, methodInfo); val.Unpatch((MethodBase)methodInfo4, methodInfo2); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Removed TalentTree Divine Favor cycle. Cooldown reduction is unchanged."); } private static bool ModifierHeld() { if (!Input.GetKey((KeyCode)304) && !Input.GetKey((KeyCode)303) && !Input.GetKey((KeyCode)306) && !Input.GetKey((KeyCode)305) && !Input.GetKey((KeyCode)308)) { return Input.GetKey((KeyCode)307); } return true; } private static bool Matches(KeyCode main, KeyCode[] modifiers, bool needsMod, bool gpDown) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Invalid comparison between Unknown and I4 if ((int)main == 0) { return false; } if (!Input.GetKeyDown(main) && !((int)main == 102 && gpDown)) { return false; } for (int i = 0; i < modifiers.Length; i++) { if (!Input.GetKey(modifiers[i]) && !SameSide(modifiers[i])) { return false; } } if (!needsMod) { return !ModifierHeld(); } return true; } private static bool SameSide(KeyCode modifier) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Invalid comparison between Unknown and I4 //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Invalid comparison between Unknown and I4 //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Invalid comparison between Unknown and I4 //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Invalid comparison between Unknown and I4 //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Invalid comparison between Unknown and I4 //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Invalid comparison between Unknown and I4 if ((int)modifier == 304 || (int)modifier == 303) { if (!Input.GetKey((KeyCode)304)) { return Input.GetKey((KeyCode)303); } return true; } if ((int)modifier == 306 || (int)modifier == 305) { if (!Input.GetKey((KeyCode)306)) { return Input.GetKey((KeyCode)305); } return true; } if ((int)modifier == 308 || (int)modifier == 307) { if (!Input.GetKey((KeyCode)308)) { return Input.GetKey((KeyCode)307); } return true; } return false; } private static void Activate(Player player, int slot) { if (_getPowers == null || (Object)(object)player != (Object)(object)Player.m_localPlayer) { return; } List<string> list = _getPowers(player); if (list == null || slot < 0 || slot >= list.Count) { return; } string text = list[slot]; if (string.IsNullOrEmpty(text)) { return; } ObjectDB instance = ObjectDB.instance; if ((Object)(object)instance == (Object)null) { return; } if (_cachedDb != instance) { _cachedDb = instance; _effectCache.Clear(); } if (!_effectCache.TryGetValue(text, out var value)) { value.Vanilla = instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(text)); value.Passive = instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("PassivePowers " + text)); _effectCache[text] = value; } if ((Object)(object)value.Vanilla == (Object)null || (Object)(object)value.Passive == (Object)null) { return; } _activating = true; try { player.m_guardianSE = value.Vanilla; player.StartGuardianPower(); player.m_guardianSE = value.Passive; } finally { _activating = false; } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }