Decompiled source of ValheimResetNow v0.1.0

ValheimResetNow.dll

Decompiled 14 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn.Managers;
using Jotunn.Utils;
using StarLevelSystem;
using UnityEngine;
using UnityEngine.SceneManagement;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.NamingConventions;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("ValheimResetNow")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+eca2bf1e6311d6770c80c7ac3ab7301fa0d189b3")]
[assembly: AssemblyProduct("ValheimResetNow")]
[assembly: AssemblyTitle("ValheimResetNow")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace StarLevelSystem
{
	[PublicAPI]
	public static class API
	{
		private static readonly Type APIReciever;

		private static readonly MethodInfo UpdateCreatureLevel;

		private static readonly MethodInfo UpdateCreatureColorization;

		private static readonly MethodInfo GetBaseAttributeValue;

		private static readonly MethodInfo UpdateCreatureBaseAttributes;

		private static readonly MethodInfo GetAllBaseAttributeValues;

		private static readonly MethodInfo SetAllBaseAttributeValues;

		private static readonly MethodInfo GetPerLevelAttributeValue;

		private static readonly MethodInfo UpdateCreaturePerLevelAttributes;

		private static readonly MethodInfo GetAllPerLevelAttributeValues;

		private static readonly MethodInfo SetAllPerLevelAttributeValues;

		private static readonly MethodInfo GetCreatureDamageRecievedModifier;

		private static readonly MethodInfo UpdateCreatureDamageRecievedModifier;

		private static readonly MethodInfo GetAllDamageRecievedModifiers;

		private static readonly MethodInfo SetAllDamageRecievedModifiers;

		private static readonly MethodInfo GetCreatureDamageBonus;

		private static readonly MethodInfo UpdateCreatureDamageBonus;

		private static readonly MethodInfo GetAllDamageBonus;

		private static readonly MethodInfo SetAllDamageBonus;

		private static readonly MethodInfo ApplyUpdatesToCreature;

		private static readonly MethodInfo GetPossibleModifiersForType;

		private static readonly MethodInfo GetAllModifiersForCreature;

		private static readonly MethodInfo AddModifierToCreature;

		private static readonly MethodInfo AddNewModifierToSLS;

		private static readonly MethodInfo RegisterLocationResetTargetMethod;

		private static readonly MethodInfo UnregisterLocationResetTargetMethod;

		private static readonly MethodInfo GetRegisteredLocationResetTargetsMethod;

		private static readonly MethodInfo GetLocationResetTargetInfoMethod;

		private static readonly MethodInfo IsLocationResetReadyMethod;

		private static readonly MethodInfo GetLocationResetStatusMethod;

		private static readonly MethodInfo IsKnownResetTargetNameMethod;

		private static readonly MethodInfo GetLocationLastResetMethod;

		private static readonly MethodInfo GetSecondsUntilLocationResetMethod;

		private static readonly MethodInfo GetLocationResetInfoMethod;

		private static readonly MethodInfo GetChunkResetInfoMethod;

		private static readonly MethodInfo ResetNamedLocationMethod;

		private static readonly MethodInfo ResetLocationsInRadiusMethod;

		public static bool IsAvailable => APIReciever != null;

		public static bool SupportsLocationReset => ResetNamedLocationMethod != null;

		static API()
		{
			APIReciever = Type.GetType("StarLevelSystem.modules.APIReciever, StarLevelSystem");
			if (!(APIReciever == null))
			{
				UpdateCreatureLevel = APIReciever.GetMethod("UpdateCreatureLevel", BindingFlags.Static | BindingFlags.Public);
				UpdateCreatureColorization = APIReciever.GetMethod("UpdateCreatureColorization", BindingFlags.Static | BindingFlags.Public);
				GetBaseAttributeValue = APIReciever.GetMethod("GetBaseAttributeValue", BindingFlags.Static | BindingFlags.Public);
				UpdateCreatureBaseAttributes = APIReciever.GetMethod("UpdateCreatureBaseAttributes", BindingFlags.Static | BindingFlags.Public);
				GetAllBaseAttributeValues = APIReciever.GetMethod("GetAllBaseAttributes", BindingFlags.Static | BindingFlags.Public);
				SetAllBaseAttributeValues = APIReciever.GetMethod("SetAllBaseAttributes", BindingFlags.Static | BindingFlags.Public);
				GetPerLevelAttributeValue = APIReciever.GetMethod("GetPerLevelAttributeValue", BindingFlags.Static | BindingFlags.Public);
				UpdateCreaturePerLevelAttributes = APIReciever.GetMethod("UpdateCreaturePerLevelAttributes", BindingFlags.Static | BindingFlags.Public);
				GetAllPerLevelAttributeValues = APIReciever.GetMethod("GetAllPerLevelAttributes", BindingFlags.Static | BindingFlags.Public);
				SetAllPerLevelAttributeValues = APIReciever.GetMethod("SetAllPerLevelAttributes", BindingFlags.Static | BindingFlags.Public);
				GetCreatureDamageRecievedModifier = APIReciever.GetMethod("GetCreatureDamageRecievedModifier", BindingFlags.Static | BindingFlags.Public);
				UpdateCreatureDamageRecievedModifier = APIReciever.GetMethod("UpdateCreatureDamageRecievedModifier", BindingFlags.Static | BindingFlags.Public);
				GetAllDamageRecievedModifiers = APIReciever.GetMethod("GetAllDamageRecievedModifiers", BindingFlags.Static | BindingFlags.Public);
				SetAllDamageRecievedModifiers = APIReciever.GetMethod("SetAllDamageRecievedModifiers", BindingFlags.Static | BindingFlags.Public);
				GetCreatureDamageBonus = APIReciever.GetMethod("GetCreatureDamageBonus", BindingFlags.Static | BindingFlags.Public);
				UpdateCreatureDamageBonus = APIReciever.GetMethod("UpdateCreatureDamageBonus", BindingFlags.Static | BindingFlags.Public);
				GetAllDamageBonus = APIReciever.GetMethod("GetAllDamageBonus", BindingFlags.Static | BindingFlags.Public);
				SetAllDamageBonus = APIReciever.GetMethod("SetAllDamageBonus", BindingFlags.Static | BindingFlags.Public);
				ApplyUpdatesToCreature = APIReciever.GetMethod("ApplyUpdatesToCreature", BindingFlags.Static | BindingFlags.Public);
				GetPossibleModifiersForType = APIReciever.GetMethod("GetPossibleModifiersForType", BindingFlags.Static | BindingFlags.Public);
				GetAllModifiersForCreature = APIReciever.GetMethod("GetAllModifiersForCreature", BindingFlags.Static | BindingFlags.Public);
				AddModifierToCreature = APIReciever.GetMethod("AddModifierToCreature", BindingFlags.Static | BindingFlags.Public);
				AddNewModifierToSLS = APIReciever.GetMethod("AddNewModifierToSLS", BindingFlags.Static | BindingFlags.Public);
				RegisterLocationResetTargetMethod = APIReciever.GetMethod("RegisterLocationResetTarget", BindingFlags.Static | BindingFlags.Public);
				UnregisterLocationResetTargetMethod = APIReciever.GetMethod("UnregisterLocationResetTarget", BindingFlags.Static | BindingFlags.Public);
				GetRegisteredLocationResetTargetsMethod = APIReciever.GetMethod("GetRegisteredLocationResetTargets", BindingFlags.Static | BindingFlags.Public);
				GetLocationResetTargetInfoMethod = APIReciever.GetMethod("GetLocationResetTargetInfo", BindingFlags.Static | BindingFlags.Public);
				IsLocationResetReadyMethod = APIReciever.GetMethod("IsLocationResetReady", BindingFlags.Static | BindingFlags.Public);
				GetLocationResetStatusMethod = APIReciever.GetMethod("GetLocationResetStatus", BindingFlags.Static | BindingFlags.Public);
				IsKnownResetTargetNameMethod = APIReciever.GetMethod("IsKnownResetTargetName", BindingFlags.Static | BindingFlags.Public);
				GetLocationLastResetMethod = APIReciever.GetMethod("GetLocationLastReset", BindingFlags.Static | BindingFlags.Public);
				GetSecondsUntilLocationResetMethod = APIReciever.GetMethod("GetSecondsUntilLocationReset", BindingFlags.Static | BindingFlags.Public);
				GetLocationResetInfoMethod = APIReciever.GetMethod("GetLocationResetInfo", BindingFlags.Static | BindingFlags.Public);
				GetChunkResetInfoMethod = APIReciever.GetMethod("GetChunkResetInfo", BindingFlags.Static | BindingFlags.Public);
				ResetNamedLocationMethod = APIReciever.GetMethod("ResetNamedLocation", BindingFlags.Static | BindingFlags.Public);
				ResetLocationsInRadiusMethod = APIReciever.GetMethod("ResetLocationsInRadius", BindingFlags.Static | BindingFlags.Public);
			}
		}

		private static object Call(MethodInfo method, object fallback, params object[] args)
		{
			if (method == null)
			{
				return fallback;
			}
			return method.Invoke(null, args);
		}

		public static bool SetCreatureLevel(Character creatureId, int newLevel)
		{
			return (bool)UpdateCreatureLevel.Invoke(null, new object[2] { creatureId, newLevel });
		}

		public static bool SetCreatureColorization(Character creatureId, float value, float hue, float sat, bool emission = false)
		{
			return (bool)UpdateCreatureColorization.Invoke(null, new object[5] { creatureId, value, hue, sat, emission });
		}

		public static float GetCreatureBaseAttribute(Character creatureId, int attribute)
		{
			return (float)GetBaseAttributeValue.Invoke(null, new object[2] { creatureId, attribute });
		}

		public static bool SetCreatureBaseAttribute(Character creatureId, int attribute, float value)
		{
			return (bool)UpdateCreatureBaseAttributes.Invoke(null, new object[3] { creatureId, attribute, value });
		}

		public static Dictionary<int, float> GetAllCreatureBaseAttributes(Character creatureId)
		{
			return (Dictionary<int, float>)GetAllBaseAttributeValues.Invoke(null, new object[1] { creatureId });
		}

		public static bool SetAllCreatureBaseAttributes(Character creatureId, Dictionary<int, float> attributes)
		{
			return (bool)SetAllBaseAttributeValues.Invoke(null, new object[2] { creatureId, attributes });
		}

		public static float GetCreaturePerLevelAttribute(Character creatureId, int attribute)
		{
			return (float)GetPerLevelAttributeValue.Invoke(null, new object[2] { creatureId, attribute });
		}

		public static bool SetCreaturePerLevelAttribute(Character creatureId, int attribute, float value)
		{
			return (bool)UpdateCreaturePerLevelAttributes.Invoke(null, new object[3] { creatureId, attribute, value });
		}

		public static Dictionary<int, float> GetAllCreaturePerLevelAttributes(Character creatureId)
		{
			return (Dictionary<int, float>)GetAllPerLevelAttributeValues.Invoke(null, new object[1] { creatureId });
		}

		public static bool SetAllCreaturePerLevelAttributes(Character creatureId, Dictionary<int, float> attributes)
		{
			return (bool)SetAllPerLevelAttributeValues.Invoke(null, new object[2] { creatureId, attributes });
		}

		public static float GetCreatureDamageReceivedModifier(Character creatureId, int damageType)
		{
			return (float)GetCreatureDamageRecievedModifier.Invoke(null, new object[2] { creatureId, damageType });
		}

		public static bool SetCreatureDamageReceivedModifier(Character creatureId, int damageType, float value)
		{
			return (bool)UpdateCreatureDamageRecievedModifier.Invoke(null, new object[3] { creatureId, damageType, value });
		}

		public static Dictionary<int, float> GetAllCreatureDamageReceivedModifiers(Character creatureId)
		{
			return (Dictionary<int, float>)GetAllDamageRecievedModifiers.Invoke(null, new object[1] { creatureId });
		}

		public static bool SetAllCreatureDamageReceivedModifiers(Character creatureId, Dictionary<int, float> attributes)
		{
			return (bool)SetAllDamageRecievedModifiers.Invoke(null, new object[2] { creatureId, attributes });
		}

		public static float GetCreatureFlatDamageBonus(Character creatureId, int damageType)
		{
			return (float)GetCreatureDamageBonus.Invoke(null, new object[2] { creatureId, damageType });
		}

		public static bool SetCreatureFlatDamageBonus(Character creatureId, int damageType, float value)
		{
			return (bool)UpdateCreatureDamageBonus.Invoke(null, new object[3] { creatureId, damageType, value });
		}

		public static Dictionary<int, float> GetAllCreatureFlatDamageBonuses(Character creatureId)
		{
			return (Dictionary<int, float>)GetAllDamageBonus.Invoke(null, new object[1] { creatureId });
		}

		public static bool SetAllCreatureFlatDamageBonuses(Character creatureId, Dictionary<int, float> attributes)
		{
			return (bool)SetAllDamageBonus.Invoke(null, new object[2] { creatureId, attributes });
		}

		public static bool ApplyCreatureUpdates(Character creatureId)
		{
			return (bool)ApplyUpdatesToCreature.Invoke(null, new object[1] { creatureId });
		}

		public static List<string> GetPossibleModifiers(int modType = 0)
		{
			return (List<string>)GetPossibleModifiersForType.Invoke(null, new object[1] { modType });
		}

		public static Dictionary<string, int> GetCreaturesModifiers(Character creatureId)
		{
			return (Dictionary<string, int>)GetAllModifiersForCreature.Invoke(null, new object[1] { creatureId });
		}

		public static bool AddModifierToTargetCreature(Character creatureId, string modifierName, int modifierType, bool update = true)
		{
			return (bool)AddModifierToCreature.Invoke(null, new object[4] { creatureId, modifierName, modifierType, update });
		}

		public static bool AddNewModifier(int modifierID, string modifier_name, Delegate setupMethod = null, float selectionWeight = 10f, float basepower = 0f, float perlevelpower = 0f, Dictionary<Biome, List<string>> biomeConfig = null, int namingStyle = 2, string name_suffixes = null, string name_prefixes = null, int visualStyle = 0, Sprite starIcon = null, GameObject visualEffect = null, List<string> allowed_creatures = null, List<string> unallowed_creatures = null, List<Biome> allowed_biomes = null)
		{
			return (bool)AddNewModifierToSLS.Invoke(null, new object[16]
			{
				modifierID, modifier_name, setupMethod, selectionWeight, basepower, perlevelpower, biomeConfig, namingStyle, name_suffixes, name_prefixes,
				visualStyle, starIcon, visualEffect, allowed_creatures, unallowed_creatures, allowed_biomes
			});
		}

		public static bool RegisterLocationReset(string prefabName, string sourceId, float resetHours = 0f, string resetSchedule = null, bool enabled = true, int mode = 0, bool resetTerrain = false, float terrainRadius = 0f, float extraTerrainRadius = 0f, bool resetInterior = true, float minDistance = 0f, float maxDistance = 0f, Action<bool> onResult = null)
		{
			return (bool)Call(RegisterLocationResetTargetMethod, false, prefabName, sourceId, resetHours, resetSchedule, mode, resetTerrain, terrainRadius, extraTerrainRadius, resetInterior, minDistance, maxDistance, enabled, onResult);
		}

		public static bool UnregisterLocationReset(string prefabName, string sourceId, Action<bool> onResult = null)
		{
			return (bool)Call(UnregisterLocationResetTargetMethod, false, prefabName, sourceId, onResult);
		}

		public static bool GetRegisteredLocationResets(string sourceId, Action<List<string>> onResult)
		{
			return (bool)Call(GetRegisteredLocationResetTargetsMethod, false, sourceId, onResult);
		}

		public static bool GetLocationResetTargetInfo(string prefabName, Action<Dictionary<string, object>> onResult)
		{
			return (bool)Call(GetLocationResetTargetInfoMethod, false, prefabName, onResult);
		}

		public static bool IsLocationResetReady(Action<bool> onResult)
		{
			return (bool)Call(IsLocationResetReadyMethod, false, onResult);
		}

		public static bool GetLocationResetStatus(Action<Dictionary<string, object>> onResult)
		{
			return (bool)Call(GetLocationResetStatusMethod, false, onResult);
		}

		public static bool IsKnownLocationResetTarget(string prefabName, Action<bool> onResult)
		{
			return (bool)Call(IsKnownResetTargetNameMethod, false, prefabName, onResult);
		}

		public static bool GetLocationLastReset(string locationName, Vector3 center, float radius, Action<long> onResult)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return (bool)Call(GetLocationLastResetMethod, false, locationName, center, radius, onResult);
		}

		public static bool GetSecondsUntilLocationReset(string locationName, Vector3 center, float radius, Action<double> onResult)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return (bool)Call(GetSecondsUntilLocationResetMethod, false, locationName, center, radius, onResult);
		}

		public static bool GetLocationResetInfo(string locationName, Vector3 center, float radius, Action<Dictionary<string, object>> onResult)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return (bool)Call(GetLocationResetInfoMethod, false, locationName, center, radius, onResult);
		}

		public static bool GetChunkResetInfo(Vector3 position, bool includePrefabs, Action<Dictionary<string, object>> onResult)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			return (bool)Call(GetChunkResetInfoMethod, false, position, includePrefabs, onResult);
		}

		public static bool ResetNamedLocation(string locationName, Vector3 center, float radius = 128f, int safety = 0, bool resetAllMatches = false, float safeWaitSeconds = 0f, bool includeDetail = false, Action<Dictionary<string, object>> onComplete = null)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			return (bool)Call(ResetNamedLocationMethod, false, locationName, center, radius, safety, resetAllMatches, safeWaitSeconds, includeDetail, onComplete);
		}

		public static bool ResetLocationsInRadius(Vector3 center, float radius = 128f, int safety = 0, float safeWaitSeconds = 0f, bool includeDetail = false, Action<Dictionary<string, object>> onComplete = null)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			return (bool)Call(ResetLocationsInRadiusMethod, false, center, radius, safety, safeWaitSeconds, includeDetail, onComplete);
		}
	}
}
namespace ValheimResetNow
{
	internal static class BossStone
	{
		internal const string NamePrefix = "VRN_BossStone_";

		private static readonly Dictionary<string, string> bossStones = new Dictionary<string, string>
		{
			{ "TrophyEikthyr", "BossStone_Eikthyr" },
			{ "TrophyTheElder", "BossStone_TheElder" },
			{ "TrophyBonemass", "BossStone_Bonemass" },
			{ "TrophyDragonQueen", "BossStone_DragonQueen" },
			{ "TrophyGoblinKing", "BossStone_Yagluth" },
			{ "TrophySeekerQueen", "BossStone_TheQueen" },
			{ "TrophyFader", "BossStone_Fader" }
		};

		private static readonly Dictionary<int, string> trophies = new Dictionary<int, string>
		{
			{
				StringExtensionMethods.GetStableHashCode("Crypt2"),
				"TrophyEikthyr"
			},
			{
				StringExtensionMethods.GetStableHashCode("Crypt3"),
				"TrophyEikthyr"
			},
			{
				StringExtensionMethods.GetStableHashCode("Crypt4"),
				"TrophyEikthyr"
			},
			{
				StringExtensionMethods.GetStableHashCode("Hildir_crypt"),
				"TrophyEikthyr"
			},
			{
				StringExtensionMethods.GetStableHashCode("SunkenCrypt4"),
				"TrophyTheElder"
			},
			{
				StringExtensionMethods.GetStableHashCode("Hildir_cave"),
				"TrophyBonemass"
			},
			{
				StringExtensionMethods.GetStableHashCode("MountainCave02"),
				"TrophyBonemass"
			},
			{
				StringExtensionMethods.GetStableHashCode("Hildir_plainsfortress"),
				"TrophyDragonQueen"
			},
			{
				StringExtensionMethods.GetStableHashCode("Mistlands_DvergrTownEntrance1"),
				"TrophyGoblinKing"
			},
			{
				StringExtensionMethods.GetStableHashCode("Mistlands_DvergrTownEntrance2"),
				"TrophyGoblinKing"
			},
			{
				StringExtensionMethods.GetStableHashCode("CharredFortress"),
				"TrophySeekerQueen"
			}
		};

		private static readonly Dictionary<string, GameObject> prefabs = new Dictionary<string, GameObject>();

		private static readonly HashSet<int> ourHashes = new HashSet<int>();

		private const float Scale = 0.5f;

		internal static bool Ready => prefabs.Count > 0;

		internal static string TrophyFor(string locationName)
		{
			if (!string.IsNullOrEmpty(locationName) && trophies.TryGetValue(StringExtensionMethods.GetStableHashCode(locationName), out var value))
			{
				return value;
			}
			return null;
		}

		private static IEnumerable<string> RequiredTrophies()
		{
			HashSet<string> hashSet = new HashSet<string>();
			foreach (KeyValuePair<int, string> trophy in trophies)
			{
				if (!string.IsNullOrEmpty(trophy.Value))
				{
					hashSet.Add(trophy.Value);
				}
			}
			return hashSet;
		}

		internal static bool IsOurs(int prefabHash)
		{
			return ourHashes.Contains(prefabHash);
		}

		internal static GameObject For(string trophy)
		{
			GameObject value;
			return prefabs.TryGetValue(trophy ?? string.Empty, out value) ? value : null;
		}

		internal static void Register()
		{
			PrefabManager.OnPrefabsRegistered += EnsureRegistered;
		}

		private static void EnsureRegistered()
		{
			foreach (string item in RequiredTrophies())
			{
				if (!prefabs.TryGetValue(item, out var value) || (Object)(object)value == (Object)null)
				{
					value = Build(item);
					if ((Object)(object)value == (Object)null)
					{
						continue;
					}
					prefabs[item] = value;
					ourHashes.Add(StringExtensionMethods.GetStableHashCode(((Object)value).name));
				}
				PrefabManager.Instance.RegisterToZNetScene(value);
			}
		}

		private static GameObject Build(string trophy)
		{
			//IL_003a: 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)
			string text = bossStones[trophy];
			GameObject val = PrefabManager.Instance.CreateClonedPrefab("VRN_BossStone_" + trophy, text);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			val.transform.localScale = Vector3.one * 0.5f;
			PrefabManager.Instance.AddPrefab(val);
			return val;
		}
	}
	internal static class BossStoneReset
	{
		[HarmonyPatch(typeof(ItemStand), "Interact")]
		internal static class InteractPatch
		{
			[HarmonyPrefix]
			private static bool AltUse(ItemStand __instance, Humanoid user, bool hold, bool alt, ref bool __result)
			{
				bool flag = TakeHeld();
				if (hold)
				{
					if (!alt && !flag)
					{
						return true;
					}
					__result = false;
					return false;
				}
				ZNetView val = OurView(__instance);
				if ((Object)(object)val == (Object)null)
				{
					return true;
				}
				Player val2 = (Player)(object)((user is Player) ? user : null);
				if ((Object)(object)val2 == (Object)null || (Object)(object)val2 != (Object)(object)Player.m_localPlayer)
				{
					return true;
				}
				if (!val.IsOwner())
				{
					val.ClaimOwnership();
				}
				__result = true;
				if (alt)
				{
					Use(val2, __instance, val.GetZDO());
					return false;
				}
				if (flag)
				{
					Take(val2, __instance);
					return false;
				}
				if (__instance.HaveAttachment())
				{
					__result = false;
					return false;
				}
				return true;
			}

			private static bool TakeHeld()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				KeyCode value = VRNConfig.TakeTrophyKey.Value;
				return (int)value != 0 && Input.GetKey(value);
			}
		}

		[HarmonyPatch(typeof(ItemStand), "GetHoverText")]
		internal static class HoverPatch
		{
			[HarmonyPostfix]
			private static void Append(ItemStand __instance, ref string __result)
			{
				if (!string.IsNullOrEmpty(__result))
				{
					ZDO val = StoneZdo(__instance);
					if (val != null)
					{
						string text = (__instance.HaveAttachment() ? HoldToActivate(__result) : __result);
						__result = StatusLine(val, __instance) + "\n\n" + text;
					}
				}
			}
		}

		[HarmonyPatch(typeof(RuneStone), "GetHoverText")]
		internal static class LoreHoverPatch
		{
			[HarmonyPostfix]
			private static void Replace(RuneStone __instance, ref string __result)
			{
				ZDO val = RuneZdo(__instance);
				if (val != null)
				{
					__result = Status(val) + ClaimPrompt(val) + "\n\n" + __result;
				}
			}
		}

		[HarmonyPatch(typeof(RuneStone), "Interact")]
		internal static class LoreInteractPatch
		{
			[HarmonyPrefix]
			private static bool ReadInstead(RuneStone __instance, Humanoid character, bool hold, bool alt, ref bool __result)
			{
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				if (hold)
				{
					return true;
				}
				ZDO val = RuneZdo(__instance);
				if (val == null)
				{
					return true;
				}
				Player val2 = (Player)(object)((character is Player) ? character : null);
				if ((Object)(object)val2 == (Object)null || (Object)(object)val2 != (Object)(object)Player.m_localPlayer)
				{
					return true;
				}
				if (alt)
				{
					((Humanoid)val2).DoInteractAnimation(((Component)__instance).gameObject);
					StoneRelay.Ask(val.m_uid, 3);
					__result = false;
					return false;
				}
				Read(val2, val);
				return true;
			}
		}

		private enum StoneState
		{
			Unread,
			Timed
		}

		private const long Unstamped = long.MinValue;

		private static readonly HashSet<ZDOID> primed = new HashSet<ZDOID>();

		private static float lastPrime = float.NegativeInfinity;

		private static string UseKey => Localization.instance.Localize("$KEY_Use");

		private static string AltKey => Localization.instance.Localize("$KEY_AltPlace");

		internal static void Reset()
		{
			lastPrime = float.NegativeInfinity;
			primed.Clear();
		}

		private static string ClaimPrompt(ZDO zdo)
		{
			if (!VRNConfig.AllowForceScheduledReset.Value)
			{
				return string.Empty;
			}
			long num = zdo.GetLong("VRN_schedAt", -1L);
			if (num < 0)
			{
				return string.Empty;
			}
			if (num > DateTimeOffset.UtcNow.ToUnixTimeSeconds())
			{
				return string.Empty;
			}
			return "\n[<color=yellow><b>" + AltKey + " + " + UseKey + "</b></color>] Force scheduled reset";
		}

		private static ZDO RuneZdo(RuneStone rune)
		{
			if ((Object)(object)rune == (Object)null)
			{
				return null;
			}
			ZNetView componentInParent = ((Component)rune).GetComponentInParent<ZNetView>();
			if ((Object)(object)componentInParent == (Object)null || !componentInParent.IsValid())
			{
				return null;
			}
			ZDO zDO = componentInParent.GetZDO();
			if (zDO == null || !BossStone.IsOurs(zDO.GetPrefab()))
			{
				return null;
			}
			return zDO;
		}

		private static void Read(Player player, ZDO zdo)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (!StoneRelay.Fresh(zdo))
			{
				StoneRelay.Ask(zdo.m_uid, 0);
			}
		}

		private static void Use(Player player, ItemStand stand, ZDO zdo)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (stand.HaveAttachment())
			{
				StoneRelay.Ask(zdo.m_uid, 1);
			}
		}

		internal static void Answered(ZDOID stone, int state, float seconds, string text)
		{
			Player localPlayer = Player.m_localPlayer;
			switch (state)
			{
			case 4:
				if ((Object)(object)localPlayer != (Object)null)
				{
					((Character)localPlayer).Message((MessageType)2, "Reset Success", 0, (Sprite)null, false);
				}
				break;
			case 5:
				if ((Object)(object)localPlayer != (Object)null)
				{
					((Character)localPlayer).Message((MessageType)2, "Other Reset In Progress", 0, (Sprite)null, false);
				}
				break;
			case 6:
				if ((Object)(object)localPlayer != (Object)null)
				{
					((Character)localPlayer).Message((MessageType)2, string.IsNullOrEmpty(text) ? "Reset Failed" : text, 0, (Sprite)null, false);
				}
				break;
			case 2:
				if ((Object)(object)localPlayer != (Object)null)
				{
					((Character)localPlayer).Message((MessageType)2, (seconds > 0f) ? ("Trophy reset already used " + Countdown(seconds)) : "Trophy reset already used", 0, (Sprite)null, false);
				}
				break;
			case 3:
				break;
			}
		}

		private static string StatusLine(ZDO zdo, ItemStand stand)
		{
			string text = Status(zdo);
			return text + "\n" + Prompt(stand);
		}

		private static StoneState StateOf(ZDO zdo)
		{
			if (zdo.GetLong("VRN_readyAt", long.MinValue) == long.MinValue)
			{
				return StoneState.Unread;
			}
			return StoneState.Timed;
		}

		private static string Status(ZDO zdo)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			if (StateOf(zdo) == StoneState.Unread)
			{
				Prime(zdo.m_uid);
				return "<color=#b0b0b0>Reading the stone...</color>";
			}
			return Clocks(zdo);
		}

		private static string Clocks(ZDO zdo)
		{
			long num = DateTimeOffset.UtcNow.ToUnixTimeSeconds();
			long num2 = zdo.GetLong("VRN_readyAt", long.MinValue) - num;
			string text = ((num2 > 0) ? ("<color=#d0c0a0>" + Countdown(num2) + " until trophy reset available</color>") : "<color=#00ff00>Trophy reset available</color>");
			long num3 = zdo.GetLong("VRN_schedAt", -1L);
			if (num3 < 0)
			{
				return text;
			}
			long num4 = num3 - num;
			return text + ((num4 > 0) ? ("\n<color=#8fb8e0>" + Countdown(num4) + " until scheduled reset</color>") : "\n<color=#8fb8e0>Scheduled reset due</color>");
		}

		private static void Prime(ZDOID id)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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)
			if (!primed.Contains(id) && !(Time.time - lastPrime < 1f))
			{
				primed.Add(id);
				lastPrime = Time.time;
				StoneRelay.Ask(id, 0);
			}
		}

		private static string HoldToActivate(string hover)
		{
			string text = Localization.instance.Localize("[<color=yellow><b>$KEY_Use</b></color>]");
			if (!hover.Contains(text))
			{
				return hover;
			}
			string newValue = Localization.instance.Localize("[<color=yellow><b>$ui_hold $KEY_Use</b></color>]");
			return hover.Replace(text, newValue);
		}

		private unsafe static string Prompt(ItemStand stand)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			string text = "[<color=yellow><b>" + AltKey + " + " + UseKey + "</b></color>] Reset with Trophy";
			KeyCode value = VRNConfig.TakeTrophyKey.Value;
			if ((int)value == 0 || !stand.HaveAttachment())
			{
				return text;
			}
			return text + "\n[<color=yellow><b>" + ((object)(*(KeyCode*)(&value))/*cast due to .constrained prefix*/).ToString() + " + " + UseKey + "</b></color>] Take Trophy";
		}

		private static void Take(Player player, ItemStand stand)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (RenewalEffects.IsSealed(((Component)stand).transform.position) || !stand.HaveAttachment())
			{
				return;
			}
			ZNetView val = OurView(stand);
			if (!((Object)(object)val == (Object)null))
			{
				if (!val.IsOwner())
				{
					val.ClaimOwnership();
				}
				stand.DropItem();
			}
		}

		private static string Countdown(double seconds)
		{
			TimeSpan timeSpan = TimeSpan.FromSeconds(seconds);
			TimeSpan timeSpan2 = timeSpan;
			TimeSpan timeSpan3 = timeSpan2;
			if (timeSpan3.TotalDays >= 1.0)
			{
				return $"{(int)timeSpan3.TotalDays}d {timeSpan3.Hours}h {timeSpan3.Minutes:00}m {timeSpan3.Seconds:00}s";
			}
			TimeSpan timeSpan4 = timeSpan2;
			if (timeSpan4.TotalHours >= 1.0)
			{
				return $"{(int)timeSpan4.TotalHours}h {timeSpan4.Minutes:00}m {timeSpan4.Seconds:00}s";
			}
			TimeSpan timeSpan5 = timeSpan2;
			if (timeSpan5.TotalMinutes >= 1.0)
			{
				return $"{timeSpan5.Minutes}m {timeSpan5.Seconds:00}s";
			}
			return Mathf.Max(1, Mathf.CeilToInt((float)seconds)) + "s";
		}

		private static ZNetView OurView(ItemStand stand)
		{
			if ((Object)(object)stand == (Object)null)
			{
				return null;
			}
			ZNetView val = (((Object)(object)stand.m_nview != (Object)null) ? stand.m_nview : ((Component)stand).GetComponentInParent<ZNetView>());
			if ((Object)(object)val == (Object)null || !val.IsValid())
			{
				return null;
			}
			ZDO zDO = val.GetZDO();
			return (zDO != null && BossStone.IsOurs(zDO.GetPrefab())) ? val : null;
		}

		private static ZDO StoneZdo(ItemStand stand)
		{
			ZNetView val = OurView(stand);
			return ((Object)(object)val != (Object)null) ? val.GetZDO() : null;
		}
	}
	internal static class RenewalEffects
	{
		[HarmonyPatch(typeof(Teleport), "Interact")]
		internal static class EntrancePatch
		{
			[HarmonyPrefix]
			private static bool Block(Teleport __instance, Humanoid character, bool hold, ref bool __result)
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				if (hold || (Object)(object)character == (Object)null || ((Character)character).InInterior())
				{
					return true;
				}
				if (!IsSealed(((Component)__instance).transform.position))
				{
					return true;
				}
				((Character)character).Message((MessageType)2, "Blocked", 0, (Sprite)null, false);
				__result = false;
				return false;
			}
		}

		internal const string SoundRpc = "VRN_StoneSound";

		internal const string SealRpc = "VRN_StoneSeal";

		private static Vector3 sealPos;

		private static float sealRadius;

		private static float sealUntil = float.NegativeInfinity;

		internal const string BlockerRpc = "VRN_StoneBlocker";

		private const float BlockerTellRadius = 20f;

		internal static void Register(ZRoutedRpc rpc)
		{
			rpc.Register<Vector3>("VRN_StoneSound", (Action<long, Vector3>)Heard);
			rpc.Register<Vector3, float, float>("VRN_StoneSeal", (Action<long, Vector3, float, float>)Sealed);
			rpc.Register<Vector3, Vector3, string, bool>("VRN_StoneBlocker", (Method<Vector3, Vector3, string, bool>)Blocked);
		}

		internal static void Blame(Vector3 stonePos, Vector3 blockerPos, string what, long asker)
		{
			//IL_0027: 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)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			if (ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(0L, "VRN_StoneBlocker", new object[4]
				{
					stonePos,
					blockerPos,
					what ?? string.Empty,
					false
				});
				if (asker != 0)
				{
					ZRoutedRpc.instance.InvokeRoutedRPC(asker, "VRN_StoneBlocker", new object[4]
					{
						stonePos,
						blockerPos,
						what ?? string.Empty,
						true
					});
				}
			}
		}

		private static void PingSelf(Vector3 position)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && ZRoutedRpc.instance != null)
			{
				position.y = ((Component)localPlayer).transform.position.y;
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.m_id, "ChatMessage", new object[4]
				{
					position,
					3,
					UserInfo.GetLocalUser(),
					string.Empty
				});
			}
		}

		private static void Blocked(long sender, Vector3 stonePos, Vector3 blockerPos, string what, bool ping)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || !Player.IsPlayerInRange(stonePos, 20f))
			{
				return;
			}
			if (ping)
			{
				if (blockerPos != Vector3.zero)
				{
					PingSelf(blockerPos);
				}
			}
			else
			{
				((Character)localPlayer).Message((MessageType)2, (what.Length > 0) ? ("Blocked by " + what) : "Something nearby is blocking this", 0, (Sprite)null, false);
			}
		}

		internal static void Reset()
		{
			sealUntil = float.NegativeInfinity;
		}

		internal static void Seal(Vector3 center, float seconds)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(0L, "VRN_StoneSeal", new object[3] { center, 64f, seconds });
			}
		}

		private static void Sealed(long sender, Vector3 center, float radius, float seconds)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (seconds <= 0f)
			{
				sealUntil = float.NegativeInfinity;
				return;
			}
			sealPos = center;
			sealRadius = radius;
			sealUntil = Time.time + seconds;
		}

		internal static bool IsSealed(Vector3 point)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time >= sealUntil)
			{
				return false;
			}
			Vector3 val = point - sealPos;
			return ((Vector3)(ref val)).sqrMagnitude <= sealRadius * sealRadius;
		}

		internal static void Announce(long peer, Vector3 stonePos)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(peer, "VRN_StoneSound", new object[1] { stonePos });
			}
		}

		private static void Heard(long sender, Vector3 stonePos)
		{
			//IL_004a: 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)
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)ZNetScene.instance == (Object)null))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab("sfx_bomblava_rocks");
				if (!((Object)(object)prefab == (Object)null))
				{
					Object.Instantiate<GameObject>(prefab, ((Component)localPlayer).transform.position, Quaternion.identity);
				}
			}
		}
	}
	internal static class BossStonePlacement
	{
		internal class Spot
		{
			internal readonly float Angle;

			internal readonly float Distance;

			internal readonly float Side;

			internal readonly float Height;

			internal readonly float Yaw;

			internal Spot(float angle, float distance, float side, float height, float yaw)
			{
				Angle = angle;
				Distance = distance;
				Side = side;
				Height = height;
				Yaw = yaw;
			}
		}

		[HarmonyPatch(typeof(ZoneSystem), "SpawnLocation")]
		internal static class SpawnLocationPatch
		{
			[HarmonyPostfix]
			private static void Place(ZoneLocation location, Vector3 pos, Quaternion rot, SpawnMode mode)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Invalid comparison between Unknown and I4
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Invalid comparison between Unknown and I4
				//IL_006b: 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_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				if (((int)mode != 0 && (int)mode != 2) || !Allowed() || location == null)
				{
					return;
				}
				string text = NameOf(location);
				if (IsTarget(text))
				{
					if ((int)mode == 2)
					{
						BossStoneSweep.PlaceZdo(text, pos, rot, location.m_exteriorRadius);
					}
					else
					{
						TryPlace(text, location.m_exteriorRadius, pos, rot, "spawn");
					}
				}
			}
		}

		internal static class BossStoneSweep
		{
			[HarmonyPatch(typeof(ZNet), "Awake")]
			internal static class KickoffPatch
			{
				[HarmonyPostfix]
				private static void Kick()
				{
					if (!ran)
					{
						ran = true;
						if ((Object)(object)ValheimResetNow.Instance != (Object)null)
						{
							((MonoBehaviour)ValheimResetNow.Instance).StartCoroutine(Run());
						}
					}
				}
			}

			private const int PerTick = 25;

			private const float TickSeconds = 0.25f;

			private static bool ran;

			internal static void Reset()
			{
				ran = false;
			}

			private static IEnumerator Run()
			{
				while ((Object)(object)ZoneSystem.instance == (Object)null || ZDOMan.instance == null || !BossStone.Ready || (Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
				{
					yield return (object)new WaitForSeconds(2f);
				}
				yield return (object)new WaitForSeconds(15f);
				ZoneSystem zones = ZoneSystem.instance;
				List<KeyValuePair<Vector2s, LocationInstance>> work = new List<KeyValuePair<Vector2s, LocationInstance>>();
				foreach (KeyValuePair<Vector2s, LocationInstance> pair in zones.m_locationInstances)
				{
					if (pair.Value.m_location != null && IsTarget(NameOf(pair.Value.m_location)))
					{
						work.Add(pair);
					}
				}
				int i = 0;
				while (i < work.Count)
				{
					Place(work[i].Key, work[i].Value);
					if ((i + 1) % 25 == 0)
					{
						yield return (object)new WaitForSeconds(0.25f);
					}
					int num = i + 1;
					i = num;
				}
			}

			private static void Place(Vector2s zoneID, LocationInstance inst)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: 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_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				if (TryReadLocationProxy(zoneID, inst.m_position, out var rot, out var proxyPos))
				{
					PlaceZdo(NameOf(inst.m_location), proxyPos, rot, inst.m_location.m_exteriorRadius);
				}
			}

			internal static void PlaceZdo(string name, Vector3 origin, Quaternion rot, float exteriorRadius)
			{
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_008c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_017b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: Unknown result type (might be due to invalid IL or missing references)
				//IL_0109: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: 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_015c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Unknown result type (might be due to invalid IL or missing references)
				Spot spot = SpotFor(name);
				if (spot == null)
				{
					return;
				}
				Resolve(origin, rot, spot, out var spot2, out var stoneRot);
				if (AlreadyPlaced(origin, spot2, exteriorRadius, spot.Distance))
				{
					return;
				}
				GameObject val = BossStone.For(BossStone.TrophyFor(name));
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				ZNetView component = val.GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null)
				{
					return;
				}
				int stableHashCode = StringExtensionMethods.GetStableHashCode(((Object)val).name);
				ZDO val2 = ZDOMan.instance.CreateNewZDO(spot2, stableHashCode);
				if (val2 == null)
				{
					return;
				}
				val2.Persistent = component.m_persistent;
				val2.Type = component.m_type;
				val2.Distant = component.m_distant;
				val2.SetPrefab(stableHashCode);
				val2.SetPosition(spot2);
				val2.SetRotation(stoneRot);
				if (component.m_syncInitialScale)
				{
					Vector3 localScale = val.transform.localScale;
					if (Mathf.Approximately(localScale.x, localScale.y) && Mathf.Approximately(localScale.x, localScale.z))
					{
						val2.Set(ZDOVars.s_scaleScalarHash, localScale.x);
					}
					else
					{
						val2.Set(ZDOVars.s_scaleHash, localScale);
					}
				}
				val2.Set("VRN_location", name);
				val2.Set("VRN_locationPos", origin);
			}
		}

		private const string TargetLocations = "Crypt2, Crypt3, Crypt4, Hildir_crypt, SunkenCrypt4, Hildir_cave, MountainCave02, Hildir_plainsfortress, Mistlands_DvergrTownEntrance1, Mistlands_DvergrTownEntrance2, CharredFortress";

		private static readonly Dictionary<int, Spot> builtIn = new Dictionary<int, Spot>
		{
			{
				StringExtensionMethods.GetStableHashCode("Crypt2"),
				new Spot(146.25f, 3.8f, 4.7f, 0f, -31.15f)
			},
			{
				StringExtensionMethods.GetStableHashCode("Crypt3"),
				new Spot(146.25f, 4.8f, 7.7f, 0f, -51.15f)
			},
			{
				StringExtensionMethods.GetStableHashCode("Crypt4"),
				new Spot(146.25f, -10f, -9f, 0f, -90f)
			},
			{
				StringExtensionMethods.GetStableHashCode("Hildir_crypt"),
				new Spot(146.25f, -10f, -9f, 0f, -90f)
			},
			{
				StringExtensionMethods.GetStableHashCode("SunkenCrypt4"),
				new Spot(146.25f, 3.8f, 4.7f, 0f, -50f)
			},
			{
				StringExtensionMethods.GetStableHashCode("MountainCave02"),
				new Spot(167f, -1.25f, -5f, -1.6f, -123f)
			},
			{
				StringExtensionMethods.GetStableHashCode("Hildir_cave"),
				new Spot(167f, -1.25f, -5f, -1.6f, -123f)
			},
			{
				StringExtensionMethods.GetStableHashCode("Hildir_plainsfortress"),
				new Spot(146.25f, 12f, 4.7f, 2.5f, -10f)
			},
			{
				StringExtensionMethods.GetStableHashCode("Mistlands_DvergrTownEntrance1"),
				new Spot(170f, 1.2f, -3.2f, -1.2f, -110f)
			},
			{
				StringExtensionMethods.GetStableHashCode("Mistlands_DvergrTownEntrance2"),
				new Spot(146.25f, -15f, -14.42f, 0.5f, -78f)
			},
			{
				StringExtensionMethods.GetStableHashCode("CharredFortress"),
				new Spot(235f, 18f, -17f, 0f, -80.5f)
			}
		};

		private static readonly HashSet<int> targetHashes = BuildTargets();

		private static readonly List<ZDO> zdoBuffer = new List<ZDO>();

		private static readonly HashSet<SectorIndex> visitedScratch = new HashSet<SectorIndex>();

		private static int locationProxyHash;

		internal const string LocationNameKey = "VRN_location";

		internal const string LocationPosKey = "VRN_locationPos";

		private static HashSet<int> BuildTargets()
		{
			HashSet<int> hashSet = new HashSet<int>();
			string[] array = "Crypt2, Crypt3, Crypt4, Hildir_crypt, SunkenCrypt4, Hildir_cave, MountainCave02, Hildir_plainsfortress, Mistlands_DvergrTownEntrance1, Mistlands_DvergrTownEntrance2, CharredFortress".Split(new char[1] { ',' });
			foreach (string text in array)
			{
				string text2 = text.Trim();
				if (text2.Length != 0)
				{
					hashSet.Add(StringExtensionMethods.GetStableHashCode(text2));
				}
			}
			return hashSet;
		}

		internal static bool IsTarget(string locationName)
		{
			if (string.IsNullOrEmpty(locationName))
			{
				return false;
			}
			return targetHashes.Contains(StringExtensionMethods.GetStableHashCode(locationName));
		}

		private static string NameOf(ZoneLocation location)
		{
			if (!string.IsNullOrEmpty(location.m_prefabName))
			{
				return location.m_prefabName;
			}
			try
			{
				return location.m_prefab.Name;
			}
			catch (Exception)
			{
				return null;
			}
		}

		internal static Spot SpotFor(string locationName)
		{
			Spot value;
			return (!string.IsNullOrEmpty(locationName) && builtIn.TryGetValue(StringExtensionMethods.GetStableHashCode(locationName), out value)) ? value : null;
		}

		internal static void Reset()
		{
			locationProxyHash = 0;
		}

		private static bool Allowed()
		{
			if (!BossStone.Ready)
			{
				return false;
			}
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
			{
				return false;
			}
			return (Object)(object)ZNetScene.instance != (Object)null && ZDOMan.instance != null;
		}

		private static bool TryPlace(string locationName, float exteriorRadius, Vector3 pos, Quaternion rot, string via)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			Spot spot = SpotFor(locationName);
			if (spot == null)
			{
				return false;
			}
			float distance = spot.Distance;
			Resolve(pos, rot, spot, out var spot2, out var stoneRot);
			if (AlreadyPlaced(pos, spot2, exteriorRadius, distance))
			{
				return false;
			}
			string text = BossStone.TrophyFor(locationName);
			if (string.IsNullOrEmpty(text))
			{
				return false;
			}
			GameObject val = BossStone.For(text);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			GameObject val2 = Object.Instantiate<GameObject>(val, spot2, stoneRot);
			if ((Object)(object)val2 == (Object)null)
			{
				return false;
			}
			StampLocation(val2, locationName, pos);
			return true;
		}

		private static void StampLocation(GameObject placed, string locationName, Vector3 locationPos)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			ZNetView component = placed.GetComponent<ZNetView>();
			ZDO val = (((Object)(object)component != (Object)null) ? component.GetZDO() : null);
			if (val != null)
			{
				val.Set("VRN_location", locationName);
				val.Set("VRN_locationPos", locationPos);
			}
		}

		private static void Resolve(Vector3 pos, Quaternion rot, Spot place, out Vector3 spot, out Quaternion stoneRot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0043: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = rot * Quaternion.Euler(0f, place.Angle, 0f) * Vector3.forward;
			val.y = 0f;
			val = ((((Vector3)(ref val)).sqrMagnitude < 0.0001f) ? Vector3.right : ((Vector3)(ref val)).normalized);
			Vector3 val2 = Vector3.Cross(Vector3.up, val);
			spot = pos + val * place.Distance + val2 * place.Side;
			spot.y = pos.y + place.Height;
			stoneRot = rot;
			Vector3 val3 = pos - spot;
			val3.y = 0f;
			if (((Vector3)(ref val3)).sqrMagnitude > 0.0001f)
			{
				stoneRot = Quaternion.LookRotation(((Vector3)(ref val3)).normalized);
			}
			stoneRot *= Quaternion.Euler(0f, place.Yaw, 0f);
		}

		private static bool AlreadyPlaced(Vector3 locationPos, Vector3 spot, float exteriorRadius, float distance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			Vector2s zone = ZoneSystem.GetZone(locationPos);
			Vector2s zone2 = ZoneSystem.GetZone(spot);
			float range = Mathf.Max(exteriorRadius, Mathf.Abs(distance)) + 8f;
			if (ZoneHasStone(zone, locationPos, range))
			{
				return true;
			}
			if ((zone2.x != zone.x || zone2.y != zone.y) && ZoneHasStone(zone2, locationPos, range))
			{
				return true;
			}
			return false;
		}

		private static bool ZoneHasStone(Vector2s zone, Vector3 locationPos, float range)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			float num = range * range;
			zdoBuffer.Clear();
			visitedScratch.Clear();
			ZDOMan.instance.FindObjects(zone, zdoBuffer, visitedScratch);
			bool result = false;
			for (int i = 0; i < zdoBuffer.Count; i++)
			{
				ZDO val = zdoBuffer[i];
				if (val != null && val.IsValid() && BossStone.IsOurs(val.GetPrefab()) && !Destroyed(val))
				{
					Vector3 val2 = val.GetPosition() - locationPos;
					val2.y = 0f;
					if (!(((Vector3)(ref val2)).sqrMagnitude > num))
					{
						result = true;
						break;
					}
				}
			}
			zdoBuffer.Clear();
			return result;
		}

		private static bool Destroyed(ZDO zdo)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			List<ZDOID> destroySendList = ZDOMan.instance.m_destroySendList;
			for (int i = 0; i < destroySendList.Count; i++)
			{
				if (destroySendList[i] == zdo.m_uid)
				{
					return true;
				}
			}
			return false;
		}

		private static bool TryReadLocationProxy(Vector2s zone, Vector3 locationPos, out Quaternion rot, out Vector3 proxyPos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			rot = Quaternion.identity;
			proxyPos = locationPos;
			if (locationProxyHash == 0)
			{
				ZoneSystem instance = ZoneSystem.instance;
				if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_locationProxyPrefab == (Object)null)
				{
					return false;
				}
				locationProxyHash = StringExtensionMethods.GetStableHashCode(((Object)instance.m_locationProxyPrefab).name);
			}
			zdoBuffer.Clear();
			visitedScratch.Clear();
			ZDOMan.instance.FindObjects(zone, zdoBuffer, visitedScratch);
			bool result = false;
			float num = float.MaxValue;
			for (int i = 0; i < zdoBuffer.Count; i++)
			{
				ZDO val = zdoBuffer[i];
				if (val != null && val.IsValid() && val.GetPrefab() == locationProxyHash)
				{
					Vector3 val2 = val.GetPosition() - locationPos;
					float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
					if (!(sqrMagnitude >= num))
					{
						num = sqrMagnitude;
						rot = val.GetRotation();
						proxyPos = val.GetPosition();
						result = true;
					}
				}
			}
			zdoBuffer.Clear();
			return result;
		}

		internal static string LocationNameOf(ZDO zdo, Vector3 stonePos)
		{
			string text = zdo.GetString("VRN_location", string.Empty);
			if (!string.IsNullOrEmpty(text))
			{
				return text;
			}
			return null;
		}

		internal static Vector3 LocationCenterOf(ZDO zdo, Vector3 stonePos)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			Vector3 vec = zdo.GetVec3("VRN_locationPos", Vector3.zero);
			return (vec == Vector3.zero) ? stonePos : vec;
		}
	}
	internal static class CharacterResetLog
	{
		internal class Book
		{
			public Dictionary<string, Character> Players { get; set; } = new Dictionary<string, Character>();
		}

		internal class Character
		{
			public string Name { get; set; } = string.Empty;

			public Dictionary<string, Entry> Resets { get; set; } = new Dictionary<string, Entry>();
		}

		internal class Entry
		{
			public string Location { get; set; } = string.Empty;

			public int X { get; set; }

			public int Z { get; set; }

			public long At { get; set; }

			public string AtUtc { get; set; } = string.Empty;

			public int Count { get; set; }
		}

		private const string FolderName = "ValheimResetNow";

		private const string FileName = "CharacterResetsLog.yaml";

		private static Book book;

		private static readonly Dictionary<string, long> newestByLocation = new Dictionary<string, long>();

		private static bool dirty;

		internal static string KeyFor(string location, Vector3 pos)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			return location + "@" + Mathf.RoundToInt(pos.x) + "," + Mathf.RoundToInt(pos.z);
		}

		internal static void Load()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			if (book != null)
			{
				return;
			}
			book = new Book();
			newestByLocation.Clear();
			dirty = false;
			string text = FilePath();
			if (!File.Exists(text))
			{
				return;
			}
			try
			{
				IDeserializer val = ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).IgnoreUnmatchedProperties().Build();
				using (StreamReader streamReader = File.OpenText(text))
				{
					book = val.Deserialize<Book>((TextReader)streamReader) ?? new Book();
				}
				if (book.Players == null)
				{
					book.Players = new Dictionary<string, Character>();
				}
				Reindex();
			}
			catch (Exception)
			{
				book = new Book();
				newestByLocation.Clear();
				string destFileName = text + ".broken";
				try
				{
					File.Copy(text, destFileName, overwrite: true);
				}
				catch (Exception)
				{
				}
			}
		}

		private static void Reindex()
		{
			newestByLocation.Clear();
			foreach (KeyValuePair<string, Character> player in book.Players)
			{
				if (player.Value == null || player.Value.Resets == null)
				{
					continue;
				}
				foreach (KeyValuePair<string, Entry> reset in player.Value.Resets)
				{
					if (!newestByLocation.TryGetValue(reset.Key, out var value) || value < reset.Value.At)
					{
						newestByLocation[reset.Key] = reset.Value.At;
					}
				}
			}
		}

		internal static long LastReset(string key)
		{
			Load();
			long value;
			return newestByLocation.TryGetValue(key, out value) ? value : 0;
		}

		internal static void Record(long playerId, string playerName, string location, Vector3 pos, long whenUnix)
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			Load();
			string key = ((playerId != 0L) ? playerId.ToString() : "unknown");
			if (!book.Players.TryGetValue(key, out var value) || value == null)
			{
				value = new Character();
				book.Players[key] = value;
			}
			if (!string.IsNullOrEmpty(playerName))
			{
				value.Name = playerName;
			}
			if (value.Resets == null)
			{
				value.Resets = new Dictionary<string, Entry>();
			}
			string key2 = KeyFor(location, pos);
			if (!value.Resets.TryGetValue(key2, out var value2) || value2 == null)
			{
				value2 = new Entry
				{
					Location = location,
					X = Mathf.RoundToInt(pos.x),
					Z = Mathf.RoundToInt(pos.z)
				};
				value.Resets[key2] = value2;
			}
			value2.At = whenUnix;
			value2.AtUtc = DateTimeOffset.FromUnixTimeSeconds(whenUnix).UtcDateTime.ToString("yyyy-MM-ddTHH:mm:ssZ");
			value2.Count++;
			if (!newestByLocation.TryGetValue(key2, out var value3) || value3 < whenUnix)
			{
				newestByLocation[key2] = whenUnix;
			}
			dirty = true;
			Flush();
		}

		internal static void Flush()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			if (book == null || !dirty)
			{
				return;
			}
			string text = FilePath();
			try
			{
				Directory.CreateDirectory(Path.GetDirectoryName(text));
				ISerializer val = ((BuilderSkeleton<SerializerBuilder>)new SerializerBuilder()).WithNamingConvention(CamelCaseNamingConvention.Instance).Build();
				string contents = val.Serialize((object)book);
				string text2 = text + ".tmp";
				File.WriteAllText(text2, contents);
				if (File.Exists(text))
				{
					File.Delete(text);
				}
				File.Move(text2, text);
				dirty = false;
			}
			catch (Exception)
			{
			}
		}

		internal static void Unload()
		{
			Flush();
			book = null;
			newestByLocation.Clear();
			dirty = false;
		}

		private static string FilePath()
		{
			return Path.Combine(Path.Combine(Paths.ConfigPath, "ValheimResetNow"), "CharacterResetsLog.yaml");
		}
	}
	internal static class StoneRelay
	{
		[HarmonyPatch(typeof(Game), "Start")]
		internal static class RegisterPatch
		{
			[HarmonyPostfix]
			private static void Register()
			{
				if (ZRoutedRpc.instance != null)
				{
					ZRoutedRpc.instance.Register<ZDOID, int, long, string>("VRN_StoneAsk", (Method<ZDOID, int, long, string>)Serve);
					ZRoutedRpc.instance.Register<ZDOID, int, float, string>("VRN_StoneTell", (Method<ZDOID, int, float, string>)Hear);
					RenewalEffects.Register(ZRoutedRpc.instance);
					if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer())
					{
						CharacterResetLog.Load();
					}
				}
			}
		}

		private enum Gate
		{
			Open,
			TrophyOnly,
			NotDue,
			NoSchedule,
			Busy,
			Occupied
		}

		private const string AskRpc = "VRN_StoneAsk";

		private const string TellRpc = "VRN_StoneTell";

		internal const int ModeStatus = 0;

		internal const int ModeReset = 1;

		internal const int ModeScheduled = 3;

		internal const int StateCooling = 2;

		internal const int StateDone = 4;

		internal const int StateBusy = 5;

		internal const int StateFailed = 6;

		private static bool resetRunning;

		private static ZDOID committedStone = ZDOID.None;

		internal const string ReadyAtKey = "VRN_readyAt";

		internal const string SchedAtKey = "VRN_schedAt";

		internal const string StampedAtKey = "VRN_stampedAt";

		private const float InteriorHeight = 5000f;

		private const float InteriorFloor = 3000f;

		private const int MaxBlockersShown = 10;

		internal static void Reset()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			resetRunning = false;
			committedStone = ZDOID.None;
		}

		internal static void Ask(ZDOID stone, int mode)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			if (ZRoutedRpc.instance != null && !(stone == ZDOID.None))
			{
				Player localPlayer = Player.m_localPlayer;
				long num = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetPlayerID() : 0);
				string text = (((Object)(object)localPlayer != (Object)null) ? localPlayer.GetPlayerName() : string.Empty);
				ZRoutedRpc.instance.InvokeRoutedRPC("VRN_StoneAsk", new object[4] { stone, mode, num, text });
			}
		}

		private static void Hear(long sender, ZDOID stone, int state, float seconds, string text)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			BossStoneReset.Answered(stone, state, seconds, text);
		}

		private static void Serve(long sender, ZDOID stone, int mode, long playerId, string playerName)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || ZDOMan.instance == null)
			{
				return;
			}
			ZDO zdo = ZDOMan.instance.GetZDO(stone);
			if (zdo == null || !zdo.IsValid() || !BossStone.IsOurs(zdo.GetPrefab()))
			{
				return;
			}
			Vector3 stonePos = zdo.GetPosition();
			string location = BossStonePlacement.LocationNameOf(zdo, stonePos);
			if (string.IsNullOrEmpty(location) || !API.SupportsLocationReset)
			{
				return;
			}
			Vector3 center = BossStonePlacement.LocationCenterOf(zdo, stonePos);
			if (mode != 0 && !WithinReach(sender, stonePos))
			{
				Tell(sender, stone, 6, 0f, "Too far from the stone");
			}
			else
			{
				if (mode == 0 && Fresh(zdo))
				{
					return;
				}
				API.GetLocationResetTargetInfo(location, delegate(Dictionary<string, object> target)
				{
					//IL_0008: 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_006d: Unknown result type (might be due to invalid IL or missing references)
					//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
					//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
					//IL_0111: Unknown result type (might be due to invalid IL or missing references)
					//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
					//IL_0235: Unknown result type (might be due to invalid IL or missing references)
					//IL_021c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0170: Unknown result type (might be due to invalid IL or missing references)
					//IL_0176: Unknown result type (might be due to invalid IL or missing references)
					//IL_0182: Unknown result type (might be due to invalid IL or missing references)
					//IL_0266: Unknown result type (might be due to invalid IL or missing references)
					//IL_026b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0277: Unknown result type (might be due to invalid IL or missing references)
					//IL_027d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0289: Unknown result type (might be due to invalid IL or missing references)
					//IL_024d: Unknown result type (might be due to invalid IL or missing references)
					float num = Remaining(location, center, target);
					double scheduled = ScheduledSeconds(location, center);
					Stamp(zdo, (num > 0f) ? (Now() + (long)num) : 0, scheduled);
					if (mode != 0)
					{
						if (mode == 3)
						{
							switch (ScheduledGate(scheduled, center))
							{
							case Gate.TrophyOnly:
								Tell(sender, stone, 6, 0f, "Trophy only");
								break;
							case Gate.NotDue:
								Tell(sender, stone, 6, 0f, "Not due yet");
								break;
							case Gate.NoSchedule:
								break;
							case Gate.Busy:
								Tell(sender, stone, 5, 0f, string.Empty);
								break;
							case Gate.Occupied:
								Tell(sender, stone, 6, 0f, "Someone is inside");
								break;
							default:
								if (zdo.GetInt(ZDOVars.s_item, 0) != 0)
								{
									DropTrophy(zdo, "the scheduled claim on '" + location + "'");
								}
								Renew(sender, stone, stonePos, location, center, playerId, playerName, spendsTrophyClock: false);
								break;
							}
						}
						else if (num > 0f)
						{
							Tell(sender, stone, 2, num, string.Empty);
						}
						else if (zdo.GetInt(ZDOVars.s_item, 0) == 0)
						{
							Tell(sender, stone, 6, 0f, "Needs a trophy");
						}
						else if (resetRunning)
						{
							Tell(sender, stone, 5, 0f, string.Empty);
						}
						else if (SomeoneInside(center))
						{
							Tell(sender, stone, 6, 0f, "Someone is inside");
						}
						else
						{
							committedStone = stone;
							Renew(sender, stone, stonePos, location, center, playerId, playerName, spendsTrophyClock: true);
						}
					}
				});
			}
		}

		private static Gate ScheduledGate(double scheduled, Vector3 center)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			if (!VRNConfig.AllowForceScheduledReset.Value)
			{
				return Gate.TrophyOnly;
			}
			if (scheduled > 0.0)
			{
				return Gate.NotDue;
			}
			if (scheduled != 0.0)
			{
				return Gate.NoSchedule;
			}
			if (resetRunning)
			{
				return Gate.Busy;
			}
			if (SomeoneInside(center))
			{
				return Gate.Occupied;
			}
			return Gate.Open;
		}

		private static bool DropTrophy(ZDO zdo, string why)
		{
			if ((Object)(object)ZNetScene.instance == (Object)null || !ZNetScene.instance.m_instances.TryGetValue(zdo, out var value) || (Object)(object)value == (Object)null)
			{
				return false;
			}
			ItemStand componentInChildren = ((Component)value).GetComponentInChildren<ItemStand>(true);
			if ((Object)(object)componentInChildren == (Object)null)
			{
				return false;
			}
			if (!value.IsOwner())
			{
				value.ClaimOwnership();
			}
			componentInChildren.DropItem();
			return true;
		}

		private static float Remaining(string location, Vector3 center, Dictionary<string, object> target)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			string key = CharacterResetLog.KeyFor(location, center);
			if (VRNConfig.AlwaysAllowTrophyResets.Value)
			{
				return 0f;
			}
			double num = Number(target, "resetSeconds", 0.0);
			if (num <= 0.0)
			{
				return 0f;
			}
			long num2 = CharacterResetLog.LastReset(key);
			if (num2 <= 0)
			{
				return 0f;
			}
			double num3 = (double)num2 + num - (double)Now();
			return (num3 > 0.0) ? ((float)num3) : 0f;
		}

		internal static bool Fresh(ZDO zdo)
		{
			float num = 60f;
			if (num <= 0f)
			{
				return false;
			}
			long num2 = zdo.GetLong("VRN_stampedAt", 0L);
			if (num2 <= 0)
			{
				return false;
			}
			return DateTimeOffset.UtcNow.ToUnixTimeSeconds() - num2 < (long)num;
		}

		private static void Stamp(ZDO zdo, long readyAt, double scheduled)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (!zdo.IsOwner())
			{
				ZDOMan.instance.ForceSendZDO(zdo.m_uid);
				zdo.SetOwner(ZDOMan.GetSessionID());
			}
			zdo.Set("VRN_readyAt", readyAt);
			zdo.Set("VRN_schedAt", (scheduled >= 0.0) ? (Now() + (long)scheduled) : (-1));
			zdo.Set("VRN_stampedAt", Now());
		}

		private static void Restamp(ZDOID stone, string location, Vector3 center)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (ZDOMan.instance == null)
			{
				return;
			}
			ZDO zdo = ZDOMan.instance.GetZDO(stone);
			if (zdo != null && zdo.IsValid())
			{
				API.GetLocationResetTargetInfo(location, delegate(Dictionary<string, object> target)
				{
					//IL_0008: 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)
					float num = Remaining(location, center, target);
					double scheduled = ScheduledSeconds(location, center);
					Stamp(zdo, (num > 0f) ? (Now() + (long)num) : 0, scheduled);
				});
			}
		}

		private static double ScheduledSeconds(string location, Vector3 center)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			double answer = -1.0;
			API.GetLocationResetInfo(location, center, 64f, delegate(Dictionary<string, object> info)
			{
				if (Flag(info, "found") && Flag(info, "configured") && Flag(info, "enabled"))
				{
					if (Number(info, "lastResetUnix", 0.0) <= 0.0)
					{
						answer = 0.0;
					}
					else
					{
						answer = Number(info, "secondsUntilDue", -1.0);
					}
				}
			});
			return answer;
		}

		private static string Stamp(long unix)
		{
			return DateTimeOffset.FromUnixTimeSeconds(unix).UtcDateTime.ToString("yyyy-MM-dd HH:mm:ss") + "Z";
		}

		private static void Renew(long sender, ZDOID stone, Vector3 stonePos, string location, Vector3 center, long playerId, string playerName, bool spendsTrophyClock)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0059: 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)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			resetRunning = true;
			committedStone = stone;
			float num = 3f;
			RenewalEffects.Seal(center, num + 20f);
			if (num <= 0f || (Object)(object)ValheimResetNow.Instance == (Object)null)
			{
				Fire(sender, stone, stonePos, location, center, playerId, playerName, spendsTrophyClock);
			}
			else
			{
				((MonoBehaviour)ValheimResetNow.Instance).StartCoroutine(Countdown(num, sender, stone, stonePos, location, center, playerId, playerName, spendsTrophyClock));
			}
		}

		private static IEnumerator Countdown(float delay, long sender, ZDOID stone, Vector3 stonePos, string location, Vector3 center, long playerId, string playerName, bool spendsTrophyClock)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			yield return (object)new WaitForSeconds(delay);
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || !API.SupportsLocationReset)
			{
				resetRunning = false;
				committedStone = ZDOID.None;
				RenewalEffects.Seal(center, 0f);
			}
			else
			{
				Fire(sender, stone, stonePos, location, center, playerId, playerName, spendsTrophyClock);
			}
		}

		private static void Fire(long sender, ZDOID stone, Vector3 stonePos, string location, Vector3 center, long playerId, string playerName, bool spendsTrophyClock)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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)
			API.ResetNamedLocation(location, center, 64f, 1, resetAllMatches: false, 0f, includeDetail: true, delegate(Dictionary<string, object> result)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				resetRunning = false;
				committedStone = ZDOID.None;
				RenewalEffects.Seal(center, 0f);
				if (!Flag(result, "completed") || Count(result, "locationsRebuilt") <= 0)
				{
					if (Count(result, "zonesBlocked") == 1 && ParseBlocker(Blockers(result), out var what, out var where))
					{
						RenewalEffects.Blame(stonePos, where, what, sender);
					}
					Tell(sender, stone, 6, 0f, Excuse(result));
				}
				else
				{
					if (spendsTrophyClock)
					{
						CharacterResetLog.Record(playerId, playerName, location, center, Now());
					}
					RenewalEffects.Announce(sender, stonePos);
					Restamp(stone, location, center);
					Tell(sender, stone, 4, 0f, string.Empty);
				}
			});
		}

		private static string Excuse(Dictionary<string, object> result)
		{
			string text = Text(result, "refusalCode");
			string text2 = text;
			switch (text2)
			{
			default:
				if (text2.Length != 0)
				{
					break;
				}
				return Refusal(result);
			case "cooldown":
			case "already_running":
			case "not_ready":
				return "Still settling";
			case "no_such_location":
				return "Chamber not found";
			case null:
				break;
			}
			return "Renewal refused";
		}

		private static void Tell(long peer, ZDOID stone, int state, float seconds, string text)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(peer, "VRN_StoneTell", new object[4]
				{
					stone,
					state,
					seconds,
					text ?? string.Empty
				});
			}
		}

		private static bool SomeoneInside(Vector3 center)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			Vector3 interior = center + Vector3.up * 5000f;
			float radius = 64f;
			ZNet instance = ZNet.instance;
			if ((Object)(object)instance != (Object)null)
			{
				List<ZNetPeer> peers = instance.GetPeers();
				for (int i = 0; i < peers.Count; i++)
				{
					if (Inside(peers[i].m_refPos, interior, radius))
					{
						return true;
					}
				}
			}
			Player localPlayer = Player.m_localPlayer;
			return (Object)(object)localPlayer != (Object)null && Inside(((Component)localPlayer).transform.position, interior, radius);
		}

		private static bool Inside(Vector3 point, Vector3 interior, float radius)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (point.y < 3000f)
			{
				return false;
			}
			Vector3 val = point - interior;
			val.y = 0f;
			return ((Vector3)(ref val)).sqrMagnitude <= radius * radius;
		}

		private static bool WithinReach(long sender, Vector3 stonePos)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_0045: 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)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			float num = 64f;
			Vector3 val = ZNet.instance.GetPeer(sender)?.m_refPos ?? (((Object)(object)Player.m_localPlayer != (Object)null) ? ((Component)Player.m_localPlayer).transform.position : stonePos);
			Vector3 val2 = val - stonePos;
			return ((Vector3)(ref val2)).sqrMagnitude <= num * num;
		}

		private static long Now()
		{
			return DateTimeOffset.UtcNow.ToUnixTimeSeconds();
		}

		private static string Refusal(Dictionary<string, object> result)
		{
			int num = Count(result, "zonesBlocked");
			string text = ((num > 0) ? Blockers(result) : string.Empty);
			switch (num)
			{
			case 0:
			{
				string text2 = Text(result, "reason");
				return (text2.Length > 0) ? text2 : "Nothing needed resetting";
			}
			case 1:
			{
				if (ParseBlocker(text, out var what, out var _) && what.Length > 0)
				{
					return "Blocked by " + what;
				}
				if (text.Length != 0)
				{
					break;
				}
				return "Blocked by 1 chunk";
			}
			}
			return (text.Length > 0) ? ("Blocked by\n" + text) : $"Blocked by {num} chunks";
		}

		private static string Blockers(Dictionary<string, object> result)
		{
			if (result == null || !result.TryGetValue("zones", out var value))
			{
				return string.Empty;
			}
			if (!(value is IEnumerable enumerable))
			{
				return string.Empty;
			}
			List<string> list = new List<string>();
			try
			{
				foreach (object item in enumerable)
				{
					if (!(item is IDictionary dictionary) || !dictionary.Contains("skipReason"))
					{
						continue;
					}
					object obj = dictionary["skipReason"];
					if (obj == null)
					{
						continue;
					}
					string text = obj.ToString().Trim();
					if (text.Length != 0 && !list.Contains(text))
					{
						list.Add(text);
						if (list.Count == 10)
						{
							break;
						}
					}
				}
			}
			catch (Exception)
			{
				return string.Empty;
			}
			return string.Join("\n", list.ToArray());
		}

		private static bool ParseBlocker(string reason, out string what, out Vector3 where)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			what = string.Empty;
			where = Vector3.zero;
			if (string.IsNullOrEmpty(reason))
			{
				return false;
			}
			int num = reason.IndexOf('\'');
			int num2 = ((num >= 0) ? reason.IndexOf('\'', num + 1) : (-1));
			if (num >= 0 && num2 > num)
			{
				what = reason.Substring(num + 1, num2 - num - 1);
			}
			if (Coord(reason, "x=", out var value) && Coord(reason, "z=", out var value2))
			{
				where = new Vector3(value, 0f, value2);
			}
			return what.Length > 0 || where != Vector3.zero;
		}

		private static bool Coord(string text, string tag, out float value)
		{
			value = 0f;
			int num = text.IndexOf(tag, StringComparison.Ordinal);
			if (num < 0)
			{
				return false;
			}
			int num2 = num + tag.Length;
			int i;
			for (i = num2; i < text.Length && (char.IsDigit(text[i]) || text[i] == '-' || text[i] == '.'); i++)
			{
			}
			if (i == num2)
			{
				return false;
			}
			return float.TryParse(text.Substring(num2, i - num2), NumberStyles.Float, CultureInfo.InvariantCulture, out value);
		}

		private static bool Flag(Dictionary<string, object> result, string key)
		{
			if (result == null || !result.TryGetValue(key, out var value) || value == null)
			{
				return false;
			}
			try
			{
				return Convert.ToBoolean(value);
			}
			catch (Exception)
			{
				return false;
			}
		}

		private static int Count(Dictionary<string, object> result, string key)
		{
			return (int)Number(result, key, 0.0);
		}

		private static double Number(Dictionary<string, object> result, string key, double fallback)
		{
			if (result == null || !result.TryGetValue(key, out var value) || value == null)
			{
				return fallback;
			}
			try
			{
				return Convert.ToDouble(value);
			}
			catch (Exception)
			{
				return fallback;
			}
		}

		private static string Text(Dictionary<string, object> result, string key)
		{
			if (result == null || !result.TryGetValue(key, out var value) || value == null)
			{
				return string.Empty;
			}
			return value.ToString();
		}
	}
	[BepInPlugin("Leslie.ValheimResetNow", "ValheimResetNow", "0.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class ValheimResetNow : BaseUnityPlugin
	{
		public const string PluginGUID = "Leslie.ValheimResetNow";

		public const string PluginName = "ValheimResetNow";

		public const string PluginVersion = "0.1.0";

		internal static ValheimResetNow Instance;

		private void Awake()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			new VRNConfig(((BaseUnityPlugin)this).Config);
			BossStone.Register();
			new Harmony("Leslie.ValheimResetNow").PatchAll();
			SceneManager.sceneUnloaded += delegate
			{
				BossStonePlacement.Reset();
				BossStonePlacement.BossStoneSweep.Reset();
				BossStoneReset.Reset();
				StoneRelay.Reset();
				RenewalEffects.Reset();
				CharacterResetLog.Unload();
			};
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ValheimResetNow v0.1.0 loaded");
		}
	}
	internal class VRNConfig
	{
		public static ConfigFile cfg;

		private const string SectionStone = "CryptStone";

		private const string SectionReset = "CryptStone.Reset";

		internal static ConfigEntry<KeyCode> TakeTrophyKey;

		internal static ConfigEntry<bool> AllowForceScheduledReset;

		internal static ConfigEntry<bool> AlwaysAllowTrophyResets;

		internal const float ResetSearchRadius = 64f;

		internal const float ResetDelaySeconds = 3f;

		internal const float SealSeconds = 20f;

		internal const float ReadIntervalSeconds = 60f;

		public VRNConfig(ConfigFile cf)
		{
			cfg = cf;
			cfg.SaveOnConfigSet = true;
			CreateConfigValues(cf);
			SetupMainFileWatcher();
		}

		internal static void SetupMainFileWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher();
			fileSystemWatcher.NotifyFilter = NotifyFilters.LastWrite;
			fileSystemWatcher.Path = Path.GetDirectoryName(cfg.ConfigFilePath);
			fileSystemWatcher.Filter = Path.GetFileName(cfg.ConfigFilePath);
			fileSystemWatcher.Changed += OnConfigFileChanged;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private static void OnConfigFileChanged(object sender, FileSystemEventArgs e)
		{
			if (File.Exists(cfg.ConfigFilePath))
			{
				cfg.Reload();
			}
		}

		public static ConfigEntry<T> BindServerConfig<T>(string category, string key, T value, string description)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			return cfg.Bind<T>(category, key, value, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
		}

		public static ConfigEntry<T> BindClientConfig<T>(string category, string key, T value, string description)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			return cfg.Bind<T>(category, key, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}

		private void CreateConfigValues(ConfigFile config)
		{
			TakeTrophyKey = BindClientConfig<KeyCode>("CryptStone", "TakeTrophyKey", (KeyCode)308, "Key to take trophy");
			AllowForceScheduledReset = BindServerConfig("CryptStone.Reset", "AllowForceScheduledReset", value: true, "Flag to allow forcing scheduled resets that are ready.");
			AlwaysAllowTrophyResets = BindServerConfig("CryptStone.Reset", "AlwaysAllowTrophyResets", value: false, "Always allow trophy resets.");
		}
	}
}