Decompiled source of World Advancement Progression v0.2.11

Plugins/VentureValheim.Progression.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("VentureValheim.Progression")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("VentureValheim.Progression")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("C7C3AE76-5385-4FCC-B89C-88205DFE26C7")]
[assembly: AssemblyFileVersion("0.2.11")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.2.11.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace VentureValheim.Progression
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.orianaventure.mod.WorldAdvancementProgression", "WorldAdvancementProgression", "0.2.11")]
	public class ProgressionPlugin : BaseUnityPlugin
	{
		private static readonly ProgressionPlugin _instance;

		private const string ModName = "WorldAdvancementProgression";

		private const string ModVersion = "0.2.11";

		private const string Author = "com.orianaventure.mod";

		private const string ModGUID = "com.orianaventure.mod.WorldAdvancementProgression";

		private static string ConfigFileName;

		private static string ConfigFileFullPath;

		private readonly Harmony HarmonyInstance = new Harmony("com.orianaventure.mod.WorldAdvancementProgression");

		public static readonly ManualLogSource VentureProgressionLogger;

		public static ConfigEntry<bool> CE_BlockAllGlobalKeys;

		public static ConfigEntry<string> CE_BlockedGlobalKeys;

		public static ConfigEntry<string> CE_AllowedGlobalKeys;

		public static ConfigEntry<string> CE_EnforcedGlobalKeys;

		public static ConfigEntry<bool> CE_UsePrivateKeys;

		public static ConfigEntry<string> CE_BlockedPrivateKeys;

		public static ConfigEntry<string> CE_AllowedPrivateKeys;

		public static ConfigEntry<string> CE_EnforcedPrivateKeys;

		public static ConfigEntry<bool> CE_AdminBypass;

		public static ConfigEntry<bool> CE_UseBlockedActionMessage;

		public static ConfigEntry<string> CE_BlockedActionMessage;

		public static ConfigEntry<bool> CE_UseBlockedActionEffect;

		public static ConfigEntry<bool> CE_LockTaming;

		public static ConfigEntry<string> CE_OverrideLockTamingDefaults;

		public static ConfigEntry<bool> CE_LockGuardianPower;

		public static ConfigEntry<bool> CE_LockBossSummons;

		public static ConfigEntry<string> CE_OverrideLockBossSummonsDefaults;

		public static ConfigEntry<bool> CE_UnlockBossSummonsOverTime;

		public static ConfigEntry<int> CE_UnlockBossSummonsTime;

		public static ConfigEntry<bool> CE_LockEquipment;

		public static ConfigEntry<bool> CE_LockCrafting;

		public static ConfigEntry<bool> CE_LockBuilding;

		public static ConfigEntry<bool> CE_LockCooking;

		public static ConfigEntry<string> CE_LockPortalsKey;

		public static ConfigEntry<bool> CE_EnableSkillManager;

		public static ConfigEntry<bool> CE_AllowSkillDrain;

		public static ConfigEntry<bool> CE_UseAbsoluteSkillDrain;

		public static ConfigEntry<int> CE_AbsoluteSkillDrain;

		public static ConfigEntry<bool> CE_CompareAndSelectDrain;

		public static ConfigEntry<bool> CE_CompareUseMinimumDrain;

		public static ConfigEntry<bool> CE_OverrideMaximumSkillLevel;

		public static ConfigEntry<int> CE_MaximumSkillLevel;

		public static ConfigEntry<bool> CE_OverrideMinimumSkillLevel;

		public static ConfigEntry<int> CE_MinimumSkillLevel;

		public static ConfigEntry<bool> CE_UseBossKeysForSkillLevel;

		public static ConfigEntry<int> CE_BossKeysSkillPerKey;

		public static ConfigEntry<bool> CE_UnlockAllHaldorItems;

		public static ConfigEntry<string> CE_HelmetYuleKey;

		public static ConfigEntry<string> CE_HelmetDvergerKey;

		public static ConfigEntry<string> CE_BeltStrengthKey;

		public static ConfigEntry<string> CE_YmirRemainsKey;

		public static ConfigEntry<string> CE_FishingRodKey;

		public static ConfigEntry<string> CE_FishingBaitKey;

		public static ConfigEntry<string> CE_ThunderstoneKey;

		public static ConfigEntry<string> CE_ChickenEggKey;

		public static ConfigEntry<bool> CE_UnlockAllHildirItems;

		public static ConfigEntry<string> CE_CryptItemsKey;

		public static ConfigEntry<string> CE_CaveItemsKey;

		public static ConfigEntry<string> CE_TowerItemsKey;

		public static ConfigEntry<bool> CE_UsePrivateRaids;

		private readonly ConfigurationManagerAttributes AdminConfig = new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		};

		private readonly ConfigurationManagerAttributes ClientConfig = new ConfigurationManagerAttributes
		{
			IsAdminOnly = false
		};

		private DateTime _lastReloadTime;

		private const long RELOAD_DELAY = 10000000L;

		public static ProgressionPlugin Instance => _instance;

		static ProgressionPlugin()
		{
			_instance = new ProgressionPlugin();
			ConfigFileName = "com.orianaventure.mod.WorldAdvancementProgression.cfg";
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			VentureProgressionLogger = Logger.CreateLogSource("WorldAdvancementProgression");
			CE_BlockAllGlobalKeys = null;
			CE_BlockedGlobalKeys = null;
			CE_AllowedGlobalKeys = null;
			CE_EnforcedGlobalKeys = null;
			CE_UsePrivateKeys = null;
			CE_BlockedPrivateKeys = null;
			CE_AllowedPrivateKeys = null;
			CE_EnforcedPrivateKeys = null;
			CE_AdminBypass = null;
			CE_UseBlockedActionMessage = null;
			CE_BlockedActionMessage = null;
			CE_UseBlockedActionEffect = null;
			CE_LockTaming = null;
			CE_OverrideLockTamingDefaults = null;
			CE_LockGuardianPower = null;
			CE_LockBossSummons = null;
			CE_OverrideLockBossSummonsDefaults = null;
			CE_UnlockBossSummonsOverTime = null;
			CE_UnlockBossSummonsTime = null;
			CE_LockEquipment = null;
			CE_LockCrafting = null;
			CE_LockBuilding = null;
			CE_LockCooking = null;
			CE_LockPortalsKey = null;
			CE_EnableSkillManager = null;
			CE_AllowSkillDrain = null;
			CE_UseAbsoluteSkillDrain = null;
			CE_AbsoluteSkillDrain = null;
			CE_CompareAndSelectDrain = null;
			CE_CompareUseMinimumDrain = null;
			CE_OverrideMaximumSkillLevel = null;
			CE_MaximumSkillLevel = null;
			CE_OverrideMinimumSkillLevel = null;
			CE_MinimumSkillLevel = null;
			CE_UseBossKeysForSkillLevel = null;
			CE_BossKeysSkillPerKey = null;
			CE_UnlockAllHaldorItems = null;
			CE_HelmetYuleKey = null;
			CE_HelmetDvergerKey = null;
			CE_BeltStrengthKey = null;
			CE_YmirRemainsKey = null;
			CE_FishingRodKey = null;
			CE_FishingBaitKey = null;
			CE_ThunderstoneKey = null;
			CE_ChickenEggKey = null;
			CE_UnlockAllHildirItems = null;
			CE_CryptItemsKey = null;
			CE_CaveItemsKey = null;
			CE_TowerItemsKey = null;
			CE_UsePrivateRaids = null;
		}

		private ProgressionPlugin()
		{
		}//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Expected O, but got Unknown
		//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_0022: Expected O, but got Unknown
		//IL_0023: 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)
		//IL_0034: Expected O, but got Unknown


		private void AddConfig<T>(string key, string section, string description, bool synced, T value, ref ConfigEntry<T> configEntry)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			string extendedDescription = GetExtendedDescription(description, synced);
			configEntry = ((BaseUnityPlugin)this).Config.Bind<T>(section, key, value, new ConfigDescription(extendedDescription, (AcceptableValueBase)null, new object[1] { synced ? AdminConfig : ClientConfig }));
		}

		public string GetExtendedDescription(string description, bool synchronizedSetting)
		{
			return description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]");
		}

		public void Awake()
		{
			AddConfig("BlockAllGlobalKeys", "Keys", "True to stop all global keys from being added to the global list (boolean).", synced: true, value: true, ref CE_BlockAllGlobalKeys);
			AddConfig("BlockedGlobalKeys", "Keys", "Stop only these keys being added to the global list when BlockAllGlobalKeys is false (comma-separated).", synced: true, "", ref CE_BlockedGlobalKeys);
			AddConfig("AllowedGlobalKeys", "Keys", "Allow only these keys being added to the global list when BlockAllGlobalKeys is true (comma-separated).", synced: true, "", ref CE_AllowedGlobalKeys);
			AddConfig("EnforcedGlobalKeys", "Keys", "Always add these keys to the global list on startup (comma-separated).", synced: true, "", ref CE_EnforcedGlobalKeys);
			AddConfig("UsePrivateKeys", "Keys", "True to use private player keys to control game behavior (boolean).", synced: true, value: true, ref CE_UsePrivateKeys);
			AddConfig("BlockedPrivateKeys", "Keys", "Stop only these keys being added to the player's key list when UsePrivateKeys is true (comma-separated).", synced: true, "", ref CE_BlockedPrivateKeys);
			AddConfig("AllowedPrivateKeys", "Keys", "Allow only these keys being added to the player's key list when UsePrivateKeys is true (comma-separated).", synced: true, "", ref CE_AllowedPrivateKeys);
			AddConfig("EnforcedPrivateKeys", "Keys", "Always add these keys to the player's private list on startup (comma-separated).", synced: true, "", ref CE_EnforcedPrivateKeys);
			AddConfig("AdminBypass", "Locking", "True to allow admins to bypass locking settings (boolean)", synced: true, value: false, ref CE_AdminBypass);
			AddConfig("UseBlockedActionMessage", "Locking", "True to enable the blocked display message used in this mod (string).", synced: true, value: true, ref CE_UseBlockedActionMessage);
			AddConfig("BlockedActionMessage", "Locking", "Generic blocked display message used in this mod (string).", synced: true, "The Gods Reject You", ref CE_BlockedActionMessage);
			AddConfig("UseBlockedActionEffect", "Locking", "True to enable the blocked display effect (fire) used in this mod (string).", synced: true, value: true, ref CE_UseBlockedActionEffect);
			AddConfig("LockTaming", "Locking", "True to lock the ability to tame creatures based on keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: false, ref CE_LockTaming);
			AddConfig("OverrideLockTamingDefaults", "Locking", "Override keys needed to Tame creatures. Leave blank to use defaults (comma-separated prefab,key pairs).", synced: true, "", ref CE_OverrideLockTamingDefaults);
			AddConfig("LockGuardianPower", "Locking", "True to lock the ability to get and use guardian powers based on keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockGuardianPower);
			AddConfig("LockBossSummons", "Locking", "True to lock the ability to spawn bosses based on keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockBossSummons);
			AddConfig("OverrideLockBossSummonsDefaults", "Locking", "Override keys needed to summon bosses. Leave blank to use defaults (comma-separated prefab,key pairs).", synced: true, "", ref CE_OverrideLockBossSummonsDefaults);
			AddConfig("UnlockBossSummonsOverTime", "Locking", "True to unlock the ability to spawn bosses based on in-game days passed when LockBossSummons is True (boolean).", synced: true, value: false, ref CE_UnlockBossSummonsOverTime);
			AddConfig("UnlockBossSummonsTime", "Locking", "Number of in-game days required to unlock the next boss in the sequence when UnlockBossSummonsOverTime is True (int).", synced: true, 100, ref CE_UnlockBossSummonsTime);
			AddConfig("LockEquipment", "Locking", "True to lock the ability to equip or use boss items or items made from biome metals/materials based on keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockEquipment);
			AddConfig("LockCrafting", "Locking", "True to lock the ability to craft items based on boss items and biome metals/materials and keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockCrafting);
			AddConfig("LockBuilding", "Locking", "True to lock the ability to build based on boss items and biome metals/materials and keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockBuilding);
			AddConfig("LockCooking", "Locking", "True to lock the ability to cook with biome food materials based on keys. Uses private key if enabled, global key if not (boolean).", synced: true, value: true, ref CE_LockCooking);
			AddConfig("LockPortalsKey", "Locking", "Use this key to control player ability to use portals (ex: defeated_eikthyr). Leave blank to allow vanilla portal behavior (string).", synced: true, "", ref CE_LockPortalsKey);
			AddConfig("EnableSkillManager", "Skills", "Enable the Skill Manager feature (boolean).", synced: true, value: true, ref CE_EnableSkillManager);
			AddConfig("AllowSkillDrain", "Skills", "Enable skill drain on death (boolean).", synced: true, value: true, ref CE_AllowSkillDrain);
			AddConfig("UseAbsoluteSkillDrain", "Skills", "Reduce skills by a set number of levels (boolean).", synced: true, value: false, ref CE_UseAbsoluteSkillDrain);
			AddConfig("AbsoluteSkillDrain", "Skills", "The number of levels (When UseAbsoluteSkillDrain is true) (int).", synced: true, 1, ref CE_AbsoluteSkillDrain);
			AddConfig("CompareAndSelectDrain", "Skills", "Enable comparing skill drain original vs absolute value (When UseAbsoluteSkillDrain is true) (boolean).", synced: true, value: false, ref CE_CompareAndSelectDrain);
			AddConfig("CompareUseMinimumDrain", "Skills", "True to use the smaller value (When CompareAndSelectDrain is true) (boolean).", synced: true, value: true, ref CE_CompareUseMinimumDrain);
			AddConfig("OverrideMaximumSkillLevel", "Skills", "Override the maximum (ceiling) skill level for all skill gain (boolean).", synced: true, value: false, ref CE_OverrideMaximumSkillLevel);
			AddConfig("MaximumSkillLevel", "Skills", "If overridden, the maximum (ceiling) skill level for all skill gain (int).", synced: true, 100, ref CE_MaximumSkillLevel);
			AddConfig("OverrideMinimumSkillLevel", "Skills", "Override the minimum (floor) skill level for all skill loss (boolean).", synced: true, value: false, ref CE_OverrideMinimumSkillLevel);
			AddConfig("MinimumSkillLevel", "Skills", "If overridden, the minimum (floor) skill level for all skill loss (int).", synced: true, 0, ref CE_MinimumSkillLevel);
			AddConfig("UseBossKeysForSkillLevel", "Skills", "True to use unlocked boss keys to control skill floor/ceiling values (boolean).", synced: true, value: false, ref CE_UseBossKeysForSkillLevel);
			AddConfig("BossKeysSkillPerKey", "Skills", "Skill drain floor and skill gain ceiling increased this amount per boss defeated (boolean).", synced: true, 10, ref CE_BossKeysSkillPerKey);
			AddConfig("UnlockAllHaldorItems", "Trader", "True to remove the key check from Haldor entirely and unlock all items (boolean).", synced: true, value: false, ref CE_UnlockAllHaldorItems);
			AddConfig("HelmetYuleKey", "Trader", "Custom key for unlocking the Yule Hat. Leave blank to use default (string).", synced: true, "", ref CE_HelmetYuleKey);
			AddConfig("HelmetDvergerKey", "Trader", "Custom key for unlocking the Dverger Circlet. Leave blank to use default (string).", synced: true, "", ref CE_HelmetDvergerKey);
			AddConfig("BeltStrengthKey", "Trader", "Custom key for unlocking the Megingjord. Leave blank to use default (string).", synced: true, "", ref CE_BeltStrengthKey);
			AddConfig("YmirRemainsKey", "Trader", "Custom key for unlocking Ymir Flesh. Leave blank to use default (string).", synced: true, "", ref CE_YmirRemainsKey);
			AddConfig("FishingRodKey", "Trader", "Custom key for unlocking the Fishing Rod. Leave blank to use default (string).", synced: true, "", ref CE_FishingRodKey);
			AddConfig("FishingBaitKey", "Trader", "Custom key for unlocking Fishing Bait. Leave blank to use default (string).", synced: true, "", ref CE_FishingBaitKey);
			AddConfig("ThunderstoneKey", "Trader", "Custom key for unlocking the Thunder Stone. Leave blank to use default (string).", synced: true, "", ref CE_ThunderstoneKey);
			AddConfig("ChickenEggKey", "Trader", "Custom key for unlocking the Egg. Leave blank to use default (string).", synced: true, "", ref CE_ChickenEggKey);
			AddConfig("UnlockAllHildirItems", "Hildir", "True to remove the key check from Hildir entirely and unlock all items (boolean).", synced: true, value: false, ref CE_UnlockAllHildirItems);
			AddConfig("CryptItemsKey", "Hildir", "Custom key for unlocking the Crypt Dungeon items. Leave blank to use default (string).", synced: true, "", ref CE_CryptItemsKey);
			AddConfig("CaveItemsKey", "Hildir", "Custom key for unlocking the Cave Dungeon items. Leave blank to use default (string).", synced: true, "", ref CE_CaveItemsKey);
			AddConfig("TowerItemsKey", "Hildir", "Custom key for unlocking the Tower Dungeon items. Leave blank to use default (string).", synced: true, "", ref CE_TowerItemsKey);
			AddConfig("UsePrivateRaids", "Raids", "True to use this mod's raids feature when using private keys (bool).", synced: true, value: true, ref CE_UsePrivateRaids);
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			HarmonyInstance.PatchAll(executingAssembly);
			SetupWatcher();
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		private void SetupWatcher()
		{
			_lastReloadTime = DateTime.Now;
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName);
			fileSystemWatcher.Changed += ReadConfigValues;
			fileSystemWatcher.Created += ReadConfigValues;
			fileSystemWatcher.Renamed += ReadConfigValues;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			DateTime now = DateTime.Now;
			long num = now.Ticks - _lastReloadTime.Ticks;
			if (File.Exists(ConfigFileFullPath) && num >= 10000000)
			{
				try
				{
					VentureProgressionLogger.LogInfo((object)"Attempting to reload configuration...");
					((BaseUnityPlugin)this).Config.Reload();
				}
				catch
				{
					VentureProgressionLogger.LogError((object)("There was an issue loading " + ConfigFileName));
					return;
				}
				_lastReloadTime = now;
				KeyManager.Instance.UpdateConfigurations();
			}
		}
	}
	public interface IProgressionConfiguration
	{
		bool GetBlockAllGlobalKeys();

		string GetBlockedGlobalKeys();

		string GetAllowedGlobalKeys();

		string GetEnforcedGlobalKeys();

		bool GetUsePrivateKeys();

		string GetBlockedPrivateKeys();

		string GetAllowedPrivateKeys();

		string GetEnforcedPrivateKeys();

		bool GetAdminBypass();

		bool GetUseBlockedActionMessage();

		string GetBlockedActionMessage();

		bool GetUseBlockedActionEffect();

		bool GetLockTaming();

		string GetOverrideLockTamingDefaults();

		bool GetLockGuardianPower();

		bool GetLockBossSummons();

		string GetOverrideLockBossSummonsDefaults();

		bool GetUnlockBossSummonsOverTime();

		int GetUnlockBossSummonsTime();

		bool GetLockEquipment();

		bool GetLockCrafting();

		bool GetLockBuilding();

		bool GetLockCooking();

		string GetLockPortalsKey();

		bool GetEnableSkillManager();

		bool GetAllowSkillDrain();

		bool GetUseAbsoluteSkillDrain();

		int GetAbsoluteSkillDrain();

		bool GetCompareAndSelectDrain();

		bool GetCompareUseMinimumDrain();

		bool GetOverrideMaximumSkillLevel();

		int GetMaximumSkillLevel();

		bool GetOverrideMinimumSkillLevel();

		int GetMinimumSkillLevel();

		bool GetUseBossKeysForSkillLevel();

		int GetBossKeysSkillPerKey();

		bool GetUnlockAllHaldorItems();

		string GetHelmetYuleKey();

		string GetHelmetDvergerKey();

		string GetBeltStrengthKey();

		string GetYmirRemainsKey();

		string GetFishingRodKey();

		string GetFishingBaitKey();

		string GetThunderstoneKey();

		string GetChickenEggKey();

		bool GetUnlockAllHildirItems();

		string GetCryptItemsKey();

		string GetCaveItemsKey();

		string GetTowerItemsKey();

		bool GetUsePrivateRaids();
	}
	public class ProgressionConfiguration : IProgressionConfiguration
	{
		private static IProgressionConfiguration _instance;

		public static IProgressionConfiguration Instance => _instance;

		static ProgressionConfiguration()
		{
			_instance = new ProgressionConfiguration();
		}

		public ProgressionConfiguration()
		{
		}

		public ProgressionConfiguration(IProgressionConfiguration progressionConfiguration)
		{
			_instance = progressionConfiguration;
		}

		public bool GetBlockAllGlobalKeys()
		{
			return ProgressionPlugin.CE_BlockAllGlobalKeys.Value;
		}

		public string GetBlockedGlobalKeys()
		{
			return ProgressionPlugin.CE_BlockedGlobalKeys.Value;
		}

		public string GetAllowedGlobalKeys()
		{
			return ProgressionPlugin.CE_AllowedGlobalKeys.Value;
		}

		public string GetEnforcedGlobalKeys()
		{
			return ProgressionPlugin.CE_EnforcedGlobalKeys.Value;
		}

		public bool GetUsePrivateKeys()
		{
			return ProgressionPlugin.CE_UsePrivateKeys.Value;
		}

		public string GetBlockedPrivateKeys()
		{
			return ProgressionPlugin.CE_BlockedPrivateKeys.Value;
		}

		public string GetAllowedPrivateKeys()
		{
			return ProgressionPlugin.CE_AllowedPrivateKeys.Value;
		}

		public string GetEnforcedPrivateKeys()
		{
			return ProgressionPlugin.CE_EnforcedPrivateKeys.Value;
		}

		public bool GetAdminBypass()
		{
			return ProgressionPlugin.CE_AdminBypass.Value;
		}

		public bool GetUseBlockedActionMessage()
		{
			return ProgressionPlugin.CE_UseBlockedActionMessage.Value;
		}

		public string GetBlockedActionMessage()
		{
			return ProgressionPlugin.CE_BlockedActionMessage.Value;
		}

		public bool GetUseBlockedActionEffect()
		{
			return ProgressionPlugin.CE_UseBlockedActionEffect.Value;
		}

		public bool GetLockTaming()
		{
			if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin)
			{
				return false;
			}
			return ProgressionPlugin.CE_LockTaming.Value;
		}

		public string GetOverrideLockTamingDefaults()
		{
			return ProgressionPlugin.CE_OverrideLockTamingDefaults.Value;
		}

		public bool GetLockGuardianPower()
		{
			if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin)
			{
				return false;
			}
			return ProgressionPlugin.CE_LockGuardianPower.Value;
		}

		public bool GetLockBossSummons()
		{
			if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin)
			{
				return false;
			}
			return ProgressionPlugin.CE_LockBossSummons.Value;
		}

		public string GetOverrideLockBossSummonsDefaults()
		{
			return ProgressionPlugin.CE_OverrideLockBossSummonsDefaults.Value;
		}

		public bool GetUnlockBossSummonsOverTime()
		{
			return ProgressionPlugin.CE_UnlockBossSummonsOverTime.Value;
		}

		public int GetUnlockBossSummonsTime()
		{
			return ProgressionPlugin.CE_UnlockBossSummonsTime.Value;
		}

		public bool GetLockEquipment()
		{
			if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin)
			{
				return false;
			}
			return ProgressionPlugin.CE_LockEquipment.Value;
		}

		public bool GetLockCrafting()
		{
			if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin)
			{
				return false;
			}
			return ProgressionPlugin.CE_LockCrafting.Value;
		}

		public bool GetLockBuilding()
		{
			if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin)
			{
				return false;
			}
			return ProgressionPlugin.CE_LockBuilding.Value;
		}

		public bool GetLockCooking()
		{
			if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin)
			{
				return false;
			}
			return ProgressionPlugin.CE_LockCooking.Value;
		}

		public string GetLockPortalsKey()
		{
			if (Instance.GetAdminBypass() && SynchronizationManager.Instance.PlayerIsAdmin)
			{
				return "";
			}
			return ProgressionPlugin.CE_LockPortalsKey.Value;
		}

		public bool GetEnableSkillManager()
		{
			return ProgressionPlugin.CE_EnableSkillManager.Value;
		}

		public bool GetAllowSkillDrain()
		{
			return ProgressionPlugin.CE_AllowSkillDrain.Value;
		}

		public bool GetUseAbsoluteSkillDrain()
		{
			return ProgressionPlugin.CE_UseAbsoluteSkillDrain.Value;
		}

		public int GetAbsoluteSkillDrain()
		{
			return ProgressionPlugin.CE_AbsoluteSkillDrain.Value;
		}

		public bool GetCompareAndSelectDrain()
		{
			return ProgressionPlugin.CE_CompareAndSelectDrain.Value;
		}

		public bool GetCompareUseMinimumDrain()
		{
			return ProgressionPlugin.CE_CompareUseMinimumDrain.Value;
		}

		public bool GetOverrideMaximumSkillLevel()
		{
			return ProgressionPlugin.CE_OverrideMaximumSkillLevel.Value;
		}

		public int GetMaximumSkillLevel()
		{
			return ProgressionPlugin.CE_MaximumSkillLevel.Value;
		}

		public bool GetOverrideMinimumSkillLevel()
		{
			return ProgressionPlugin.CE_OverrideMinimumSkillLevel.Value;
		}

		public int GetMinimumSkillLevel()
		{
			return ProgressionPlugin.CE_MinimumSkillLevel.Value;
		}

		public bool GetUseBossKeysForSkillLevel()
		{
			return ProgressionPlugin.CE_UseBossKeysForSkillLevel.Value;
		}

		public int GetBossKeysSkillPerKey()
		{
			return ProgressionPlugin.CE_BossKeysSkillPerKey.Value;
		}

		public bool GetUnlockAllHaldorItems()
		{
			return ProgressionPlugin.CE_UnlockAllHaldorItems.Value;
		}

		public string GetHelmetYuleKey()
		{
			return ProgressionPlugin.CE_HelmetYuleKey.Value;
		}

		public string GetHelmetDvergerKey()
		{
			return ProgressionPlugin.CE_HelmetDvergerKey.Value;
		}

		public string GetBeltStrengthKey()
		{
			return ProgressionPlugin.CE_BeltStrengthKey.Value;
		}

		public string GetYmirRemainsKey()
		{
			return ProgressionPlugin.CE_YmirRemainsKey.Value;
		}

		public string GetFishingRodKey()
		{
			return ProgressionPlugin.CE_FishingRodKey.Value;
		}

		public string GetFishingBaitKey()
		{
			return ProgressionPlugin.CE_FishingBaitKey.Value;
		}

		public string GetThunderstoneKey()
		{
			return ProgressionPlugin.CE_ThunderstoneKey.Value;
		}

		public string GetChickenEggKey()
		{
			return ProgressionPlugin.CE_ChickenEggKey.Value;
		}

		public bool GetUnlockAllHildirItems()
		{
			return ProgressionPlugin.CE_UnlockAllHildirItems.Value;
		}

		public string GetCryptItemsKey()
		{
			return ProgressionPlugin.CE_CryptItemsKey.Value;
		}

		public string GetCaveItemsKey()
		{
			return ProgressionPlugin.CE_CaveItemsKey.Value;
		}

		public string GetTowerItemsKey()
		{
			return ProgressionPlugin.CE_TowerItemsKey.Value;
		}

		public bool GetUsePrivateRaids()
		{
			return ProgressionPlugin.CE_UsePrivateRaids.Value;
		}
	}
	public class KeyManager : IKeyManager
	{
		[HarmonyPatch(typeof(Tameable), "DecreaseRemainingTime")]
		public static class Patch_Tameable_DecreaseRemainingTime
		{
			[HarmonyPriority(200)]
			private static void Prefix(Tameable __instance, ref float time)
			{
				if (ProgressionConfiguration.Instance.GetLockTaming() && ((Object)(object)__instance.m_character == (Object)null || !Instance.HasTamingKey(Utils.GetPrefabName(((Component)__instance.m_character).gameObject))))
				{
					time = 0f;
				}
			}
		}

		[HarmonyPatch(typeof(ItemStand), "DelayedPowerActivation")]
		public static class Patch_ItemStand_DelayedPowerActivation
		{
			[HarmonyPriority(200)]
			private static bool Prefix(ItemStand __instance)
			{
				if (ProgressionConfiguration.Instance.GetLockGuardianPower())
				{
					KeyManager instance = Instance;
					StatusEffect guardianPower = __instance.m_guardianPower;
					if (!instance.HasGuardianKey((guardianPower != null) ? ((Object)guardianPower).name : null))
					{
						Instance.ApplyBlockedActionEffects(Player.m_localPlayer);
						return false;
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Player), "ActivateGuardianPower")]
		public static class Patch_Player_ActivateGuardianPower
		{
			[HarmonyPriority(200)]
			private static bool Prefix(Player __instance, ref bool __result, ref bool __runOriginal)
			{
				if (!__runOriginal)
				{
					return false;
				}
				if (!Utility.IsNullOrWhiteSpace(__instance.m_guardianPower) && ProgressionConfiguration.Instance.GetLockGuardianPower() && !Instance.HasGuardianKey(__instance.m_guardianPower))
				{
					Instance.ApplyBlockedActionEffects(Player.m_localPlayer);
					__result = false;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(OfferingBowl), "InitiateSpawnBoss")]
		public static class Patch_OfferingBowl_InitiateSpawnBoss
		{
			[HarmonyPriority(200)]
			private static bool Prefix(OfferingBowl __instance)
			{
				if (ProgressionConfiguration.Instance.GetLockBossSummons() && (Object)(object)__instance.m_bossPrefab != (Object)null && !Instance.HasSummoningKey(Utils.GetPrefabName(__instance.m_bossPrefab.gameObject)))
				{
					Instance.ApplyBlockedActionEffects(Player.m_localPlayer);
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Humanoid), "EquipItem")]
		public static class Patch_Humanoid_EquipItem
		{
			[HarmonyPriority(200)]
			private static bool Prefix(Humanoid __instance, ref bool __result, ItemData item)
			{
				if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer)
				{
					return true;
				}
				if (ProgressionConfiguration.Instance.GetLockEquipment() && Instance.IsActionBlocked(item, item.m_quality, checkBossItems: true, checkMaterials: true, checkFood: false))
				{
					Instance.ApplyBlockedActionEffects(Player.m_localPlayer);
					__result = false;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Inventory), "GetAmmoItem")]
		public static class Patch_Inventory_GetAmmoItem
		{
			private static void Postfix(Inventory __instance, ref ItemData __result)
			{
				if (__instance == ((Humanoid)Player.m_localPlayer).GetInventory() && __result != null && ProgressionConfiguration.Instance.GetLockEquipment() && Instance.IsActionBlocked(__result, __result.m_quality, checkBossItems: true, checkMaterials: true, checkFood: false))
				{
					Instance.ApplyBlockedActionEffects(Player.m_localPlayer);
					__result = null;
				}
			}
		}

		[HarmonyPatch(typeof(Door), "HaveKey")]
		public static class Patch_Door_HaveKey
		{
			[HarmonyPriority(200)]
			private static void Postfix(Door __instance, ref bool __result)
			{
				if (__result && ProgressionConfiguration.Instance.GetLockEquipment() && (Object)(object)__instance.m_keyItem != (Object)null && !Instance.HasItemKey(Utils.GetPrefabName(((Component)__instance.m_keyItem).gameObject), checkBossItems: true, checkMaterials: false, checkFood: false))
				{
					Instance.ApplyBlockedActionEffects(Player.m_localPlayer);
					__result = false;
				}
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "DoCrafting")]
		public static class Patch_InventoryGui_DoCrafting
		{
			[HarmonyPriority(200)]
			private static bool Prefix(InventoryGui __instance)
			{
				bool lockCrafting = ProgressionConfiguration.Instance.GetLockCrafting();
				bool lockCooking = ProgressionConfiguration.Instance.GetLockCooking();
				int qualityLevel = ProgressionAPI.GetQualityLevel(__instance.m_craftUpgradeItem);
				if ((lockCrafting || lockCooking) && Instance.IsActionBlocked(__instance.m_craftRecipe, qualityLevel, lockCrafting, lockCrafting, lockCooking))
				{
					Instance.ApplyBlockedActionEffects(Player.m_localPlayer);
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Player), "PlacePiece")]
		public static class Patch_Player_PlacePiece
		{
			[HarmonyPriority(200)]
			private static bool Prefix(ref bool __result, Piece piece)
			{
				if (ProgressionConfiguration.Instance.GetLockBuilding() && piece?.m_resources != null)
				{
					for (int i = 0; i < piece.m_resources.Length; i++)
					{
						if ((Object)(object)piece.m_resources[i]?.m_resItem != (Object)null && !Instance.HasItemKey(Utils.GetPrefabName(((Component)piece.m_resources[i].m_resItem).gameObject), checkBossItems: true, checkMaterials: true, checkFood: false))
						{
							Instance.ApplyBlockedActionEffects(Player.m_localPlayer);
							__result = false;
							return false;
						}
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(CookingStation), "OnUseItem")]
		public static class Patch_CookingStation_OnUseItem
		{
			[HarmonyPriority(200)]
			private static bool Prefix(ItemData item, ref bool __result)
			{
				if (ProgressionConfiguration.Instance.GetLockCooking() && Instance.IsActionBlocked(item, item.m_quality, checkBossItems: false, checkMaterials: false, checkFood: true))
				{
					Instance.ApplyBlockedActionEffects(Player.m_localPlayer);
					__result = false;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(TeleportWorld), "Teleport")]
		public static class Patch_TeleportWorld_Teleport
		{
			private static bool Prefix(Player player)
			{
				if ((Object)(object)player == (Object)(object)Player.m_localPlayer && !Instance.HasKey(ProgressionConfiguration.Instance.GetLockPortalsKey()))
				{
					Instance.ApplyBlockedActionEffects(Player.m_localPlayer);
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(ZoneSystem), "SetGlobalKey", new Type[] { typeof(string) })]
		public static class Patch_ZoneSystem_SetGlobalKey
		{
			[HarmonyPriority(200)]
			private static bool Prefix(string name)
			{
				return Instance.SkipAddKeyMethod(name.ToLower());
			}

			private static void Postfix(string name)
			{
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				name = name.ToLower();
				if ((Object)(object)Player.m_localPlayer != (Object)null && !Instance.BlockPrivateKey(name))
				{
					List<Player> list = new List<Player>();
					Player.GetPlayersInRange(((Component)Player.m_localPlayer).transform.position, 100f, list);
					if (list != null && list.Count == 0)
					{
						ProgressionPlugin.VentureProgressionLogger.LogDebug((object)"No players in range to send key!");
						return;
					}
					for (int i = 0; i < list.Count; i++)
					{
						string playerName = list[i].GetPlayerName();
						ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Attempting to send private key: " + name + " to \"" + playerName + "\"."));
						Instance.SendPrivateKey(playerName, name);
					}
				}
				else
				{
					ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Skipping adding private key: " + name + "."));
				}
			}
		}

		[HarmonyPatch(typeof(ZoneSystem), "RPC_SetGlobalKey")]
		public static class Patch_ZoneSystem_RPC_SetGlobalKey
		{
			[HarmonyPriority(200)]
			private static bool Prefix(string name)
			{
				ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("RPC_SetGlobalKey called for: " + name + "."));
				bool num = Instance.SkipAddKeyMethod(name.ToLower());
				if (!num)
				{
					ZoneSystem.instance.SendGlobalKeys(ZRoutedRpc.Everybody);
				}
				return num;
			}
		}

		[HarmonyPatch(typeof(ZoneSystem), "GetGlobalKey", new Type[] { typeof(string) })]
		public static class Patch_ZoneSystem_GetGlobalKey
		{
			private static bool Prefix(string name, ref bool __result)
			{
				name = name.ToLower();
				if (ProgressionConfiguration.Instance.GetUsePrivateKeys() && !ZNet.instance.IsDedicated() && !Instance.IsWorldModifier(name))
				{
					__result = Instance.HasPrivateKey(name);
					return !__result;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(ZoneSystem), "GetGlobalKeys")]
		public static class Patch_ZoneSystem_GetGlobalKeys
		{
			private static void Postfix(ref List<string> __result)
			{
				if (ProgressionConfiguration.Instance.GetUsePrivateKeys() && !ZNet.instance.IsDedicated())
				{
					List<string> list = new List<string>(Instance.PrivateKeysList);
					__result = ProgressionAPI.MergeLists(__result, list);
				}
			}
		}

		[HarmonyPatch(typeof(ZoneSystem), "RPC_RemoveGlobalKey")]
		public static class Patch_ZoneSystem_RPC_RemoveGlobalKey
		{
			private static void Postfix(string name)
			{
				ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("RPC_RemoveGlobalKey called for: " + name + "."));
				if (ProgressionConfiguration.Instance.GetUsePrivateKeys() && !ZNet.instance.IsDedicated())
				{
					Instance.RemovePrivateKey(name);
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Save")]
		public static class Patch_Player_Save
		{
			private static void Prefix(Player __instance)
			{
				if (!ProgressionAPI.IsInTheMainScene())
				{
					Instance.ResetPlayer();
				}
				else if (__instance.m_customData.ContainsKey("VV_PrivateKeys"))
				{
					__instance.m_customData["VV_PrivateKeys"] = Instance.GetPrivateKeysString();
				}
				else
				{
					__instance.m_customData.Add("VV_PrivateKeys", Instance.GetPrivateKeysString());
				}
			}
		}

		[HarmonyPatch(typeof(Player), "EquipInventoryItems")]
		public static class Patch_Player_EquipInventoryItems
		{
			private static void Prefix(Player __instance)
			{
				if (!ProgressionAPI.IsInTheMainScene())
				{
					return;
				}
				ProgressionPlugin.VentureProgressionLogger.LogInfo((object)"Starting Player Key Management. Cleaning up private keys!");
				Instance.ResetPlayer();
				Instance.UpdateConfigurations();
				HashSet<string> hashSet = new HashSet<string>();
				if (__instance.m_customData.ContainsKey("VV_PrivateKeys"))
				{
					hashSet = ProgressionAPI.StringToSet(__instance.m_customData["VV_PrivateKeys"]);
				}
				foreach (string item in hashSet)
				{
					if (!Instance.BlockPrivateKey(item))
					{
						Instance.PrivateKeysList.Add(item);
					}
				}
				foreach (string enforcedPrivateKeys in Instance.EnforcedPrivateKeysList)
				{
					Instance.PrivateKeysList.Add(enforcedPrivateKeys);
				}
				try
				{
					ZRoutedRpc.instance.Register<string>("VV_SetPrivateKey", (Action<long, string>)Instance.RPC_SetPrivateKey);
					ZRoutedRpc.instance.Register<string>("VV_RemovePrivateKey", (Action<long, string>)Instance.RPC_RemovePrivateKey);
					ZRoutedRpc.instance.Register("VV_ResetPrivateKeys", (Action<long>)Instance.RPC_ResetPrivateKeys);
				}
				catch
				{
					ProgressionPlugin.VentureProgressionLogger.LogDebug((object)"Player RPCs have already been registered. Skipping.");
				}
				Instance.SendPrivateKeysToServer(Instance.PrivateKeysList);
			}
		}

		[HarmonyPatch(typeof(ZoneSystem), "Load")]
		public static class Patch_ZoneSystem_Load
		{
			private static void Postfix()
			{
				if (!ZNet.instance.IsServer())
				{
					return;
				}
				ProgressionPlugin.VentureProgressionLogger.LogInfo((object)"Starting Server Key Management. Cleaning up public keys!");
				Instance.ResetConfigurations();
				Instance.ResetServer();
				Instance.UpdateConfigurations();
				List<string> list = ProgressionAPI.GetGlobalKeys().ToList();
				bool blockAllGlobalKeys = ProgressionConfiguration.Instance.GetBlockAllGlobalKeys();
				for (int i = 0; i < list.Count; i++)
				{
					if (Instance.BlockGlobalKey(blockAllGlobalKeys, list[i]))
					{
						ZoneSystem.instance.m_globalKeys.Remove(list[i]);
					}
				}
				foreach (string enforcedGlobalKeys in Instance.EnforcedGlobalKeysList)
				{
					ZoneSystem.instance.m_globalKeys.Add(enforcedGlobalKeys);
				}
				if (ProgressionConfiguration.Instance.GetUsePrivateKeys())
				{
					ZoneSystem.instance.m_globalKeysEnums.Add((GlobalKeys)12);
				}
				try
				{
					ZRoutedRpc.instance.Register("VV_ServerListKeys", (Action<long>)Instance.RPC_ServerListKeys);
					ZRoutedRpc.instance.Register<string, long>("VV_ServerSetPrivateKeys", (Action<long, string, long>)Instance.RPC_ServerSetPrivateKeys);
					ZRoutedRpc.instance.Register<string, long>("VV_ServerSetPrivateKey", (Action<long, string, long>)Instance.RPC_ServerSetPrivateKey);
					ZRoutedRpc.instance.Register<string, long>("VV_ServerRemovePrivateKey", (Action<long, string, long>)Instance.RPC_ServerRemovePrivateKey);
					ZRoutedRpc.instance.Register<string>("VV_SetPrivateKey", (Action<long, string>)Instance.RPC_SetPrivateKey);
					ZRoutedRpc.instance.Register<string>("VV_RemovePrivateKey", (Action<long, string>)Instance.RPC_RemovePrivateKey);
					ZRoutedRpc.instance.Register("VV_ResetPrivateKeys", (Action<long>)Instance.RPC_ResetPrivateKeys);
				}
				catch
				{
					ProgressionPlugin.VentureProgressionLogger.LogDebug((object)"Server RPCs have already been registered. Skipping.");
				}
			}
		}

		[HarmonyPatch(typeof(Terminal), "InitTerminal")]
		private static class Patch_Terminal_InitTerminal
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static ConsoleEvent <>9__1_0;

				public static ConsoleEvent <>9__1_1;

				public static ConsoleEvent <>9__1_2;

				public static ConsoleEvent <>9__1_3;

				public static ConsoleEvent <>9__1_4;

				public static ConsoleEvent <>9__1_5;

				public static ConsoleEvent <>9__1_6;

				public static ConsoleEvent <>9__1_7;

				public static ConsoleEvent <>9__1_8;

				internal void <Postfix>b__1_0(ConsoleEventArgs args)
				{
					if (args.Length >= 2)
					{
						ProgressionAPI.AddGlobalKey(args[1]);
						args.Context.AddString("Setting global key " + args[1] + ".");
					}
					else
					{
						args.Context.AddString("Syntax: setglobalkey [key]");
					}
				}

				internal void <Postfix>b__1_1(ConsoleEventArgs args)
				{
					if (args.Length >= 2)
					{
						ProgressionAPI.RemoveGlobalKey(args[1]);
						args.Context.AddString("Removing global key " + args[1] + ".");
					}
					else
					{
						args.Context.AddString("Syntax: removeglobalkey [key]");
					}
				}

				internal void <Postfix>b__1_2(ConsoleEventArgs args)
				{
					HashSet<string> globalKeys = ProgressionAPI.GetGlobalKeys();
					args.Context.AddString($"Total Keys {globalKeys.Count}");
					foreach (string item in globalKeys)
					{
						args.Context.AddString(item);
					}
				}

				internal void <Postfix>b__1_3(ConsoleEventArgs args)
				{
					ZoneSystem.instance.ResetGlobalKeys();
				}

				internal void <Postfix>b__1_4(ConsoleEventArgs args)
				{
					if (args.Length >= 3)
					{
						string text = args[2];
						for (int i = 3; i < args.Length; i++)
						{
							text = text + " " + args[i];
						}
						Instance.AddPrivateKey(args[1], text);
						args.Context.AddString("Setting private key " + args[1] + " for player " + text + ".");
					}
					else if (args.Length == 2)
					{
						Instance.AddPrivateKey(args[1]);
						args.Context.AddString("Setting private key " + args[1] + ".");
					}
					else
					{
						args.Context.AddString("Syntax: setprivatekey [key]");
					}
				}

				internal void <Postfix>b__1_5(ConsoleEventArgs args)
				{
					if (args.Length >= 3)
					{
						string text = args[2];
						for (int i = 3; i < args.Length; i++)
						{
							text = text + " " + args[i];
						}
						Instance.RemovePrivateKey(args[1], text);
						args.Context.AddString("Removing private key " + args[1] + " for player " + text + ".");
					}
					else if (args.Length == 2)
					{
						Instance.RemovePrivateKey(args[1]);
						args.Context.AddString("Removing private key " + args[1] + ".");
					}
					else
					{
						args.Context.AddString("Syntax: removeprivatekey [key] [optional: player name]");
					}
				}

				internal void <Postfix>b__1_6(ConsoleEventArgs args)
				{
					if (args.Length >= 2)
					{
						string text = args[1];
						for (int i = 2; i < args.Length; i++)
						{
							text = text + " " + args[i];
						}
						Instance.ResetPrivateKeys(args[1]);
						args.Context.AddString("Private keys cleared for player " + text + ".");
					}
					else if (args.Length == 1)
					{
						Instance.ResetPrivateKeys();
						args.Context.AddString("Private keys cleared");
					}
					else
					{
						args.Context.AddString("Syntax: resetprivatekeys [optional: player name]");
					}
				}

				internal void <Postfix>b__1_7(ConsoleEventArgs args)
				{
					args.Context.AddString($"Total Keys {Instance.PrivateKeysList.Count}");
					foreach (string privateKeys in Instance.PrivateKeysList)
					{
						args.Context.AddString(privateKeys);
					}
				}

				internal void <Postfix>b__1_8(ConsoleEventArgs args)
				{
					if (ZNet.instance.IsServer())
					{
						args.Context.AddString($"Total Players Recorded This Session: {Instance.ServerPrivateKeysList.Count}");
						{
							foreach (KeyValuePair<long, HashSet<string>> serverPrivateKeys in Instance.ServerPrivateKeysList)
							{
								int num = serverPrivateKeys.Value?.Count ?? 0;
								args.Context.AddString($"Player {serverPrivateKeys.Key} has {num} recorded keys:");
								if (serverPrivateKeys.Value == null)
								{
									continue;
								}
								foreach (string item in serverPrivateKeys.Value)
								{
									args.Context.AddString(item);
								}
							}
							return;
						}
					}
					args.Context.AddString("You are not the server, no data available client side. Printing key information to server logoutput.log file.");
					Instance.SendServerListKeys();
				}
			}

			[HarmonyPriority(800)]
			private static void Prefix(out bool __state)
			{
				__state = Terminal.m_terminalInitialized;
			}

			private static void Postfix(bool __state)
			{
				//IL_0045: 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_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Expected O, but got Unknown
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Expected O, but got Unknown
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a1: 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_00ac: Expected O, but got Unknown
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Expected O, but got Unknown
				//IL_0125: 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_011c: Expected O, but got Unknown
				//IL_015d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: Expected O, but got Unknown
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				//IL_0186: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Expected O, but got Unknown
				//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01be: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c4: Expected O, but got Unknown
				//IL_0205: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_01fc: Expected O, but got Unknown
				if (__state)
				{
					return;
				}
				ProgressionPlugin.VentureProgressionLogger.LogInfo((object)"Adding Terminal Commands for key management.");
				object obj = <>c.<>9__1_0;
				if (obj == null)
				{
					ConsoleEvent val = delegate(ConsoleEventArgs args)
					{
						if (args.Length >= 2)
						{
							ProgressionAPI.AddGlobalKey(args[1]);
							args.Context.AddString("Setting global key " + args[1] + ".");
						}
						else
						{
							args.Context.AddString("Syntax: setglobalkey [key]");
						}
					};
					<>c.<>9__1_0 = val;
					obj = (object)val;
				}
				new ConsoleCommand("setglobalkey", "[name]", (ConsoleEvent)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj2 = <>c.<>9__1_1;
				if (obj2 == null)
				{
					ConsoleEvent val2 = delegate(ConsoleEventArgs args)
					{
						if (args.Length >= 2)
						{
							ProgressionAPI.RemoveGlobalKey(args[1]);
							args.Context.AddString("Removing global key " + args[1] + ".");
						}
						else
						{
							args.Context.AddString("Syntax: removeglobalkey [key]");
						}
					};
					<>c.<>9__1_1 = val2;
					obj2 = (object)val2;
				}
				new ConsoleCommand("removeglobalkey", "[name]", (ConsoleEvent)obj2, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj3 = <>c.<>9__1_2;
				if (obj3 == null)
				{
					ConsoleEvent val3 = delegate(ConsoleEventArgs args)
					{
						HashSet<string> globalKeys = ProgressionAPI.GetGlobalKeys();
						args.Context.AddString($"Total Keys {globalKeys.Count}");
						foreach (string item in globalKeys)
						{
							args.Context.AddString(item);
						}
					};
					<>c.<>9__1_2 = val3;
					obj3 = (object)val3;
				}
				new ConsoleCommand("listglobalkeys", "", (ConsoleEvent)obj3, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj4 = <>c.<>9__1_3;
				if (obj4 == null)
				{
					ConsoleEvent val4 = delegate
					{
						ZoneSystem.instance.ResetGlobalKeys();
					};
					<>c.<>9__1_3 = val4;
					obj4 = (object)val4;
				}
				new ConsoleCommand("resetglobalkeys", "", (ConsoleEvent)obj4, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj5 = <>c.<>9__1_4;
				if (obj5 == null)
				{
					ConsoleEvent val5 = delegate(ConsoleEventArgs args)
					{
						if (args.Length >= 3)
						{
							string text3 = args[2];
							for (int k = 3; k < args.Length; k++)
							{
								text3 = text3 + " " + args[k];
							}
							Instance.AddPrivateKey(args[1], text3);
							args.Context.AddString("Setting private key " + args[1] + " for player " + text3 + ".");
						}
						else if (args.Length == 2)
						{
							Instance.AddPrivateKey(args[1]);
							args.Context.AddString("Setting private key " + args[1] + ".");
						}
						else
						{
							args.Context.AddString("Syntax: setprivatekey [key]");
						}
					};
					<>c.<>9__1_4 = val5;
					obj5 = (object)val5;
				}
				new ConsoleCommand("setprivatekey", "[name] [optional: player name]", (ConsoleEvent)obj5, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj6 = <>c.<>9__1_5;
				if (obj6 == null)
				{
					ConsoleEvent val6 = delegate(ConsoleEventArgs args)
					{
						if (args.Length >= 3)
						{
							string text2 = args[2];
							for (int j = 3; j < args.Length; j++)
							{
								text2 = text2 + " " + args[j];
							}
							Instance.RemovePrivateKey(args[1], text2);
							args.Context.AddString("Removing private key " + args[1] + " for player " + text2 + ".");
						}
						else if (args.Length == 2)
						{
							Instance.RemovePrivateKey(args[1]);
							args.Context.AddString("Removing private key " + args[1] + ".");
						}
						else
						{
							args.Context.AddString("Syntax: removeprivatekey [key] [optional: player name]");
						}
					};
					<>c.<>9__1_5 = val6;
					obj6 = (object)val6;
				}
				new ConsoleCommand("removeprivatekey", "[name] [optional: player name]", (ConsoleEvent)obj6, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj7 = <>c.<>9__1_6;
				if (obj7 == null)
				{
					ConsoleEvent val7 = delegate(ConsoleEventArgs args)
					{
						if (args.Length >= 2)
						{
							string text = args[1];
							for (int i = 2; i < args.Length; i++)
							{
								text = text + " " + args[i];
							}
							Instance.ResetPrivateKeys(args[1]);
							args.Context.AddString("Private keys cleared for player " + text + ".");
						}
						else if (args.Length == 1)
						{
							Instance.ResetPrivateKeys();
							args.Context.AddString("Private keys cleared");
						}
						else
						{
							args.Context.AddString("Syntax: resetprivatekeys [optional: player name]");
						}
					};
					<>c.<>9__1_6 = val7;
					obj7 = (object)val7;
				}
				new ConsoleCommand("resetprivatekeys", "[optional: player name]", (ConsoleEvent)obj7, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj8 = <>c.<>9__1_7;
				if (obj8 == null)
				{
					ConsoleEvent val8 = delegate(ConsoleEventArgs args)
					{
						args.Context.AddString($"Total Keys {Instance.PrivateKeysList.Count}");
						foreach (string privateKeys in Instance.PrivateKeysList)
						{
							args.Context.AddString(privateKeys);
						}
					};
					<>c.<>9__1_7 = val8;
					obj8 = (object)val8;
				}
				new ConsoleCommand("listprivatekeys", "", (ConsoleEvent)obj8, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
				object obj9 = <>c.<>9__1_8;
				if (obj9 == null)
				{
					ConsoleEvent val9 = delegate(ConsoleEventArgs args)
					{
						if (ZNet.instance.IsServer())
						{
							args.Context.AddString($"Total Players Recorded This Session: {Instance.ServerPrivateKeysList.Count}");
							{
								foreach (KeyValuePair<long, HashSet<string>> serverPrivateKeys in Instance.ServerPrivateKeysList)
								{
									int num = serverPrivateKeys.Value?.Count ?? 0;
									args.Context.AddString($"Player {serverPrivateKeys.Key} has {num} recorded keys:");
									if (serverPrivateKeys.Value != null)
									{
										foreach (string item2 in serverPrivateKeys.Value)
										{
											args.Context.AddString(item2);
										}
									}
								}
								return;
							}
						}
						args.Context.AddString("You are not the server, no data available client side. Printing key information to server logoutput.log file.");
						Instance.SendServerListKeys();
					};
					<>c.<>9__1_8 = val9;
					obj9 = (object)val9;
				}
				new ConsoleCommand("listserverkeys", "", (ConsoleEvent)obj9, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			}
		}

		[HarmonyPatch(typeof(RandEventSystem), "RefreshPlayerEventData")]
		public static class Patch_RandEventSystem_RefreshPlayerEventData
		{
			private static bool Prefix(ref List<PlayerEventData> __result)
			{
				//IL_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				if (!ProgressionConfiguration.Instance.GetUsePrivateRaids() || !ProgressionConfiguration.Instance.GetUsePrivateKeys())
				{
					return true;
				}
				RandEventSystem.playerEventDatas.Clear();
				if (!ZNet.instance.IsDedicated())
				{
					RandEventSystem.playerEventDatas.Add(GetHostPlayerEventData());
				}
				foreach (ZNetPeer peer in ZNet.instance.GetPeers())
				{
					if (peer.IsReady())
					{
						RandEventSystem.playerEventDatas.Add(GetPlayerEventData(peer));
					}
				}
				__result = RandEventSystem.playerEventDatas;
				return false;
			}
		}

		[HarmonyPatch(typeof(RandEventSystem), "HaveGlobalKeys")]
		public static class Patch_RandEventSystem_HaveGlobalKeys
		{
			private static bool Prefix(ref bool __result)
			{
				if (!ProgressionConfiguration.Instance.GetUsePrivateRaids() || !ProgressionConfiguration.Instance.GetUsePrivateKeys())
				{
					return true;
				}
				__result = true;
				return false;
			}
		}

		[HarmonyPatch(typeof(Trader), "GetAvailableItems")]
		public static class Patch_Trader_GetAvailableItems
		{
			[HarmonyPriority(800)]
			private static void Postfix(Trader __instance, ref List<TradeItem> __result)
			{
				string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject);
				if ((prefabName.Equals("Haldor") && ProgressionConfiguration.Instance.GetUnlockAllHaldorItems()) || (prefabName.Equals("Hildir") && ProgressionConfiguration.Instance.GetUnlockAllHildirItems()))
				{
					__result = new List<TradeItem>(__instance.m_items);
				}
			}
		}

		[HarmonyPatch(typeof(StoreGui), "SelectItem")]
		public static class Patch_StoreGui_SelectItem
		{
			private static void Prefix(StoreGui __instance, ref int index)
			{
				if (__instance.m_itemList.Count == 0)
				{
					index = -1;
				}
			}
		}

		[HarmonyPatch(typeof(Trader), "Start")]
		public static class Patch_Trader_Start
		{
			[HarmonyPriority(800)]
			private static void Postfix(Trader __instance)
			{
				string prefabName = Utils.GetPrefabName(((Component)__instance).gameObject);
				Dictionary<string, string> dictionary = null;
				if (prefabName.Equals("Haldor"))
				{
					dictionary = Instance.GetTraderConfiguration();
				}
				else if (prefabName.Equals("Hildir"))
				{
					dictionary = Instance.GetHildirConfiguration(__instance.m_items);
				}
				if (dictionary == null)
				{
					return;
				}
				foreach (TradeItem item in __instance.m_items)
				{
					if ((Object)(object)item.m_prefab != (Object)null)
					{
						string prefabName2 = Utils.GetPrefabName(((Component)item.m_prefab).gameObject);
						if (dictionary.ContainsKey(prefabName2))
						{
							item.m_requiredGlobalKey = dictionary[prefabName2];
						}
					}
				}
			}
		}

		public const string BOSS_KEY_MEADOW = "defeated_eikthyr";

		public const string BOSS_KEY_BLACKFOREST = "defeated_gdking";

		public const string BOSS_KEY_SWAMP = "defeated_bonemass";

		public const string BOSS_KEY_MOUNTAIN = "defeated_dragon";

		public const string BOSS_KEY_PLAIN = "defeated_goblinking";

		public const string BOSS_KEY_MISTLAND = "defeated_queen";

		public const string HILDIR_KEY_CRYPT = "hildir1";

		public const string HILDIR_KEY_CAVE = "hildir2";

		public const string HILDIR_KEY_TOWER = "hildir3";

		public const int TOTAL_BOSSES = 6;

		public readonly Dictionary<string, int> BossKeyOrderList = new Dictionary<string, int>
		{
			{ "", 0 },
			{ "defeated_eikthyr", 1 },
			{ "defeated_gdking", 2 },
			{ "defeated_bonemass", 3 },
			{ "defeated_dragon", 4 },
			{ "defeated_goblinking", 5 },
			{ "defeated_queen", 6 }
		};

		public readonly Dictionary<string, string> GuardianKeysList = new Dictionary<string, string>
		{
			{ "GP_Eikthyr", "defeated_eikthyr" },
			{ "GP_TheElder", "defeated_gdking" },
			{ "GP_Bonemass", "defeated_bonemass" },
			{ "GP_Moder", "defeated_dragon" },
			{ "GP_Yagluth", "defeated_goblinking" },
			{ "GP_Queen", "defeated_queen" }
		};

		public readonly Dictionary<string, string> BossItemKeysList = new Dictionary<string, string>
		{
			{ "HardAntler", "defeated_eikthyr" },
			{ "CryptKey", "defeated_gdking" },
			{ "Wishbone", "defeated_bonemass" },
			{ "DragonTear", "defeated_dragon" },
			{ "YagluthDrop", "defeated_goblinking" },
			{ "DvergrKey", "defeated_goblinking" },
			{ "QueenDrop", "defeated_queen" }
		};

		public readonly Dictionary<string, string> MaterialKeysList = new Dictionary<string, string>
		{
			{ "FineWood", "defeated_eikthyr" },
			{ "Tin", "defeated_eikthyr" },
			{ "Copper", "defeated_eikthyr" },
			{ "Bronze", "defeated_eikthyr" },
			{ "BronzeNails", "defeated_eikthyr" },
			{ "TrollHide", "defeated_eikthyr" },
			{ "Iron", "defeated_gdking" },
			{ "IronNails", "defeated_gdking" },
			{ "Chain", "defeated_gdking" },
			{ "ElderBark", "defeated_gdking" },
			{ "Root", "defeated_gdking" },
			{ "SharpeningStone", "defeated_gdking" },
			{ "Silver", "defeated_bonemass" },
			{ "WolfHairBundle", "defeated_bonemass" },
			{ "WolfPelt", "defeated_bonemass" },
			{ "WolfClaw", "defeated_bonemass" },
			{ "WolfFang", "defeated_bonemass" },
			{ "JuteRed", "defeated_bonemass" },
			{ "Obsidian", "defeated_bonemass" },
			{ "BlackMetal", "defeated_dragon" },
			{ "Tar", "defeated_dragon" },
			{ "Needle", "defeated_dragon" },
			{ "LinenThread", "defeated_dragon" },
			{ "LoxPelt", "defeated_dragon" },
			{ "BlackMarble", "defeated_goblinking" },
			{ "BlackCore", "defeated_goblinking" },
			{ "Carapace", "defeated_goblinking" },
			{ "Eitr", "defeated_goblinking" },
			{ "ScaleHide", "defeated_goblinking" },
			{ "Wisp", "defeated_goblinking" },
			{ "YggdrasilWood", "defeated_goblinking" },
			{ "JuteBlue", "defeated_goblinking" }
		};

		public readonly Dictionary<string, string> FoodKeysList = new Dictionary<string, string>
		{
			{ "Blueberries", "defeated_eikthyr" },
			{ "MushroomYellow", "defeated_eikthyr" },
			{ "Carrot", "defeated_eikthyr" },
			{ "Thistle", "defeated_eikthyr" },
			{ "Entrails", "defeated_eikthyr" },
			{ "Turnip", "defeated_gdking" },
			{ "Bloodbag", "defeated_gdking" },
			{ "Ooze", "defeated_gdking" },
			{ "SerpentMeat", "defeated_gdking" },
			{ "SerpentMeatCooked", "defeated_gdking" },
			{ "FreezeGland", "defeated_bonemass" },
			{ "WolfMeat", "defeated_bonemass" },
			{ "Onion", "defeated_bonemass" },
			{ "Barley", "defeated_dragon" },
			{ "LoxMeat", "defeated_dragon" },
			{ "BarleyFlour", "defeated_dragon" },
			{ "Cloudberry", "defeated_dragon" },
			{ "ChickenMeat", "defeated_dragon" },
			{ "ChickenEgg", "defeated_dragon" },
			{ "BreadDough", "defeated_dragon" },
			{ "GiantBloodSack", "defeated_goblinking" },
			{ "BugMeat", "defeated_goblinking" },
			{ "RoyalJelly", "defeated_goblinking" },
			{ "HareMeat", "defeated_goblinking" },
			{ "Sap", "defeated_goblinking" },
			{ "MushroomJotunPuffs", "defeated_goblinking" }
		};

		private static int _cachedPublicBossKeys;

		private static int _cachedPrivateBossKeys;

		protected static readonly IKeyManager _instance;

		public const string RPCNAME_ServerListKeys = "VV_ServerListKeys";

		public const string RPCNAME_ServerSetPrivateKeys = "VV_ServerSetPrivateKeys";

		public const string RPCNAME_ServerSetPrivateKey = "VV_ServerSetPrivateKey";

		public const string RPCNAME_ServerRemovePrivateKey = "VV_ServerRemovePrivateKey";

		public const string RPCNAME_SetPrivateKey = "VV_SetPrivateKey";

		public const string RPCNAME_RemovePrivateKey = "VV_RemovePrivateKey";

		public const string RPCNAME_ResetPrivateKeys = "VV_ResetPrivateKeys";

		public const string PLAYER_SAVE_KEY = "VV_PrivateKeys";

		private HashSet<string> IgnoredModKeys = new HashSet<string> { "season_winter", "season_fall", "season_summer", "season_spring" };

		public string BlockedGlobalKeys { get; protected set; }

		public string AllowedGlobalKeys { get; protected set; }

		public string EnforcedGlobalKeys { get; protected set; }

		public string BlockedPrivateKeys { get; protected set; }

		public string AllowedPrivateKeys { get; protected set; }

		public string EnforcedPrivateKeys { get; protected set; }

		public string TamingKeys { get; protected set; }

		public string SummoningKeys { get; protected set; }

		public HashSet<string> BlockedGlobalKeysList { get; protected set; }

		public HashSet<string> AllowedGlobalKeysList { get; protected set; }

		public HashSet<string> EnforcedGlobalKeysList { get; protected set; }

		public HashSet<string> BlockedPrivateKeysList { get; protected set; }

		public HashSet<string> AllowedPrivateKeysList { get; protected set; }

		public HashSet<string> EnforcedPrivateKeysList { get; protected set; }

		public Dictionary<string, string> TamingKeysList { get; protected set; }

		public Dictionary<string, string> SummoningKeysList { get; protected set; }

		public Dictionary<string, string> HildirOriginalItemsList { get; protected set; }

		public static KeyManager Instance => _instance as KeyManager;

		public HashSet<string> PrivateKeysList { get; protected set; }

		public Dictionary<long, HashSet<string>> ServerPrivateKeysList { get; protected set; }

		public void UpdateConfigurations()
		{
			UpdateConfigs();
			if (ProgressionConfiguration.Instance.GetEnableSkillManager())
			{
				_cachedPublicBossKeys = CountPublicBossKeys();
				_cachedPrivateBossKeys = CountPrivateBossKeys();
				SkillsManager.Instance.UpdateCache();
			}
		}

		protected void ResetConfigurations()
		{
			BlockedGlobalKeys = "";
			AllowedGlobalKeys = "";
			EnforcedGlobalKeys = "";
			BlockedGlobalKeysList = new HashSet<string>();
			AllowedGlobalKeysList = new HashSet<string>();
			EnforcedGlobalKeysList = new HashSet<string>();
			BlockedPrivateKeys = "";
			AllowedPrivateKeys = "";
			EnforcedPrivateKeys = "";
			BlockedPrivateKeysList = new HashSet<string>();
			AllowedPrivateKeysList = new HashSet<string>();
			EnforcedPrivateKeysList = new HashSet<string>();
			TamingKeys = null;
			SummoningKeys = null;
		}

		protected void ResetServer()
		{
			ServerPrivateKeysList = new Dictionary<long, HashSet<string>>();
		}

		protected void ResetPlayer()
		{
			PrivateKeysList = new HashSet<string>();
			_cachedPublicBossKeys = -1;
			_cachedPrivateBossKeys = -1;
		}

		protected int CountPrivateBossKeys()
		{
			int num = 0;
			foreach (string key in BossKeyOrderList.Keys)
			{
				if (!Utility.IsNullOrWhiteSpace(key) && PrivateKeysList.Contains(key))
				{
					num++;
				}
			}
			return num;
		}

		private int CountPublicBossKeys()
		{
			int num = 0;
			foreach (string key in BossKeyOrderList.Keys)
			{
				if (!Utility.IsNullOrWhiteSpace(key) && HasGlobalKey(key))
				{
					num++;
				}
			}
			return num;
		}

		private void UpdateConfigs()
		{
			UpdateGlobalKeyConfiguration(ProgressionConfiguration.Instance.GetBlockedGlobalKeys(), ProgressionConfiguration.Instance.GetAllowedGlobalKeys());
			UpdatePrivateKeyConfiguration(ProgressionConfiguration.Instance.GetBlockedPrivateKeys(), ProgressionConfiguration.Instance.GetAllowedPrivateKeys());
			UpdateEnforcedKeyConfiguration(ProgressionConfiguration.Instance.GetEnforcedGlobalKeys(), ProgressionConfiguration.Instance.GetEnforcedPrivateKeys());
			UpdateTamingConfiguration(ProgressionConfiguration.Instance.GetOverrideLockTamingDefaults());
			UpdateSummoningConfiguration(ProgressionConfiguration.Instance.GetOverrideLockBossSummonsDefaults());
		}

		protected void UpdateGlobalKeyConfiguration(string blockedGlobalKeys, string allowedGlobalKeys)
		{
			if (BlockedGlobalKeys == null || !BlockedGlobalKeys.Equals(blockedGlobalKeys))
			{
				BlockedGlobalKeys = blockedGlobalKeys;
				BlockedGlobalKeysList = ProgressionAPI.StringToSet(blockedGlobalKeys);
			}
			if (AllowedGlobalKeys == null || !AllowedGlobalKeys.Equals(allowedGlobalKeys))
			{
				AllowedGlobalKeys = allowedGlobalKeys;
				AllowedGlobalKeysList = ProgressionAPI.StringToSet(allowedGlobalKeys);
			}
		}

		protected void UpdatePrivateKeyConfiguration(string blockedPrivateKeys, string allowedPrivateKeys)
		{
			if (BlockedPrivateKeys == null || !BlockedPrivateKeys.Equals(blockedPrivateKeys))
			{
				BlockedPrivateKeys = blockedPrivateKeys;
				BlockedPrivateKeysList = ProgressionAPI.StringToSet(blockedPrivateKeys);
			}
			if (AllowedPrivateKeys == null || !AllowedPrivateKeys.Equals(allowedPrivateKeys))
			{
				AllowedPrivateKeys = allowedPrivateKeys;
				AllowedPrivateKeysList = ProgressionAPI.StringToSet(allowedPrivateKeys);
			}
		}

		protected void UpdateEnforcedKeyConfiguration(string enforcedGlobalKeys, string enforcedPrivateKeys)
		{
			if (EnforcedGlobalKeys == null || !EnforcedGlobalKeys.Equals(enforcedGlobalKeys))
			{
				EnforcedGlobalKeys = enforcedGlobalKeys;
				EnforcedGlobalKeysList = ProgressionAPI.StringToSet(enforcedGlobalKeys);
			}
			if (EnforcedPrivateKeys == null || !EnforcedPrivateKeys.Equals(enforcedPrivateKeys))
			{
				EnforcedPrivateKeys = enforcedPrivateKeys;
				EnforcedPrivateKeysList = ProgressionAPI.StringToSet(enforcedPrivateKeys);
			}
		}

		protected void UpdateTamingConfiguration(string tamingString)
		{
			if (TamingKeys == null || !TamingKeys.Equals(tamingString))
			{
				TamingKeys = tamingString;
				if (Utility.IsNullOrWhiteSpace(TamingKeys))
				{
					TamingKeysList = new Dictionary<string, string>
					{
						{ "Wolf", "defeated_bonemass" },
						{ "Lox", "defeated_dragon" }
					};
				}
				else
				{
					TamingKeysList = ProgressionAPI.StringToDictionary(tamingString);
				}
			}
		}

		protected void UpdateSummoningConfiguration(string summoningString)
		{
			if (SummoningKeys == null || !SummoningKeys.Equals(summoningString))
			{
				SummoningKeys = summoningString;
				if (Utility.IsNullOrWhiteSpace(SummoningKeys))
				{
					SummoningKeysList = new Dictionary<string, string>
					{
						{ "Eikthyr", "" },
						{ "gd_king", "defeated_eikthyr" },
						{ "Bonemass", "defeated_gdking" },
						{ "Dragon", "defeated_bonemass" },
						{ "GoblinKing", "defeated_dragon" },
						{ "SeekerQueen", "defeated_goblinking" }
					};
				}
				else
				{
					SummoningKeysList = ProgressionAPI.StringToDictionary(summoningString);
				}
			}
		}

		protected Dictionary<string, string> GetTraderConfiguration()
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetHelmetYuleKey()))
			{
				dictionary.Add("HelmetYule", ProgressionConfiguration.Instance.GetHelmetYuleKey());
			}
			if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetHelmetDvergerKey()))
			{
				dictionary.Add("HelmetDverger", ProgressionConfiguration.Instance.GetHelmetDvergerKey());
			}
			if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetBeltStrengthKey()))
			{
				dictionary.Add("BeltStrength", ProgressionConfiguration.Instance.GetBeltStrengthKey());
			}
			if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetYmirRemainsKey()))
			{
				dictionary.Add("YmirRemains", ProgressionConfiguration.Instance.GetYmirRemainsKey());
			}
			if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetFishingRodKey()))
			{
				dictionary.Add("FishingRod", ProgressionConfiguration.Instance.GetFishingRodKey());
			}
			if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetFishingBaitKey()))
			{
				dictionary.Add("FishingBait", ProgressionConfiguration.Instance.GetFishingBaitKey());
			}
			if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetThunderstoneKey()))
			{
				dictionary.Add("Thunderstone", ProgressionConfiguration.Instance.GetThunderstoneKey());
			}
			if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetChickenEggKey()))
			{
				dictionary.Add("ChickenEgg", ProgressionConfiguration.Instance.GetChickenEggKey());
			}
			return dictionary;
		}

		protected void SetHildirOriginalItemsList(List<TradeItem> items)
		{
			if (HildirOriginalItemsList != null)
			{
				return;
			}
			HildirOriginalItemsList = new Dictionary<string, string>();
			foreach (TradeItem item in items)
			{
				if ((Object)(object)item.m_prefab != (Object)null)
				{
					string prefabName = Utils.GetPrefabName(((Component)item.m_prefab).gameObject);
					if (!HildirOriginalItemsList.ContainsKey(prefabName))
					{
						HildirOriginalItemsList.Add(prefabName, item.m_requiredGlobalKey);
					}
				}
			}
		}

		protected Dictionary<string, string> GetHildirConfiguration(List<TradeItem> items)
		{
			SetHildirOriginalItemsList(items);
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetCryptItemsKey()))
			{
				dictionary.Add("hildir1", ProgressionConfiguration.Instance.GetCryptItemsKey());
			}
			if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetCaveItemsKey()))
			{
				dictionary.Add("hildir2", ProgressionConfiguration.Instance.GetCaveItemsKey());
			}
			if (!Utility.IsNullOrWhiteSpace(ProgressionConfiguration.Instance.GetTowerItemsKey()))
			{
				dictionary.Add("hildir3", ProgressionConfiguration.Instance.GetTowerItemsKey());
			}
			Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
			foreach (KeyValuePair<string, string> hildirOriginalItems in HildirOriginalItemsList)
			{
				if (dictionary.ContainsKey(hildirOriginalItems.Value))
				{
					dictionary2.Add(hildirOriginalItems.Key, dictionary[hildirOriginalItems.Value]);
				}
			}
			return dictionary2;
		}

		public int GetPublicBossKeysCount()
		{
			return _cachedPublicBossKeys;
		}

		public int GetPrivateBossKeysCount()
		{
			return _cachedPrivateBossKeys;
		}

		private bool HasTamingKey(string creature)
		{
			if (Utility.IsNullOrWhiteSpace(creature))
			{
				return false;
			}
			if (TamingKeysList.ContainsKey(creature))
			{
				return HasKey(TamingKeysList[creature]);
			}
			return true;
		}

		private bool HasSummoningKey(string creature)
		{
			if (Utility.IsNullOrWhiteSpace(creature))
			{
				return false;
			}
			if (SummoningKeysList.ContainsKey(creature))
			{
				if (HasKey(SummoningKeysList[creature]))
				{
					if (ProgressionConfiguration.Instance.GetUnlockBossSummonsOverTime())
					{
						return SummoningTimeReached(SummoningKeysList[creature], ProgressionAPI.GetGameDay());
					}
					return true;
				}
				return false;
			}
			return true;
		}

		protected bool SummoningTimeReached(string key, int gameDay)
		{
			if (BossKeyOrderList.ContainsKey(key))
			{
				int num = BossKeyOrderList[key] * ProgressionConfiguration.Instance.GetUnlockBossSummonsTime();
				return gameDay >= num;
			}
			return true;
		}

		protected bool HasGuardianKey(string guardianPower)
		{
			if (Utility.IsNullOrWhiteSpace(guardianPower))
			{
				return false;
			}
			string[] source = guardianPower.Split(new char[1] { ',' });
			if (source.All(GuardianKeysList.ContainsKey))
			{
				return source.All((string gp) => HasKey(GuardianKeysList[gp]));
			}
			return false;
		}

		private bool HasItemKey(string item, bool checkBossItems, bool checkMaterials, bool checkFood)
		{
			if (Utility.IsNullOrWhiteSpace(item))
			{
				return false;
			}
			if ((checkBossItems && BossItemKeysList.ContainsKey(item) && !HasKey(BossItemKeysList[item])) || (checkMaterials && MaterialKeysList.ContainsKey(item) && !HasKey(MaterialKeysList[item])) || (checkFood && FoodKeysList.ContainsKey(item) && !HasKey(FoodKeysList[item])))
			{
				return false;
			}
			return true;
		}

		private bool IsActionBlocked(ItemData item, int quality, bool checkBossItems, bool checkMaterials, bool checkFood)
		{
			if ((Object)(object)item?.m_dropPrefab == (Object)null || !Instance.HasItemKey(Utils.GetPrefabName(item.m_dropPrefab), checkBossItems, checkMaterials, checkFood))
			{
				return true;
			}
			Recipe recipe = ObjectDB.instance.GetRecipe(item);
			return IsActionBlocked(recipe, quality, checkBossItems, checkMaterials, checkFood);
		}

		private bool IsActionBlocked(Recipe recipe, int quality, bool checkBossItems, bool checkMaterials, bool checkFood)
		{
			if ((Object)(object)recipe != (Object)null)
			{
				for (int i = 0; i < recipe.m_resources.Length; i++)
				{
					if ((Object)(object)recipe.m_resources[i].m_resItem == (Object)null)
					{
						return false;
					}
					for (int j = 1; j <= quality; j++)
					{
						if (recipe.m_resources[i].GetAmount(j) > 0)
						{
							if (Instance.HasItemKey(Utils.GetPrefabName(((Component)recipe.m_resources[i].m_resItem).gameObject), checkBossItems, checkMaterials, checkFood))
							{
								break;
							}
							return true;
						}
					}
				}
			}
			return false;
		}

		private void ApplyBlockedActionEffects(Player player)
		{
			if (!((Object)(object)player != (Object)null))
			{
				return;
			}
			if (ProgressionConfiguration.Instance.GetUseBlockedActionEffect())
			{
				SEMan sEMan = ((Character)player).GetSEMan();
				if (sEMan != null)
				{
					sEMan.AddStatusEffect(Character.s_statusEffectBurning, false, 0, 0f);
				}
			}
			if (ProgressionConfiguration.Instance.GetUseBlockedActionMessage())
			{
				((Character)player).Message((MessageType)2, ProgressionConfiguration.Instance.GetBlockedActionMessage(), 0, (Sprite)null);
			}
		}

		static KeyManager()
		{
			_cachedPublicBossKeys = -1;
			_cachedPrivateBossKeys = -1;
			_instance = new KeyManager();
		}

		protected KeyManager()
		{
			ResetServer();
			ResetPlayer();
		}

		private bool IsWorldModifier(string key)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			string text = default(string);
			GlobalKeys val = default(GlobalKeys);
			ZoneSystem.GetKeyValue(key, ref text, ref val);
			if ((int)val < 31 || (int)val == 37)
			{
				return true;
			}
			return false;
		}

		public bool BlockGlobalKey(bool blockAll, string globalKey)
		{
			if (Utility.IsNullOrWhiteSpace(globalKey))
			{
				return true;
			}
			if (IsWorldModifier(globalKey) || IgnoredModKeys.Contains(globalKey))
			{
				ProgressionPlugin.VentureProgressionLogger.LogDebug((object)(globalKey + " is non-qualifying, can not block."));
				return false;
			}
			if (blockAll)
			{
				if (AllowedGlobalKeysList.Count > 0)
				{
					return !AllowedGlobalKeysList.Contains(globalKey);
				}
				return true;
			}
			if (BlockedGlobalKeysList.Count > 0)
			{
				return BlockedGlobalKeysList.Contains(globalKey);
			}
			return false;
		}

		public bool BlockPrivateKey(string key)
		{
			if (ProgressionConfiguration.Instance.GetUsePrivateKeys() && !ZNet.instance.IsDedicated())
			{
				return PrivateKeyIsBlocked(key);
			}
			return true;
		}

		protected bool PrivateKeyIsBlocked(string key)
		{
			if (Utility.IsNullOrWhiteSpace(key) || IsWorldModifier(key) || IgnoredModKeys.Contains(key))
			{
				return true;
			}
			if (BlockedPrivateKeysList.Count > 0)
			{
				return BlockedPrivateKeysList.Contains(key);
			}
			if (AllowedPrivateKeysList.Count > 0)
			{
				return !AllowedPrivateKeysList.Contains(key);
			}
			return false;
		}

		public bool HasPrivateKey(string key)
		{
			if (Utility.IsNullOrWhiteSpace(key))
			{
				return true;
			}
			return PrivateKeysList.Contains(key);
		}

		public bool HasKey(string key)
		{
			if (!ProgressionConfiguration.Instance.GetUsePrivateKeys() || !HasPrivateKey(key))
			{
				return HasGlobalKey(key);
			}
			return true;
		}

		public bool HasGlobalKey(string key)
		{
			if (Utility.IsNullOrWhiteSpace(key))
			{
				return true;
			}
			return ProgressionAPI.GetGlobalKey(key);
		}

		private void AddPrivateKey(string key)
		{
			if (!Utility.IsNullOrWhiteSpace(key))
			{
				key = key.ToLower();
				if (PrivateKeysList.Add(key))
				{
					ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Adding Private Key " + key + "."));
					SendPrivateKeyToServer(key);
				}
			}
		}

		private void AddPrivateKey(string key, string playerName)
		{
			if (Utility.IsNullOrWhiteSpace(playerName))
			{
				AddPrivateKey(key);
			}
			else
			{
				SendPrivateKey(playerName, key);
			}
		}

		private void SendPrivateKey(string playerName, string key)
		{
			long playerID = ProgressionAPI.GetPlayerID(playerName);
			if (playerID != 0L)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(playerID, "VV_SetPrivateKey", new object[1] { key });
			}
		}

		private void RPC_SetPrivateKey(long sender, string key)
		{
			ProgressionPlugin.VentureProgressionLogger.LogDebug((object)$"Got private key {key} from {sender}: adding to list.");
			AddPrivateKey(key);
		}

		private void RemovePrivateKey(string key)
		{
			key = key.ToLower();
			if (PrivateKeysList.Remove(key))
			{
				ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Removing Private Key " + key + "."));
				SendRemovePrivateKeyFromServer(key);
			}
		}

		private void RemovePrivateKey(string key, string playerName)
		{
			if (Utility.IsNullOrWhiteSpace(playerName))
			{
				RemovePrivateKey(key);
			}
			else
			{
				SendRemovePrivateKey(playerName, key);
			}
		}

		private void SendRemovePrivateKey(string playerName, string key)
		{
			long playerID = ProgressionAPI.GetPlayerID(playerName);
			if (playerID != 0L)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(playerID, "VV_RemovePrivateKey", new object[1] { key });
			}
		}

		private void RPC_RemovePrivateKey(long sender, string key)
		{
			ProgressionPlugin.VentureProgressionLogger.LogDebug((object)$"Got private key {key} from {sender}: removing from list.");
			RemovePrivateKey(key);
		}

		private void ResetPrivateKeys()
		{
			ProgressionPlugin.VentureProgressionLogger.LogDebug((object)"Resetting Private Keys.");
			PrivateKeysList = new HashSet<string>();
			SendPrivateKeysToServer(PrivateKeysList);
		}

		private void ResetPrivateKeys(string playerName)
		{
			if (Utility.IsNullOrWhiteSpace(playerName))
			{
				ResetPrivateKeys();
			}
			else
			{
				SendResetPrivateKeys(playerName);
			}
		}

		private void SendResetPrivateKeys(string playerName)
		{
			long playerID = ProgressionAPI.GetPlayerID(playerName);
			if (playerID != 0L)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(playerID, "VV_ResetPrivateKeys", Array.Empty<object>());
			}
		}

		private void RPC_ResetPrivateKeys(long sender)
		{
			ProgressionPlugin.VentureProgressionLogger.LogDebug((object)$"Got reset keys command from {sender}.");
			ResetPrivateKeys();
		}

		private void SendPrivateKeysToServer(HashSet<string> keys)
		{
			string text = string.Join<string>(",", (IEnumerable<string>)keys);
			ZRoutedRpc.instance.InvokeRoutedRPC("VV_ServerSetPrivateKeys", new object[2]
			{
				text,
				ProgressionAPI.GetLocalPlayerID()
			});
		}

		private void RPC_ServerSetPrivateKeys(long sender, string keys, long playerID)
		{
			HashSet<string> hashSet = ProgressionAPI.StringToSet(keys);
			ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Updating Server Player: " + $"{hashSet.Count} keys found for peer {sender}: \"{ProgressionAPI.GetPlayerName(playerID)}\"."));
			SetServerKeys(playerID, hashSet);
		}

		private void SendPrivateKeyToServer(string key)
		{
			ZRoutedRpc.instance.InvokeRoutedRPC("VV_ServerSetPrivateKey", new object[2]
			{
				key,
				ProgressionAPI.GetLocalPlayerID()
			});
		}

		private void RPC_ServerSetPrivateKey(long sender, string key, long playerID)
		{
			ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Updating Server Player: " + $"Adding key {key} for peer {sender}: \"{ProgressionAPI.GetPlayerName(playerID)}\"."));
			SetServerKey(playerID, key);
		}

		private void SendRemovePrivateKeyFromServer(string key)
		{
			ZRoutedRpc.instance.InvokeRoutedRPC("VV_ServerRemovePrivateKey", new object[2]
			{
				key,
				ProgressionAPI.GetLocalPlayerID()
			});
		}

		private void RPC_ServerRemovePrivateKey(long sender, string key, long playerID)
		{
			ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Updating Server Player: " + $"Removing key {key} for peer {sender}: \"{ProgressionAPI.GetPlayerName(playerID)}\"."));
			RemoveServerKey(playerID, key);
		}

		private void SendServerListKeys()
		{
			ZRoutedRpc.instance.InvokeRoutedRPC("VV_ServerListKeys", Array.Empty<object>());
		}

		private void RPC_ServerListKeys(long sender)
		{
			foreach (KeyValuePair<long, HashSet<string>> serverPrivateKeys in ServerPrivateKeysList)
			{
				string text = "";
				foreach (string item in serverPrivateKeys.Value)
				{
					text = text + item + ", ";
				}
				ProgressionPlugin.VentureProgressionLogger.LogInfo((object)("Player " + ProgressionAPI.GetPlayerName(serverPrivateKeys.Key) + " has " + $"{serverPrivateKeys.Value.Count} recorded keys: {text}"));
			}
		}

		private void SetServerKeys(long playerID, HashSet<string> keys)
		{
			if (ServerPrivateKeysList.ContainsKey(playerID))
			{
				ServerPrivateKeysList[playerID] = keys;
			}
			else
			{
				ServerPrivateKeysList.Add(playerID, keys);
			}
		}

		private void SetServerKey(long playerID, string key)
		{
			if (ServerPrivateKeysList.ContainsKey(playerID))
			{
				ServerPrivateKeysList[playerID].Add(key);
				return;
			}
			HashSet<string> value = new HashSet<string> { key };
			ServerPrivateKeysList.Add(playerID, value);
		}

		private void RemoveServerKey(long playerID, string key)
		{
			if (ServerPrivateKeysList.ContainsKey(playerID))
			{
				ServerPrivateKeysList[playerID].Remove(key);
			}
		}

		private string GetPrivateKeysString()
		{
			return string.Join<string>(",", (IEnumerable<string>)PrivateKeysList);
		}

		private bool SkipAddKeyMethod(string key)
		{
			if (Instance.BlockGlobalKey(ProgressionConfiguration.Instance.GetBlockAllGlobalKeys(), key))
			{
				ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Skipping adding global key: " + key + "."));
				return false;
			}
			ProgressionPlugin.VentureProgressionLogger.LogDebug((object)("Adding global key: " + key + "."));
			return true;
		}

		private static HashSet<string> GetPossiblePlayerEvents(long playerID)
		{
			HashSet<string> playerKeys = ((!Instance.ServerPrivateKeysList.ContainsKey(playerID)) ? new HashSet<string>() : Instance.ServerPrivateKeysList[playerID]);
			return GetPossiblePlayerEvents(playerKeys);
		}

		private static HashSet<string> GetPossiblePlayerEvents(HashSet<string> playerKeys)
		{
			HashSet<string> hashSet = new HashSet<string>();
			foreach (RandomEvent @event in RandEventSystem.instance.m_events)
			{
				if (IsValidEvent(@event, playerKeys))
				{
					hashSet.Add(@event.m_name);
				}
			}
			return hashSet;
		}

		private static bool IsValidEvent(RandomEvent randEvent, HashSet<string> playerKeys)
		{
			foreach (string requiredGlobalKey in randEvent.m_requiredGlobalKeys)
			{
				if (!playerKeys.Contains(requiredGlobalKey))
				{
					return false;
				}
			}
			foreach (string notRequiredGlobalKey in randEvent.m_notRequiredGlobalKeys)
			{
				if (playerKeys.Contains(notRequiredGlobalKey))
				{
					return false;
				}
			}
			return true;
		}

		private static PlayerEventData GetPlayerEventData(ZNetPeer peer)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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)
			PlayerEventData result = default(PlayerEventData);
			result.position = peer.m_refPos;
			result.possibleEvents = GetPossiblePlayerEvents(((ZDOID)(ref peer.m_characterID)).UserID);
			result.baseValue = 0;
			if (peer.m_serverSyncedPlayerData.TryGetValue("baseValue", out var value))
			{
				int.TryParse(value, out result.baseValue);
			}
			return result;
		}

		private static PlayerEventData GetHostPlayerEventData()
		{
			//IL_0002: 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_0014: 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)
			PlayerEventData result = default(PlayerEventData);
			result.position = ZNet.instance.GetReferencePosition();
			result.possibleEvents = GetPossiblePlayerEvents(Instance.PrivateKeysList);
			result.baseValue = ((Character)Player.m_localPlayer).m_nview.GetZDO().GetInt(ZDOVars.s_baseValue, 0);
			return result;
		}
	}
	public interface IKeyManager
	{
		string BlockedGlobalKeys { get; }

		string AllowedGlobalKeys { get; }

		string EnforcedGlobalKeys { get; }

		string BlockedPrivateKeys { get; }

		string AllowedPrivateKeys { get; }

		string EnforcedPrivateKeys { get; }

		HashSet<string> BlockedGlobalKeysList { get; }

		HashSet<string> AllowedGlobalKeysList { get; }

		HashSet<string> EnforcedGlobalKeysList { get; }

		HashSet<string> BlockedPrivateKeysList { get; }

		HashSet<string> AllowedPrivateKeysList { get; }

		HashSet<string> EnforcedPrivateKeysList { get; }

		HashSet<string> PrivateKeysList { get; }

		int GetPublicBossKeysCount();

		int GetPrivateBossKeysCount();

		bool BlockGlobalKey(bool blockAll, string globalKey);

		bool HasPrivateKey(string key);

		bool HasGlobalKey(string key);
	}
	public interface IProgressionAPI
	{
	}
	[PublicAPI]
	public class ProgressionAPI : IProgressionAPI
	{
		private static readonly ProgressionAPI _instance;

		public static ProgressionAPI Instance => _instance;

		static ProgressionAPI()
		{
			_instance = new ProgressionAPI();
		}

		protected ProgressionAPI()
		{
		}

		public static bool IsInTheMainScene()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			return ((Scene)(ref activeScene)).name.Equals("main");
		}

		public static HashSet<string> StringToSet(string str)
		{
			HashSet<string> hashSet = new HashSet<string>();
			if (!Utility.IsNullOrWhiteSpace(str))
			{
				List<string> list = str.Split(new char[1] { ',' }).ToList();
				for (int i = 0; i < list.Count; i++)
				{
					hashSet.Add(list[i].Trim().ToLower());
				}
			}
			return hashSet;
		}

		public static Dictionary<string, string> StringToDictionary(string str)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			if (!Utility.IsNullOrWhiteSpace(str))
			{
				List<string> list = str.Split(new char[1] { ',' }).ToList();
				for (int i = 0; i < list.Count - 1; i += 2)
				{
					string key = list[i].Trim();
					if (!dictionary.ContainsKey(key))
					{
						dictionary.Add(key, list[i + 1].Trim());
					}
				}
			}
			return dictionary;
		}

		public static List<string> MergeLists(List<string> list1, List<string> list2)
		{
			return list1.Union(list2).ToList();
		}

		public static bool GetGlobalKey(string key)
		{
			if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.m_globalKeys != null)
			{
				return ZoneSystem.instance.m_globalKeys.Contains(key);
			}
			return false;
		}

		public static HashSet<string> GetGlobalKeys()
		{
			return ZoneSystem.instance.m_globalKeys;
		}

		public static void AddGlobalKey(string key)
		{
			if (!Utility.IsNullOrWhiteSpace(key))
			{
				key = key.ToLower();
				if (!ZoneSystem.instance.m_globalKeys.Contains(key))
				{
					ZoneSystem.instance.m_globalKeys.Add(key);
					ZoneSystem.instance.SendGlobalKeys(ZRoutedRpc.Everybody);
				}
			}
		}

		public static void RemoveGlobalKey(string key)
		{
			if (!Utility.IsNullOrWhiteSpace(key))
			{
				key = key.ToLower();
				ZoneSystem.instance.m_globalKeys.Remove(key);
			}
		}

		public static long GetPlayerID(string playerName)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			string value = playerName.Trim().ToLower();
			List<PlayerInfo> playerList = ZNet.instance.GetPlayerList();
			for (int i = 0; i < playerList.Count; i++)
			{
				if (playerList[i].m_name.Trim().ToLower().Equals(value))
				{
					PlayerInfo val = playerList[i];
					return ((ZDOID)(ref val.m_characterID)).UserID;
				}
			}
			return 0L;
		}

		public static string GetPlayerName(long playerID)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (GetLocalPlayerID() == playerID)
			{
				return GetLocalPlayerName();
			}
			List<PlayerInfo> playerList = ZNet.instance.GetPlayerList();
			for (int i = 0; i < playerList.Count; i++)
			{
				PlayerInfo val = playerList[i];
				if (((ZDOID)(ref val.m_characterID)).UserID == playerID)
				{
					return playerList[i].m_name;
				}
			}
			return playerID.ToString();
		}

		public static string GetLocalPlayerName()
		{
			PlayerProfile playerProfile = Game.instance.GetPlayerProfile();
			if (playerProfile != null)
			{
				return playerProfile.m_playerName;
			}
			return "";
		}

		public static long GetLocalPlayerID()
		{
			return Game.instance.GetPlayerProfile()?.m_playerID ?? 0;
		}

		public static int GetGameDay()
		{
			return EnvMan.instance.GetCurrentDay();
		}

		public static int GetQualityLevel(ItemData item)
		{
			if (item != null)
			{
				return item.m_quality + 1;
			}
			return 1;
		}
	}
	public class SkillsManager
	{
		[HarmonyPatch(typeof(Skills), "LowerAllSkills")]
		public static class Patch_Skills_LowerAllSkills
		{
			private static bool Prefix(Skills __instance, float factor, ref bool __runOriginal)
			{
				if (!__runOriginal)
				{
					return __runOriginal;
				}
				if (!ProgressionConfiguration.Instance.GetEnableSkillManager())
				{
					return true;
				}
				if (ProgressionConfiguration.Instance.GetAllowSkillDrain())
				{
					foreach (KeyValuePair<SkillType, Skill> skillDatum in __instance.m_skillData)
					{
						float skillDrainFloor = Instance.GetSkillDrainFloor();
						float skillDrain = Instance.GetSkillDrain(skillDatum.Value.m_level, skillDrainFloor, factor);
						skillDatum.Value.m_level = Instance.NormalizeSkillLevel(skillDatum.Value.m_level - skillDrain);
						skillDatum.Value.m_accumulator = 0f;
					}
					((Character)__instance.m_player).Message((MessageType)1, "$msg_skills_lowered", 0, (Sprite)null);
					return false;
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(Skill), "Raise")]
		public static class Patch_Skills_Skill_Raise
		{
			private static bool Prefix(Skill __instance, float factor, ref bool __result)
			{
				if (!ProgressionConfiguration.Instance.GetEnableSkillManager())
				{
					return true;
				}
				float increase = __instance.m_info.m_increseStep * factor;
				float skillGainCeiling = Instance.GetSkillGainCeiling();
				float skillAccumulationGain = Instance.GetSkillAccumulationGain(__instance.m_level, skillGainCeiling, increase);
				if (__instance.m_accumulator + skillAccumulationGain >= __instance.GetNextLevelRequirement())
				{
					__instance.m_level = Instance.NormalizeSkillLevel(__instance.m_level += 1f);
					__instance.m_accumulator = 0f;
					__result = true;
				}
				else
				{
					__instance.m_accumulator += skillAccumulationGain;
					__result = false;
				}
				return false;
			}
		}

		private static readonly SkillsManager _instance;

		public const float SKILL_MINIMUM = 0f;

		public const float SKILL_MAXIMUM = 100f;

		private float _cachedSkillFloor;

		private float _cachedSkillCeiling = 100f;

		public static SkillsManager Instance => _instance;

		static SkillsManager()
		{
			_instance = new SkillsManager();
		}

		protected SkillsManager()
		{
		}

		public void UpdateCache()
		{
			if (ProgressionConfiguration.Instance.GetUseBossKeysForSkillLevel())
			{
				int bossesDefeated = ((!ProgressionConfiguration.Instance.GetUsePrivateKeys()) ? GetPublicBossKeysCount() : GetPrivateBossKeysCount());
				_cachedSkillCeiling = (ProgressionConfiguration.Instance.GetOverrideMaximumSkillLevel() ? ((float)ProgressionConfiguration.Instance.GetMaximumSkillLevel()) : GetBossSkillCeiling(bossesDefeated));
				_cachedSkillFloor = (ProgressionConfiguration.Instance.GetOverrideMinimumSkillLevel() ? ((float)ProgressionConfiguration.Instance.GetMinimumSkillLevel()) : GetBossSkillFloor(bossesDefeated));
			}
			else
			{
				_cachedSkillCeiling = GetMaximumSkillLevel();
				_cachedSkillFloor = GetMinimumSkillLevel();
			}
		}

		private float GetMaximumSkillLevel()
		{
			if (ProgressionConfiguration.Instance.GetOverrideMaximumSkillLevel())
			{
				return ProgressionConfiguration.Instance.GetMaximumSkillLevel();
			}
			return 100f;
		}

		private float GetMinimumSkillLevel()
		{
			if (ProgressionConfiguration.Instance.GetOverrideMinimumSkillLevel())
			{
				return ProgressionConfiguration.Instance.GetMinimumSkillLevel();
			}
			return 0f;
		}

		protected virtual int GetPrivateBossKeysCount()
		{
			return KeyManager.Instance.GetPrivateBossKeysCount();
		}

		protected virtual int GetPublicBossKeysCount()
		{
			return KeyManager.Instance.GetPublicBossKeysCount();
		}

		protected float GetBossSkillCeiling(int bossesDefeated)
		{
			return NormalizeSkillLevel(100f - (float)(ProgressionConfiguration.Instance.GetBossKeysSkillPerKey() * (6 - bossesDefeated)));
		}

		protected float GetBossSkillFloor(int bossesDefeated)
		{
			return NormalizeSkillLevel(ProgressionConfiguration.Instance.GetBossKeysSkillPerKey() * bossesDefeated);
		}

		protected float GetSkillDrain(float level, float floor, float factor)
		{
			if (floor < level)
			{
				if (ProgressionConfiguration.Instance.GetUseAbsoluteSkillDrain())
				{
					int absoluteSkillDrain = ProgressionConfiguration.Instance.GetAbsoluteSkillDrain();
					if (ProgressionConfiguration.Instance.GetCompareAndSelectDrain())
					{
						if (ProgressionConfiguration.Instance.GetCompareUseMinimumDrain())
						{
							return Mathf.Min(level * factor, (float)absoluteSkillDrain);
						}
						return Mathf.Max(level * factor, (float)absoluteSkillDrain);
					}
					return absoluteSkillDrain;
				}
				return level * factor;
			}
			return 0f;
		}

		protected float GetSkillAccumulationGain(float level, float ceiling, float increase)
		{
			if (!(ceiling > level))
			{
				return 0f;
			}
			return increase;
		}

		protected float NormalizeSkillLevel(float level)
		{
			return Mathf.Clamp(level, 0f, GetMaximumSkillLevel());
		}

		protected float GetSkillDrainFloor()
		{
			return _cachedSkillFloor;
		}

		protected float GetSkillGainCeiling()
		{
			return _cachedSkillCeiling;
		}
	}
}