Decompiled source of Hunting v1.3.6

Hunting.dll

Decompiled 3 weeks 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.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Hunting.Functions;
using Hunting.Patches;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using SkillManager;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: Guid("D30D4CCF-E7C9-4819-AA2A-935D4907C49F")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyProduct("Hunting")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("https://valheim.thunderstore.io/package/blacks7ar/Hunting/")]
[assembly: AssemblyTitle("Hunting")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: AssemblyFileVersion("1.3.6")]
[assembly: AssemblyCompany("blacks7ar")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.6.0")]
[module: <dec9b5e1-30f2-4615-b2b4-ad02c26a3299>RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<deaee61b-1e2a-417d-9776-3c2c5305ce82>Embedded]
	internal sealed class <deaee61b-1e2a-417d-9776-3c2c5305ce82>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[<deaee61b-1e2a-417d-9776-3c2c5305ce82>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <5182ce2a-4b71-4038-9cfc-c774de8cc672>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <5182ce2a-4b71-4038-9cfc-c774de8cc672>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <5182ce2a-4b71-4038-9cfc-c774de8cc672>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<deaee61b-1e2a-417d-9776-3c2c5305ce82>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <71803631-bd00-444e-8767-8867f40864a9>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <71803631-bd00-444e-8767-8867f40864a9>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[<deaee61b-1e2a-417d-9776-3c2c5305ce82>Embedded]
	[CompilerGenerated]
	internal sealed class <dec9b5e1-30f2-4615-b2b4-ad02c26a3299>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <dec9b5e1-30f2-4615-b2b4-ad02c26a3299>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SkillManager
{
	[PublicAPI]
	public class Skill
	{
		public static class LocalizationCache
		{
			private static readonly Dictionary<string, Localization> localizations = new Dictionary<string, Localization>();

			internal static void LocalizationPostfix(Localization __instance, string language)
			{
				string key = localizations.FirstOrDefault((KeyValuePair<string, Localization> l) => l.Value == __instance).Key;
				if (key != null)
				{
					localizations.Remove(key);
				}
				if (!localizations.ContainsKey(language))
				{
					localizations.Add(language, __instance);
				}
			}

			public static Localization ForLanguage([<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)] string language = null)
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				if (localizations.TryGetValue(language ?? PlayerPrefs.GetString("language", "English"), out var value))
				{
					return value;
				}
				value = new Localization();
				if (language != null)
				{
					value.SetupLanguage(language);
				}
				return value;
			}
		}

		[PublicAPI]
		public class LocalizeKey
		{
			private static readonly List<LocalizeKey> keys = new List<LocalizeKey>();

			public readonly string Key;

			public readonly Dictionary<string, string> Localizations = new Dictionary<string, string>();

			public LocalizeKey(string key)
			{
				Key = key.Replace("$", "");
			}

			public void Alias(string alias)
			{
				Localizations.Clear();
				if (!alias.Contains("$"))
				{
					alias = "$" + alias;
				}
				Localizations["alias"] = alias;
				Localization.instance.AddWord(Key, Localization.instance.Localize(alias));
			}

			public LocalizeKey English(string key)
			{
				return addForLang("English", key);
			}

			public LocalizeKey Swedish(string key)
			{
				return addForLang("Swedish", key);
			}

			public LocalizeKey French(string key)
			{
				return addForLang("French", key);
			}

			public LocalizeKey Italian(string key)
			{
				return addForLang("Italian", key);
			}

			public LocalizeKey German(string key)
			{
				return addForLang("German", key);
			}

			public LocalizeKey Spanish(string key)
			{
				return addForLang("Spanish", key);
			}

			public LocalizeKey Russian(string key)
			{
				return addForLang("Russian", key);
			}

			public LocalizeKey Romanian(string key)
			{
				return addForLang("Romanian", key);
			}

			public LocalizeKey Bulgarian(string key)
			{
				return addForLang("Bulgarian", key);
			}

			public LocalizeKey Macedonian(string key)
			{
				return addForLang("Macedonian", key);
			}

			public LocalizeKey Finnish(string key)
			{
				return addForLang("Finnish", key);
			}

			public LocalizeKey Danish(string key)
			{
				return addForLang("Danish", key);
			}

			public LocalizeKey Norwegian(string key)
			{
				return addForLang("Norwegian", key);
			}

			public LocalizeKey Icelandic(string key)
			{
				return addForLang("Icelandic", key);
			}

			public LocalizeKey Turkish(string key)
			{
				return addForLang("Turkish", key);
			}

			public LocalizeKey Lithuanian(string key)
			{
				return addForLang("Lithuanian", key);
			}

			public LocalizeKey Czech(string key)
			{
				return addForLang("Czech", key);
			}

			public LocalizeKey Hungarian(string key)
			{
				return addForLang("Hungarian", key);
			}

			public LocalizeKey Slovak(string key)
			{
				return addForLang("Slovak", key);
			}

			public LocalizeKey Polish(string key)
			{
				return addForLang("Polish", key);
			}

			public LocalizeKey Dutch(string key)
			{
				return addForLang("Dutch", key);
			}

			public LocalizeKey Portuguese_European(string key)
			{
				return addForLang("Portuguese_European", key);
			}

			public LocalizeKey Portuguese_Brazilian(string key)
			{
				return addForLang("Portuguese_Brazilian", key);
			}

			public LocalizeKey Chinese(string key)
			{
				return addForLang("Chinese", key);
			}

			public LocalizeKey Japanese(string key)
			{
				return addForLang("Japanese", key);
			}

			public LocalizeKey Korean(string key)
			{
				return addForLang("Korean", key);
			}

			public LocalizeKey Hindi(string key)
			{
				return addForLang("Hindi", key);
			}

			public LocalizeKey Thai(string key)
			{
				return addForLang("Thai", key);
			}

			public LocalizeKey Abenaki(string key)
			{
				return addForLang("Abenaki", key);
			}

			public LocalizeKey Croatian(string key)
			{
				return addForLang("Croatian", key);
			}

			public LocalizeKey Georgian(string key)
			{
				return addForLang("Georgian", key);
			}

			public LocalizeKey Greek(string key)
			{
				return addForLang("Greek", key);
			}

			public LocalizeKey Serbian(string key)
			{
				return addForLang("Serbian", key);
			}

			public LocalizeKey Ukrainian(string key)
			{
				return addForLang("Ukrainian", key);
			}

			private LocalizeKey addForLang(string lang, string value)
			{
				Localizations[lang] = value;
				if (Localization.instance.GetSelectedLanguage() == lang)
				{
					Localization.instance.AddWord(Key, value);
				}
				else if (lang == "English" && !Localization.instance.m_translations.ContainsKey(Key))
				{
					Localization.instance.AddWord(Key, value);
				}
				return this;
			}

			[HarmonyPriority(300)]
			internal static void AddLocalizedKeys(Localization __instance, string language)
			{
				foreach (LocalizeKey key in keys)
				{
					string value2;
					if (key.Localizations.TryGetValue(language, out var value) || key.Localizations.TryGetValue("English", out value))
					{
						__instance.AddWord(key.Key, value);
					}
					else if (key.Localizations.TryGetValue("alias", out value2))
					{
						Localization.instance.AddWord(key.Key, Localization.instance.Localize(value2));
					}
				}
			}
		}

		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			[<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)]
			public string Category;
		}

		[HarmonyPatch(typeof(Skills), "IsSkillValid")]
		private static class Patch_Skills_IsSkillValid
		{
			private static void Postfix(SkillType type, ref bool __result)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				if (!__result && skills.ContainsKey(type))
				{
					__result = true;
				}
			}
		}

		private static readonly Dictionary<SkillType, Skill> skills;

		internal static readonly Dictionary<string, Skill> skillByName;

		private readonly string skillName;

		private readonly string internalSkillName;

		private readonly SkillDef skillDef;

		public readonly LocalizeKey Name;

		public readonly LocalizeKey Description;

		private float skillEffectFactor = 1f;

		private int skillLoss = 5;

		public bool Configurable;

		private static bool InitializedTerminal;

		[<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)]
		private static Localization _english;

		[<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static bool hasConfigSync;

		[<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)]
		private static object _configSync;

		public float SkillGainFactor
		{
			get
			{
				return skillDef.m_increseStep;
			}
			set
			{
				skillDef.m_increseStep = value;
				this.SkillGainFactorChanged?.Invoke(value);
			}
		}

		public float SkillEffectFactor
		{
			get
			{
				return skillEffectFactor;
			}
			set
			{
				skillEffectFactor = value;
				this.SkillEffectFactorChanged?.Invoke(value);
			}
		}

		public int SkillLoss
		{
			get
			{
				return skillLoss;
			}
			set
			{
				skillLoss = value;
				this.SkillLossChanged?.Invoke(value);
			}
		}

		private static Localization english => _english ?? (_english = LocalizationCache.ForLanguage("English"));

		private static BaseUnityPlugin plugin
		{
			get
			{
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: Expected O, but got Unknown
				object obj = _plugin;
				if (obj == null)
				{
					BaseUnityPlugin val = (BaseUnityPlugin)Chainloader.ManagerObject.GetComponent((Type)Assembly.GetExecutingAssembly().DefinedTypes.First((TypeInfo t) => t.IsClass && typeof(BaseUnityPlugin).IsAssignableFrom(t)));
					_plugin = val;
					obj = (object)val;
				}
				return (BaseUnityPlugin)obj;
			}
		}

		[<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)]
		private static object configSync
		{
			[<71803631-bd00-444e-8767-8867f40864a9>NullableContext(2)]
			get
			{
				if (_configSync == null && hasConfigSync)
				{
					Type type = Assembly.GetExecutingAssembly().GetType("ServerSync.ConfigSync");
					if ((object)type != null)
					{
						_configSync = Activator.CreateInstance(type, plugin.Info.Metadata.GUID + " SkillManager");
						type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString());
						type.GetProperty("IsLocked").SetValue(_configSync, true);
					}
					else
					{
						hasConfigSync = false;
					}
				}
				return _configSync;
			}
		}

		[<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)]
		[method: <71803631-bd00-444e-8767-8867f40864a9>NullableContext(2)]
		[field: <5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)]
		public event Action<float> SkillGainFactorChanged;

		[<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)]
		[method: <71803631-bd00-444e-8767-8867f40864a9>NullableContext(2)]
		[field: <5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)]
		public event Action<float> SkillEffectFactorChanged;

		[<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)]
		[method: <71803631-bd00-444e-8767-8867f40864a9>NullableContext(2)]
		[field: <5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)]
		public event Action<float> SkillLossChanged;

		public Skill(string englishName, string icon)
			: this(englishName, loadSprite(icon, 64, 64))
		{
		}

		public Skill(string englishName, Sprite icon)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			SkillType val = fromName(englishName);
			string text = new Regex("[^a-zA-Z]").Replace(englishName, "_");
			skills[val] = this;
			skillByName[englishName] = this;
			skillDef = new SkillDef
			{
				m_description = "$skilldesc_" + text,
				m_icon = icon,
				m_increseStep = 1f,
				m_skill = val
			};
			internalSkillName = text;
			skillName = englishName;
			Name = new LocalizeKey("skill_" + ((object)(SkillType)(ref val)).ToString()).English(englishName);
			Description = new LocalizeKey("skilldesc_" + text);
		}

		public static SkillType fromName(string englishName)
		{
			return (SkillType)Math.Abs(StringExtensionMethods.GetStableHashCode(englishName));
		}

		static Skill()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Expected O, but got Unknown
			//IL_01ab: Expected O, but got Unknown
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Expected O, but got Unknown
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_023c: Expected O, but got Unknown
			skills = new Dictionary<SkillType, Skill>();
			skillByName = new Dictionary<string, Skill>();
			InitializedTerminal = false;
			hasConfigSync = true;
			Harmony val = new Harmony("org.bepinex.helpers.skillmanager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(FejdStartup), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_FejdStartup", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Skills), "GetSkillDef", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_GetSkillDef", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Skills), "CheatRaiseSkill", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_CheatRaiseskill", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Skills), "CheatResetSkill", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_CheatResetSkill", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "LoadCSV", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizeKey), "AddLocalizedKeys", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Terminal), "InitTerminal", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Terminal_InitTerminal_Prefix", (Type[])null, (Type[])null)), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Terminal_InitTerminal", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Localization), "SetupLanguage", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(LocalizationCache), "LocalizationPostfix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(Skills), "OnDeath", (Type[])null, (Type[])null), new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_OnDeath_Prefix", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(Skill), "Patch_Skills_OnDeath_Finalizer", (Type[])null, (Type[])null)), (HarmonyMethod)null);
		}

		private static void Patch_FejdStartup()
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			foreach (Skill skill in skills.Values)
			{
				if (skill.Configurable)
				{
					string key = skill.Name.Key;
					string group = new Regex("['[\"\\]]").Replace(english.Localize(key), "").Trim();
					string category = Localization.instance.Localize(key).Trim();
					ConfigEntry<float> skillGain = config(group, "Skill gain factor", skill.SkillGainFactor, new ConfigDescription("The rate at which you gain experience for the skill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f), new object[1]
					{
						new ConfigurationManagerAttributes
						{
							Category = category
						}
					}));
					skill.SkillGainFactor = skillGain.Value;
					skillGain.SettingChanged += delegate
					{
						skill.SkillGainFactor = skillGain.Value;
					};
					ConfigEntry<float> skillEffect = config(group, "Skill effect factor", skill.SkillEffectFactor, new ConfigDescription("The power of the skill, based on the default power.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f), new object[1]
					{
						new ConfigurationManagerAttributes
						{
							Category = category
						}
					}));
					skill.SkillEffectFactor = skillEffect.Value;
					skillEffect.SettingChanged += delegate
					{
						skill.SkillEffectFactor = skillEffect.Value;
					};
					ConfigEntry<int> skillLoss = config(group, "Skill loss", skill.skillLoss, new ConfigDescription("How much experience to lose on death.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
					{
						new ConfigurationManagerAttributes
						{
							Category = category
						}
					}));
					skill.skillLoss = skillLoss.Value;
					skillLoss.SettingChanged += delegate
					{
						skill.skillLoss = skillLoss.Value;
					};
				}
			}
		}

		private static void Patch_Skills_GetSkillDef([<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(2)] ref SkillDef __result, List<SkillDef> ___m_skills, SkillType type)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			if (__result == null)
			{
				SkillDef val = GetSkillDef(type);
				if (val != null)
				{
					___m_skills.Add(val);
					__result = val;
				}
			}
		}

		private static bool Patch_Skills_CheatRaiseskill(Skills __instance, string name, float value, Player ___m_player)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			foreach (SkillType key in skills.Keys)
			{
				SkillType current = key;
				Skill skill = skills[current];
				if (string.Equals(skill.internalSkillName, name, StringComparison.CurrentCultureIgnoreCase))
				{
					Skill skill2 = __instance.GetSkill(current);
					skill2.m_level += value;
					skill2.m_level = Mathf.Clamp(skill2.m_level, 0f, 100f);
					((Character)___m_player).Message((MessageType)1, "Skill increased " + Localization.instance.Localize("$skill_" + ((object)(SkillType)(ref current)).ToString()) + ": " + (int)skill2.m_level, 0, skill2.m_info.m_icon);
					Console.instance.Print("Skill " + skill.internalSkillName + " = " + skill2.m_level);
					return false;
				}
			}
			return true;
		}

		private static bool Patch_Skills_CheatResetSkill(Skills __instance, string name)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			foreach (SkillType key in skills.Keys)
			{
				Skill skill = skills[key];
				if (string.Equals(skill.internalSkillName, name, StringComparison.CurrentCultureIgnoreCase))
				{
					__instance.ResetSkill(key);
					Console.instance.Print("Skill " + skill.internalSkillName + " reset");
					return false;
				}
			}
			return true;
		}

		private static void Patch_Skills_OnDeath_Prefix(Skills __instance, [<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(new byte[] { 2, 0 })] ref Dictionary<SkillType, Skill> __state)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			if (__state == null)
			{
				__state = new Dictionary<SkillType, Skill>();
			}
			foreach (KeyValuePair<SkillType, Skill> skill in skills)
			{
				if (__instance.m_skillData.TryGetValue(skill.Key, out var value))
				{
					__state[skill.Key] = value;
					if (skill.Value.skillLoss > 0)
					{
						Skill obj = value;
						obj.m_level -= value.m_level * (float)skill.Value.SkillLoss / 100f;
						value.m_accumulator = 0f;
					}
					__instance.m_skillData.Remove(skill.Key);
				}
			}
		}

		private static void Patch_Skills_OnDeath_Finalizer(Skills __instance, [<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(new byte[] { 2, 0 })] ref Dictionary<SkillType, Skill> __state)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (__state == null)
			{
				return;
			}
			foreach (KeyValuePair<SkillType, Skill> item in __state)
			{
				__instance.m_skillData[item.Key] = item.Value;
			}
			__state = null;
		}

		private static void Patch_Terminal_InitTerminal_Prefix()
		{
			InitializedTerminal = Terminal.m_terminalInitialized;
		}

		private static void Patch_Terminal_InitTerminal()
		{
			if (!InitializedTerminal)
			{
				AddSkill(Terminal.commands["raiseskill"]);
				AddSkill(Terminal.commands["resetskill"]);
			}
			static void AddSkill(ConsoleCommand command)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Expected O, but got Unknown
				ConsoleOptionsFetcher fetcher = command.m_tabOptionsFetcher;
				command.m_tabOptionsFetcher = (ConsoleOptionsFetcher)delegate
				{
					List<string> list = fetcher.Invoke();
					list.AddRange(skills.Values.Select((Skill skill) => skill.internalSkillName));
					return list;
				};
			}
		}

		[<71803631-bd00-444e-8767-8867f40864a9>NullableContext(2)]
		private static SkillDef GetSkillDef(SkillType skillType)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (!skills.ContainsKey(skillType))
			{
				return null;
			}
			return skills[skillType].skillDef;
		}

		private static byte[] ReadEmbeddedFileBytes(string name)
		{
			using MemoryStream memoryStream = new MemoryStream();
			Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + "." + name).CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		private static Texture2D loadTexture(string name)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_001f: Expected O, but got Unknown
			Texture2D val = new Texture2D(0, 0);
			ImageConversion.LoadImage(val, ReadEmbeddedFileBytes("icons." + name));
			return val;
		}

		private static Sprite loadSprite(string name, int width, int height)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			return Sprite.Create(loadTexture(name), new Rect(0f, 0f, (float)width, (float)height), Vector2.zero);
		}

		private static ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description)
		{
			ConfigEntry<T> val = plugin.Config.Bind<T>(group, name, value, description);
			configSync?.GetType().GetMethod("AddConfigEntry").MakeGenericMethod(typeof(T))
				.Invoke(configSync, new object[1] { val });
			return val;
		}

		private static ConfigEntry<T> config<T>(string group, string name, T value, string description)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}
	}
	[PublicAPI]
	public static class SkillExtensions
	{
		public static float GetSkillFactor(this Character character, string name)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return character.GetSkillFactor(Skill.fromName(name)) * Skill.skillByName[name].SkillEffectFactor;
		}

		public static float GetSkillFactor(this Skills skills, string name)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return skills.GetSkillFactor(Skill.fromName(name)) * Skill.skillByName[name].SkillEffectFactor;
		}

		public static void RaiseSkill(this Character character, string name, float value = 1f)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			character.RaiseSkill(Skill.fromName(name), value);
		}

		public static void RaiseSkill(this Skills skill, string name, float value = 1f)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			skill.RaiseSkill(Skill.fromName(name), value);
		}

		public static void LowerSkill(this Character character, string name, float factor = 1f)
		{
			character.GetSkills().LowerSkill(name, factor);
		}

		public static void LowerSkill(this Skills skills, string name, float factor)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (factor > 0f && skills.m_skillData.TryGetValue(Skill.fromName(name), out var value))
			{
				Skill obj = value;
				obj.m_level -= value.m_level * factor;
				value.m_accumulator = 0f;
			}
		}
	}
}
namespace Hunting
{
	[BepInPlugin("blacks7ar.Hunting", "Hunting", "1.3.6")]
	public class Plugin : BaseUnityPlugin
	{
		public enum DisplayOptions
		{
			Numerical,
			Percentage
		}

		private const string modGUID = "blacks7ar.Hunting";

		public const string modName = "Hunting";

		public const string modAuthor = "blacks7ar";

		public const string modVersion = "1.3.6";

		public const string modLink = "https://valheim.thunderstore.io/package/blacks7ar/Hunting/";

		private static readonly Harmony _harmony = new Harmony("blacks7ar.Hunting");

		private static readonly ConfigSync _configSync = new ConfigSync("blacks7ar.Hunting")
		{
			DisplayName = "Hunting",
			CurrentVersion = "1.3.6",
			MinimumRequiredVersion = "1.3.6"
		};

		private static ConfigEntry<Toggle> _serverConfigLocked;

		private static ConfigEntry<float> _expGainFactor;

		public static ConfigEntry<float> _huntingYieldFactor;

		public static ConfigEntry<string> _tier1Meadows;

		public static ConfigEntry<int> _tier1MeadowsLevel;

		public static ConfigEntry<string> _tier2BlackForest;

		public static ConfigEntry<int> _tier2BlackForestLevel;

		public static ConfigEntry<string> _tier3Swamps;

		public static ConfigEntry<int> _tier3SwampsLevel;

		public static ConfigEntry<string> _tier4Mountains;

		public static ConfigEntry<int> _tier4MountainsLevel;

		public static ConfigEntry<string> _tier5Plains;

		public static ConfigEntry<int> _tier5PlainsLevel;

		public static ConfigEntry<string> _tier6Mistlands;

		public static ConfigEntry<int> _tier6MistlandsLevel;

		public static ConfigEntry<string> _tier7Ashlands;

		public static ConfigEntry<int> _tier7AshlandsLevel;

		public static ConfigEntry<string> _tier8DeepNorth;

		public static ConfigEntry<int> _tier8DeepNorthLevel;

		public static ConfigEntry<float> _detectionRadius;

		public static ConfigEntry<Toggle> _displayExpGained;

		public static ConfigEntry<Toggle> _displayEnemyHPEnable;

		public static ConfigEntry<int> _displayEnemyHPLevel;

		public static ConfigEntry<DisplayOptions> _displayEnemyHPOptions;

		private static ConfigEntry<int> _expLoss;

		public static ConfigEntry<Toggle> _useDropSystem;

		public static ConfigEntry<Toggle> _iconsOnly;

		private static Skill _hunting;

		public static HashSet<string> _CreatureList;

		private ConfigEntry<T> config<T>(string group, string name, T value, ConfigDescription description, bool synchronizedConfig = true)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedConfig ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
			_configSync.AddConfigEntry<T>(val2).SynchronizedConfig = synchronizedConfig;
			return val2;
		}

		private ConfigEntry<T> config2<T>(string group, string name, T value, string desc, bool synchronizedConfig = true)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			Hunting.Functions.ConfigurationManagerAttributes configurationManagerAttributes = new Hunting.Functions.ConfigurationManagerAttributes
			{
				CustomDrawer = TextBox
			};
			return config(group, name, value, new ConfigDescription(desc, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes }), synchronizedConfig);
		}

		public void Awake()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Expected O, but got Unknown
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected O, but got Unknown
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Expected O, but got Unknown
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Expected O, but got Unknown
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Expected O, but got Unknown
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Expected O, but got Unknown
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Expected O, but got Unknown
			//IL_058f: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Expected O, but got Unknown
			//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c1: Expected O, but got Unknown
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Expected O, but got Unknown
			//IL_0621: Unknown result type (might be due to invalid IL or missing references)
			//IL_062c: Expected O, but got Unknown
			//IL_0648: Unknown result type (might be due to invalid IL or missing references)
			//IL_0653: Expected O, but got Unknown
			//IL_0681: Unknown result type (might be due to invalid IL or missing references)
			//IL_068c: Expected O, but got Unknown
			//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f7: Expected O, but got Unknown
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			_hunting = new Skill("Hunting", "deericon2.png");
			_hunting.Description.English("Increase item yield when hunting wild animals and pins them on the minimap for easy hunting.");
			_hunting.Configurable = false;
			_serverConfigLocked = config("1- ServerSync", "Lock Configuration", Toggle.On, new ConfigDescription("If On, the configuration is locked and can be changed by server admins only.", (AcceptableValueBase)null, Array.Empty<object>()));
			_configSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			_huntingYieldFactor = config("2- Hunting", "Hunting Yield Factor", 2f, new ConfigDescription("Hunting yield factor at skill level 100.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), Array.Empty<object>()));
			_detectionRadius = config("2- Hunting", "Detection Radius", 30f, new ConfigDescription("Detection radius for tracking down prey.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
			_useDropSystem = config("2- Hunting", "Use Drop System", Toggle.On, new ConfigDescription("If On, calculating the drops from preys will be handled by this mod.", (AcceptableValueBase)null, Array.Empty<object>()));
			_iconsOnly = config("2- Hunting", "Icons Only", Toggle.Off, new ConfigDescription("If On, only icons will be visible on the world map.", (AcceptableValueBase)null, Array.Empty<object>()));
			_tier1Meadows = config2("3- Hunters Instinct", "Tier1 Meadows", "Deer,Boar,Neck,BOH_Hare_Brown,BOH_Hare_Native,BOH_Hare_DarkGrey,BOH_Hare_Exotic,BOH_Hare_White,Fox_TW", "Prefab names of creatures you want to track in meadows biome.\n(NOTE: You need to logout if you added additional creature while in-game)");
			_tier1Meadows.SettingChanged += delegate
			{
				GenerateCreatureList();
			};
			_tier1MeadowsLevel = config("3- Hunters Instinct", "Tier1 Meadows Level", 10, new ConfigDescription("Required skill level needed to track down prey on meadows biome and pin them on the map.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new Hunting.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			_tier2BlackForest = config2("3- Hunters Instinct", "Tier2 BlackForest", "Razorback_TW,BlackBear_TW", "Prefab names of creatures you want to track in blackforest biomes.\n(NOTE: You need to logout if you added additional creature while in-game)");
			_tier2BlackForest.SettingChanged += delegate
			{
				GenerateCreatureList();
			};
			_tier2BlackForestLevel = config("3- Hunters Instinct", "Tier2 BlackForest Level", 20, new ConfigDescription("Required skill level needed to track down prey on blackforest biome and pin them on the map.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new Hunting.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			_tier3Swamps = config2("3- Hunters Instinct", "Tier3 Swamp", "RottingElk_TW", "Prefab names of creatures you want to track in swamp biome.\n(NOTE: You need to logout if you added additional creature while in-game)");
			_tier3Swamps.SettingChanged += delegate
			{
				GenerateCreatureList();
			};
			_tier3SwampsLevel = config("3- Hunters Instinct", "Tier3 Swamp Level", 30, new ConfigDescription("Required skill level needed to track down prey on swamp biome and pin them on the map.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new Hunting.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			_tier4Mountains = config2("3- Hunters Instinct", "Tier4 Mountain", "Wolf,GrizzlyBear_TW", "Prefab names of creatures you want to track in mountain biome.\n(NOTE: You need to logout if you added additional creature while in-game)");
			_tier4Mountains.SettingChanged += delegate
			{
				GenerateCreatureList();
			};
			_tier4MountainsLevel = config("3- Hunters Instinct", "Tier4 Mountain Level", 40, new ConfigDescription("Required skill level needed to track down prey on mountain biome and pin them on the map.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new Hunting.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			_tier5Plains = config2("3- Hunters Instinct", "Tier5 Plains", "Lox,Prowler_TW", "Prefab names of creatures you want to track in plains biome.\n(NOTE: You need to logout if you added additional creature while in-game)");
			_tier5Plains.SettingChanged += delegate
			{
				GenerateCreatureList();
			};
			_tier5PlainsLevel = config("3- Hunters Instinct", "Tier5 Plains Level", 50, new ConfigDescription("Required skill level needed to track down prey on plains biome and pin them on the map.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new Hunting.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			_tier6Mistlands = config2("3- Hunters Instinct", "Tier6 Mistlands", "Hare", "Prefab names of creatures you want to track in mistlands biome.\n(NOTE: You need to logout if you added additional creature while in-game)");
			_tier6Mistlands.SettingChanged += delegate
			{
				GenerateCreatureList();
			};
			_tier6MistlandsLevel = config("3- Hunters Instinct", "Tier6 Mistlands Level", 60, new ConfigDescription("Required skill level needed to track down prey on mistlands biome and pin them on the map.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new Hunting.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			_tier7Ashlands = config2("3- Hunters Instinct", "Tier7 Ashlands", "AshenScorpid_TW,AshenDimetrodon_TW,AshenDrake_TW,AshenCrab_TW", "Prefab names of creatures you want to track in ashlands biome.\n(NOTE: You need to logout if you added additional creature while in-game)");
			_tier7Ashlands.SettingChanged += delegate
			{
				GenerateCreatureList();
			};
			_tier7AshlandsLevel = config("3- Hunters Instinct", "Tier7 Ashlands Level", 70, new ConfigDescription("Required skill level needed to track down prey on ashlands biome and pin them on the map.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new Hunting.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			_tier8DeepNorth = config2("3- Hunters Instinct", "Tier8 DeepNorth", "ArcticBear_TW,ArcticWolf_TW,ArcticDrake_TW,ArcticSerpent_TW", "Prefab names of creatures you want to track in deepnorth biome.\n(NOTE: You need to logout if you added additional creature while in-game)");
			_tier8DeepNorth.SettingChanged += delegate
			{
				GenerateCreatureList();
			};
			_tier8DeepNorthLevel = config("3- Hunters Instinct", "Tier8 DeepNorth Level", 80, new ConfigDescription("Required skill level needed to track down prey on deepnorth biome and pin them on the map.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new Hunting.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			_displayEnemyHPEnable = config("4- Hunters Vision", "Enable", Toggle.On, new ConfigDescription("If On, creatures health will be displayed in numerical or percentage value.", (AcceptableValueBase)null, Array.Empty<object>()));
			_displayEnemyHPOptions = config("4- Hunters Vision", "Display Creatures Health In", DisplayOptions.Percentage, new ConfigDescription("Displays creatures health in either numerical or percentage value.", (AcceptableValueBase)null, Array.Empty<object>()));
			_displayEnemyHPLevel = config("4- Hunters Vision", "Hunters Vision Level", 15, new ConfigDescription("Required skill level needed to display creatures health.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), new object[1]
			{
				new Hunting.Functions.ConfigurationManagerAttributes
				{
					ShowRangeAsPercent = false
				}
			}));
			_displayExpGained = config("5- Skills Exp", "Display Exp Gain", Toggle.On, new ConfigDescription("Enable/Disable exp gain notification.", (AcceptableValueBase)null, Array.Empty<object>()));
			_expGainFactor = config("5- Skills Exp", "Exp Gain Factor", 1f, new ConfigDescription("Exp gain factor for Hunting skill.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.01f, 5f), Array.Empty<object>()));
			_expGainFactor.SettingChanged += delegate
			{
				_hunting.SkillGainFactor = _expGainFactor.Value;
			};
			_hunting.SkillGainFactor = _expGainFactor.Value;
			_expLoss = config("5- Skills Exp", "Exp Loss Amount", 0, new ConfigDescription("Skills exp loss on death.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
			_expLoss.SettingChanged += delegate
			{
				_hunting.SkillLoss = _expLoss.Value;
			};
			_hunting.SkillLoss = _expLoss.Value;
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
			((BaseUnityPlugin)this).Config.Save();
			GenerateCreatureList();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
		}

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

		private static void GenerateCreatureList()
		{
			HashSet<string> other = new HashSet<string>(_tier1Meadows.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			HashSet<string> other2 = new HashSet<string>(_tier2BlackForest.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			HashSet<string> other3 = new HashSet<string>(_tier3Swamps.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			HashSet<string> other4 = new HashSet<string>(_tier4Mountains.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			HashSet<string> other5 = new HashSet<string>(_tier5Plains.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			HashSet<string> other6 = new HashSet<string>(_tier6Mistlands.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			HashSet<string> other7 = new HashSet<string>(_tier7Ashlands.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			HashSet<string> other8 = new HashSet<string>(_tier8DeepNorth.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			HashSet<string> hashSet = new HashSet<string>();
			hashSet.UnionWith(other);
			hashSet.UnionWith(other2);
			hashSet.UnionWith(other3);
			hashSet.UnionWith(other4);
			hashSet.UnionWith(other5);
			hashSet.UnionWith(other6);
			hashSet.UnionWith(other7);
			hashSet.UnionWith(other8);
			_CreatureList = hashSet;
		}

		private static void TextBox(ConfigEntryBase entryBase)
		{
			entryBase.BoxedValue = GUILayout.TextArea((string)entryBase.BoxedValue, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
		}
	}
}
namespace Hunting.Functions
{
	public class ConfigurationManagerAttributes
	{
		[UsedImplicitly]
		public bool? ShowRangeAsPercent;

		[UsedImplicitly]
		public int? Order;

		[UsedImplicitly]
		public bool? Browsable;

		[UsedImplicitly]
		public string Category;

		[UsedImplicitly]
		public Action<ConfigEntryBase> CustomDrawer;
	}
	public static class Helper
	{
		public static readonly IDictionary<string, Sprite> _Tier1Icons = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _Tier2Icons = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _Tier3Icons = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _Tier4Icons = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _Tier5Icons = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _Tier6Icons = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _Tier7Icons = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _Tier8Icons = new Dictionary<string, Sprite>();

		public static float tFloat(this float value, int digits)
		{
			double num = Math.Pow(10.0, digits);
			return (float)(Math.Truncate(num * (double)value) / num);
		}

		private static string TrackPrey(string prey, string track)
		{
			Match match = new Regex(track, RegexOptions.IgnoreCase).Match(prey);
			if (!match.Success)
			{
				return "";
			}
			return match.Value;
		}

		public static void GetTier1PinIcons(string prey)
		{
			if (_Tier1Icons.ContainsKey(prey))
			{
				return;
			}
			foreach (string key in ObjectDBPatch._SpritesDictTier1.Keys)
			{
				if (!(TrackPrey(prey, key) == ""))
				{
					_Tier1Icons.Add(prey, ObjectDBPatch._SpritesDictTier1[key]);
					break;
				}
			}
		}

		public static void GetTier2PinIcons(string prey)
		{
			if (_Tier2Icons.ContainsKey(prey))
			{
				return;
			}
			foreach (string key in ObjectDBPatch._SpritesDictTier2.Keys)
			{
				if (!(TrackPrey(prey, key) == ""))
				{
					_Tier2Icons.Add(prey, ObjectDBPatch._SpritesDictTier2[key]);
					break;
				}
			}
		}

		public static void GetTier3PinIcons(string prey)
		{
			if (_Tier3Icons.ContainsKey(prey))
			{
				return;
			}
			foreach (string key in ObjectDBPatch._SpritesDictTier3.Keys)
			{
				if (!(TrackPrey(prey, key) == ""))
				{
					_Tier3Icons.Add(prey, ObjectDBPatch._SpritesDictTier3[key]);
					break;
				}
			}
		}

		public static void GetTier4PinIcons(string prey)
		{
			if (_Tier4Icons.ContainsKey(prey))
			{
				return;
			}
			foreach (string key in ObjectDBPatch._SpritesDictTier4.Keys)
			{
				if (!(TrackPrey(prey, key) == ""))
				{
					_Tier4Icons.Add(prey, ObjectDBPatch._SpritesDictTier4[key]);
					break;
				}
			}
		}

		public static void GetTier5PinIcons(string prey)
		{
			if (_Tier5Icons.ContainsKey(prey))
			{
				return;
			}
			foreach (string key in ObjectDBPatch._SpritesDictTier5.Keys)
			{
				if (!(TrackPrey(prey, key) == ""))
				{
					_Tier5Icons.Add(prey, ObjectDBPatch._SpritesDictTier5[key]);
					break;
				}
			}
		}

		public static void GetTier6PinIcons(string prey)
		{
			if (_Tier6Icons.ContainsKey(prey))
			{
				return;
			}
			foreach (string key in ObjectDBPatch._SpritesDictTier6.Keys)
			{
				if (!(TrackPrey(prey, key) == ""))
				{
					_Tier6Icons.Add(prey, ObjectDBPatch._SpritesDictTier6[key]);
					break;
				}
			}
		}

		public static void GetTier7PinIcons(string prey)
		{
			if (_Tier7Icons.ContainsKey(prey))
			{
				return;
			}
			foreach (string key in ObjectDBPatch._SpritesDictTier7.Keys)
			{
				if (!(TrackPrey(prey, key) == ""))
				{
					_Tier7Icons.Add(prey, ObjectDBPatch._SpritesDictTier7[key]);
					break;
				}
			}
		}

		public static void GetTier8PinIcons(string prey)
		{
			if (_Tier8Icons.ContainsKey(prey))
			{
				return;
			}
			foreach (string key in ObjectDBPatch._SpritesDictTier8.Keys)
			{
				if (!(TrackPrey(prey, key) == ""))
				{
					_Tier8Icons.Add(prey, ObjectDBPatch._SpritesDictTier8[key]);
					break;
				}
			}
		}
	}
	public enum Toggle
	{
		On = 1,
		Off = 0
	}
}
namespace Hunting.Patches
{
	[HarmonyPatch(typeof(CharacterDrop), "GenerateDropList")]
	public class CharacterDropPatch
	{
		[HarmonyPriority(100)]
		[UsedImplicitly]
		private static void Postfix(CharacterDrop __instance, ref List<KeyValuePair<GameObject, int>> __result)
		{
			if (!CharacterPatch._isHunting || (Object)(object)__instance.m_character == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null || !CharacterPatch.IsPrey(__instance.m_character) || __instance.m_character.IsTamed() || Plugin._useDropSystem.Value == Toggle.Off)
			{
				return;
			}
			List<KeyValuePair<GameObject, int>> list = new List<KeyValuePair<GameObject, int>>();
			int num = ((!Object.op_Implicit((Object)(object)__instance.m_character)) ? 1 : Mathf.Max(1, (int)Mathf.Pow(2f, (float)(__instance.m_character.GetLevel() - 1))));
			foreach (Drop drop in __instance.m_drops)
			{
				if ((Object)(object)drop.m_prefab == (Object)null)
				{
					continue;
				}
				float num2 = drop.m_chance;
				if (drop.m_levelMultiplier)
				{
					num2 *= (float)num;
				}
				if (Random.value <= num2)
				{
					int num3 = (drop.m_dontScale ? Random.Range(drop.m_amountMin, drop.m_amountMax) : Game.instance.ScaleDrops(drop.m_prefab, drop.m_amountMin, drop.m_amountMax));
					if (drop.m_levelMultiplier)
					{
						num3 *= num;
					}
					if (drop.m_onePerPlayer)
					{
						num3 = ZNet.instance.GetNrOfPlayers();
					}
					if (num3 > 100)
					{
						num3 = 100;
					}
					if (num3 > 0)
					{
						int num4 = new Random().Next(1, 100);
						((Character)Player.m_localPlayer).GetSkills().m_skillData.TryGetValue((SkillType)Mathf.Abs(StringExtensionMethods.GetStableHashCode("Hunting")), out var value);
						if ((float)num4 <= value?.m_level)
						{
							float num5 = 1f + Plugin._huntingYieldFactor.Value * ((Character)(object)Player.m_localPlayer).GetSkillFactor("Hunting");
							int value2 = Mathf.FloorToInt((float)num3 * num5);
							list.Add(new KeyValuePair<GameObject, int>(drop.m_prefab, value2));
						}
						else
						{
							list.Add(new KeyValuePair<GameObject, int>(drop.m_prefab, num3));
						}
					}
				}
				__result = list;
			}
		}
	}
	[HarmonyPatch]
	public class CharacterPatch
	{
		public static bool _isHunting;

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "RPC_Damage")]
		private static void RpcDamage_Prefix(Character __instance, HitData hit)
		{
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			Character attacker = hit.GetAttacker();
			Player val = (Player)(object)((attacker is Player) ? attacker : null);
			if (val != null && ((Humanoid)val).GetCurrentWeapon() != null && ((Humanoid)val).GetCurrentWeapon() != ((Humanoid)val).m_unarmedWeapon.m_itemData && IsUsingHuntingWeapon(val) && IsPrey(__instance) && !__instance.IsTamed())
			{
				_isHunting = true;
				((Character)val).GetSkills().m_skillData.TryGetValue((SkillType)Mathf.Abs(StringExtensionMethods.GetStableHashCode("Hunting")), out var value);
				string value2 = ((Object)((Component)__instance).gameObject).name.Replace("(Clone)", "");
				string[] source = Plugin._tier1Meadows.Value.Split(',', ' ');
				if (value != null && value.m_level > 10f)
				{
					((Character)val).RaiseSkill(Skill.fromName("Hunting"), source.Contains(value2) ? 0.8f : 1f);
				}
				else if (value != null && value.m_level > 20f)
				{
					((Character)val).RaiseSkill(Skill.fromName("Hunting"), source.Contains(value2) ? 0.5f : 1f);
				}
				else if (value != null && value.m_level > 30f)
				{
					((Character)val).RaiseSkill(Skill.fromName("Hunting"), source.Contains(value2) ? 0.2f : 1f);
				}
				else
				{
					((Character)val).RaiseSkill(Skill.fromName("Hunting"), 1f);
				}
			}
		}

		[HarmonyPatch(typeof(Character), "Awake")]
		[HarmonyPostfix]
		private static void Awake_Postfix(Character __instance)
		{
			if (!__instance.IsTamed())
			{
				AddTier1Tracker(((Component)__instance).gameObject);
				AddTier2Tracker(((Component)__instance).gameObject);
				AddTier3Tracker(((Component)__instance).gameObject);
				AddTier4Tracker(((Component)__instance).gameObject);
				AddTier5Tracker(((Component)__instance).gameObject);
				AddTier6Tracker(((Component)__instance).gameObject);
				AddTier7Tracker(((Component)__instance).gameObject);
				AddTier8Tracker(((Component)__instance).gameObject);
			}
		}

		private static void AddTier1Tracker(GameObject gameObject)
		{
			string name = ((Object)gameObject).name;
			string resourceName = Localization.instance.Localize(gameObject.GetComponent<Character>().m_name);
			Helper.GetTier1PinIcons(name);
			if (Helper._Tier1Icons.TryGetValue(name, out var value))
			{
				gameObject.AddComponent<Tracker>().Create(resourceName, Plugin._detectionRadius.Value, value, Plugin._tier1MeadowsLevel.Value);
			}
		}

		private static void AddTier2Tracker(GameObject gameObject)
		{
			string name = ((Object)gameObject).name;
			string resourceName = Localization.instance.Localize(gameObject.GetComponent<Character>().m_name);
			Helper.GetTier2PinIcons(name);
			if (Helper._Tier2Icons.TryGetValue(name, out var value))
			{
				gameObject.AddComponent<Tracker>().Create(resourceName, Plugin._detectionRadius.Value, value, Plugin._tier2BlackForestLevel.Value);
			}
		}

		private static void AddTier3Tracker(GameObject gameObject)
		{
			string name = ((Object)gameObject).name;
			string resourceName = Localization.instance.Localize(gameObject.GetComponent<Character>().m_name);
			Helper.GetTier3PinIcons(name);
			if (Helper._Tier3Icons.TryGetValue(name, out var value))
			{
				gameObject.AddComponent<Tracker>().Create(resourceName, Plugin._detectionRadius.Value, value, Plugin._tier3SwampsLevel.Value);
			}
		}

		private static void AddTier4Tracker(GameObject gameObject)
		{
			string name = ((Object)gameObject).name;
			string resourceName = Localization.instance.Localize(gameObject.GetComponent<Character>().m_name);
			Helper.GetTier4PinIcons(name);
			if (Helper._Tier4Icons.TryGetValue(name, out var value))
			{
				gameObject.AddComponent<Tracker>().Create(resourceName, Plugin._detectionRadius.Value, value, Plugin._tier4MountainsLevel.Value);
			}
		}

		private static void AddTier5Tracker(GameObject gameObject)
		{
			string name = ((Object)gameObject).name;
			string resourceName = Localization.instance.Localize(gameObject.GetComponent<Character>().m_name);
			Helper.GetTier5PinIcons(name);
			if (Helper._Tier5Icons.TryGetValue(name, out var value))
			{
				gameObject.AddComponent<Tracker>().Create(resourceName, Plugin._detectionRadius.Value, value, Plugin._tier5PlainsLevel.Value);
			}
		}

		private static void AddTier6Tracker(GameObject gameObject)
		{
			string name = ((Object)gameObject).name;
			string resourceName = Localization.instance.Localize(gameObject.GetComponent<Character>().m_name);
			Helper.GetTier6PinIcons(name);
			if (Helper._Tier6Icons.TryGetValue(name, out var value))
			{
				gameObject.AddComponent<Tracker>().Create(resourceName, Plugin._detectionRadius.Value, value, Plugin._tier6MistlandsLevel.Value);
			}
		}

		private static void AddTier7Tracker(GameObject gameObject)
		{
			string name = ((Object)gameObject).name;
			string resourceName = Localization.instance.Localize(gameObject.GetComponent<Character>().m_name);
			Helper.GetTier7PinIcons(name);
			if (Helper._Tier7Icons.TryGetValue(name, out var value))
			{
				gameObject.AddComponent<Tracker>().Create(resourceName, Plugin._detectionRadius.Value, value, Plugin._tier7AshlandsLevel.Value);
			}
		}

		private static void AddTier8Tracker(GameObject gameObject)
		{
			string name = ((Object)gameObject).name;
			string resourceName = Localization.instance.Localize(gameObject.GetComponent<Character>().m_name);
			Helper.GetTier8PinIcons(name);
			if (Helper._Tier8Icons.TryGetValue(name, out var value))
			{
				gameObject.AddComponent<Tracker>().Create(resourceName, Plugin._detectionRadius.Value, value, Plugin._tier8DeepNorthLevel.Value);
			}
		}

		public static bool IsPrey(Character character)
		{
			string[] source = Plugin._CreatureList.ToArray();
			string text = ((Object)character).name.Replace("(Clone)", "");
			return source.Any((string name) => text == name);
		}

		private static bool IsUsingHuntingWeapon(Player player)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Invalid comparison between Unknown and I4
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Invalid comparison between Unknown and I4
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			SkillType skillType = ((Humanoid)player).GetCurrentWeapon().m_shared.m_skillType;
			if ((int)skillType <= 5)
			{
				if ((int)skillType == 2 || (int)skillType == 5)
				{
					goto IL_0028;
				}
			}
			else if ((int)skillType == 8 || (int)skillType == 14)
			{
				goto IL_0028;
			}
			return false;
			IL_0028:
			return true;
		}
	}
	[HarmonyPatch]
	public class EnemyHudPatch
	{
		private static readonly ConditionalWeakTable<HudData, TMP_Text> HpText = new ConditionalWeakTable<HudData, TMP_Text>();

		[HarmonyPrefix]
		[HarmonyPatch(typeof(EnemyHud), "ShowHud")]
		private static void ShowHud_Prefix(ref EnemyHud __instance, ref Character c, ref bool __state)
		{
			__state = __instance.m_huds.ContainsKey(c);
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyHud), "ShowHud")]
		private static void ShowHud_Postfix(ref EnemyHud __instance, ref Character c, ref bool __state)
		{
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			if (!__state && __instance.m_huds.TryGetValue(c, out var value) && !c.IsPlayer() && !((Object)(object)c == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)c == (Object)(object)Player.m_localPlayer) && Plugin._displayEnemyHPEnable.Value != 0 && Plugin._displayEnemyHPLevel.Value > 0 && ((Character)(object)Player.m_localPlayer).GetSkillFactor("Hunting") >= (float)Plugin._displayEnemyHPLevel.Value / 100f)
			{
				TMP_Text val = (TMP_Text)(object)Object.Instantiate<TextMeshProUGUI>(value.m_name, ((TMP_Text)value.m_name).transform.parent);
				((Object)val).name = "enemyHPText";
				switch (Plugin._displayEnemyHPOptions.Value)
				{
				case Plugin.DisplayOptions.Numerical:
				{
					float health = value.m_character.GetHealth();
					float maxHealth = value.m_character.GetMaxHealth();
					val.text = $"{health:0}/{maxHealth:0}";
					break;
				}
				case Plugin.DisplayOptions.Percentage:
				{
					float healthPercentage = value.m_character.GetHealthPercentage();
					val.text = $"{Mathf.FloorToInt(healthPercentage * 100f)}%";
					break;
				}
				}
				((Graphic)val).color = Color.white;
				if (c.IsBoss())
				{
					val.rectTransform.anchoredPosition = new Vector2(val.rectTransform.anchoredPosition.x, -7f);
					val.fontSizeMax = 17f;
					val.fontSizeMin = 10f;
				}
				else
				{
					val.rectTransform.anchoredPosition = new Vector2(val.rectTransform.anchoredPosition.x, 6f);
					val.fontSizeMax = 13f;
					val.fontSizeMin = 7f;
				}
				HpText.Add(value, val);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(EnemyHud), "UpdateHuds")]
		private static void UpdateHuds_Postfix(ref EnemyHud __instance)
		{
			Character val = null;
			foreach (HudData item in __instance.m_huds.Select((KeyValuePair<Character, HudData> hud) => hud.Value))
			{
				if (!Object.op_Implicit((Object)(object)item.m_character) || !__instance.TestShow(item.m_character, true))
				{
					if ((Object)(object)val == (Object)null)
					{
						val = item.m_character;
						Object.Destroy((Object)(object)item.m_gui);
					}
					continue;
				}
				if (item.m_character.IsPlayer())
				{
					return;
				}
				if (!HpText.TryGetValue(item, out var value))
				{
					continue;
				}
				if ((Object)(object)item.m_character == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)item.m_character == (Object)(object)Player.m_localPlayer)
				{
					return;
				}
				if (Plugin._displayEnemyHPEnable.Value == Toggle.On && Plugin._displayEnemyHPLevel.Value > 0 && ((Character)(object)Player.m_localPlayer).GetSkillFactor("Hunting") >= (float)Plugin._displayEnemyHPLevel.Value / 100f)
				{
					switch (Plugin._displayEnemyHPOptions.Value)
					{
					case Plugin.DisplayOptions.Numerical:
					{
						float health = item.m_character.GetHealth();
						float maxHealth = item.m_character.GetMaxHealth();
						value.text = $"{health:0}/{maxHealth:0}";
						break;
					}
					case Plugin.DisplayOptions.Percentage:
					{
						float healthPercentage = item.m_character.GetHealthPercentage();
						value.text = $"{Mathf.FloorToInt(healthPercentage * 100f)}%";
						break;
					}
					}
				}
				else if (Plugin._displayEnemyHPEnable.Value == Toggle.Off || Plugin._displayEnemyHPLevel.Value <= 0 || !(((Character)(object)Player.m_localPlayer).GetSkillFactor("Hunting") >= (float)Plugin._displayEnemyHPLevel.Value / 100f))
				{
					value.text = "";
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				__instance.m_huds.Remove(val);
			}
		}
	}
	[HarmonyPatch(typeof(ObjectDB), "UpdateRegisters")]
	public class ObjectDBPatch
	{
		public static readonly IDictionary<string, Sprite> _SpritesDictTier1 = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _SpritesDictTier2 = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _SpritesDictTier3 = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _SpritesDictTier4 = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _SpritesDictTier5 = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _SpritesDictTier6 = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _SpritesDictTier7 = new Dictionary<string, Sprite>();

		public static readonly IDictionary<string, Sprite> _SpritesDictTier8 = new Dictionary<string, Sprite>();

		private static void Postfix(ObjectDB __instance)
		{
			GetTier1Sprites(__instance);
			GetTier2Sprites(__instance);
			GetTier3Sprites(__instance);
			GetTier4Sprites(__instance);
			GetTier5Sprites(__instance);
			GetTier6Sprites(__instance);
			GetTier7Sprites(__instance);
			GetTier8Sprites(__instance);
		}

		private static void GetTier1Sprites(ObjectDB objectDB)
		{
			_SpritesDictTier1.Clear();
			HashSet<string> hashSet = new HashSet<string>(Plugin._tier1Meadows.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			ZNetScene instance = ZNetScene.instance;
			if (!Object.op_Implicit((Object)(object)instance) || instance.m_prefabs.Count <= 0)
			{
				return;
			}
			foreach (string item in hashSet)
			{
				string text = item;
				GameObject prefab = instance.GetPrefab(StringExtensionMethods.GetStableHashCode(item));
				if ((Object)(object)prefab == (Object)null)
				{
					continue;
				}
				CharacterDrop component = prefab.GetComponent<CharacterDrop>();
				if ((Object)(object)component != (Object)null)
				{
					foreach (Drop drop in component.m_drops)
					{
						text = (((Object)drop.m_prefab).name.ToLower().Contains("trophy") ? ((Object)drop.m_prefab).name : ((Object)component.m_drops[0].m_prefab).name);
					}
				}
				GameObject itemPrefab = objectDB.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text));
				if ((Object)(object)itemPrefab == (Object)null)
				{
					continue;
				}
				ItemDrop component2 = itemPrefab.GetComponent<ItemDrop>();
				if ((Object)(object)component2 != (Object)null)
				{
					_SpritesDictTier1.Add(item, component2.m_itemData.GetIcon());
					continue;
				}
				Sprite value = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).SingleOrDefault((Func<Sprite, bool>)((Sprite x) => ((Object)x).name == "mapicon_pin"));
				_SpritesDictTier1.Add(item, value);
			}
		}

		private static void GetTier2Sprites(ObjectDB objectDB)
		{
			_SpritesDictTier2.Clear();
			HashSet<string> hashSet = new HashSet<string>(Plugin._tier2BlackForest.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			ZNetScene instance = ZNetScene.instance;
			if (!Object.op_Implicit((Object)(object)instance) || instance.m_prefabs.Count <= 0)
			{
				return;
			}
			foreach (string item in hashSet)
			{
				string text = item;
				GameObject prefab = instance.GetPrefab(StringExtensionMethods.GetStableHashCode(item));
				if ((Object)(object)prefab == (Object)null)
				{
					continue;
				}
				CharacterDrop component = prefab.GetComponent<CharacterDrop>();
				if ((Object)(object)component != (Object)null)
				{
					foreach (Drop drop in component.m_drops)
					{
						text = (((Object)drop.m_prefab).name.ToLower().Contains("trophy") ? ((Object)drop.m_prefab).name : ((Object)component.m_drops[0].m_prefab).name);
					}
				}
				GameObject itemPrefab = objectDB.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text));
				if ((Object)(object)itemPrefab == (Object)null)
				{
					continue;
				}
				ItemDrop component2 = itemPrefab.GetComponent<ItemDrop>();
				if ((Object)(object)component2 != (Object)null)
				{
					_SpritesDictTier2.Add(item, component2.m_itemData.GetIcon());
					continue;
				}
				Sprite value = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).SingleOrDefault((Func<Sprite, bool>)((Sprite x) => ((Object)x).name == "mapicon_pin"));
				_SpritesDictTier2.Add(item, value);
			}
		}

		private static void GetTier3Sprites(ObjectDB objectDB)
		{
			_SpritesDictTier3.Clear();
			HashSet<string> hashSet = new HashSet<string>(Plugin._tier3Swamps.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			ZNetScene instance = ZNetScene.instance;
			if (!Object.op_Implicit((Object)(object)instance) || instance.m_prefabs.Count <= 0)
			{
				return;
			}
			foreach (string item in hashSet)
			{
				string text = item;
				GameObject prefab = instance.GetPrefab(StringExtensionMethods.GetStableHashCode(item));
				if ((Object)(object)prefab == (Object)null)
				{
					continue;
				}
				CharacterDrop component = prefab.GetComponent<CharacterDrop>();
				if ((Object)(object)component != (Object)null)
				{
					foreach (Drop drop in component.m_drops)
					{
						text = (((Object)drop.m_prefab).name.ToLower().Contains("trophy") ? ((Object)drop.m_prefab).name : ((Object)component.m_drops[0].m_prefab).name);
					}
				}
				GameObject itemPrefab = objectDB.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text));
				if ((Object)(object)itemPrefab == (Object)null)
				{
					continue;
				}
				ItemDrop component2 = itemPrefab.GetComponent<ItemDrop>();
				if ((Object)(object)component2 != (Object)null)
				{
					_SpritesDictTier3.Add(item, component2.m_itemData.GetIcon());
					continue;
				}
				Sprite value = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).SingleOrDefault((Func<Sprite, bool>)((Sprite x) => ((Object)x).name == "mapicon_pin"));
				_SpritesDictTier3.Add(item, value);
			}
		}

		private static void GetTier4Sprites(ObjectDB objectDB)
		{
			_SpritesDictTier4.Clear();
			HashSet<string> hashSet = new HashSet<string>(Plugin._tier4Mountains.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			ZNetScene instance = ZNetScene.instance;
			if (!Object.op_Implicit((Object)(object)instance) || instance.m_prefabs.Count <= 0)
			{
				return;
			}
			foreach (string item in hashSet)
			{
				string text = item;
				GameObject prefab = instance.GetPrefab(StringExtensionMethods.GetStableHashCode(item));
				if ((Object)(object)prefab == (Object)null)
				{
					continue;
				}
				CharacterDrop component = prefab.GetComponent<CharacterDrop>();
				if ((Object)(object)component != (Object)null)
				{
					foreach (Drop drop in component.m_drops)
					{
						text = (((Object)drop.m_prefab).name.ToLower().Contains("trophy") ? ((Object)drop.m_prefab).name : ((Object)component.m_drops[0].m_prefab).name);
					}
				}
				GameObject itemPrefab = objectDB.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text));
				if ((Object)(object)itemPrefab == (Object)null)
				{
					continue;
				}
				ItemDrop component2 = itemPrefab.GetComponent<ItemDrop>();
				if ((Object)(object)component2 != (Object)null)
				{
					_SpritesDictTier4.Add(item, component2.m_itemData.GetIcon());
					continue;
				}
				Sprite value = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).SingleOrDefault((Func<Sprite, bool>)((Sprite x) => ((Object)x).name == "mapicon_pin"));
				_SpritesDictTier4.Add(item, value);
			}
		}

		private static void GetTier5Sprites(ObjectDB objectDB)
		{
			_SpritesDictTier5.Clear();
			HashSet<string> hashSet = new HashSet<string>(Plugin._tier5Plains.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			ZNetScene instance = ZNetScene.instance;
			if (!Object.op_Implicit((Object)(object)instance) || instance.m_prefabs.Count <= 0)
			{
				return;
			}
			foreach (string item in hashSet)
			{
				string text = item;
				GameObject prefab = instance.GetPrefab(StringExtensionMethods.GetStableHashCode(item));
				if ((Object)(object)prefab == (Object)null)
				{
					continue;
				}
				CharacterDrop component = prefab.GetComponent<CharacterDrop>();
				if ((Object)(object)component != (Object)null)
				{
					foreach (Drop drop in component.m_drops)
					{
						text = (((Object)drop.m_prefab).name.ToLower().Contains("trophy") ? ((Object)drop.m_prefab).name : ((Object)component.m_drops[0].m_prefab).name);
					}
				}
				GameObject itemPrefab = objectDB.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text));
				if ((Object)(object)itemPrefab == (Object)null)
				{
					continue;
				}
				ItemDrop component2 = itemPrefab.GetComponent<ItemDrop>();
				if ((Object)(object)component2 != (Object)null)
				{
					_SpritesDictTier5.Add(item, component2.m_itemData.GetIcon());
					continue;
				}
				Sprite value = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).SingleOrDefault((Func<Sprite, bool>)((Sprite x) => ((Object)x).name == "mapicon_pin"));
				_SpritesDictTier5.Add(item, value);
			}
		}

		private static void GetTier6Sprites(ObjectDB objectDB)
		{
			_SpritesDictTier6.Clear();
			HashSet<string> hashSet = new HashSet<string>(Plugin._tier6Mistlands.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			ZNetScene instance = ZNetScene.instance;
			if (!Object.op_Implicit((Object)(object)instance) || instance.m_prefabs.Count <= 0)
			{
				return;
			}
			foreach (string item in hashSet)
			{
				string text = item;
				GameObject prefab = instance.GetPrefab(StringExtensionMethods.GetStableHashCode(item));
				if ((Object)(object)prefab == (Object)null)
				{
					continue;
				}
				CharacterDrop component = prefab.GetComponent<CharacterDrop>();
				if ((Object)(object)component != (Object)null)
				{
					foreach (Drop drop in component.m_drops)
					{
						text = (((Object)drop.m_prefab).name.ToLower().Contains("trophy") ? ((Object)drop.m_prefab).name : ((Object)component.m_drops[0].m_prefab).name);
					}
				}
				GameObject itemPrefab = objectDB.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text));
				if ((Object)(object)itemPrefab == (Object)null)
				{
					continue;
				}
				ItemDrop component2 = itemPrefab.GetComponent<ItemDrop>();
				if ((Object)(object)component2 != (Object)null)
				{
					_SpritesDictTier6.Add(item, component2.m_itemData.GetIcon());
					continue;
				}
				Sprite value = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).SingleOrDefault((Func<Sprite, bool>)((Sprite x) => ((Object)x).name == "mapicon_pin"));
				_SpritesDictTier6.Add(item, value);
			}
		}

		private static void GetTier7Sprites(ObjectDB objectDB)
		{
			_SpritesDictTier7.Clear();
			HashSet<string> hashSet = new HashSet<string>(Plugin._tier7Ashlands.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			ZNetScene instance = ZNetScene.instance;
			if (!Object.op_Implicit((Object)(object)instance) || instance.m_prefabs.Count <= 0)
			{
				return;
			}
			foreach (string item in hashSet)
			{
				string text = item;
				GameObject prefab = instance.GetPrefab(StringExtensionMethods.GetStableHashCode(item));
				if ((Object)(object)prefab == (Object)null)
				{
					continue;
				}
				CharacterDrop component = prefab.GetComponent<CharacterDrop>();
				if ((Object)(object)component != (Object)null)
				{
					foreach (Drop drop in component.m_drops)
					{
						text = (((Object)drop.m_prefab).name.ToLower().Contains("trophy") ? ((Object)drop.m_prefab).name : ((Object)component.m_drops[0].m_prefab).name);
					}
				}
				GameObject itemPrefab = objectDB.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text));
				if ((Object)(object)itemPrefab == (Object)null)
				{
					continue;
				}
				ItemDrop component2 = itemPrefab.GetComponent<ItemDrop>();
				if ((Object)(object)component2 != (Object)null)
				{
					_SpritesDictTier7.Add(item, component2.m_itemData.GetIcon());
					continue;
				}
				Sprite value = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).SingleOrDefault((Func<Sprite, bool>)((Sprite x) => ((Object)x).name == "mapicon_pin"));
				_SpritesDictTier7.Add(item, value);
			}
		}

		private static void GetTier8Sprites(ObjectDB objectDB)
		{
			_SpritesDictTier8.Clear();
			HashSet<string> hashSet = new HashSet<string>(Plugin._tier8DeepNorth.Value.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries));
			ZNetScene instance = ZNetScene.instance;
			if (!Object.op_Implicit((Object)(object)instance) || instance.m_prefabs.Count <= 0)
			{
				return;
			}
			foreach (string item in hashSet)
			{
				string text = item;
				GameObject prefab = instance.GetPrefab(StringExtensionMethods.GetStableHashCode(item));
				if ((Object)(object)prefab == (Object)null)
				{
					continue;
				}
				CharacterDrop component = prefab.GetComponent<CharacterDrop>();
				if ((Object)(object)component != (Object)null)
				{
					foreach (Drop drop in component.m_drops)
					{
						text = (((Object)drop.m_prefab).name.ToLower().Contains("trophy") ? ((Object)drop.m_prefab).name : ((Object)component.m_drops[0].m_prefab).name);
					}
				}
				GameObject itemPrefab = objectDB.GetItemPrefab(StringExtensionMethods.GetStableHashCode(text));
				if ((Object)(object)itemPrefab == (Object)null)
				{
					continue;
				}
				ItemDrop component2 = itemPrefab.GetComponent<ItemDrop>();
				if ((Object)(object)component2 != (Object)null)
				{
					_SpritesDictTier8.Add(item, component2.m_itemData.GetIcon());
					continue;
				}
				Sprite value = ((IEnumerable<Sprite>)Resources.FindObjectsOfTypeAll<Sprite>()).SingleOrDefault((Func<Sprite, bool>)((Sprite x) => ((Object)x).name == "mapicon_pin"));
				_SpritesDictTier8.Add(item, value);
			}
		}
	}
	[HarmonyPatch]
	public class PlayerPatch
	{
		[HarmonyPatch(typeof(Player), "Awake")]
		[HarmonyPostfix]
		private static void Awake_Postfix(Player __instance)
		{
			((Character)__instance).m_nview.Register<int>("Hunting IncreaseSkill", (Action<long, int>)delegate(long _, int factor)
			{
				((Character)(object)__instance).RaiseSkill("Hunting", factor);
			});
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "Update")]
		private static void Update_Postfix(ref Player __instance)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				((Character)__instance).m_nview.GetZDO().Set("Hunting Skill Factor", ((Character)__instance).GetSkillFactor(Skill.fromName("Hunting")));
			}
		}
	}
	[HarmonyPatch(typeof(Projectile), "OnHit")]
	public class ProjectilePatch
	{
		private static void Prefix(Projectile __instance, Collider collider, Vector3 hitPoint, bool water)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Invalid comparison between Unknown and I4
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Invalid comparison between Unknown and I4
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Invalid comparison between Unknown and I4
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			Character owner = __instance.m_owner;
			Player val = (Player)(object)((owner is Player) ? owner : null);
			if (val == null)
			{
				return;
			}
			GameObject val2 = (Object.op_Implicit((Object)(object)collider) ? Projectile.FindHitObject(collider) : null);
			bool flag = false;
			bool flag2 = false;
			IDestructible val3 = (Object.op_Implicit((Object)(object)val2) ? val2.GetComponent<IDestructible>() : null);
			if (val3 != null)
			{
				flag2 = val3 is Character;
				if (!__instance.IsValidTarget(val3))
				{
					return;
				}
				flag = true;
			}
			Character val4 = (Character)(object)((val3 is Character) ? val3 : null);
			if (!flag || (Object)(object)__instance.m_owner == (Object)null || !flag2 || !Object.op_Implicit((Object)(object)val4) || !CharacterPatch.IsPrey(val4) || val4.IsTamed() || ((int)__instance.m_skill != 5 && (int)__instance.m_skill != 2 && (int)__instance.m_skill != 7))
			{
				return;
			}
			((Character)val).GetSkills().m_skillData.TryGetValue((SkillType)Mathf.Abs(StringExtensionMethods.GetStableHashCode("Hunting")), out var value);
			string value2 = ((Object)((Component)val4).gameObject).name.Replace("(Clone)", "");
			string[] array = Plugin._tier1Meadows.Value.Split(',', ' ');
			if (Plugin._tier4MountainsLevel.Value > 0 && value?.m_level > (float)Plugin._tier4MountainsLevel.Value)
			{
				if (array.Length != 0 && array.Contains(value2))
				{
					((Character)val).RaiseSkill(Skill.fromName("Hunting"), 0.2f);
				}
			}
			else
			{
				((Character)val).RaiseSkill(Skill.fromName("Hunting"), 1f);
			}
		}
	}
	[HarmonyPatch(typeof(Skills), "RaiseSkill")]
	public class SkillsPatch
	{
		private static void Postfix(Skills __instance, SkillType skillType, float factor = 1f)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin._displayExpGained.Value == Toggle.Off)
			{
				return;
			}
			((Character)__instance.m_player).GetSkills().m_skillData.TryGetValue((SkillType)Mathf.Abs(StringExtensionMethods.GetStableHashCode("Hunting")), out var value);
			if ((SkillType?)skillType != value?.m_info.m_skill)
			{
				return;
			}
			try
			{
				if (value.m_level < 100f)
				{
					float value2 = value.m_accumulator / (value.GetNextLevelRequirement() / 100f);
					((Character)__instance.m_player).Message((MessageType)1, $"Level {value.m_level.tFloat(0)} Hunting [{value.m_accumulator.tFloat(2)}/{value.GetNextLevelRequirement().tFloat(2)}] ({value2.tFloat(0)}%)", 0, value.m_info.m_icon);
				}
			}
			catch
			{
			}
		}
	}
	[<5182ce2a-4b71-4038-9cfc-c774de8cc672>Nullable(0)]
	[<71803631-bd00-444e-8767-8867f40864a9>NullableContext(1)]
	public class Tracker : MonoBehaviour
	{
		public string m_resourceName;

		private float m_trackRange;

		private Sprite m_pinIcon;

		private PinData m_pinData;

		private int m_requiredLevel;

		public void Create(string resourceName, float trackRange, Sprite pinIcon, int requiredLevel)
		{
			m_resourceName = resourceName;
			m_trackRange = trackRange;
			m_pinIcon = pinIcon;
			m_pinData = null;
			m_requiredLevel = requiredLevel;
		}

		private void Update()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if (Object.op_Implicit((Object)(object)localPlayer))
			{
				Vector2 val = Vector2.op_Implicit(((Component)localPlayer).transform.position - ((Component)this).transform.position);
				float skillFactor = ((Character)(object)localPlayer).GetSkillFactor("Hunting");
				bool flag = Plugin._iconsOnly.Value == Toggle.On;
				if (m_pinData == null && ((Vector2)(ref val)).magnitude < m_trackRange && m_requiredLevel > 0 && skillFactor >= (float)m_requiredLevel / 100f)
				{
					m_pinData = Minimap.instance.AddPin(((Component)this).transform.position, (PinType)8, flag ? "" : m_resourceName, false, false, 0L, "");
					m_pinData.m_icon = m_pinIcon;
					m_pinData.m_worldSize = 0f;
				}
				else if (m_pinData != null && ((Vector2)(ref val)).magnitude > m_trackRange)
				{
					Minimap.instance.RemovePin(m_pinData);
					m_pinData = null;
				}
				else if (m_pinData != null && (m_requiredLevel <= 0 || (float)m_requiredLevel / 100f > skillFactor))
				{
					Minimap.instance.RemovePin(m_pinData);
					m_pinData = null;
				}
				if (m_pinData != null)
				{
					m_pinData.m_pos = ((Component)this).transform.position;
				}
			}
		}

		private void OnDestroy()
		{
			if (m_pinData == null)
			{
				return;
			}
			try
			{
				Minimap.instance.RemovePin(m_pinData);
				m_pinData = null;
			}
			catch
			{
			}
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class 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)]
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[Microsoft.CodeAnalysis.Embedded]
	[CompilerGenerated]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ServerSync
{
	[PublicAPI]
	internal abstract class OwnConfigEntryBase
	{
		public object? LocalBaseValue;

		public bool SynchronizedConfig = true;

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

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

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

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

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

		public readonly string Identifier;

		public readonly Type Type;

		private object? boxedValue;

		protected bool localIsOwner;

		public readonly int Priority;

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

		public event Action? ValueChanged;

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

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

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

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

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

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

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

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

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

		[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
		private class SendConfigsAfterLogin
		{
			private class BufferingSocket : ISocket
			{
				public volatile bool finished = false;

				public volatile int versionMatchQueued = -1;

				public readonly List<ZPackage> Package = new List<ZPackage>();

				public readonly ISocket Original;

				public BufferingSocket(ISocket original)
				{
					Original = original;
				}

				public bool IsConnected()
				{
					return Original.IsConnected();
				}

				public ZPackage Recv()
				{
					return Original.Recv();
				}

				public int GetSendQueueSize()
				{
					return Original.GetSendQueueSize();
				}

				public int GetCurrentSendRate()
				{
					return Original.GetCurrentSendRate();
				}

				public bool IsHost()
				{
					return Original.IsHost();
				}

				public void Dispose()
				{
					Original.Dispose();
				}

				public bool GotNewData()
				{
					return Original.GotNewData();
				}

				public void Close()
				{
					Original.Close();
				}

				public string GetEndPointString()
				{
					return Original.GetEndPointString();
				}

				public void GetAndResetStats(out int totalSent, out int totalRecv)
				{
					Original.GetAndResetStats(ref totalSent, ref totalRecv);
				}

				public void GetConnectionQuality(out float localQuality, out float remoteQuality, out int ping, out float outByteSec, out float inByteSec)
				{
					Original.GetConnectionQuality(ref localQuality, ref remoteQuality, ref ping, ref outByteSec, ref inByteSec);
				}

				public ISocket Accept()
				{
					return Original.Accept();
				}

				public int GetHostPort()
				{
					return Original.GetHostPort();
				}

				public bool Flush()
				{
					return Original.Flush();
				}

				public string GetHostName()
				{
					return Original.GetHostName();
				}

				public void VersionMatch()
				{
					if (finished)
					{
						Original.VersionMatch();
					}
					else
					{
						versionMatchQueued = Package.Count;
					}
				}

				public void Send(ZPackage pkg)
				{
					//IL_0057: Unknown result type (might be due to invalid IL or missing references)
					//IL_005d: Expected O, but got Unknown
					int pos = pkg.GetPos();
					pkg.SetPos(0);
					int num = pkg.ReadInt();
					if ((num == StringExtensionMethods.GetStableHashCode("PeerInfo") || num == StringExtensionMethods.GetStableHashCode("RoutedRPC") || num == StringExtensionMethods.GetStableHashCode("ZDOData")) && !finished)
					{
						ZPackage val = new ZPackage(pkg.GetArray());
						val.SetPos(pos);
						Package.Add(val);
					}
					else
					{
						pkg.SetPos(pos);
						Original.Send(pkg);
					}
				}
			}

			[HarmonyPriority(800)]
			[HarmonyPrefix]
			private static void Prefix(ref Dictionary<Assembly, BufferingSocket>? __state, ZNet __instance, ZRpc rpc)
			{
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Invalid comparison between Unknown and I4
				if (__instance.IsServer())
				{
					BufferingSocket value = new BufferingSocket(rpc.GetSocket());
					AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc, value);
					object? obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance, new object[1] { rpc });
					ZNetPeer val = (ZNetPeer)((obj is ZNetPeer) ? obj : null);
					if (val != null && (int)ZNet.m_onlineBackend > 0)
					{
						AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, value);
					}
					if (__state == null)
					{
						__state = new Dictionary<Assembly, BufferingSocket>();
					}
					__state[Assembly.GetExecutingAssembly()] = value;
				}
			}

			[HarmonyPostfix]
			private static void Postfix(Dictionary<Assembly, BufferingSocket> __state, ZNet __instance, ZRpc rpc)
			{
				ZRpc rpc2 = rpc;
				ZNet __instance2 = __instance;
				Dictionary<Assembly, BufferingSocket> __state2 = __state;
				ZNetPeer peer;
				if (__instance2.IsServer())
				{
					object obj = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance2, new object[1] { rpc2 });
					peer = (ZNetPeer)((obj is ZNetPeer) ? obj : null);
					if (peer == null)
					{
						SendBufferedData();
					}
					else
					{
						((MonoBehaviour)__instance2).StartCoroutine(sendAsync());
					}
				}
				void SendBufferedData()
				{
					if (rpc2.GetSocket() is BufferingSocket bufferingSocket)
					{
						AccessTools.DeclaredField(typeof(ZRpc), "m_socket").SetValue(rpc2, bufferingSocket.Original);
						object? obj2 = AccessTools.DeclaredMethod(typeof(ZNet), "GetPeer", new Type[1] { typeof(ZRpc) }, (Type[])null).Invoke(__instance2, new object[1] { rpc2 });
						ZNetPeer val = (ZNetPeer)((obj2 is ZNetPeer) ? obj2 : null);
						if (val != null)
						{
							AccessTools.DeclaredField(typeof(ZNetPeer), "m_socket").SetValue(val, bufferingSocket.Original);
						}
					}
					BufferingSocket bufferingSocket2 = __state2[Assembly.GetExecutingAssembly()];
					bufferingSocket2.finished = true;
					for (int i = 0; i < bufferingSocket2.Package.Count; i++)
					{
						if (i == bufferingSocket2.versionMatchQueued)
						{
							bufferingSocket2.Original.VersionMatch();
						}
						bufferingSocket2.Original.Send(bufferingSocket2.Package[i]);
					}
					if (bufferingSocket2.Package.Count == bufferingSocket2.versionMatchQueued)
					{
						bufferingSocket2.Original.VersionMatch();
					}
				}
				IEnumerator sendAsync()
				{
					foreach (ConfigSync configSync in configSyncs)
					{
						List<PackageEntry> entries = new List<PackageEntry>();
						if (configSync.CurrentVersion != null)
						{
							entries.Add(new PackageEntry
							{
								section = "Internal",
								key = "serverversion",
								type = typeof(string),
								value = configSync.CurrentVersion
							});
						}
						MethodInfo listContainsId = AccessTools.DeclaredMethod(typeof(ZNet), "ListContainsId", (Type[])null, (Type[])null);
						SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance);
						entries.Add(new PackageEntry
						{
							section = "Internal",
							key = "lockexempt",
							type = typeof(bool),
							value = (((object)listContainsId == null) ? ((object)adminList.Contains(rpc2.GetSocket().GetHostName())) : listContainsId.Invoke(ZNet.instance, new object[2]
							{
								adminList,
								rpc2.GetSocket().GetHostName()
							}))
						});
						ZPackage package = ConfigsToPackage(configSync.allConfigs.Select((OwnConfigEntryBase c) => c.BaseConfig), configSync.allCustomValues, entries, partial: false);
						yield return ((MonoBehaviour)__instance2).StartCoroutine(configSync.sendZPackage(new List<ZNetPeer> { peer }, package));
					}
					SendBufferedData();
				}
			}
		}

		private class PackageEntry
		{
			public string section = null;

			public string key = null;

			public Type type = null;

			public object? value;
		}

		[HarmonyPatch(typeof(ConfigEntryBase), "GetSerializedValue")]
		private static class PreventSavingServerInfo
		{
			[HarmonyPrefix]
			private static bool Prefix(ConfigEntryBase __instance, ref string __result)
			{
				OwnConfigEntryBase ownConfigEntryBase = configData(__instance);
				if (ownConfigEntryBase == null || isWritableConfig(ownConfigEntryBase))
				{
					return true;
				}
				__result = TomlTypeConverter.ConvertToString(ownConfigEntryBase.LocalBaseValue, __instance.SettingType);
				return false;
			}
		}

		[HarmonyPatch(typeof(ConfigEntryBase), "SetSerializedValue")]
		private static class PreventConfigRereadChangingValues
		{
			[HarmonyPrefix]
			private static bool Prefix(ConfigEntryBase __instance, string value)
			{
				OwnConfigEntryBase ownConfigEntryBase = configData(__instance);
				if (ownConfigEntryBase == null || ownConfigEntryBase.Loca