Decompiled source of ArcadeHelper v2.4.0

ArcadeHelper.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace ArcadeHelperMod;

[BepInPlugin("com.arcaderoom.arcadehelper", "Arcade Helper", "2.4.0")]
public class ArcadeHelperPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Minimap), "OnMapMiddleClick")]
	public static class Minimap_OnMapMiddleClick_Patch
	{
		public static void Postfix(Minimap __instance)
		{
			//IL_00b4: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			try
			{
				if ((Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303) || Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)) && ActiveWaypoint.HasValue)
				{
					ClearWaypoint();
					if ((Object)(object)MessageHud.instance != (Object)null)
					{
						MessageHud.instance.ShowMessage((MessageType)1, "<color=#FFA500>✖ Навигацията е спряна.</color>", 0, (Sprite)null, false, true);
					}
					return;
				}
				Vector3 value = Traverse.Create((object)__instance).Method("ScreenToWorldPoint", new object[1] { Input.mousePosition }).GetValue<Vector3>();
				PinData value2 = Traverse.Create((object)__instance).Method("GetClosestPinToCursor", new object[0]).GetValue<PinData>();
				string name = ((value2 != null && !string.IsNullOrEmpty(value2.m_name)) ? value2.m_name : "Маркер");
				Vector3 val = value2?.m_pos ?? value;
				if (ActiveWaypoint.HasValue && (Vector3.Distance(ActiveWaypoint.Value, val) < 250f || (value2 != null && value2.m_pos == ActiveWaypoint.Value) || (value2 != null && !string.IsNullOrEmpty(value2.m_name) && value2.m_name == ActiveWaypointName)))
				{
					ClearWaypoint();
					if ((Object)(object)MessageHud.instance != (Object)null)
					{
						MessageHud.instance.ShowMessage((MessageType)1, "<color=#FFA500>✖ Навигацията е спряна.</color>", 0, (Sprite)null, false, true);
					}
				}
				else
				{
					SetWaypoint(val, name);
				}
			}
			catch
			{
			}
		}
	}

	[HarmonyPatch(typeof(Chat), "SendText")]
	public static class Chat_SendText_Patch
	{
		public static bool Prefix(Chat __instance, Type type, string text)
		{
			if (!string.IsNullOrEmpty(text))
			{
				string text2 = text.Trim();
				if (text2.Equals("/clear", StringComparison.OrdinalIgnoreCase) || text2.Equals("/stop", StringComparison.OrdinalIgnoreCase) || text2.Equals("/c", StringComparison.OrdinalIgnoreCase))
				{
					if (ActiveWaypoint.HasValue)
					{
						ClearWaypoint();
						if ((Object)(object)MessageHud.instance != (Object)null)
						{
							MessageHud.instance.ShowMessage((MessageType)1, "<color=#FFA500>✖ Навигацията е спряна.</color>", 0, (Sprite)null, false, true);
						}
					}
					return false;
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TombStone), "OnTakeAllSuccess")]
	public static class TombStone_OnTakeAllSuccess_Patch
	{
		public static void Postfix(TombStone __instance)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__instance == (Object)null) && (AutoCleanDeathPin == null || AutoCleanDeathPin.Value) && Traverse.Create((object)__instance).Method("IsOwner", new object[0]).GetValue<bool>())
			{
				RemoveDeathPinNear(((Component)__instance).transform.position);
			}
		}
	}

	[HarmonyPatch(typeof(TombStone), "UpdateDespawn")]
	public static class TombStone_UpdateDespawn_Patch
	{
		public static void Postfix(TombStone __instance)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)__instance == (Object)null) && (AutoCleanDeathPin == null || AutoCleanDeathPin.Value) && Traverse.Create((object)__instance).Method("IsOwner", new object[0]).GetValue<bool>())
			{
				Container value = Traverse.Create((object)__instance).Field("m_container").GetValue<Container>();
				if ((Object)(object)value != (Object)null && value.GetInventory() != null && value.GetInventory().NrOfItems() == 0)
				{
					RemoveDeathPinNear(((Component)__instance).transform.position);
				}
			}
		}
	}

	[HarmonyPatch(typeof(Container), "GetHoverText")]
	[HarmonyPriority(0)]
	public static class Container_GetHoverText_Patch
	{
		public static void Postfix(Container __instance, ref string __result)
		{
			//IL_0066: 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)
			if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).GetComponent<TombStone>() != (Object)null)
			{
				return;
			}
			ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
			if (!((Object)(object)component == (Object)null) && component.GetZDO() != null)
			{
				string text = ((ChestRenameKey != null) ? ((object)ChestRenameKey.Value).ToString() : "LeftAlt");
				string text2 = (text.Contains("Alt") ? "[Alt + E]" : (text.Contains("Control") ? "[Ctrl + E]" : ("[" + text + "]")));
				string text3 = component.GetZDO().GetString("Arcade_ChestName", "");
				if (!string.IsNullOrEmpty(text3))
				{
					__result = "<color=#FFE066>\ud83c\udff7 " + text3 + "</color>\n" + __result;
				}
				string text4 = ((ToggleAutoFeederKey != null) ? ((object)ToggleAutoFeederKey.Value).ToString() : "F");
				if (component.GetZDO().GetBool("Arcade_AutoFeeder", false))
				{
					string text5 = __result;
					__result = text5 + "\n<color=#98FB98>[⚡ АВТО-ЗАХРАНВАЩ САНДЪК ⚡]</color>\n<color=#FFFF77>[" + text4 + "]</color> <color=#AAAAAA>изключи захранването</color> | <color=#FFFF77>" + text2 + "</color> <color=#AAAAAA>преименувай</color>";
				}
				else
				{
					string text5 = __result;
					__result = text5 + "\n<color=#FFFF77>[" + text4 + "]</color> <color=#AAAAAA>авто-захранване</color> | <color=#FFFF77>" + text2 + "</color> <color=#AAAAAA>преименувай</color>";
				}
			}
		}
	}

	[HarmonyPatch(typeof(WearNTear), "Damage")]
	public static class WearNTear_Damage_Patch
	{
		public static bool Prefix(WearNTear __instance, HitData hit)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || hit == null)
			{
				return true;
			}
			if (ProtectStructures != null && !ProtectStructures.Value)
			{
				return true;
			}
			if (IsInsideActiveWard(((Component)__instance).transform.position, out var activeWard))
			{
				Character attacker = hit.GetAttacker();
				if ((Object)(object)attacker == (Object)null || !attacker.IsPlayer())
				{
					FlashWard(activeWard);
					hit.ApplyModifier(0f);
					return false;
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Destructible), "Damage")]
	public static class Destructible_Damage_Patch
	{
		public static bool Prefix(Destructible __instance, HitData hit)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || hit == null)
			{
				return true;
			}
			if (ProtectStructures != null && !ProtectStructures.Value)
			{
				return true;
			}
			if (IsInsideActiveWard(((Component)__instance).transform.position, out var activeWard))
			{
				Character attacker = hit.GetAttacker();
				if ((Object)(object)attacker == (Object)null || !attacker.IsPlayer())
				{
					FlashWard(activeWard);
					hit.ApplyModifier(0f);
					return false;
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Character), "Damage")]
	public static class Character_Damage_Patch
	{
		public static bool Prefix(Character __instance, HitData hit)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || hit == null)
			{
				return true;
			}
			if (ProtectPlayersAndPets != null && !ProtectPlayersAndPets.Value)
			{
				return true;
			}
			if ((__instance.IsPlayer() || __instance.IsTamed()) && IsInsideActiveWard(((Component)__instance).transform.position, out var activeWard))
			{
				Character attacker = hit.GetAttacker();
				if ((Object)(object)attacker != (Object)null && !attacker.IsPlayer())
				{
					FlashWard(activeWard);
					hit.ApplyModifier(0f);
					return false;
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Player), "GetMaxCarryWeight")]
	public static class Player_GetMaxCarryWeight_Patch
	{
		public static void Postfix(Player __instance, ref float __result)
		{
			if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
			{
				float num = ((ExtraCarryWeight != null) ? ExtraCarryWeight.Value : 200f);
				__result += num;
			}
		}
	}

	[HarmonyPatch(typeof(Player), "OnSpawned")]
	public static class Player_OnSpawned_Patch
	{
		public static void Postfix(Player __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && (Object)(object)Instance != (Object)null)
			{
				Instance.StartWelcomeSequence();
			}
		}
	}

	[HarmonyPatch(typeof(Game), "OnDestroy")]
	public static class Game_OnDestroy_Patch
	{
		public static void Postfix()
		{
			tradersRevealed = false;
			ClearWaypoint();
		}
	}

	[HarmonyPatch(typeof(Smelter), "UpdateSmelter")]
	public static class Smelter_UpdateSmelter_Patch
	{
		public static void Prefix(Smelter __instance)
		{
			if (!((Object)(object)__instance == (Object)null))
			{
				ZNetView value = Traverse.Create((object)__instance).Field("m_nview").GetValue<ZNetView>();
				if (!((Object)(object)value == (Object)null) && value.IsValid() && value.IsOwner())
				{
					AutoFeedSmelter(__instance);
				}
			}
		}
	}

	[HarmonyPatch(typeof(ZNet), "RPC_ClientHandshake")]
	public static class ZNet_RPC_ClientHandshake_Patch
	{
		public static void Postfix(ZNet __instance, ZRpc rpc, bool needPassword, string serverPasswordSalt)
		{
			if ((Object)(object)__instance == (Object)null || !needPassword || EnableAutoPassword == null || !EnableAutoPassword.Value || AutoServerPassword == null || string.IsNullOrEmpty(AutoServerPassword.Value))
			{
				return;
			}
			try
			{
				Traverse.Create((object)__instance).Method("OnPasswordEntered", new object[1] { AutoServerPassword.Value }).GetValue();
			}
			catch
			{
			}
		}
	}

	[HarmonyPatch(typeof(ZNet), "InPasswordDialog")]
	public static class ZNet_InPasswordDialog_Patch
	{
		public static void Postfix(ZNet __instance, ref bool __result)
		{
			if ((Object)(object)__instance == (Object)null || !__result || EnableAutoPassword == null || !EnableAutoPassword.Value || AutoServerPassword == null || string.IsNullOrEmpty(AutoServerPassword.Value))
			{
				return;
			}
			try
			{
				Traverse.Create((object)__instance).Method("OnPasswordEntered", new object[1] { AutoServerPassword.Value }).GetValue();
				__result = false;
			}
			catch
			{
			}
		}
	}

	[HarmonyPatch(typeof(ZNet), "OnPasswordEntered")]
	public static class ZNet_OnPasswordEntered_Patch
	{
		public static void Prefix(string pwd)
		{
			if (!string.IsNullOrEmpty(pwd) && SaveEnteredPassword != null && SaveEnteredPassword.Value && AutoServerPassword != null && AutoServerPassword.Value != pwd)
			{
				AutoServerPassword.Value = pwd;
				if ((Object)(object)Instance != (Object)null)
				{
					((BaseUnityPlugin)Instance).Config.Save();
				}
			}
		}
	}

	public const string ModGUID = "com.arcaderoom.arcadehelper";

	public const string ModName = "Arcade Helper";

	public const string ModVersion = "2.4.0";

	public static ArcadeHelperPlugin Instance;

	private readonly Harmony harmony = new Harmony("com.arcaderoom.arcadehelper");

	public static bool tradersRevealed = false;

	public static ConfigEntry<bool> EnableAutoPassword;

	public static ConfigEntry<string> AutoServerPassword;

	public static ConfigEntry<bool> SaveEnteredPassword;

	public static ConfigEntry<bool> ShowPortalNames;

	public static ConfigEntry<float> PortalNameDistance;

	public static ConfigEntry<Color> PortalNameColor;

	public static ConfigEntry<int> PortalFontSize;

	public static ConfigEntry<bool> ShowChestNames;

	public static ConfigEntry<KeyCode> ChestRenameKey;

	public static ConfigEntry<float> ChestNameDistance;

	public static ConfigEntry<Color> ChestNameColor;

	public static ConfigEntry<int> ChestFontSize;

	public static ConfigEntry<float> ChestHeightOffset;

	public static ConfigEntry<float> ChestForwardOffset;

	public static ConfigEntry<bool> EnableLightBeacon;

	public static ConfigEntry<bool> EnableHUDNavigation;

	public static ConfigEntry<KeyCode> StopNavigationKey;

	public static ConfigEntry<float> ArrivalDistance;

	public static ConfigEntry<Color> BeaconColor;

	public static ConfigEntry<KeyCode> ToggleAutoFeederKey;

	public static ConfigEntry<float> FeedingRadius;

	public static ConfigEntry<bool> AutoFeedCoal;

	public static ConfigEntry<bool> AutoFeedOre;

	public static ConfigEntry<bool> EnableWardProtection;

	public static ConfigEntry<bool> ProtectStructures;

	public static ConfigEntry<bool> ProtectPlayersAndPets;

	public static ConfigEntry<float> ExtraCarryWeight;

	public static ConfigEntry<bool> AutoCleanDeathPin;

	public static ConfigEntry<bool> AutoRevealTraders;

	public static ConfigEntry<bool> ShowWelcomeMessage;

	public static ConfigEntry<string> WelcomeMessageText;

	public static Vector3? ActiveWaypoint;

	public static string ActiveWaypointName = "";

	private static GameObject beaconObj;

	private static LineRenderer beaconLine;

	private void Awake()
	{
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Expected O, but got Unknown
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Expected O, but got Unknown
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Expected O, but got Unknown
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Expected O, but got Unknown
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Expected O, but got Unknown
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_029c: Expected O, but got Unknown
		//IL_0334: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Expected O, but got Unknown
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d5: Expected O, but got Unknown
		//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b3: Expected O, but got Unknown
		Instance = this;
		EnableAutoPassword = ((BaseUnityPlugin)this).Config.Bind<bool>("0. Server Login (Вход в сървър)", "EnableAutoPassword", true, "Автоматично въвеждане на паролата при свързване със сървър.");
		AutoServerPassword = ((BaseUnityPlugin)this).Config.Bind<string>("0. Server Login (Вход в сървър)", "AutoServerPassword", "", "Парола за сървъра (може да я въведете тук в F1 менюто или модът ще я запомни автоматично).");
		SaveEnteredPassword = ((BaseUnityPlugin)this).Config.Bind<bool>("0. Server Login (Вход в сървър)", "SaveEnteredPassword", true, "Автоматично запомняне на паролата в настройките, когато я въведете в играта.");
		ShowPortalNames = ((BaseUnityPlugin)this).Config.Bind<bool>("1. Portals (Портали)", "ShowPortalNames", true, "Показване на светещи плаващи имена в средата на порталите.");
		PortalNameDistance = ((BaseUnityPlugin)this).Config.Bind<float>("1. Portals (Портали)", "PortalNameDistance", 25f, new ConfigDescription("Разстояние в метри, от което се виждат имената на порталите.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 100f), new object[0]));
		PortalNameColor = ((BaseUnityPlugin)this).Config.Bind<Color>("1. Portals (Портали)", "PortalNameColor", new Color(1f, 0.8f, 0.2f, 1f), "Цвят на светещия текст на порталите.");
		PortalFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("1. Portals (Портали)", "PortalFontSize", 18, new ConfigDescription("Базов размер на шрифта за имената на порталите.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 36), new object[0]));
		ShowChestNames = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Chest Labels (Етикети на сандъци)", "ShowChestNames", true, "Показване на 3D плаващи светещи имена над сандъците без нужда от табели.");
		ChestRenameKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("2. Chest Labels (Етикети на сандъци)", "ChestRenameKey", (KeyCode)308, "Клавиш за преименуване (по подразбиране Alt + E или единичен бутон при поглед към сандък).");
		ChestNameDistance = ((BaseUnityPlugin)this).Config.Bind<float>("2. Chest Labels (Етикети на сандъци)", "ChestNameDistance", 14f, new ConfigDescription("Разстояние в метри, от което се виждат имената на сандъците.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 40f), new object[0]));
		ChestNameColor = ((BaseUnityPlugin)this).Config.Bind<Color>("2. Chest Labels (Етикети на сандъци)", "ChestNameColor", new Color(1f, 0.95f, 0.6f, 1f), "Цвят по подразбиране за имената на сандъците.");
		ChestFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("2. Chest Labels (Етикети на сандъци)", "ChestFontSize", 14, new ConfigDescription("Размер на шрифта за етикетите на сандъците.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 28), new object[0]));
		ChestHeightOffset = ((BaseUnityPlugin)this).Config.Bind<float>("2. Chest Labels (Етикети на сандъци)", "ChestHeightOffset", 0.15f, new ConfigDescription("Вертикално отместване на текста над сандъка.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-0.5f, 1.2f), new object[0]));
		ChestForwardOffset = ((BaseUnityPlugin)this).Config.Bind<float>("2. Chest Labels (Етикети на сандъци)", "ChestForwardOffset", 0f, new ConfigDescription("Отместване напред/назад на текста спрямо сандъка.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-1f, 1f), new object[0]));
		EnableLightBeacon = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Navigation (Навигация)", "EnableLightBeacon", true, "Светещ фар / стълб от светлина до небето на маркираното място.");
		EnableHUDNavigation = ((BaseUnityPlugin)this).Config.Bind<bool>("3. Navigation (Навигация)", "EnableHUDNavigation", true, "Показване на 3D посока със стрелки и метри на екрана.");
		StopNavigationKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("3. Navigation (Навигация)", "StopNavigationKey", (KeyCode)284, "Клавиш за ръчно спиране на навигацията.");
		ArrivalDistance = ((BaseUnityPlugin)this).Config.Bind<float>("3. Navigation (Навигация)", "ArrivalDistance", 12f, new ConfigDescription("Разстояние в метри, при което навигацията се счита за завършена.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(3f, 30f), new object[0]));
		BeaconColor = ((BaseUnityPlugin)this).Config.Bind<Color>("3. Navigation (Навигация)", "BeaconColor", new Color(0.1f, 0.9f, 1f, 0.85f), "Цвят на светещия стълб на навигацията.");
		ToggleAutoFeederKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("4. Auto Feeder (Авто-сандъци)", "ToggleAutoFeederKey", (KeyCode)102, "Клавиш за включване/изключване на авто-захранващ сандък при поглед към него.");
		FeedingRadius = ((BaseUnityPlugin)this).Config.Bind<float>("4. Auto Feeder (Авто-сандъци)", "FeedingRadius", 15f, new ConfigDescription("Радиус в метри, в който фурните търсят авто-сандъци.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 50f), new object[0]));
		AutoFeedCoal = ((BaseUnityPlugin)this).Config.Bind<bool>("4. Auto Feeder (Авто-сандъци)", "AutoFeedCoal", true, "Автоматично зареждане на въглища и дърва.");
		AutoFeedOre = ((BaseUnityPlugin)this).Config.Bind<bool>("4. Auto Feeder (Авто-сандъци)", "AutoFeedOre", true, "Автоматично зареждане на сурова руда за топене.");
		EnableWardProtection = ((BaseUnityPlugin)this).Config.Bind<bool>("5. Ward Protection (Защита)", "EnableWardProtection", true, "100% неуязвимост от врагове в зоната на активен Ward (Guardian Stone).");
		ProtectStructures = ((BaseUnityPlugin)this).Config.Bind<bool>("5. Ward Protection (Защита)", "ProtectStructures", true, "Защита на сгради, стени, покриви, работилници и сандъци.");
		ProtectPlayersAndPets = ((BaseUnityPlugin)this).Config.Bind<bool>("5. Ward Protection (Защита)", "ProtectPlayersAndPets", true, "Защита на герои и опитомени животни в Ward зоната.");
		ExtraCarryWeight = ((BaseUnityPlugin)this).Config.Bind<float>("6. Player & World (Герой и свят)", "ExtraCarryWeight", 200f, new ConfigDescription("Допълнителни килограми към капацитета за носене (200 = 500кг базов).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1000f), new object[0]));
		AutoCleanDeathPin = ((BaseUnityPlugin)this).Config.Bind<bool>("6. Player & World (Герой и свят)", "AutoCleanDeathPin", true, "Автоматично изтриване на маркера за смърт (черепа) при взимане на трупа.");
		AutoRevealTraders = ((BaseUnityPlugin)this).Config.Bind<bool>("6. Player & World (Герой и свят)", "AutoRevealTraders", true, "Автоматично маркиране на търговците (Haldor, Hildir, Bog Witch) на картата.");
		ShowWelcomeMessage = ((BaseUnityPlugin)this).Config.Bind<bool>("7. Welcome Message (Поздрав)", "ShowWelcomeMessage", true, "Показване на приветствено съобщение при влизане в сървъра.");
		WelcomeMessageText = ((BaseUnityPlugin)this).Config.Bind<string>("7. Welcome Message (Поздрав)", "WelcomeMessageText", "★ Добре дошли в Arcade Room! ★", "Текст на приветственото съобщение при влизане.");
		harmony.PatchAll();
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Arcade Helper v2.4.0 successfully loaded!");
	}

	private void Update()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: 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)
		if (ActiveWaypoint.HasValue)
		{
			if ((StopNavigationKey != null && Input.GetKeyDown(StopNavigationKey.Value)) || (Minimap.IsOpen() && (Input.GetKeyDown((KeyCode)127) || Input.GetKeyDown((KeyCode)8))))
			{
				ClearWaypoint();
				if ((Object)(object)MessageHud.instance != (Object)null)
				{
					MessageHud.instance.ShowMessage((MessageType)1, "<color=#FFA500>✖ Навигацията е спряна.</color>", 0, (Sprite)null, false, true);
				}
			}
			else if (Minimap.IsOpen() && Input.GetMouseButtonDown(1) && (Object)(object)Minimap.instance != (Object)null)
			{
				try
				{
					Vector3 value = Traverse.Create((object)Minimap.instance).Method("ScreenToWorldPoint", new object[1] { Input.mousePosition }).GetValue<Vector3>();
					if (Vector3.Distance(ActiveWaypoint.Value, value) < 250f)
					{
						ClearWaypoint();
						if ((Object)(object)MessageHud.instance != (Object)null)
						{
							MessageHud.instance.ShowMessage((MessageType)1, "<color=#FFA500>✖ Навигацията е спряна.</color>", 0, (Sprite)null, false, true);
						}
					}
				}
				catch
				{
				}
			}
		}
		if ((!((Object)(object)Chat.instance != (Object)null) || !Chat.instance.IsChatDialogWindowVisible()) && !Console.IsVisible() && !TextInput.IsVisible())
		{
			CheckChestRenameInput();
			if (ToggleAutoFeederKey != null && Input.GetKeyDown(ToggleAutoFeederKey.Value))
			{
				ToggleHoverContainerAutoFeeder();
			}
		}
	}

	private void CheckChestRenameInput()
	{
		//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_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Invalid comparison between Unknown and I4
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Invalid comparison between Unknown and I4
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Invalid comparison between Unknown and I4
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Invalid comparison between Unknown and I4
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Invalid comparison between Unknown and I4
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Invalid comparison between Unknown and I4
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Invalid comparison between Unknown and I4
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		KeyCode val = (KeyCode)((ChestRenameKey == null) ? 308 : ((int)ChestRenameKey.Value));
		bool flag = false;
		if ((int)val == 308 || (int)val == 307 || (int)val == 313)
		{
			if ((Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307) || Input.GetKey((KeyCode)313)) && Input.GetKeyDown((KeyCode)101))
			{
				flag = true;
			}
		}
		else if ((int)val == 306 || (int)val == 305)
		{
			if ((Input.GetKey((KeyCode)306) || Input.GetKey((KeyCode)305)) && Input.GetKeyDown((KeyCode)101))
			{
				flag = true;
			}
		}
		else if ((int)val == 304 || (int)val == 303)
		{
			if ((Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) && Input.GetKeyDown((KeyCode)101))
			{
				flag = true;
			}
		}
		else if (Input.GetKeyDown(val))
		{
			flag = true;
		}
		if (!flag)
		{
			return;
		}
		GameObject hoverObject = ((Humanoid)Player.m_localPlayer).GetHoverObject();
		if ((Object)(object)hoverObject == (Object)null)
		{
			return;
		}
		Container componentInParent = hoverObject.GetComponentInParent<Container>();
		if (!((Object)(object)componentInParent != (Object)null) || !((Object)(object)((Component)componentInParent).GetComponent<TombStone>() == (Object)null))
		{
			return;
		}
		if (CanAccessContainer(componentInParent))
		{
			if ((Object)(object)TextInput.instance != (Object)null)
			{
				TextInput.instance.RequestText((TextReceiver)(object)new ContainerTextReceiver(componentInParent), "Име на сандъка (поддържа цветни тагове)", 45);
			}
		}
		else if ((Object)(object)MessageHud.instance != (Object)null)
		{
			MessageHud.instance.ShowMessage((MessageType)2, "<color=#FF6666>Нямате достъп до този сандък!</color>", 0, (Sprite)null, false, true);
		}
	}

	private void OnGUI()
	{
		//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_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)Player.m_localPlayer == (Object)null) && !((Object)(object)Camera.main == (Object)null))
		{
			Vector3 position = ((Component)Player.m_localPlayer).transform.position;
			if (ShowPortalNames != null && ShowPortalNames.Value)
			{
				DrawNearbyPortalNames(position);
			}
			if (ShowChestNames != null && ShowChestNames.Value)
			{
				DrawNearbyChestNames(position);
			}
			if (EnableHUDNavigation != null && EnableHUDNavigation.Value)
			{
				DrawNavigationHUD(position);
			}
			if (ActiveWaypoint.HasValue && Minimap.IsOpen())
			{
				DrawMapNavigationControls();
			}
		}
	}

	private void DrawMapNavigationControls()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: 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_00a7: 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_00c8: 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)
		float num = 340f;
		float num2 = 36f;
		Rect val = default(Rect);
		((Rect)(ref val))..ctor((float)Screen.width / 2f - num / 2f, 18f, num, num2);
		GUIStyle val2 = new GUIStyle(GUI.skin.box);
		val2.fontSize = 14;
		val2.fontStyle = (FontStyle)1;
		val2.alignment = (TextAnchor)4;
		val2.normal.textColor = Color.white;
		string text = ((StopNavigationKey != null) ? ((object)StopNavigationKey.Value).ToString() : "F3");
		string text2 = "✖ СПРИ НАВИГАЦИЯТА / ПРЕМАХНИ МАРКЕР (" + text + ")";
		Color color = GUI.color;
		GUI.color = new Color(0.85f, 0.2f, 0.2f, 0.95f);
		if (GUI.Button(val, text2, val2))
		{
			ClearWaypoint();
			if ((Object)(object)MessageHud.instance != (Object)null)
			{
				MessageHud.instance.ShowMessage((MessageType)1, "<color=#FFA500>✖ Навигацията е спряна.</color>", 0, (Sprite)null, false, true);
			}
		}
		GUI.color = color;
	}

	private void DrawNearbyPortalNames(Vector3 playerPos)
	{
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: 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_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: 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_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_015f: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Expected O, but got Unknown
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Expected O, but got Unknown
		//IL_020f: 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_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Expected O, but got Unknown
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: 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_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: 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)
		try
		{
			float num = ((PortalNameDistance != null) ? PortalNameDistance.Value : 25f);
			Collider[] array = Physics.OverlapSphere(playerPos, num);
			List<TeleportWorld> list = new List<TeleportWorld>();
			Color val = (Color)((PortalNameColor != null) ? PortalNameColor.Value : new Color(1f, 0.8f, 0.2f, 1f));
			int num2 = ((PortalFontSize != null) ? PortalFontSize.Value : 18);
			Collider[] array2 = array;
			foreach (Collider val2 in array2)
			{
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				TeleportWorld componentInParent = ((Component)val2).GetComponentInParent<TeleportWorld>();
				if (!((Object)(object)componentInParent != (Object)null) || list.Contains(componentInParent))
				{
					continue;
				}
				list.Add(componentInParent);
				string text = "";
				try
				{
					text = Traverse.Create((object)componentInParent).Method("GetText", new object[0]).GetValue<string>();
				}
				catch
				{
				}
				if (!string.IsNullOrEmpty(text))
				{
					Vector3 val3 = ((Component)componentInParent).transform.position + Vector3.up * 1.6f;
					Vector3 val4 = Camera.main.WorldToScreenPoint(val3);
					if (val4.z > 0.4f)
					{
						float num3 = Vector3.Distance(playerPos, ((Component)componentInParent).transform.position);
						float num4 = Mathf.Clamp01((num - num3) / (num * 0.4f));
						string text2 = "✦ " + text + " ✦";
						GUIStyle val5 = new GUIStyle(GUI.skin.label);
						val5.fontSize = Mathf.Clamp((int)((float)num2 - num3 * 0.3f), 11, num2 + 4);
						val5.fontStyle = (FontStyle)1;
						val5.alignment = (TextAnchor)4;
						val5.richText = true;
						val5.normal.textColor = new Color(val.r, val.g, val.b, num4);
						Vector2 val6 = val5.CalcSize(new GUIContent(text2));
						val6.x += 18f;
						val6.y += 8f;
						float num5 = val4.x - val6.x / 2f;
						float num6 = (float)Screen.height - val4.y - val6.y / 2f;
						GUIStyle val7 = new GUIStyle(GUI.skin.box);
						Color color = GUI.color;
						GUI.color = new Color(0f, 0f, 0f, 0.65f * num4);
						GUI.Box(new Rect(num5, num6, val6.x, val6.y), GUIContent.none);
						GUI.color = color;
						GUI.Label(new Rect(num5, num6, val6.x, val6.y), text2, val5);
					}
				}
			}
		}
		catch
		{
		}
	}

	private void DrawNearbyChestNames(Vector3 playerPos)
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: 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_0193: 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_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: 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)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: 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_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Expected O, but got Unknown
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_030b: Expected O, but got Unknown
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_030b: 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_036d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			float num = ((ChestNameDistance != null) ? ChestNameDistance.Value : 14f);
			Collider[] array = Physics.OverlapSphere(playerPos, num);
			List<Container> list = new List<Container>();
			Color val = (Color)((ChestNameColor != null) ? ChestNameColor.Value : new Color(1f, 0.95f, 0.6f, 1f));
			int num2 = ((ChestFontSize != null) ? ChestFontSize.Value : 14);
			float num3 = ((ChestHeightOffset != null) ? ChestHeightOffset.Value : 0.15f);
			float num4 = ((ChestForwardOffset != null) ? ChestForwardOffset.Value : 0f);
			Collider[] array2 = array;
			Vector3 val5 = default(Vector3);
			foreach (Collider val2 in array2)
			{
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				Container componentInParent = ((Component)val2).GetComponentInParent<Container>();
				if (!((Object)(object)componentInParent != (Object)null) || list.Contains(componentInParent) || !((Object)(object)((Component)componentInParent).GetComponent<TombStone>() == (Object)null))
				{
					continue;
				}
				list.Add(componentInParent);
				ZNetView component = ((Component)componentInParent).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || component.GetZDO() == null)
				{
					continue;
				}
				string text = component.GetZDO().GetString("Arcade_ChestName", "");
				if (!string.IsNullOrEmpty(text))
				{
					Collider componentInChildren = ((Component)componentInParent).GetComponentInChildren<Collider>();
					Vector3 val3;
					Bounds bounds;
					if (!((Object)(object)componentInChildren != (Object)null))
					{
						val3 = ((Component)componentInParent).transform.position;
					}
					else
					{
						bounds = componentInChildren.bounds;
						val3 = ((Bounds)(ref bounds)).center;
					}
					Vector3 val4 = val3;
					float num5;
					if (!((Object)(object)componentInChildren != (Object)null))
					{
						num5 = ((Component)componentInParent).transform.position.y + 0.6f;
					}
					else
					{
						bounds = componentInChildren.bounds;
						num5 = ((Bounds)(ref bounds)).max.y;
					}
					float num6 = num5;
					((Vector3)(ref val5))..ctor(val4.x, num6 + num3, val4.z);
					if (Mathf.Abs(num4) > 0.001f)
					{
						val5 += ((Component)componentInParent).transform.forward * num4;
					}
					Vector3 val6 = Camera.main.WorldToScreenPoint(val5);
					if (val6.z > 0.3f)
					{
						float num7 = Vector3.Distance(playerPos, val4);
						float num8 = Mathf.Clamp01((num - num7) / (num * 0.35f));
						string text2 = "<b>" + text + "</b>";
						GUIStyle val7 = new GUIStyle(GUI.skin.label);
						val7.fontSize = Mathf.Clamp((int)((float)num2 - num7 * 0.25f), 10, num2 + 2);
						val7.fontStyle = (FontStyle)1;
						val7.alignment = (TextAnchor)4;
						val7.richText = true;
						val7.normal.textColor = new Color(val.r, val.g, val.b, num8);
						Vector2 val8 = val7.CalcSize(new GUIContent(text2));
						val8.x += 12f;
						val8.y += 4f;
						float num9 = val6.x - val8.x / 2f;
						float num10 = (float)Screen.height - val6.y - val8.y / 2f;
						Color color = GUI.color;
						GUI.color = new Color(0f, 0f, 0f, 0.7f * num8);
						GUI.Box(new Rect(num9, num10, val8.x, val8.y), GUIContent.none);
						GUI.color = color;
						GUI.Label(new Rect(num9, num10, val8.x, val8.y), text2, val7);
					}
				}
			}
		}
		catch
		{
		}
	}

	private void DrawNavigationHUD(Vector3 playerPos)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: 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_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: 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_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_00fa: 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_0103: 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_033a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: Expected O, but got Unknown
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Expected O, but got Unknown
		//IL_0378: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		if (!ActiveWaypoint.HasValue)
		{
			return;
		}
		Vector3 value = ActiveWaypoint.Value;
		float num = Vector3.Distance(playerPos, value);
		float num2 = ((ArrivalDistance != null) ? ArrivalDistance.Value : 12f);
		if (num < num2)
		{
			ClearWaypoint();
			if ((Object)(object)MessageHud.instance != (Object)null)
			{
				MessageHud.instance.ShowMessage((MessageType)2, "<color=#98FB98>★ Пристигнахте до целта! ★</color>", 0, (Sprite)null, false, true);
			}
			return;
		}
		Vector3 forward = ((Component)Camera.main).transform.forward;
		forward.y = 0f;
		((Vector3)(ref forward)).Normalize();
		Vector3 val = value - ((Component)Camera.main).transform.position;
		val.y = 0f;
		((Vector3)(ref val)).Normalize();
		float num3 = Vector3.SignedAngle(forward, val, Vector3.up);
		Vector3 val2 = value + Vector3.up * 2f;
		Vector3 val3 = Camera.main.WorldToScreenPoint(val2);
		string text = ((!string.IsNullOrEmpty(ActiveWaypointName)) ? ActiveWaypointName : "Маркер");
		string text2 = "";
		float num4 = (float)Screen.width / 2f;
		float num5 = (float)Screen.height / 2f;
		if (val3.z > 0f && val3.x >= 60f && val3.x <= (float)(Screen.width - 60) && val3.y >= 60f && val3.y <= (float)(Screen.height - 60))
		{
			text2 = "▼ " + text + " • " + (int)num + "m ▼";
			num4 = val3.x;
			num5 = (float)Screen.height - val3.y;
		}
		else if (Mathf.Abs(num3) > 135f)
		{
			text2 = "▼▼ ЗАД ВАС • " + text + " (" + (int)num + "m) ▼▼";
			num4 = (float)Screen.width / 2f;
			num5 = (float)Screen.height - 70f;
		}
		else if (num3 < 0f)
		{
			text2 = "◀◀ НАЛЯВО • " + text + " (" + (int)num + "m)";
			num4 = 140f;
			num5 = (float)Screen.height / 2f;
		}
		else
		{
			text2 = text + " (" + (int)num + "m) • НАДЯСНО ▶▶";
			num4 = (float)Screen.width - 140f;
			num5 = (float)Screen.height / 2f;
		}
		GUIStyle val4 = new GUIStyle(GUI.skin.box);
		val4.fontSize = 15;
		val4.fontStyle = (FontStyle)1;
		val4.normal.textColor = Color.yellow;
		val4.alignment = (TextAnchor)4;
		Vector2 val5 = val4.CalcSize(new GUIContent(text2));
		val5.x += 20f;
		val5.y += 10f;
		Rect val6 = default(Rect);
		((Rect)(ref val6))..ctor(num4 - val5.x / 2f, num5 - val5.y / 2f, val5.x, val5.y);
		GUI.Box(val6, text2, val4);
	}

	public static void SetWaypoint(Vector3 pos, string name)
	{
		//IL_0001: 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_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		ActiveWaypoint = pos;
		ActiveWaypointName = name;
		UpdateBeacon();
		if ((Object)(object)MessageHud.instance != (Object)null && (Object)(object)Player.m_localPlayer != (Object)null)
		{
			float num = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, pos);
			string text = ((StopNavigationKey != null) ? ((object)StopNavigationKey.Value).ToString() : "F3");
			MessageHud.instance.ShowMessage((MessageType)1, "<color=#98FB98>\ud83c\udfaf Навигация активирана: </color><color=#FFD700>" + name + "</color> (" + (int)num + "m)\n<color=#AAAAAA>[" + text + " за спиране]</color>", 0, (Sprite)null, false, true);
		}
	}

	public static void ClearWaypoint()
	{
		ActiveWaypoint = null;
		ActiveWaypointName = "";
		if ((Object)(object)beaconObj != (Object)null)
		{
			Object.Destroy((Object)(object)beaconObj);
			beaconObj = null;
			beaconLine = null;
		}
	}

	private static void UpdateBeacon()
	{
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: 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)
		//IL_00ae: Expected O, but got Unknown
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Expected O, but got Unknown
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: 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_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: 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_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
		if (!ActiveWaypoint.HasValue || (EnableLightBeacon != null && !EnableLightBeacon.Value))
		{
			if ((Object)(object)beaconObj != (Object)null)
			{
				Object.Destroy((Object)(object)beaconObj);
				beaconObj = null;
				beaconLine = null;
			}
			return;
		}
		Color startColor = (Color)((BeaconColor != null) ? BeaconColor.Value : new Color(0.1f, 0.9f, 1f, 0.85f));
		if ((Object)(object)beaconObj == (Object)null)
		{
			beaconObj = new GameObject("Arcade_Waypoint_Beacon");
			beaconLine = beaconObj.AddComponent<LineRenderer>();
			((Renderer)beaconLine).material = new Material(Shader.Find("Sprites/Default"));
			beaconLine.startColor = startColor;
			beaconLine.endColor = new Color(startColor.r, startColor.g, startColor.b, 0.35f);
			beaconLine.startWidth = 2f;
			beaconLine.endWidth = 8f;
			beaconLine.positionCount = 2;
			beaconLine.useWorldSpace = true;
		}
		else
		{
			beaconLine.startColor = startColor;
			beaconLine.endColor = new Color(startColor.r, startColor.g, startColor.b, 0.35f);
		}
		Vector3 value = ActiveWaypoint.Value;
		beaconLine.SetPosition(0, value);
		beaconLine.SetPosition(1, value + Vector3.up * 800f);
	}

	public static void RemoveDeathPinNear(Vector3 pos)
	{
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Invalid comparison between Unknown and I4
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Minimap.instance == (Object)null)
		{
			return;
		}
		try
		{
			List<PinData> value = Traverse.Create((object)Minimap.instance).Field("m_pins").GetValue<List<PinData>>();
			if (value == null)
			{
				return;
			}
			PinData val = null;
			float num = 35f;
			foreach (PinData item in value)
			{
				if (item != null && (int)item.m_type == 4)
				{
					float num2 = Vector3.Distance(item.m_pos, pos);
					if (num2 < num)
					{
						num = num2;
						val = item;
					}
				}
			}
			if (val != null)
			{
				Minimap.instance.RemovePin(val);
				if ((Object)(object)MessageHud.instance != (Object)null)
				{
					MessageHud.instance.ShowMessage((MessageType)1, "<color=#98FB98>☠ Маркерът за смърт беше автоматично премахнат от картата.</color>", 0, (Sprite)null, false, true);
				}
			}
		}
		catch
		{
		}
	}

	private void ToggleHoverContainerAutoFeeder()
	{
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		GameObject hoverObject = ((Humanoid)Player.m_localPlayer).GetHoverObject();
		if ((Object)(object)hoverObject == (Object)null)
		{
			return;
		}
		Container componentInParent = hoverObject.GetComponentInParent<Container>();
		if ((Object)(object)componentInParent == (Object)null || (Object)(object)((Component)componentInParent).GetComponent<TombStone>() != (Object)null)
		{
			return;
		}
		ZNetView component = ((Component)componentInParent).GetComponent<ZNetView>();
		if ((Object)(object)component == (Object)null || component.GetZDO() == null)
		{
			return;
		}
		bool flag = component.GetZDO().GetBool("Arcade_AutoFeeder", false);
		bool flag2 = !flag;
		component.GetZDO().Set("Arcade_AutoFeeder", flag2);
		if ((Object)(object)MessageHud.instance != (Object)null)
		{
			if (flag2)
			{
				MessageHud.instance.ShowMessage((MessageType)2, "<color=#98FB98>⚡ Сандъкът е активиран като [АВТО-ЗАХРАНВАЩ]! ⚡</color>\n<color=#FFD700>Фурните ще взимат въглища, дърва и руда САМО от него.</color>", 0, (Sprite)null, false, true);
			}
			else
			{
				MessageHud.instance.ShowMessage((MessageType)2, "<color=#FFA500>✖ Авто-захранването за този сандък е ИЗКЛЮЧЕНО.</color>", 0, (Sprite)null, false, true);
			}
		}
	}

	public static bool IsInsideActiveWard(Vector3 point, out PrivateArea activeWard)
	{
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		activeWard = null;
		if (EnableWardProtection != null && !EnableWardProtection.Value)
		{
			return false;
		}
		try
		{
			List<PrivateArea> value = Traverse.Create(typeof(PrivateArea)).Field("m_allAreas").GetValue<List<PrivateArea>>();
			if (value == null)
			{
				return false;
			}
			foreach (PrivateArea item in value)
			{
				if (!((Object)(object)item == (Object)null))
				{
					Traverse val = Traverse.Create((object)item);
					if (val.Method("IsEnabled", new object[0]).GetValue<bool>() && val.Method("IsInside", new object[2] { point, 0f }).GetValue<bool>())
					{
						activeWard = item;
						return true;
					}
				}
			}
		}
		catch
		{
		}
		return false;
	}

	public static void FlashWard(PrivateArea ward)
	{
		if ((Object)(object)ward == (Object)null)
		{
			return;
		}
		try
		{
			Traverse.Create((object)ward).Method("FlashShield", new object[1] { true }).GetValue();
		}
		catch
		{
		}
	}

	public void StartWelcomeSequence()
	{
		((MonoBehaviour)this).StopAllCoroutines();
		((MonoBehaviour)this).StartCoroutine(WelcomeCoroutine());
	}

	private IEnumerator WelcomeCoroutine()
	{
		yield return (object)new WaitForSeconds(3.5f);
		if (AutoRevealTraders != null && AutoRevealTraders.Value)
		{
			RevealSingleTraders();
		}
		if (ShowWelcomeMessage != null && ShowWelcomeMessage.Value && (Object)(object)MessageHud.instance != (Object)null)
		{
			string text = ((WelcomeMessageText != null) ? WelcomeMessageText.Value : "★ Добре дошли в Arcade Room! ★");
			MessageHud.instance.ShowMessage((MessageType)2, "<color=#FFD700>" + text + "</color>", 0, (Sprite)null, false, true);
		}
	}

	public static void RevealSingleTraders()
	{
		//IL_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: 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)
		if (tradersRevealed || (Object)(object)Minimap.instance == (Object)null || (Object)(object)ZoneSystem.instance == (Object)null || ZoneSystem.instance.m_locationInstances == null || ZoneSystem.instance.m_locationInstances.Count == 0)
		{
			return;
		}
		try
		{
			List<PinData> value = Traverse.Create((object)Minimap.instance).Field("m_pins").GetValue<List<PinData>>();
			if (value != null)
			{
				List<PinData> list = new List<PinData>();
				foreach (PinData item in value)
				{
					if (item != null && !string.IsNullOrEmpty(item.m_name) && (item.m_name.Contains("Търговец") || item.m_name.Contains("Хилдир") || item.m_name.Contains("Вещица") || item.m_name.Contains("Bog Witch") || item.m_name.Contains("Haldor") || item.m_name.Contains("Hildir")))
					{
						list.Add(item);
					}
				}
				foreach (PinData item2 in list)
				{
					Minimap.instance.RemovePin(item2);
				}
			}
		}
		catch
		{
		}
		Vector3? bestTraderLocation = GetBestTraderLocation("vendor_blackforest", "haldor", "vendor");
		Vector3? bestTraderLocation2 = GetBestTraderLocation("hildir_camp", "hildir");
		Vector3? bestTraderLocation3 = GetBestTraderLocation("bogwitch", "witch");
		if (bestTraderLocation.HasValue)
		{
			Minimap.instance.DiscoverLocation(bestTraderLocation.Value, (PinType)3, "Haldor (Търговец)", false);
		}
		if (bestTraderLocation2.HasValue)
		{
			Minimap.instance.DiscoverLocation(bestTraderLocation2.Value, (PinType)14, "Hildir (Хилдир)", false);
		}
		if (bestTraderLocation3.HasValue)
		{
			Minimap.instance.DiscoverLocation(bestTraderLocation3.Value, (PinType)3, "Bog Witch (Вещица)", false);
		}
		tradersRevealed = true;
	}

	private static Vector3? GetBestTraderLocation(params string[] matchKeywords)
	{
		//IL_006b: 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_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)ZoneSystem.instance == (Object)null || ZoneSystem.instance.m_locationInstances == null)
		{
			return null;
		}
		Vector3? result = null;
		float num = float.MaxValue;
		bool flag = false;
		foreach (KeyValuePair<Vector2s, LocationInstance> locationInstance in ZoneSystem.instance.m_locationInstances)
		{
			LocationInstance value = locationInstance.Value;
			if (value.m_location == null || string.IsNullOrEmpty(value.m_location.m_name))
			{
				continue;
			}
			string text = value.m_location.m_name.ToLower();
			bool flag2 = false;
			foreach (string value2 in matchKeywords)
			{
				if (text.Contains(value2))
				{
					flag2 = true;
					break;
				}
			}
			if (!flag2)
			{
				continue;
			}
			float num2 = Vector3.Distance(value.m_position, Vector3.zero);
			if (value.m_placed)
			{
				if (!flag || num2 < num)
				{
					flag = true;
					num = num2;
					result = value.m_position;
				}
			}
			else if (!flag && num2 < num)
			{
				num = num2;
				result = value.m_position;
			}
		}
		return result;
	}

	public static void AutoFeedSmelter(Smelter smelter)
	{
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02de: Unknown result type (might be due to invalid IL or missing references)
		//IL_058b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0596: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)smelter == (Object)null)
		{
			return;
		}
		float radius = ((FeedingRadius != null) ? FeedingRadius.Value : 15f);
		List<Container> list = null;
		Traverse val = Traverse.Create((object)smelter);
		if (AutoFeedCoal != null && AutoFeedCoal.Value && (Object)(object)smelter.m_fuelItem != (Object)null)
		{
			float num = val.Method("GetFuel", new object[0]).GetValue<float>();
			int maxFuel = smelter.m_maxFuel;
			int num2 = maxFuel - (int)Math.Ceiling(num);
			if (num2 > 0)
			{
				list = GetNearbyContainers(((Component)smelter).transform.position, radius);
				string text = ((smelter.m_fuelItem.m_itemData != null && smelter.m_fuelItem.m_itemData.m_shared != null) ? smelter.m_fuelItem.m_itemData.m_shared.m_name : "");
				string name = ((Object)((Component)smelter.m_fuelItem).gameObject).name;
				foreach (Container item in list)
				{
					if (num2 <= 0)
					{
						break;
					}
					Inventory inventory = item.GetInventory();
					if (inventory == null)
					{
						continue;
					}
					List<ItemData> allItems = inventory.GetAllItems();
					int num3 = allItems.Count - 1;
					while (num3 >= 0 && num2 > 0)
					{
						ItemData val2 = allItems[num3];
						if (val2 != null && ((!string.IsNullOrEmpty(text) && val2.m_shared.m_name == text) || ((Object)(object)val2.m_dropPrefab != (Object)null && ((Object)val2.m_dropPrefab).name == name) || val2.m_shared.m_name == "$item_coal" || val2.m_shared.m_name == "Coal" || val2.m_shared.m_name == "$item_wood" || val2.m_shared.m_name == "Wood"))
						{
							int num4 = Math.Min(num2, val2.m_stack);
							inventory.RemoveItem(val2, num4);
							val.Method("SetFuel", new object[1] { num + (float)num4 }).GetValue();
							num += (float)num4;
							num2 -= num4;
							SaveContainer(item);
							if (smelter.m_fuelAddedEffects != null)
							{
								smelter.m_fuelAddedEffects.Create(((Component)smelter).transform.position, ((Component)smelter).transform.rotation, (Transform)null, 1f, -1, default(ZDOID));
							}
						}
						num3--;
					}
				}
			}
		}
		if (AutoFeedOre == null || !AutoFeedOre.Value || smelter.m_conversion == null || smelter.m_conversion.Count <= 0)
		{
			return;
		}
		int value = val.Method("GetQueueSize", new object[0]).GetValue<int>();
		int maxOre = smelter.m_maxOre;
		int num5 = maxOre - value;
		if (num5 <= 0)
		{
			return;
		}
		if (list == null)
		{
			list = GetNearbyContainers(((Component)smelter).transform.position, radius);
		}
		foreach (Container item2 in list)
		{
			if (num5 <= 0)
			{
				break;
			}
			Inventory inventory = item2.GetInventory();
			if (inventory == null)
			{
				continue;
			}
			List<ItemData> allItems = inventory.GetAllItems();
			int num3 = allItems.Count - 1;
			while (num3 >= 0 && num5 > 0)
			{
				ItemData val2 = allItems[num3];
				if (val2 != null)
				{
					string text2 = (((Object)(object)val2.m_dropPrefab != (Object)null) ? ((Object)val2.m_dropPrefab).name : val2.m_shared.m_name);
					ItemConversion value2 = val.Method("GetItemConversion", new object[1] { text2 }).GetValue<ItemConversion>();
					if (value2 == null)
					{
						value2 = val.Method("GetItemConversion", new object[1] { val2.m_shared.m_name }).GetValue<ItemConversion>();
					}
					if (value2 != null && (Object)(object)value2.m_from != (Object)null)
					{
						int num4 = Math.Min(num5, val2.m_stack);
						for (int i = 0; i < num4; i++)
						{
							val.Method("QueueOre", new object[2]
							{
								((Object)((Component)value2.m_from).gameObject).name,
								false
							}).GetValue();
						}
						inventory.RemoveItem(val2, num4);
						num5 -= num4;
						SaveContainer(item2);
						if (smelter.m_oreAddedEffects != null)
						{
							smelter.m_oreAddedEffects.Create(((Component)smelter).transform.position, ((Component)smelter).transform.rotation, (Transform)null, 1f, -1, default(ZDOID));
						}
					}
				}
				num3--;
			}
		}
	}

	private static void SaveContainer(Container c)
	{
		if ((Object)(object)c == (Object)null)
		{
			return;
		}
		try
		{
			Traverse.Create((object)c).Method("Save", new object[0]).GetValue();
		}
		catch
		{
		}
	}

	private static bool CanAccessContainer(Container c)
	{
		if ((Object)(object)c == (Object)null)
		{
			return false;
		}
		try
		{
			return Traverse.Create((object)c).Method("CheckAccess", new object[1] { 0L }).GetValue<bool>();
		}
		catch
		{
			return true;
		}
	}

	private static List<Container> GetNearbyContainers(Vector3 position, float radius)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: 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)
		List<Container> list = new List<Container>();
		Collider[] array = Physics.OverlapSphere(position, radius);
		Collider[] array2 = array;
		foreach (Collider val in array2)
		{
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			Container componentInParent = ((Component)val).GetComponentInParent<Container>();
			if ((Object)(object)componentInParent != (Object)null && !list.Contains(componentInParent) && (Object)(object)((Component)componentInParent).GetComponent<TombStone>() == (Object)null)
			{
				ZNetView component = ((Component)componentInParent).GetComponent<ZNetView>();
				if ((Object)(object)component != (Object)null && component.GetZDO() != null && component.GetZDO().GetBool("Arcade_AutoFeeder", false) && componentInParent.GetInventory() != null && CanAccessContainer(componentInParent))
				{
					list.Add(componentInParent);
				}
			}
		}
		list.Sort((Container a, Container b) => Vector3.Distance(((Component)a).transform.position, position).CompareTo(Vector3.Distance(((Component)b).transform.position, position)));
		return list;
	}
}
public class ContainerTextReceiver : TextReceiver
{
	private Container container;

	private ZNetView nview;

	public ContainerTextReceiver(Container c)
	{
		container = c;
		if ((Object)(object)c != (Object)null)
		{
			nview = ((Component)c).GetComponent<ZNetView>();
		}
	}

	public string GetText()
	{
		if ((Object)(object)nview != (Object)null && nview.GetZDO() != null)
		{
			return nview.GetZDO().GetString("Arcade_ChestName", "");
		}
		return "";
	}

	public void SetText(string text)
	{
		if ((Object)(object)nview != (Object)null && nview.GetZDO() != null)
		{
			if (!nview.IsOwner())
			{
				nview.ClaimOwnership();
			}
			nview.GetZDO().Set("Arcade_ChestName", text);
		}
		if ((Object)(object)MessageHud.instance != (Object)null)
		{
			if (!string.IsNullOrEmpty(text))
			{
				MessageHud.instance.ShowMessage((MessageType)2, "<color=#98FB98>✔ Сандъкът беше преименуван на: </color>\n<b>" + text + "</b>", 0, (Sprite)null, false, true);
			}
			else
			{
				MessageHud.instance.ShowMessage((MessageType)2, "<color=#FFA500>✖ Името на сандъка беше изчистено.</color>", 0, (Sprite)null, false, true);
			}
		}
	}
}