Decompiled source of RustyCompass v1.1.5

RustyCompass.dll

Decompiled 6 months ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using RustyCompass.Utilities;
using ServerSync;
using StatusEffectManager;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.BufferedDeserialization;
using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyProduct("RustyCompass")]
[assembly: AssemblyCompany("RustyMods")]
[assembly: AssemblyFileVersion("1.1.5")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyTitle("RustyCompass")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: Guid("E0E2F92E-557C-4A05-9D89-AA92A0BD75C4")]
[assembly: AssemblyConfiguration("")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.5.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<05ec03ad-cb07-4323-9837-6a8d03d3bbfb>Embedded]
	internal sealed class <05ec03ad-cb07-4323-9837-6a8d03d3bbfb>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[<05ec03ad-cb07-4323-9837-6a8d03d3bbfb>Embedded]
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class <a99f1a42-905e-4247-90f1-1bf75fa7d6bb>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <a99f1a42-905e-4247-90f1-1bf75fa7d6bb>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <a99f1a42-905e-4247-90f1-1bf75fa7d6bb>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<05ec03ad-cb07-4323-9837-6a8d03d3bbfb>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class <23dea103-1d4b-4c3e-b366-73cab9074174>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <23dea103-1d4b-4c3e-b366-73cab9074174>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace StatusEffectManager
{
	[PublicAPI]
	[Description("The ItemDrop effect to apply the status effect")]
	public enum EffectType
	{
		Equip,
		Attack,
		Consume,
		Set
	}
	public struct SE_Item
	{
		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(1)]
		public StatusEffect Effect;

		public EffectType Type;
	}
	[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
	[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
	[PublicAPI]
	public class CustomSE
	{
		private static readonly List<CustomSE> RegisteredEffects = new List<CustomSE>();

		private static readonly Dictionary<StatusEffect, CustomSE> CustomEffectMap = new Dictionary<StatusEffect, CustomSE>();

		internal static readonly List<StatusEffect> CustomSEs = new List<StatusEffect>();

		internal static readonly Dictionary<SE_Item, string> AddToPrefabs = new Dictionary<SE_Item, string>();

		[Description("Instance of the StatusEffect.")]
		public readonly StatusEffect Effect;

		public EffectType Type;

		private string _folderName = "icons";

		private AssetBundle _assetBundle = null;

		[Description("Sets the icon for the StatusEffect. Must be 64x64")]
		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public Sprite IconSprite = null;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		private string IconName = null;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		private LocalizeKey _name;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		private static Localization _english;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		private static BaseUnityPlugin _plugin;

		private static bool hasConfigSync = true;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		private static object _configSync;

		[Description("Sets the icon for the StatusEffect. Must be 64x64")]
		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public string Icon
		{
			[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(2)]
			get
			{
				return IconName;
			}
			[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(2)]
			set
			{
				IconName = value;
				IconSprite = ((IconName == null) ? null : loadSprite(IconName));
				Effect.m_icon = IconSprite;
			}
		}

		[Description("Sets the in-game name for the StatusEffect")]
		public LocalizeKey Name
		{
			get
			{
				LocalizeKey name = _name;
				if (name != null)
				{
					return name;
				}
				StatusEffect effect = Effect;
				if (effect.m_name.StartsWith("$"))
				{
					_name = new LocalizeKey(effect.m_name);
				}
				else
				{
					string text = "$statuseffect_" + ((Object)Effect).name.Replace(" ", "_");
					_name = new LocalizeKey(text).English(effect.m_name);
					effect.m_name = text;
				}
				return _name;
			}
		}

		private static Localization english
		{
			get
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Expected O, but got Unknown
				if (_english == null)
				{
					_english = new Localization();
					_english.SetupLanguage("English");
				}
				return _english;
			}
		}

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

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		private static object configSync
		{
			[<23dea103-1d4b-4c3e-b366-73cab9074174>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 + " ItemManager");
						type.GetField("CurrentVersion").SetValue(_configSync, plugin.Info.Metadata.Version.ToString());
						type.GetProperty("IsLocked").SetValue(_configSync, true);
					}
					else
					{
						hasConfigSync = false;
					}
				}
				return _configSync;
			}
		}

		public CustomSE(string assetBundleFileName, string customEffectName, string folderName = "assets")
			: this(EffectManager.RegisterAssetBundle(assetBundleFileName, folderName), customEffectName)
		{
		}

		public CustomSE(AssetBundle bundle, string customEffectName)
		{
			Effect = EffectManager.RegisterCustomSE(bundle, customEffectName);
			RegisteredEffects.Add(this);
			CustomEffectMap[Effect] = this;
		}

		public CustomSE(string customEffectName)
		{
			Effect = ScriptableObject.CreateInstance<StatusEffect>();
			EffectManager.RegisterCustomSE(Effect, customEffectName);
			RegisteredEffects.Add(this);
			CustomEffectMap[Effect] = this;
		}

		[return: <a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		private byte[] ReadEmbeddedFileBytes(string name)
		{
			using MemoryStream memoryStream = new MemoryStream();
			Stream manifestResourceStream = Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + ((_folderName == "") ? "" : ".") + _folderName + "." + name);
			if (manifestResourceStream == null)
			{
				return null;
			}
			manifestResourceStream.CopyTo(memoryStream);
			return memoryStream.ToArray();
		}

		[return: <a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		private Texture2D loadTexture(string name)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			byte[] array = ReadEmbeddedFileBytes(name);
			if (array != null)
			{
				Texture2D val = new Texture2D(0, 0);
				ImageConversion.LoadImage(val, array);
				return val;
			}
			return null;
		}

		private Sprite loadSprite(string name)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = loadTexture(name);
			if (val != null)
			{
				return Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), Vector2.zero);
			}
			AssetBundle assetBundle = _assetBundle;
			Sprite val2 = ((assetBundle != null) ? assetBundle.LoadAsset<Sprite>(name) : null);
			if (val2 != null)
			{
				return val2;
			}
			throw new FileNotFoundException("Could not find a file named " + name + " for the effect icon");
		}

		public void AddSEToPrefab(CustomSE customSE, string prefabName)
		{
			SE_Item sE_Item = default(SE_Item);
			sE_Item.Effect = customSE.Effect;
			sE_Item.Type = customSE.Type;
			SE_Item key = sE_Item;
			AddToPrefabs.Add(key, prefabName);
		}

		private static ConfigEntry<T> config<[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)] 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<[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)] 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>()));
		}
	}
	[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
	[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
	[PublicAPI]
	public class LocalizeKey
	{
		public readonly string Key;

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

		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)
		{
			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;
		}
	}
	[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
	[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
	public static class EffectManager
	{
		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
		private struct BundleId
		{
			[UsedImplicitly]
			public string assetBundleFileName;

			[UsedImplicitly]
			public string folderName;
		}

		private static readonly Dictionary<BundleId, AssetBundle> bundleCache;

		static EffectManager()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Expected O, but got Unknown
			bundleCache = new Dictionary<BundleId, AssetBundle>();
			Harmony val = new Harmony("org.bepinex.helpers.StatusEffectManager");
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ObjectDB), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(EffectManager), "Patch_ObjectDBInit", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			val.Patch((MethodBase)AccessTools.DeclaredMethod(typeof(ZNetScene), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(AccessTools.DeclaredMethod(typeof(EffectManager), "Patch_ZNetSceneAwake", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		public static AssetBundle RegisterAssetBundle(string assetBundleFileName, string folderName = "assets")
		{
			BundleId bundleId = default(BundleId);
			bundleId.assetBundleFileName = assetBundleFileName;
			bundleId.folderName = folderName;
			BundleId key = bundleId;
			if (!bundleCache.TryGetValue(key, out var value))
			{
				Dictionary<BundleId, AssetBundle> dictionary = bundleCache;
				AssetBundle? obj = ((IEnumerable<AssetBundle>)Resources.FindObjectsOfTypeAll<AssetBundle>()).FirstOrDefault((Func<AssetBundle, bool>)([<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(0)] (AssetBundle a) => ((Object)a).name == assetBundleFileName)) ?? AssetBundle.LoadFromStream(Assembly.GetExecutingAssembly().GetManifestResourceStream(Assembly.GetExecutingAssembly().GetName().Name + ((folderName == "") ? "" : ".") + folderName + "." + assetBundleFileName));
				AssetBundle result = obj;
				dictionary[key] = obj;
				return result;
			}
			return value;
		}

		public static StatusEffect RegisterCustomSE(string assetBundleFileName, string customEffectName, string folderName = "assets")
		{
			return RegisterCustomSE(RegisterAssetBundle(assetBundleFileName, folderName), customEffectName);
		}

		public static StatusEffect RegisterCustomSE(AssetBundle assets, string customEffectName)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			StatusEffect val = (StatusEffect)assets.LoadAsset<ScriptableObject>(customEffectName);
			CustomSE.CustomSEs.Add(val);
			return val;
		}

		public static StatusEffect RegisterCustomSE(StatusEffect customSE, string customEffectName)
		{
			((Object)customSE).name = customEffectName;
			CustomSE.CustomSEs.Add(customSE);
			return customSE;
		}

		[HarmonyPriority(700)]
		private static void Patch_ObjectDBInit(ObjectDB __instance)
		{
			foreach (StatusEffect customSE in CustomSE.CustomSEs)
			{
				if (!__instance.m_StatusEffects.Contains(customSE))
				{
					__instance.m_StatusEffects.Add(customSE);
				}
			}
			__instance.UpdateItemHashes();
		}

		[HarmonyPriority(700)]
		private static void Patch_ZNetSceneAwake(ZNetScene __instance)
		{
			foreach (KeyValuePair<SE_Item, string> addToPrefab in CustomSE.AddToPrefabs)
			{
				try
				{
					GameObject prefab = __instance.GetPrefab(addToPrefab.Value);
					ItemDrop val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<ItemDrop>() : prefab.GetComponentInChildren<ItemDrop>());
					Aoe val2 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<Aoe>() : prefab.GetComponentInChildren<Aoe>());
					EffectArea val3 = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<EffectArea>() : prefab.GetComponentInChildren<EffectArea>());
					if (Object.op_Implicit((Object)(object)val))
					{
						switch (addToPrefab.Key.Type)
						{
						case EffectType.Equip:
							val.m_itemData.m_shared.m_equipStatusEffect = addToPrefab.Key.Effect;
							break;
						case EffectType.Attack:
							val.m_itemData.m_shared.m_attackStatusEffect = addToPrefab.Key.Effect;
							break;
						case EffectType.Consume:
							val.m_itemData.m_shared.m_consumeStatusEffect = addToPrefab.Key.Effect;
							break;
						case EffectType.Set:
							val.m_itemData.m_shared.m_setSize = 1;
							val.m_itemData.m_shared.m_setName = ((Object)addToPrefab.Key.Effect).name;
							val.m_itemData.m_shared.m_setStatusEffect = addToPrefab.Key.Effect;
							break;
						default:
							throw new ArgumentOutOfRangeException();
						}
					}
					else if (Object.op_Implicit((Object)(object)val2))
					{
						val2.m_statusEffect = ((Object)addToPrefab.Key.Effect).name;
					}
					else if (Object.op_Implicit((Object)(object)val3))
					{
						val3.m_statusEffect = ((Object)addToPrefab.Key.Effect).name;
					}
					else
					{
						Debug.LogWarning((object)("The prefab '" + ((Object)prefab).name + "' does not have an ItemDrop, AOE, or EffectArea component. Cannot add the StatusEffect to the prefab."));
					}
				}
				catch (Exception arg)
				{
					Debug.LogWarning((object)$"BROKE : {arg}");
				}
			}
		}
	}
}
namespace RustyCompass
{
	[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
	[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
	[BepInPlugin("RustyMods.RustyCompass", "RustyCompass", "1.1.5")]
	public class RustyCompassPlugin : BaseUnityPlugin
	{
		[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(0)]
		public enum Toggle
		{
			On = 1,
			Off = 0
		}

		[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(0)]
		public enum Compass
		{
			Compass1,
			Compass2,
			Compass3,
			Compass4
		}

		[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(0)]
		public enum CompassType
		{
			Circle,
			Bar
		}

		[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(0)]
		private class ConfigurationManagerAttributes
		{
			[UsedImplicitly]
			public int? Order = null;

			[UsedImplicitly]
			public bool? Browsable = null;

			[UsedImplicitly]
			[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
			public string Category = null;

			[UsedImplicitly]
			[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(new byte[] { 2, 1 })]
			public Action<ConfigEntryBase> CustomDrawer = null;
		}

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
		private class AcceptableShortcuts : AcceptableValueBase
		{
			public AcceptableShortcuts()
				: base(typeof(KeyboardShortcut))
			{
			}

			public override object Clamp(object value)
			{
				return value;
			}

			public override bool IsValid(object value)
			{
				return true;
			}

			public override string ToDescriptionString()
			{
				return "# Acceptable values: " + string.Join(", ", UnityInput.Current.SupportedKeyCodes);
			}
		}

		internal const string ModName = "RustyCompass";

		internal const string ModVersion = "1.1.5";

		internal const string Author = "RustyMods";

		private const string ModGUID = "RustyMods.RustyCompass";

		private static string ConfigFileName = "RustyMods.RustyCompass.cfg";

		private static string ConfigFileFullPath;

		internal static string ConnectionError;

		private readonly Harmony _harmony = new Harmony("RustyMods.RustyCompass");

		public static readonly ManualLogSource RustyCompassLogger;

		private static readonly ConfigSync ConfigSync;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public static readonly Sprite CompassSprite;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public static readonly Sprite CompassArrow;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public static readonly Sprite CompassSimple;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public static readonly Sprite CompassBW;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public static readonly Sprite CompassViking;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public static readonly Sprite NorthIcon;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public static readonly Sprite SouthIcon;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public static readonly Sprite EastIcon;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public static readonly Sprite WestIcon;

		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public static readonly Sprite RuneIcon;

		private static ConfigEntry<Toggle> _serverConfigLocked;

		public static ConfigEntry<Toggle> _isModActive;

		public static ConfigEntry<CompassType> _CompassType;

		public static ConfigEntry<Toggle> _useCompassTokens;

		public static ConfigEntry<float> _CompassPinsMaxDistance;

		public static ConfigEntry<Toggle> _CompassPinsEnabled;

		public static ConfigEntry<Color> _BiomesColor;

		public static ConfigEntry<Color> _CompassColor;

		public static ConfigEntry<Compass> _CompassSprite;

		public static ConfigEntry<Vector2> _CompassPosition;

		public static ConfigEntry<float> _CompassSize;

		public static ConfigEntry<Color> _HandColor;

		public static ConfigEntry<Color> _WindMarkerColor;

		public static ConfigEntry<Color> _CirclePinsColor;

		public static ConfigEntry<float> _CirclePinsMaxSize;

		public static ConfigEntry<float> _CircleDirectionIcons;

		public static ConfigEntry<Color> _CircleDirectionColor;

		public static ConfigEntry<Toggle> _SwapEastWest;

		public static ConfigEntry<Color> _CompassBarColor;

		public static ConfigEntry<Vector2> _CompassBarIconSize;

		public static ConfigEntry<float> _CompassBarIconSpacing;

		public static ConfigEntry<float> _CompassBarPosition;

		public static ConfigEntry<Color> _CompassPinsColor;

		public static ConfigEntry<float> _CompassPinsMaxSize;

		public static ConfigEntry<Toggle> _SwapEastWestBar;

		public static ConfigEntry<Toggle> _TameTrackEnabled;

		public void Awake()
		{
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0646: Unknown result type (might be due to invalid IL or missing references)
			//IL_0664: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0762: Unknown result type (might be due to invalid IL or missing references)
			//IL_0780: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_080e: Unknown result type (might be due to invalid IL or missing references)
			Localizer.Load();
			_serverConfigLocked = config("1 - General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only.");
			ConfigSync.AddLockingConfigEntry<Toggle>(_serverConfigLocked);
			_isModActive = config("1 - General Settings", "_Enabled", Toggle.On, "If on, mod is active", synchronizedSetting: false);
			_CompassType = config("1 - General Settings", "Compass Type", CompassType.Bar, "Compass bar or circle", synchronizedSetting: false);
			_useCompassTokens = config("1 - General Settings", "Use Compass Tokens", Toggle.Off, "If on, compass features are enabled using quest items");
			_CompassPinsEnabled = config("1 - General Settings", "Pins Enabled", Toggle.On, "If on, pins are added to the compass bar");
			_CompassPinsMaxDistance = config("1 - General Settings", "Bar Pins Max Distance", 100f, "Max distance pins appear on bar", synchronizedSetting: false);
			Vector2 value = default(Vector2);
			((Vector2)(ref value))..ctor(820f, 400f);
			_CompassPosition = config<Vector2>("2 - Circle Compass Settings", "Compass Position", value, "Alignment of compass", synchronizedSetting: false);
			_CompassSize = config("2 - Circle Compass Settings", "Compass Size", 200f, "Size of compass", synchronizedSetting: false);
			_CompassColor = config<Color>("2 - Circle Compass Settings", "Compass Color", Color.black, "Color of the compass", synchronizedSetting: false);
			_HandColor = config<Color>("2 - Circle Compass Settings", "Hand Color", Color.yellow, "Color of the hand on compass", synchronizedSetting: false);
			_WindMarkerColor = config<Color>("2 - Circle Compass Settings", "Wind Marker Color", Color.white, "Wind Marker Color", synchronizedSetting: false);
			_BiomesColor = config<Color>("2 - Circle Compass Settings", "Biomes Name Color", Color.white, "Biomes Text Color", synchronizedSetting: false);
			_CompassSprite = config("2 - Circle Compass Settings", "Compass Image", Compass.Compass1, "Compass sprite options", synchronizedSetting: false);
			_CirclePinsColor = config<Color>("2 - Circle Compass Settings", "Pin Color", Color.white, "Set the colors of the pins", synchronizedSetting: false);
			_CirclePinsMaxSize = config("2 - Circle Compass Settings", "Pin Max Size", 30f, "Pin size for the circle compass", synchronizedSetting: false);
			_CircleDirectionIcons = config("2 - Circle Compass Settings", "NESW Icon Placement", 120f, "Placement of the icons based on center of compass", synchronizedSetting: false);
			_CircleDirectionColor = config<Color>("2 - Circle Compass Settings", "NWSW Color", Color.white, "Color of compass directions", synchronizedSetting: false);
			_SwapEastWest = config("2 - Circle Compass Settings", "Swap East West", Toggle.Off, "If on, swaps the position of east and west icons", synchronizedSetting: false);
			_CompassBarColor = config<Color>("3 - Bar Compass Settings", "Compass Bar Color", Color.white, "Compass Bar Color", synchronizedSetting: false);
			Vector2 value2 = default(Vector2);
			((Vector2)(ref value2))..ctor(50f, 50f);
			_CompassBarIconSize = config<Vector2>("3 - Bar Compass Settings", "Compass Icon Size", value2, "Icon Size", synchronizedSetting: false);
			_CompassBarIconSpacing = config("3 - Bar Compass Settings", "Compass Bar Icon Spacing", 25f, "Spacing between icons", synchronizedSetting: false);
			_CompassBarPosition = config("3 - Bar Compass Settings", "Compass Bar Position", 200f, "Compass Bar Vertical Position", synchronizedSetting: false);
			_CompassPinsColor = config<Color>("3 - Bar Compass Settings", "Compass Pins Color", Color.white, "Color of the pins on the bar", synchronizedSetting: false);
			_CompassPinsMaxSize = config("3 - Bar Compass Settings", "Pins Max Size", 50f, "Size of compass bar pins", synchronizedSetting: false);
			_SwapEastWestBar = config("3 - Bar Compass Settings", "Swap East West", Toggle.Off, "If on, swaps east and west icons", synchronizedSetting: false);
			_TameTrackEnabled = config("4 - Tame Tracker Settings", "Tame Tracker", Toggle.Off, "If on, tames are automatically pinned on compass bar and minimap", synchronizedSetting: false);
			Item item = new Item("compassbundle", "RS_Compass_Token_Gold");
			item.Name.English("Lost Compass Token");
			item.Description.English("Awakens the third eye, giving access to a compass bar");
			item.Crafting.Add(CraftingTable.Forge, 2);
			item.RequiredItems.Add("Bronze", 5);
			item.RequiredItems.Add("Resin", 20);
			item.RequiredItems.Add("Flint", 5);
			item.RequiredItems.Add("CryptKey", 1);
			item.CraftAmount = 1;
			item.Configurable = Configurability.Recipe;
			Item item2 = new Item("compassbundle", "RS_Compass_Token_Brass");
			item2.Name.English("Rusty Compass Token");
			item2.Description.English("Enables the use of a circular compass");
			item2.Crafting.Add(CraftingTable.Workbench, 2);
			item2.RequiredItems.Add("Copper", 5);
			item2.RequiredItems.Add("Resin", 10);
			item2.RequiredItems.Add("Flint", 5);
			item2.RequiredItems.Add("HardAntler", 1);
			item2.CraftAmount = 1;
			item2.Configurable = Configurability.Recipe;
			Item item3 = new Item("compassbundle", "RS_Compass_Token_Silver");
			item3.Name.English("Silver Compass Token");
			item3.Description.English("Enables the use of a circular compass and a deeper understanding of their location as well as wind direction");
			item3.Crafting.Add(CraftingTable.ArtisanTable, 1);
			item3.RequiredItems.Add("Silver", 5);
			item3.RequiredItems.Add("Resin", 20);
			item3.RequiredItems.Add("Obsidian", 5);
			item3.RequiredItems.Add("Crystal", 10);
			item3.CraftAmount = 1;
			item3.Configurable = Configurability.Recipe;
			Item item4 = new Item("compassbundle", "RS_Compass_Token_DarkGold");
			item4.Name.English("Forgotten Compass Token");
			item4.Description.English("Grants full usage of the compass bar with senses of their surroundings");
			item4.Crafting.Add(CraftingTable.ArtisanTable, 1);
			item4.RequiredItems.Add("BlackMetal", 5);
			item4.RequiredItems.Add("Resin", 20);
			item4.RequiredItems.Add("DragonTear", 1);
			item4.RequiredItems.Add("Coins", 100);
			item4.CraftAmount = 1;
			item4.Configurable = Configurability.Recipe;
			CustomSE customSE = new CustomSE("se_compass_gold");
			customSE.Name.English("Lost Compass");
			customSE.Type = EffectType.Equip;
			customSE.IconSprite = EastIcon;
			customSE.Effect.m_startMessage = "Lost Compass is active";
			customSE.Effect.m_startMessageType = (MessageType)2;
			customSE.Effect.m_stopMessage = "";
			customSE.Effect.m_stopMessageType = (MessageType)1;
			customSE.Effect.m_tooltip = "Your sense of direction is elevated";
			customSE.AddSEToPrefab(customSE, "RS_Compass_Token_Gold");
			CustomSE customSE2 = new CustomSE("se_compass_brass");
			customSE2.Name.English("Rusty Compass");
			customSE2.Type = EffectType.Equip;
			customSE2.IconSprite = WestIcon;
			customSE2.Effect.m_startMessage = "Rusty Compass is active";
			customSE2.Effect.m_startMessageType = (MessageType)2;
			customSE2.Effect.m_stopMessage = "";
			customSE2.Effect.m_stopMessageType = (MessageType)1;
			customSE2.Effect.m_tooltip = "Your sense of direction is elevated";
			customSE2.AddSEToPrefab(customSE2, "RS_Compass_Token_Brass");
			CustomSE customSE3 = new CustomSE("se_compass_silver");
			customSE3.Name.English("Silver Compass");
			customSE3.Type = EffectType.Equip;
			customSE3.IconSprite = SouthIcon;
			customSE3.Effect.m_startMessage = "Silver Compass is active";
			customSE3.Effect.m_startMessageType = (MessageType)2;
			customSE3.Effect.m_stopMessage = "";
			customSE3.Effect.m_stopMessageType = (MessageType)1;
			customSE3.Effect.m_tooltip = "Your sense of direction is elevated";
			customSE3.AddSEToPrefab(customSE3, "RS_Compass_Token_Silver");
			CustomSE customSE4 = new CustomSE("se_compass_darkgold");
			customSE4.Name.English("Forgotten Compass");
			customSE4.Type = EffectType.Equip;
			customSE4.IconSprite = SouthIcon;
			customSE4.Effect.m_startMessage = "Forgotten Compass is active";
			customSE4.Effect.m_startMessageType = (MessageType)2;
			customSE4.Effect.m_stopMessage = "";
			customSE4.Effect.m_stopMessageType = (MessageType)1;
			customSE4.Effect.m_tooltip = "Your sense of direction is elevated";
			customSE4.AddSEToPrefab(customSE4, "RS_Compass_Token_DarkGold");
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			_harmony.PatchAll(executingAssembly);
			SetupWatcher();
		}

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

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

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

		private ConfigEntry<T> config<[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
			SyncedConfigEntry<T> syncedConfigEntry = ConfigSync.AddConfigEntry<T>(val2);
			syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
			return val2;
		}

		private ConfigEntry<T> config<[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		static RustyCompassPlugin()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
			ConnectionError = "";
			RustyCompassLogger = Logger.CreateLogSource("RustyCompass");
			ConfigSync = new ConfigSync("RustyMods.RustyCompass")
			{
				DisplayName = "RustyCompass"
			};
			CompassSprite = SpriteManager.RegisterSprite("rustyCompassIcon.png");
			CompassArrow = SpriteManager.RegisterSprite("compassArrowIcon.png");
			CompassSimple = SpriteManager.RegisterSprite("rustyCompassSimple.png");
			CompassBW = SpriteManager.RegisterSprite("rustyCompassBW.png");
			CompassViking = SpriteManager.RegisterSprite("rustyCompassViking.png");
			NorthIcon = SpriteManager.RegisterSprite("compassNorth.png");
			SouthIcon = SpriteManager.RegisterSprite("compassSouth.png");
			EastIcon = SpriteManager.RegisterSprite("compassEast.png");
			WestIcon = SpriteManager.RegisterSprite("compassWest.png");
			RuneIcon = SpriteManager.RegisterSprite("compassRune.png");
			_serverConfigLocked = null;
			_isModActive = null;
			_CompassType = null;
			_useCompassTokens = null;
			_CompassPinsMaxDistance = null;
			_CompassPinsEnabled = null;
			_BiomesColor = null;
			_CompassColor = null;
			_CompassSprite = null;
			_CompassPosition = null;
			_CompassSize = null;
			_HandColor = null;
			_WindMarkerColor = null;
			_CirclePinsColor = null;
			_CirclePinsMaxSize = null;
			_CircleDirectionIcons = null;
			_CircleDirectionColor = null;
			_SwapEastWest = null;
			_CompassBarColor = null;
			_CompassBarIconSize = null;
			_CompassBarIconSpacing = null;
			_CompassBarPosition = null;
			_CompassPinsColor = null;
			_CompassPinsMaxSize = null;
			_SwapEastWestBar = null;
			_TameTrackEnabled = null;
		}
	}
	[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
	public static class RegisterAndCheckVersion
	{
		[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			RustyCompassPlugin.RustyCompassLogger.LogDebug((object)"Registering version RPC handler");
			peer.m_rpc.Register<ZPackage>("RustyCompass_VersionCheck", (Action<ZRpc, ZPackage>)RpcHandlers.RPC_RustyCompass_Version);
			RustyCompassPlugin.RustyCompassLogger.LogInfo((object)"Invoking version check");
			ZPackage val = new ZPackage();
			val.Write("1.1.5");
			val.Write(RpcHandlers.ComputeHashForMod().Replace("-", ""));
			peer.m_rpc.Invoke("RustyCompass_VersionCheck", new object[1] { val });
		}
	}
	[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
	[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
	[HarmonyPatch(typeof(ZNet), "RPC_PeerInfo")]
	public static class VerifyClient
	{
		private static bool Prefix(ZRpc rpc, ZPackage pkg, ref ZNet __instance)
		{
			if (!__instance.IsServer() || RpcHandlers.ValidatedPeers.Contains(rpc))
			{
				return true;
			}
			RustyCompassPlugin.RustyCompassLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") never sent version or couldn't due to previous disconnect, disconnecting"));
			rpc.Invoke("Error", new object[1] { 3 });
			return false;
		}

		private static void Postfix(ZNet __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.instance.GetServerPeerID(), "RustyCompassRequestAdminSync", new object[1] { (object)new ZPackage() });
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "ShowConnectError")]
	public class ShowConnectionError
	{
		[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
		private static void Postfix(FejdStartup __instance)
		{
			if (__instance.m_connectionFailedPanel.activeSelf)
			{
				__instance.m_connectionFailedError.fontSizeMax = 25f;
				__instance.m_connectionFailedError.fontSizeMin = 15f;
				TMP_Text connectionFailedError = __instance.m_connectionFailedError;
				connectionFailedError.text = connectionFailedError.text + "\n" + RustyCompassPlugin.ConnectionError;
			}
		}
	}
	[HarmonyPatch(typeof(ZNet), "Disconnect")]
	public static class RemoveDisconnectedPeerFromVerified
	{
		[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
		private static void Prefix(ZNetPeer peer, ref ZNet __instance)
		{
			if (__instance.IsServer())
			{
				RustyCompassPlugin.RustyCompassLogger.LogInfo((object)("Peer (" + peer.m_rpc.m_socket.GetHostName() + ") disconnected, removing from validated list"));
				RpcHandlers.ValidatedPeers.Remove(peer.m_rpc);
			}
		}
	}
	[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
	[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
	public static class RpcHandlers
	{
		public static readonly List<ZRpc> ValidatedPeers = new List<ZRpc>();

		public static void RPC_RustyCompass_Version(ZRpc rpc, ZPackage pkg)
		{
			string text = pkg.ReadString();
			string text2 = pkg.ReadString();
			string text3 = ComputeHashForMod().Replace("-", "");
			RustyCompassPlugin.RustyCompassLogger.LogInfo((object)("Version check, local: 1.1.5,  remote: " + text));
			if (text2 != text3 || text != "1.1.5")
			{
				RustyCompassPlugin.ConnectionError = "RustyCompass Installed: 1.1.5 " + text3 + "\n Needed: " + text + " " + text2;
				if (ZNet.instance.IsServer())
				{
					RustyCompassPlugin.RustyCompassLogger.LogWarning((object)("Peer (" + rpc.m_socket.GetHostName() + ") has incompatible version, disconnecting..."));
					rpc.Invoke("Error", new object[1] { 3 });
				}
			}
			else if (!ZNet.instance.IsServer())
			{
				RustyCompassPlugin.RustyCompassLogger.LogInfo((object)"Received same version from server!");
			}
			else
			{
				RustyCompassPlugin.RustyCompassLogger.LogInfo((object)("Adding peer (" + rpc.m_socket.GetHostName() + ") to validated list"));
				ValidatedPeers.Add(rpc);
			}
		}

		public static string ComputeHashForMod()
		{
			using SHA256 sHA = SHA256.Create();
			byte[] array = sHA.ComputeHash(File.ReadAllBytes(Assembly.GetExecutingAssembly().Location));
			StringBuilder stringBuilder = new StringBuilder();
			byte[] array2 = array;
			foreach (byte b in array2)
			{
				stringBuilder.Append(b.ToString("X2"));
			}
			return stringBuilder.ToString();
		}
	}
}
namespace RustyCompass.Utilities
{
	public static class SpriteManager
	{
		[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
		[return: <a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(2)]
		public static Sprite RegisterSprite(string fileName, string folderName = "icons")
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = "RustyCompass." + folderName + "." + fileName;
			using (Stream stream = executingAssembly.GetManifestResourceStream(name))
			{
				if (stream != null)
				{
					byte[] array = new byte[stream.Length];
					stream.Read(array, 0, array.Length);
					Texture2D val = new Texture2D(2, 2);
					if (ImageConversion.LoadImage(val, array))
					{
						Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), Vector2.zero);
						((Object)val2).name = fileName.Replace(".png", "");
						return val2;
					}
				}
			}
			return null;
		}
	}
}
namespace RustyCompass.Patches
{
	[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
	[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
	public static class HUDPatches
	{
		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
		[HarmonyPatch(typeof(Hud), "Awake")]
		public static class HudPatch
		{
			public static TMP_FontAsset font = null;

			private static GameObject root = null;

			public static int compassIconCount;

			public static readonly Sprite fireIcon = Minimap.instance.m_icons[0].m_icon;

			public static readonly Sprite spawnIcon = Minimap.instance.m_locationIcons[0].m_icon;

			public static readonly Sprite merchantIcon = Minimap.instance.m_locationIcons[1].m_icon;

			public static readonly Sprite clothIcon = Minimap.instance.m_locationIcons[2].m_icon;

			public static readonly Sprite houseIcon = Minimap.instance.m_icons[1].m_icon;

			public static readonly Sprite anchorIcon = Minimap.instance.m_icons[2].m_icon;

			public static readonly Sprite circleIcon = Minimap.instance.m_icons[3].m_icon;

			public static readonly Sprite portalIcon = Minimap.instance.m_icons[4].m_icon;

			public static readonly Sprite deathIcon = Minimap.instance.m_icons[5].m_icon;

			public static readonly Sprite bedIcon = Minimap.instance.m_icons[6].m_icon;

			public static readonly Sprite yellowTargetIcon = Minimap.instance.m_icons[7].m_icon;

			public static readonly Sprite bossIcon = Minimap.instance.m_icons[8].m_icon;

			public static readonly Sprite vikingIcon = Minimap.instance.m_icons[9].m_icon;

			public static readonly Sprite exclamationIcon = Minimap.instance.m_icons[10].m_icon;

			public static readonly Sprite blueTargetIcon = Minimap.instance.m_icons[12].m_icon;

			public static readonly Sprite questionMarkIcon = Minimap.instance.m_icons[13].m_icon;

			private static void Postfix(Hud __instance)
			{
				root = __instance.m_rootObject;
				Transform val = root.transform.Find("staminapanel");
				Transform val2 = val.Find("Stamina");
				Transform val3 = val2.Find("StaminaText");
				TextMeshProUGUI val4 = default(TextMeshProUGUI);
				((Component)val3).TryGetComponent<TextMeshProUGUI>(ref val4);
				if (Object.op_Implicit((Object)(object)val4))
				{
					font = ((TMP_Text)val4).font;
				}
				CreateCompassCircle();
				CreateCompassBar();
			}

			private static void CreateCompassBar()
			{
				//IL_0235: Unknown result type (might be due to invalid IL or missing references)
				//IL_023c: Expected O, but got Unknown
				//IL_0263: Unknown result type (might be due to invalid IL or missing references)
				//IL_0273: Unknown result type (might be due to invalid IL or missing references)
				//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)(object)RustyCompassPlugin.RuneIcon == (Object)null) && !((Object)(object)RustyCompassPlugin.SouthIcon == (Object)null) && !((Object)(object)RustyCompassPlugin.EastIcon == (Object)null) && !((Object)(object)RustyCompassPlugin.NorthIcon == (Object)null) && !((Object)(object)RustyCompassPlugin.WestIcon == (Object)null))
				{
					List<Sprite> list = new List<Sprite>
					{
						RustyCompassPlugin.SouthIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.EastIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.NorthIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.WestIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon
					};
					List<Sprite> list2 = new List<Sprite>
					{
						RustyCompassPlugin.SouthIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.WestIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.NorthIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.EastIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon,
						RustyCompassPlugin.RuneIcon
					};
					compassIconCount = list.Count;
					float value = RustyCompassPlugin._CompassBarPosition.Value;
					float value2 = RustyCompassPlugin._CompassBarIconSpacing.Value;
					float num = (float)list.Count * value2;
					float num2 = (0f - num) / 2f;
					for (int i = 0; i < list.Count; i++)
					{
						float num3 = num2 + (float)i * value2;
						GameObject val = new GameObject($"barIcon ({i})");
						RectTransform val2 = val.AddComponent<RectTransform>();
						((Transform)val2).SetParent(root.transform);
						val2.sizeDelta = new Vector2(50f, 50f);
						val2.anchoredPosition = new Vector2(num3, value);
						Image val3 = val.AddComponent<Image>();
						val3.sprite = ((RustyCompassPlugin._SwapEastWestBar.Value == RustyCompassPlugin.Toggle.On) ? list2[i] : list[i]);
						((Graphic)val3).color = Color.white;
					}
				}
			}

			private static void CreateCompassCircle()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Expected O, but got Unknown
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0056: Expected O, but got Unknown
				//IL_0075: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Expected O, but got Unknown
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: 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_014b: Expected O, but got Unknown
				//IL_016e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0185: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bf: Expected O, but got Unknown
				//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_021c: Unknown result type (might be due to invalid IL or missing references)
				//IL_022c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0233: Expected O, but got Unknown
				//IL_0256: Unknown result type (might be due to invalid IL or missing references)
				//IL_026d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0290: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a7: Expected O, but got Unknown
				//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0304: Unknown result type (might be due to invalid IL or missing references)
				//IL_0314: Unknown result type (might be due to invalid IL or missing references)
				//IL_031b: Expected O, but got Unknown
				//IL_033e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0355: Unknown result type (might be due to invalid IL or missing references)
				//IL_036b: Unknown result type (might be due to invalid IL or missing references)
				//IL_03df: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e6: Expected O, but got Unknown
				//IL_0409: Unknown result type (might be due to invalid IL or missing references)
				//IL_0420: Unknown result type (might be due to invalid IL or missing references)
				//IL_044a: Unknown result type (might be due to invalid IL or missing references)
				GameObject val = new GameObject("CompassContainer");
				RectTransform val2 = val.AddComponent<RectTransform>();
				((Transform)val2).SetParent(root.transform);
				val2.anchoredPosition = RustyCompassPlugin._CompassPosition.Value;
				val2.sizeDelta = new Vector2(200f, 200f);
				GameObject val3 = new GameObject("background");
				RectTransform val4 = val3.AddComponent<RectTransform>();
				((Transform)val4).SetParent(val.transform);
				val4.anchoredPosition = new Vector2(0f, 0f);
				val4.sizeDelta = new Vector2(RustyCompassPlugin._CompassSize.Value, RustyCompassPlugin._CompassSize.Value);
				Image val5 = val3.AddComponent<Image>();
				val5.sprite = RustyCompassPlugin.CompassBW;
				((Graphic)val5).color = Color.white;
				((MaskableGraphic)val5).maskable = true;
				GameObject val6 = new GameObject("north");
				RectTransform val7 = val6.AddComponent<RectTransform>();
				((Transform)val7).SetParent(val3.transform);
				val7.anchoredPosition = new Vector2(0f, 0f);
				val7.sizeDelta = new Vector2(50f, 50f);
				Image val8 = val6.AddComponent<Image>();
				val8.sprite = RustyCompassPlugin.NorthIcon;
				((Graphic)val8).color = Color.white;
				GameObject val9 = new GameObject("east");
				RectTransform val10 = val9.AddComponent<RectTransform>();
				((Transform)val10).SetParent(val3.transform);
				val10.anchoredPosition = new Vector2(0f, 0f);
				val10.sizeDelta = new Vector2(50f, 50f);
				Image val11 = val9.AddComponent<Image>();
				val11.sprite = RustyCompassPlugin.EastIcon;
				((Graphic)val11).color = Color.white;
				GameObject val12 = new GameObject("south");
				RectTransform val13 = val12.AddComponent<RectTransform>();
				((Transform)val13).SetParent(val3.transform);
				val13.anchoredPosition = new Vector2(0f, 0f);
				val13.sizeDelta = new Vector2(50f, 50f);
				Image val14 = val12.AddComponent<Image>();
				val14.sprite = RustyCompassPlugin.SouthIcon;
				((Graphic)val14).color = Color.white;
				GameObject val15 = new GameObject("west");
				RectTransform val16 = val15.AddComponent<RectTransform>();
				((Transform)val16).SetParent(val3.transform);
				val16.anchoredPosition = new Vector2(0f, 0f);
				val16.sizeDelta = new Vector2(50f, 50f);
				Image val17 = val15.AddComponent<Image>();
				val17.sprite = RustyCompassPlugin.WestIcon;
				((Graphic)val17).color = Color.white;
				GameObject val18 = new GameObject("hand");
				RectTransform val19 = val18.AddComponent<RectTransform>();
				((Transform)val19).SetParent(val.transform);
				val19.anchoredPosition = new Vector2(0f, 0f);
				val19.sizeDelta = new Vector2(100f, 100f);
				Image val20 = val18.AddComponent<Image>();
				val20.sprite = RustyCompassPlugin.CompassArrow;
				((Graphic)val20).color = Color.white;
				GameObject val21 = new GameObject("biomes");
				RectTransform val22 = val21.AddComponent<RectTransform>();
				((Transform)val22).SetParent(val.transform);
				val22.anchoredPosition = new Vector2(0f, 100f);
				val22.sizeDelta = new Vector2(250f, 25f);
				TextMeshProUGUI val23 = val21.AddComponent<TextMeshProUGUI>();
				((Graphic)val23).color = Color.white;
				((TMP_Text)val23).font = font;
				((TMP_Text)val23).text = "";
				((TMP_Text)val23).fontSize = 20f;
				((TMP_Text)val23).fontSizeMax = 20f;
				((TMP_Text)val23).fontSizeMin = 2f;
				((TMP_Text)val23).enableAutoSizing = true;
				RectTransform windMarker = Minimap.m_instance.m_windMarker;
				Image component = ((Component)windMarker).gameObject.GetComponent<Image>();
				GameObject val24 = new GameObject("windMarker");
				RectTransform val25 = val24.AddComponent<RectTransform>();
				((Transform)val25).SetParent(val.transform);
				val25.anchoredPosition = new Vector2(-100f, -100f);
				val25.sizeDelta = new Vector2(32f, 32f);
				Image val26 = val24.AddComponent<Image>();
				val26.sprite = component.sprite;
				((Graphic)val26).color = RustyCompassPlugin._WindMarkerColor.Value;
			}
		}

		[HarmonyPatch(typeof(Hud), "Update")]
		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
		public static class HudUpdatePatch
		{
			[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
			private class PinData
			{
				public string m_name = null;

				public Sprite m_icon = null;

				public GameObject m_uiElement = null;

				public PinType m_type;

				public Vector3 m_pos;
			}

			private static GameObject root = null;

			private static Quaternion playerRotation;

			private static Vector3 playerPosition;

			private static readonly List<PinData> BarPins = new List<PinData>();

			private static readonly List<PinData> CirclePins = new List<PinData>();

			private static bool compassCircle;

			private static bool biomesName;

			private static bool windIcon;

			private static bool compassBarActive;

			private static bool barPinActive;

			private static bool circlePinActive;

			private static void Postfix(Hud __instance)
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				root = __instance.m_rootObject;
				playerRotation = ((Component)Utils.GetMainCamera()).transform.rotation;
				playerPosition = ((Component)Utils.GetMainCamera()).transform.position;
				UpdateCompassCircle();
				UpdateCompassBar();
				UpdatePins();
				if (RustyCompassPlugin._useCompassTokens.Value == RustyCompassPlugin.Toggle.On)
				{
					CheckPlayerInventory();
				}
			}

			private static void CheckPlayerInventory()
			{
				if ((Object)(object)Player.m_localPlayer == (Object)null)
				{
					return;
				}
				List<ItemData> equippedItems = ((Humanoid)Player.m_localPlayer).GetInventory().GetEquippedItems();
				compassBarActive = false;
				compassCircle = false;
				barPinActive = false;
				biomesName = false;
				windIcon = false;
				circlePinActive = false;
				foreach (ItemData item in equippedItems)
				{
					bool flag;
					switch (item.m_shared.m_name)
					{
					case "$item_compass_token_brass":
					case "$item_compass_token_gold":
					case "$item_compass_token_silver":
					case "$item_compass_token_darkgold":
						flag = true;
						break;
					default:
						flag = false;
						break;
					}
					if (!flag)
					{
						continue;
					}
					SetCompassActive(item.m_shared.m_name);
					break;
				}
			}

			private static void SetCompassActive(string itemName)
			{
				switch (itemName)
				{
				case "$item_compass_token_brass":
					compassCircle = true;
					break;
				case "$item_compass_token_gold":
					compassBarActive = true;
					break;
				case "$item_compass_token_silver":
					compassCircle = true;
					biomesName = true;
					windIcon = true;
					circlePinActive = true;
					break;
				case "$item_compass_token_darkgold":
					compassBarActive = true;
					barPinActive = true;
					break;
				}
			}

			private static void UpdateCompassBar()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				float y = ((Quaternion)(ref playerRotation)).eulerAngles.y;
				float num = (float)HudPatch.compassIconCount * RustyCompassPlugin._CompassBarIconSpacing.Value;
				float num2 = 360f;
				float value = RustyCompassPlugin._CompassBarPosition.Value;
				RectTransform val2 = default(RectTransform);
				Image val3 = default(Image);
				for (int i = 0; i < HudPatch.compassIconCount; i++)
				{
					Transform val = root.transform.Find($"barIcon ({i})");
					((Component)val).TryGetComponent<RectTransform>(ref val2);
					((Component)val).TryGetComponent<Image>(ref val3);
					if (!Object.op_Implicit((Object)(object)val2) || !Object.op_Implicit((Object)(object)val3))
					{
						break;
					}
					float num3 = (y + (float)i * (num2 / (float)HudPatch.compassIconCount)) % num2;
					float num4 = num3 / num2 * num - num / 2f;
					val2.sizeDelta = RustyCompassPlugin._CompassBarIconSize.Value;
					val2.anchoredPosition = new Vector2(num4, value);
					((Graphic)val3).color = RustyCompassPlugin._CompassBarColor.Value;
					((Component)val).gameObject.SetActive(RustyCompassPlugin._isModActive.Value == RustyCompassPlugin.Toggle.On && ((RustyCompassPlugin._useCompassTokens.Value == RustyCompassPlugin.Toggle.On && compassBarActive) || (RustyCompassPlugin._useCompassTokens.Value != RustyCompassPlugin.Toggle.On && RustyCompassPlugin._CompassType.Value == RustyCompassPlugin.CompassType.Bar)));
				}
			}

			private static void UpdatePins()
			{
				//IL_0190: Unknown result type (might be due to invalid IL or missing references)
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_0197: Unknown result type (might be due to invalid IL or missing references)
				//IL_0199: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_04de: Unknown result type (might be due to invalid IL or missing references)
				//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_031b: Unknown result type (might be due to invalid IL or missing references)
				//IL_034a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0367: Unknown result type (might be due to invalid IL or missing references)
				//IL_0617: Unknown result type (might be due to invalid IL or missing references)
				//IL_0629: Unknown result type (might be due to invalid IL or missing references)
				//IL_065b: Unknown result type (might be due to invalid IL or missing references)
				//IL_068a: Unknown result type (might be due to invalid IL or missing references)
				//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)Camera.main == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null)
				{
					return;
				}
				Transform val = root.transform.Find("CompassContainer");
				Transform val2 = root.transform.Find("barIcon (0)");
				List<PinData> latestPinData = GetLatestPinData();
				foreach (PinData barPin in BarPins)
				{
					Object.Destroy((Object)(object)barPin.m_uiElement);
				}
				foreach (PinData circlePin in CirclePins)
				{
					Object.Destroy((Object)(object)circlePin.m_uiElement);
				}
				BarPins.Clear();
				CirclePins.Clear();
				float value = RustyCompassPlugin._CompassPinsMaxDistance.Value;
				if (((Component)val).gameObject.activeInHierarchy)
				{
					if (RustyCompassPlugin._CompassPinsEnabled.Value == RustyCompassPlugin.Toggle.Off)
					{
						return;
					}
					foreach (PinData item in latestPinData)
					{
						GameObject uiElement = CreateCirclePin(item);
						item.m_uiElement = uiElement;
						CirclePins.Add(item);
					}
					RectTransform val5 = default(RectTransform);
					Image val6 = default(Image);
					TextMeshProUGUI val7 = default(TextMeshProUGUI);
					RectTransform val8 = default(RectTransform);
					foreach (PinData circlePin2 in CirclePins)
					{
						Vector3 pos = circlePin2.m_pos;
						Vector3 val3 = pos - playerPosition;
						float num = Vector3.Distance(playerPosition, pos);
						float value2 = RustyCompassPlugin._CirclePinsMaxSize.Value;
						string text = ((circlePin2.m_name == "") ? ((Object)circlePin2.m_icon).name : circlePin2.m_name);
						if (1 == 0)
						{
						}
						string text2 = text switch
						{
							"mapicon_trader" => "$rusty_compass_haldor", 
							"mapicon_start" => "$rusty_compass_spawn", 
							"mapicon_hildir" => "$rusty_compass_hildir", 
							_ => text, 
						};
						if (1 == 0)
						{
						}
						text = text2;
						string arg = Localization.instance.Localize(text);
						GameObject uiElement2 = circlePin2.m_uiElement;
						Transform val4 = uiElement2.transform.Find("text");
						uiElement2.TryGetComponent<RectTransform>(ref val5);
						uiElement2.TryGetComponent<Image>(ref val6);
						((Component)val4).TryGetComponent<TextMeshProUGUI>(ref val7);
						((Component)val4).TryGetComponent<RectTransform>(ref val8);
						if (!Object.op_Implicit((Object)(object)val5) || !Object.op_Implicit((Object)(object)val6) || !Object.op_Implicit((Object)(object)val7) || !Object.op_Implicit((Object)(object)val8))
						{
							return;
						}
						val5.anchoredPosition = new Vector2(val3.x, val3.z);
						((Graphic)val6).color = RustyCompassPlugin._CirclePinsColor.Value;
						((TMP_Text)val7).text = $"{arg} (<color=orange>{Mathf.Round(num)}</color>)";
						((Graphic)val7).color = RustyCompassPlugin._CirclePinsColor.Value;
						float num2 = value2 / num;
						float num3 = value2 * num2;
						num3 = Mathf.Clamp(num3, 5f, value2);
						val5.sizeDelta = new Vector2(num3, num3);
						val8.sizeDelta = new Vector2(100f * num2, 25f * num2);
						uiElement2.SetActive(num < value && RustyCompassPlugin._CompassPinsEnabled.Value == RustyCompassPlugin.Toggle.On && RustyCompassPlugin._isModActive.Value == RustyCompassPlugin.Toggle.On && ((RustyCompassPlugin._useCompassTokens.Value == RustyCompassPlugin.Toggle.On && circlePinActive) || (RustyCompassPlugin._useCompassTokens.Value != RustyCompassPlugin.Toggle.On && RustyCompassPlugin._CompassType.Value == RustyCompassPlugin.CompassType.Circle)));
					}
				}
				if (!((Component)val2).gameObject.activeInHierarchy || RustyCompassPlugin._CompassPinsEnabled.Value == RustyCompassPlugin.Toggle.Off)
				{
					return;
				}
				foreach (PinData item2 in latestPinData)
				{
					GameObject uiElement3 = CreateBarPin(item2);
					item2.m_uiElement = uiElement3;
					BarPins.Add(item2);
				}
				float num4 = (float)HudPatch.compassIconCount * RustyCompassPlugin._CompassBarIconSpacing.Value;
				float num5 = 360f;
				float value3 = RustyCompassPlugin._CompassBarPosition.Value;
				float value4 = RustyCompassPlugin._CompassPinsMaxSize.Value;
				RectTransform val11 = default(RectTransform);
				Image val12 = default(Image);
				TextMeshProUGUI val13 = default(TextMeshProUGUI);
				RectTransform val14 = default(RectTransform);
				foreach (PinData barPin2 in BarPins)
				{
					Vector3 pos2 = barPin2.m_pos;
					Vector3 val9 = pos2 - playerPosition;
					float num6 = Vector3.Distance(playerPosition, pos2);
					float num7 = Vector3.SignedAngle(playerRotation * Vector3.forward, val9, Vector3.up);
					float num8 = num7 % num5 / num5 * (0f - num4);
					string text3 = ((barPin2.m_name == "") ? ((Object)barPin2.m_icon).name : barPin2.m_name);
					if (1 == 0)
					{
					}
					string text2 = text3 switch
					{
						"mapicon_trader" => "$rusty_compass_haldor", 
						"mapicon_start" => "$rusty_compass_spawn", 
						"mapicon_hildir" => "$rusty_compass_hildir", 
						_ => text3, 
					};
					if (1 == 0)
					{
					}
					text3 = text2;
					string arg2 = Localization.instance.Localize(text3);
					GameObject uiElement4 = barPin2.m_uiElement;
					Transform val10 = uiElement4.transform.Find("text");
					uiElement4.TryGetComponent<RectTransform>(ref val11);
					uiElement4.TryGetComponent<Image>(ref val12);
					((Component)val10).TryGetComponent<TextMeshProUGUI>(ref val13);
					((Component)val10).TryGetComponent<RectTransform>(ref val14);
					if (!Object.op_Implicit((Object)(object)val11) || !Object.op_Implicit((Object)(object)val12) || !Object.op_Implicit((Object)(object)val13) || !Object.op_Implicit((Object)(object)val14))
					{
						break;
					}
					val11.anchoredPosition = new Vector2(num8, value3);
					((Graphic)val12).color = RustyCompassPlugin._CompassPinsColor.Value;
					((TMP_Text)val13).text = $"{arg2} (<color=orange>{Mathf.Round(num6)}</color>)";
					((Graphic)val13).color = RustyCompassPlugin._CompassPinsColor.Value;
					float num9 = value4 / num6;
					float num10 = value4 * num9;
					num10 = Mathf.Clamp(num10, 5f, value4);
					val11.sizeDelta = new Vector2(num10, num10);
					val14.sizeDelta = new Vector2(100f * num9, 25f * num9);
					uiElement4.SetActive(num6 < value && RustyCompassPlugin._CompassPinsEnabled.Value == RustyCompassPlugin.Toggle.On && RustyCompassPlugin._isModActive.Value == RustyCompassPlugin.Toggle.On && ((RustyCompassPlugin._useCompassTokens.Value == RustyCompassPlugin.Toggle.On && barPinActive) || (RustyCompassPlugin._useCompassTokens.Value != RustyCompassPlugin.Toggle.On && RustyCompassPlugin._CompassType.Value == RustyCompassPlugin.CompassType.Bar)));
				}
			}

			private static GameObject CreateBarPin(PinData pinData)
			{
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Expected O, but got Unknown
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Expected I4, but got Unknown
				//IL_022f: Unknown result type (might be due to invalid IL or missing references)
				//IL_023f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0246: Expected O, but got Unknown
				//IL_0269: Unknown result type (might be due to invalid IL or missing references)
				//IL_0280: Unknown result type (might be due to invalid IL or missing references)
				//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
				string text = ((pinData.m_name == "") ? ((Object)pinData.m_icon).name : pinData.m_name);
				Vector3 pos = pinData.m_pos;
				GameObject val = new GameObject($"BarPin ({pos.x}{pos.y}{pos.z})");
				RectTransform val2 = val.AddComponent<RectTransform>();
				((Transform)val2).SetParent(root.transform);
				val2.anchoredPosition = new Vector2(0f, 0f);
				val2.sizeDelta = new Vector2(50f, 50f);
				Image val3 = val.AddComponent<Image>();
				Image val4 = val3;
				PinType type = pinData.m_type;
				if (1 == 0)
				{
				}
				Sprite sprite = (Sprite)((int)type switch
				{
					9 => HudPatch.bossIcon, 
					10 => HudPatch.vikingIcon, 
					4 => HudPatch.deathIcon, 
					5 => HudPatch.bedIcon, 
					0 => HudPatch.fireIcon, 
					1 => HudPatch.houseIcon, 
					2 => HudPatch.anchorIcon, 
					3 => HudPatch.circleIcon, 
					6 => HudPatch.portalIcon, 
					14 => HudPatch.questionMarkIcon, 
					15 => HudPatch.questionMarkIcon, 
					16 => HudPatch.questionMarkIcon, 
					12 => HudPatch.blueTargetIcon, 
					7 => HudPatch.yellowTargetIcon, 
					13 => HudPatch.exclamationIcon, 
					11 => HudPatch.exclamationIcon, 
					_ => HudPatch.circleIcon, 
				});
				if (1 == 0)
				{
				}
				val4.sprite = sprite;
				Image val5 = val3;
				string name = ((Object)pinData.m_icon).name;
				if (1 == 0)
				{
				}
				sprite = (Sprite)(name switch
				{
					"mapicon_start" => HudPatch.spawnIcon, 
					"mapicon_trader" => HudPatch.merchantIcon, 
					"mapicon_hildir" => HudPatch.clothIcon, 
					_ => val3.sprite, 
				});
				if (1 == 0)
				{
				}
				val5.sprite = sprite;
				((Graphic)val3).color = Color.white;
				GameObject val6 = new GameObject("text");
				RectTransform val7 = val6.AddComponent<RectTransform>();
				((Transform)val7).SetParent(val.transform);
				val7.anchoredPosition = new Vector2(0f, -35f);
				val7.sizeDelta = new Vector2(100f, 25f);
				TextMeshProUGUI val8 = val6.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val8).font = HudPatch.font;
				((TMP_Text)val8).fontSize = 15f;
				((TMP_Text)val8).fontSizeMax = 15f;
				((TMP_Text)val8).fontSizeMin = 5f;
				((TMP_Text)val8).enableAutoSizing = true;
				((Graphic)val8).color = Color.white;
				((TMP_Text)val8).horizontalAlignment = (HorizontalAlignmentOptions)2;
				((TMP_Text)val8).verticalAlignment = (VerticalAlignmentOptions)512;
				((TMP_Text)val8).richText = true;
				((TMP_Text)val8).text = Localization.instance.Localize(text);
				val.SetActive(false);
				return val;
			}

			private static GameObject CreateCirclePin(PinData pinData)
			{
				//IL_0049: 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_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_007a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Expected O, but got Unknown
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: Expected I4, but got Unknown
				//IL_024e: Unknown result type (might be due to invalid IL or missing references)
				//IL_025e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0265: Expected O, but got Unknown
				//IL_0289: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
				Transform val = root.transform.Find("CompassContainer");
				Transform parent = val.Find("background");
				string text = ((pinData.m_name == "") ? ((Object)pinData.m_icon).name : pinData.m_name);
				Vector3 pos = pinData.m_pos;
				GameObject val2 = new GameObject($"CirclePin ({pos.x}{pos.y}{pos.z})");
				RectTransform val3 = val2.AddComponent<RectTransform>();
				((Transform)val3).SetParent(parent);
				val3.anchoredPosition = new Vector2(0f, 0f);
				val3.sizeDelta = new Vector2(50f, 50f);
				Image val4 = val2.AddComponent<Image>();
				Image val5 = val4;
				PinType type = pinData.m_type;
				if (1 == 0)
				{
				}
				Sprite sprite = (Sprite)((int)type switch
				{
					9 => HudPatch.bossIcon, 
					10 => HudPatch.vikingIcon, 
					4 => HudPatch.deathIcon, 
					5 => HudPatch.bedIcon, 
					0 => HudPatch.fireIcon, 
					1 => HudPatch.houseIcon, 
					2 => HudPatch.anchorIcon, 
					3 => HudPatch.circleIcon, 
					6 => HudPatch.portalIcon, 
					14 => HudPatch.questionMarkIcon, 
					15 => HudPatch.questionMarkIcon, 
					16 => HudPatch.questionMarkIcon, 
					12 => HudPatch.blueTargetIcon, 
					7 => HudPatch.yellowTargetIcon, 
					13 => HudPatch.exclamationIcon, 
					11 => HudPatch.exclamationIcon, 
					_ => HudPatch.circleIcon, 
				});
				if (1 == 0)
				{
				}
				val5.sprite = sprite;
				Image val6 = val4;
				string name = ((Object)pinData.m_icon).name;
				if (1 == 0)
				{
				}
				sprite = (Sprite)(name switch
				{
					"mapicon_start" => HudPatch.spawnIcon, 
					"mapicon_trader" => HudPatch.merchantIcon, 
					"mapicon_hildir" => HudPatch.clothIcon, 
					_ => val4.sprite, 
				});
				if (1 == 0)
				{
				}
				val6.sprite = sprite;
				((Graphic)val4).color = Color.white;
				GameObject val7 = new GameObject("text");
				RectTransform val8 = val7.AddComponent<RectTransform>();
				((Transform)val8).SetParent(val2.transform);
				val8.anchoredPosition = new Vector2(0f, -25f);
				val8.sizeDelta = new Vector2(100f, 25f);
				TextMeshProUGUI val9 = val7.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val9).font = HudPatch.font;
				((TMP_Text)val9).fontSize = 15f;
				((TMP_Text)val9).fontSizeMax = 15f;
				((TMP_Text)val9).fontSizeMin = 5f;
				((TMP_Text)val9).enableAutoSizing = true;
				((Graphic)val9).color = Color.white;
				((TMP_Text)val9).horizontalAlignment = (HorizontalAlignmentOptions)2;
				((TMP_Text)val9).verticalAlignment = (VerticalAlignmentOptions)512;
				((TMP_Text)val9).richText = true;
				((TMP_Text)val9).text = Localization.instance.Localize(text);
				val2.SetActive(false);
				return val2;
			}

			private static List<PinData> GetLatestPinData()
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: 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)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				//IL_004c: 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_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0062: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Expected O, but got Unknown
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Invalid comparison between Unknown and I4
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Invalid comparison between Unknown and I4
				//IL_017e: 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_0185: Unknown result type (might be due to invalid IL or missing references)
				//IL_0188: Invalid comparison between Unknown and I4
				//IL_018c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Invalid comparison between Unknown and I4
				//IL_0194: Unknown result type (might be due to invalid IL or missing references)
				//IL_0198: Invalid comparison between Unknown and I4
				//IL_0206: Unknown result type (might be due to invalid IL or missing references)
				//IL_020b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0213: Unknown result type (might be due to invalid IL or missing references)
				//IL_0218: Unknown result type (might be due to invalid IL or missing references)
				List<PinData> list = new List<PinData>();
				List<PlayerInfo> tempPlayerInfo = Minimap.instance.m_tempPlayerInfo;
				foreach (PlayerInfo item2 in tempPlayerInfo)
				{
					PinData item = new PinData
					{
						m_name = item2.m_name,
						m_type = (PinType)10,
						m_icon = HudPatch.vikingIcon,
						m_save = false,
						m_checked = false,
						m_pos = item2.m_position,
						m_ownerID = 0L
					};
					list.Add(item);
				}
				List<PinData> pins = Minimap.instance.m_pins;
				foreach (PinData item3 in pins)
				{
					PinType type = item3.m_type;
					if (((int)type != 11 && (int)type != 13) || 1 == 0)
					{
						list.Add(item3);
					}
				}
				Dictionary<Vector3, PinData> locationPins = Minimap.instance.m_locationPins;
				List<KeyValuePair<Vector3, PinData>> list2 = locationPins.ToList();
				foreach (KeyValuePair<Vector3, PinData> item4 in list2)
				{
					PinData value = item4.Value;
					list.Add(value);
				}
				List<PinData> playerPins = Minimap.instance.m_playerPins;
				foreach (PinData item5 in playerPins)
				{
					PinType type2 = item5.m_type;
					if (((int)type2 != 8 && (int)type2 != 11 && (int)type2 != 13) || 1 == 0)
					{
						list.Add(item5);
					}
				}
				List<PinData> list3 = new List<PinData>();
				foreach (PinData item6 in list)
				{
					PinData pinData = new PinData
					{
						m_name = item6.m_name,
						m_type = item6.m_type,
						m_pos = item6.m_pos,
						m_icon = item6.m_icon
					};
					bool flag = string.IsNullOrEmpty(item6.m_name);
					bool flag2 = flag;
					if (flag2)
					{
						bool flag3;
						switch (((Object)item6.m_icon).name)
						{
						case "mapicon_start":
						case "mapicon_trader":
						case "mapicon_hildir":
							flag3 = true;
							break;
						default:
							flag3 = false;
							break;
						}
						flag2 = flag3;
					}
					if (flag2)
					{
						pinData.m_name = ((Object)item6.m_icon).name;
						list3.Add(pinData);
					}
					else if (!string.IsNullOrEmpty(item6.m_name))
					{
						list3.Add(pinData);
					}
				}
				return list3;
			}

			private static void UpdateCompassCircle()
			{
				//IL_0177: Unknown result type (might be due to invalid IL or missing references)
				//IL_0198: Unknown result type (might be due to invalid IL or missing references)
				//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_022f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0239: Unknown result type (might be due to invalid IL or missing references)
				//IL_0245: Unknown result type (might be due to invalid IL or missing references)
				//IL_025f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0278: Unknown result type (might be due to invalid IL or missing references)
				//IL_0291: Unknown result type (might be due to invalid IL or missing references)
				//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0351: Unknown result type (might be due to invalid IL or missing references)
				//IL_036d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0313: Unknown result type (might be due to invalid IL or missing references)
				//IL_0330: Unknown result type (might be due to invalid IL or missing references)
				//IL_0380: Unknown result type (might be due to invalid IL or missing references)
				//IL_0392: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0446: Unknown result type (might be due to invalid IL or missing references)
				//IL_0462: Unknown result type (might be due to invalid IL or missing references)
				//IL_0467: Unknown result type (might be due to invalid IL or missing references)
				//IL_046c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0470: Unknown result type (might be due to invalid IL or missing references)
				//IL_047b: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_040c: Unknown result type (might be due to invalid IL or missing references)
				Transform val = root.transform.Find("CompassContainer");
				Transform val2 = val.Find("background");
				Transform val3 = val.Find("hand");
				Transform val4 = ((Component)val).transform.Find("biomes");
				Transform val5 = val.Find("windMarker");
				Transform val6 = val2.Find("north");
				Transform val7 = val2.Find("east");
				Transform val8 = val2.Find("south");
				Transform val9 = val2.Find("west");
				RectTransform val10 = default(RectTransform);
				((Component)val).TryGetComponent<RectTransform>(ref val10);
				RectTransform val11 = default(RectTransform);
				((Component)val2).TryGetComponent<RectTransform>(ref val11);
				Image val12 = default(Image);
				((Component)val2).TryGetComponent<Image>(ref val12);
				Image val13 = default(Image);
				((Component)val3).TryGetComponent<Image>(ref val13);
				TextMeshProUGUI val14 = default(TextMeshProUGUI);
				((Component)val4).TryGetComponent<TextMeshProUGUI>(ref val14);
				Image val15 = default(Image);
				((Component)val5).TryGetComponent<Image>(ref val15);
				RectTransform val16 = default(RectTransform);
				((Component)val6).TryGetComponent<RectTransform>(ref val16);
				RectTransform val17 = default(RectTransform);
				((Component)val7).TryGetComponent<RectTransform>(ref val17);
				RectTransform val18 = default(RectTransform);
				((Component)val8).TryGetComponent<RectTransform>(ref val18);
				RectTransform val19 = default(RectTransform);
				((Component)val9).TryGetComponent<RectTransform>(ref val19);
				Image val20 = default(Image);
				((Component)val6).TryGetComponent<Image>(ref val20);
				Image val21 = default(Image);
				((Component)val7).TryGetComponent<Image>(ref val21);
				Image val22 = default(Image);
				((Component)val8).TryGetComponent<Image>(ref val22);
				Image val23 = default(Image);
				((Component)val9).TryGetComponent<Image>(ref val23);
				if (!Object.op_Implicit((Object)(object)val10) || !Object.op_Implicit((Object)(object)val11) || !Object.op_Implicit((Object)(object)val12) || !Object.op_Implicit((Object)(object)val13) || !Object.op_Implicit((Object)(object)val14) || !Object.op_Implicit((Object)(object)val15) || !Object.op_Implicit((Object)(object)val16) || !Object.op_Implicit((Object)(object)val17) || !Object.op_Implicit((Object)(object)val18) || !Object.op_Implicit((Object)(object)val19))
				{
					return;
				}
				val10.anchoredPosition = RustyCompassPlugin._CompassPosition.Value;
				val11.sizeDelta = new Vector2(RustyCompassPlugin._CompassSize.Value, RustyCompassPlugin._CompassSize.Value);
				((Graphic)val12).color = RustyCompassPlugin._CompassColor.Value;
				Image val24 = val12;
				RustyCompassPlugin.Compass value = RustyCompassPlugin._CompassSprite.Value;
				if (1 == 0)
				{
				}
				Sprite sprite = (Sprite)(value switch
				{
					RustyCompassPlugin.Compass.Compass1 => RustyCompassPlugin.CompassSprite, 
					RustyCompassPlugin.Compass.Compass2 => RustyCompassPlugin.CompassSimple, 
					RustyCompassPlugin.Compass.Compass3 => RustyCompassPlugin.CompassBW, 
					RustyCompassPlugin.Compass.Compass4 => RustyCompassPlugin.CompassViking, 
					_ => val12.sprite, 
				});
				if (1 == 0)
				{
				}
				val24.sprite = sprite;
				val2.rotation = Quaternion.Euler(0f, 0f, ((Quaternion)(ref playerRotation)).eulerAngles.y);
				float y = val2.eulerAngles.y;
				val6.rotation = Quaternion.Euler(0f, 0f, y);
				val7.rotation = Quaternion.Euler(0f, 0f, y);
				val8.rotation = Quaternion.Euler(0f, 0f, y);
				val9.rotation = Quaternion.Euler(0f, 0f, y);
				val16.anchoredPosition = new Vector2(0f, RustyCompassPlugin._CircleDirectionIcons.Value);
				val18.anchoredPosition = new Vector2(0f, 0f - RustyCompassPlugin._CircleDirectionIcons.Value);
				if (RustyCompassPlugin._SwapEastWest.Value == RustyCompassPlugin.Toggle.Off)
				{
					val17.anchoredPosition = new Vector2(RustyCompassPlugin._CircleDirectionIcons.Value, 0f);
					val19.anchoredPosition = new Vector2(0f - RustyCompassPlugin._CircleDirectionIcons.Value, 0f);
				}
				else
				{
					val17.anchoredPosition = new Vector2(0f - RustyCompassPlugin._CircleDirectionIcons.Value, 0f);
					val19.anchoredPosition = new Vector2(RustyCompassPlugin._CircleDirectionIcons.Value, 0f);
				}
				((Graphic)val20).color = RustyCompassPlugin._CircleDirectionColor.Value;
				((Graphic)val21).color = RustyCompassPlugin._CircleDirectionColor.Value;
				((Graphic)val22).color = RustyCompassPlugin._CircleDirectionColor.Value;
				((Graphic)val23).color = RustyCompassPlugin._CircleDirectionColor.Value;
				((Graphic)val13).color = RustyCompassPlugin._HandColor.Value;
				if (Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					Biome currentBiome = Player.m_localPlayer.m_currentBiome;
					((TMP_Text)val14).text = ((object)(Biome)(ref currentBiome)).ToString();
					((Graphic)val14).color = RustyCompassPlugin._BiomesColor.Value;
					if (RustyCompassPlugin._useCompassTokens.Value == RustyCompassPlugin.Toggle.On)
					{
						((Component)val14).gameObject.SetActive(biomesName);
					}
				}
				((Graphic)val15).color = RustyCompassPlugin._WindMarkerColor.Value;
				Quaternion val25 = Quaternion.LookRotation(EnvMan.instance.GetWindDir());
				val5.rotation = Quaternion.Euler(0f, 0f, 0f - ((Quaternion)(ref val25)).eulerAngles.y);
				if (RustyCompassPlugin._useCompassTokens.Value == RustyCompassPlugin.Toggle.On)
				{
					((Component)val5).gameObject.SetActive(windIcon);
				}
				((Component)val).gameObject.SetActive(RustyCompassPlugin._isModActive.Value == RustyCompassPlugin.Toggle.On && ((RustyCompassPlugin._useCompassTokens.Value == RustyCompassPlugin.Toggle.On && compassCircle) || (RustyCompassPlugin._useCompassTokens.Value != RustyCompassPlugin.Toggle.On && RustyCompassPlugin._CompassType.Value == RustyCompassPlugin.CompassType.Circle)));
			}
		}
	}
	public static class MinimapPatches
	{
		[HarmonyPatch(typeof(Minimap), "Awake")]
		[<a99f1a42-905e-4247-90f1-1bf75fa7d6bb>Nullable(0)]
		[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
		public static class MinimapAwakePatch
		{
			public static readonly Dictionary<ZDO, string> TempTames = new Dictionary<ZDO, string>();

			public static readonly List<PinData> TempTamePins = new List<PinData>();
		}

		[HarmonyPatch(typeof(Minimap), "OnDestroy")]
		private static class MinimapOnDestroyPatch
		{
			[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
			private static void Postfix(Tameable __instance)
			{
				MinimapAwakePatch.TempTames.Clear();
				MinimapAwakePatch.TempTamePins.Clear();
			}
		}

		[HarmonyPatch(typeof(Minimap), "UpdatePlayerPins")]
		private static class MinimapUpdatePatches
		{
			[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
			private static void Postfix(Minimap __instance)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				//IL_00de: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0101: Unknown result type (might be due to invalid IL or missing references)
				//IL_0108: Unknown result type (might be due to invalid IL or missing references)
				//IL_010f: Unknown result type (might be due to invalid IL or missing references)
				//IL_011c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Expected O, but got Unknown
				//IL_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: Expected O, but got Unknown
				if (!Object.op_Implicit((Object)(object)__instance) || (Object)(object)Player.m_localPlayer == (Object)null)
				{
					return;
				}
				SpriteData val = __instance.m_icons[3];
				foreach (PinData tempTamePin in MinimapAwakePatch.TempTamePins)
				{
					__instance.RemovePin(tempTamePin);
				}
				MinimapAwakePatch.TempTamePins.Clear();
				if (MinimapAwakePatch.TempTames.Count == 0 || RustyCompassPlugin._TameTrackEnabled.Value != RustyCompassPlugin.Toggle.On)
				{
					return;
				}
				foreach (KeyValuePair<ZDO, string> tempTame in MinimapAwakePatch.TempTames)
				{
					if (tempTame.Key.IsValid())
					{
						PinData val2 = new PinData
						{
							m_type = (PinType)10,
							m_pos = tempTame.Key.GetPosition(),
							m_icon = val.m_icon,
							m_save = false,
							m_checked = false,
							m_name = tempTame.Value,
							m_ownerID = 0L
						};
						val2.m_NamePinData = new PinNameData(val2);
						__instance.CreateMapNamePin(val2, __instance.m_pinNameRootSmall);
						MinimapAwakePatch.TempTamePins.Add(val2);
					}
				}
				foreach (PinData tempTamePin2 in MinimapAwakePatch.TempTamePins)
				{
					__instance.m_pins.Add(tempTamePin2);
				}
			}
		}
	}
	public static class TamePatches
	{
		[HarmonyPatch(typeof(Tameable), "Update")]
		private static class TameUpdatePatch
		{
			[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
			private static void Postfix(Tameable __instance)
			{
				if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return;
				}
				try
				{
					ZNetView val = default(ZNetView);
					((Component)__instance).TryGetComponent<ZNetView>(ref val);
					if (!Object.op_Implicit((Object)(object)val))
					{
						return;
					}
					ZDO zDO = val.GetZDO();
					if (!zDO.IsValid())
					{
						return;
					}
					string hoverName = __instance.GetHoverName();
					if (hoverName == null || !Object.op_Implicit((Object)(object)__instance.m_monsterAI))
					{
						return;
					}
					GameObject followTarget = __instance.m_monsterAI.GetFollowTarget();
					if ((Object)(object)followTarget != (Object)null && ((Character)followTarget.GetComponent<Player>()).GetHoverName() == ((Character)Player.m_localPlayer).GetHoverName())
					{
						if (MinimapPatches.MinimapAwakePatch.TempTames.ContainsKey(zDO))
						{
							return;
						}
						MinimapPatches.MinimapAwakePatch.TempTames.Add(zDO, hoverName);
					}
					if (__instance.HaveSaddle() && ((Behaviour)__instance.m_saddle).isActiveAndEnabled && !MinimapPatches.MinimapAwakePatch.TempTames.ContainsKey(zDO))
					{
						MinimapPatches.MinimapAwakePatch.TempTames.Add(zDO, hoverName);
					}
				}
				catch (NullReferenceException)
				{
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "Awake")]
		private static class TameAwakePatch
		{
			[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
			private static void Postfix(Tameable __instance)
			{
				if (!Object.op_Implicit((Object)(object)__instance) || !Object.op_Implicit((Object)(object)Player.m_localPlayer))
				{
					return;
				}
				ZNetView val = default(ZNetView);
				((Component)__instance).TryGetComponent<ZNetView>(ref val);
				if (!Object.op_Implicit((Object)(object)val))
				{
					return;
				}
				ZDO zDO = val.GetZDO();
				if (!zDO.IsValid())
				{
					return;
				}
				string hoverName = __instance.GetHoverName();
				if (hoverName == null || !Object.op_Implicit((Object)(object)__instance.m_monsterAI))
				{
					return;
				}
				GameObject followTarget = __instance.m_monsterAI.GetFollowTarget();
				if ((Object)(object)followTarget != (Object)null && ((Character)followTarget.GetComponent<Player>()).GetHoverName() == ((Character)Player.m_localPlayer).GetHoverName())
				{
					if (MinimapPatches.MinimapAwakePatch.TempTames.ContainsKey(zDO))
					{
						return;
					}
					MinimapPatches.MinimapAwakePatch.TempTames.Add(zDO, hoverName);
				}
				if (__instance.HaveSaddle() && ((Behaviour)__instance.m_saddle).isActiveAndEnabled && !MinimapPatches.MinimapAwakePatch.TempTames.ContainsKey(zDO))
				{
					MinimapPatches.MinimapAwakePatch.TempTames.Add(zDO, hoverName);
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "UnSummon")]
		private static class TameUnsummonPatch
		{
			[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
			private static void Postfix(Tameable __instance)
			{
				MinimapPatches.MinimapAwakePatch.TempTames.Clear();
			}
		}

		[HarmonyPatch(typeof(Tameable), "RPC_SetSaddle")]
		private static class TameSetSaddlePatch
		{
			[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
			private static void Postfix(Tameable __instance)
			{
				if (!Object.op_Implicit((Object)(object)__instance))
				{
					return;
				}
				ZNetView val = default(ZNetView);
				((Component)__instance).TryGetComponent<ZNetView>(ref val);
				if (Object.op_Implicit((Object)(object)val))
				{
					ZDO zDO = val.GetZDO();
					string hoverName = __instance.GetHoverName();
					if (((Behaviour)__instance.m_saddle).isActiveAndEnabled)
					{
						MinimapPatches.MinimapAwakePatch.TempTames.Add(zDO, hoverName);
					}
					else
					{
						MinimapPatches.MinimapAwakePatch.TempTames.Remove(zDO);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "RPC_Command")]
		private static class TameCommandPatch
		{
			[<23dea103-1d4b-4c3e-b366-73cab9074174>NullableContext(1)]
			private static void Postfix(Tameable __instance)
			{
				if (!Objec