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.0
plugins\cjayride-DivineFavorPowers\Cjayride.DivineFavorPowers.dll
Decompiled 2 days 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 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.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("Cjayride.DivineFavorPowers")] [assembly: AssemblyTitle("Cjayride.DivineFavorPowers")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.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.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { [HarmonyPatch] private static class CyclePatch { [HarmonyPrefix] [HarmonyPatch(typeof(Player), "StartGuardianPower")] private static bool BlockPlainPress(Player __instance) { return !ShouldDefer(__instance); } [HarmonyPostfix] [HarmonyPatch(typeof(Player), "Update")] private static void TrackHold(Player __instance) { if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } if (ZInput.GetButtonDown("GP")) { _armed = ShouldDefer(__instance); _cycles = 0; } else { if (!_armed) { return; } if (!ZInput.GetButton("GP")) { _armed = false; if (_cycles == 0) { ActivateFirst(__instance); } } else if (!((Character)__instance).TakeInput()) { _armed = false; } else if (ZInput.GetButtonPressedTimer("GP") >= 0.8f + (float)_cycles * 0.8f) { _cycles++; Rotate(__instance); } } } } public const string PluginGUID = "cjayride.divinefavorpowers"; public const string PluginName = "DivineFavorPowers"; public const string PluginVersion = "1.0.0"; private const float HoldThreshold = 0.8f; private const float CycleInterval = 0.8f; private const string CycleFlag = "warcaller_divine_favor_cycle"; private const string EquippedKey = "PassivePowers GuardianPowers"; private static MethodInfo _hasTalent; private static MethodInfo _activeEnabled; private static bool _armed; private static int _cycles; private void Awake() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) bool num = Chainloader.PluginInfos.ContainsKey("M2Valheim.TalentTree"); bool flag = Chainloader.PluginInfos.ContainsKey("org.bepinex.plugins.passivepowers"); if (!num || !flag) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"DivineFavorPowers idle. Needs TalentTree and Passive Powers."); return; } RemoveTalentTreeCycle(); new Harmony("cjayride.divinefavorpowers").PatchAll(typeof(CyclePatch)); ((BaseUnityPlugin)this).Logger.LogInfo((object)"DivineFavorPowers 1.0.0 loaded. Rank 3 cycles equipped Passive Powers."); } private void RemoveTalentTreeCycle() { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) Type type = AccessTools.TypeByName("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 CanCycle(Player player) { if (_hasTalent == null) { _hasTalent = AccessTools.Method(AccessTools.TypeByName("Core.TalentRuntimeService"), "HasTalent", new Type[2] { typeof(Player), typeof(string) }, (Type[])null); } if (_hasTalent == null || (Object)(object)player == (Object)null) { return false; } return (bool)_hasTalent.Invoke(null, new object[2] { player, "warcaller_divine_favor_cycle" }); } 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 ShouldDefer(Player player) { if ((Object)(object)player == (Object)(object)Player.m_localPlayer && ZInput.GetButtonDown("GP") && ((Character)player).TakeInput() && !Hud.InRadial() && !Hud.IsPieceSelectionVisible() && !ModifierHeld()) { return CanCycle(player); } return false; } private static bool ActivePowerEnabled(string power) { if (_activeEnabled == null) { _activeEnabled = AccessTools.Method(AccessTools.TypeByName("PassivePowers.Utils"), "ActivePowerEnabled", new Type[1] { typeof(string) }, (Type[])null); } if (_activeEnabled == null) { return false; } return (bool)_activeEnabled.Invoke(null, new object[1] { power }); } private static List<string> EquippedPowers(Player player) { string guardianPower = player.m_guardianPower; if (string.IsNullOrWhiteSpace(guardianPower)) { return new List<string>(); } return new List<string>(guardianPower.Split(new char[1] { ',' })); } private static void WriteEquipped(Player player, List<string> powers) { string text = (player.m_guardianPower = string.Join(",", powers)); ZNetView nview = ((Character)player).m_nview; if (nview != null) { ZDO zDO = nview.GetZDO(); if (zDO != null) { zDO.Set("PassivePowers GuardianPowers", text); } } } private static void ActivateFirst(Player player) { List<string> list = EquippedPowers(player); if (list.Count == 0 || string.IsNullOrEmpty(list[0])) { return; } string text = list[0]; if (ActivePowerEnabled(text)) { StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(text)); StatusEffect statusEffect2 = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("PassivePowers " + text)); if (!((Object)(object)statusEffect == (Object)null) && !((Object)(object)statusEffect2 == (Object)null)) { player.m_guardianSE = statusEffect; player.StartGuardianPower(); player.m_guardianSE = statusEffect2; } } } private static void Rotate(Player player) { List<string> list = EquippedPowers(player); if (list.Count != 0) { if (list.Count > 1) { string item = list[0]; list.RemoveAt(0); list.Add(item); WriteEquipped(player, list); } StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(list[0])); if ((Object)(object)statusEffect != (Object)null) { ((Character)player).Message((MessageType)2, statusEffect.m_name, 0, statusEffect.m_icon, false); } } } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }