Decompiled source of Almanac v3.7.94

Almanac.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using API;
using Almanac.Achievements;
using Almanac.Bounties;
using Almanac.Data;
using Almanac.ExternalAPIs;
using Almanac.Lottery;
using Almanac.Managers;
using Almanac.Marketplace;
using Almanac.NPC;
using Almanac.Quests;
using Almanac.Store;
using Almanac.TreasureHunt;
using Almanac.Tutorials;
using Almanac.UI;
using Almanac.Utilities;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using ServerSync;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;
using Valheim.SettingsGui;
using YamlDotNet.Serialization;

[assembly: Guid("E0E2F92E-557C-4A05-9D89-AA92A0BD75C4")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyProduct("Almanac")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("Almanac")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyFileVersion("3.7.94")]
[assembly: AssemblyCompany("RustyMods")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("3.7.94.0")]
[module: <a6524b31-0149-45bb-8f13-b71b7c2ad05b>RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<491690f8-5c14-4670-8c35-dc408f290e09>Embedded]
	internal sealed class <491690f8-5c14-4670-8c35-dc408f290e09>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	[<491690f8-5c14-4670-8c35-dc408f290e09>Embedded]
	internal sealed class <293b6170-8ea0-48d9-9d57-220f8716613b>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <293b6170-8ea0-48d9-9d57-220f8716613b>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <293b6170-8ea0-48d9-9d57-220f8716613b>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[<491690f8-5c14-4670-8c35-dc408f290e09>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class <10fe1035-bca0-423b-a28b-581755449829>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <10fe1035-bca0-423b-a28b-581755449829>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[<491690f8-5c14-4670-8c35-dc408f290e09>Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class <a6524b31-0149-45bb-8f13-b71b7c2ad05b>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <a6524b31-0149-45bb-8f13-b71b7c2ad05b>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace LocalizationManager
{
	[PublicAPI]
	[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
	[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
	public class Localizer
	{
		private static readonly Dictionary<string, Dictionary<string, Func<string>>> PlaceholderProcessors;

		private static readonly Dictionary<string, Dictionary<string, string>> loadedTexts;

		private static readonly ConditionalWeakTable<Localization, string> localizationLanguage;

		private static readonly List<WeakReference<Localization>> localizationObjects;

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static readonly List<string> fileExtensions;

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Expected O, but got Unknown
				if (_plugin == null)
				{
					IEnumerable<TypeInfo> source;
					try
					{
						source = Assembly.GetExecutingAssembly().DefinedTypes.ToList();
					}
					catch (ReflectionTypeLoadException ex)
					{
						source = from t in ex.Types
							where t != null
							select t.GetTypeInfo();
					}
					_plugin = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)source.First([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
				}
				return _plugin;
			}
		}

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)]
		[method: <10fe1035-bca0-423b-a28b-581755449829>NullableContext(2)]
		[field: <293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)]
		public static event Action OnLocalizationComplete;

		private static void UpdatePlaceholderText(Localization localization, string key)
		{
			localizationLanguage.TryGetValue(localization, out var value);
			string text = loadedTexts[value][key];
			if (PlaceholderProcessors.TryGetValue(key, out var value2))
			{
				text = value2.Aggregate(text, [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (string current, KeyValuePair<string, Func<string>> kv) => current.Replace("{" + kv.Key + "}", kv.Value()));
			}
			localization.AddWord(key, text);
		}

		public static void AddPlaceholder<T>(string key, string placeholder, ConfigEntry<T> config, [<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1, 1 })] Func<T, string> convertConfigValue = null)
		{
			if (convertConfigValue == null)
			{
				convertConfigValue = (T val) => val.ToString();
			}
			if (!PlaceholderProcessors.ContainsKey(key))
			{
				PlaceholderProcessors[key] = new Dictionary<string, Func<string>>();
			}
			config.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				UpdatePlaceholder();
			};
			if (loadedTexts.ContainsKey(Localization.instance.GetSelectedLanguage()))
			{
				UpdatePlaceholder();
			}
			void UpdatePlaceholder()
			{
				PlaceholderProcessors[key][placeholder] = () => convertConfigValue(config.Value);
				UpdatePlaceholderText(Localization.instance, key);
			}
		}

		public static void AddText(string key, string text)
		{
			List<WeakReference<Localization>> list = new List<WeakReference<Localization>>();
			foreach (WeakReference<Localization> localizationObject in localizationObjects)
			{
				if (localizationObject.TryGetTarget(out var target))
				{
					Dictionary<string, string> dictionary = loadedTexts[localizationLanguage.GetOrCreateValue(target)];
					if (!target.m_translations.ContainsKey(key))
					{
						dictionary[key] = text;
						target.AddWord(key, text);
					}
				}
				else
				{
					list.Add(localizationObject);
				}
			}
			foreach (WeakReference<Localization> item in list)
			{
				localizationObjects.Remove(item);
			}
		}

		public static void Load()
		{
			_ = plugin;
		}

		public static void LoadLocalizationLater(Localization __instance)
		{
			LoadLocalization(Localization.instance, __instance.GetSelectedLanguage());
		}

		public static void SafeCallLocalizeComplete()
		{
			Localizer.OnLocalizationComplete?.Invoke();
		}

		private static void LoadLocalization(Localization __instance, string language)
		{
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Expected O, but got Unknown
			if (!localizationLanguage.Remove(__instance))
			{
				localizationObjects.Add(new WeakReference<Localization>(__instance));
			}
			localizationLanguage.Add(__instance, language);
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			foreach (string item in from f in Directory.GetFiles(Paths.ConfigPath, plugin.Info.Metadata.Name + ".*", SearchOption.AllDirectories)
				where fileExtensions.IndexOf(Path.GetExtension(f)) >= 0
				select f)
			{
				string[] array = Path.GetFileNameWithoutExtension(item).Split(new char[1] { '.' });
				if (array.Length >= 2)
				{
					string text = array[1];
					if (dictionary.ContainsKey(text))
					{
						Debug.LogWarning((object)("Duplicate key " + text + " found for " + plugin.Info.Metadata.Name + ". The duplicate file found at " + item + " will be skipped."));
					}
					else
					{
						dictionary[text] = item;
					}
				}
			}
			Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
			string text2 = null;
			if (dictionary.TryGetValue(language, out var value))
			{
				text2 = File.ReadAllText(value);
			}
			else
			{
				byte[] array2 = LoadTranslationFromAssembly(language);
				if (array2 != null)
				{
					text2 = Encoding.UTF8.GetString(array2);
				}
			}
			if (text2 == null && dictionary.TryGetValue("English", out var value2))
			{
				text2 = File.ReadAllText(value2);
			}
			if (text2 != null)
			{
				foreach (KeyValuePair<string, string> item2 in ((BuilderSkeleton<DeserializerBuilder>)new DeserializerBuilder()).IgnoreFields().Build().Deserialize<Dictionary<string, string>>(text2) ?? new Dictionary<string, string>())
				{
					dictionary2[item2.Key] = item2.Value;
				}
			}
			loadedTexts[language] = dictionary2;
			foreach (KeyValuePair<string, string> item3 in dictionary2)
			{
				UpdatePlaceholderText(__instance, item3.Key);
			}
		}

		static Localizer()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			PlaceholderProcessors = new Dictionary<string, Dictionary<string, Func<string>>>();
			loadedTexts = new Dictionary<string, Dictionary<string, string>>();
			localizationLanguage = new ConditionalWeakTable<Localization, string>();
			localizationObjects = new List<WeakReference<Localization>>();
			fileExtensions = new List<string>(2) { ".json", ".yml" };
			Harmony val = new Harmony("org.bepinex.helpers.LocalizationManager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalization", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "SetupGui", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "LoadLocalizationLater", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Start", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Localizer), "SafeCallLocalizeComplete", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		[return: <293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)]
		private static byte[] LoadTranslationFromAssembly(string language)
		{
			foreach (string fileExtension in fileExtensions)
			{
				byte[] array = ReadEmbeddedFileBytes("translations." + language + fileExtension);
				if (array != null)
				{
					return array;
				}
			}
			return null;
		}

		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(2)]
		public static byte[] ReadEmbeddedFileBytes([<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)] string resourceFileName, Assembly containingAssembly = null)
		{
			using MemoryStream memoryStream = new MemoryStream();
			if ((object)containingAssembly == null)
			{
				containingAssembly = Assembly.GetCallingAssembly();
			}
			string text = containingAssembly.GetManifestResourceNames().FirstOrDefault([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (string str) => str.EndsWith(resourceFileName, StringComparison.Ordinal));
			if (text != null)
			{
				containingAssembly.GetManifestResourceStream(text)?.CopyTo(memoryStream);
			}
			return (memoryStream.Length == 0L) ? null : memoryStream.ToArray();
		}
	}
	public static class LocalizationManagerVersion
	{
		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
		public const string Version = "1.4.1";
	}
}
namespace API
{
	[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(2)]
	[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
	public static class EpicMMOSystem_API
	{
		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
		private enum API_State
		{
			NotReady,
			NotInstalled,
			Ready
		}

		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
		public enum Attribut
		{
			Strength,
			Agility,
			Intellect,
			Body,
			Vigour,
			Special
		}

		private static API_State state;

		private static MethodInfo eGetLevel;

		private static MethodInfo eAddExp;

		private static MethodInfo eGetAttribute;

		private static MethodInfo eGetAttributeRusty;

		private static MethodInfo eSetSingleRate;

		public static bool IsLoaded()
		{
			return state == API_State.Ready;
		}

		public static int GetLevel()
		{
			int result = 0;
			Init();
			if (eGetLevel != null)
			{
				result = (int)eGetLevel.Invoke(null, null);
			}
			return result;
		}

		public static int GetAttribute(Attribut attribute)
		{
			int result = 0;
			Init();
			if (eGetAttribute != null)
			{
				result = (int)eGetAttribute.Invoke(null, new object[1] { attribute });
			}
			return result;
		}

		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
		public static int GetAttributeRusty(string attribute)
		{
			int result = 0;
			Init();
			if (eGetAttributeRusty != null)
			{
				result = (int)eGetAttributeRusty.Invoke(null, new object[1] { attribute });
			}
			return result;
		}

		public static void AddExp(int value)
		{
			Init();
			eAddExp?.Invoke(null, new object[1] { value });
		}

		public static void SetSingleRate(float rate)
		{
			Init();
			eSetSingleRate?.Invoke(null, new object[1] { rate });
		}

		static EpicMMOSystem_API()
		{
			state = API_State.NotReady;
			Init();
		}

		private static void Init()
		{
			API_State aPI_State = state;
			if ((uint)(aPI_State - 1) > 1u)
			{
				if (Type.GetType("EpicMMOSystem.EpicMMOSystem, EpicMMOSystem") == null)
				{
					state = API_State.NotInstalled;
					return;
				}
				state = API_State.Ready;
				Type type = Type.GetType("API.EMMOS_API, EpicMMOSystem");
				eGetLevel = type?.GetMethod("GetLevel", BindingFlags.Static | BindingFlags.Public);
				eAddExp = type?.GetMethod("AddExp", BindingFlags.Static | BindingFlags.Public);
				eGetAttribute = type?.GetMethod("GetAttribute", BindingFlags.Static | BindingFlags.Public);
				eGetAttributeRusty = type?.GetMethod("GetAttribute", BindingFlags.Static | BindingFlags.Public);
				eSetSingleRate = type?.GetMethod("SetSingleRate", BindingFlags.Static | BindingFlags.Public);
			}
		}
	}
}
namespace Almanac
{
	[PublicAPI]
	[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
	[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
	public static class API
	{
		public static int GetPlayerDeathCount(string creatureID)
		{
			CritterHelper.CritterInfo value;
			return CritterHelper.namedCritters.TryGetValue(creatureID, out value) ? PlayerInfo.GetPlayerStat(PlayerInfo.RecordType.Death, value.character.m_name) : 0;
		}

		public static int GetPlayerCompletedAchievements(Player player)
		{
			return player.GetCollectedAchievements().Count;
		}

		public static void AddTokens(Player player, int amount, bool message)
		{
			player.AddTokens(amount, message);
		}

		public static void RemoveTokens(Player player, int amount)
		{
			player.RemoveTokens(amount);
		}

		public static int GetTokens(Player player)
		{
			return player.GetTokens();
		}
	}
	[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
	[PublicAPI]
	[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(2)]
	public static class Almanac_API
	{
		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
		internal class Method
		{
			private const string Namespace = "Almanac";

			private const string ClassName = "API";

			private const string Assembly = "Almanac";

			private const string API_LOCATION = "Almanac.API, Almanac";

			private static readonly Dictionary<string, Type> CachedTypes = new Dictionary<string, Type>();

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)]
			private readonly MethodInfo info;

			[return: <293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 1, 2 })]
			public object[] Invoke([<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 1, 2 })] params object[] args)
			{
				object obj = info?.Invoke(null, args);
				object[] array = new object[args.Length + 1];
				array[0] = obj;
				Array.Copy(args, 0, array, 1, args.Length);
				return array;
			}

			public Method(string typeNameWithAssembly, string methodName, BindingFlags bindingFlags = BindingFlags.Static | BindingFlags.Public)
			{
				if (!TryGetType(typeNameWithAssembly, out var type))
				{
					return;
				}
				if (type == null)
				{
					Debug.LogWarning((object)("Type resolution returned null for: '" + typeNameWithAssembly + "'"));
					return;
				}
				info = type.GetMethod(methodName, bindingFlags);
				if (info == null)
				{
					Debug.LogWarning((object)("Failed to find public static method '" + methodName + "' in type '" + type.FullName + "'. Verify the method name is correct, the method exists, and it is marked as public static. "));
				}
			}

			public Method(string methodName, BindingFlags bindingFlags = BindingFlags.Static | BindingFlags.Public)
				: this("Almanac.API, Almanac", methodName, bindingFlags)
			{
			}

			private static bool TryGetType(string typeNameWithAssembly, [<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)] out Type type)
			{
				if (CachedTypes.TryGetValue(typeNameWithAssembly, out type))
				{
					return true;
				}
				Type type2 = Type.GetType(typeNameWithAssembly);
				if ((object)type2 == null)
				{
					Debug.LogWarning((object)("Failed to resolve type: '" + typeNameWithAssembly + "'. Verify the namespace, class name, and assembly name are correct. Ensure the assembly is loaded and accessible."));
					return false;
				}
				type = type2;
				CachedTypes[typeNameWithAssembly] = type2;
				return true;
			}

			public Method(string typeNameWithAssembly, string methodName, params Type[] types)
			{
				if (!TryGetType(typeNameWithAssembly, out var type))
				{
					return;
				}
				if (type == null)
				{
					Debug.LogWarning((object)("Type resolution returned null for: '" + typeNameWithAssembly + "'"));
					return;
				}
				info = type.GetMethod(methodName, types);
				if (info == null)
				{
					Debug.LogWarning((object)("Failed to find public static method '" + methodName + "' in type '" + type.FullName + "'. Verify the method name is correct, the method exists, and it is marked as public static. "));
				}
			}

			public Method(string methodName, params Type[] types)
				: this("Almanac.API, Almanac", methodName, types)
			{
			}

			[PublicAPI]
			public ParameterInfo[] GetParameters()
			{
				return info?.GetParameters() ?? Array.Empty<ParameterInfo>();
			}

			[PublicAPI]
			public static void ClearCache()
			{
				CachedTypes.Clear();
			}
		}

		private static Method _GetPlayerDeathCount;

		private static Method _GetPlayerCompletedAchievements;

		private static Method _GetTokens;

		private static Method _AddTokens;

		private static Method _RemoveTokens;

		static Almanac_API()
		{
			if (IsLoaded())
			{
				_GetPlayerDeathCount = new Method("GetPlayerDeathCount");
				_GetPlayerCompletedAchievements = new Method("GetPlayerCompletedAchievements");
				_GetTokens = new Method("GetTokens");
				_AddTokens = new Method("AddTokens");
				_RemoveTokens = new Method("RemoveTokens");
			}
		}

		public static bool IsLoaded()
		{
			return Type.GetType("Almanac.API, Almanac") != null;
		}

		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
		public static int GetPlayerDeathCount(string creatureID)
		{
			object[] array = _GetPlayerDeathCount?.Invoke(creatureID);
			return (int)(((array != null) ? array[0] : null) ?? ((object)0));
		}
	}
	[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
	[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
	public static class Leaderboard
	{
		[Serializable]
		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
		public class LeaderboardInfo
		{
			private static Entries.EntryBuilder builder = new Entries.EntryBuilder();

			public string PlayerName = string.Empty;

			public int CollectedAchievements;

			public int Kills;

			public int Deaths;

			public DateTime LastUpdated;

			public LeaderboardInfo(string playerName, int collectedAchievements, int kills, int deaths)
			{
				PlayerName = playerName;
				CollectedAchievements = collectedAchievements;
				Kills = kills;
				Deaths = deaths;
				LastUpdated = DateTime.UtcNow;
			}

			public LeaderboardInfo()
			{
			}

			public int GetRank()
			{
				return CollectedAchievements + Mathf.Max(Kills / Math.Max(Deaths, 1), 0);
			}

			public List<Entries.Entry> ToEntries()
			{
				builder.Clear();
				builder.Add(Keys.CollectedAchievement, CollectedAchievements);
				builder.Add(Keys.TotalKills, Kills);
				builder.Add(Keys.TotalDeaths, Deaths);
				builder.Add(Keys.Ratio, (Deaths == 0) ? ((float)Kills) : ((float)Kills / (float)Deaths));
				builder.Add(Keys.LastUpdated, LastUpdated.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss"));
				return builder.ToList();
			}

			public void OnClick(AlmanacPanel panel, AlmanacPanel.ElementView.Element item)
			{
				panel.elementView.SetSelected(item);
				panel.description.Reset();
				panel.description.SetName(PlayerName);
				ToEntries().Build(panel.description.view);
				panel.description.view.Resize();
			}
		}

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)]
		private static string LeaderboardFileName;

		private static readonly CustomSyncedValue<string> SyncedLeaderboard = new CustomSyncedValue<string>(AlmanacPlugin.ConfigSync, "Almanac_Server_Synced_Leaderboard", "");

		public static readonly Dictionary<string, LeaderboardInfo> players = new Dictionary<string, LeaderboardInfo>();

		public static readonly AlmanacDir LeaderboardDir = new AlmanacDir(AlmanacPlugin.AlmanacDir.Path, "Leaderboards");

		private static readonly ISerializer serializer = new SerializerBuilder().Build();

		private static readonly IDeserializer deserializer = new DeserializerBuilder().Build();

		public static void Setup()
		{
			AlmanacPlugin.OnZNetAwake += Initialize;
			SyncedLeaderboard.ValueChanged += OnSyncedLeaderboardChange;
			AlmanacPlugin.OnZNetSave += Save;
			AlmanacPlugin.OnPlayerProfileLoadPlayerDataPostfix += delegate
			{
				SendLocalPlayerInfo();
			};
			AlmanacPlugin.OnPlayerProfileSavePlayerDataPostfix += SendLocalPlayerInfo;
		}

		private static void Initialize()
		{
			if (Configs.AddLogs)
			{
				AlmanacPlugin.LogDebug("Almanac.Leaderboard.Initialize");
			}
			LeaderboardFileName = ZNet.instance.GetWorldName() + ".Leaderboard.dat";
			ZRoutedRpc.instance.Register<ZPackage>("RPC_Leaderboard", (Action<long, ZPackage>)RPC_Leaderboard);
			Read();
			UpdateServerLeaderboard();
		}

		private static void UpdateServerLeaderboard()
		{
			if (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer())
			{
				string value = serializer.Serialize((object)players);
				SyncedLeaderboard.Value = value;
				if (Configs.AddLogs)
				{
					AlmanacPlugin.LogDebug("Server: Leaderboard.Update");
				}
			}
		}

		private static void OnSyncedLeaderboardChange()
		{
			if (!Object.op_Implicit((Object)(object)ZNet.instance) || ZNet.instance.IsServer() || string.IsNullOrEmpty(SyncedLeaderboard.Value))
			{
				return;
			}
			try
			{
				Dictionary<string, LeaderboardInfo> other = deserializer.Deserialize<Dictionary<string, LeaderboardInfo>>(SyncedLeaderboard.Value);
				players.Clear();
				players.AddRange(other);
				if (Configs.AddLogs)
				{
					AlmanacPlugin.LogDebug("Client: Leaderboard.Update");
				}
			}
			catch
			{
				AlmanacPlugin.LogWarning("Failed to parse server leaderboard");
			}
		}

		public static List<LeaderboardInfo> GetLeaderboard()
		{
			return (from player in players.Values.ToList()
				orderby player.GetRank()
				select player).ToList();
		}

		private static void SendLocalPlayerInfo()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			if (Object.op_Implicit((Object)(object)ZNet.instance) && Object.op_Implicit((Object)(object)Player.m_localPlayer) && ((Character)Player.m_localPlayer).m_nview.IsValid())
			{
				LeaderboardInfo leaderboardInfo = new LeaderboardInfo(Player.m_localPlayer.GetPlayerName(), Player.m_localPlayer.GetCollectedAchievements().Count, PlayerInfo.GetPlayerStat((PlayerStatType)6).Floor(), PlayerInfo.GetPlayerStat((PlayerStatType)0).Floor());
				if (ZNet.instance.IsServer())
				{
					players[leaderboardInfo.PlayerName] = leaderboardInfo;
					UpdateServerLeaderboard();
					return;
				}
				ZPackage val = new ZPackage();
				val.Write(leaderboardInfo.PlayerName);
				val.Write(leaderboardInfo.CollectedAchievements);
				val.Write(leaderboardInfo.Kills);
				val.Write(leaderboardInfo.Deaths);
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "RPC_Leaderboard", new object[1] { val });
			}
		}

		public static void RPC_Leaderboard(long sender, ZPackage pkg)
		{
			string text = pkg.ReadString();
			int collectedAchievements = pkg.ReadInt();
			int kills = pkg.ReadInt();
			int deaths = pkg.ReadInt();
			players[text] = new LeaderboardInfo(text, collectedAchievements, kills, deaths);
			UpdateServerLeaderboard();
		}

		private static void Save()
		{
			if (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsServer() && LeaderboardFileName != null)
			{
				string text = serializer.Serialize((object)players);
				byte[] content = CompressAndEncode(text);
				LeaderboardDir.WriteAllBytes(LeaderboardFileName, content);
				if (Configs.AddLogs)
				{
					AlmanacPlugin.LogDebug("Server: Almanac.Leaderboard.Save");
				}
			}
		}

		private static void Read()
		{
			if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer() || LeaderboardFileName == null || !LeaderboardDir.FileExists(LeaderboardFileName))
			{
				return;
			}
			try
			{
				byte[] compressedData = LeaderboardDir.ReadAllBytes(LeaderboardFileName);
				string text = DecompressAndDecode(compressedData);
				Dictionary<string, LeaderboardInfo> other = deserializer.Deserialize<Dictionary<string, LeaderboardInfo>>(text);
				players.Clear();
				players.AddRange(other);
			}
			catch
			{
				AlmanacPlugin.LogWarning("Failed to parse server leaderboard: " + Path.GetFileName(LeaderboardFileName));
			}
		}

		private static byte[] CompressAndEncode(string text)
		{
			byte[] bytes = Encoding.UTF8.GetBytes(text);
			using MemoryStream memoryStream = new MemoryStream();
			using GZipStream gZipStream = new GZipStream(memoryStream, CompressionMode.Compress);
			gZipStream.Write(bytes, 0, bytes.Length);
			gZipStream.Close();
			return memoryStream.ToArray();
		}

		private static string DecompressAndDecode(byte[] compressedData)
		{
			using MemoryStream stream = new MemoryStream(compressedData);
			using GZipStream gZipStream = new GZipStream(stream, CompressionMode.Decompress);
			using MemoryStream memoryStream = new MemoryStream();
			gZipStream.CopyTo(memoryStream);
			return Encoding.UTF8.GetString(memoryStream.ToArray());
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
	[BepInPlugin("RustyMods.Almanac", "Almanac", "3.7.94")]
	[BepInIncompatibility("randyknapp.mods.auga")]
	[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(2)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class AlmanacPlugin : BaseUnityPlugin
	{
		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
		[HarmonyPatch(typeof(PlayerProfile), "SavePlayerData")]
		private static class PlayerProfile_SavePlayerData_Patch
		{
			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			[UsedImplicitly]
			private static void Prefix(Player player)
			{
				AlmanacPlugin.OnPlayerProfileSavePlayerDataPrefix?.Invoke(player);
			}

			[UsedImplicitly]
			private static void Postfix()
			{
				AlmanacPlugin.OnPlayerProfileSavePlayerDataPostfix?.Invoke();
			}
		}

		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
		[HarmonyPatch(typeof(PlayerProfile), "LoadPlayerData")]
		private static class PlayerProfile_LoadPlayerData_Patch
		{
			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			[UsedImplicitly]
			private static void Postfix(Player player)
			{
				AlmanacPlugin.OnPlayerProfileLoadPlayerDataPostfix?.Invoke(player);
			}
		}

		[HarmonyPatch(typeof(ZNet), "Save")]
		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
		private static class ZNet_Save_Patch
		{
			[UsedImplicitly]
			private static void Postfix()
			{
				AlmanacPlugin.OnZNetSave?.Invoke();
			}
		}

		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
		[HarmonyPatch(typeof(ZNet), "Awake")]
		private static class ZNet_Awake_Patch
		{
			[UsedImplicitly]
			private static void Postfix()
			{
				AlmanacPlugin.OnZNetAwake?.Invoke();
			}
		}

		[HarmonyPriority(0)]
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
		public class ZNetScene_Awake_Patch
		{
			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			[UsedImplicitly]
			public static void Postfix(ZNetScene __instance)
			{
				foreach (GameObject prefab in __instance.m_prefabs)
				{
					if (!((Object)(object)prefab == (Object)null))
					{
						AlmanacPlugin.OnZNetScenePrefabs?.Invoke(prefab);
					}
				}
				AlmanacPlugin.OnZNetSceneAwake?.Invoke();
			}
		}

		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
		[HarmonyPriority(0)]
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		private static class ObjectDB_Awake_Patch
		{
			[UsedImplicitly]
			private static void Postfix()
			{
				if ((Object)(object)ZNetScene.instance == (Object)null)
				{
					return;
				}
				foreach (GameObject item in ObjectDB.instance.m_items)
				{
					if (!((Object)(object)item == (Object)null))
					{
						AlmanacPlugin.OnObjectDBPrefabs?.Invoke(item);
					}
				}
				foreach (StatusEffect statusEffect in ObjectDB.instance.m_StatusEffects)
				{
					SpriteManager.OnObjectDBStatusEffects(statusEffect);
				}
				AlmanacPlugin.OnObjectDBAwake?.Invoke();
			}
		}

		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
		[HarmonyPatch(typeof(FejdStartup), "OnNewCharacterDone")]
		private static class FejdStartup_OnNewCharacterDone_Patch
		{
			[UsedImplicitly]
			private static void Prefix()
			{
				AlmanacPlugin.OnNewCharacterDone?.Invoke();
			}
		}

		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
			public static readonly <>c <>9 = new <>c();

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 0, 1, 1 })]
			public static Action<string[]> <>9__48_0;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 0, 1 })]
			public static Action<ZPackage> <>9__48_1;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 0, 1, 1 })]
			public static Action<string[]> <>9__48_2;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 0, 1, 1 })]
			public static Action<string[]> <>9__48_3;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 0, 1, 1 })]
			public static Action<string[]> <>9__48_4;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
			public static ConsoleEventFailable <>9__49_0;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
			public static Func<KeyValuePair<string, CommandData>, bool> <>9__49_1;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
			public static Func<KeyValuePair<string, CommandData>, string> <>9__49_2;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__49_3;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__49_4;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__49_5;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__49_7;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__49_8;

			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 0, 1 })]
			public static Func<ConsoleEventArgs, bool> <>9__49_9;

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			internal void <SetupDiscordCommands>b__48_0(string[] args)
			{
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Expected O, but got Unknown
				if (args.Length < 2)
				{
					return;
				}
				string text = args[1].Trim();
				if (!int.TryParse(args[2].Trim(), out var result))
				{
					return;
				}
				if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Player.m_localPlayer.GetPlayerName() == text)
				{
					Player.m_localPlayer.AddTokens(result);
					return;
				}
				ZNetPeer peerByPlayerName = ZNet.instance.GetPeerByPlayerName(text);
				if (peerByPlayerName != null)
				{
					ZPackage val = new ZPackage();
					val.Write("!almanactokens");
					val.Write(result);
					peerByPlayerName.m_rpc.Invoke("RPC_BotToClient", new object[1] { val });
				}
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			internal void <SetupDiscordCommands>b__48_1(ZPackage pkg)
			{
				int amount = pkg.ReadInt();
				Player.m_localPlayer.AddTokens(amount);
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			internal void <SetupDiscordCommands>b__48_2(string[] _)
			{
				List<Leaderboard.LeaderboardInfo> leaderboard = Leaderboard.GetLeaderboard();
				if (leaderboard.Count == 0)
				{
					DiscordBot_API.SendWebhookMessage(DiscordBot_API.Channel.Commands, "Leaderboard is empty");
					return;
				}
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				foreach (Leaderboard.LeaderboardInfo item in leaderboard)
				{
					dictionary[item.PlayerName] = "```" + string.Join("\n", new List<string>
					{
						$"Achievements: {item.CollectedAchievements}",
						$"Kills: {item.Kills}",
						$"Deaths: {item.Deaths}",
						$"Rank: {item.GetRank()}"
					}) + "```";
				}
				DiscordBot_API.SendWebhookTable(DiscordBot_API.Channel.Commands, "Leaderboard", dictionary);
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			internal void <SetupDiscordCommands>b__48_3(string[] _)
			{
				List<MarketManager.MarketItem> marketItems = MarketManager.GetMarketItems();
				if (marketItems.Count <= 0)
				{
					DiscordBot_API.SendWebhookMessage(DiscordBot_API.Channel.Commands, "No player items on marketplace");
					return;
				}
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				foreach (MarketManager.MarketItem item in marketItems)
				{
					dictionary[item.itemData.m_shared.m_name] = $"```Cost: {item.GetCostPerUnit()} {Keys.AlmanacToken}\nPosted by: {item.PostedBy}\nDate posted: {item.DatePosted:yyyy-M-d dddd}```";
				}
				DiscordBot_API.SendWebhookTable(DiscordBot_API.Channel.Commands, "Marketplace", dictionary);
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			internal void <SetupDiscordCommands>b__48_4(string[] args)
			{
				if (args.Length >= 2)
				{
					string key = args[1].Trim();
					if (!Leaderboard.players.Remove(key))
					{
						DiscordBot_API.SendWebhookMessage(DiscordBot_API.Channel.Commands, "Failed to find leaderboard player");
					}
				}
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
			internal object <SetupCommands>b__49_0(ConsoleEventArgs args)
			{
				if (args.Length < 2)
				{
					return false;
				}
				if (!CommandData.m_commands.TryGetValue(args[1], out var value))
				{
					return false;
				}
				return value.Run(args);
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
			internal bool <SetupCommands>b__49_1(KeyValuePair<string, CommandData> x)
			{
				return !x.Value.IsSecret();
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
			internal string <SetupCommands>b__49_2(KeyValuePair<string, CommandData> x)
			{
				return x.Key;
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			internal bool <SetupCommands>b__49_3(ConsoleEventArgs _)
			{
				if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return false;
				}
				Player.m_localPlayer.ClearRecords();
				Player.m_localPlayer.ClearTokens();
				Player.m_localPlayer.ClearSavedQuests();
				Player.m_localPlayer.ClearSavedDialogues();
				Player.m_localPlayer.ClearNotices();
				return true;
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			internal bool <SetupCommands>b__49_4(ConsoleEventArgs _)
			{
				if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return false;
				}
				Player.m_localPlayer.ClearSavedQuests();
				return true;
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			internal bool <SetupCommands>b__49_5(ConsoleEventArgs _)
			{
				if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return false;
				}
				Player.m_localPlayer.ClearSavedDialogues();
				return true;
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			internal bool <SetupCommands>b__49_7(ConsoleEventArgs _)
			{
				if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return false;
				}
				Player.m_localPlayer.ClearRecords();
				Player.m_localPlayer.ClearTokens();
				Player.m_localPlayer.ClearSavedQuests();
				Player.m_localPlayer.ClearSavedDialogues();
				Player.m_localPlayer.ClearNotices();
				Player.m_localPlayer.m_knownBiome.Clear();
				Player.m_localPlayer.m_knownMaterial.Clear();
				Player.m_localPlayer.m_knownRecipes.Clear();
				Player.m_localPlayer.m_knownStations.Clear();
				Player.m_localPlayer.m_knownTexts.Clear();
				Player.m_localPlayer.m_trophies.Clear();
				return true;
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			internal bool <SetupCommands>b__49_8(ConsoleEventArgs args)
			{
				if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return false;
				}
				if (args.Length < 3)
				{
					return false;
				}
				if (!int.TryParse(args[2], out var result))
				{
					return false;
				}
				Player.m_localPlayer.AddTokens(result);
				return true;
			}

			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
			internal bool <SetupCommands>b__49_9(ConsoleEventArgs args)
			{
				if (args.Length < 2)
				{
					return false;
				}
				if (!int.TryParse(args[1], out var result))
				{
					return false;
				}
				LotteryManager.LotteryTotal = result;
				return true;
			}
		}

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
		internal const string ModName = "Almanac";

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
		internal const string ModVersion = "3.7.94";

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
		internal const string Author = "RustyMods";

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
		private const string ModGUID = "RustyMods.Almanac";

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
		public const string ConfigFileName = "RustyMods.Almanac.cfg";

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
		public static readonly string ConfigFileFullPath;

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
		internal static string ConnectionError;

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
		public readonly Harmony _harmony = new Harmony("RustyMods.Almanac");

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
		public static readonly ConfigSync ConfigSync;

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
		public static readonly AlmanacDir AlmanacDir;

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
		public static AlmanacPlugin instance;

		public static event Action OnZNetAwake;

		public static event Action OnZNetSceneAwake;

		public static event Action OnZNetSave;

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
		[method: <293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
		[field: <293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
		public static event Action<Player> OnPlayerProfileLoadPlayerDataPostfix;

		public static event Action OnPlayerProfileSavePlayerDataPostfix;

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
		[method: <293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
		[field: <293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
		public static event Action<Player> OnPlayerProfileSavePlayerDataPrefix;

		public static event Action OnObjectDBAwake;

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
		[method: <293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
		[field: <293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
		public static event Action<GameObject> OnZNetScenePrefabs;

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
		[method: <293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
		[field: <293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
		public static event Action<GameObject> OnObjectDBPrefabs;

		public static event Action OnNewCharacterDone;

		public void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			instance = this;
			Configs.Load();
			Clone._root = new GameObject("Almanac.PrefabManager.Clones");
			Object.DontDestroyOnLoad((Object)(object)Clone._root);
			Clone._root.SetActive(false);
			Keys.Write();
			Localizer.Load();
			SpriteManager.RegisterCustomIcons();
			StoreManager.Setup();
			BountyManager.Setup();
			TreasureManager.Setup();
			AchievementManager.Setup();
			CreatureGroup.Setup();
			CustomEffectManager.Setup();
			Filters.Setup();
			LotteryManager.Setup();
			MarketManager.Setup();
			QuestManager.Setup();
			Leaderboard.Setup();
			CritterHelper.Setup();
			ItemHelper.Setup();
			PieceHelper.Setup();
			PlayerInfo.Setup();
			DialogueManager.Setup();
			RandomTalkManager.Setup();
			SetupCommands();
			SetupDiscordCommands();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
		}

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

		private void Update()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			QuestPanel questPanel = QuestPanel.instance;
			if (questPanel != null && !(Time.time - questPanel.lastInputTime < 0.1f) && ZInput.GetKeyDown(Configs.QuestKey, true))
			{
				questPanel.lastInputTime = Time.time;
				questPanel.Toggle();
			}
		}

		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
		public static void LogInfo(string msg)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)msg);
		}

		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
		public static void LogWarning(string msg)
		{
			((BaseUnityPlugin)instance).Logger.LogWarning((object)msg);
		}

		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
		public static void LogError(string msg)
		{
			((BaseUnityPlugin)instance).Logger.LogError((object)msg);
		}

		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
		public static void LogDebug(string msg)
		{
			((BaseUnityPlugin)instance).Logger.LogDebug((object)msg);
		}

		private static void SetupDiscordCommands()
		{
			if (!DiscordBot_API.IsLoaded())
			{
				return;
			}
			DiscordBot_API.RegisterCommand("!almanactokens", "give player tokens, `player name` `amount`", [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)] (string[] args) =>
			{
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Expected O, but got Unknown
				if (args.Length >= 2)
				{
					string text = args[1].Trim();
					if (int.TryParse(args[2].Trim(), out var result))
					{
						if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Player.m_localPlayer.GetPlayerName() == text)
						{
							Player.m_localPlayer.AddTokens(result);
						}
						else
						{
							ZNetPeer peerByPlayerName = ZNet.instance.GetPeerByPlayerName(text);
							if (peerByPlayerName != null)
							{
								ZPackage val = new ZPackage();
								val.Write("!almanactokens");
								val.Write(result);
								peerByPlayerName.m_rpc.Invoke("RPC_BotToClient", new object[1] { val });
							}
						}
					}
				}
			}, [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)] (ZPackage pkg) =>
			{
				int amount = pkg.ReadInt();
				Player.m_localPlayer.AddTokens(amount);
			}, adminOnly: true, isSecret: false, "fries");
			DiscordBot_API.RegisterCommand("!almanacleaderboard", "show almanac leaderboard", [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)] (string[] _) =>
			{
				List<Leaderboard.LeaderboardInfo> leaderboard = Leaderboard.GetLeaderboard();
				if (leaderboard.Count == 0)
				{
					DiscordBot_API.SendWebhookMessage(DiscordBot_API.Channel.Commands, "Leaderboard is empty");
				}
				else
				{
					Dictionary<string, string> dictionary = new Dictionary<string, string>();
					foreach (Leaderboard.LeaderboardInfo item in leaderboard)
					{
						dictionary[item.PlayerName] = "```" + string.Join("\n", new List<string>
						{
							$"Achievements: {item.CollectedAchievements}",
							$"Kills: {item.Kills}",
							$"Deaths: {item.Deaths}",
							$"Rank: {item.GetRank()}"
						}) + "```";
					}
					DiscordBot_API.SendWebhookTable(DiscordBot_API.Channel.Commands, "Leaderboard", dictionary);
				}
			}, null, adminOnly: false, isSecret: false, "brokenheart");
			DiscordBot_API.RegisterCommand("!almanacstore", "displays player items on sale", [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)] (string[] _) =>
			{
				List<MarketManager.MarketItem> marketItems = MarketManager.GetMarketItems();
				if (marketItems.Count <= 0)
				{
					DiscordBot_API.SendWebhookMessage(DiscordBot_API.Channel.Commands, "No player items on marketplace");
				}
				else
				{
					Dictionary<string, string> dictionary = new Dictionary<string, string>();
					foreach (MarketManager.MarketItem item2 in marketItems)
					{
						dictionary[item2.itemData.m_shared.m_name] = $"```Cost: {item2.GetCostPerUnit()} {Keys.AlmanacToken}\nPosted by: {item2.PostedBy}\nDate posted: {item2.DatePosted:yyyy-M-d dddd}```";
					}
					DiscordBot_API.SendWebhookTable(DiscordBot_API.Channel.Commands, "Marketplace", dictionary);
				}
			});
			DiscordBot_API.RegisterCommand("!leaderboardremove", "removes player entry from leaderboard, `player name`", [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)] (string[] args) =>
			{
				if (args.Length >= 2)
				{
					string key = args[1].Trim();
					if (!Leaderboard.players.Remove(key))
					{
						DiscordBot_API.SendWebhookMessage(DiscordBot_API.Channel.Commands, "Failed to find leaderboard player");
					}
				}
			}, null, adminOnly: true);
		}

		private void SetupCommands()
		{
			//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_002a: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			object obj = <>c.<>9__49_0;
			if (obj == null)
			{
				ConsoleEventFailable val = [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (ConsoleEventArgs args) =>
				{
					if (args.Length < 2)
					{
						return false;
					}
					CommandData value;
					return (!CommandData.m_commands.TryGetValue(args[1], out value)) ? ((object)false) : ((object)value.Run(args));
				};
				<>c.<>9__49_0 = val;
				obj = (object)val;
			}
			ConsoleCommand val2 = new ConsoleCommand("almanac", "Use help to find commands", (ConsoleEventFailable)obj, false, false, false, false, false, new ConsoleOptionsFetcher(Enumerable.ToList), false, false, false);
			CommandData commandData = new CommandData("reset", "clears all almanac data off player file", [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)] (ConsoleEventArgs _) =>
			{
				if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return false;
				}
				Player.m_localPlayer.ClearRecords();
				Player.m_localPlayer.ClearTokens();
				Player.m_localPlayer.ClearSavedQuests();
				Player.m_localPlayer.ClearSavedDialogues();
				Player.m_localPlayer.ClearNotices();
				return true;
			});
			CommandData commandData2 = new CommandData("reset_quests", "clears all quests from player file", [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)] (ConsoleEventArgs _) =>
			{
				if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return false;
				}
				Player.m_localPlayer.ClearSavedQuests();
				return true;
			});
			CommandData commandData3 = new CommandData("reset_dialogues", "clears all dialogues from player file", [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)] (ConsoleEventArgs _) =>
			{
				if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return false;
				}
				Player.m_localPlayer.ClearSavedDialogues();
				return true;
			});
			CommandData commandData4 = new CommandData("size", "prints the kilobyte size of almanac data on player file", [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)] (ConsoleEventArgs _) =>
			{
				if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return false;
				}
				int num = Player.m_localPlayer.GetTokensByteCount() + Player.m_localPlayer.GetRecordByteCount() + Player.m_localPlayer.GetQuestByteCount() + Player.m_localPlayer.GetDialogueByteCount();
				double num2 = (double)num / 1024.0;
				((BaseUnityPlugin)this).Logger.LogInfo((object)$"Almanac Data Size: {num2} kilobytes");
				return true;
			});
			CommandData commandData5 = new CommandData("full_reset", "clears all almanac data as well as valheim player data", [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)] (ConsoleEventArgs _) =>
			{
				if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return false;
				}
				Player.m_localPlayer.ClearRecords();
				Player.m_localPlayer.ClearTokens();
				Player.m_localPlayer.ClearSavedQuests();
				Player.m_localPlayer.ClearSavedDialogues();
				Player.m_localPlayer.ClearNotices();
				Player.m_localPlayer.m_knownBiome.Clear();
				Player.m_localPlayer.m_knownMaterial.Clear();
				Player.m_localPlayer.m_knownRecipes.Clear();
				Player.m_localPlayer.m_knownStations.Clear();
				Player.m_localPlayer.m_knownTexts.Clear();
				Player.m_localPlayer.m_trophies.Clear();
				return true;
			});
			CommandData commandData6 = new CommandData("tokens", "give local player almanac tokens", [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)] (ConsoleEventArgs args) =>
			{
				if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return false;
				}
				if (args.Length < 3)
				{
					return false;
				}
				if (!int.TryParse(args[2], out var result))
				{
					return false;
				}
				Player.m_localPlayer.AddTokens(result);
				return true;
			}, null, isSecret: false, adminOnly: true);
			CommandData commandData7 = new CommandData("fullhouse", "[amount] Set current full house lottery reward", [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)] (ConsoleEventArgs args) =>
			{
				if (args.Length < 2)
				{
					return false;
				}
				if (!int.TryParse(args[1], out var result))
				{
					return false;
				}
				LotteryManager.LotteryTotal = result;
				return true;
			}, null, isSecret: false, adminOnly: true);
		}

		static AlmanacPlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + "RustyMods.Almanac.cfg";
			ConnectionError = "";
			ConfigSync = new ConfigSync("RustyMods.Almanac")
			{
				DisplayName = "Almanac",
				CurrentVersion = "3.7.94",
				MinimumRequiredVersion = "3.7.94"
			};
			AlmanacDir = new AlmanacDir(Paths.ConfigPath, "Almanac");
			instance = null;
		}
	}
	[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
	public static class RegisterAndCheckVersion
	{
		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			AlmanacPlugin.LogDebug("Registering version RPC handler");
			peer.m_rpc.Register<ZPackage>("Almanac_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_Almanac_Version);
			AlmanacPlugin.LogDebug("Invoking version check");
			ZPackage val = new ZPackage();
			val.Write("3.7.94");
			peer.m_rpc.Invoke("Almanac_VersionCheck", new object[1] { val });
		}
	}
	[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
	[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
	[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
	public static class VerifyClient
	{
		private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance)
		{
			if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc))
			{
				return true;
			}
			AlmanacPlugin.LogWarning("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting");
			rpc.Invoke("Error", new object[1] { 3 });
			return false;
		}

		private static void Postfix(ZNet __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "RequestAdminSync", new object[1] { (object)new ZPackage() });
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "ShowConnectError")]
	public class ShowConnectionError
	{
		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
		private static void Postfix(FejdStartup __instance)
		{
			if (__instance.m_connectionFailedPanel.activeSelf)
			{
				__instance.m_connectionFailedError.fontSizeMax = 25f;
				__instance.m_connectionFailedError.fontSizeMax = 15f;
				TMP_Text connectionFailedError = __instance.m_connectionFailedError;
				connectionFailedError.text = connectionFailedError.text + "\n" + AlmanacPlugin.ConnectionError;
			}
		}
	}
	[HarmonyPatch(typeof(ZNet), "Disconnect")]
	public static class RemoveDisconnectedPeerFromVerified
	{
		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			if (__instance.IsServer())
			{
				AlmanacPlugin.LogInfo("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list");
				RpcHandlers.ValidatedPeers.Remove(peer.m_rpc);
			}
		}
	}
	[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
	[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
	public static class RpcHandlers
	{
		public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>();

		public static void RPC_Almanac_Version(ZRpc rpc, ZPackage pkg)
		{
			string text = pkg.ReadString();
			AlmanacPlugin.LogInfo("Version check, local: 3.7.94,  remote: " + text);
			if (text != "3.7.94")
			{
				AlmanacPlugin.ConnectionError = "Almanac Installed: 3.7.94\n Needed: " + text;
				if (ZNet.instance.IsServer())
				{
					AlmanacPlugin.LogWarning("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting");
					rpc.Invoke("Error", new object[1] { 3 });
				}
			}
			else if (!ZNet.instance.IsServer())
			{
				AlmanacPlugin.LogInfo("Received same version from server!");
			}
			else
			{
				AlmanacPlugin.LogInfo("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list");
				ValidatedPeers.Add(rpc);
			}
		}
	}
}
namespace Almanac.Utilities
{
	[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
	[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
	public class AlmanacDir
	{
		public readonly string Path;

		public bool Exists => Directory.Exists(Path);

		public AlmanacDir(string dir, string name)
		{
			Path = System.IO.Path.Combine(dir, name);
			EnsureDirectoryExists();
		}

		private void EnsureDirectoryExists()
		{
			if (!Directory.Exists(Path))
			{
				Directory.CreateDirectory(Path);
			}
		}

		public string[] GetFiles(string searchPattern = "*", bool includeSubDirs = false)
		{
			SearchOption searchOption = (includeSubDirs ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly);
			return ExecuteWithRetry([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] () => Directory.GetFiles(Path, searchPattern, searchOption));
		}

		public string[] GetDirectories(string searchPattern = "*")
		{
			return ExecuteWithRetry([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] () => Directory.GetDirectories(Path, searchPattern));
		}

		public string CreateDir(string dirName)
		{
			string text = System.IO.Path.Combine(Path, dirName);
			if (Directory.Exists(text))
			{
				return text;
			}
			Directory.CreateDirectory(text);
			return text;
		}

		public string WriteFile(string fileName, string content)
		{
			string fullPath = System.IO.Path.Combine(Path, fileName);
			ExecuteWithRetry(delegate
			{
				File.WriteAllText(fullPath, content);
			});
			return fullPath;
		}

		public void WriteAllLines(string fileName, List<string> lines)
		{
			string fullPath = System.IO.Path.Combine(Path, fileName);
			ExecuteWithRetry(delegate
			{
				File.WriteAllLines(fullPath, lines);
			});
		}

		public void WriteAllBytes(string fileName, byte[] content)
		{
			string fullPath = System.IO.Path.Combine(Path, fileName);
			ExecuteWithRetry(delegate
			{
				File.WriteAllBytes(fullPath, content);
			});
		}

		public string ReadFile(string fileName)
		{
			string fullPath = System.IO.Path.Combine(Path, fileName);
			return ExecuteWithRetry([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] () => File.ReadAllText(fullPath));
		}

		public IEnumerable<string> ReadAllLines(string fileName)
		{
			string fullPath = System.IO.Path.Combine(Path, fileName);
			return ExecuteWithRetry([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] () => File.ReadAllLines(fullPath));
		}

		public byte[] ReadAllBytes(string fileName)
		{
			string fullPath = System.IO.Path.Combine(Path, fileName);
			return ExecuteWithRetry([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] () => File.ReadAllBytes(fullPath));
		}

		public bool FileExists(string fileName)
		{
			string fullPath = System.IO.Path.Combine(Path, fileName);
			return ExecuteWithRetry(() => File.Exists(fullPath));
		}

		public void DeleteFile(string fileName)
		{
			string fullPath = System.IO.Path.Combine(Path, fileName);
			ExecuteWithRetry(delegate
			{
				if (File.Exists(fullPath))
				{
					File.Delete(fullPath);
				}
			});
		}

		private T ExecuteWithRetry<[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)] T>(Func<T> operation)
		{
			try
			{
				return operation();
			}
			catch (DirectoryNotFoundException)
			{
				EnsureDirectoryExists();
				return operation();
			}
		}

		private void ExecuteWithRetry(Action operation)
		{
			try
			{
				operation();
			}
			catch (DirectoryNotFoundException)
			{
				EnsureDirectoryExists();
				operation();
			}
		}
	}
	public enum Toggle
	{
		On = 1,
		Off = 0
	}
	public enum OrderType
	{
		None,
		Completed,
		NotCompleted,
		DisplayName,
		UniqueID
	}
	[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
	[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
	public static class Configs
	{
		[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
		public class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order = null;

			[UsedImplicitly]
			public bool? Browsable = null;

			[UsedImplicitly]
			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)]
			public string Category = null;

			[UsedImplicitly]
			[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(new byte[] { 2, 1 })]
			public Action<ConfigEntryBase> CustomDrawer = null;
		}

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
		public class StringListConfig
		{
			public readonly List<string> list;

			public StringListConfig(List<string> items)
			{
				list = items;
			}

			public StringListConfig(string items)
			{
				list = items.Split(new char[1] { ',' }).ToList();
			}

			public static void Draw(ConfigEntryBase cfg)
			{
				//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Expected O, but got Unknown
				//IL_0132: Unknown result type (might be due to invalid IL or missing references)
				//IL_0137: Unknown result type (might be due to invalid IL or missing references)
				//IL_014d: Expected O, but got Unknown
				bool valueOrDefault = cfg.Description.Tags.Select([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : ((bool?)null)).FirstOrDefault((bool? v) => v.HasValue) == true;
				bool flag = false;
				List<string> list = new List<string>();
				GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
				foreach (string item2 in new StringListConfig((string)cfg.BoxedValue).list)
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					string item = item2;
					string text = GUILayout.TextField(item2, Array.Empty<GUILayoutOption>());
					if (text != item2 && !valueOrDefault)
					{
						flag = true;
						item = text;
					}
					if (GUILayout.Button("x", new GUIStyle(GUI.skin.button)
					{
						fixedWidth = 21f
					}, Array.Empty<GUILayoutOption>()) && !valueOrDefault)
					{
						flag = true;
					}
					else
					{
						list.Add(item);
					}
					if (GUILayout.Button("+", new GUIStyle(GUI.skin.button)
					{
						fixedWidth = 21f
					}, Array.Empty<GUILayoutOption>()) && !valueOrDefault)
					{
						list.Add("");
						flag = true;
					}
					GUILayout.EndHorizontal();
				}
				GUILayout.EndVertical();
				if (flag)
				{
					cfg.BoxedValue = new StringListConfig(list).ToString();
				}
			}

			public override string ToString()
			{
				return string.Join(",", list);
			}
		}

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
		public class SerializedRequirements
		{
			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
			public struct Requirement
			{
				[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(1)]
				public string itemName;

				public int amount;

				public bool recover;
			}

			public static ConfigurationManagerAttributes attributes = new ConfigurationManagerAttributes
			{
				CustomDrawer = DrawConfigTable
			};

			public readonly List<Requirement> Reqs;

			public static void DrawConfigTable(ConfigEntryBase cfg)
			{
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Expected O, but got Unknown
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Expected O, but got Unknown
				//IL_0166: Unknown result type (might be due to invalid IL or missing references)
				//IL_016b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Expected O, but got Unknown
				//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c8: Expected O, but got Unknown
				//IL_021a: Unknown result type (might be due to invalid IL or missing references)
				//IL_021f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0235: Expected O, but got Unknown
				bool valueOrDefault = cfg.Description.Tags.Select([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object a) => (a.GetType().Name == "ConfigurationManagerAttributes") ? ((bool?)a.GetType().GetField("ReadOnly")?.GetValue(a)) : ((bool?)null)).FirstOrDefault((bool? v) => v.HasValue) == true;
				List<Requirement> list = new List<Requirement>();
				bool flag = false;
				GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
				foreach (Requirement req in new SerializedRequirements((string)cfg.BoxedValue).Reqs)
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					int num = req.amount;
					if (int.TryParse(GUILayout.TextField(num.ToString(), new GUIStyle(GUI.skin.textField)
					{
						fixedWidth = 40f
					}, Array.Empty<GUILayoutOption>()), out var result) && result != num && !valueOrDefault)
					{
						num = result;
						flag = true;
					}
					string text = GUILayout.TextField(req.itemName, new GUIStyle(GUI.skin.textField), Array.Empty<GUILayoutOption>());
					string text2 = (valueOrDefault ? req.itemName : text);
					flag = flag || text2 != req.itemName;
					bool flag2 = req.recover;
					if (GUILayout.Toggle(req.recover, "Recover", new GUIStyle(GUI.skin.toggle)
					{
						fixedWidth = 67f
					}, Array.Empty<GUILayoutOption>()) != req.recover)
					{
						flag2 = !flag2;
						flag = true;
					}
					if (GUILayout.Button("x", new GUIStyle(GUI.skin.button)
					{
						fixedWidth = 21f
					}, Array.Empty<GUILayoutOption>()) && !valueOrDefault)
					{
						flag = true;
					}
					else
					{
						list.Add(new Requirement
						{
							amount = num,
							itemName = text2,
							recover = flag2
						});
					}
					if (GUILayout.Button("+", new GUIStyle(GUI.skin.button)
					{
						fixedWidth = 21f
					}, Array.Empty<GUILayoutOption>()) && !valueOrDefault)
					{
						flag = true;
						list.Add(new Requirement
						{
							amount = 1,
							itemName = "",
							recover = false
						});
					}
					GUILayout.EndHorizontal();
				}
				GUILayout.EndVertical();
				if (flag)
				{
					cfg.BoxedValue = new SerializedRequirements(list).ToString();
				}
			}

			public SerializedRequirements(List<Requirement> reqs)
			{
				Reqs = reqs;
			}

			public SerializedRequirements(string reqs)
			{
				Reqs = reqs.Split(new char[1] { ',' }).Select([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (string r) =>
				{
					string[] array = r.Split(new char[1] { ':' });
					int result;
					bool result2 = default(bool);
					return new Requirement
					{
						itemName = array[0],
						amount = ((array.Length <= 1 || !int.TryParse(array[1], out result)) ? 1 : result),
						recover = (array.Length <= 2 || !bool.TryParse(array[2], out result2) || result2)
					};
				}).ToList();
			}

			public override string ToString()
			{
				return string.Join(",", Reqs.Select([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (Requirement r) => $"{r.itemName}:{r.amount}:{r.recover}"));
			}

			public static Requirement[] toPieceReqs(SerializedRequirements craft)
			{
				Dictionary<string, Requirement> dictionary = craft.Reqs.Where((Requirement r) => r.itemName != "").ToDictionary((Func<Requirement, string>)([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (Requirement r) => r.itemName), (Func<Requirement, Requirement>)([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (Requirement r) =>
				{
					//IL_000d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0012: Unknown result type (might be due to invalid IL or missing references)
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0025: Unknown result type (might be due to invalid IL or missing references)
					ItemDrop val = ResItem(r);
					return (val == null) ? ((Requirement)null) : new Requirement
					{
						m_amount = r.amount,
						m_resItem = val,
						m_recover = r.recover
					};
				}));
				return dictionary.Values.Where([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (Requirement v) => v != null).ToArray();
				[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(2)]
				static ItemDrop ResItem(Requirement r)
				{
					GameObject prefab = Helpers.GetPrefab(r.itemName);
					return (prefab != null) ? prefab.GetComponent<ItemDrop>() : null;
				}
			}
		}

		private static ConfigEntry<Toggle> _serverConfigLocked;

		private static ConfigEntry<Toggle> _KnowledgeWall;

		private static ConfigEntry<Toggle> _UseIgnoreList;

		private static ConfigEntry<Toggle> _ShowAllData;

		private static ConfigEntry<Color> _OutlineColor;

		private static ConfigEntry<Toggle> _Transparent;

		private static ConfigEntry<Toggle> _HideUnknownEntries;

		public static ConfigEntry<Vector3> _customizationPos;

		public static ConfigEntry<Vector3> _dialoguePos;

		public static ConfigEntry<Vector3> _panelPos;

		private static ConfigEntry<int> _TreasureCooldown;

		private static ConfigEntry<int> _BountyCooldown;

		private static ConfigEntry<int> _lotteryCost;

		private static ConfigEntry<int> _minFullHouse;

		private static ConfigEntry<Toggle> _generateBounties;

		private static ConfigEntry<float> _bountyRange;

		private static ConfigEntry<float> _treasureRange;

		private static ConfigEntry<float> _fullHouseChance;

		private static ConfigEntry<int> _lotteryMatchCount;

		private static ConfigEntry<int> _tokensPerSuccess;

		private static ConfigEntry<int> _iconOptionCount;

		private static ConfigEntry<Toggle> _broadcastWin;

		private static ConfigEntry<Toggle> _TreasureEnabled;

		private static ConfigEntry<Toggle> _BountyEnabled;

		private static ConfigEntry<Toggle> _AchievementsEnabled;

		private static ConfigEntry<Toggle> _lotteryEnabled;

		private static ConfigEntry<Toggle> _statusEffectsEnabled;

		private static ConfigEntry<Toggle> _storeEnabled;

		private static ConfigEntry<Toggle> _metricsEnabled;

		private static ConfigEntry<Toggle> _leaderboardEnabled;

		private static ConfigEntry<Toggle> _marketplaceEnabled;

		private static ConfigEntry<Toggle> _trophiesEnabled;

		private static ConfigEntry<Toggle> _itemsEnabled;

		private static ConfigEntry<Toggle> _piecesEnabled;

		private static ConfigEntry<Toggle> _creaturesEnabled;

		private static ConfigEntry<Toggle> _almanacEnabled;

		private static ConfigEntry<Vector2> _elementViewGridSize;

		public static ConfigEntry<Vector3> _questPanelPos;

		private static ConfigEntry<KeyCode> _questKey;

		private static ConfigEntry<Toggle> _autoHideDialogue;

		private static ConfigEntry<Toggle> _allowConversion;

		private static ConfigEntry<int> _conversionRate;

		private static ConfigEntry<string> _conversionItem;

		private static ConfigEntry<float> _scrollbarSensitivity;

		private static ConfigEntry<Toggle> _returnBountyCostWhenCancel;

		private static ConfigEntry<Toggle> _returnTreasureCostWhenCancel;

		private static ConfigEntry<Toggle> _checkNoCost;

		private static ConfigEntry<string> _adminList;

		private static ConfigEntry<Toggle> _enableAchievementNotices;

		private static ConfigEntry<Toggle> _enableAchievementEffects;

		private static ConfigEntry<int> _maxAchievementEffects;

		private static ConfigEntry<OrderType> _achievementOrdering;

		private static ConfigEntry<Toggle> _logging;

		public static ConfigEntry<PieceCategory> npc_category;

		public static ConfigEntry<string> npc_requirements;

		public static ConfigEntry<string> npc_station;

		public static PieceCategory NPC_Category => npc_category.Value;

		public static Requirement[] NPC_Requirements => SerializedRequirements.toPieceReqs(new SerializedRequirements(npc_requirements.Value));

		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)]
		public static CraftingStation NPC_Station
		{
			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(2)]
			get
			{
				GameObject prefab = Helpers.GetPrefab(npc_station.Value);
				return ((prefab != null) ? prefab.GetComponent<CraftingStation>() : null) ?? null;
			}
		}

		public static bool UseIgnoreList => _UseIgnoreList.Value == Toggle.On;

		public static bool ShowBounties => _BountyEnabled.Value == Toggle.On;

		public static bool ShowAchievements => _AchievementsEnabled.Value == Toggle.On;

		public static bool ShowTreasures => _TreasureEnabled.Value == Toggle.On;

		public static bool ShowAllData => _ShowAllData.Value == Toggle.On;

		public static bool UseKnowledgeWall => _KnowledgeWall.Value == Toggle.On;

		public static bool AchievementEffectsEnabled => _enableAchievementEffects.Value == Toggle.On;

		public static int MaxAchievementEffects => _maxAchievementEffects.Value;

		public static bool ShowAchievementNotices => _enableAchievementNotices.Value == Toggle.On;

		public static bool Transparent => _Transparent.Value == Toggle.On;

		public static Color OutlineColor => _OutlineColor.Value;

		public static int BountyCooldown => _BountyCooldown.Value;

		public static float BountyRange => _bountyRange.Value;

		public static float TreasureRange => _treasureRange.Value;

		public static int TreasureCooldown => _TreasureCooldown.Value;

		public static bool ShowLottery => _lotteryEnabled.Value == Toggle.On;

		public static bool ShowStatusEffects => _statusEffectsEnabled.Value == Toggle.On;

		public static bool ShowStore => _storeEnabled.Value == Toggle.On;

		public static bool ShowMetrics => _metricsEnabled.Value == Toggle.On;

		public static bool ShowLeaderboard => _leaderboardEnabled.Value == Toggle.On;

		public static bool HideUnknownEntries => _HideUnknownEntries.Value == Toggle.On;

		public static int LotteryCost => _lotteryCost.Value;

		public static bool ShowMarketplace => _marketplaceEnabled.Value == Toggle.On;

		public static int MinFullHouse => _minFullHouse.Value;

		public static bool AllowConversion => _allowConversion.Value == Toggle.On;

		public static int ConversionRate => _conversionRate.Value;

		public static string ConversionItem => _conversionItem.Value;

		public static float ScrollbarSensitivity => _scrollbarSensitivity.Value;

		public static bool ReturnBountyCostWhenCancel => _returnBountyCostWhenCancel.Value == Toggle.On;

		public static bool ReturnTreasureCostWhenCancel => _returnTreasureCostWhenCancel.Value == Toggle.On;

		public static bool ShowTrophies => _trophiesEnabled.Value == Toggle.On;

		public static bool ShowItems => _itemsEnabled.Value == Toggle.On;

		public static bool ShowPieces => _piecesEnabled.Value == Toggle.On;

		public static bool ShowCreatures => _creaturesEnabled.Value == Toggle.On;

		public static bool ShowAlmanac => _almanacEnabled.Value == Toggle.On;

		public static Vector3 QuestPanelPos => _questPanelPos.Value;

		public static Vector2 ElementViewGridSize => _elementViewGridSize.Value;

		public static Vector3 CustomizationPos => _customizationPos.Value;

		public static Vector3 DialoguePos => _dialoguePos.Value;

		public static KeyCode QuestKey => _questKey.Value;

		public static Vector3 PanelPos => _panelPos.Value;

		public static bool GenerateBounties => _generateBounties.Value == Toggle.On;

		private static string AdminList => _adminList.Value;

		public static bool CheckNoCost => _checkNoCost.Value == Toggle.On;

		public static AlmanacPanel.Background.BackgroundOption bkgOption => Transparent ? AlmanacPanel.Background.BackgroundOption.Transparent : AlmanacPanel.Background.BackgroundOption.Opaque;

		public static OrderType AchievementOrderType => _achievementOrdering.Value;

		public static bool AddLogs => _logging.Value == Toggle.On;

		public static float FullHouseChance => _fullHouseChance.Value;

		public static int RequiredMatchCount => _lotteryMatchCount.Value;

		public static int TokensPerSuccess => _tokensPerSuccess.Value;

		public static int IconsCount => _iconOptionCount.Value;

		public static bool BroadcastWin => _broadcastWin.Value == Toggle.On;

		public static bool AutoHideDialogue => _autoHideDialogue.Value == Toggle.On;

		public static bool IsAdmin(string name)
		{
			return new StringListConfig(AdminList).list.Select([<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (string x) => x.ToLower()).Contains(name.ToLower());
		}

		public static void Load()
		{
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Expected O, but got Unknown
			//IL_0575: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Expected O, but got Unknown
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_060a: Expected O, but got Unknown
			//IL_066e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0679: Expected O, but got Unknown
			//IL_069a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Expected O, but got Unknown
			//IL_06e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ef: Expected O, but got Unknown
			//IL_0743: Unknown result type (might be due to invalid IL or missing references)
			//IL_078c: Unknown result type (might be due to invalid IL or missing references)
			//IL_086e: Unknown result type (might be due to invalid IL or missing references)
			//IL_089c: Unknown result type (might be due to invalid IL or missing references)
			//IL_08eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0943: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a66: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a71: Expected O, but got Unknown
			_serverConfigLocked = config("1 - General", "0 - Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only.");
			AlmanacPlugin.ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			_logging = config("1 - General", "Logging", Toggle.Off, "If on, will add development debug logs", synchronizedSetting: false);
			_KnowledgeWall = config("1 - General", "Knowledge Wall", Toggle.On, "If on, the plugin blacks out unknown items from the almanac");
			_UseIgnoreList = config("1 - General", "Use Ignore List", Toggle.On, "If on, the plugin uses the IgnoreList.yml to filter almanac");
			_ShowAllData = config("1 - General", "Show All Data", Toggle.Off, "If on, Almanac does not filter extra data, like prefab name and material name");
			_allowConversion = config("1 - General", "Enable Conversion", Toggle.On, "If on, players can convert chosen item into almanac tokens");
			_conversionRate = config("1 - General", "Conversion Rate", 50, "Set conversion ratio, ie. 50 coins for 1 token");
			_conversionItem = config("1 - General", "Conversion Item", "Coins", "Set item to use to convert into almanac tokens");
			_almanacEnabled = config("1 - General", "Almanac Button", Toggle.On, "If on, almanac button replaces trophies button");
			_checkNoCost = config("1 - General", "Admin Tools Check No Cost", Toggle.Off, "If on, no cost must be enabled to use admin tools");
			_enableAchievementNotices = config("1 - General", "Achievement Notices", Toggle.Off, "If on, will show notifications of achievement completion");
			_adminList = config("1 - General", "Admin List", "", new ConfigDescription("Almanac admin list, names seperated by a comma", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					CustomDrawer = StringListConfig.Draw
				}
			}));
			_almanacEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.inventoryButton?.Show(ShowAlmanac);
			};
			_lotteryEnabled = config("2 - Tabs", "Lottery", Toggle.On, "If on, lottery feature is enabled");
			_lotteryEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.instance?.Tabs[AlmanacPanel.Tab.TabOption.Lottery].SetActive(ShowLottery);
			};
			_statusEffectsEnabled = config("2 - Tabs", "Status Effects", Toggle.On, "If on, status effects is enabled");
			_statusEffectsEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.instance?.Tabs[AlmanacPanel.Tab.TabOption.StatusEffects].SetActive(ShowStatusEffects);
			};
			_AchievementsEnabled = config("2 - Tabs", "Achievements", Toggle.On, "If on, achievements is enabled");
			_AchievementsEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.instance?.Tabs[AlmanacPanel.Tab.TabOption.Achievements].SetActive(ShowAchievements);
			};
			_storeEnabled = config("2 - Tabs", "Store", Toggle.On, "If on, store is enabled");
			_storeEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.instance?.Tabs[AlmanacPanel.Tab.TabOption.Store].SetActive(ShowStore);
			};
			_metricsEnabled = config("2 - Tabs", "Metrics", Toggle.On, "If on, metrics is enabled");
			_metricsEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.instance?.Tabs[AlmanacPanel.Tab.TabOption.Metrics].SetActive(ShowMetrics);
			};
			_leaderboardEnabled = config("2 - Tabs", "Leaderboard", Toggle.On, "If on, leaderboard is enabled");
			_leaderboardEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.instance?.Tabs[AlmanacPanel.Tab.TabOption.Leaderboard].SetActive(ShowLeaderboard);
			};
			_marketplaceEnabled = config("2 - Tabs", "Marketplace", Toggle.On, "If on, marketplace extends store tab");
			_TreasureEnabled = config("2 - Tabs", "Treasures", Toggle.On, "If on, treasures is enabled");
			_TreasureEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.instance?.Tabs[AlmanacPanel.Tab.TabOption.Treasures].SetActive(ShowTreasures);
			};
			_BountyEnabled = config("2 - Tabs", "Bounties", Toggle.On, "If on, bounties is enabled");
			_BountyEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.instance?.Tabs[AlmanacPanel.Tab.TabOption.Bounties].SetActive(ShowBounties);
			};
			_trophiesEnabled = config("2 - Tabs", "Trophies", Toggle.On, "If on, trophies is enabled");
			_trophiesEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.instance?.Tabs[AlmanacPanel.Tab.TabOption.Trophies].SetActive(ShowTrophies);
			};
			_itemsEnabled = config("2 - Tabs", "Items", Toggle.On, "If on, items are enabled");
			_itemsEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.instance?.Tabs[AlmanacPanel.Tab.TabOption.Items].SetActive(ShowItems);
			};
			_piecesEnabled = config("2 - Tabs", "Pieces", Toggle.On, "If on, pieces are enabled");
			_piecesEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.instance?.Tabs[AlmanacPanel.Tab.TabOption.Pieces].SetActive(ShowPieces);
			};
			_creaturesEnabled = config("2 - Tabs", "Creatures", Toggle.On, "If on, creatures are enabled");
			_creaturesEnabled.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.instance?.Tabs[AlmanacPanel.Tab.TabOption.Creatures].SetActive(ShowCreatures);
			};
			_TreasureCooldown = config("4 - Treasures", "Cooldown", 30, "Set cooldown between treasure hunts, in minutes");
			_returnTreasureCostWhenCancel = config("4 - Treasures", "Cancel Return Cost", Toggle.Off, "If on, cost will be reimbursed when canceled");
			_treasureRange = config("4 - Treasures", "Range", 3000f, new ConfigDescription("Set initial range to spawn treasure, will increment radius by 50.0 per each attempt to find suitable location", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1000f, 5000f), Array.Empty<object>()));
			_BountyCooldown = config("3 - Bounties", "Cooldown", 30, "Set cooldown between bounty hunts, in minutes");
			_returnBountyCostWhenCancel = config("3 - Bounties", "Cancel Return Cost", Toggle.Off, "If on, cost will be reimbursed when canceled");
			_generateBounties = config("3 - Bounties", "Generate", Toggle.Off, "If on, will generate random bounties");
			_bountyRange = config("3 - Bounties", "Range", 3000f, new ConfigDescription("Set initial search range to spawn bounty, will increment radius by 50.0 per each attempt to find suitable location", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1000f, 5000f), Array.Empty<object>()));
			_lotteryCost = config("4 - Lottery", "Cost to Roll", 1, "Set cost to roll");
			_minFullHouse = config("4 - Lottery", "Min Full House", 10, "Set minimum full house reward");
			_fullHouseChance = config("4 - Lottery", "Full House Chance", 0.01f, new ConfigDescription("Set chance to roll a full house", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			_lotteryMatchCount = config("4 - Lottery", "Match Count", 3, new ConfigDescription("Required matches for a success", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>()));
			_tokensPerSuccess = config("4 - Lottery", "Tokens Per Success", 10, "Set amount of tokens per match success");
			_iconOptionCount = config("4 - Lottery", "Unique Icons", 26, new ConfigDescription("Set amount of unique icons to use in lottery, reduce to increase chances", (AcceptableValueBase)(object)new AcceptableValueRange<int>(3, 26), Array.Empty<object>()));
			_broadcastWin = config("4 - Lottery", "Broadcast Win", Toggle.On, "If on, will broadcast to everyone that player has won");
			_HideUnknownEntries = config("5 - User Interface", "Hide Unknown", Toggle.Off, "If on, elements are not displayed instead of blacked out");
			_panelPos = config<Vector3>("5 - User Interface", "Panel Position", new Vector3(410f, 200f, 0f), "Set position of panel", synchronizedSetting: false);
			_panelPos.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				AlmanacPanel.instance?.SetPanelPosition(PanelPos);
			};
			_OutlineColor = config<Color>("5 - User Interface", "Outline Color", Helpers._OrangeColor, "Set the color of the outline for selected items", synchronizedSetting: false);
			_OutlineColor.SettingChanged += AlmanacPanel.OnSelectedColorChange;
			_Transparent = config("5 - User Interface", "Transparent Panels", Toggle.Off, "If on, panels are transparent", synchronizedSetting: false);
			_Transparent.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				if (!((Object)(object)AlmanacPanel.instance == (Object)null) && !((Object)(object)FormPanel.instance == (Object)null) && !((Object)(object)NPCCustomization.instance == (Object)null))
				{
					AlmanacPanel.instance.background.SetBackground(bkgOption);
					FormPanel.instance.background.SetBackground(bkgOption);
					NPCCustomization.instance.background.SetBackground(bkgOption);
				}
			};
			_scrollbarSensitivity = config("5 - User Interface", "Scroll Sensitivity", 700f, "High is more sensitive", synchronizedSetting: false);
			_scrollbarSensitivity.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				AlmanacPanel.OnScrollbarSensitivityChanged(ScrollbarSensitivity);
				NPCCustomization.View.OnScrollbarSensitivityChanged(ScrollbarSensitivity);
			};
			_customizationPos = config<Vector3>("5 - User Interface", "NPC Customization", new Vector3(490f, 170f, 0f), "Set position of customization", synchronizedSetting: false);
			_dialoguePos = config<Vector3>("5 - User Interface", "NPC Dialogue", new Vector3(980f, 365f, 0f), "Set position of dialogue", synchronizedSetting: false);
			_dialoguePos.SettingChanged += DialoguePanel.OnPosChange;
			_elementViewGridSize = config<Vector2>("5 - User Interface", "Grid Element Size", new Vector2(180f, 180f), "");
			_elementViewGridSize.SettingChanged += [<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)] (object _, EventArgs _) =>
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				AlmanacPanel.instance?.elementView.SetGridElementSize(ElementViewGridSize);
			};
			_questPanelPos = config<Vector3>("5 - User Interface", "Quest Panel", new Vector3(45f, 870f, 0f), "Set position of quest tooltips", synchronizedSetting: false);
			_questPanelPos.SettingChanged += QuestPanel.OnPosChange;
			_questKey = config<KeyCode>("5 - User Interface", "Quest Key", (KeyCode)287, "Set key to show / hide quest tooltips", synchronizedSetting: false);
			_autoHideDialogue = config("5 - User Interface", "Auto-Hide Dialogue", Toggle.On, "If on, dialogue panel will auto-close after Give & Quest Commands");
			_enableAchievementEffects = config("6 - Achievements", "Status Effects", Toggle.Off, "If on, will allow legacy achievement feature: status effects");
			_maxAchievementEffects = config("6 - Achievements", "Max Effects", 8, "Set maximum amount of concurrent achievement effects");
			_achievementOrdering = config("6 - Achievements", "Order Style", OrderType.Completed, "Set how achievements are ordered");
			npc_category = config<PieceCategory>("7 - NPC", "Build Category", (PieceCategory)0, "Set NPC Build category");
			npc_station = config("7 - NPC", "Build Station", "", "Set NPC build crafting station");
			npc_requirements = config("7 - NPC", "Build Requirements", "SwordCheat:1:true", new ConfigDescription("Set NPC Build requirements", (AcceptableValueBase)null, new object[1] { SerializedRequirements.attributes }));
			SetupWatcher();
		}

		private static void SetupWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, "RustyMods.Almanac.cfg");
			fileSystemWatcher.Changed += ReadConfigValues;
			fileSystemWatcher.Created += ReadConfigValues;
			fileSystemWatcher.Renamed += ReadConfigValues;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private static void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(AlmanacPlugin.ConfigFileFullPath))
			{
				return;
			}
			try
			{
				AlmanacPlugin.LogDebug("ReadConfigValues called");
				((BaseUnityPlugin)AlmanacPlugin.instance).Config.Reload();
			}
			catch
			{
				AlmanacPlugin.LogError("There was an issue loading your RustyMods.Almanac.cfg");
				AlmanacPlugin.LogError("Please check your config entries for spelling and format!");
			}
		}

		private static ConfigEntry<T> config<[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)AlmanacPlugin.instance).Config.Bind<T>(group, name, value, val);
			SyncedConfigEntry<T> syncedConfigEntry = AlmanacPlugin.ConfigSync.AddConfigEntry<T>(val2);
			syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
			return val2;
		}

		private static ConfigEntry<T> config<[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}
	}
	[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(1)]
	[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
	public static class Entries
	{
		[<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(0)]
		public class EntryBuilder
		{
			[<10fe1035-bca0-423b-a28b-581755449829>NullableContext(0)]
			public enum Option
			{
				None,
				Percentage,
				Seconds,
				Minutes,
				PerLevel,
				Degree,
				Add,
				Minus,
				Level,
				XP
			}

			private readonly List<Entry> m_list = new List<Entry>();

			public bool m_showAll;

			public void Clear()
			{
				m_list.Clear();
			}

			public List<Entry> ToList()
			{
				return m_list;
			}

			public void Add(string title)
			{
				Add(title, "title");
			}

			public void AddRange(List<Entry> entries)
			{
				m_list.AddRange(entries);
			}

			public void Add(string key, string value)
			{
				if (!string.IsNullOrEmpty(value) || m_showAll)
				{
					m_list.Add(new Entry(key, value));
				}
			}

			public void Add(string key, string value, string defaultValue)
			{
				m_list.Add(new Entry(key, string.IsNullOrEmpty(value) ? defaultValue : value));
			}

			public void Add(AchievementType type, string value)
			{
				Add("$label_" + type.ToString().ToLower(), value);
			}

			public unsafe void Add(PlayerStatType type)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				Add("$playerstat_" + ((object)(*(PlayerStatType*)(&type))/*cast due to .constrained prefix*/).ToString().ToLower(), PlayerInfo.GetPlayerStat(type));
			}

			public void Add(DamageModPair pair)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				if ((int)pair.m_modifier != 0 || m_showAll)
				{
					Add(pair.m_type, pair.m_modifier);
				}
			}

			public unsafe void Add(DamageType type, DamageModifier modifier)
			{
				Add("$inventory_" + ((object)(*(DamageType*)(&type))/*cast due to .constrained prefix*/).ToString().ToLower(), "$inventory_" + ((object)(*(DamageModifier*)(&modifier))/*cast due to .constrained prefix*/).ToString().ToLower());
			}

			public unsafe void Add(string key, Faction faction)
			{
				Add(key, "$faction_" + ((object)(*(Faction*)(&faction))/*cast due to .constrained prefix*/).ToString().ToLower());
			}

			public unsafe void Add(SkillType type, float value, Option option = Option.None)
			{
				Add("$skill_" + ((object)(*(SkillType*)(&type))/*cast due to .constrained prefix*/).ToString().ToLower(), value, option);
			}

			public void Add(string key, [<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)] Material material)
			{
				Add(key, ((Object)(object)material == (Object)null) ? Keys.None : ((Object)material).name);
			}

			public void Add(string key, float value, float perLvl, string postfix)
			{
				Add(key, $"{value} +{perLvl}{postfix}");
			}

			public void Add(string key, [<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)] StatusEffect statusEffect)
			{
				Add(key, ((Object)(object)statusEffect == (Object)null) ? Keys.None : statusEffect.m_name);
			}

			public unsafe void Add(string key, DamageModifier modifier)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Invalid comparison between Unknown and I4
				if ((int)modifier != 0)
				{
					Add(key, "$inventory_" + ((object)(*(DamageModifier*)(&modifier))/*cast due to .constrained prefix*/).ToString().ToLower());
				}
			}

			public void Add(string key, Enum type)
			{
				Add(key, Helpers.SplitCamelCase(type.ToString()));
			}

			public void Add(string key, [<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)] CraftingStation station)
			{
				Add(key, ((Object)(object)station == (Object)null) ? Keys.None : station.m_name);
			}

			public void Add(string key, [<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)] GameObject value)
			{
				Add(key, ((Object)(object)value == (Object)null) ? Keys.None : ((Object)value).name);
			}

			public void Add(string key, AmmoType ammo)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				Add(key, ammo.m_ammo);
			}

			public void Add(ItemDrop from, ItemDrop to)
			{
				Add(from.m_itemData.m_shared.m_name, to.m_itemData.m_shared.m_name);
			}

			public void Add(string key, bool value)
			{
				Add(key, value ? Keys.True : Keys.False);
			}

			public void Add(string key, [<293b6170-8ea0-48d9-9d57-220f8716613b>Nullable(2)] ItemDrop item)
			{
				Add(key, ((Object)(object)item == (Object)null) ? Keys.None : item.m_itemData.m_shared.m_name);
			}

			public void Add(string key, int pre, int post, string separator)
			{
				Add(key, $"{pre}<color=orange>{separator}</color>{post}");
			}

			public unsafe void Add(string key, Biome biome)
			{
				string[] array = ((object)(*(Biome*)(&biome))/*cast due to .constrained prefix*/).ToString().Split(new char[1] { ',' });
				string[] array2 = array;
				foreach (string text in array2)
				{
					if (Enum.TryParse<Biome>(text.Trim(), ignoreCase: true, out Biome result))
					{
						Add(key, "$biome_" + ((object)(*(Biome*)(&result))/*cast due to .constrained prefix*/).ToString().ToLower());
					}
				}
			}

			public void Add(string key, float value, string postfix)
			{
				Add(key, value.ToString("0") + postfix);
			}

			public void Add(string key, float value, Option option = Option.None)
			{
				if (value != 0f || m_showAll)
				{
					switch (option)
					{
					case Option.Minutes:
						Add(key, value.ToString("0.0") + "<color=orange>" + Keys.Min + "</color>");
						break;
					case Option.Seconds:
						Add(key, value.ToString("0.0") + "<color=orange>s</color>");
						break;
					case Option.Percentage:
						Add(key, (value * 100f).ToString("0.0") + "<color=orange>%</color>");
						break;
					case Option.PerLevel:
						Add(key, value.ToString("0.0") + "<color=orange>/" + Keys.Lvl + "</color>");
						break;
					case Option.Degree:
						Add(key, value.ToString("0") + "<color=orange>°</color>");
						break;
					case Option.Add:
						Add(key, "<color=orange>+</color>" + value.ToString("0.0"));
						break;
					case Option.Level:
						Add(key, value.ToString("0") + "<color=orange>" + Keys.Lvl + "</color>");
						break;
					case Option.XP:
						Add(key, value.ToString("0") + "<color=orange>" + Keys.XP + "</color>");
						break;
					default:
						Add(key, value.ToString("0.0"));
						break;
					}
				}
			}

			public void Add(string key, int value, Option option = Option.None)
			{
				if (value != 0 || m_showAll)
				{
					switch (option)
					{
					case Option.Minutes:
						Add(key, value + "<color=orange>" + Keys.Min + "</color>");
						break;
					case Option.Seconds:
						Add(key, value + "<color=orange>s</color>");
						break;
					case Option.Percentage:
						Add(key, value * 100 + "<color=orange>%</color>");
						break;
					case Option.PerLevel:
						Add(key, value + "<color=orange>/" + Keys.Lvl + "</color>");
						break;
					case Option.Degree:
						Add(key, value + "<color=orange>°</color>");
						break;
					case Option.Add:
						Add(key, "<color=orange>+</color>" + value);
						break;
					case Option.Level:
						Add(key, value + "<color=orange>" + Keys.Lvl + "</color>");
						break;
					case Option.XP:
						Add(key, value + "<color=orange>" + Keys.XP + "</color>");
						break;
					default:
						Add(key, value.ToString());
						break;