Decompiled source of BetterDeathRaiser v2.1.0

GsiX.BetterDeathRaiser.dll

Decompiled 10 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.GUI;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("BetterDeathRiser")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BetterDeathRiser")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace BetterDeathRaiser;

[BepInPlugin("GsiX.BetterDeathRaiser", "GsiX Better Death Raiser", "2.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class BetterDeathRaiserPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Player), "Update")]
	private static class Player_Update_Patch
	{
		private static void Postfix(Player __instance)
		{
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			if (!PluginEnable.Value || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			if (Undead.MainAttack != null && Undead.MainAttack.IsDone())
			{
				Undead.MainDelayStart = Time.time;
				Undead.MainAttack = null;
			}
			if (Undead.MainDelayStart != -1f && Time.time - Undead.MainDelayStart > 2f)
			{
				Undead.MainDelayStart = -1f;
			}
			if (EnableHumanRegen.Value && Time.time - Undead.PlayerHealInterval > 1f && Undead.HaveStatusEffect((Character)(object)__instance, "BDRStatusEffect"))
			{
				Undead.PlayerHealInterval = Time.time;
				Undead.CharacterHeal((Character)(object)__instance, HumanHealthRegen.Value);
			}
			if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return;
			}
			if (float.IsNaN(__instance.m_stamina))
			{
				__instance.m_stamina = 0f;
			}
			if (Undead.CurseInProgress)
			{
				if (!(Time.time - Undead.CurseDelayStart > Undead.CurseAnimationDelay))
				{
					return;
				}
				Character component = ((Component)__instance).GetComponent<Character>();
				if ((Object)(object)component != (Object)null)
				{
					float num = 0f;
					foreach (Character allCharacter in Character.GetAllCharacters())
					{
						if ((Object)(object)allCharacter != (Object)null && !allCharacter.IsDead() && (allCharacter.m_tamed || ((Object)allCharacter).name == Undead.ObjectName_Player || (int)allCharacter.m_faction == 0) && Vector3.Distance(((Component)component).transform.position, ((Component)allCharacter).transform.position) < UndeadCurseRadius.Value)
						{
							num += 1f;
							float num2 = allCharacter.GetHealth() + UndeadInstantHealth.Value;
							if (num2 > allCharacter.GetMaxHealth())
							{
								num2 = allCharacter.GetMaxHealth();
							}
							allCharacter.SetHealth(num2);
							allCharacter.m_seman.AddStatusEffect(Undead.UndeadSEEffect.StatusEffect.NameHash(), true, 0, 0f);
							if (Undead.AnimeLoadedSkull)
							{
								Undead.PlayCastAnimation(((Component)allCharacter).gameObject, Undead.SkullItems);
							}
							if (((Object)allCharacter).name == Undead.ObjectName_Player && (Object)(object)allCharacter != (Object)(object)component)
							{
								Undead.PrintCenterMessage(((Component)allCharacter).gameObject, "Undead Buff from " + __instance.GetPlayerName());
							}
						}
					}
					if (num == 1f)
					{
						Undead.PrintCenterMessage(((Component)component).gameObject, "Undead Cursed Himself");
					}
					else if (num > 1f)
					{
						Undead.PrintCenterMessage(((Component)component).gameObject, $"Undead Cursed {num} Subjects");
					}
				}
				Undead.CurseInProgress = false;
				Undead.PlayerCanMove = true;
			}
			else if (Undead.TeleInProgress)
			{
				if (!(Time.time - Undead.TeleDelayStart > Undead.TeleportAnimationDelay))
				{
					return;
				}
				MonsterAI val = default(MonsterAI);
				foreach (Character allCharacter2 in Character.GetAllCharacters())
				{
					if (!allCharacter2.IsDead() && ((Component)allCharacter2).TryGetComponent<MonsterAI>(ref val) && (Object)(object)val.GetFollowTarget() == (Object)(object)((Component)__instance).gameObject)
					{
						if (!allCharacter2.IsOwner())
						{
							allCharacter2.m_nview.ClaimOwnership();
						}
						((Component)allCharacter2).transform.position = ((Component)__instance).transform.position;
						((BaseAI)val).SetAlerted(false);
						val.m_targetCreature = null;
						val.m_targetStatic = null;
						val.m_timeSinceAttacking = 0f;
					}
				}
				Undead.TeleInProgress = false;
				Undead.PlayerCanMove = true;
			}
			else
			{
				if (!Undead.UnsummonProgress || !(Time.time - Undead.UnsummonDelayStart > Undead.UnsummonAnimationDelay))
				{
					return;
				}
				MonsterAI val2 = default(MonsterAI);
				foreach (Character allCharacter3 in Character.GetAllCharacters())
				{
					if (!allCharacter3.IsDead() && ((Component)allCharacter3).TryGetComponent<MonsterAI>(ref val2) && (Object)(object)val2.GetFollowTarget() == (Object)(object)((Component)__instance).gameObject)
					{
						if (!allCharacter3.IsOwner())
						{
							allCharacter3.m_nview.ClaimOwnership();
						}
						Tameable component2 = ((Component)allCharacter3).GetComponent<Tameable>();
						if ((Object)(object)component2 != (Object)null)
						{
							Undead.PlayCastAnimation(((Component)component2).gameObject, Undead.SkullItems);
							component2.UnSummon();
						}
					}
				}
				Undead.UnsummonProgress = false;
				Undead.PlayerCanMove = true;
			}
		}
	}

	[HarmonyPatch(typeof(Player), "GetComfortLevel")]
	private class Player_GetComfortLevel_Patch
	{
		private static void Postfix(Player __instance, ref int __result, ref bool __runOriginal)
		{
			if (!((Object)(object)__instance == (Object)null) && PluginEnable.Value)
			{
				if ((Object)(object)__instance != (Object)null && StatusEffectConfort.Value > 0 && Undead.HaveStatusEffect((Character)(object)__instance, "BDRStatusEffect"))
				{
					__result = __instance.m_comfortLevel + StatusEffectConfort.Value;
					__runOriginal = false;
				}
			}
		}
	}

	[HarmonyPatch(typeof(Humanoid), "Start")]
	private static class Humanoid_Start_Patch
	{
		private static bool Prefix(Humanoid __instance, ref bool __runOriginal)
		{
			if (PluginEnable.Value && (Object)(object)__instance != (Object)null && !((Character)__instance).IsPlayer() && ((Object)__instance).name == Undead.ObjectName_Vanilla)
			{
				Tameable component = ((Component)__instance).GetComponent<Tameable>();
				if ((Object)(object)component != (Object)null)
				{
					GameObject followTarget = component.m_monsterAI.GetFollowTarget();
					if ((Object)(object)Undead.UndeadSpawnOwner != (Object)null && (Object)(object)Undead.UndeadSpawnOwner == (Object)(object)followTarget)
					{
						component.m_commandable = true;
						Undead.UndeadUpdateInterval(component, set: true);
						for (int i = 0; i < 4; i++)
						{
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[i]);
						}
						string text = "";
						if (Undead.UndeadSpawnWeapon == Undeads.Weapon.Bow)
						{
							text = Undead.UndeadText[1];
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[6]);
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[7]);
						}
						else if (Undead.UndeadSpawnWeapon == Undeads.Weapon.Sword)
						{
							text = Undead.UndeadText[2];
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[4]);
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[5]);
						}
						else if (Undead.UndeadSpawnWeapon == Undeads.Weapon.Mace)
						{
							text = Undead.UndeadText[3];
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[8]);
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[5]);
						}
						component.SetText(component.GetText() + " " + text);
						Undead.UndeadSpawnOwner = null;
						__runOriginal = false;
						return false;
					}
					Undeads.Weapon undeadWeaponType = Undead.GetUndeadWeaponType(component);
					if (undeadWeaponType != 0)
					{
						component.m_commandable = true;
						Undead.UndeadUpdateInterval(component, set: true);
						for (int j = 0; j < 4; j++)
						{
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[j]);
						}
						switch (undeadWeaponType)
						{
						case Undeads.Weapon.Bow:
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[7]);
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[6]);
							break;
						case Undeads.Weapon.Sword:
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[5]);
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[4]);
							break;
						case Undeads.Weapon.Mace:
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[5]);
							Undead.GiveDefaultItem(__instance, Undead.UndeadEquipmentEnum[8]);
							break;
						}
						__runOriginal = false;
						return false;
					}
				}
			}
			__runOriginal = true;
			return true;
		}
	}

	[HarmonyPatch(typeof(Humanoid), "StartAttack")]
	private static class Humanoid_StartAttack_Patch
	{
		private static bool Prefix(Humanoid __instance, Character target, bool secondaryAttack, ref bool __result, ref bool __runOriginal)
		{
			if (PluginEnable.Value && (Object)(object)__instance != (Object)null && Undead.IsHoldingUndead(((Component)__instance).gameObject, EnabledTweakVanilla.Value))
			{
				Player component = ((Component)__instance).gameObject.GetComponent<Player>();
				if ((Object)(object)Player.m_localPlayer != (Object)(object)component || (Object)(object)Undead.UndeadSpawnOwner != (Object)null || Undead.MainDelayStart != -1f || Undead.MainAttack != null)
				{
					__result = false;
					__runOriginal = false;
					return __runOriginal;
				}
				__runOriginal = false;
				if ((((Character)__instance).InAttack() && !__instance.HaveQueuedChain()) || ((Character)__instance).InDodge() || !((Character)__instance).CanMove() || ((Character)__instance).IsKnockedBack() || ((Character)__instance).IsStaggering() || ((Character)__instance).InMinorAction())
				{
					__result = false;
					return false;
				}
				ItemData currentWeapon = __instance.GetCurrentWeapon();
				if (currentWeapon == null)
				{
					__result = false;
					return false;
				}
				if (secondaryAttack && !currentWeapon.HaveSecondaryAttack())
				{
					__result = false;
					return false;
				}
				if (!secondaryAttack && !currentWeapon.HavePrimaryAttack())
				{
					__result = false;
					return false;
				}
				if (__instance.m_currentAttack != null)
				{
					__instance.m_currentAttack.Stop();
					__instance.m_previousAttack = __instance.m_currentAttack;
					__instance.m_currentAttack = null;
				}
				Undead.MainAttack = ((!secondaryAttack) ? (Undead.MainAttack = currentWeapon.m_shared.m_attack.Clone()) : (Undead.MainAttack = currentWeapon.m_shared.m_secondaryAttack.Clone()));
				if (Undead.MainAttack.Start(__instance, ((Character)__instance).m_body, ((Character)__instance).m_zanim, ((Character)__instance).m_animEvent, __instance.m_visEquipment, currentWeapon, __instance.m_previousAttack, __instance.m_timeSinceLastAttack, __instance.GetAttackDrawPercentage()))
				{
					__instance.ClearActionQueue();
					__instance.m_currentAttack = Undead.MainAttack;
					__instance.m_currentAttackIsSecondary = secondaryAttack;
					__instance.m_lastCombatTimer = 0f;
					Undead.UndeadSpawnOwner = ((Component)Player.m_localPlayer).gameObject;
					Undead.UndeadSpawnWeapon = Undead.UndeadWeapon;
					__result = true;
					return false;
				}
				Undead.MainAttack = null;
				__result = false;
				return false;
			}
			__runOriginal = true;
			return true;
		}
	}

	[HarmonyPatch(typeof(Humanoid), "EquipItem")]
	private static class Humanoid_EquipItem_Patch
	{
		private static void Postfix(Humanoid __instance, ItemData item, bool triggerEquipEffects = true)
		{
			if (Undead.CastIsInAnimation || (!PluginEnable.Value && (Object)(object)__instance == (Object)null) || item == null || !Undead.IsHoldingUndead(((Component)__instance).gameObject, EnabledTweakVanilla.Value))
			{
				return;
			}
			UpdateStaffSkele_Undead(__instance.m_leftItem);
			UpdateStaffSkele_Vanilla(__instance.m_leftItem);
			Player component = ((Component)__instance).gameObject.GetComponent<Player>();
			if ((Object)(object)Player.m_localPlayer == (Object)(object)component)
			{
				if (Undead.UndeadWeapon == Undeads.Weapon.Bow)
				{
					Undead.PrintCenterMessage(((Component)__instance).gameObject, Undead.UndeadText[1]);
				}
				else if (Undead.UndeadWeapon == Undeads.Weapon.Sword)
				{
					Undead.PrintCenterMessage(((Component)__instance).gameObject, Undead.UndeadText[2]);
				}
				else if (Undead.UndeadWeapon == Undeads.Weapon.Mace)
				{
					Undead.PrintCenterMessage(((Component)__instance).gameObject, Undead.UndeadText[3]);
				}
			}
		}
	}

	[HarmonyPatch(typeof(Humanoid), "IsBlocking")]
	private static class Humanoid_IsBlocking_Patch
	{
		private static bool Prefix(Humanoid __instance, ref bool __result, ref bool __runOriginal)
		{
			__runOriginal = true;
			if (!PluginEnable.Value && (Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Player component = ((Component)__instance).GetComponent<Player>();
			if ((Object)(object)component != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)component == (Object)(object)Player.m_localPlayer)
			{
				if (__instance.m_leftItem == null || !Undead.IsHoldingUndead(((Component)__instance).gameObject, EnabledTweakVanilla.Value))
				{
					return true;
				}
				__runOriginal = false;
				__result = false;
				if (((Character)component).InAttack() || ((Character)component).InDodge() || ((Character)component).InPlaceMode() || ((Character)component).IsStaggering() || ((Character)component).InMinorAction())
				{
					return false;
				}
				if (Undead.TeleInProgress || Undead.CurseInProgress || Undead.UnsummonProgress)
				{
					return false;
				}
				if (ZInput.GetKey((KeyCode)324, true) && Time.time - Undead.WeaponSelectionStart > Undead.WeaponSelectionDelay)
				{
					Undead.WeaponSelectionStart = Time.time;
					if (ZInput.GetButton(Shortcut_Selection.Name))
					{
						TogglePanel();
					}
					else if (ZInput.GetButton(Shortcut_Teleport.Name))
					{
						UndeadTeleport();
					}
					else if (ZInput.GetButton(Shortcut_Curse.Name))
					{
						UndeadCurse();
					}
					else if (ZInput.GetButton(Shortcut_Unsummon.Name))
					{
						UndeadUnsummon();
					}
				}
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Tameable), "Update")]
	private static class Tameable_Update_Patch
	{
		private static void Postfix(Tameable __instance)
		{
			if (!PluginEnable.Value || !((Object)(object)__instance != (Object)null) || !Undead.IsTamedUndead(__instance) || !Undead.UndeadUpdateInterval(__instance))
			{
				return;
			}
			if (DisableUndeadHungry.Value)
			{
				__instance.ResetFeedingTimer();
			}
			if (!EnableUndeadRegen.Value)
			{
				return;
			}
			if (UndeadCursedHealOnly.Value)
			{
				Character component = ((Component)__instance).gameObject.GetComponent<Character>();
				if (Undead.HaveStatusEffect(component, "BDRStatusEffect"))
				{
					Undead.CharacterHeal(__instance.m_character, UndeadHealthRegen.Value);
				}
			}
			else
			{
				Undead.CharacterHeal(__instance.m_character, UndeadHealthRegen.Value);
			}
		}
	}

	[HarmonyPatch(typeof(Tameable), "Interact")]
	private static class Tameable_Interact_Patch
	{
		private static bool Prefix(Tameable __instance, Humanoid user, bool hold, bool alt, ref bool __result, ref bool __runOriginal)
		{
			//IL_0059: 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)
			if (PluginEnable.Value && (Object)(object)__instance != (Object)null && __instance.m_nview.IsValid() && Undead.IsTamedUndead(__instance))
			{
				if (Time.time - __instance.m_lastPetTime > 1f)
				{
					__instance.m_lastPetTime = Time.time;
					__instance.m_petEffect.Create(((Component)__instance).transform.position, ((Component)__instance).transform.rotation, (Transform)null, 1f, -1);
					__instance.Command(user, true);
				}
				__runOriginal = false;
				__result = false;
				return false;
			}
			__runOriginal = true;
			return true;
		}
	}

	[HarmonyPatch(typeof(Tameable), "UnsummonMaxInstances")]
	private static class Tameable_UnsummonMaxInstances_Patch
	{
		private static void Prefix(Tameable __instance, ref int maxInstances)
		{
			if (PluginEnable.Value && !((Object)(object)__instance == (Object)null) && __instance.m_nview.IsValid() && __instance.m_nview.IsOwner() && !(((Object)__instance).name != Undead.ObjectName_Vanilla))
			{
				GameObject followTarget = __instance.m_monsterAI.GetFollowTarget();
				if ((Object)(object)Undead.UndeadSpawnOwner != (Object)null && (Object)(object)Undead.UndeadSpawnOwner == (Object)(object)followTarget)
				{
					ModifyMaxSummon(ref maxInstances);
				}
				else if (Undead.IsTamedUndead(__instance))
				{
					ModifyMaxSummon(ref maxInstances);
				}
			}
			static void ModifyMaxSummon(ref int maxinstances)
			{
				if (!MaxSummonStaffLevel.Value)
				{
					maxinstances = Undead.UndeadMaxSummon;
				}
				else
				{
					maxinstances += 2;
					if (maxinstances > Undead.UndeadMaxSummon)
					{
						maxinstances = Undead.UndeadMaxSummon;
					}
				}
			}
		}
	}

	[HarmonyPatch(typeof(Tameable), "GetHoverText")]
	private static class Tameable_GetHoverText_Patch
	{
		private static void Postfix(Tameable __instance, ref string __result)
		{
			if (!PluginEnable.Value || (Object)(object)__instance == (Object)null || !__instance.m_nview.IsValid() || !Undead.IsTamedUndead(__instance))
			{
				return;
			}
			bool flag = Undead.IsHoldingUndead(((Component)Player.m_localPlayer).gameObject, EnabledTweakVanilla.Value);
			string text = "";
			GameObject followTarget = __instance.m_monsterAI.GetFollowTarget();
			if ((Object)(object)followTarget != (Object)null)
			{
				Player component = followTarget.GetComponent<Player>();
				if ((Object)(object)component != (Object)null)
				{
					text = component.GetPlayerName();
				}
			}
			string text2 = ((!(text == "")) ? Localization.instance.Localize("Following <color=green>" + text + "</color>\n[<color=yellow><b>$KEY_Use</b></color>] Commands") : Localization.instance.Localize("<color=#858585>Roaming</color>\n[<color=yellow><b>$KEY_Use</b></color>] Commands"));
			string text3 = ((ZInput.IsNonClassicFunctionality() && ZInput.IsGamepadActive()) ? ((!flag || !KeyTextEnabled.Value) ? text2 : SetupText(text2)) : ((!flag || !KeyTextEnabled.Value) ? text2 : SetupText(text2)));
			__result = text3;
			static string SetupText(string input)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				return input + Localization.instance.Localize($"\n[<color=yellow><b> {ConfigTeleport.Value} </b></color>] Teleport" + $"\n[<color=yellow><b> {ConfigSelection.Value} </b></color>] Selection" + $"\n[<color=yellow><b> {ConfigCurse.Value} </b></color>] Curse" + $"\n[<color=yellow><b> {ConfigUnsummon.Value} </b></color>] Unsummon");
			}
		}
	}

	[HarmonyPatch(typeof(Character), "OnCollisionStay")]
	private static class Character_OnCollisionStay_Patch
	{
		private static void Postfix(Character __instance, Collision collision)
		{
			if (PluginEnable.Value && (Object)(object)__instance != (Object)null && collision != null)
			{
				Character component = collision.gameObject.GetComponent<Character>();
				if ((Object)(object)component != (Object)null && ((Object)component).name == Undead.ObjectName_Vanilla && ((Object)__instance).name == Undead.ObjectName_Player)
				{
					Physics.IgnoreCollision(collision.collider, ((Component)__instance).gameObject.GetComponent<Collider>());
				}
				else if ((Object)(object)component != (Object)null && ((Object)component).name == Undead.ObjectName_Player && ((Object)__instance).name == Undead.ObjectName_Vanilla)
				{
					Physics.IgnoreCollision(collision.collider, ((Component)__instance).gameObject.GetComponent<Collider>());
				}
				else if (((Object)__instance).name == Undead.ObjectName_Vanilla && (Object)(object)collision.gameObject.GetComponentInParent<Vagon>() != (Object)null)
				{
					Physics.IgnoreCollision(collision.collider, ((Component)__instance).gameObject.GetComponent<Collider>());
				}
			}
		}
	}

	[HarmonyPatch(typeof(Player), "CanMove")]
	private static class Player_CanMove_Patch
	{
		private static void Postfix(Player __instance, ref bool __result)
		{
			if (PluginEnable.Value && !((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				__result = Undead.PlayerCanMove;
			}
		}
	}

	[HarmonyPatch(typeof(ItemDrop), "Awake")]
	private static class ItemDrop_Awake_Patch
	{
		private static void Postfix(ItemDrop __instance)
		{
			if (PluginEnable.Value)
			{
				_ = (Object)(object)__instance == (Object)null;
			}
		}
	}

	[HarmonyPatch(typeof(ZNetScene), "Awake")]
	private static class ZNetScene_Awake_Patch
	{
		private static void Postfix(ZNetScene __instance)
		{
			if (!((Object)(object)__instance != (Object)null))
			{
				return;
			}
			UpdatePrefabDB();
			Undead.AnimeLoadedOrbs = Undead.GetAnimationProp(ZNetScene.instance.GetPrefab(Undead.StaffSkeleton_Shield), out Undead.OrbsItems);
			Undead.AnimeLoadedSkull = Undead.GetAnimationProp(ZNetScene.instance.GetPrefab(Undead.StaffSkeleton_Raiser), out Undead.SkullItems);
			for (int i = 0; i < 9; i++)
			{
				if ((Object)(object)Undead.UndeadEquipmentEnum[i] == (Object)null)
				{
					Undead.UndeadEquipmentEnum[i] = ZNetScene.instance.GetPrefab(Undead.UndeadEquipmentName[i]);
				}
			}
			GameObject prefab = ZNetScene.instance.GetPrefab("skeleton_bow2");
			if ((Object)(object)prefab != (Object)null)
			{
				Undead.CachedBowAi = prefab.GetComponent<ItemDrop>();
			}
		}
	}

	public const string PluginGUID = "GsiX.BetterDeathRaiser";

	public const string PluginName = "GsiX Better Death Raiser";

	public const string PluginVersion = "2.1.0";

	public static string PluginNamespace = "BetterDeathRaiser";

	public readonly Harmony harmony = new Harmony("GsiX.BetterDeathRaiser");

	private static ManualLogSource DeLog;

	private static ItemConfig UndeadItemConfig;

	private static GameObject SleectPanel;

	private static ButtonConfig Shortcut_Teleport;

	private static ButtonConfig Shortcut_Selection;

	private static ButtonConfig Shortcut_Curse;

	private static ButtonConfig Shortcut_Unsummon;

	public static ConfigEntry<bool> PluginEnable;

	public static ConfigEntry<float> UndeadHealthRegen;

	public static ConfigEntry<bool> EnableUndeadRegen;

	public static ConfigEntry<bool> UndeadCursedHealOnly;

	public static ConfigEntry<bool> DisableUndeadHungry;

	public static ConfigEntry<bool> MaxSummonStaffLevel;

	public static ConfigEntry<float> UndeadCurseRadius;

	public static ConfigEntry<float> UndeadInstantHealth;

	public static ConfigEntry<bool> EnabledTweakVanilla;

	public static ConfigEntry<float> CostCastHealthVanilla;

	public static ConfigEntry<float> CostCastHealthPerVanilla;

	public static ConfigEntry<float> CostCastStaminaVanilla;

	public static ConfigEntry<float> CostCastEitrVanilla;

	public static ConfigEntry<float> DurabilityCastCostVanilla;

	public static ConfigEntry<bool> EnabledTweakUndead;

	public static ConfigEntry<float> CostCastHealthUndead;

	public static ConfigEntry<float> CostCastHealthPerUndead;

	public static ConfigEntry<float> CostCastStaminaUndead;

	public static ConfigEntry<float> CostCastEitrUndead;

	public static ConfigEntry<float> DurabilityCastCostUndead;

	public static ConfigEntry<bool> EnableHumanRegen;

	public static ConfigEntry<float> HumanHealthRegen;

	public static ConfigEntry<bool> CastCurseCanMove;

	public static ConfigEntry<bool> CastTelepCanMove;

	public static ConfigEntry<string> CraftWorkStation;

	public static ConfigEntry<int> CraftMaxQuality;

	public static ConfigEntry<string> CraftingRequirement1;

	public static ConfigEntry<string> CraftingRequirement2;

	public static ConfigEntry<string> CraftingRequirement3;

	public static ConfigEntry<float> TeleUseInterval;

	public static ConfigEntry<float> CurseUseInterval;

	public static ConfigEntry<float> UnsummonUseInterval;

	public static ConfigEntry<float> RightClickCost;

	public static ConfigEntry<float> CurseEffectDuration;

	public static ConfigEntry<int> StatusEffectConfort;

	public static ConfigEntry<bool> KeysHintEnabled;

	public static ConfigEntry<bool> KeyTextEnabled;

	public static ConfigEntry<KeyboardShortcut> ConfigTeleport;

	public static ConfigEntry<KeyboardShortcut> ConfigSelection;

	public static ConfigEntry<KeyboardShortcut> ConfigCurse;

	public static ConfigEntry<KeyboardShortcut> ConfigUnsummon;

	private static float Buff_TeleUseInterval;

	private static float Buff_CurseUseInterval;

	private static float Buff_UnsummonUseInterval;

	private static Undeads Undead;

	private static readonly Dictionary<string, Texture2D> cachedTextures = new Dictionary<string, Texture2D>();

	public void Awake()
	{
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Expected O, but got Unknown
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Expected O, but got Unknown
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Expected O, but got Unknown
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Expected O, but got Unknown
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Expected O, but got Unknown
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Expected O, but got Unknown
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Expected O, but got Unknown
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Expected O, but got Unknown
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Expected O, but got Unknown
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Expected O, but got Unknown
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: 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_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Expected O, but got Unknown
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0209: Expected O, but got Unknown
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Expected O, but got Unknown
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Expected O, but got Unknown
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Expected O, but got Unknown
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Expected O, but got Unknown
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02df: Expected O, but got Unknown
		//IL_02df: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: Expected O, but got Unknown
		//IL_0311: Unknown result type (might be due to invalid IL or missing references)
		//IL_0316: Unknown result type (might be due to invalid IL or missing references)
		//IL_031d: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Expected O, but got Unknown
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0335: Expected O, but got Unknown
		//IL_035d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0362: Unknown result type (might be due to invalid IL or missing references)
		//IL_0369: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Expected O, but got Unknown
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Expected O, but got Unknown
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Expected O, but got Unknown
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Expected O, but got Unknown
		//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0401: Unknown result type (might be due to invalid IL or missing references)
		//IL_040f: Expected O, but got Unknown
		//IL_040f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0419: Expected O, but got Unknown
		//IL_043d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0442: Unknown result type (might be due to invalid IL or missing references)
		//IL_0449: Unknown result type (might be due to invalid IL or missing references)
		//IL_0457: Expected O, but got Unknown
		//IL_0457: Unknown result type (might be due to invalid IL or missing references)
		//IL_0461: Expected O, but got Unknown
		//IL_0489: Unknown result type (might be due to invalid IL or missing references)
		//IL_048e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0495: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a3: Expected O, but got Unknown
		//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ad: Expected O, but got Unknown
		//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04da: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ef: Expected O, but got Unknown
		//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f9: Expected O, but got Unknown
		//IL_0521: Unknown result type (might be due to invalid IL or missing references)
		//IL_0526: Unknown result type (might be due to invalid IL or missing references)
		//IL_052d: Unknown result type (might be due to invalid IL or missing references)
		//IL_053b: Expected O, but got Unknown
		//IL_053b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0545: Expected O, but got Unknown
		//IL_056d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0572: Unknown result type (might be due to invalid IL or missing references)
		//IL_0579: Unknown result type (might be due to invalid IL or missing references)
		//IL_0587: Expected O, but got Unknown
		//IL_0587: Unknown result type (might be due to invalid IL or missing references)
		//IL_0591: Expected O, but got Unknown
		//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_05be: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d3: Expected O, but got Unknown
		//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_05dd: Expected O, but got Unknown
		//IL_0601: Unknown result type (might be due to invalid IL or missing references)
		//IL_0606: Unknown result type (might be due to invalid IL or missing references)
		//IL_060d: Unknown result type (might be due to invalid IL or missing references)
		//IL_061b: Expected O, but got Unknown
		//IL_061b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0625: Expected O, but got Unknown
		//IL_0649: Unknown result type (might be due to invalid IL or missing references)
		//IL_064e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0655: Unknown result type (might be due to invalid IL or missing references)
		//IL_0663: Expected O, but got Unknown
		//IL_0663: Unknown result type (might be due to invalid IL or missing references)
		//IL_066d: Expected O, but got Unknown
		//IL_0691: Unknown result type (might be due to invalid IL or missing references)
		//IL_0696: Unknown result type (might be due to invalid IL or missing references)
		//IL_069d: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ab: Expected O, but got Unknown
		//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b5: Expected O, but got Unknown
		//IL_06dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f7: Expected O, but got Unknown
		//IL_06f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0701: Expected O, but got Unknown
		//IL_0729: Unknown result type (might be due to invalid IL or missing references)
		//IL_072e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0735: Unknown result type (might be due to invalid IL or missing references)
		//IL_0743: Expected O, but got Unknown
		//IL_0743: Unknown result type (might be due to invalid IL or missing references)
		//IL_074d: Expected O, but got Unknown
		//IL_0775: Unknown result type (might be due to invalid IL or missing references)
		//IL_077a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0781: Unknown result type (might be due to invalid IL or missing references)
		//IL_078f: Expected O, but got Unknown
		//IL_078f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0799: Expected O, but got Unknown
		//IL_07c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_07cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_07db: Expected O, but got Unknown
		//IL_07db: Unknown result type (might be due to invalid IL or missing references)
		//IL_07e5: Expected O, but got Unknown
		//IL_080d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0812: Unknown result type (might be due to invalid IL or missing references)
		//IL_0819: Unknown result type (might be due to invalid IL or missing references)
		//IL_0827: Expected O, but got Unknown
		//IL_0827: Unknown result type (might be due to invalid IL or missing references)
		//IL_0831: Expected O, but got Unknown
		//IL_0855: Unknown result type (might be due to invalid IL or missing references)
		//IL_085a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0861: Unknown result type (might be due to invalid IL or missing references)
		//IL_086f: Expected O, but got Unknown
		//IL_086f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0879: Expected O, but got Unknown
		//IL_08a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_08bb: Expected O, but got Unknown
		//IL_08bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c5: Expected O, but got Unknown
		//IL_08ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0907: Expected O, but got Unknown
		//IL_0907: Unknown result type (might be due to invalid IL or missing references)
		//IL_0911: Expected O, but got Unknown
		//IL_0939: Unknown result type (might be due to invalid IL or missing references)
		//IL_093e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0945: Unknown result type (might be due to invalid IL or missing references)
		//IL_0953: Expected O, but got Unknown
		//IL_0953: Unknown result type (might be due to invalid IL or missing references)
		//IL_095d: Expected O, but got Unknown
		//IL_0985: Unknown result type (might be due to invalid IL or missing references)
		//IL_098a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0991: Unknown result type (might be due to invalid IL or missing references)
		//IL_099f: Expected O, but got Unknown
		//IL_099f: Unknown result type (might be due to invalid IL or missing references)
		//IL_09a9: Expected O, but got Unknown
		//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_09dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_09eb: Expected O, but got Unknown
		//IL_09eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_09f5: Expected O, but got Unknown
		//IL_0a1a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a1f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a26: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a34: Expected O, but got Unknown
		//IL_0a34: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a3e: Expected O, but got Unknown
		//IL_0a62: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a67: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a6e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a7c: Expected O, but got Unknown
		//IL_0a7c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a86: Expected O, but got Unknown
		//IL_0aaa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aaf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ab6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ac4: Expected O, but got Unknown
		//IL_0ac4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ace: Expected O, but got Unknown
		//IL_0aea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0afd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b02: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b09: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b17: Expected O, but got Unknown
		//IL_0b17: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b21: Expected O, but got Unknown
		//IL_0b3d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b50: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b55: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b5c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b6a: Expected O, but got Unknown
		//IL_0b6a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b74: Expected O, but got Unknown
		//IL_0b90: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ba3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ba8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0baf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bbd: Expected O, but got Unknown
		//IL_0bbd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bc7: Expected O, but got Unknown
		//IL_0be3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bf6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bfb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c02: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c10: Expected O, but got Unknown
		//IL_0c10: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c1a: Expected O, but got Unknown
		DeLog = ((BaseUnityPlugin)this).Logger;
		Undead = new Undeads();
		PluginEnable = ((BaseUnityPlugin)this).Config.Bind<bool>("PLUGIN ENABLED", "PluginEnable", true, new ConfigDescription("Plugin Enabled/Disabled", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 1
		} }));
		EnableUndeadRegen = ((BaseUnityPlugin)this).Config.Bind<bool>("UNDEAD TWEAK", "EnableUndeadRegen", true, new ConfigDescription("Allow undead to regen healt during Cursed", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 2
		} }));
		UndeadCursedHealOnly = ((BaseUnityPlugin)this).Config.Bind<bool>("UNDEAD TWEAK", "UndeadCursedHealOnly", true, new ConfigDescription("If on, undead only heal up when received Cursed buff.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 3
		} }));
		DisableUndeadHungry = ((BaseUnityPlugin)this).Config.Bind<bool>("UNDEAD TWEAK", "DisableUndeadHungry", true, new ConfigDescription("If on, undead never go hungry.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 4
		} }));
		MaxSummonStaffLevel = ((BaseUnityPlugin)this).Config.Bind<bool>("UNDEAD TWEAK", "MaxSummonStaffLevel", true, new ConfigDescription("If on, number of undead can be summon base on Staff upgrade level.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 6
		} }));
		UndeadHealthRegen = ((BaseUnityPlugin)this).Config.Bind<float>("UNDEAD TWEAK", "UndeadRegenHealth", 2f, new ConfigDescription("Undead health healed per sec during Cursed", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 7
		} }));
		UndeadCurseRadius = ((BaseUnityPlugin)this).Config.Bind<float>("UNDEAD TWEAK", "UndeadCurseRadius", 6f, new ConfigDescription("Radius effected to get Cursed buff.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 8
		} }));
		UndeadInstantHealth = ((BaseUnityPlugin)this).Config.Bind<float>("UNDEAD TWEAK", "UndeadInstantHealth", 50f, new ConfigDescription("Non regen instant Health added to player and undead during receiving buff.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 9
		} }));
		EnabledTweakVanilla = ((BaseUnityPlugin)this).Config.Bind<bool>("VANILLA CASTING COST", "EnabledTweakVanilla", false, new ConfigDescription("If true, Vanilla Death Raiser also will be modify.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 10
		} }));
		CostCastHealthVanilla = ((BaseUnityPlugin)this).Config.Bind<float>("VANILLA CASTING COST", "VanillaCastCost_Health", 0f, new ConfigDescription("Value zero Off. Vanilla 0. How much health cost to cast Undead.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 11
		} }));
		CostCastHealthPerVanilla = ((BaseUnityPlugin)this).Config.Bind<float>("VANILLA CASTING COST", "VanillaCastCost_HealthPer", 50f, new ConfigDescription("Value zero Off. Vanilla 50%. How much health percentage cost to cast Undead. Override CostCastHealth", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 12
		} }));
		CostCastStaminaVanilla = ((BaseUnityPlugin)this).Config.Bind<float>("VANILLA CASTING COST", "VanillaCastCost_Stamina", 0f, new ConfigDescription("Value zero Off. Vanilla 0. How much stamina cost to cast Undead.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 13
		} }));
		CostCastEitrVanilla = ((BaseUnityPlugin)this).Config.Bind<float>("VANILLA CASTING COST", "VanillaCastCost_Eitr", 100f, new ConfigDescription("Value zero Off. How much eitr cost to cast Undead.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 14
		} }));
		DurabilityCastCostVanilla = ((BaseUnityPlugin)this).Config.Bind<float>("VANILLA CASTING COST", "VanillaCastCost_Durability", 1f, new ConfigDescription("StaffSkeleton durability cost for each cast.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 15
		} }));
		EnabledTweakUndead = ((BaseUnityPlugin)this).Config.Bind<bool>("UNDEAD CASTING COST", "EnabledTweakUndead", true, new ConfigDescription("If true, Custom Death Raiser can be use ingame.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 16
		} }));
		CostCastHealthUndead = ((BaseUnityPlugin)this).Config.Bind<float>("UNDEAD CASTING COST", "UndeadCastCost_Health", 0f, new ConfigDescription("Value zero Off. Vanilla 0. How much health cost to cast Undead.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 17
		} }));
		CostCastHealthPerUndead = ((BaseUnityPlugin)this).Config.Bind<float>("UNDEAD CASTING COST", "UndeadCastCost_HealthPer", 20f, new ConfigDescription("Value zero Off. Vanilla 50%. How much health percentage cost to cast Undead. Override CostCastHealth", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 18
		} }));
		CostCastStaminaUndead = ((BaseUnityPlugin)this).Config.Bind<float>("UNDEAD CASTING COST", "UndeadCastCost_Stamina", 50f, new ConfigDescription("Value zero Off. Vanilla 0. How much stamina cost to cast Undead.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 19
		} }));
		CostCastEitrUndead = ((BaseUnityPlugin)this).Config.Bind<float>("UNDEAD CASTING COST", "UndeadCastCost_Eitr", 0f, new ConfigDescription("Value zero Off. How much eitr cost to cast Undead.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 20
		} }));
		DurabilityCastCostUndead = ((BaseUnityPlugin)this).Config.Bind<float>("UNDEAD CASTING COST", "UndeadCastCost_Durability", 1f, new ConfigDescription("StaffUndead durability cost for each cast.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 21
		} }));
		EnableHumanRegen = ((BaseUnityPlugin)this).Config.Bind<bool>("HUMAN", "EnableHumanRegen", true, new ConfigDescription("Allow human to regen healt during Cursed", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 22
		} }));
		CastCurseCanMove = ((BaseUnityPlugin)this).Config.Bind<bool>("HUMAN", "MoveDuringTeleportCast", false, new ConfigDescription("Allow player to move during casting teleport", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 23
		} }));
		CastTelepCanMove = ((BaseUnityPlugin)this).Config.Bind<bool>("HUMAN", "MoveDuringCurseCast", false, new ConfigDescription("Allow player to move during casting Cursed", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 24
		} }));
		HumanHealthRegen = ((BaseUnityPlugin)this).Config.Bind<float>("HUMAN", "HumanRegenHealth", 2f, new ConfigDescription("Human health healed per sec during Cursed", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 25
		} }));
		CraftWorkStation = ((BaseUnityPlugin)this).Config.Bind<string>("CRAFTING UNDEAD", "CraftingStation", "workbench", new ConfigDescription("Valid list - workbench, forge, stonecutter, artisanstation, blackforge, magetable", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 26
		} }));
		CraftingRequirement1 = ((BaseUnityPlugin)this).Config.Bind<string>("CRAFTING UNDEAD", "CraftingRequirement1", "TrophyEikthyr|5", new ConfigDescription("Drop Prefab Name | Amount.Empty to disable. https://valheim-modding.github.io/Jotunn/data/objects/item-list.html", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 27
		} }));
		CraftingRequirement2 = ((BaseUnityPlugin)this).Config.Bind<string>("CRAFTING UNDEAD", "CraftingRequirement2", "HardAntler|5", new ConfigDescription("Drop Prefab Name|Amount. Empty to disable. https://valheim-modding.github.io/Jotunn/data/objects/item-list.html", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 28
		} }));
		CraftingRequirement3 = ((BaseUnityPlugin)this).Config.Bind<string>("CRAFTING UNDEAD", "CraftingRequirement3", "AncientSeed|2", new ConfigDescription("Drop Prefab Name|Amount. Empty to disable. https://valheim-modding.github.io/Jotunn/data/objects/item-list.html", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 29
		} }));
		CraftMaxQuality = ((BaseUnityPlugin)this).Config.Bind<int>("CRAFTING UNDEAD", "CraftMaxLevel", 5, new ConfigDescription("Max level StaffUndead can be upgrade. Do not exceed crafting station maximum level.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 30
		} }));
		TeleUseInterval = ((BaseUnityPlugin)this).Config.Bind<float>("OTHER", "TeleUseInterval", 5f, new ConfigDescription("Interval before Teleport can be use again.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 31
		} }));
		CurseUseInterval = ((BaseUnityPlugin)this).Config.Bind<float>("OTHER", "SummonUseInterval", 5f, new ConfigDescription("Interval before Summoning can be use again.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 32
		} }));
		UnsummonUseInterval = ((BaseUnityPlugin)this).Config.Bind<float>("OTHER", "UnsummonUseInterval", 5f, new ConfigDescription("Interval before Unsummon can be use again.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 33
		} }));
		RightClickCost = ((BaseUnityPlugin)this).Config.Bind<float>("OTHER", "RightClickCost", 2f, new ConfigDescription("Durability cost everytime right click used.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 34
		} }));
		CurseEffectDuration = ((BaseUnityPlugin)this).Config.Bind<float>("OTHER", "CurseActiveDuration", 240f, new ConfigDescription("How long Curse status effect remain active.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 35
		} }));
		StatusEffectConfort = ((BaseUnityPlugin)this).Config.Bind<int>("OTHER", "StatusEffectConfort", 10, new ConfigDescription("Comfort stacked during Curse buff active. Set zero to turn off.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Order = 36
		} }));
		KeysHintEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("KEY CONFIG", "KeysHintEnabled", true, new ConfigDescription("If true, Shortcut key hint displayed when equipping Staff Undead.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = false,
			Order = 37
		} }));
		KeyTextEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("KEY CONFIG", "KeyTextEnabled", false, new ConfigDescription("If true, Skeleton hover name display button hint.", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = false,
			Order = 38
		} }));
		ConfigTeleport = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("KEY CONFIG", "KeyTeleport", new KeyboardShortcut((KeyCode)116, Array.Empty<KeyCode>()), new ConfigDescription("Teleport", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = false,
			Order = 39
		} }));
		ConfigSelection = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("KEY CONFIG", "KeyUIPanel", new KeyboardShortcut((KeyCode)101, Array.Empty<KeyCode>()), new ConfigDescription("UI Panel Selection", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = false,
			Order = 40
		} }));
		ConfigCurse = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("KEY CONFIG", "KeyCurse", new KeyboardShortcut((KeyCode)104, Array.Empty<KeyCode>()), new ConfigDescription("Cast Curse", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = false,
			Order = 41
		} }));
		ConfigUnsummon = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("KEY CONFIG", "KeyUnsummon", new KeyboardShortcut((KeyCode)107, Array.Empty<KeyCode>()), new ConfigDescription("Unsummon", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = false,
			Order = 42
		} }));
		CreateConfig();
		AddLocalizations();
		UndeadStatusEffects();
		PrefabManager.OnVanillaPrefabsAvailable += CreateStaffUndead;
		harmony.PatchAll();
		EnabledTweakVanilla.SettingChanged += delegate
		{
			UndeadItemConfigChanges(Undead.StaffSRaiser_Localize);
		};
		CostCastHealthVanilla.SettingChanged += delegate
		{
			UndeadItemConfigChanges(Undead.StaffSRaiser_Localize);
		};
		CostCastHealthPerVanilla.SettingChanged += delegate
		{
			UndeadItemConfigChanges(Undead.StaffSRaiser_Localize);
		};
		CostCastStaminaVanilla.SettingChanged += delegate
		{
			UndeadItemConfigChanges(Undead.StaffSRaiser_Localize);
		};
		CostCastEitrVanilla.SettingChanged += delegate
		{
			UndeadItemConfigChanges(Undead.StaffSRaiser_Localize);
		};
		DurabilityCastCostVanilla.SettingChanged += delegate
		{
			UndeadItemConfigChanges(Undead.StaffSRaiser_Localize);
		};
		EnabledTweakUndead.SettingChanged += delegate
		{
			UndeadItemConfigChanges(Undead.StaffUndead_Localize);
		};
		CostCastHealthUndead.SettingChanged += delegate
		{
			UndeadItemConfigChanges(Undead.StaffUndead_Localize);
		};
		CostCastHealthPerUndead.SettingChanged += delegate
		{
			UndeadItemConfigChanges(Undead.StaffUndead_Localize);
		};
		CostCastStaminaUndead.SettingChanged += delegate
		{
			UndeadItemConfigChanges(Undead.StaffUndead_Localize);
		};
		CostCastEitrUndead.SettingChanged += delegate
		{
			UndeadItemConfigChanges(Undead.StaffUndead_Localize);
		};
		DurabilityCastCostUndead.SettingChanged += delegate
		{
			UndeadItemConfigChanges(Undead.StaffUndead_Localize);
		};
		TeleUseInterval.SettingChanged += delegate
		{
			ConfigChanges();
		};
		CurseUseInterval.SettingChanged += delegate
		{
			ConfigChanges();
		};
		UnsummonUseInterval.SettingChanged += delegate
		{
			ConfigChanges();
		};
		SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr)
		{
			if (attr.InitialSynchronization)
			{
				CraftingRequirementEvent(initial: true);
				ConfigChanges();
				UpdatePrefabDB();
			}
			else
			{
				CraftingRequirementEvent(initial: false);
				ConfigChanges();
				UpdatePrefabDB();
				UndeadItemConfigChanges(Undead.StaffSRaiser_Localize);
				UndeadItemConfigChanges(Undead.StaffUndead_Localize);
			}
		};
	}

	private static void UpdateStaffSkele_Undead(ItemData item)
	{
		if (item == null || ((Object)item.m_dropPrefab).name != Undead.StaffSkeleton_Undead)
		{
			return;
		}
		if (EnabledTweakUndead.Value)
		{
			if (CostCastHealthPerUndead.Value > 0f)
			{
				if (item.m_shared.m_attack.m_attackHealthPercentage != CostCastHealthPerUndead.Value)
				{
					item.m_shared.m_attack.m_attackHealthPercentage = CostCastHealthPerUndead.Value;
					item.m_shared.m_attack.m_attackHealth = 0f;
				}
			}
			else if (item.m_shared.m_attack.m_attackHealth != CostCastHealthUndead.Value)
			{
				item.m_shared.m_attack.m_attackHealthPercentage = 0f;
				item.m_shared.m_attack.m_attackHealth = CostCastHealthUndead.Value;
			}
			if (item.m_shared.m_attack.m_attackStamina != CostCastStaminaUndead.Value)
			{
				item.m_shared.m_attack.m_attackStamina = CostCastStaminaUndead.Value;
			}
			if (item.m_shared.m_attack.m_attackEitr != CostCastEitrUndead.Value)
			{
				item.m_shared.m_attack.m_attackEitr = CostCastEitrUndead.Value;
			}
			if (item.m_shared.m_maxQuality != CraftMaxQuality.Value)
			{
				item.m_shared.m_maxQuality = CraftMaxQuality.Value;
			}
			if (item.m_shared.m_useDurabilityDrain != DurabilityCastCostUndead.Value)
			{
				item.m_shared.m_useDurabilityDrain = DurabilityCastCostUndead.Value;
			}
		}
		else
		{
			item.m_shared.m_attack.m_attackHealthPercentage = 1000f;
			item.m_shared.m_attack.m_attackHealth = 1000f;
			item.m_shared.m_attack.m_attackStamina = 1000f;
			item.m_shared.m_attack.m_attackEitr = 1000f;
			item.m_shared.m_maxQuality = 1;
			item.m_shared.m_useDurabilityDrain = 200f;
		}
	}

	private static void UpdateStaffSkele_Vanilla(ItemData item)
	{
		if (item == null || item.m_shared.m_name != Undead.StaffSRaiser_Localize)
		{
			return;
		}
		if (EnabledTweakVanilla.Value)
		{
			if (CostCastHealthPerVanilla.Value > 0f)
			{
				if (item.m_shared.m_attack.m_attackHealthPercentage != CostCastHealthPerVanilla.Value)
				{
					item.m_shared.m_attack.m_attackHealthPercentage = CostCastHealthPerVanilla.Value;
					item.m_shared.m_attack.m_attackHealth = 0f;
				}
			}
			else if (item.m_shared.m_attack.m_attackHealth != CostCastHealthVanilla.Value)
			{
				item.m_shared.m_attack.m_attackHealthPercentage = 0f;
				item.m_shared.m_attack.m_attackHealth = CostCastHealthVanilla.Value;
			}
			if (item.m_shared.m_attack.m_attackStamina != CostCastStaminaVanilla.Value)
			{
				item.m_shared.m_attack.m_attackStamina = CostCastStaminaVanilla.Value;
			}
			if (item.m_shared.m_attack.m_attackEitr != CostCastEitrVanilla.Value)
			{
				item.m_shared.m_attack.m_attackEitr = CostCastEitrVanilla.Value;
			}
			if (item.m_shared.m_maxQuality != CraftMaxQuality.Value)
			{
				item.m_shared.m_maxQuality = CraftMaxQuality.Value;
			}
			if (item.m_shared.m_useDurabilityDrain != DurabilityCastCostVanilla.Value)
			{
				item.m_shared.m_useDurabilityDrain = DurabilityCastCostVanilla.Value;
			}
		}
		else
		{
			item.m_shared.m_attack.m_attackHealthPercentage = 50f;
			item.m_shared.m_attack.m_attackHealth = 0f;
			item.m_shared.m_attack.m_attackStamina = 0f;
			item.m_shared.m_attack.m_attackEitr = 100f;
			item.m_shared.m_maxQuality = 3;
			item.m_shared.m_useDurabilityDrain = 1f;
		}
	}

	private static bool GetRequirement(string value, ref string[] require, ref int amount)
	{
		string text = value.Replace(" ", "");
		require = text.Split(new char[1] { '|' });
		if (require.Length < 2)
		{
			ELog("***** Vertical Bar \"|\" Error *****");
			return false;
		}
		amount = Convert.ToInt32(require[1].Replace(" ", ""));
		if (amount == 0)
		{
			ELog("***** " + require[0] + " amount result with error *****");
			return false;
		}
		return true;
	}

	private static void CraftingRequirementEvent(bool initial)
	{
		bool flag = false;
		if ((Object)(object)Undead.PrefabUndead != (Object)null)
		{
			ItemDrop component = Undead.PrefabUndead.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				Recipe recipe = ObjectDB.instance.GetRecipe(component.m_itemData);
				if ((Object)(object)recipe != (Object)null)
				{
					string workStationName = Undead.GetWorkStationName(CraftWorkStation.Value);
					if (workStationName == "")
					{
						ELog("***** CraftingStation name error *****");
						return;
					}
					CraftingStation val = null;
					GameObject prefab = ZNetScene.instance.GetPrefab(workStationName);
					if ((Object)(object)prefab != (Object)null)
					{
						val = prefab.GetComponent<CraftingStation>();
					}
					Requirement val2 = AddRequirement(CraftingRequirement1.Value);
					Requirement val3 = AddRequirement(CraftingRequirement2.Value);
					Requirement val4 = AddRequirement(CraftingRequirement3.Value);
					if ((Object)(object)val != (Object)null && (val2 != null || val3 != null || val4 != null))
					{
						List<Requirement> list = new List<Requirement>();
						if (val2 != null)
						{
							list.Add(val2);
						}
						if (val3 != null)
						{
							list.Add(val3);
						}
						if (val4 != null)
						{
							list.Add(val4);
						}
						recipe.m_resources = list.ToArray();
						recipe.m_craftingStation = val;
						recipe.m_repairStation = val;
						recipe.m_requireOnlyOneIngredient = false;
						flag = true;
					}
				}
			}
		}
		if (initial)
		{
			if (flag)
			{
				DLog("Server Initial Config sync received success.");
			}
			else
			{
				DLog("Server Initial Config sync received failed.");
			}
		}
		else if (flag)
		{
			DLog("Server Config sync changes received success.");
		}
		else
		{
			DLog("Server Config sync changes received failed.");
		}
		static Requirement AddRequirement(string config)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			if (config.Length > 3)
			{
				string[] require = new string[0];
				int amount = 0;
				if (!GetRequirement(config, ref require, ref amount))
				{
					ELog("***** Get requirement from config error *****");
					return null;
				}
				GameObject prefab2 = ZNetScene.instance.GetPrefab(require[0]);
				if ((Object)(object)prefab2 != (Object)null)
				{
					ItemDrop component2 = prefab2.GetComponent<ItemDrop>();
					if ((Object)(object)component2 != (Object)null)
					{
						return new Requirement
						{
							m_resItem = component2,
							m_amount = amount,
							m_extraAmountOnlyOneIngredient = 0,
							m_amountPerLevel = amount,
							m_recover = true
						};
					}
				}
			}
			else
			{
				DLog("***** Empty Config Requirement *****");
			}
			return null;
		}
	}

	private static void UpdatePrefabDB()
	{
		Undead.PrefabUndead = ZNetScene.instance.GetPrefab(Undead.StaffSkeleton_Undead);
		ItemDrop val = default(ItemDrop);
		if ((Object)(object)Undead.PrefabUndead != (Object)null && Undead.PrefabUndead.TryGetComponent<ItemDrop>(ref val))
		{
			UpdateStaffSkele_Undead(val.m_itemData);
			val.m_itemData.m_shared.m_value = 99;
			val.m_itemData.m_shared.m_weight = 5f;
		}
		if (EnabledTweakVanilla.Value)
		{
			Undead.PrefabVanilla = ZNetScene.instance.GetPrefab(Undead.StaffSkeleton_Raiser);
			ItemDrop val2 = default(ItemDrop);
			if ((Object)(object)Undead.PrefabVanilla != (Object)null && Undead.PrefabVanilla.TryGetComponent<ItemDrop>(ref val2))
			{
				UpdateStaffSkele_Vanilla(val2.m_itemData);
				val2.m_itemData.m_shared.m_value = 99;
				val2.m_itemData.m_shared.m_weight = 5f;
			}
		}
	}

	private static void ConfigChanges()
	{
		Buff_TeleUseInterval = TeleUseInterval.Value;
		Buff_CurseUseInterval = CurseUseInterval.Value;
		Buff_UnsummonUseInterval = UnsummonUseInterval.Value;
		if (Buff_TeleUseInterval < Undead.TeleportAnimationDelay + 0.1f)
		{
			Buff_TeleUseInterval = Undead.TeleportAnimationDelay + 0.1f;
		}
		if (Buff_CurseUseInterval < Undead.CurseAnimationDelay + 0.1f)
		{
			Buff_CurseUseInterval = Undead.CurseAnimationDelay + 0.1f;
		}
		if (Buff_UnsummonUseInterval < Undead.UnsummonAnimationDelay + 0.1f)
		{
			Buff_UnsummonUseInterval = Undead.UnsummonAnimationDelay + 0.1f;
		}
	}

	private static void UndeadItemConfigChanges(string m_name)
	{
		if (!((Object)(object)Player.m_localPlayer != (Object)null))
		{
			return;
		}
		Humanoid component = ((Component)Player.m_localPlayer).GetComponent<Humanoid>();
		if (!((Object)(object)component != (Object)null))
		{
			return;
		}
		Inventory inventory = component.GetInventory();
		if (inventory == null)
		{
			return;
		}
		List<ItemData> list = new List<ItemData>();
		inventory.GetAllItems(m_name, list);
		if (list.Count <= 0)
		{
			return;
		}
		foreach (ItemData item in list)
		{
			if (m_name == Undead.StaffUndead_Localize)
			{
				UpdateStaffSkele_Undead(item);
				Debug.Log((object)"============================= UpdateStaffSkele_Undead");
			}
			else
			{
				UpdateStaffSkele_Vanilla(item);
				Debug.Log((object)"============================= UpdateStaffSkele_Vanilla");
			}
		}
	}

	private static void DLog(string text, bool isError = false)
	{
		if (isError)
		{
			DeLog.LogError((object)text);
		}
		else
		{
			DeLog.LogMessage((object)text);
		}
	}

	private static void ELog(string text)
	{
		DeLog.LogError((object)text);
	}

	public void OnDestroy()
	{
		harmony.UnpatchSelf();
	}

	private void CreateConfig()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: 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_002b: Expected O, but got Unknown
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Expected O, but got Unknown
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Expected O, but got Unknown
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Expected O, but got Unknown
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Expected O, but got Unknown
		//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e1: Expected O, but got Unknown
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Expected O, but got Unknown
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Expected O, but got Unknown
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Expected O, but got Unknown
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Expected O, but got Unknown
		Shortcut_Teleport = new ButtonConfig
		{
			Name = "Teleport",
			HintToken = "$Hint_Teleoprt",
			ShortcutConfig = ConfigTeleport
		};
		InputManager.Instance.AddButton("GsiX.BetterDeathRaiser", Shortcut_Teleport);
		Shortcut_Selection = new ButtonConfig
		{
			Name = "Selection",
			HintToken = "$Hint_Selection",
			ShortcutConfig = ConfigSelection
		};
		InputManager.Instance.AddButton("GsiX.BetterDeathRaiser", Shortcut_Selection);
		Shortcut_Curse = new ButtonConfig
		{
			Name = "Cursed",
			HintToken = "$Hint_Curse",
			ShortcutConfig = ConfigCurse
		};
		InputManager.Instance.AddButton("GsiX.BetterDeathRaiser", Shortcut_Curse);
		Shortcut_Unsummon = new ButtonConfig
		{
			Name = "Unsummon",
			HintToken = "$Hint_Unsummon",
			ShortcutConfig = ConfigUnsummon
		};
		InputManager.Instance.AddButton("GsiX.BetterDeathRaiser", Shortcut_Unsummon);
		KeyboardShortcut value = ConfigTeleport.Value;
		string text = ((object)(KeyboardShortcut)(ref value)).ToString();
		text = "Mouse-2 + " + text;
		value = ConfigSelection.Value;
		string text2 = ((object)(KeyboardShortcut)(ref value)).ToString();
		text2 = "Mouse-2 + " + text2;
		value = ConfigCurse.Value;
		string text3 = ((object)(KeyboardShortcut)(ref value)).ToString();
		text3 = "Mouse-2 + " + text3;
		value = ConfigUnsummon.Value;
		string text4 = ((object)(KeyboardShortcut)(ref value)).ToString();
		text4 = "Mouse-2 + " + text4;
		KeyHintConfig val = new KeyHintConfig();
		val.Item = Undead.StaffSkeleton_Undead;
		if (KeysHintEnabled.Value)
		{
			val.ButtonConfigs = (ButtonConfig[])(object)new ButtonConfig[5]
			{
				new ButtonConfig
				{
					Name = "Mouse-1",
					HintToken = "$Hint_Primary"
				},
				new ButtonConfig
				{
					Name = text,
					HintToken = Shortcut_Teleport.HintToken
				},
				new ButtonConfig
				{
					Name = text2,
					HintToken = Shortcut_Selection.HintToken
				},
				new ButtonConfig
				{
					Name = text3,
					HintToken = Shortcut_Curse.HintToken
				},
				new ButtonConfig
				{
					Name = text4,
					HintToken = Shortcut_Unsummon.HintToken
				}
			};
		}
		KeyHintManager.Instance.AddKeyHint(val);
	}

	private void AddLocalizations()
	{
		CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
		string text = "English";
		localization.AddTranslation(ref text, new Dictionary<string, string>
		{
			{ "bdrstateffect_fffectname", "Cursed" },
			{ "item_StaffUndead", "Staff Undead" },
			{ "item_StaffUndead_desc", "Undead Necromancer Raiser" },
			{ "Hint_Primary", "Summon" },
			{ "Hint_Teleoprt", "Teleport" },
			{ "Hint_Selection", "Selection" },
			{ "Hint_Curse", "Curse" },
			{ "Hint_Unsummon", "Unsummon" }
		});
	}

	private void UndeadStatusEffects()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
		((Object)val).name = "BDRStatusEffect";
		((StatusEffect)val).m_name = "$bdrstateffect_fffectname";
		Texture2D val2 = LoadTexture(PluginNamespace, "BetterDeathRaiser_effect.png");
		((StatusEffect)val).m_icon = Sprite.Create(val2, new Rect(0f, 0f, (float)((Texture)val2).width, (float)((Texture)val2).height), Vector2.zero);
		val.m_jumpModifier = new Vector3(0.3f, 0.3f, 0.3f);
		val.m_speedModifier = 0.2f;
		val.m_jumpStaminaUseModifier = -0.7f;
		val.m_runStaminaDrainModifier = -0.7f;
		val.m_staminaRegenMultiplier = 3f;
		val.m_fallDamageModifier = -0.5f;
		val.m_addMaxCarryWeight = 550f;
		val.m_eitrRegenMultiplier = 11f;
		val.m_stealthModifier = 2f;
		Undead.UndeadSEEffect = new CustomStatusEffect((StatusEffect)(object)val, false);
		Undead.UndeadSEEffect.StatusEffect.m_ttl = CurseEffectDuration.Value;
		ItemManager.Instance.AddStatusEffect(Undead.UndeadSEEffect);
	}

	private void CreateStaffUndead()
	{
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Expected O, but got Unknown
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Expected O, but got Unknown
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Expected O, but got Unknown
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Expected O, but got Unknown
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Expected O, but got Unknown
		string workStationName = Undead.GetWorkStationName(CraftWorkStation.Value);
		if (workStationName == "")
		{
			PrefabManager.OnVanillaPrefabsAvailable -= CreateStaffUndead;
			ELog("***** CraftingStation name error *****");
			return;
		}
		Texture2D val = LoadTexture(PluginNamespace, "BetterDeathRaiser_icon.png");
		Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero);
		Texture2D styleTex = LoadTexture(PluginNamespace, "BetterDeathRaiser_texture.png");
		ItemConfig val3 = new ItemConfig();
		val3.Name = Undead.StaffUndead_Localize;
		val3.Description = "$item_StaffUndead_desc";
		val3.Icons = (Sprite[])(object)new Sprite[1] { val2 };
		val3.StyleTex = styleTex;
		val3.Amount = 1;
		val3.MinStationLevel = 1;
		val3.QualityResultAmountMultiplier = 2;
		val3.CraftingStation = workStationName;
		val3.RepairStation = workStationName;
		UndeadItemConfig = val3;
		string[] require = new string[0];
		int amount = 0;
		if (CraftingRequirement1.Value.Length > 3 && GetRequirement(CraftingRequirement1.Value, ref require, ref amount))
		{
			UndeadItemConfig.AddRequirement(new RequirementConfig(require[0], amount, 1, true));
		}
		if (CraftingRequirement2.Value.Length > 3 && GetRequirement(CraftingRequirement2.Value, ref require, ref amount))
		{
			UndeadItemConfig.AddRequirement(new RequirementConfig(require[0], amount, 1, true));
		}
		if (CraftingRequirement3.Value.Length > 3 && GetRequirement(CraftingRequirement3.Value, ref require, ref amount))
		{
			UndeadItemConfig.AddRequirement(new RequirementConfig(require[0], amount, 1, true));
		}
		CustomItem val4 = new CustomItem(Undead.StaffSkeleton_Undead, Undead.StaffSkeleton_Raiser, UndeadItemConfig);
		ItemManager.Instance.AddItem(val4);
		PrefabManager.OnVanillaPrefabsAvailable -= CreateStaffUndead;
	}

	private static Texture2D LoadTexture(string pluginNameSpace, string fileName)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		//IL_0059: Expected O, but got Unknown
		Texture2D val;
		if (cachedTextures.ContainsKey(fileName))
		{
			val = cachedTextures[fileName];
		}
		else
		{
			Stream? manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(pluginNameSpace + ".Package.Assets." + fileName);
			byte[] array = new byte[manifestResourceStream.Length];
			manifestResourceStream.Read(array, 0, array.Length);
			Texture2D val2 = new Texture2D(0, 0);
			ImageConversion.LoadImage(val2, array);
			val = val2;
			cachedTextures.Add(fileName, val);
		}
		return val;
	}

	private static void UndeadTeleport()
	{
		Player localPlayer = Player.m_localPlayer;
		if (!Undead.IsHoldingUndead(((Component)localPlayer).gameObject, EnabledTweakVanilla.Value))
		{
			return;
		}
		if (Time.time - Undead.TeleUseStart < Buff_TeleUseInterval)
		{
			Undead.PrintCenterMessage(((Component)localPlayer).gameObject, "Undead Teleport Cooldown");
			return;
		}
		Humanoid component = ((Component)localPlayer).GetComponent<Humanoid>();
		if (!((Object)(object)component != (Object)null))
		{
			return;
		}
		ItemData leftItem = component.m_leftItem;
		ProcessTimeStart(component, leftItem, ref Undead.TeleUseStart, ref Undead.TeleDelayStart, ref Undead.TeleInProgress);
		PlayCharacterAnimation(component, leftItem);
		MonsterAI val = default(MonsterAI);
		foreach (Character allCharacter in Character.GetAllCharacters())
		{
			if (!allCharacter.IsDead() && ((Component)allCharacter).TryGetComponent<MonsterAI>(ref val) && (Object)(object)val.GetFollowTarget() == (Object)(object)((Component)localPlayer).gameObject)
			{
				if (!allCharacter.IsOwner())
				{
					allCharacter.m_nview.ClaimOwnership();
				}
				if (Undead.AnimeLoadedSkull)
				{
					Undead.PlayCastAnimation(((Component)allCharacter).gameObject, Undead.SkullItems);
					UpdateWeaponDurability(leftItem);
				}
			}
		}
	}

	private static void UndeadCurse()
	{
		Player localPlayer = Player.m_localPlayer;
		if (!Undead.IsHoldingUndead(((Component)localPlayer).gameObject, EnabledTweakVanilla.Value))
		{
			return;
		}
		if (Time.time - Undead.CurseUseStart < Buff_CurseUseInterval)
		{
			Undead.PrintCenterMessage(((Component)localPlayer).gameObject, "Undead Curse Cooldown");
			return;
		}
		Humanoid component = ((Component)localPlayer).GetComponent<Humanoid>();
		if ((Object)(object)component != (Object)null)
		{
			ItemData leftItem = component.m_leftItem;
			ProcessTimeStart(component, leftItem, ref Undead.CurseUseStart, ref Undead.CurseDelayStart, ref Undead.CurseInProgress);
			PlayCharacterAnimation(component, leftItem);
			if (Undead.AnimeLoadedOrbs)
			{
				Undead.PlayCastAnimation(((Component)component).gameObject, Undead.OrbsItems);
				UpdateWeaponDurability(leftItem);
			}
		}
	}

	private static void UndeadUnsummon()
	{
		Player localPlayer = Player.m_localPlayer;
		if (!Undead.IsHoldingUndead(((Component)localPlayer).gameObject, EnabledTweakVanilla.Value))
		{
			return;
		}
		if (Time.time - Undead.UnsummonUseStart < Buff_UnsummonUseInterval)
		{
			Undead.PrintCenterMessage(((Component)localPlayer).gameObject, "Undead Unsummon Cooldown");
			return;
		}
		Humanoid component = ((Component)localPlayer).GetComponent<Humanoid>();
		if ((Object)(object)component != (Object)null)
		{
			ItemData leftItem = component.m_leftItem;
			ProcessTimeStart(component, leftItem, ref Undead.UnsummonUseStart, ref Undead.UnsummonDelayStart, ref Undead.UnsummonProgress);
			PlayCharacterAnimation(component, leftItem);
			UpdateWeaponDurability(leftItem);
		}
	}

	private static void ProcessTimeStart(Humanoid human, ItemData leftitem, ref float usestart, ref float delaystart, ref bool progress)
	{
		usestart = Time.time;
		delaystart = Time.time;
		leftitem.m_lastAttackTime = Time.time;
		leftitem.m_durability -= RightClickCost.Value;
		human.m_lastCombatTimer = 0f;
		progress = true;
		Undead.PlayerCanMove = false;
	}

	private static void PlayCharacterAnimation(Humanoid human, ItemData leftitem)
	{
		if (Undead.AnimeLoadedSkull)
		{
			Undead.CastIsInAnimation = true;
			human.UnequipItem(leftitem, false);
			if (human.EquipItem(leftitem, false))
			{
				((Character)human).m_zanim.SetTrigger(Undead.SkullItems.m_itemData.m_shared.m_attack.m_attackAnimation);
				Undead.PlayCastAnimation(((Component)human).gameObject, Undead.SkullItems);
			}
			Undead.CastIsInAnimation = false;
		}
	}

	private static void UpdateWeaponDurability(ItemData weapon)
	{
		weapon.m_durability -= weapon.m_shared.m_useDurabilityDrain;
		if (weapon.m_durability < 0f)
		{
			weapon.m_durability = 0f;
		}
	}

	private static void TogglePanel()
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c5: Expected O, but got Unknown
		//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Expected O, but got Unknown
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Expected O, but got Unknown
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Expected O, but got Unknown
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Expected O, but got Unknown
		//IL_0283: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Expected O, but got Unknown
		if (!Object.op_Implicit((Object)(object)SleectPanel))
		{
			if (GUIManager.Instance == null)
			{
				DLog("GUIManager instance is null", isError: true);
				return;
			}
			if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront))
			{
				DLog("GUIManager CustomGUI is null", isError: true);
				return;
			}
			SleectPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 850f, 400f, false);
			SleectPanel.SetActive(false);
			SleectPanel.AddComponent<DragWindowCntrl>();
			GUIManager.Instance.CreateText("UNDEAD SELECTION", SleectPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(80f, -60f), GUIManager.Instance.AveriaSerifBold, 30, GUIManager.Instance.ValheimOrange, true, Color.black, 450f, 40f, false);
			GUIManager.Instance.CreateText("UNDEAD CAST", SleectPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(130f, -260f), GUIManager.Instance.AveriaSerifBold, 30, GUIManager.Instance.ValheimOrange, true, Color.black, 450f, 40f, false);
			float posX2 = -250f;
			float posX3 = 0f;
			float posX4 = 250f;
			float posY2 = 80f;
			float posY3 = -120f;
			((UnityEvent)CreateButton("UNDEAD ARCHER", posX2, posY2).GetComponent<Button>().onClick).AddListener(new UnityAction(SetType_Archer));
			((UnityEvent)CreateButton("UNDEAD WARRIOR", posX3, posY2).GetComponent<Button>().onClick).AddListener(new UnityAction(SetType_Warrior));
			((UnityEvent)CreateButton("UNDEAD BRUTE", posX4, posY2).GetComponent<Button>().onClick).AddListener(new UnityAction(SetType_Brute));
			((UnityEvent)CreateButton("UNDEAD CURSE", posX2, posY3).GetComponent<Button>().onClick).AddListener(new UnityAction(SetType_Curse));
			((UnityEvent)CreateButton("UNDEAD TELEPORT", posX3, posY3).GetComponent<Button>().onClick).AddListener(new UnityAction(SetType_Teleport));
			((UnityEvent)CreateButton("UNDEAD UNSUMMON", posX4, posY3).GetComponent<Button>().onClick).AddListener(new UnityAction(SetType_Unsummon));
		}
		bool flag = !SleectPanel.activeSelf;
		SleectPanel.SetActive(flag);
		GUIManager.BlockInput(flag);
		static GameObject CreateButton(string name, float posX, float posY)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = GUIManager.Instance.CreateButton(name, SleectPanel.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(posX, posY), 200f, 60f);
			obj.SetActive(true);
			return obj;
		}
		static void SetType_Archer()
		{
			Undead.UndeadWeapon = Undeads.Weapon.Bow;
			Undead.PrintCenterMessage(null, Undead.UndeadText[(int)Undead.UndeadWeapon]);
			TogglePanel();
		}
		static void SetType_Brute()
		{
			Undead.UndeadWeapon = Undeads.Weapon.Mace;
			Undead.PrintCenterMessage(null, Undead.UndeadText[(int)Undead.UndeadWeapon]);
			TogglePanel();
		}
		static void SetType_Curse()
		{
			UndeadCurse();
			TogglePanel();
		}
		static void SetType_Teleport()
		{
			UndeadTeleport();
			TogglePanel();
		}
		static void SetType_Unsummon()
		{
			UndeadUnsummon();
			TogglePanel();
		}
		static void SetType_Warrior()
		{
			Undead.UndeadWeapon = Undeads.Weapon.Sword;
			Undead.PrintCenterMessage(null, Undead.UndeadText[(int)Undead.UndeadWeapon]);
			TogglePanel();
		}
	}
}
internal class Undeads
{
	public enum Gears
	{
		Cape,
		Helmet,
		Chest,
		Legs,
		Sword,
		Shield,
		Bow,
		Arrow,
		Mace,
		len
	}

	public enum Weapon
	{
		None,
		Bow,
		Sword,
		Mace
	}

	public readonly string ObjectName_Player = "Player(Clone)";

	public readonly string ObjectName_Vanilla = "Skeleton_Friendly(Clone)";

	public GameObject[] UndeadEquipmentEnum = (GameObject[])(object)new GameObject[9];

	public readonly string[] UndeadEquipmentName = new string[9] { "CapeLox", "HelmetCarapace", "ArmorCarapaceChest", "ArmorCarapaceLegs", "skeleton_sword_hildir", "ShieldCarapace", "BowDraugrFang", "ArrowCarapace", "skeleton_mace" };

	public Weapon UndeadWeapon = Weapon.Bow;

	public Weapon UndeadSpawnWeapon = Weapon.Bow;

	public readonly string[] UndeadText = new string[4] { "Undead None", "Undead Archer", "Undead Warrior", "Undead Brute" };

	public readonly string[] WorkbenchConfig = new string[6] { "workbench", "forge", "stonecutter", "artisanstation", "blackforge", "magetable" };

	public readonly string[] WorkbenchPiece = new string[6] { "piece_workbench", "forge", "piece_stonecutter", "piece_artisanstation", "blackforge", "piece_magetable" };

	public ItemDrop OrbsItems;

	public ItemDrop SkullItems;

	public ItemDrop CachedBowAi;

	public GameObject UndeadSpawnOwner;

	public GameObject PrefabUndead;

	public GameObject PrefabVanilla;

	public CustomStatusEffect UndeadSEEffect;

	public bool AnimeLoadedOrbs;

	public bool AnimeLoadedSkull;

	public readonly string StaffSkeleton_Undead = "StaffUndead";

	public readonly string StaffUndead_Localize = "$item_StaffUndead";

	public readonly string StaffSkeleton_Raiser = "StaffSkeleton";

	public readonly string StaffSRaiser_Localize = "$item_staffskeleton";

	public readonly string StaffSkeleton_Shield = "StaffShield";

	public readonly int UndeadMaxSummon = 8;

	public float MainDelayStart = -1f;

	public Attack MainAttack;

	public bool TeleInProgress;

	public float TeleDelayStart = Time.time;

	public float TeleUseStart = Time.time;

	public readonly float TeleportAnimationDelay = 1f;

	public readonly float WeaponSelectionDelay = 0.2f;

	public float WeaponSelectionStart = Time.time;

	public float PlayerHealInterval = Time.time;

	public bool CurseInProgress;

	public float CurseDelayStart = Time.time;

	public float CurseUseStart = Time.time;

	public readonly float CurseAnimationDelay = 2f;

	public bool UnsummonProgress;

	public float UnsummonDelayStart = Time.time;

	public float UnsummonUseStart = Time.time;

	public readonly float UnsummonAnimationDelay = 2f;

	public bool CastIsInAnimation;

	public bool PlayerCanMove = true;

	public string GetWorkStationName(string configVal)
	{
		for (int i = 0; i < WorkbenchConfig.Length; i++)
		{
			if (WorkbenchConfig[i] == configVal)
			{
				return WorkbenchPiece[i];
			}
		}
		return "";
	}

	public bool IsTamedUndead(Tameable tameable)
	{
		if (((Object)tameable).name == ObjectName_Vanilla)
		{
			return GetUndeadWeaponType(tameable) != Weapon.None;
		}
		return false;
	}

	public bool GetAnimationProp(GameObject type, out ItemDrop item)
	{
		if ((Object)(object)type == (Object)null)
		{
			Print("GetAnimationProp", "obj null");
			item = null;
			return false;
		}
		item = type.GetComponent<ItemDrop>();
		if ((Object)(object)item == (Object)null)
		{
			Print("GetAnimationProp", "item null");
			item = null;
			return false;
		}
		return true;
	}

	public void PlayCastAnimation(GameObject obj, ItemDrop item)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)obj != (Object)null)
		{
			Character component = obj.GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				item.m_itemData.m_shared.m_startEffect.Create(((Component)component).transform.position, ((Component)component).transform.rotation, ((Component)component).transform, 1f, -1);
				item.m_itemData.m_shared.m_attack.m_startEffect.Create(((Component)component).transform.position, ((Component)component).transform.rotation, ((Component)component).transform, 1f, -1);
				component.AddNoise(0f);
			}
		}
	}

	public bool IsHoldingUndead(GameObject player, bool allowvanilla)
	{
		Humanoid component = player.GetComponent<Humanoid>();
		if ((Object)(object)component == (Object)null || component.m_leftItem == null)
		{
			return false;
		}
		if (!allowvanilla || !((Object)component.m_leftItem.m_dropPrefab).name.Contains(StaffSkeleton_Raiser))
		{
			return ((Object)component.m_leftItem.m_dropPrefab).name.Contains(StaffSkeleton_Undead);
		}
		return true;
	}

	public void CharacterHeal(Character character, float amount)
	{
		if ((Object)(object)character != (Object)null)
		{
			if (character.GetHealth() + amount < character.GetMaxHealth())
			{
				character.Heal(amount, true);
			}
			else if (character.GetHealth() < character.GetMaxHealth())
			{
				character.SetHealth(character.GetMaxHealth());
			}
		}
	}

	public bool UndeadUpdateInterval(Tameable tameable, bool set = false)
	{
		if (set)
		{
			tameable.m_tamingTime = Time.time;
		}
		else if (Time.time - tameable.m_tamingTime > 1f)
		{
			tameable.m_tamingTime = Time.time;
			return true;
		}
		return false;
	}

	public bool HaveStatusEffect(Character character, string effectname)
	{
		if ((Object)(object)character == (Object)null)
		{
			return false;
		}
		return character.GetSEMan().HaveStatusEffect(effectname);
	}

	public Weapon GetUndeadWeaponType(Tameable tameable)
	{
		string text = tameable.GetText();
		if (text.Contains(UndeadText[1]))
		{
			return Weapon.Bow;
		}
		if (text.Contains(UndeadText[2]))
		{
			return Weapon.Sword;
		}
		if (text.Contains(UndeadText[3]))
		{
			return Weapon.Mace;
		}
		return Weapon.None;
	}

	public void GiveDefaultItem(Humanoid human, GameObject prefab)
	{
		ItemData val = human.PickupPrefab(prefab, 0, false);
		if (val != null)
		{
			if ((Object)(object)CachedBowAi != (Object)null && ((Object)prefab).name == UndeadEquipmentName[6])
			{
				val.m_shared = CachedBowAi.m_itemData.m_shared;
				val.m_shared.m_aiAttackInterval = 0.5f;
				val.m_shared.m_damages.m_poison = 10f;
				val.m_shared.m_damages.m_lightning = 2f;
				val.m_shared.m_damages.m_frost = 2f;
			}
			if (!val.IsWeapon())
			{
				human.EquipItem(val, false);
			}
		}
	}

	public void PrintCenterMessage(GameObject obj, string text)
	{
		GameObject val = obj;
		if ((Object)(object)val == (Object)null)
		{
			val = ((Component)Player.m_localPlayer).gameObject;
		}
		Humanoid component = val.GetComponent<Humanoid>();
		if (component != null)
		{
			((Character)component).Message((MessageType)2, Localization.instance.Localize(text), 0, (Sprite)null);
		}
	}

	public void Print(string args1, string args2)
	{
	}
}