Decompiled source of PassivePowers v1.1.5

PassivePowers.dll

Decompiled 7 months ago
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<int, RunStamina>.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<int, JumpStamina>.Total() / 100f;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "GetJogSpeedFactor")]
		private class IncreaseJogSpeed
		{
			private static void Postfix(ref float __result)
			{
				__result += (float)PowerConfig<int, MovementSpeed>.Total() / 100f;
			}
		}

		[HarmonyPatch(typeof(Player), "GetRunSpeedFactor")]
		private class IncreaseRunSpeed
		{
			private static void Postfix(ref float __result)
			{
				__result += (float)PowerConfig<int, MovementSpeed>.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<int, SwimSpeed>.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<int, SwimSpeed>.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<int, SwimStaminaUsage>.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<int, TreeDamage>.Total() / 100f;
					hitData.m_damage.m_pickaxe *= 1f + (float)PowerConfig<int, MiningDamage>.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<int, StaminaSneakUsage>.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<int, BonusFireDamage>.Total() / 100f) * (1f + (float)PowerConfig<int, BonusDamage>.Total() / 100f);
					hit.m_damage.m_frost = (hit.m_damage.m_frost + totalDamage * (float)PowerConfig<int, BonusFrostDamage>.Total() / 100f) * (1f + (float)PowerConfig<int, BonusDamage>.Total() / 100f);
					hit.m_damage.m_poison = (hit.m_damage.m_poison + totalDamage * (float)PowerConfig<int, BonusPoisonDamage>.Total() / 100f) * (1f + (float)PowerConfig<int, BonusDamage>.Total() / 100f);
					hit.m_damage.m_lightning = (hit.m_damage.m_lightning + totalDamage * (float)PowerConfig<int, BonusLightningDamage>.Total() / 100f) * (1f + (float)PowerConfig<int, BonusDamage>.Total() / 100f);
					hit.m_damage.m_spirit = (hit.m_damage.m_spirit + totalDamage * (float)PowerConfig<int, BonusSpiritDamage>.Total() / 100f) * (1f + (float)PowerConfig<int, BonusDamage>.Total() / 100f);
					hit.m_damage.m_blunt = (hit.m_damage.m_blunt + totalDamage * (float)PowerConfig<int, BonusBluntDamage>.Total() / 100f) * (1f + (float)PowerConfig<int, BonusDamage>.Total() / 100f);
					hit.m_damage.m_pierce = (hit.m_damage.m_pierce + totalDamage * (float)PowerConfig<int, BonusPierceDamage>.Total() / 100f) * (1f + (float)PowerConfig<int, BonusDamage>.Total() / 100f);
					hit.m_damage.m_slash = (hit.m_damage.m_slash + totalDamage * (float)PowerConfig<int, BonusSlashDamage>.Total() / 100f) * (1f + (float)PowerConfig<int, BonusDamage>.Total() / 100f);
				}
				if (__instance.IsPlayer())
				{
					hit.m_damage.m_fire *= 1f - (float)PowerConfig<int, BonusFireDefense>.Total() / 100f;
					hit.m_damage.m_frost *= 1f - (float)PowerConfig<int, BonusFrostDefense>.Total() / 100f;
					hit.m_damage.m_poison *= 1f - (float)PowerConfig<int, BonusPoisonDefense>.Total() / 100f;
					hit.m_damage.m_lightning *= 1f - (float)PowerConfig<int, BonusLightningDefense>.Total() / 100f;
					hit.m_damage.m_blunt *= 1f - (float)PowerConfig<int, PhysicalDamage>.Total() / 100f;
					hit.m_damage.m_pierce *= 1f - (float)PowerConfig<int, PhysicalDamage>.Total() / 100f;
					hit.m_damage.m_slash *= 1f - (float)PowerConfig<int, PhysicalDamage>.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<int, HealthRegen>.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 <Transpiler>d__3 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
			{
				private int <>1__state;

				private CodeInstruction <>2__current;

				private int <>l__initialThreadId;

				private IEnumerable<CodeInstruction> instructions;

				public IEnumerable<CodeInstruction> <>3__instructions;

				private IEnumerator<CodeInstruction> <>7__wrap1;

				private CodeInstruction <instruction>5__3;

				CodeInstruction IEnumerator<CodeInstruction>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <Transpiler>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;
					<instruction>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 (<instruction>5__3.opcode == OpCodes.Callvirt && CodeInstructionExtensions.OperandIs(<instruction>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:
							<instruction>5__3 = null;
							break;
						}
						if (<>7__wrap1.MoveNext())
						{
							<instruction>5__3 = <>7__wrap1.Current;
							<>2__current = <instruction>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<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
				{
					<Transpiler>d__3 <Transpiler>d__;
					if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
					{
						<>1__state = 0;
						<Transpiler>d__ = this;
					}
					else
					{
						<Transpiler>d__ = new <Transpiler>d__3(0);
					}
					<Transpiler>d__.instructions = <>3__instructions;
					return <Transpiler>d__;
				}

				[DebuggerHidden]
				IEnumerator IEnumerable.GetEnumerator()
				{
					return ((IEnumerable<CodeInstruction>)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(<Transpiler>d__3))]
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Transpiler>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<int, EitrRegen>.Total() / 100f;
			}
		}

		[HarmonyPatch(typeof(Player), "GetMaxCarryWeight")]
		private static class IncreaseCarryWeight
		{
			[UsedImplicitly]
			private static void Postfix(Player __instance, ref float __result)
			{
				__result += PowerConfig<int, CarryWeight>.Total();
			}
		}

		[HarmonyPatch(typeof(SEMan), "ModifyAdrenaline")]
		private static class ModifyAdrenaline
		{
			[UsedImplicitly]
			public static void Prefix(float baseValue, ref float use)
			{
				use *= 1f + (float)PowerConfig<int, AdrenalineBonus>.Total() / 100f;
			}
		}

		[HarmonyPatch(typeof(SEMan), "ModifyStagger")]
		private static class ModifyStagger
		{
			[UsedImplicitly]
			public static void Postfix(float baseValue, ref float use)
			{
				use -= use * (float)PowerConfig<int, StaggerResist>.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<int, BlockStaminaUsage>.Total() * -1) / 100f) + (float)(PowerConfig<int, BlockStaminaReturn>.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<object>())).ToSingle(CultureInfo.InvariantCulture) / 100f;
			if (num > 0f)
			{
				return num;
			}
			float num2 = 0f;
			foreach (KeyValuePair<string, BossConfig> kv in PassivePowers.activeBossConfigs)
			{
				foreach (PowerConfig config in kv.Value.Configs)
				{
					if (config.GetType() == type)
					{
						List<Player> 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<ConfigEntryBase>? 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<object, string>? ObjToStr;

		public Func<string, object>? 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<string>("PassivePowers Activate BossPower", (Action<long, string>)ActivateBossPowerRPC);
				((Character)__instance).m_nview.Register<string>("PassivePowers BossDied", (Action<long, string>)BossDied);
			}
		}

		[HarmonyPatch(typeof(Player), "Update")]
		private class ActivateBossPower
		{
			[CompilerGenerated]
			private sealed class <Transpiler>d__4 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
			{
				private int <>1__state;

				private CodeInstruction <>2__current;

				private int <>l__initialThreadId;

				private IEnumerable<CodeInstruction> instructions;

				public IEnumerable<CodeInstruction> <>3__instructions;

				private IEnumerator<CodeInstruction> <>7__wrap1;

				private CodeInstruction <instruction>5__3;

				CodeInstruction IEnumerator<CodeInstruction>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <Transpiler>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;
					<instruction>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 (<instruction>5__3.opcode == OpCodes.Call && CodeInstructionExtensions.OperandIs(<instruction>5__3, (MemberInfo)InputKey))
							{
								<>2__current = new CodeInstruction(OpCodes.Call, (object)CheckInputKey);
								<>1__state = 4;
								return true;
							}
							goto IL_014a;
							IL_014a:
							<instruction>5__3 = null;
							break;
						}
						if (<>7__wrap1.MoveNext())
						{
							<instruction>5__3 = <>7__wrap1.Current;
							if (<instruction>5__3.opcode == OpCodes.Call && CodeInstructionExtensions.OperandIs(<instruction>5__3, (MemberInfo)GuardianPowerStart))
							{
								<>2__current = new CodeInstruction(OpCodes.Pop, (object)null);
								<>1__state = 1;
								return true;
							}
							<>2__current = <instruction>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<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
				{
					<Transpiler>d__4 <Transpiler>d__;
					if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
					{
						<>1__state = 0;
						<Transpiler>d__ = this;
					}
					else
					{
						<Transpiler>d__ = new <Transpiler>d__4(0);
					}
					<Transpiler>d__.instructions = <>3__instructions;
					return <Transpiler>d__;
				}

				[DebuggerHidden]
				IEnumerator IEnumerable.GetEnumerator()
				{
					return ((IEnumerable<CodeInstruction>)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<KeyboardShortcut> powerKey) => powerKey.Value.IsKeyDown());
				}
				return false;
			}

			[IteratorStateMachine(typeof(<Transpiler>d__4))]
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Transpiler>d__4(-2)
				{
					<>3__instructions = instructions
				};
			}
		}

		[HarmonyPatch(typeof(Player), "ActivateGuardianPower")]
		private static class DedicatedGuardianPowerRPC
		{
			[CompilerGenerated]
			private sealed class <Transpiler>d__1 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
			{
				private int <>1__state;

				private CodeInstruction <>2__current;

				private int <>l__initialThreadId;

				private IEnumerable<CodeInstruction> instructions;

				public IEnumerable<CodeInstruction> <>3__instructions;

				private MethodInfo <AddStatusEffect>5__2;

				private IEnumerator<CodeInstruction> <>7__wrap2;

				CodeInstruction IEnumerator<CodeInstruction>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <Transpiler>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();
						}
					}
					<AddStatusEffect>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;
							<AddStatusEffect>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, <AddStatusEffect>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<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
				{
					<Transpiler>d__1 <Transpiler>d__;
					if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
					{
						<>1__state = 0;
						<Transpiler>d__ = this;
					}
					else
					{
						<Transpiler>d__ = new <Transpiler>d__1(0);
					}
					<Transpiler>d__.instructions = <>3__instructions;
					return <Transpiler>d__;
				}

				[DebuggerHidden]
				IEnumerator IEnumerable.GetEnumerator()
				{
					return ((IEnumerable<CodeInstruction>)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(<Transpiler>d__1))]
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Transpiler>d__1(-2)
				{
					<>3__instructions = instructions
				};
			}
		}

		[HarmonyPatch]
		public class AddStatusEffects
		{
			private static IEnumerable<MethodBase> 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<StatusEffect> list = new List<StatusEffect>();
				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<StatusEffect>();
						((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<StatusEffect>();
						((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<PowerDepletionBehaviour>().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 <Transpiler>d__4 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
			{
				private int <>1__state;

				private CodeInstruction <>2__current;

				private int <>l__initialThreadId;

				private IEnumerable<CodeInstruction> instructions;

				public IEnumerable<CodeInstruction> <>3__instructions;

				private IEnumerator<CodeInstruction> <>7__wrap1;

				private CodeInstruction <instruction>5__3;

				CodeInstruction IEnumerator<CodeInstruction>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <Transpiler>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;
					<instruction>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 (<instruction>5__3.opcode == OpCodes.Ldstr && ((string)<instruction>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:
							<instruction>5__3 = null;
							break;
						}
						if (<>7__wrap1.MoveNext())
						{
							<instruction>5__3 = <>7__wrap1.Current;
							<>2__current = <instruction>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<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
				{
					<Transpiler>d__4 <Transpiler>d__;
					if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
					{
						<>1__state = 0;
						<Transpiler>d__ = this;
					}
					else
					{
						<Transpiler>d__ = new <Transpiler>d__4(0);
					}
					<Transpiler>d__.instructions = <>3__instructions;
					return <Transpiler>d__;
				}

				[DebuggerHidden]
				IEnumerator IEnumerable.GetEnumerator()
				{
					return ((IEnumerable<CodeInstruction>)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(<Transpiler>d__4))]
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Transpiler>d__4(-2)
				{
					<>3__instructions = instructions
				};
			}
		}

		[HarmonyPatch(typeof(ItemStand), "Interact")]
		private class SwitchSelectedPowers
		{
			[CompilerGenerated]
			private sealed class <Transpiler>d__5 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
			{
				private int <>1__state;

				private CodeInstruction <>2__current;

				private int <>l__initialThreadId;

				private ILGenerator ilg;

				public ILGenerator <>3__ilg;

				private IEnumerable<CodeInstruction> instructions;

				public IEnumerable<CodeInstruction> <>3__instructions;

				private Label <cleanup>5__2;

				private IEnumerator<CodeInstruction> <>7__wrap2;

				private CodeInstruction <instruction>5__4;

				CodeInstruction IEnumerator<CodeInstruction>.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					get
					{
						return <>2__current;
					}
				}

				[DebuggerHidden]
				public <Transpiler>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;
					<instruction>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;
							<cleanup>5__2 = ilg.DefineLabel();
							<>7__wrap2 = instructions.GetEnumerator();
							<>1__state = -3;
							goto IL_01c2;
						case 1:
							<>1__state = -3;
							if (<instruction>5__4.opcode == OpCodes.Ldstr && ((string)<instruction>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)<cleanup>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())
							{
								<instruction>5__4 = <>7__wrap2.Current;
								<>2__current = <instruction>5__4;
								<>1__state = 1;
								return true;
							}
							<>m__Finally1();
							<>7__wrap2 = null;
							<>2__current = new CodeInstruction(OpCodes.Pop, (object)null)
							{
								labels = new List<Label> { <cleanup>5__2 }
							};
							<>1__state = 7;
							return true;
							IL_01bb:
							<instruction>5__4 = null;
							goto IL_01c2;
						}
					}
					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<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
				{
					<Transpiler>d__5 <Transpiler>d__;
					if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
					{
						<>1__state = 0;
						<Transpiler>d__ = this;
					}
					else
					{
						<Transpiler>d__ = new <Transpiler>d__5(0);
					}
					<Transpiler>d__.instructions = <>3__instructions;
					<Transpiler>d__.ilg = <>3__ilg;
					return <Transpiler>d__;
				}

				[DebuggerHidden]
				IEnumerator IEnumerable.GetEnumerator()
				{
					return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
				}
			}

			private static readonly MethodInfo ActivationStatusUpdater = AccessTools.DeclaredMethod(typeof(SwitchSelectedPowers), "UpdateActivationStatus", (Type[])null, (Type[])null);

			private static readonly MethodInfo ActivatePowerCheck = AccessTools.DeclaredMethod(typeof(SwitchSelectedPowers), "CanActivatePower", (Type[])null, (Type[])null);

			private const string activateStr = "$guardianstone_hook_power_activate";

			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_power_activate", "$guardianstone_hook_power_deactivate");
				}
				return str;
			}

			private static bool CanActivatePower(ItemStand itemStand)
			{
				if (Utils.PassivePowerEnabled(((Object)itemStand.m_guardianPower).name))
				{
					return true;
				}
				((Character)Player.m_localPlayer).Message((MessageType)2, Localization.instance.Localize("$powers_min_kills_passive", new string[1] { requiredBossKillsPassive[((Object)itemStand.m_guardianPower).name].Value.ToString() }), 0, (Sprite)null);
				return false;
			}

			[IteratorStateMachine(typeof(<Transpiler>d__5))]
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator ilg)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Transpiler>d__5(-2)
				{
					<>3__instructions = instructions,
					<>3__ilg = ilg
				};
			}
		}

		[HarmonyPatch(typeof(TextsDialog), "AddActiveEffects")]
		private class AddPowerEffectsToCompendium
		{
			private static readonly MethodInfo GuardianPowerGetter = AccessTools.DeclaredMethod(typeof(Player), "GetGuardianPowerHUD", (Type[])null, (Type[])null);

			private static readonly MethodInfo GuardianPowerWriter = AccessTools.DeclaredMethod(typeof(AddPowerEffectsToCompendium), "DisplayGuardianPowers", (Type[])null, (Type[])null);

			private static void DisplayGuardianPowers(StringBuilder stringBuilder)
			{
				List<string> passivePowers = Utils.getPassivePowers(Player.m_localPlayer);
				if (passivePowers.Count == 0)
				{
					return;
				}
				stringBuilder.Append("<color=yellow>" + Localization.instance.Localize("$inventory_selectedgp") + "</color>\n");
				foreach (string item in passivePowers)
				{
					StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(item));
					if (statusEffect != null)
					{
						UpdateStatusEffectTooltip(statusEffect);
						stringBuilder.Append("<color=orange>" + Localization.instance.Localize(statusEffect.m_name) + "</color>\n");
						stringBuilder.Append(Localization.instance.Localize(statusEffect.GetTooltipString()));
						stringBuilder.Append("\n\n");
					}
				}
			}

			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Expected O, but got Unknown
				List<CodeInstruction> list = instructions.ToList();
				int i;
				for (i = 0; i < list.Count; i++)
				{
					CodeInstruction val = list[i];
					if (val.opcode == OpCodes.Callvirt && CodeInstructionExtensions.OperandIs(val, (MemberInfo)GuardianPowerGetter))
					{
						break;
					}
				}
				int num = i - 3;
				Label? label;
				for (label = null; i < list.Count && !CodeInstructionExtensions.Branches(list[i], ref label); i++)
				{
				}
				CodeInstruction val2 = list[i + 1];
				val2.labels = list[num].labels;
				return list.Take(num).Concat((IEnumerable<CodeInstruction>)(object)new CodeInstruction[2]
				{
					val2,
					new CodeInstruction(OpCodes.Call, (object)GuardianPowerWriter)
				}).Concat(list.Skip(num).SkipWhile((CodeInstruction instruction) => !instruction.labels.Contains(label.Value)));
			}
		}

		private class HudPower
		{
			public Transform root;

			public TMP_Text name;

			public Image icon;
		}

		[HarmonyPatch(typeof(Hud), "Awake")]
		private class DisplayMultiplePowers
		{
			private static void Postfix(Hud __instance)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Expected O, but got Unknown
				//IL_00ba: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
				hudPowers.Clear();
				RectTransform gpRoot = __instance.m_gpRoot;
				GameObject val = new GameObject("powerContainer 1");
				val.transform.parent = (Transform)(object)gpRoot;
				val.transform.localPosition = Vector3.zero;
				GameObject val2 = val;
				for (int num = ((Transform)gpRoot).childCount - 1; num >= 0; num--)
				{
					Transform child = ((Transform)gpRoot).GetChild(num);
					if ((Object)(object)child != (Object)(object)__instance.m_gpCooldown.transform && ((Object)child).name != "TimeBar")
					{
						child.SetParent(val2.transform, true);
					}
				}
				RegisterHudPower(val2.transform);
				for (int i = 2; i <= 7; i++)
				{
					GameObject obj = Object.Instantiate<GameObject>(val2, (Transform)(object)gpRoot);
					((Object)obj).name = "powerContainer " + i;
					Transform transform = obj.transform;
					transform.position += new Vector3(0f, (float)(70 * (i - 1)), 0f);
					RegisterHudPower(obj.transform);
				}
				static void RegisterHudPower(Transform root)
				{
					hudPowers.Add(new HudPower
					{
						root = root,
						icon = ((Component)root.Find("Icon")).GetComponent<Image>(),
						name = ((Component)root.Find("Name")).GetComponent<TMP_Text>()
					});
				}
			}
		}

		[HarmonyPatch(typeof(Hud), "UpdateGuardianPower")]
		private class DisplayBossPowerCooldown
		{
			private static bool Prefix(Hud __instance)
			{
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				int i = 0;
				foreach (string passivePower in Utils.getPassivePowers(Player.m_localPlayer))
				{
					StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(passivePower));
					if (statusEffect != null)
					{
						((Component)hudPowers[i].root).gameObject.SetActive(true);
						hudPowers[i].name.text = Localization.instance.Localize(statusEffect.m_name);
						hudPowers[i].icon.sprite = statusEffect.m_icon;
						((Graphic)hudPowers[i++].icon).color = (Color)((remainingCooldown <= 0f) ? Color.white : new Color(1f, 0f, 1f, 0f));
					}
				}
				((Component)__instance.m_gpRoot).gameObject.SetActive(i > 0);
				for (; i < hudPowers.Count; i++)
				{
					((Component)hudPowers[i].root).gameObject.SetActive(false);
				}
				__instance.m_gpCooldown.text = ((!Utils.ActivePowersEnabled()) ? Localization.instance.Localize("$powers_type_passive") : ((remainingCooldown > 0f) ? StatusEffect.GetTimeString(remainingCooldown, false, false) : Localization.instance.Localize("$hud_ready")));
				return false;
			}
		}

		[HarmonyPatch(typeof(PlayerProfile), "SavePlayerData")]
		private static class SaveBossKills
		{
			private static void Prefix(PlayerProfile __instance, Player player)
			{
				foreach (KeyValuePair<string, float> enemyStat in __instance.m_enemyStats)
				{
					player.m_customData[enemyStat.Key] = enemyStat.Value.ToString(CultureInfo.InvariantCulture);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerProfile), "LoadPlayerData")]
		private static class LoadBossKills
		{
			private static void Postfix(PlayerProfile __instance, Player player)
			{
				if (!Object.op_Implicit((Object)(object)ZNetScene.instance))
				{
					return;
				}
				foreach (GameObject prefab in ZNetScene.instance.m_prefabs)
				{
					Character component = prefab.GetComponent<Character>();
					if (component != null && player.m_customData.TryGetValue(component.m_name, out var value) && float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && !__instance.m_enemyStats.ContainsKey(component.m_name))
					{
						__instance.m_enemyStats[component.m_name] = result;
					}
				}
			}
		}

		[HarmonyPatch(typeof(Character), "OnDeath")]
		public static class CountBossKills
		{
			private static void Prefix(Character __instance)
			{
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				if (!__instance.IsBoss() || !Utils.effectToBossMap.ContainsValue(__instance.m_name))
				{
					return;
				}
				List<Player> list = new List<Player>();
				Player.GetPlayersInRange(((Component)__instance).transform.position, 50f, list);
				foreach (Player item in list)
				{
					if ((Object)(object)item != (Object)(object)Player.m_localPlayer)
					{
						((Character)item).m_nview.InvokeRPC("PassivePowers BossDied", new object[1] { __instance.m_name });
					}
				}
			}
		}

		private const string ModName = "Passive Powers";

		private const string ModVersion = "1.1.5";

		private const string ModGUID = "org.bepinex.plugins.passivepowers";

		private static readonly ConfigSync configSync = new ConfigSync("org.bepinex.plugins.passivepowers")
		{
			DisplayName = "Passive Powers",
			CurrentVersion = "1.1.5",
			MinimumRequiredVersion = "1.1.5"
		};

		public static object? configManager;

		private const int bossPowerCount = 7;

		private static ConfigEntry<Toggle> serverConfigLocked = null;

		public static ConfigEntry<int> maximumBossPowers = null;

		private static ConfigEntry<int> activeBossPowerCooldown = null;

		private static ConfigEntry<int> activeBossPowerDuration = null;

		private static ConfigEntry<int> activeBossPowerDepletion = null;

		private static readonly ConfigEntry<KeyboardShortcut>[] bossPowerKeys = new ConfigEntry<KeyboardShortcut>[7];

		private static readonly Dictionary<string, ConfigEntry<string>> bossConfigs = new Dictionary<string, ConfigEntry<string>>();

		public static readonly Dictionary<string, BossConfig> activeBossConfigs = new Dictionary<string, BossConfig>();

		public static readonly Dictionary<string, ConfigEntry<int>> requiredBossKillsPassive = new Dictionary<string, ConfigEntry<int>>();

		public static readonly Dictionary<string, ConfigEntry<int>> requiredBossKillsActive = new Dictionary<string, ConfigEntry<int>>();

		private static readonly Dictionary<string, ConfigEntry<Spread>> PowerSpread = new Dictionary<string, ConfigEntry<Spread>>();

		private readonly ConfigurationManagerAttributes activeBossPowerSettingAttributes = new ConfigurationManagerAttributes();

		private static readonly List<HudPower> hudPowers = new List<HudPower>();

		private static float remainingCooldown => Player.m_localPlayer.m_guardianPowerCooldown;

		private static void reloadConfigDisplay()
		{
			configManager?.GetType().GetMethod("BuildSettingList").Invoke(configManager, Array.Empty<object>());
		}

		private ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, description);
			configSync.AddConfigEntry<T>(val).SynchronizedConfig = synchronizedSetting;
			return val;
		}

		private void bossConfig(string PowerName, int index, string bossName, string defaults)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Expected O, but got Unknown
			string PowerName2 = PowerName;
			string group = $"{index} - {bossName}";
			ConfigEntry<string> val = config(group, "Effects", defaults, new ConfigDescription("Powers of " + bossName, (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					CustomDrawer = BossConfig.DrawConfigTable(PowerName2),
					Order = -10
				}
			}));
			val.SettingChanged += delegate
			{
				bossConfigChanged(PowerName2);
			};
			bossConfigs[PowerName2] = val;
			bossConfigChanged(PowerName2);
			ConfigEntry<int> value = config(group, "Min kills (Passive)", 1, new ConfigDescription("Minimum required kills of " + bossName + " to be able to use the passive power of the boss. Use 0 to allow everyone to use the passive power as soon as the trophy is hanging on the boss stone.", (AcceptableValueBase)null, Array.Empty<object>()));
			requiredBossKillsPassive[PowerName2] = value;
			ConfigEntry<int> value2 = config(group, "Min kills (Active)", -1, new ConfigDescription("Minimum required kills of " + bossName + " to be able to use the active power of the boss. Use -1 to disable the active power and only allow the passive power.", (AcceptableValueBase)null, Array.Empty<object>()));
			requiredBossKillsActive[PowerName2] = value2;
			ConfigEntry<Spread> value3 = config(group, "Activation spread", Spread.Everyone, new ConfigDescription("Self: Only the player activating the boss power gets the buff.\nConditions Met: Only the nearby players that have the required boss kills receive the buff.\nEveryone: Every nearby player gets the buff.", (AcceptableValueBase)null, Array.Empty<object>()));
			PowerSpread[PowerName2] = value3;
		}

		private static void bossConfigChanged(string PowerName)
		{
			activeBossConfigs[PowerName] = new BossConfig(bossConfigs[PowerName].Value);
		}

		private ConfigEntry<T> config<T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		public void Awake()
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Expected O, but got Unknown
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Expected O, but got Unknown
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Expected O, but got Unknown
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Expected O, but got Unknown
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			Localizer.Load();
			Type type = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly a) => a.GetName().Name == "ConfigurationManager")?.GetType("ConfigurationManager.ConfigurationManager");
			configManager = ((type == null) ? null : Chainloader.ManagerObject.GetComponent(type));
			serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only.");
			maximumBossPowers = config("1 - General", "Maximum boss powers", 2, new ConfigDescription("Sets the maximum number of boss powers that can be active at the same time.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 7), Array.Empty<object>()));
			activeBossPowerCooldown = config("2 - Active Powers", "Cooldown for boss powers (seconds)", 600, new ConfigDescription("Cooldown after activating one of the boss powers. Cooldown is shared between all boss powers.", (AcceptableValueBase)null, new object[1] { activeBossPowerSettingAttributes }));
			activeBossPowerCooldown.SettingChanged += activeBossPowerSettingChanged;
			activeBossPowerDuration = config("2 - Active Powers", "Duration for active boss powers (seconds)", 30, new ConfigDescription("Duration of the buff from activating boss powers.", (AcceptableValueBase)null, new object[1] { activeBossPowerSettingAttributes }));
			activeBossPowerDuration.SettingChanged += activeBossPowerSettingChanged;
			activeBossPowerDepletion = config("2 - Active Powers", "Power loss duration after boss power activation (seconds)", 180, new ConfigDescription("Disables the passive effect of the boss power for the specified duration after the active effect ends.", (AcceptableValueBase)null, new object[1] { activeBossPowerSettingAttributes }));
			activeBossPowerDepletion.SettingChanged += activeBossPowerSettingChanged;
			bossConfig("GP_Eikthyr", 3, "Eikthyr", "RunStamina:15:60,JumpStamina:15:60,SwimStaminaUsage:15:60");
			bossConfig("GP_TheElder", 4, "The Elder", "HealthRegen:10:30,TreeDamage:20:60,MiningDamage:20:60");
			bossConfig("GP_Bonemass", 5, "Bonemass", "PhysicalDamage:10:25,BlockStaminaUsage:35:100,BlockStaminaReturn:2:5");
			bossConfig("GP_Moder", 6, "Moder", "BonusFrostDefense:10:50,TailWind:20:100,WindModifier:35:200,CarryWeight:100:300,MovementSpeed:5:10");
			bossConfig("GP_Yagluth", 7, "Yagluth", "BonusLightningDefense:10:50,BonusDamage:5:10");
			bossConfig("GP_Queen", 8, "Queen", "EitrRegen:35:100,BonusPoisonDefense:10:50,StaminaSneakUsage:50:100");
			bossConfig("GP_Fader", 9, "Fader", "BonusFireDefense:10:50,AdrenalineBonus:35:100,StaggerResist:20:50");
			for (int i = 0; i < 7; i++)
			{
				bossPowerKeys[i] = config<KeyboardShortcut>("2 - Active Powers", $"Shortcut for boss power {i + 1}", new KeyboardShortcut((KeyCode)(49 + i), (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), new ConfigDescription($"Keyboard shortcut to activate the {i + 1}. boss power.", (AcceptableValueBase)null, new object[1] { activeBossPowerSettingAttributes }), synchronizedSetting: false);
			}
			configSync.AddLockingConfigEntry<Toggle>(serverConfigLocked);
			activeBossPowerSettingAttributes.Browsable = Utils.ActivePowersEnabled();
			foreach (ConfigEntry<int> value in requiredBossKillsActive.Values)
			{
				value.SettingChanged += delegate
				{
					activeBossPowerSettingAttributes.Browsable = Utils.ActivePowersEnabled();
					reloadConfigDisplay();
				};
			}
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			new Harmony("org.bepinex.plugins.passivepowers").PatchAll(executingAssembly);
		}

		private static void ActivateBossPowerRPC(long peer, string bossPower)
		{
			if (Utils.ActivePowerEnabled(bossPower.Substring("PassivePowers ".Length)))
			{
				((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode(bossPower), true, 0, 0f);
			}
		}

		private static void activeBossPowerSettingChanged(object o, EventArgs e)
		{
			foreach (StatusEffect statusEffect in ObjectDB.instance.m_StatusEffects)
			{
				if (((Object)statusEffect).name.StartsWith("PassivePowers", StringComparison.Ordinal))
				{
					if (((Object)statusEffect).name.Contains("Depletion"))
					{
						statusEffect.m_ttl = activeBossPowerDepletion.Value;
						continue;
					}
					statusEffect.m_cooldown = activeBossPowerCooldown.Value;
					statusEffect.m_ttl = activeBossPowerDuration.Value;
				}
			}
		}

		private void Update()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			if (!Utils.ActivePowersEnabled())
			{
				return;
			}
			for (int i = 0; i < bossPowerKeys.Length; i++)
			{
				if (!bossPowerKeys[i].Value.IsKeyDown() || !((Character)Player.m_localPlayer).TakeInput())
				{
					continue;
				}
				List<string> passivePowers = Utils.getPassivePowers(Player.m_localPlayer);
				if (i >= passivePowers.Count)
				{
					continue;
				}
				string text = passivePowers[i];
				StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode("PassivePowers " + text));
				if (statusEffect != null)
				{
					if (Utils.ActivePowerEnabled(text))
					{
						Player.m_localPlayer.m_guardianSE = ObjectDB.instance.GetStatusEffect(StringExtensionMethods.GetStableHashCode(text));
						Player.m_localPlayer.StartGuardianPower();
						Player.m_localPlayer.m_guardianSE = statusEffect;
					}
					else if (requiredBossKillsActive[text].Value > 0)
					{
						((Character)Player.m_localPlayer).Message((MessageType)2, Localization.instance.Localize("$powers_min_kills_active", new string[1] { requiredBossKillsActive[text].Value.ToString() }), 0, (Sprite)null);
					}
					else
					{
						((Character)Player.m_localPlayer).Message((MessageType)2, Localization.instance.Localize("$powers_not_active"), 0, (Sprite)null);
					}
				}
			}
		}

		private static void UpdateStatusEffectTooltip(StatusEffect statusEffect)
		{
			StatusEffect statusEffect2 = statusEffect;
			statusEffect2.m_tooltip = "";
			List<string> powers = new List<string>();
			int value2 = requiredBossKillsPassive[((Object)statusEffect2).name].Value;
			powers.Add("");
			if (value2 > 0)
			{
				powers.Add(Localization.instance.Localize("$powers_min_kills_passive", new string[1] { value2.ToString() }));
			}
			addTooltips((PowerConfig p) => (int)p.BoxedPassive, "passive");
			value2 = requiredBossKillsActive[((Object)statusEffect2).name].Value;
			if (value2 >= 0)
			{
				powers.Add("");
				if (value2 > 0)
				{
					powers.Add(Localization.instance.Localize("$powers_min_kills_active", new string[1] { value2.ToString() }));
					powers.Add("");
				}
				powers.Add(Localization.instance.Localize("$powers_activation_hint", new string[2]
				{
					Utils.getHumanFriendlyTime(activeBossPowerCooldown.Value),
					Utils.getHumanFriendlyTime(activeBossPowerDuration.Value)
				}));
				addTooltips((PowerConfig p) => (int)p.BoxedActive, "active");
				powers.Add(Localization.instance.Localize("$powers_depletion_hint", new string[1] { Utils.getHumanFriendlyTime(activeBossPowerDepletion.Value) }));
			}
			statusEffect2.m_tooltip = string.Join("\n", powers);
			void addTooltips(Func<PowerConfig, int> value, string type)
			{
				foreach (PowerConfig config in activeBossConfigs[((Object)statusEffect2).name].Configs)
				{
					int num = value(config);
					if (num > 0)
					{
						powers.Add(Localization.instance.Localize("$powers_type_" + type + ": " + config.Desc, new string[1] { num.ToString() }));
					}
				}
			}
		}

		private static void BossDied(long sender, string bossName)
		{
			Utils.IncrementOrSet<string>(Game.instance.GetPlayerProfile().m_enemyStats, bossName, 1f);
		}
	}
	public abstract class PowerConfig
	{
		public static readonly Type[] Modifiers = (from t in typeof(PowerConfig<, >).Assembly.GetTypes()
			where typeof(PowerConfig).IsAssignableFrom(t) && !t.IsAbstract
			orderby t.Name
			select t).ToArray();

		public static readonly Dictionary<string, Type> ModifierMap = Modifiers.ToDictionary((Type t) => t.Name, (Type t) => t);

		public static readonly string[] ModifierNames = Modifiers.Select((Type m) => createFromFloats(m, 0f, 0f).Modifier).ToArray();

		public abstract string Modifier { get; }

		public abstract string Desc { get; }

		public abstract string Unit { get; }

		public abstract object BoxedActive { get; }

		public abstract object BoxedPassive { get; }

		public override bool Equals(object? obj)
		{
			if (obj is PowerConfig powerConfig)
			{
				return Modifier == powerConfig.Modifier;
			}
			return false;
		}

		public override int GetHashCode()
		{
			return Modifier.GetHashCode();
		}

		public static PowerConfig createFromFloats(Type type, float active, float passive)
		{
			MethodInfo method = type.GetMethod("Cast", BindingFlags.Static | BindingFlags.Public | BindingFlags.FlattenHierarchy);
			return (PowerConfig)type.GetConstructors()[0].Invoke(new object[2]
			{
				method.Invoke(null, new object[1] { active }),
				method.Invoke(null, new object[1] { passive })
			});
		}
	}
	public abstract class PowerConfig<T, U> : PowerConfig where T : struct, IConvertible where U : PowerConfig<T, U>
	{
		[CompilerGenerated]
		private T <Active>P;

		[CompilerGenerated]
		private T <Passive>P;

		public override object BoxedActive => <Active>P;

		public override object BoxedPassive => <Passive>P;

		protected PowerConfig(T Active, T Passive)
		{
			<Active>P = Active;
			<Passive>P = Passive;
			base..ctor();
		}

		private T Value(string powerName)
		{
			Player localPlayer = Player.m_localPlayer;
			if (localPlayer == null || !Utils.CanApplyPower(localPlayer, powerName))
			{
				return default(T);
			}
			if (!((Character)localPlayer).m_seman.HaveStatusEffect(StringExtensionMethods.GetStableHashCode("PassivePowers Depletion " + powerName)))
			{
				if (!((Character)Player.m_localPlayer).m_seman.HaveStatusEffect(StringExtensionMethods.GetStableHashCode("PassivePowers " + powerName)))
				{
					return <Passive>P;
				}
				return <Active>P;
			}
			return default(T);
		}

		public static T Total()
		{
			return Cast(PassivePowers.activeBossConfigs.Sum<KeyValuePair<string, BossConfig>>((KeyValuePair<string, BossConfig> kv) => kv.Value.Configs.Sum((PowerConfig c) => (!(c is U val)) ? 0f : val.Value(kv.Key).ToSingle(CultureInfo.InvariantCulture))));
		}

		public static T Cast(float value)
		{
			return (T)Convert.ChangeType(value, typeof(T));
		}
	}
	[UsedImplicitly]
	public class MovementSpeed : PowerConfig<int, MovementSpeed>
	{
		public override string Modifier => "Movement Speed";

		public override string Desc => "$powers_movement_speed_increase";

		public override string Unit => "% increase";

		public MovementSpeed(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class SwimSpeed : PowerConfig<int, SwimSpeed>
	{
		public override string Modifier => "Swim Speed";

		public override string Desc => "$powers_swim_speed_increase";

		public override string Unit => "% increase";

		public SwimSpeed(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class SwimStaminaUsage : PowerConfig<int, SwimStaminaUsage>
	{
		public override string Modifier => "Swim Stamina Usage";

		public override string Desc => "$powers_swim_stamina_usage";

		public override string Unit => "% decrease";

		public SwimStaminaUsage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class RunStamina : PowerConfig<int, RunStamina>
	{
		public override string Modifier => "Run Stamina Reduction";

		public override string Desc => "$powers_run_stamina_reduction";

		public override string Unit => "% reduction";

		public RunStamina(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class JumpStamina : PowerConfig<int, JumpStamina>
	{
		public override string Modifier => "Jump Stamina Reduction";

		public override string Desc => "$powers_jump_stamina_reduction";

		public override string Unit => "% reduction";

		public JumpStamina(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class TreeDamage : PowerConfig<int, TreeDamage>
	{
		public override string Modifier => "Tree Damage Increase";

		public override string Desc => "$powers_tree_damage";

		public override string Unit => "% increase";

		public TreeDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class MiningDamage : PowerConfig<int, MiningDamage>
	{
		public override string Modifier => "Mining Damage Increase";

		public override string Desc => "$powers_stone_damage";

		public override string Unit => "% increase";

		public MiningDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class PhysicalDamage : PowerConfig<int, PhysicalDamage>
	{
		public override string Modifier => "Physical Damage Taken Reduction";

		public override string Desc => "$powers_physical_damage_reduction";

		public override string Unit => "% reduction";

		public PhysicalDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class HealthRegen : PowerConfig<int, HealthRegen>
	{
		public override string Modifier => "Health Regen Increase";

		public override string Desc => "$powers_health_regen_increase";

		public override string Unit => "% increase";

		public HealthRegen(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class TailWind : PowerConfig<int, TailWind>
	{
		public override string Modifier => "Tail Wind Chance";

		public override string Desc => "$powers_tailwind_chance";

		public override string Unit => "% increase";

		public TailWind(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class WindSpeed : PowerConfig<int, WindSpeed>
	{
		public override string Modifier => "Wind Speed Modifier";

		public override string Desc => "$powers_wind_modifier";

		public override string Unit => "% increase";

		public WindSpeed(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class ElementalDamage : PowerConfig<int, ElementalDamage>
	{
		public override string Modifier => "Elemental Damage Taken Reduction";

		public override string Desc => "$powers_elemental_damage_reduction";

		public override string Unit => "% reduction";

		public ElementalDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusDamage : PowerConfig<int, BonusDamage>
	{
		public override string Modifier => "Bonus Damage";

		public override string Desc => "$powers_additional_damage";

		public override string Unit => "% bonus";

		public BonusDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusFireDamage : PowerConfig<int, BonusFireDamage>
	{
		public override string Modifier => "Bonus Fire Damage";

		public override string Desc => "$powers_additional_fire_damage";

		public override string Unit => "% bonus";

		public BonusFireDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusFrostDamage : PowerConfig<int, BonusFrostDamage>
	{
		public override string Modifier => "Bonus Frost Damage";

		public override string Desc => "$powers_additional_frost_damage";

		public override string Unit => "% bonus";

		public BonusFrostDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusLightningDamage : PowerConfig<int, BonusLightningDamage>
	{
		public override string Modifier => "Bonus Lightning Damage";

		public override string Desc => "$powers_additional_lightning_damage";

		public override string Unit => "% bonus";

		public BonusLightningDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusPoisonDamage : PowerConfig<int, BonusPoisonDamage>
	{
		public override string Modifier => "Bonus Poison Damage";

		public override string Desc => "$powers_additional_poison_damage";

		public override string Unit => "% bonus";

		public BonusPoisonDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusSpiritDamage : PowerConfig<int, BonusSpiritDamage>
	{
		public override string Modifier => "Bonus Spirit Damage";

		public override string Desc => "$powers_additional_spirit_damage";

		public override string Unit => "% bonus";

		public BonusSpiritDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusBluntDamage : PowerConfig<int, BonusBluntDamage>
	{
		public override string Modifier => "Bonus Blunt Damage";

		public override string Desc => "$powers_additional_blunt_damage";

		public override string Unit => "% bonus";

		public BonusBluntDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusPierceDamage : PowerConfig<int, BonusPierceDamage>
	{
		public override string Modifier => "Bonus Pierce Damage";

		public override string Desc => "$powers_additional_pierce_damage";

		public override string Unit => "% bonus";

		public BonusPierceDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusSlashDamage : PowerConfig<int, BonusSlashDamage>
	{
		public override string Modifier => "Bonus Slash Damage";

		public override string Desc => "$powers_additional_slash_damage";

		public override string Unit => "% bonus";

		public BonusSlashDamage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusFireDefense : PowerConfig<int, BonusFireDefense>
	{
		public override string Modifier => "Bonus Fire Defense";

		public override string Desc => "$powers_additional_fire_defense";

		public override string Unit => "% bonus";

		public BonusFireDefense(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusFrostDefense : PowerConfig<int, BonusFrostDefense>
	{
		public override string Modifier => "Bonus Frost Defense";

		public override string Desc => "$powers_additional_frost_defense";

		public override string Unit => "% bonus";

		public BonusFrostDefense(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusLightningDefense : PowerConfig<int, BonusLightningDefense>
	{
		public override string Modifier => "Bonus Lightning Defense";

		public override string Desc => "$powers_additional_lightning_defense";

		public override string Unit => "% bonus";

		public BonusLightningDefense(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusPoisonDefense : PowerConfig<int, BonusPoisonDefense>
	{
		public override string Modifier => "Bonus Poison Defense";

		public override string Desc => "$powers_additional_poison_defense";

		public override string Unit => "% bonus";

		public BonusPoisonDefense(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BonusSpiritDefense : PowerConfig<int, BonusSpiritDefense>
	{
		public override string Modifier => "Bonus Spirit Defense";

		public override string Desc => "$powers_additional_spirit_damage";

		public override string Unit => "% bonus";

		public BonusSpiritDefense(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class StaminaSneakUsage : PowerConfig<int, StaminaSneakUsage>
	{
		public override string Modifier => "Stamina Sneak Usage";

		public override string Desc => "$powers_sneak_stamina_reduction";

		public override string Unit => "% bonus";

		public StaminaSneakUsage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class AdrenalineBonus : PowerConfig<int, AdrenalineBonus>
	{
		public override string Modifier => "Adrenaline Bonus";

		public override string Desc => "$powers_adrenaline_bonus";

		public override string Unit => "% bonus";

		public AdrenalineBonus(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class StaggerResist : PowerConfig<int, StaggerResist>
	{
		public override string Modifier => "Stagger Resist";

		public override string Desc => "$powers_stagger_resist";

		public override string Unit => "% bonus";

		public StaggerResist(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BlockStaminaUsage : PowerConfig<int, BlockStaminaUsage>
	{
		public override string Modifier => "Block Stamina Usage";

		public override string Desc => "$powers_block_stamina_usage";

		public override string Unit => "% bonus";

		public BlockStaminaUsage(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class BlockStaminaReturn : PowerConfig<int, BlockStaminaReturn>
	{
		public override string Modifier => "Block Stamina Return";

		public override string Desc => "$powers_block_stamina_return";

		public override string Unit => "+ bonus";

		public BlockStaminaReturn(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class EitrRegen : PowerConfig<int, EitrRegen>
	{
		public override string Modifier => "Eitr Regen Increase";

		public override string Desc => "$powers_eitr_regen";

		public override string Unit => "% increase";

		public EitrRegen(int active, int passive)
			: base(active, passive)
		{
		}
	}
	[UsedImplicitly]
	public class CarryWeight : PowerConfig<int, CarryWeight>
	{
		public override string Modifier => "Carry Weight Increase";

		public override string Desc => "$powers_carry_weight";

		public override string Unit => "+ increase";

		public CarryWeight(int active, int passive)
			: base(active, passive)
		{
		}
	}
	public class BossConfig
	{
		private delegate bool NumberParse(string input, out float value);

		public readonly HashSet<PowerConfig> Configs;

		public BossConfig(HashSet<PowerConfig> configs)
		{
			Configs = configs;
			base..ctor();
		}

		public BossConfig(string configs)
			: this(new HashSet<PowerConfig>(from c in configs.Split(new char[1] { ',' }).Select(delegate(string r)
				{
					string[] array = r.Split(new char[1] { ':' });
					if (array.Length < 2)
					{
						return null;
					}
					if (!PowerConfig.ModifierMap.TryGetValue(array[0], out Type value))
					{
						return null;
					}
					if (!NumberParseFloat(array[1], out var value2))
					{
						return null;
					}
					float value3 = 0f;
					return (array.Length > 2 && !NumberParseFloat(array[2], out value3)) ? null : PowerConfig.createFromFloats(value, value3, value2);
				})
				where c != null
				select c))
		{
		}

		public override string ToString()
		{
			return string.Join(",", Configs.Select((PowerConfig r) => $"{r.GetType().Name}:{r.BoxedPassive}:{r.BoxedActive}"));
		}

		private static object createComboBox()
		{
			//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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			Rect val = (Rect)PassivePowers.configManager.GetType().GetProperty("SettingWindowRect", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(PassivePowers.configManager);
			return PassivePowers.configManager.GetType().Assembly.GetType("ConfigurationManager.Utilities.ComboBox").GetConstructors()[0].Invoke(new object[5]
			{
				(object)default(Rect),
				(object)new GUIContent(""),
				((IEnumerable<string>)PowerConfig.ModifierNames).Select((Func<string, GUIContent>)((string s) => new GUIContent(s))).ToArray(),
				GUI.skin.button,
				((Rect)(ref val)).yMax
			});
		}

		private static void updateComboBox(object comboBox, string current, Action<int> handler, int width)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Type type = comboBox.GetType();
			GUIContent val = new GUIContent(current);
			Rect rect = GUILayoutUtility.GetRect(val, GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width((float)width) });
			type.GetProperty("Rect").SetValue(comboBox, rect);
			type.GetProperty("ButtonContent").SetValue(comboBox, val);
			type.GetMethod("Show").Invoke(comboBox, new object[1] { handler });
		}

		private static bool NumberParseInt(string input, out float value)
		{
			int result;
			bool result2 = int.TryParse(input, out result);
			value = result;
			return result2;
		}

		private static bool NumberParseFloat(string input, out float value)
		{
			return float.TryParse(input, NumberStyles.Float, CultureInfo.InvariantCulture, out value);
		}

		public static Action<ConfigEntryBase> DrawConfigTable(string powerName)
		{
			string powerName2 = powerName;
			List<object> comboBoxes = new List<object>();
			Type selectedPower = null;
			int selectedComboBox = 0;
			bool initialDraw = true;
			bool[] used = new bool[PowerConfig.Modifiers.Length];
			PowerConfig config;
			return delegate(ConfigEntryBase cfg)
			{
				//IL_010a: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Expected O, but got Unknown
				//IL_0253: Unknown result type (might be due to invalid IL or missing references)
				//IL_0258: Unknown result type (might be due to invalid IL or missing references)
				//IL_026d: Expected O, but got Unknown
				//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_02bc: Expected O, but got Unknown
				bool locked = cfg.Description.Tags.Select((object a) => (!(a.GetType().Name == "ConfigurationManagerAttributes")) ? null : ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a))).FirstOrDefault((bool? v) => v.HasValue).GetValueOrDefault();
				HashSet<PowerConfig> newConfigs = new HashSet<PowerConfig>();
				bool wasUpdated = false;
				int num = (int)(PassivePowers.configManager?.GetType().GetProperty("RightColumnWidth", BindingFlags.Instance | BindingFlags.NonPublic).GetGetMethod(nonPublic: true)
					.Invoke(PassivePowers.configManager, Array.Empty<object>()) ?? ((object)130));
				GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
				HashSet<PowerConfig> configs = new BossConfig((string)cfg.BoxedValue).Configs;
				bool flag = false;
				if (configs.Count == 0)
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.Label("No powers selected", new GUIStyle(GUI.skin.label)
					{
						stretchWidth = true
					}, Array.Empty<GUILayoutOption>());
					flag = GUILayout.Button("Add", Array.Empty<GUILayoutOption>());
					GUILayout.EndHorizontal();
				}
				int num2 = -1;
				foreach (PowerConfig item in configs)
				{
					config = item;
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					if (++num2 >= comboBoxes.Count)
					{
						comboBoxes.Add(createComboBox());
					}
					int comboIdx = num2;
					int modifierIdx = Array.IndexOf(PowerConfig.Modifiers, config.GetType());
					updateComboBox(comboBoxes[num2], config.Modifier, delegate(int index)
					{
						for (int k = 0; k <= index; k++)
						{
							if (index >= used.Length - 1)
							{
								break;
							}
							if (used[k] && k != modifierIdx)
							{
								index++;
							}
						}
						selectedPower = PowerConfig.Modifiers[index];
						selectedComboBox = comboIdx;
					}, num - 3 - 21 - 3 - 21);
					Type type2 = ((num2 == selectedComboBox && (object)selectedPower != null) ? selectedPower : config.GetType());
					wasUpdated = wasUpdated || config.GetType() != type2;
					bool num3 = GUILayout.Button("x", new GUIStyle(GUI.skin.button)
					{
						fixedWidth = 21f
					}, Array.Empty<GUILayoutOption>()) && !locked;
					flag = flag || (configs.Count != PowerConfig.Modifiers.Length && GUILayout.Button("+", new GUIStyle(GUI.skin.button)
					{
						fixedWidth = 21f
					}, Array.Empty<GUILayoutOption>()) && !locked);
					GUILayout.EndHorizontal();
					float active = ((PassivePowers.requiredBossKillsActive[powerName2].Value >= 0) ? Query("Active", config.BoxedActive) : ((config.BoxedPassive is int) ? ((float)(int)config.BoxedActive) : ((float)config.BoxedActive)));
					float passive = Query("Passive", config.BoxedPassive);
					if (num3)
					{
						wasUpdated = true;
					}
					else
					{
						newConfigs.Add(PowerConfig.createFromFloats(type2, active, passive));
					}
				}
				selectedPower = null;
				if (flag)
				{
					wasUpdated = true;
					newConfigs.Add(PowerConfig.createFromFloats(PowerConfig.Modifiers.First((Type p) => newConfigs.All((PowerConfig c) => p != c.GetType())), 0f, 0f));
					if (++num2 >= comboBoxes.Count)
					{
						comboBoxes.Add(createComboBox());
					}
				}
				GUILayout.EndVertical();
				if (wasUpdated || initialDraw)
				{
					initialDraw = false;
					cfg.BoxedValue = new BossConfig(newConfigs).ToString();
					FieldInfo field = comboBoxes[0].GetType().GetField("listContent", BindingFlags.Instance | BindingFlags.NonPublic);
					used = new bool[PowerConfig.Modifiers.Length];
					int i = 0;
					while (i < PowerConfig.Modifiers.Length)
					{
						used[i] = newConfigs.Any((PowerConfig p) => p.GetType() == PowerConfig.Modifiers[i]);
						int num4 = i + 1;
						i = num4;
					}
					num2 = -1;
					foreach (PowerConfig item2 in newConfigs)
					{
						List<string> list = new List<string>();
						for (int j = 0; j < used.Length; j++)
						{
							if (!used[j] || PowerConfig.Modifiers[j] == item2.GetType())
							{
								list.Add(PowerConfig.ModifierNames[j]);
							}
						}
						field.SetValue(comboBoxes[++num2], ((IEnumerable<string>)list).Select((Func<string, GUIContent>)((string s) => new GUIContent(s))).ToArray());
					}
				}
				float Query(string type, object current)
				{
					//IL_001f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0024: Unknown result type (might be due to invalid IL or missing references)
					//IL_0039: Expected O, but got Unknown
					//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c5: Expected O, but got Unknown
					//IL_0102: Unknown result type (might be due to invalid IL or missing references)
					//IL_0107: Unknown result type (might be due to invalid IL or missing references)
					//IL_0118: Expected O, but got Unknown
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.Label(type + ": ", new GUIStyle(GUI.skin.label)
					{
						fixedWidth = 70f
					}, Array.Empty<GUILayoutOption>());
					float num6 = ((current is int num5) ? ((float)num5) : ((float)current));
					if (((current is int) ? new NumberParse(NumberParseInt) : new NumberParse(NumberParseFloat))(GUILayout.TextField(num6.ToString(CultureInfo.InvariantCulture), new GUIStyle(GUI.skin.textField)
					{
						fixedWidth = 60f
					}, Array.Empty<GUILayoutOption>()), out var value) && value != num6 && !locked)
					{
						num6 = value;
						wasUpdated = true;
					}
					GUILayout.Label(" " + config.Unit, new GUIStyle(GUI.skin.label)
					{
						stretchWidth = true
					}, Array.Empty<GUILayoutOption>());
					GUILayout.EndHorizontal();
					return num6;
				}
			};
		}
	}
	public class PowerDepletionBehaviour : MonoBehaviour
	{
		public string statusEffect;

		public void Awake()
		{
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				((Character)Player.m_localPlayer).m_seman.AddStatusEffect(StringExtensionMethods.GetStableHashCode(statusEffect), false, 0, 0f);
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public static class Utils
	{
		public static readonly Dictionary<string, string> effectToBossMap = new Dictionary<string, string>
		{
			{ "GP_Eikthyr", "$enemy_eikthyr" },
			{ "GP_TheElder", "$enemy_gdking" },
			{ "GP_Bonemass", "$enemy_bonemass" },
			{ "GP_Moder", "$enemy_dragon" },
			{ "GP_Yagluth", "$enemy_goblinking" },
			{ "GP_Queen", "$enemy_seekerqueen" },
			{ "GP_Fader", "$enemy_fader" }
		};

		public static bool GetToggle(this ConfigEntry<Toggle> toggle)
		{
			return toggle.Value == Toggle.On;
		}

		public static List<string> getPassivePowers(Player player)
		{
			return getPassivePowers(player.m_guardianPower);
		}

		public static List<string> getPassivePowers(string powerList)
		{
			if (!Utility.IsNullOrWhiteSpace(powerList))
			{
				return powerList.Split(new char[1] { ',' }).ToList();
			}
			return new List<string>();
		}

		public static string getHumanFriendlyTime(int seconds)
		{
			TimeSpan timeSpan = TimeSpan.FromSeconds(seconds);
			string text = Localization.instance.Localize((timeSpan.Seconds >= 2) ? "$powers_second_plural" : "$powers_second_singular", new string[1] { timeSpan.Seconds.ToString() });
			string text2 = Localization.instance.Localize((timeSpan.Minutes >= 2) ? "$powers_minute_plural" : "$powers_minute_singular", new string[1] { timeSpan.Minutes.ToString() });
			if (!(timeSpan.TotalMinutes >= 1.0))
			{
				return text;
			}
			if (timeSpan.Seconds != 0)
			{
				return Localization.instance.Localize("$powers_time_bind", new string[2] { text2, text });
			}
			return text2;
		}

		public static bool CanApplyPower(Player player, string power)
		{
			if (!getPassivePowers(player).Contains(power))
			{
				return ((Character)player).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("PassivePowers " + power));
			}
			return true;
		}

		public static bool ActivePowersEnabled()
		{
			return PassivePowers.requiredBossKillsActive.Any<KeyValuePair<string, ConfigEntry<int>>>((KeyValuePair<string, ConfigEntry<int>> v) => v.Value.Value >= 0);
		}

		private static bool PowerEnabled(Dictionary<string, ConfigEntry<int>> required, string powerName)
		{
			int value = required[powerName].Value;
			Game.instance.GetPlayerProfile().m_enemyStats.TryGetValue(effectToBossMap[powerName], out var value2);
			if (value >= 0)
			{
				return (float)value <= value2;
			}
			return false;
		}

		public static bool ActivePowerEnabled(string powerName)
		{
			return PowerEnabled(PassivePowers.requiredBossKillsActive, powerName);
		}

		public static bool PassivePowerEnabled(string powerName)
		{
			return PowerEnabled(PassivePowers.requiredBossKillsPassive, powerName);
		}

		public static bool IsKeyDown(this KeyboardShortcut shortcut)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if ((int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey))
			{
				return ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey);
			}
			return false;
		}
	}
	public static class Power
	{
		public const string Eikthyr = "GP_Eikthyr";

		public const string TheElder = "GP_TheElder";

		public const string Bonemass = "GP_Bonemass";

		public const string Moder = "GP_Moder";

		public const string Yagluth = "GP_Yagluth";

		public const string Queen = "GP_Queen";

		public const string Fader = "GP_Fader";
	}
	[HarmonyPatch(typeof(Player), "SetGuardianPower")]
	public class SetSelectedGuardianPowers
	{
		private static bool Prefix(Player __instance, string name)
		{
			if (name == "" || name.Contains(","))
			{
				__instance.m_guardianPower = name;
			}
			else
			{
				List<string> passivePowers = Utils.getPassivePowers(__instance);
				if (!passivePowers.Remove(name))
				{
					passivePowers.Add(name);
				}
				if (passivePowers.Count > PassivePowers.maximumBossPowers.Value)
				{
					passivePowers.RemoveAt(0);
				}
				__instance.m_guardianPower = string.Join(",", passivePowers);
			}
			ZDO zDO = ((Character)__instance).m_nview.GetZDO();
			if (zDO != null)
			{
				zDO.Set("PassivePowers GuardianPowers", __instance.m_guardianPower);
			}
			return false;
		}
	}
}
namespace ServerSync
{
	[PublicAPI]
	internal abstract class OwnConfigEntryBase
	{
		public object? LocalBaseValue;

		public bool SynchronizedConfig = true;

		public abstract ConfigEntryBase BaseConfig { get; }
	}
	[PublicAPI]
	internal class SyncedConfigEntry<T> : OwnConfigEntryBase
	{
		public readonly ConfigEntry<T> SourceConfig;

		public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig;

		public T Value
		{
			get
			{
				return SourceConfig.Value;
			}
			set
			{
				SourceConfig.Value = value;
			}
		}

		public SyncedConfigEntry(ConfigEntry<T> sourceConfig)
		{
			SourceConfig = sourceConfig;
			base..ctor();
		}

		public void AssignLocalValue(T value)
		{
			if (LocalBaseValue == null)
			{
				Value = value;
			}
			else
			{
				LocalBaseValue = value;
			}
		}
	}
	internal abstract class CustomSyncedValueBase
	{
		public object? LocalBaseValue;

		public readonly string Identifier;

		public readonly Type Type;

		private object? boxedValue;

		protected bool localIsOwner;

		public readonly int Priority;

		public object? BoxedValue
		{
			get
			{
				return boxedValue;
			}
			set
			{
				boxedValue = value;
				this.ValueChanged?.Invoke();
			}
		}

		public event Action? ValueChanged;

		protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority)
		{
			Priority = priority;
			Identifier = identifier;
			Type = type;
			configSync.AddCustomValue(this);
			localIsOwner = configSync.IsSourceOfTruth;
			configSync.SourceOfTruthChanged += delegate(bool truth)
			{
				localIsOwner = truth;
			};
		}
	}
	[PublicAPI]
	internal sealed class CustomSyncedValue<T> : CustomSyncedValueBase
	{
		public T Value
		{
			get
			{
				return (T)base.BoxedValue;
			}
			set
			{
				base.BoxedValue = value;
			}
		}

		public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0)
			: base(configSync, identifier, typeof(T), priority)
		{
			Value = value;
		}

		public void AssignLocalValue(T value)
		{
			if (localIsOwner)
			{
				Value = value;
			}
			else
			{
				LocalBaseValue = value;
			}
		}
	}
	internal class ConfigurationManagerAttributes
	{
		[UsedImplicitly]
		public bool? ReadOnly = false;
	}
	[PublicAPI]
	internal class ConfigSync
	{
		[HarmonyPatch(typeof(ZRpc), "HandlePackage")]
		private static class SnatchCurrentlyHandlingRPC
		{
			public static ZRpc? currentRpc;

			[HarmonyPrefix]
			private static void Prefix(ZRpc __instance)
			{
				currentRpc = __instance;
			}
		}

		[HarmonyPatch(typeof(ZNet), "Awake")]
		internal static class RegisterRPCPatch
		{
			[HarmonyPostfix]
			private static void Postfix(ZNet __instance)
			{
				isServer = __instance.IsServer();
				foreach (ConfigSync configSync2 in configSyncs)
				{
					ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync);
					if (isServer)
					{
						configSync2.InitialSyncDone = true;
						Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections"));
					}
				}
				if (isServer)
				{
					((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges());
				}
				static void SendAdmin(List<ZNetPeer> peers, bool isAdmin)
				{
					ZPackage package = ConfigsToPackage(null, null, new PackageEntry[1]
					{
						new PackageEntry
						{
							section = "Internal",
							key = "lockexempt",
							type = typeof(bool),
							value = isAdmin
						}
					});
					ConfigSync configSync = configSyncs.First();
					if (configSync != null)
					{
						((MonoBehaviour)ZNet.instance).StartCoroutine(configSync.sendZPackage(peers, package));
					}
				}
				static IEnumerator WatchAdminListChanges()
				{
					MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null);
					SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance);
					List<string> CurrentList = new List<string>(adminList.GetList());
					while (true)
					{
						yield return (object)new WaitForSeconds(30f);
						if (!adminList.GetList().SequenceEqual(CurrentList))
						{
							CurrentList = new List<string>(adminList.GetList());
							List<ZNetPeer> adminPeer = ZNet.instance.GetPeers().Where(delegate(ZNetPeer p)
							{
								string hostName = p.m_rpc.GetSocket().GetHostName();
								return ((object)listContainsId == null) ? adminList.Contains(hostName) : ((bool)listContainsId.Invoke(ZNet.instance, new object[2] { adminList, hostName }));
							}).ToList();
							List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList();
							SendAdmin(nonAdminPeer, isAdmin: false);
							SendAdmin(adminPeer, isAdmin: true);
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
		private static class RegisterClientRPCPatch
		{
			[HarmonyPostfix]
			private static void Postfix(ZNet __instance, ZNetPeer peer)
			{
				if (__instance.IsServer())
				{
					return;
				}
				foreach (ConfigSync configSync in configSyncs)
				{
					peer.m_rpc.Register<ZPackage>(configSync.Name + " ConfigSync", (Action<ZRpc, ZPackage>)configSync.RPC_FromServerConfigSync);
				}
			}
		}

		private class ParsedConfigs
		{
			public readonly Dictionary<OwnConfigEntryBase, object?> configValues = new Dictionary<OwnConfigEntryBase, object>();

			public readonly Dictionary<CustomSyncedValueBase, object?> customValues = new Dictionary<CustomSyncedValueBase, object>();
		}

		[HarmonyPatch(typeof(ZNet), "Shutdown")]
		private class ResetConfigsOnShutdown
		{
			[HarmonyPostfix]
			private static void Postfix()
			{
				ProcessingServerUpdate = true;
				foreach (ConfigSync configSync in configSyncs)
				{
					configSync.resetConfigsFromServer();
					configSync.IsSourceOfTruth = true;
					configSync.InitialSyncDone = false;
				}
				ProcessingServerUpdate = false;
			}
		}

		[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
		private class SendConfigsAfterLogin
		{
			private class BufferingSo