using System; using System.Collections; using System.Collections.Concurrent; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Linq.Expressions; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using HarmonyLib; using JetBrains.Annotations; using LocalizationManager; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; using UnityEngine; using UnityEngine.UI; using YamlDotNet.Core; using YamlDotNet.Core.Events; using YamlDotNet.Core.Tokens; using YamlDotNet.Helpers; using YamlDotNet.Serialization; using YamlDotNet.Serialization.Converters; using YamlDotNet.Serialization.EventEmitters; using YamlDotNet.Serialization.NamingConventions; using YamlDotNet.Serialization.NodeDeserializers; using YamlDotNet.Serialization.NodeTypeResolvers; using YamlDotNet.Serialization.ObjectFactories; using YamlDotNet.Serialization.ObjectGraphTraversalStrategies; using YamlDotNet.Serialization.ObjectGraphVisitors; using YamlDotNet.Serialization.Schemas; using YamlDotNet.Serialization.TypeInspectors; using YamlDotNet.Serialization.TypeResolvers; using YamlDotNet.Serialization.Utilities; using YamlDotNet.Serialization.ValueDeserializers; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("PassivePowers")] [assembly: AssemblyDescription("https://valheim.thunderstore.io/package/Smoothbrain/PassivePowers")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("PassivePowers")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("5058B942-6277-45D3-94B5-3465F0650537")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [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 PassivePowers { [UsedImplicitly] public static class BossPowerPatches { [HarmonyPatch(typeof(SEMan), "ModifyRunStaminaDrain")] private class ReduceRunStaminaUsage { private static void Prefix(SEMan __instance, ref float drain) { if (__instance.m_character is Player) { drain *= 1f - (float)PowerConfig.Total() / 100f; } } } [HarmonyPatch(typeof(SEMan), "ModifyJumpStaminaUsage")] private class ReduceJumpStaminaUsage { private static void Prefix(SEMan __instance, ref float staminaUse) { if (__instance.m_character is Player) { staminaUse *= 1f - (float)PowerConfig.Total() / 100f; } } } [HarmonyPatch(typeof(Player), "GetJogSpeedFactor")] private class IncreaseJogSpeed { private static void Postfix(ref float __result) { __result += (float)PowerConfig.Total() / 100f; } } [HarmonyPatch(typeof(Player), "GetRunSpeedFactor")] private class IncreaseRunSpeed { private static void Postfix(ref float __result) { __result += (float)PowerConfig.Total() / 100f; } } [HarmonyPatch(typeof(Character), "UpdateSwimming")] private class IncreaseSwimSpeed { private static void Prefix(Character __instance) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { ((Character)val).m_swimSpeed = ((Character)val).m_swimSpeed * (1f + (float)PowerConfig.Total() / 100f); } } private static void Postfix(Character __instance) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { ((Character)val).m_swimSpeed = ((Character)val).m_swimSpeed / (1f + (float)PowerConfig.Total() / 100f); } } } [HarmonyPatch(typeof(SE_Stats), "ModifySwimStaminaUsage")] private class ModifySwimStaminaUsage { private static void Prefix(SE_Stats __instance, float baseStaminaUse, ref float staminaUse) { __instance.m_swimStaminaUseModifier = (float)PowerConfig.Total() / 100f; } } [HarmonyPatch(typeof(SEMan), "ModifyAttack")] private class IncreaseTerrainDamage { private static void Prefix(SEMan __instance, ref HitData hitData) { if (__instance.m_character is Player) { hitData.m_damage.m_chop *= 1f + (float)PowerConfig.Total() / 100f; hitData.m_damage.m_pickaxe *= 1f + (float)PowerConfig.Total() / 100f; } } } [HarmonyPatch(typeof(SEMan), "ModifySneakStaminaUsage")] private class SEManModifyStaminaSneakUsage { [UsedImplicitly] private static void Postfix(SEMan __instance, float baseStaminaUse, ref float staminaUse) { if (__instance.m_character.IsSneaking()) { staminaUse -= staminaUse * (float)PowerConfig.Total() / 100f; } } } [HarmonyPatch(typeof(Character), "Damage")] private class ModifyDamageDoneOrTaken { private static void Prefix(HitData hit, Character __instance) { if (hit.GetAttacker() is Player) { float totalDamage = hit.GetTotalDamage(); hit.m_damage.m_fire = (hit.m_damage.m_fire + totalDamage * (float)PowerConfig.Total() / 100f) * (1f + (float)PowerConfig.Total() / 100f); hit.m_damage.m_frost = (hit.m_damage.m_frost + totalDamage * (float)PowerConfig.Total() / 100f) * (1f + (float)PowerConfig.Total() / 100f); hit.m_damage.m_poison = (hit.m_damage.m_poison + totalDamage * (float)PowerConfig.Total() / 100f) * (1f + (float)PowerConfig.Total() / 100f); hit.m_damage.m_lightning = (hit.m_damage.m_lightning + totalDamage * (float)PowerConfig.Total() / 100f) * (1f + (float)PowerConfig.Total() / 100f); hit.m_damage.m_spirit = (hit.m_damage.m_spirit + totalDamage * (float)PowerConfig.Total() / 100f) * (1f + (float)PowerConfig.Total() / 100f); hit.m_damage.m_blunt = (hit.m_damage.m_blunt + totalDamage * (float)PowerConfig.Total() / 100f) * (1f + (float)PowerConfig.Total() / 100f); hit.m_damage.m_pierce = (hit.m_damage.m_pierce + totalDamage * (float)PowerConfig.Total() / 100f) * (1f + (float)PowerConfig.Total() / 100f); hit.m_damage.m_slash = (hit.m_damage.m_slash + totalDamage * (float)PowerConfig.Total() / 100f) * (1f + (float)PowerConfig.Total() / 100f); } if (__instance.IsPlayer()) { hit.m_damage.m_fire *= 1f - (float)PowerConfig.Total() / 100f; hit.m_damage.m_frost *= 1f - (float)PowerConfig.Total() / 100f; hit.m_damage.m_poison *= 1f - (float)PowerConfig.Total() / 100f; hit.m_damage.m_lightning *= 1f - (float)PowerConfig.Total() / 100f; hit.m_damage.m_blunt *= 1f - (float)PowerConfig.Total() / 100f; hit.m_damage.m_pierce *= 1f - (float)PowerConfig.Total() / 100f; hit.m_damage.m_slash *= 1f - (float)PowerConfig.Total() / 100f; } } } [HarmonyPatch(typeof(SEMan), "ModifyHealthRegen")] public static class IncreaseHealthRegen { [UsedImplicitly] public static void Postfix(SEMan __instance, ref float regenMultiplier) { if (__instance.m_character is Player) { regenMultiplier += (float)PowerConfig.Total() / 100f; } } } [HarmonyPatch(typeof(Ship), "IsWindControllActive")] private class TurnWindInFavor { private static void Postfix(Ship __instance, ref bool __result) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) float num = ShipValue(__instance, typeof(TailWind)); State state = Random.state; Random.InitState((int)(EnvMan.instance.m_totalSeconds / (double)EnvMan.instance.m_windPeriodDuration)); if (Random.Range(0f, 1f) < num) { __result = true; } Random.state = state; } } [HarmonyPatch(typeof(Ship), "GetSailForce")] private class IncreaseSailingSpeed { [CompilerGenerated] private sealed class d__3 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable instructions; public IEnumerable <>3__instructions; private IEnumerator <>7__wrap1; private CodeInstruction 5__3; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__3(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 2u) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; if (5__3.opcode == OpCodes.Callvirt && CodeInstructionExtensions.OperandIs(5__3, (MemberInfo)WindIntensityGetter)) { <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 2; return true; } goto IL_00f1; case 2: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Call, (object)WindIntensityUpdater); <>1__state = 3; return true; case 3: { <>1__state = -3; goto IL_00f1; } IL_00f1: 5__3 = null; break; } if (<>7__wrap1.MoveNext()) { 5__3 = <>7__wrap1.Current; <>2__current = 5__3; <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__3 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__3(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly MethodInfo WindIntensityGetter = AccessTools.DeclaredMethod(typeof(EnvMan), "GetWindIntensity", (Type[])null, (Type[])null); private static readonly MethodInfo WindIntensityUpdater = AccessTools.DeclaredMethod(typeof(IncreaseSailingSpeed), "UpdateWindIntensity", (Type[])null, (Type[])null); private static float UpdateWindIntensity(float windIntensity, Ship ship) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) float num = ShipValue(ship, typeof(WindSpeed)); if (Vector3.Angle(((Component)ship).transform.forward, EnvMan.instance.GetWindDir()) > 90f) { return windIntensity * (1f - num); } return windIntensity * (1f + num); } [IteratorStateMachine(typeof(d__3))] private static IEnumerable Transpiler(IEnumerable instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__3(-2) { <>3__instructions = instructions }; } } [HarmonyPatch(typeof(SEMan), "ModifyEitrRegen")] private static class IncreaseEitrRegen { private static void Prefix(ref float eitrMultiplier) { eitrMultiplier *= 1f + (float)PowerConfig.Total() / 100f; } } [HarmonyPatch(typeof(Player), "GetMaxCarryWeight")] private static class IncreaseCarryWeight { [UsedImplicitly] private static void Postfix(Player __instance, ref float __result) { __result += PowerConfig.Total(); } } [HarmonyPatch(typeof(SEMan), "ModifyAdrenaline")] private static class ModifyAdrenaline { [UsedImplicitly] public static void Prefix(float baseValue, ref float use) { use *= 1f + (float)PowerConfig.Total() / 100f; } } [HarmonyPatch(typeof(SEMan), "ModifyStagger")] private static class ModifyStagger { [UsedImplicitly] public static void Postfix(float baseValue, ref float use) { use -= use * (float)PowerConfig.Total() / 100f; } } [HarmonyPatch(typeof(SEMan), "ModifyBlockStaminaUsage")] private static class ModifyBlockStaminaUsage { [UsedImplicitly] public static void Prefix(float baseStaminaUse, ref float staminaUse) { staminaUse = staminaUse * (1f + (float)(PowerConfig.Total() * -1) / 100f) + (float)(PowerConfig.Total() * -1); } } private static float ShipValue(Ship ship, Type type) { float num = ((IConvertible)type.GetMethod("Total", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy).Invoke(null, Array.Empty())).ToSingle(CultureInfo.InvariantCulture) / 100f; if (num > 0f) { return num; } float num2 = 0f; foreach (KeyValuePair kv in PassivePowers.activeBossConfigs) { foreach (PowerConfig config in kv.Value.Configs) { if (config.GetType() == type) { List list = ship.m_players.FindAll(delegate(Player p) { ZDO zDO = ((Character)p).m_nview.GetZDO(); return Utils.getPassivePowers(((zDO != null) ? zDO.GetString("PassivePowers GuardianPowers", "") : null) ?? "").Contains(kv.Key); }); num2 += ((IConvertible)config.BoxedPassive).ToSingle(CultureInfo.InvariantCulture) * (float)list.Count / (float)Mathf.Max(1, ship.m_players.Count); } } } return num2; } } public class ConfigurationManagerAttributes { public bool? ShowRangeAsPercent; public Action? CustomDrawer; public bool? Browsable; public string? Category; public object? DefaultValue; public bool? HideDefaultButton; public bool? HideSettingName; public string? Description; public string? DispName; public int? Order; public bool? ReadOnly; public bool? IsAdvanced; public Func? ObjToStr; public Func? StrToObj; } public enum Toggle { On = 1, Off = 0 } public enum Spread { Self, ConditionsMet, Everyone } [BepInPlugin("org.bepinex.plugins.passivepowers", "Passive Powers", "1.1.5")] [BepInIncompatibility("org.bepinex.plugins.valheim_plus")] public class PassivePowers : BaseUnityPlugin { [HarmonyPatch(typeof(Player), "Awake")] private static class AddRPCs { private static void Postfix(Player __instance) { ((Character)__instance).m_nview.Register("PassivePowers Activate BossPower", (Action)ActivateBossPowerRPC); ((Character)__instance).m_nview.Register("PassivePowers BossDied", (Action)BossDied); } } [HarmonyPatch(typeof(Player), "Update")] private class ActivateBossPower { [CompilerGenerated] private sealed class d__4 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable instructions; public IEnumerable <>3__instructions; private IEnumerator <>7__wrap1; private CodeInstruction 5__3; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 3u) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: 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 //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Ldc_I4_0, (object)null); <>1__state = 2; return true; case 2: <>1__state = -3; goto IL_00f9; case 3: <>1__state = -3; goto IL_00f9; case 4: { <>1__state = -3; goto IL_014a; } IL_00f9: if (5__3.opcode == OpCodes.Call && CodeInstructionExtensions.OperandIs(5__3, (MemberInfo)InputKey)) { <>2__current = new CodeInstruction(OpCodes.Call, (object)CheckInputKey); <>1__state = 4; return true; } goto IL_014a; IL_014a: 5__3 = null; break; } if (<>7__wrap1.MoveNext()) { 5__3 = <>7__wrap1.Current; if (5__3.opcode == OpCodes.Call && CodeInstructionExtensions.OperandIs(5__3, (MemberInfo)GuardianPowerStart)) { <>2__current = new CodeInstruction(OpCodes.Pop, (object)null); <>1__state = 1; return true; } <>2__current = 5__3; <>1__state = 3; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__4 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__4(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly MethodInfo CheckInputKey = AccessTools.DeclaredMethod(typeof(ActivateBossPower), "CheckKeyDown", (Type[])null, (Type[])null); private static readonly MethodInfo InputKey = AccessTools.DeclaredMethod(typeof(ZInput), "GetButtonDown", (Type[])null, (Type[])null); private static readonly MethodInfo GuardianPowerStart = AccessTools.DeclaredMethod(typeof(Player), "StartGuardianPower", (Type[])null, (Type[])null); public static bool CheckKeyDown(bool activeKey) { if (activeKey) { return !bossPowerKeys.Any((ConfigEntry powerKey) => powerKey.Value.IsKeyDown()); } return false; } [IteratorStateMachine(typeof(d__4))] private static IEnumerable Transpiler(IEnumerable instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(-2) { <>3__instructions = instructions }; } } [HarmonyPatch(typeof(Player), "ActivateGuardianPower")] private static class DedicatedGuardianPowerRPC { [CompilerGenerated] private sealed class d__1 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable instructions; public IEnumerable <>3__instructions; private MethodInfo 5__2; private IEnumerator <>7__wrap2; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__1(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 1u) { try { } finally { <>m__Finally1(); } } 5__2 = null; <>7__wrap2 = null; <>1__state = -2; } private bool MoveNext() { //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = AccessTools.DeclaredMethod(typeof(SEMan), "AddStatusEffect", new Type[4] { typeof(int), typeof(bool), typeof(int), typeof(float) }, (Type[])null); <>7__wrap2 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; case 2: <>1__state = -3; break; } if (<>7__wrap2.MoveNext()) { CodeInstruction current = <>7__wrap2.Current; if (CodeInstructionExtensions.Calls(current, 5__2)) { <>2__current = new CodeInstruction(OpCodes.Call, (object)AccessTools.DeclaredMethod(typeof(DedicatedGuardianPowerRPC), "StatusEffectRPC", (Type[])null, (Type[])null)); <>1__state = 1; return true; } <>2__current = current; <>1__state = 2; return true; } <>m__Finally1(); <>7__wrap2 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap2 != null) { <>7__wrap2.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__1 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__1(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static StatusEffect? StatusEffectRPC(SEMan seman, int nameHash, bool resetTime, int itemLevel, float skillLevel) { string name = ((Object)ObjectDB.instance.GetStatusEffect(nameHash)).name; Spread value = PowerSpread[name.Substring("PassivePowers ".Length)].Value; if (value == Spread.ConditionsMet) { seman.m_nview.InvokeRPC("PassivePowers Activate BossPower", new object[1] { name }); } else if (value == Spread.Everyone || (Object)(object)Player.m_localPlayer == (Object)(object)seman.m_character) { return seman.AddStatusEffect(nameHash, resetTime, itemLevel, skillLevel); } return null; } [IteratorStateMachine(typeof(d__1))] private static IEnumerable Transpiler(IEnumerable instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__1(-2) { <>3__instructions = instructions }; } } [HarmonyPatch] public class AddStatusEffects { private static IEnumerable TargetMethods() { return new MethodInfo[2] { AccessTools.DeclaredMethod(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), AccessTools.DeclaredMethod(typeof(ObjectDB), "CopyOtherDB", (Type[])null, (Type[])null) }; } private static void Postfix(ObjectDB __instance) { //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: 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) //IL_01b2: 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_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01d2: Expected O, but got Unknown //IL_01d4: Expected O, but got Unknown List list = new List(); foreach (StatusEffect item in __instance.m_StatusEffects.Where((StatusEffect se) => ((Object)se).name.StartsWith("GP_"))) { string name = "PassivePowers " + ((Object)item).name; if (__instance.m_StatusEffects.All((StatusEffect se) => ((Object)se).name != name)) { StatusEffect val = ScriptableObject.CreateInstance(); ((Object)val).name = name; val.m_activationAnimation = item.m_activationAnimation; val.m_startEffects = item.m_startEffects; val.m_startMessage = item.m_startMessage; val.m_startMessageType = item.m_startMessageType; val.m_icon = item.m_icon; val.m_name = item.m_name; val.m_cooldown = activeBossPowerCooldown.Value; val.m_ttl = activeBossPowerDuration.Value; list.Add(val); StatusEffect val2 = ScriptableObject.CreateInstance(); ((Object)val2).name = "PassivePowers Depletion " + ((Object)item).name; val2.m_startMessage = Localization.instance.Localize("$powers_depleted_description", new string[1] { item.m_name }); val2.m_startMessageType = item.m_startMessageType; val2.m_icon = item.m_icon; val2.m_name = Localization.instance.Localize("$powers_depleted"); val2.m_tooltip = Localization.instance.Localize("$powers_depleted_description", new string[1] { item.m_name }); val2.m_ttl = activeBossPowerDepletion.Value; EffectData val3 = new EffectData { m_prefab = new GameObject(((Object)item).name + " Depletion Prefab") }; val3.m_prefab.AddComponent().statusEffect = ((Object)val2).name; val.m_stopEffects.m_effectPrefabs = (EffectData[])(object)new EffectData[1] { val3 }; list.Add(val2); } } __instance.m_StatusEffects.AddRange(list); } } [HarmonyPatch(typeof(ItemStand), "IsGuardianPowerActive")] private class RemoveActiveTooltip { private static void Postfix(out bool __result) { __result = false; } } [HarmonyPatch(typeof(SE_Stats), "GetTooltipString")] private class RemoveOriginalEffectDescription { private static void Postfix(SE_Stats __instance, ref string __result) { if (((Object)__instance).name.StartsWith("GP_", StringComparison.Ordinal)) { __result = ((StatusEffect)__instance).m_tooltip; } } } [HarmonyPatch(typeof(ItemStand), "GetHoverText")] private class ModifyBossStoneHoverText { [CompilerGenerated] private sealed class d__4 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable instructions; public IEnumerable <>3__instructions; private IEnumerator <>7__wrap1; private CodeInstruction 5__3; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__4(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 2u) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; 5__3 = null; <>1__state = -2; } private bool MoveNext() { //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Expected O, but got Unknown //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>7__wrap1 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; if (5__3.opcode == OpCodes.Ldstr && ((string)5__3.operand).Contains("$guardianstone_hook_activate")) { <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 2; return true; } goto IL_00fb; case 2: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Call, (object)ActivationStatusUpdater); <>1__state = 3; return true; case 3: { <>1__state = -3; goto IL_00fb; } IL_00fb: 5__3 = null; break; } if (<>7__wrap1.MoveNext()) { 5__3 = <>7__wrap1.Current; <>2__current = 5__3; <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap1 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { d__4 d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; d__ = this; } else { d__ = new d__4(0); } d__.instructions = <>3__instructions; return d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } private static readonly MethodInfo ActivationStatusUpdater = AccessTools.DeclaredMethod(typeof(ModifyBossStoneHoverText), "UpdateActivationStatus", (Type[])null, (Type[])null); private const string activateStr = "$guardianstone_hook_activate"; private static void Prefix(ItemStand __instance) { StatusEffect guardianPower = __instance.m_guardianPower; if (guardianPower != null) { UpdateStatusEffectTooltip(guardianPower); } } private static string UpdateActivationStatus(string str, ItemStand itemStand) { if (Utils.getPassivePowers(Player.m_localPlayer).Contains(((Object)itemStand.m_guardianPower).name)) { return str.Replace("$guardianstone_hook_activate", "$guardianstone_hook_deactivate"); } return str; } [IteratorStateMachine(typeof(d__4))] private static IEnumerable Transpiler(IEnumerable instructions) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__4(-2) { <>3__instructions = instructions }; } } [HarmonyPatch(typeof(ItemStand), "Interact")] private class SwitchSelectedPowers { [CompilerGenerated] private sealed class d__5 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private ILGenerator ilg; public ILGenerator <>3__ilg; private IEnumerable instructions; public IEnumerable <>3__instructions; private Label 5__2; private IEnumerator <>7__wrap2; private CodeInstruction 5__4; CodeInstruction IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__5(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 5u) { try { } finally { <>m__Finally1(); } } <>7__wrap2 = null; 5__4 = null; <>1__state = -2; } private bool MoveNext() { //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_0122: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Expected O, but got Unknown //IL_019b: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: Expected O, but got Unknown //IL_0223: Unknown result type (might be due to invalid IL or missing references) //IL_022d: Expected O, but got Unknown //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Expected O, but got Unknown //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Expected O, but got Unknown //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f7: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; 5__2 = ilg.DefineLabel(); <>7__wrap2 = instructions.GetEnumerator(); <>1__state = -3; goto IL_01c2; case 1: <>1__state = -3; if (5__4.opcode == OpCodes.Ldstr && ((string)5__4.operand).Contains("$guardianstone_hook_power_activate")) { <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 2; return true; } goto IL_01bb; case 2: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Call, (object)ActivationStatusUpdater); <>1__state = 3; return true; case 3: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 4; return true; case 4: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Call, (object)ActivatePowerCheck); <>1__state = 5; return true; case 5: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Brfalse, (object)5__2); <>1__state = 6; return true; case 6: <>1__state = -3; goto IL_01bb; case 7: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Pop, (object)null); <>1__state = 8; return true; case 8: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Pop, (object)null); <>1__state = 9; return true; case 9: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Ldc_I4_0, (object)null); <>1__state = 10; return true; case 10: <>1__state = -1; <>2__current = new CodeInstruction(OpCodes.Ret, (object)null); <>1__state = 11; return true; case 11: { <>1__state = -1; return false; } IL_01c2: if (<>7__wrap2.MoveNext()) { 5__4 = <>7__wrap2.Current; <>2__current = 5__4; <>1__state = 1; return true; } <>m__Finally1(); <>7__wrap2 = null; <>2__current = new CodeInstruction(OpCodes.Pop, (object)null) { labels = new List