Decompiled source of QuickPing v1.5.11

plugins/QuickPing.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Managers;
using Jotunn.Utils;
using QuickPing.Patches;
using QuickPing.Utilities;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("QuickPing")]
[assembly: AssemblyDescription("Ping what you see !")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Atopy")]
[assembly: AssemblyProduct("QuickPing")]
[assembly: AssemblyCopyright("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("31e0f113-b41a-497c-89f8-8db164e0b3eb")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyFileVersion("1.5.11.0")]
[assembly: AssemblyInformationalVersion("1.5.11-beta.1+4.Branch.hotfix-0.217.46-patch.Sha.cdbf359b6e74957c35d574cd4dc2af408b75f447")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.5.11.0")]
[CompilerGenerated]
[ExcludeFromCodeCoverage]
internal static class GitVersionInformation
{
	public static string Major = "1";

	public static string Minor = "5";

	public static string Patch = "11";

	public static string PreReleaseTag = "beta.1";

	public static string PreReleaseTagWithDash = "-beta.1";

	public static string PreReleaseLabel = "beta";

	public static string PreReleaseLabelWithDash = "-beta";

	public static string PreReleaseNumber = "1";

	public static string WeightedPreReleaseNumber = "30001";

	public static string BuildMetaData = "4";

	public static string BuildMetaDataPadded = "0004";

	public static string FullBuildMetaData = "4.Branch.hotfix-0.217.46-patch.Sha.cdbf359b6e74957c35d574cd4dc2af408b75f447";

	public static string MajorMinorPatch = "1.5.11";

	public static string SemVer = "1.5.11-beta.1";

	public static string LegacySemVer = "1.5.11-beta1";

	public static string LegacySemVerPadded = "1.5.11-beta0001";

	public static string AssemblySemVer = "1.5.11.0";

	public static string AssemblySemFileVer = "1.5.11.0";

	public static string FullSemVer = "1.5.11-beta.1+4";

	public static string InformationalVersion = "1.5.11-beta.1+4.Branch.hotfix-0.217.46-patch.Sha.cdbf359b6e74957c35d574cd4dc2af408b75f447";

	public static string BranchName = "hotfix/0.217.46-patch";

	public static string EscapedBranchName = "hotfix-0-217-46-patch";

	public static string Sha = "cdbf359b6e74957c35d574cd4dc2af408b75f447";

	public static string ShortSha = "cdbf359";

	public static string NuGetVersionV2 = "1.5.11-beta0001";

	public static string NuGetVersion = "1.5.11-beta0001";

	public static string NuGetPreReleaseTagV2 = "beta0001";

	public static string NuGetPreReleaseTag = "beta0001";

	public static string VersionSourceSha = "6043814434b7b236d10a87bebb9fec17c2776b99";

	public static string CommitsSinceVersionSource = "4";

	public static string CommitsSinceVersionSourcePadded = "0004";

	public static string UncommittedChanges = "0";

	public static string CommitDate = "2024-04-21";
}
namespace QuickPing
{
	public enum HoverType
	{
		GameObject,
		Character,
		Hoverable,
		Piece,
		Location
	}
	public class HoverObject : MonoBehaviour
	{
		public GameObject Hover;

		public IDestructible Destructible;

		public Vector3 pos;

		public Vector3 center;

		public HoverType type;

		public bool pinable;

		public string Name { get; set; }
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.atopy.plugins.quickping", "QuickPing", "1.5.11.0")]
	public class QuickPingPlugin : BaseUnityPlugin
	{
		public static QuickPingPlugin Instance { get; set; }

		public static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			Log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Settings.Init();
			Harmony.CreateAndPatchAll(typeof(Player_Patch), "com.atopy.plugins.quickping");
			Harmony.CreateAndPatchAll(typeof(ChatPing_Patch), "com.atopy.plugins.quickping");
			Harmony.CreateAndPatchAll(typeof(Minimap_Patch), "com.atopy.plugins.quickping");
			Harmony.CreateAndPatchAll(typeof(Terminal_Patch), "com.atopy.plugins.quickping");
			Harmony.CreateAndPatchAll(typeof(MineRock5_Patch), "com.atopy.plugins.quickping");
			Harmony.CreateAndPatchAll(typeof(Destructible_Patch), "com.atopy.plugins.quickping");
			Harmony.CreateAndPatchAll(typeof(ZNet_Patch), "com.atopy.plugins.quickping");
			Harmony.CreateAndPatchAll(typeof(WearNTear_Patch), "com.atopy.plugins.quickping");
			Player_Patch.OnPlayerPing.AddListener((UnityAction<HoverObject>)Player_Patch.SendPing);
			Player_Patch.OnPlayerPing.AddListener((UnityAction<HoverObject>)Minimap_Patch.AddPin);
			Player_Patch.OnPlayerForcePing.AddListener((UnityAction<HoverObject>)Player_Patch.SendPing);
			Player_Patch.OnPlayerForcePing.AddListener((UnityAction<HoverObject>)Minimap_Patch.ForceAddPin);
			Player_Patch.OnPlayerRename.AddListener((UnityAction<HoverObject>)Player_Patch.SendRename);
			Player_Patch.OnPlayerRename.AddListener((UnityAction<HoverObject>)Minimap_Patch.RenamePin);
		}
	}
	internal static class Settings
	{
		public const string DefaultPingText = "PING !";

		public static ConfigEntry<bool> PingWhereLooking { get; private set; }

		public static ConfigEntry<bool> AddPin { get; private set; }

		public static ConfigEntry<KeyCode> PingKey { get; private set; }

		public static ConfigEntry<KeyCode> PinEverythingKey { get; internal set; }

		public static ConfigEntry<KeyboardShortcut> RenameKey { get; internal set; }

		public static ConfigEntry<PinType> DefaultPinType { get; internal set; }

		public static ConfigEntry<Color> PlayerColor { get; private set; }

		public static ConfigEntry<Color> ShoutColor { get; private set; }

		public static ConfigEntry<Color> WhisperColor { get; private set; }

		public static ConfigEntry<Color> PingColor { get; private set; }

		public static ConfigEntry<Color> DefaultColor { get; private set; }

		public static ConfigEntry<float> ClosestPinRange { get; private set; }

		public static ButtonConfig PingBtn { get; private set; }

		public static ButtonConfig PingEverythingBtn { get; private set; }

		public static ButtonConfig RenameBtn { get; private set; }

		public static void Init()
		{
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: 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_0215: Expected O, but got Unknown
			PingWhereLooking = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("General", "PingWhereLooking", true, "Create a ping where you are looking when you press <PingKey>");
			AddPin = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<bool>("General", "AddPinOnMap", true, "If true, add a pin when useful resources (copper, berries, campfire, portals etc.) are pinged.");
			ClosestPinRange = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<float>("General", "ClosestPinRange", 2f, "Minimum distance between objects to pin/replace portal tag");
			DefaultPinType = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<PinType>("General", "DefaultPinType", (PinType)11, "Default pin when forcing adding a pin on map");
			PlayerColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "PlayerColor", Color.green, "Color for Player name in pings/messages.");
			ShoutColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "ShoutColor", Color.yellow, "Color for Shout ping.");
			WhisperColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "WhisperColor", new Color(1f, 1f, 1f, 0.75f), "Color for Whisper ping.");
			PingColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "PingColor", new Color(0.6f, 0.7f, 1f, 1f), "Color for \"Ping\" ping.");
			DefaultColor = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<Color>("Colors", "DefaultColor", Color.white, "Default color");
			PingKey = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<KeyCode>("Bindings", "PingInputKey", (KeyCode)116, "The keybind to trigger a ping where you are looking");
			PinEverythingKey = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<KeyCode>("Bindings", "PingEverythingInputKey", (KeyCode)103, "Add a pin on minimap to whatever you're looking at.");
			RenameKey = ((BaseUnityPlugin)QuickPingPlugin.Instance).Config.Bind<KeyboardShortcut>("Bindings", "RenameInputKey", new KeyboardShortcut(PingKey.Value, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), new ConfigDescription("The keybind to rename a ping", (AcceptableValueBase)null, Array.Empty<object>()));
			AddInputs();
		}

		public static void AddInputs()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_002b: Expected O, but got Unknown
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			PingBtn = new ButtonConfig
			{
				Name = "Ping",
				Config = PingKey,
				Hint = "Ping where you are looking, and pin useful resources"
			};
			PingEverythingBtn = new ButtonConfig
			{
				Name = "PinEverything",
				Config = PinEverythingKey,
				Hint = "Pin on map everything you're looking at"
			};
			RenameBtn = new ButtonConfig
			{
				Name = "Rename",
				ShortcutConfig = RenameKey
			};
			InputManager.Instance.AddButton("com.atopy.plugins.quickping", RenameBtn);
			InputManager.Instance.AddButton("com.atopy.plugins.quickping", PingBtn);
			InputManager.Instance.AddButton("com.atopy.plugins.quickping", PingEverythingBtn);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "com.atopy.plugins.quickping";

		public const string PLUGIN_NAME = "QuickPing";

		public const string PLUGIN_VERSION = "1.5.11.0";
	}
}
namespace QuickPing.Utilities
{
	internal static class DataManager
	{
		public static Dictionary<ZDOID, PinData> PinnedObjects = new Dictionary<ZDOID, PinData>();

		public static Dictionary<string, string> CustomNames = new Dictionary<string, string>();

		public static bool Save(World world, PlayerProfile playerProfile)
		{
			bool num = SaveCustomNames(world, playerProfile);
			bool flag = SavePinnedObjects(world, playerProfile);
			return num && flag;
		}

		public static void Load(World world, PlayerProfile playerProfile)
		{
			LoadCustomNames(world, playerProfile);
			LoadPinnedObjects(world, playerProfile);
		}

		private static void LoadPinnedObjects(World world, PlayerProfile playerProfile)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			PinnedObjects.Clear();
			string path = GetPath(world, playerProfile, "pinned");
			FileReader val = null;
			try
			{
				val = new FileReader(path, world.m_fileSource, (FileHelperType)0);
			}
			catch
			{
				if (val != null)
				{
					val.Dispose();
				}
				QuickPingPlugin.Log.LogWarning((object)("Failed to load pinned objects. World: " + world.m_name + " - Profile: " + playerProfile.m_playerName));
				return;
			}
			BinaryReader binary = val.m_binary;
			int count = binary.ReadInt32();
			UnpackPinnedObjects(new ZPackage(binary.ReadBytes(count)));
		}

		private static bool SavePinnedObjects(World world, PlayerProfile playerProfile)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Invalid comparison between Unknown and I4
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			ZPackage obj = PackPinnedObjects();
			if ((int)world.m_fileSource != 2)
			{
				Directory.CreateDirectory(World.GetWorldSavePath(world.m_fileSource));
			}
			string path = GetPath(world, playerProfile, "pinned");
			string text = path + ".new";
			string text2 = path + ".old";
			byte[] array = obj.GetArray();
			FileWriter val = new FileWriter(text, (FileHelperType)0, world.m_fileSource);
			val.m_binary.Write(array.Length);
			val.m_binary.Write(array);
			val.Finish();
			int num;
			if ((int)val.Status != 2)
			{
				num = (((int)world.m_fileSource == 2) ? 1 : 0);
				if (num != 0)
				{
					goto IL_009c;
				}
			}
			else
			{
				num = 0;
			}
			FileHelpers.ReplaceOldFile(path, text, text2, world.m_fileSource);
			goto IL_009c;
			IL_009c:
			return (byte)num != 0;
		}

		private static void LoadCustomNames(World world, PlayerProfile playerProfile)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			CustomNames.Clear();
			string path = GetPath(world, playerProfile, "customNames");
			FileReader val = null;
			try
			{
				val = new FileReader(path, world.m_fileSource, (FileHelperType)0);
			}
			catch
			{
				if (val != null)
				{
					val.Dispose();
				}
				QuickPingPlugin.Log.LogWarning((object)("Failed to load custom names. World: " + world.m_name + " - Profile: " + playerProfile.m_playerName));
				return;
			}
			BinaryReader binary = val.m_binary;
			int count = binary.ReadInt32();
			UnpackCustomNames(new ZPackage(binary.ReadBytes(count)));
		}

		private static bool SaveCustomNames(World world, PlayerProfile playerProfile)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Invalid comparison between Unknown and I4
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Invalid comparison between Unknown and I4
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			ZPackage obj = PackCustomNames();
			if ((int)world.m_fileSource != 2)
			{
				Directory.CreateDirectory(World.GetWorldSavePath(world.m_fileSource));
			}
			string path = GetPath(world, playerProfile, "customNames");
			string text = path + ".new";
			string text2 = path + ".old";
			byte[] array = obj.GetArray();
			FileWriter val = new FileWriter(text, (FileHelperType)0, world.m_fileSource);
			val.m_binary.Write(array.Length);
			val.m_binary.Write(array);
			val.Finish();
			int num;
			if ((int)val.Status != 2)
			{
				num = (((int)world.m_fileSource == 2) ? 1 : 0);
				if (num != 0)
				{
					goto IL_009c;
				}
			}
			else
			{
				num = 0;
			}
			FileHelpers.ReplaceOldFile(path, text, text2, world.m_fileSource);
			goto IL_009c;
			IL_009c:
			return (byte)num != 0;
		}

		private static string GetPath(World world, PlayerProfile playerProfile, string extension)
		{
			string text = default(string);
			string text2 = default(string);
			string text3 = default(string);
			FileHelpers.SplitFilePath(world.GetDBPath(), ref text, ref text2, ref text3);
			string text4 = text + text2;
			string text5 = "." + playerProfile.m_playerName + ".mod.quickping." + extension;
			return text4 + text5;
		}

		private static ZPackage PackPinnedObjects()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			ZPackage val = new ZPackage();
			foreach (KeyValuePair<ZDOID, PinData> pinnedObject in PinnedObjects)
			{
				val.Write(pinnedObject.Key);
				val.Write(pinnedObject.Value);
			}
			return val;
		}

		private static ZPackage PackCustomNames()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			ZPackage val = new ZPackage();
			foreach (KeyValuePair<string, string> customName in CustomNames)
			{
				string key = customName.Key;
				if (key != null && !(key == ""))
				{
					val.Write(customName.Key);
					val.Write(customName.Value);
				}
			}
			return val;
		}

		private static void UnpackCustomNames(ZPackage zPackage)
		{
			CustomNames.Clear();
			while (zPackage.GetPos() < zPackage.Size())
			{
				string text = zPackage.ReadString();
				string value = zPackage.ReadString();
				if (!(text == ""))
				{
					CustomNames.Add(text, value);
				}
			}
		}

		private static void UnpackPinnedObjects(ZPackage zPackage)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<ZDOID, PinData> dictionary = new Dictionary<ZDOID, PinData>();
			if (zPackage == null)
			{
				return;
			}
			while (zPackage.GetPos() < zPackage.Size())
			{
				ZDOID key = zPackage.ReadZDOID();
				PinData value = zPackage.ReadPinData();
				if (!dictionary.ContainsKey(key))
				{
					dictionary.Add(key, value);
				}
			}
			PinnedObjects = dictionary;
		}

		private static void Write(this ZPackage zPackage, PinData pinData)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			zPackage.Write(pinData.m_name);
			zPackage.Write(((object)(PinType)(ref pinData.m_type)).ToString());
			zPackage.Write(pinData.m_pos);
		}

		private static PinData ReadPinData(this ZPackage package)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0031: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			return new PinData
			{
				m_name = package.ReadString(),
				m_type = (PinType)Enum.Parse(typeof(PinType), package.ReadString()),
				m_pos = package.ReadVector3()
			};
		}
	}
	internal static class GO_Ext
	{
		public static IDestructible GetRecursiveComponentInParents<IDestructible>(Transform root)
		{
			if ((Object)(object)root.parent == (Object)null)
			{
				return default(IDestructible);
			}
			IDestructible componentInParent = ((Component)root).GetComponentInParent<IDestructible>();
			if (componentInParent != null)
			{
				return componentInParent;
			}
			return GetRecursiveComponentInParents<IDestructible>(root.parent);
		}

		public static GameObject GetRecursiveParentWithComponent<T>(Transform root)
		{
			if (!Object.op_Implicit((Object)(object)root.parent))
			{
				return null;
			}
			T val = default(T);
			if (((Component)root.parent).gameObject.TryGetComponent<T>(ref val))
			{
				return ((Component)root.parent).gameObject;
			}
			return GetRecursiveParentWithComponent<T>(root.parent);
		}
	}
	internal static class DataUtils
	{
		public static byte[] ReadAllBytes(this BinaryReader reader)
		{
			using MemoryStream memoryStream = new MemoryStream();
			byte[] array = new byte[4096];
			int count;
			while ((count = reader.Read(array, 0, array.Length)) != 0)
			{
				memoryStream.Write(array, 0, count);
			}
			return memoryStream.ToArray();
		}

		public static bool Compare(this PinData x, PinData y)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			if (x.m_pos == y.m_pos)
			{
				return x.m_name == y.m_name;
			}
			return false;
		}
	}
}
namespace QuickPing.Patches
{
	public class ChatPing_Patch
	{
		[HarmonyPatch(typeof(Chat))]
		[HarmonyPatch("AddInworldText")]
		[HarmonyPrefix]
		public static bool AddInworldText(Chat __instance, GameObject go, long senderID, Vector3 position, Type type, UserInfo user, string text)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected I4, but got Unknown
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_0110: Unknown result type (might be due to invalid IL or missing references)
			WorldTextInstance val = __instance.FindExistingWorldText(senderID);
			if (val == null)
			{
				val = new WorldTextInstance();
				val.m_talkerID = senderID;
				val.m_gui = Object.Instantiate<GameObject>(__instance.m_worldTextBase, ((Component)__instance).transform);
				val.m_gui.gameObject.SetActive(true);
				Transform val2 = val.m_gui.transform.Find("Text");
				val.m_textMeshField = ((Component)val2).GetComponent<TextMeshProUGUI>();
				__instance.m_worldTexts.Add(val);
			}
			val.m_userInfo = user;
			val.m_type = type;
			val.m_go = go;
			val.m_position = position;
			Color value;
			switch ((int)type)
			{
			case 2:
				value = Settings.ShoutColor.Value;
				text = text.ToUpper();
				break;
			case 0:
				value = Settings.WhisperColor.Value;
				text = text.ToLowerInvariant();
				break;
			case 3:
				value = Settings.PingColor.Value;
				if (text == string.Empty)
				{
					text = "PING !";
				}
				break;
			default:
				value = Settings.DefaultColor.Value;
				break;
			}
			((TMP_Text)val.m_textMeshField).richText = true;
			((Graphic)val.m_textMeshField).color = value;
			val.m_timer = 0f;
			val.m_text = text;
			__instance.UpdateWorldTextField(val);
			return false;
		}

		[HarmonyPatch(typeof(Chat), "UpdateWorldTextField")]
		[HarmonyPrefix]
		public static bool UpdateWorldTextField(WorldTextInstance wt)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			if ((int)wt.m_type == 2 || (int)wt.m_type == 3)
			{
				text = "<color=#" + ColorUtility.ToHtmlStringRGBA(Settings.PlayerColor.Value) + ">" + wt.m_name + "</color>: ";
			}
			text = text + "<color=#" + ColorUtility.ToHtmlStringRGBA(((Graphic)wt.m_textMeshField).color) + ">" + wt.m_text + "</color>";
			((TMP_Text)wt.m_textMeshField).text = text;
			return false;
		}
	}
	public static class Localization_Patch
	{
		public static string Localize(Location location)
		{
			string result = "";
			foreach (Location allLocation in Location.m_allLocations)
			{
				if (((Object)location).name.Contains(((Object)allLocation).name))
				{
					string text = ((Object)allLocation).name;
					if (((Object)allLocation).name.Contains("(Clone)"))
					{
						text = ((Object)allLocation).name.Replace("(Clone)", "").Trim();
					}
					switch (text)
					{
					case "TrollCave":
					case "TrollCave01":
					case "TrollCave02":
					case "TrollCave03":
						result = Localization.instance.Localize("$location_forestcave");
						break;
					case "Crypt2":
					case "Crypt3":
					case "Crypt4":
						result = Localization.instance.Localize("$location_forestcrypt");
						break;
					case "GoblinCamp1":
					case "GoblinCamp2":
						result = Localization.instance.Localize("GoblinCamp");
						break;
					case "StoneHenge1":
					case "StoneHenge2":
					case "StoneHenge3":
					case "StoneHenge4":
					case "StoneHenge5":
					case "StoneHenge6":
						result = Localization.instance.Localize("Stone Henge");
						break;
					case "SunkenCrypt1":
					case "SunkenCrypt2":
					case "SunkenCrypt3":
					case "SunkenCrypt4":
					case "SunkenCrypt4old":
						result = Localization.instance.Localize("$location_sunkencrypt");
						break;
					case "DrakeNest01":
						result = Localization.instance.Localize("$item_dragonegg");
						break;
					case "MountainCave01":
					case "MountainCave02":
						result = Localization.instance.Localize("$location_mountaincave");
						break;
					case "Mistlands_DvergrTownEntrance":
					case "Mistlands_DvergrTownEntrance1":
					case "Mistlands_DvergrTownEntrance2":
						result = Localization.instance.Localize("$location_dvergrtown");
						break;
					}
				}
			}
			return result;
		}

		public static string GetBaseTranslation(string str)
		{
			if (str == "")
			{
				return "noStr";
			}
			string key = Localization.instance.m_translations.FirstOrDefault((KeyValuePair<string, string> x) => x.Value == str).Key;
			return "$" + key;
		}
	}
	[HarmonyPatch(typeof(MineRock5))]
	internal static class MineRock5_Patch
	{
		[HarmonyPatch(typeof(MineRock5), "AllDestroyed")]
		[HarmonyPostfix]
		public static void AllDestroyed(MineRock5 __instance, bool __result)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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)
			if (__result && Object.op_Implicit((Object)(object)__instance.m_nview))
			{
				ZDOID uid = __instance.m_nview.GetZDO().m_uid;
				if (DataManager.PinnedObjects.ContainsKey(uid))
				{
					Minimap.instance.RemovePin(DataManager.PinnedObjects[uid]);
				}
			}
		}
	}
	[HarmonyPatch(typeof(WearNTear))]
	internal static class WearNTear_Patch
	{
		[HarmonyPatch(typeof(WearNTear), "Destroy")]
		[HarmonyPrefix]
		public static void Destroy(WearNTear __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)__instance.m_nview) && __instance.m_nview.GetZDO() != null)
			{
				ZDOID uid = __instance.m_nview.GetZDO().m_uid;
				if (DataManager.PinnedObjects.ContainsKey(uid))
				{
					Minimap.instance.RemovePin(DataManager.PinnedObjects[uid]);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Destructible))]
	internal static class Destructible_Patch
	{
		[HarmonyPatch(typeof(Destructible), "Destroy")]
		[HarmonyPrefix]
		public static bool Destroy(Destructible __instance, Vector3 hitPoint, Vector3 hitDir)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			__instance.CreateDestructionEffects(hitPoint, hitDir);
			if (__instance.m_destroyNoise > 0f)
			{
				Player closestPlayer = Player.GetClosestPlayer(((Component)__instance).transform.position, 10f);
				if (Object.op_Implicit((Object)(object)closestPlayer))
				{
					((Character)closestPlayer).AddNoise(__instance.m_destroyNoise);
				}
			}
			ZDOID uid = __instance.m_nview.GetZDO().m_uid;
			if (Object.op_Implicit((Object)(object)__instance.m_spawnWhenDestroyed))
			{
				GameObject obj = Object.Instantiate<GameObject>(__instance.m_spawnWhenDestroyed, ((Component)__instance).transform.position, ((Component)__instance).transform.rotation);
				ZNetView component = obj.GetComponent<ZNetView>();
				component.SetLocalScale(((Component)__instance).transform.localScale);
				Gibber component2 = obj.GetComponent<Gibber>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.Setup(hitPoint, hitDir);
				}
				MineRock5 val = default(MineRock5);
				if (obj.TryGetComponent<MineRock5>(ref val))
				{
					if (!DataManager.PinnedObjects.ContainsKey(component.GetZDO().m_uid) && DataManager.PinnedObjects.ContainsKey(uid))
					{
						ZDOID uid2 = component.GetZDO().m_uid;
						PinData value = DataManager.PinnedObjects[uid];
						DataManager.PinnedObjects.Add(uid2, value);
						DataManager.PinnedObjects.Remove(uid);
					}
					else if (DataManager.PinnedObjects.ContainsKey(uid))
					{
						DataManager.PinnedObjects.Remove(uid);
					}
				}
			}
			else if (DataManager.PinnedObjects.ContainsKey(uid))
			{
				Minimap.instance.RemovePin(DataManager.PinnedObjects[uid]);
			}
			__instance.m_onDestroyed?.Invoke();
			ZNetScene.instance.Destroy(((Component)__instance).gameObject);
			__instance.m_destroyed = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(Character))]
	internal static class Character_Patch
	{
		[HarmonyPatch(typeof(Character), "OnDeath")]
		[HarmonyPrefix]
		public static void OnDeath(Character __instance)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)__instance.m_nview))
			{
				ZDOID uid = __instance.m_nview.GetZDO().m_uid;
				if (DataManager.PinnedObjects.ContainsKey(uid))
				{
					Minimap.instance.RemovePin(DataManager.PinnedObjects[uid]);
				}
			}
		}
	}
	internal static class Minimap_Patch
	{
		private static GameObject panel;

		private static GameObject nameInput;

		private static GameObject toggleSaveName;

		public static bool IsNaming;

		private static string tempOriginalText;

		public static PinType IsPinable(string strID)
		{
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			string baseTranslation = Localization_Patch.GetBaseTranslation(strID);
			Dictionary<PinType, List<string>> dictionary = new Dictionary<PinType, List<string>>
			{
				{
					(PinType)0,
					new List<string> { "$piece_firepit", "$piece_bonfire", "$piece_fire", "GoblinCamp" }
				},
				{
					(PinType)1,
					new List<string>()
				},
				{
					(PinType)2,
					new List<string> { "$piece_deposit_copper", "$piece_deposit_silver", "$piece_deposit_silvervein", "$piece_deposit_tin", "$piece_mudpile", "$piece_giant_brain" }
				},
				{
					(PinType)3,
					new List<string>
					{
						"$item_raspberries", "$item_blueberries", "$item_cloudberries", "$item_dragonegg", "$item_dandelion", "$item_mushroomcommon", "$item_magecap", "$item_mushroomblue", "$item_thistle", "$item_jotunpuffs",
						"$item_ancientroot", "$peRaspberryBushName", "$peBlueberryBushName", "$peCloudberryBushName", "$pePickableMushroomName", "$pePickableYellowMushroomName", "$pePickableBlueMushroomName", "$pePickableThistleName", "$pePickableDandelionName", "$pePickableJotunpuffsName"
					}
				},
				{
					(PinType)6,
					new List<string> { "$location_forestcave", "$location_forestcrypt", "Stone Henge", "$location_sunkencrypt", "$location_mountaincave", "$location_dvergrtown", "$piece_portal" }
				}
			};
			foreach (PinType key in dictionary.Keys)
			{
				if (dictionary[key].Contains(strID) || dictionary[key].Contains(baseTranslation))
				{
					return key;
				}
			}
			return (PinType)8;
		}

		internal static void RenamePin(HoverObject obj)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			AddPin(obj.Hover, obj.Destructible, obj.Name, obj.center, force: false, rename: true);
		}

		public static void AddPin(HoverObject obj)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			AddPin(obj.Hover, obj.Destructible, obj.Name, obj.center);
		}

		public static void ForceAddPin(HoverObject obj)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			AddPin(obj.Hover, obj.Destructible, obj.Name, obj.center, force: true);
		}

		public static void AddPin(GameObject hover, IDestructible idestructible, string strID, Vector3 pos, bool force = false, bool rename = false)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0046: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: 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_019d: Invalid comparison between Unknown and I4
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Invalid comparison between Unknown and I4
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			if (!Settings.AddPin.Value && !force)
			{
				return;
			}
			bool flag = false;
			PinData val = new PinData
			{
				m_type = IsPinable(strID)
			};
			if (Object.op_Implicit((Object)(object)hover) && Object.op_Implicit((Object)(object)hover.GetComponent<ItemDrop>()))
			{
				val.m_type = (PinType)8;
			}
			PinData closestPin = Minimap.instance.GetClosestPin(pos, Settings.ClosestPinRange.Value, true);
			if (strID == "$piece_portal")
			{
				Hoverable hoverable = default(Hoverable);
				if (hover.TryGetComponent<Hoverable>(ref hoverable))
				{
					val.m_name = GetPortalTag(hoverable);
					if (closestPin != null)
					{
						Minimap.instance.RemovePin(closestPin);
					}
					val.m_pos = pos;
					val = Minimap.instance.AddPin(val.m_pos, val.m_type, val.m_name, true, false, 0L, "");
					flag = true;
					QuickPingPlugin.Log.LogInfo((object)$"Add Portal Pin : Name:{val.m_name} x:{val.m_pos.x}, y:{val.m_pos.y}, Type:{val.m_type}");
				}
			}
			else if (closestPin == null || rename)
			{
				PinData val2 = val;
				if (val2.m_name == null)
				{
					val2.m_name = Localization.instance.Localize(strID);
				}
				bool flag2 = DataManager.CustomNames.ContainsKey(strID);
				if (flag2)
				{
					val.m_name = DataManager.CustomNames[strID];
				}
				val.m_pos = pos;
				if (val.m_name == null || (val.m_name == "" && !flag2))
				{
					val.m_name = "PING !";
				}
				if ((int)val.m_type == 8 && force)
				{
					val.m_type = Settings.DefaultPinType.Value;
					val = Minimap.instance.AddPin(val.m_pos, val.m_type, val.m_name, true, false, 0L, "");
					flag = true;
					QuickPingPlugin.Log.LogInfo((object)$"Add Pin : Name:{val.m_name} x:{val.m_pos.x}, y:{val.m_pos.y}, Type:{val.m_type}");
				}
				else if ((int)val.m_type != 8)
				{
					if (closestPin == null)
					{
						val = Minimap.instance.AddPin(val.m_pos, val.m_type, val.m_name, true, false, 0L, "");
						flag = true;
					}
					else if (rename)
					{
						val = closestPin;
					}
					QuickPingPlugin.Log.LogInfo((object)$"Add Pin : Name:{val.m_name} x:{val.m_pos.x}, y:{val.m_pos.y}, Type:{val.m_type}");
					if (rename)
					{
						GUIManager.BlockInput(true);
						InitNameInput();
						tempOriginalText = strID;
						Minimap.instance.ShowPinNameInput(val.m_pos);
					}
				}
			}
			if (!(idestructible != null && flag))
			{
				return;
			}
			FieldInfo field = ((object)idestructible).GetType().GetField("m_nview", BindingFlags.Instance | BindingFlags.NonPublic);
			if (field == null)
			{
				QuickPingPlugin.Log.LogWarning((object)$"Unable to link destructible {idestructible} to pin: {val.m_name}. (Is it a god?)");
				return;
			}
			object? value = field.GetValue(idestructible);
			ZNetView val3 = (ZNetView)((value is ZNetView) ? value : null);
			ZDOID uid = val3.GetZDO().m_uid;
			if (!DataManager.PinnedObjects.ContainsKey(uid))
			{
				DataManager.PinnedObjects[uid] = val;
			}
		}

		public static void UpdateNameInput()
		{
			if (Minimap.instance.m_namePin == null)
			{
				Minimap.instance.m_wasFocused = false;
			}
			if (Minimap.instance.m_namePin != null)
			{
				panel.SetActive(true);
				nameInput.SetActive(true);
				toggleSaveName.SetActive(true);
				InputField component = nameInput.GetComponent<InputField>();
				Toggle component2 = toggleSaveName.GetComponent<Toggle>();
				if (!component.isFocused)
				{
					EventSystem.current.SetSelectedGameObject(nameInput);
				}
				if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))
				{
					ValidateNameInput(component, component2.isOn);
				}
				else if (Input.GetKeyDown((KeyCode)27))
				{
					CancelNameInput();
				}
				Minimap.instance.m_wasFocused = true;
			}
			else
			{
				panel.gameObject.SetActive(false);
				IsNaming = false;
				tempOriginalText = null;
				GUIManager.BlockInput(false);
				DestroyGUI();
			}
		}

		private static void CancelNameInput()
		{
			Minimap.instance.m_namePin = null;
			Minimap.instance.m_wasFocused = false;
			panel.gameObject.SetActive(false);
			IsNaming = false;
			tempOriginalText = null;
			GUIManager.BlockInput(false);
			DestroyGUI();
		}

		private static void DestroyGUI()
		{
			Object.Destroy((Object)(object)nameInput);
			Object.Destroy((Object)(object)panel);
			Object.Destroy((Object)(object)toggleSaveName);
		}

		private static void ValidateNameInput(InputField inputField, bool save)
		{
			string text = inputField.text;
			text = text.Replace('$', ' ');
			text = text.Replace('<', ' ');
			text = text.Replace('>', ' ');
			string text2 = tempOriginalText;
			Minimap.instance.m_namePin.m_name = text;
			if (save)
			{
				QuickPingPlugin.Log.LogInfo((object)("Save name " + Minimap.instance.m_namePin.m_name + " for " + text2));
				SaveName(Minimap.instance.m_namePin.m_name, text2);
			}
			Minimap.instance.m_namePin = null;
		}

		private static void SaveName(string m_name, string originalName)
		{
			if (DataManager.CustomNames.ContainsKey(originalName))
			{
				DataManager.CustomNames[originalName] = m_name;
			}
			else
			{
				DataManager.CustomNames.Add(originalName, m_name);
			}
		}

		private static void InitNameInput()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			if (GUIManager.Instance == null)
			{
				QuickPingPlugin.Log.LogError((object)"GUIManager instance is null");
				return;
			}
			if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront))
			{
				QuickPingPlugin.Log.LogError((object)"GUIManager CustomGUI is null");
				return;
			}
			IsNaming = true;
			panel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), new Vector2(0f, 0f), 200f, 90f, true);
			VerticalLayoutGroup obj = panel.gameObject.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 10f;
			((LayoutGroup)obj).padding = new RectOffset(10, 10, 10, 10);
			((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
			nameInput = GUIManager.Instance.CreateInputField(panel.transform, new Vector2(0.5f, 0.9f), new Vector2(0.5f, 0.9f), new Vector2(0f, 0f), (ContentType)0, "Pin Name", 16, 90f, 30f);
			nameInput.SetActive(IsNaming);
			toggleSaveName = GUIManager.Instance.CreateToggle(panel.transform, 20f, 20f);
			Text component = ((Component)toggleSaveName.transform.Find("Label")).GetComponent<Text>();
			((Graphic)component).color = Color.white;
			component.text = "Save";
			((Behaviour)component).enabled = true;
			toggleSaveName.SetActive(IsNaming);
			Transform transform = toggleSaveName.transform;
			transform.position += new Vector3(20f, 0f, 0f);
		}

		private static string GetPortalTag(Hoverable hoverable)
		{
			return hoverable.GetHoverText().Split(new char[1] { '"' })[1];
		}

		[HarmonyPatch(typeof(Minimap))]
		[HarmonyPatch("RemovePin", new Type[] { typeof(PinData) })]
		[HarmonyPrefix]
		public static bool RemovePin(Minimap __instance, PinData pin)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			if (pin == null || pin.m_name == null || pin.m_name == "")
			{
				return true;
			}
			foreach (KeyValuePair<ZDOID, PinData> p in DataManager.PinnedObjects)
			{
				if (p.Value.Compare(pin))
				{
					pin = __instance.GetClosestPin(p.Value.m_pos, Settings.ClosestPinRange.Value, true);
					DataManager.PinnedObjects.Remove(DataManager.PinnedObjects.FirstOrDefault((KeyValuePair<ZDOID, PinData> x) => x.Value.Compare(p.Value)).Key);
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)pin.m_uiElement))
			{
				__instance.DestroyPinMarker(pin);
			}
			__instance.m_pins.Remove(pin);
			return false;
		}
	}
	internal static class Player_Patch
	{
		public static UnityEvent<HoverObject> OnPlayerPing = new UnityEvent<HoverObject>();

		public static UnityEvent<HoverObject> OnPlayerForcePing = new UnityEvent<HoverObject>();

		public static UnityEvent<HoverObject> OnPlayerRename = new UnityEvent<HoverObject>();

		[HarmonyPatch(typeof(Player), "Update")]
		[HarmonyPostfix]
		private static void Player_Update(Player __instance)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			if (ZInput.instance == null || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || (Object)(object)Player.m_localPlayer != (Object)(object)__instance || (!Settings.PingWhereLooking.Value && !Settings.AddPin.Value))
			{
				return;
			}
			if (Minimap_Patch.IsNaming)
			{
				Minimap_Patch.UpdateNameInput();
			}
			if (((Character)Player.m_localPlayer).TakeInput() && (int)Settings.PingKey.Value != 0)
			{
				if (ZInput.GetButtonDown(Settings.RenameBtn.Name))
				{
					HoverObject hoverObject = FindHoverObject(500f);
					hoverObject.Name = GetHoverName(hoverObject.Name, hoverObject.Hover, hoverObject.type);
					OnPlayerRename.Invoke(hoverObject);
				}
				else if (ZInput.GetButtonDown(Settings.PingBtn.Name))
				{
					HoverObject hoverObject2 = FindHoverObject(500f);
					hoverObject2.Name = GetHoverName(hoverObject2.Name, hoverObject2.Hover, hoverObject2.type);
					OnPlayerPing.Invoke(hoverObject2);
				}
				else if (ZInput.GetButtonDown(Settings.PingEverythingBtn.Name))
				{
					HoverObject hoverObject3 = FindHoverObject(500f);
					hoverObject3.Name = GetHoverName(hoverObject3.Name, hoverObject3.Hover, hoverObject3.type);
					OnPlayerForcePing.Invoke(hoverObject3);
				}
			}
		}

		private static string GetHoverName(string pingText, GameObject hover, HoverType type)
		{
			switch (type)
			{
			case HoverType.Hoverable:
			{
				Hoverable val = default(Hoverable);
				hover.TryGetComponent<Hoverable>(ref val);
				pingText = ((!val.GetHoverName().StartsWith("$")) ? Localization_Patch.GetBaseTranslation(val.GetHoverName()) : val.GetHoverName());
				if (pingText == "$")
				{
					pingText = val.GetHoverName();
				}
				if (pingText == "noStr")
				{
					pingText = val.GetHoverName();
				}
				if (((object)val).ToString().Contains("ReadMap") || ((object)val).ToString().Contains("WriteMap") || ((object)val).ToString().Contains("add_ore") || ((object)val).ToString().Contains("add_wood") || (((object)val).ToString().Contains("door") && Object.op_Implicit((Object)(object)hover.transform.parent) && Object.op_Implicit((Object)(object)((Component)hover.transform).GetComponentInParent<Piece>())))
				{
					pingText = hover.GetComponentInParent<Piece>().m_name;
				}
				break;
			}
			case HoverType.Piece:
				pingText = hover.GetComponent<Piece>().m_name;
				break;
			case HoverType.Location:
				pingText = Localization_Patch.Localize(hover.GetComponent<Location>());
				break;
			case HoverType.Character:
				pingText = hover.GetComponent<Character>().m_name;
				break;
			}
			return pingText;
		}

		public static HoverObject FindHoverObject(float range)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: 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_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			HoverObject hoverObject = new HoverObject
			{
				type = HoverType.GameObject,
				pos = ((Character)Player.m_localPlayer).GetHeadPoint(),
				center = ((Character)Player.m_localPlayer).GetHeadPoint(),
				Name = "PING !"
			};
			LayerMask val = LayerMask.op_Implicit(LayerMask.GetMask(new string[12]
			{
				"Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "character_noenv",
				"vehicle", "item"
			}));
			RaycastHit[] array = Physics.RaycastAll(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward, range + 10f, LayerMask.op_Implicit(val));
			Array.Sort(array, (RaycastHit x, RaycastHit y) => ((RaycastHit)(ref x)).distance.CompareTo(((RaycastHit)(ref y)).distance));
			RaycastHit[] array2 = array;
			if (array2.Length == 0)
			{
				Ray val2 = default(Ray);
				((Ray)(ref val2))..ctor(((Component)GameCamera.instance).transform.position, ((Component)GameCamera.instance).transform.forward);
				hoverObject.pos = ((Ray)(ref val2)).GetPoint(range);
				hoverObject.center = hoverObject.pos;
				return hoverObject;
			}
			for (int i = 0; i < 1; i++)
			{
				hoverObject.pos = ((RaycastHit)(ref array2[i])).point;
				RaycastHit raycastHit = array2[i];
				if (OverlappingPlayer(ref raycastHit))
				{
					continue;
				}
				if (!(Vector3.Distance(((Character)Player.m_localPlayer).GetEyePoint(), ((RaycastHit)(ref raycastHit)).point) < range))
				{
					break;
				}
				Character val3 = (Object.op_Implicit((Object)(object)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody) ? ((Component)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody).GetComponent<Character>() : ((Component)((RaycastHit)(ref raycastHit)).collider).GetComponent<Character>());
				if ((Object)(object)val3 != (Object)null && (!Object.op_Implicit((Object)(object)val3.GetBaseAI()) || !val3.GetBaseAI().IsSleeping()))
				{
					hoverObject.type = HoverType.Character;
					hoverObject.Hover = ((Component)val3).gameObject;
					hoverObject.center = ((Component)val3).transform.position;
				}
				else if ((hoverObject.type = CheckType(((Component)((RaycastHit)(ref raycastHit)).collider).transform, out hoverObject.Destructible)) != 0)
				{
					hoverObject.Hover = ((Component)((Component)((RaycastHit)(ref raycastHit)).collider).transform).gameObject;
					hoverObject.center = hoverObject.Hover.transform.position;
					QuickPingPlugin.Log.LogWarning((object)"Root");
				}
				else if ((Object)(object)((Component)((RaycastHit)(ref raycastHit)).collider).GetComponentInChildren<GameObject>() != (Object)null)
				{
					GameObject[] componentsInChildren = ((Component)((RaycastHit)(ref raycastHit)).collider).GetComponentsInChildren<GameObject>();
					foreach (GameObject val4 in componentsInChildren)
					{
						if ((hoverObject.type = CheckType(val4.transform, out hoverObject.Destructible)) != 0)
						{
							hoverObject.Hover = ((Component)val4.transform).gameObject;
							hoverObject.center = hoverObject.Hover.transform.position;
							QuickPingPlugin.Log.LogWarning((object)"Child");
						}
					}
				}
				else if ((Object)(object)((Component)((RaycastHit)(ref raycastHit)).collider).transform.parent != (Object)null)
				{
					hoverObject.Destructible = GO_Ext.GetRecursiveComponentInParents<IDestructible>(((Component)((RaycastHit)(ref raycastHit)).collider).transform);
					if (Object.op_Implicit((Object)(object)(hoverObject.Hover = GO_Ext.GetRecursiveParentWithComponent<Location>(((Component)((RaycastHit)(ref raycastHit)).collider).transform))))
					{
						hoverObject.type = HoverType.Location;
					}
					else if (Object.op_Implicit((Object)(object)(hoverObject.Hover = GO_Ext.GetRecursiveParentWithComponent<Piece>(((Component)((RaycastHit)(ref raycastHit)).collider).transform))))
					{
						hoverObject.type = HoverType.Piece;
					}
					else if (Object.op_Implicit((Object)(object)(hoverObject.Hover = GO_Ext.GetRecursiveParentWithComponent<Hoverable>(((Component)((RaycastHit)(ref raycastHit)).collider).transform))))
					{
						hoverObject.type = HoverType.Hoverable;
					}
				}
				break;
			}
			if (Object.op_Implicit((Object)(object)hoverObject.Hover))
			{
				hoverObject.center = hoverObject.Hover.transform.position;
			}
			else
			{
				hoverObject.center = hoverObject.pos;
			}
			return hoverObject;
		}

		private static HoverType CheckType(Transform root, out IDestructible destructible)
		{
			destructible = ((Component)root).GetComponent<IDestructible>();
			if (((Component)root).GetComponent<Hoverable>() != null)
			{
				return HoverType.Hoverable;
			}
			if ((Object)(object)((Component)root).GetComponent<Location>() != (Object)null)
			{
				return HoverType.Location;
			}
			if (Object.op_Implicit((Object)(object)((Component)root).GetComponent<Piece>()))
			{
				return HoverType.Piece;
			}
			return HoverType.GameObject;
		}

		private static bool OverlappingPlayer(ref RaycastHit raycastHit)
		{
			if (Object.op_Implicit((Object)(object)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody))
			{
				return (Object)(object)((Component)((RaycastHit)(ref raycastHit)).collider.attachedRigidbody).gameObject == (Object)(object)((Component)Player.m_localPlayer).gameObject;
			}
			return false;
		}

		internal static void SendRename(HoverObject ping)
		{
			SendPing(ping);
		}

		public static void SendPing(HoverObject ping)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			SendPing(ping.pos, Localization.instance.Localize(ping.Name));
		}

		internal static void SendPing(Vector3 position, string text, bool local = false)
		{
			//IL_0047: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Player.m_localPlayer) && Settings.PingWhereLooking.Value)
			{
				QuickPingPlugin.Log.LogInfo((object)("SendPing : " + text));
				ZRoutedRpc instance = ZRoutedRpc.instance;
				long num;
				if (!local)
				{
					num = ZRoutedRpc.Everybody;
				}
				else
				{
					ZDOID zDOID = ((Character)Player.m_localPlayer).GetZDOID();
					num = ((ZDOID)(ref zDOID)).UserID;
				}
				instance.InvokeRoutedRPC(num, "ChatMessage", new object[5]
				{
					position,
					3,
					UserInfo.GetLocalUser(),
					text,
					PrivilegeManager.GetNetworkUserId()
				});
				if (Player.m_debugMode && (Object)(object)Console.instance != (Object)null && ((Terminal)Console.instance).IsCheatsEnabled() && (Object)(object)Console.instance != (Object)null)
				{
					((Terminal)Console.instance).AddString($"Pinged at: {position.x}, {position.z}");
				}
			}
		}
	}
	internal class Terminal_Patch
	{
		[HarmonyPatch(typeof(Terminal), "AddString", new Type[]
		{
			typeof(string),
			typeof(string),
			typeof(Type),
			typeof(bool)
		})]
		[HarmonyPrefix]
		public static bool AddString(Terminal __instance, string user, string text, Type type, bool timestamp = false)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Invalid comparison between Unknown and I4
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			Color value;
			if ((int)type != 0)
			{
				if ((int)type == 2)
				{
					value = Settings.ShoutColor.Value;
					text = text.ToUpper();
				}
				else
				{
					value = Settings.DefaultColor.Value;
				}
			}
			else
			{
				value = Settings.WhisperColor.Value;
				text = text.ToLowerInvariant();
			}
			string text2 = (timestamp ? ("[" + DateTime.Now.ToString("MM-dd-yyyy HH:mm:ss") + "] ") : "");
			text2 = text2 + "<color=#" + ColorUtility.ToHtmlStringRGBA(Settings.PlayerColor.Value) + ">" + user + "</color>: <color=#" + ColorUtility.ToHtmlStringRGBA(value) + ">" + text + "</color>";
			__instance.AddString(text2);
			return false;
		}
	}
	public class ZNet_Patch
	{
		[HarmonyPatch(typeof(ZNet), "LoadWorld")]
		[HarmonyPostfix]
		private static void LoadWorld(ZNet __instance)
		{
			DataManager.Load(ZNet.m_world, Game.instance.GetPlayerProfile());
		}

		[HarmonyPatch(typeof(ZNet), "SaveWorldThread")]
		[HarmonyPostfix]
		private static void SaveWorldThread()
		{
			bool flag = DataManager.Save(ZNet.m_world, Game.instance.GetPlayerProfile());
			QuickPingPlugin.Log.LogInfo((object)$"cloud save : {!flag}");
		}
	}
}