Decompiled source of RoutePlanner v1.0.1

plugins/Routeplan.dll

Decompiled 21 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Routeplan.Ui;
using Splatform;
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: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("Routeplan")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1+1fd014236375d38e54d099ce9e2dc9ea6a436350")]
[assembly: AssemblyProduct("Routeplan")]
[assembly: AssemblyTitle("Routeplan")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Routeplan
{
	public static class Death
	{
		public static bool Enabled = true;

		public static string PinName = "";

		private static bool _primed;

		private static bool _have;

		private static Vector3 _seen;

		private const float Near = 6f;

		private static string Name()
		{
			if (!string.IsNullOrEmpty(PinName))
			{
				return PinName;
			}
			return L.GravePin;
		}

		public static void Tick()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				_primed = false;
				return;
			}
			Game instance = Game.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			PlayerProfile playerProfile = instance.GetPlayerProfile();
			if (playerProfile == null)
			{
				return;
			}
			bool flag = playerProfile.HaveDeathPoint();
			Vector3 val = (flag ? playerProfile.GetDeathPoint() : Vector3.zero);
			if (!_primed)
			{
				_primed = true;
				_have = flag;
				_seen = val;
			}
			else
			{
				if (!flag)
				{
					return;
				}
				if (_have)
				{
					Vector3 val2 = val - _seen;
					if (((Vector3)(ref val2)).sqrMagnitude < 1f)
					{
						return;
					}
				}
				_have = true;
				_seen = val;
				if (Enabled)
				{
					PinData val3 = Mark(val);
					if (val3 != null)
					{
						Route.Insert(0, val3);
						Say.Show(L.DeathFirst, "death spot put first on the route");
					}
				}
			}
		}

		private unsafe static PinData Mark(Vector3 point)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Invalid comparison between Unknown and I4
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			Minimap instance = Minimap.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return null;
			}
			try
			{
				PinData closestPin = instance.GetClosestPin(point, 6f, false);
				if (closestPin != null && (int)closestPin.m_type == 4)
				{
					return closestPin;
				}
				string text = Name();
				if (instance.HaveSimilarPin(point, (PinType)4, text, true))
				{
					return instance.GetClosestPin(point, 6f, false);
				}
				PinData result = instance.AddPin(point, (PinType)4, text, true, false, 0L, default(PlatformUserID));
				ManualLogSource log = RouteplanPlugin.Log;
				Vector3 val = point;
				log.LogInfo((object)("death pin placed at " + ((object)(*(Vector3*)(&val))/*cast due to .constrained prefix*/).ToString()));
				return result;
			}
			catch (Exception e)
			{
				RouteplanPlugin.Warn("death pin", e);
				return null;
			}
		}
	}
	public static class Hud
	{
		public static bool Enabled = true;

		public static float X = 0.5f;

		public static float Y = 0.12f;

		public static bool ShowCoords = true;

		public static bool ShowIcon = true;

		public static bool Background = false;

		public static float CursorScale = 1f;

		public static float ArrowScale = 1f;

		public static float TextScale = 1f;

		public static float UiScale = 1f;

		public const float MinScale = 1f / 3f;

		public const float MaxScale = 3f;

		public const float MinUi = 0.5f;

		public const float MaxUi = 2.5f;

		public const float ChromeBase = 1.0625f;

		public static Color NameColor = Color32.op_Implicit(new Color32((byte)231, (byte)204, (byte)175, byte.MaxValue));

		public static Color InfoColor = Color32.op_Implicit(new Color32((byte)201, (byte)150, (byte)63, byte.MaxValue));

		public static Color ArrowColor = Color32.op_Implicit(new Color32((byte)231, (byte)204, (byte)175, byte.MaxValue));

		public static float Opacity = 1f;

		public const float MinOpacity = 0.15f;

		public static string KeyModifier = "Ctrl";

		public static string KeyNext = "PageDown";

		public static string KeyPrev = "PageUp";

		public static string KeyToggle = "F8";

		public static string KeyRoute = "F9";

		public static Action Moved;

		public static Action Changed;

		public static Action<bool> LanguageChanged;

		private static RectTransform _layer;

		private static HudView _view;

		private static MapBar _bar;

		private static SettingsWindow _settings;

		private static RouteWindow _route;

		private static bool _built;

		private static float _flashedAt = float.NegativeInfinity;

		private const float FlashTime = 0.5f;

		private static float _placedX = float.NaN;

		private static float _placedY = float.NaN;

		private static Vector2 _placedIn;

		public static float RouteX = 0.82f;

		public static float RouteY = 0.3f;

		public static Action RouteMoved;

		public static bool SettingsOpen
		{
			get
			{
				if (_settings != null)
				{
					return _settings.Open;
				}
				return false;
			}
		}

		public static bool RouteOpen
		{
			get
			{
				if (_route != null)
				{
					return _route.Open;
				}
				return false;
			}
		}

		public static void SetLanguage(bool russian)
		{
			if (L.Ru != russian)
			{
				L.Ru = russian;
				if (LanguageChanged != null)
				{
					LanguageChanged(russian);
				}
				Relanguage();
			}
		}

		public static void Flash()
		{
			_flashedAt = Time.unscaledTime;
		}

		private static float Flashing()
		{
			float num = Time.unscaledTime - _flashedAt;
			if (num < 0f || num > 0.5f)
			{
				return 0f;
			}
			float num2 = 1f - num / 0.5f;
			return num2 * num2;
		}

		public static void ToggleSettings()
		{
			if (_settings != null)
			{
				_settings.Toggle();
			}
		}

		public static void CloseSettings()
		{
			if (_settings != null)
			{
				_settings.Show(on: false);
			}
		}

		public static void ToggleRoute()
		{
			if (_route != null)
			{
				_route.Toggle();
			}
		}

		public static void CloseRoute()
		{
			if (_route != null)
			{
				_route.Show(on: false);
			}
		}

		private static bool Build()
		{
			if (_built && (Object)(object)_layer == (Object)null)
			{
				Forget();
			}
			if (_built)
			{
				return true;
			}
			if ((Object)(object)UiKit.CanvasRoot == (Object)null)
			{
				UiKit.Forget();
			}
			if (!UiKit.Init())
			{
				return false;
			}
			_layer = Layer();
			_view = new HudView((Transform)(object)_layer, "arrow", grabbable: true);
			_view.MakeDraggable(Dropped);
			_view.Show(on: false);
			_bar = new MapBar((Transform)(object)_layer, ToggleSettings);
			_bar.Show(on: false);
			_settings = new SettingsWindow((Transform)(object)_layer);
			_settings.Changed = delegate
			{
				if (Changed != null)
				{
					Changed();
				}
			};
			_route = new RouteWindow((Transform)(object)_layer);
			_route.X = RouteX;
			_route.Y = RouteY;
			_route.Moved = delegate
			{
				RouteX = _route.X;
				RouteY = _route.Y;
				if (RouteMoved != null)
				{
					RouteMoved();
				}
			};
			_built = true;
			return true;
		}

		private static RectTransform Layer()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			Canvas val = ((Component)UiKit.CanvasRoot).GetComponent<Canvas>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)UiKit.CanvasRoot).GetComponentInParent<Canvas>();
			}
			GameObject val2 = new GameObject("RoutePlanner", new Type[3]
			{
				typeof(RectTransform),
				typeof(Canvas),
				typeof(GraphicRaycaster)
			});
			RectTransform val3 = (RectTransform)val2.transform;
			((Transform)val3).SetParent(UiKit.CanvasRoot, false);
			UiKit.Stretch(val3);
			Canvas component = val2.GetComponent<Canvas>();
			component.overrideSorting = true;
			if ((Object)(object)val != (Object)null)
			{
				component.sortingLayerID = val.sortingLayerID;
				component.sortingOrder = Highest(val.sortingLayerID) + 10;
			}
			else
			{
				component.sortingOrder = 300;
			}
			RouteplanPlugin.Log.LogInfo((object)string.Format("layer: canvas {0}, sorting layer {1} ({2}), order {3}, raycasters {4}", ((Object)(object)val != (Object)null) ? ((Object)val).name : "NOT FOUND", component.sortingLayerID, SortingLayer.IDToName(component.sortingLayerID), component.sortingOrder, Object.FindObjectsByType<GraphicRaycaster>((FindObjectsSortMode)0).Length));
			return val3;
		}

		private static int Highest(int layer)
		{
			int num = 0;
			Canvas[] array = Object.FindObjectsByType<Canvas>((FindObjectsSortMode)0);
			foreach (Canvas val in array)
			{
				if (val.sortingLayerID == layer && val.sortingOrder > num)
				{
					num = val.sortingOrder;
				}
			}
			return num;
		}

		public static void Destroy()
		{
			if ((Object)(object)_layer != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_layer).gameObject);
			}
			Forget();
		}

		private static void Forget()
		{
			_layer = null;
			_view = null;
			_bar = null;
			_settings = null;
			_route = null;
			_built = false;
			_placedX = float.NaN;
			_placedY = float.NaN;
		}

		public static void Tick()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Invalid comparison between Unknown and I4
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			if (!Build())
			{
				return;
			}
			bool loading = Phase.Loading;
			if (((Component)_layer).gameObject.activeSelf == loading)
			{
				((Component)_layer).gameObject.SetActive(!loading);
			}
			if (loading)
			{
				return;
			}
			Minimap instance = Minimap.instance;
			bool flag = (Object)(object)instance != (Object)null && (int)instance.m_mode == 2;
			_bar.Show(flag);
			if (flag)
			{
				Player localPlayer = Player.m_localPlayer;
				_bar.Follow(_layer);
				if ((Object)(object)localPlayer != (Object)null)
				{
					_bar.Set(((Component)localPlayer).transform.position, ShowCoords);
				}
			}
			else
			{
				_settings.Show(on: false);
			}
			_settings.Tick();
			_route.Tick(_layer);
			Route.Aim aim = Route.Current();
			bool flag2 = Enabled && !flag && aim.Valid;
			_view.Show(flag2);
			if (flag2)
			{
				_view.Set(Naming.Pin(aim.Name), Distance(aim), aim.Bearing);
				_view.SetIcon(ShowIcon ? aim.Icon : null);
				float num = Flashing();
				_view.Apply(CursorScale, ArrowScale * (1f + 0.4f * num), TextScale, Opacity, Background, Color.Lerp(ArrowColor, Color.white, num * 0.85f), NameColor, InfoColor);
				_view.Grabbable(Cursor.visible);
				Place();
			}
		}

		private static string Distance(Route.Aim aim)
		{
			return L.Distance(Mathf.RoundToInt(aim.Distance), aim.Left);
		}

		private static void Place()
		{
			//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_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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: 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_00a1: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_layer == (Object)null))
			{
				Rect rect = _layer.rect;
				Vector2 size = ((Rect)(ref rect)).size;
				if (X != _placedX || Y != _placedY || !(size == _placedIn))
				{
					RectTransform root = _view.Root;
					Vector2 anchorMin = (root.anchorMax = Vector2.zero);
					root.anchorMin = anchorMin;
					root.anchoredPosition = new Vector2(X * size.x, (1f - Y) * size.y);
					_placedX = X;
					_placedY = Y;
					_placedIn = size;
				}
			}
		}

		private static void Dropped()
		{
			//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_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_0028: 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)
			//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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_layer == (Object)null || _view == null)
			{
				return;
			}
			Rect rect = _layer.rect;
			Vector2 size = ((Rect)(ref rect)).size;
			if (!(size.x <= 0f) && !(size.y <= 0f))
			{
				Vector2 anchoredPosition = _view.Root.anchoredPosition;
				X = Mathf.Clamp01(anchoredPosition.x / size.x);
				Y = Mathf.Clamp01(1f - anchoredPosition.y / size.y);
				_placedX = float.NaN;
				Place();
				if (Moved != null)
				{
					Moved();
				}
			}
		}

		public static void Relanguage()
		{
			bool settingsOpen = SettingsOpen;
			bool routeOpen = RouteOpen;
			if ((Object)(object)_layer != (Object)null)
			{
				((Component)_layer).gameObject.SetActive(false);
				Object.Destroy((Object)(object)((Component)_layer).gameObject);
			}
			Forget();
			if (Build())
			{
				if (settingsOpen)
				{
					_settings.Show(on: true);
				}
				if (routeOpen)
				{
					_route.Show(on: true);
				}
			}
		}

		public static void ResetLook()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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)
			CursorScale = (ArrowScale = (TextScale = (UiScale = 1f)));
			Opacity = 1f;
			NameColor = Color32.op_Implicit(new Color32((byte)231, (byte)204, (byte)175, byte.MaxValue));
			InfoColor = Color32.op_Implicit(new Color32((byte)201, (byte)150, (byte)63, byte.MaxValue));
			ArrowColor = Color32.op_Implicit(new Color32((byte)231, (byte)204, (byte)175, byte.MaxValue));
			Background = false;
			ShowIcon = true;
		}
	}
	public static class MapInput
	{
		[HarmonyPatch(typeof(Minimap), "OnMapLeftClick")]
		private static class LeftClick
		{
			private static bool Prefix(Minimap __instance)
			{
				if (Blocked())
				{
					return false;
				}
				if (!Held())
				{
					return true;
				}
				PinData closestPinToCursor = __instance.GetClosestPinToCursor();
				if (closestPinToCursor == null)
				{
					return true;
				}
				Take(closestPinToCursor);
				return false;
			}
		}

		[HarmonyPatch(typeof(Minimap), "OnMapDblClick")]
		private static class DoubleClick
		{
			private static bool Prefix(Minimap __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_002f: 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_0032: 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)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				if (Blocked())
				{
					return false;
				}
				if (!Held())
				{
					return true;
				}
				PinData closestPinToCursor = __instance.GetClosestPinToCursor();
				if (closestPinToCursor != null)
				{
					Take(closestPinToCursor);
					return false;
				}
				Vector3 val = __instance.ScreenToWorldPoint(MousePosition());
				Take(__instance.AddPin(val, MarkType, Name(), true, false, 0L, default(PlatformUserID)));
				return false;
			}
		}

		[HarmonyPatch(typeof(Minimap), "RemovePinUnderPointer")]
		private static class RightClick
		{
			private static bool Prefix(Minimap __instance)
			{
				if (Blocked())
				{
					return false;
				}
				if (!Held())
				{
					return true;
				}
				PinData closestPinToCursor = __instance.GetClosestPinToCursor();
				if (closestPinToCursor == null)
				{
					Say.Show(L.NoPinUnderCursor, "no pin under the cursor");
					return false;
				}
				Take(closestPinToCursor);
				return false;
			}
		}

		[HarmonyPatch(typeof(Minimap), "OnMapLeftDown")]
		private static class LeftDown
		{
			private static bool Prefix()
			{
				return !Blocked();
			}
		}

		[HarmonyPatch(typeof(Minimap), "OnMapLeftUp")]
		private static class LeftUp
		{
			private static bool Prefix()
			{
				return !Blocked();
			}
		}

		[HarmonyPatch(typeof(Minimap), "OnMapMiddleClick")]
		private static class MiddleClick
		{
			private static bool Prefix()
			{
				return !Blocked();
			}
		}

		public static KeyCode Modifier = (KeyCode)306;

		public static KeyCode Modifier2 = (KeyCode)305;

		public static PinType MarkType = (PinType)3;

		public static string MarkName = "";

		private static string Name()
		{
			if (!string.IsNullOrEmpty(MarkName))
			{
				return MarkName;
			}
			return L.TargetPin;
		}

		private static bool Adding()
		{
			if (!Input.GetKey((KeyCode)304))
			{
				return Input.GetKey((KeyCode)303);
			}
			return true;
		}

		private static void Take(PinData pin)
		{
			if (Adding())
			{
				Route.Append(pin);
				Say.Show(L.AddedToRoute(Naming.Pin(pin.m_name), Route.Stops.Count), "added to route, stops now " + Route.Stops.Count);
			}
			else
			{
				Route.SetActivePin(pin);
				Say.Show(L.TargetIs(Naming.Pin(pin.m_name)), "target set");
			}
		}

		public static bool Held()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (!ZInput.GetKey(Modifier, true))
			{
				return ZInput.GetKey(Modifier2, true);
			}
			return true;
		}

		private static Vector3 MousePosition()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return ZInput.pointerPosition;
		}

		private static bool Blocked()
		{
			return Hud.SettingsOpen;
		}
	}
	public static class Naming
	{
		public static string Pin(string raw)
		{
			if (string.IsNullOrEmpty(raw))
			{
				return L.UnnamedPin;
			}
			Localization instance = Localization.instance;
			if (instance == null)
			{
				return raw;
			}
			string text = instance.Localize(raw);
			if (!string.IsNullOrEmpty(text))
			{
				return text;
			}
			return raw;
		}
	}
	public static class Phase
	{
		public static bool Loading
		{
			get
			{
				try
				{
					Game instance = Game.instance;
					if ((Object)(object)instance != (Object)null && instance.WaitingForRespawn())
					{
						return true;
					}
					Hud instance2 = Hud.instance;
					return (Object)(object)instance2 != (Object)null && (Object)(object)instance2.m_loadingScreen != (Object)null && instance2.m_loadingScreen.alpha > 0.01f;
				}
				catch (Exception e)
				{
					RouteplanPlugin.Warn("loading state", e);
					return false;
				}
			}
		}

		public static bool Busy
		{
			get
			{
				if (Loading)
				{
					return true;
				}
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null))
				{
					return ((Character)localPlayer).IsDead();
				}
				return true;
			}
		}
	}
	public static class Route
	{
		public struct Stop
		{
			public string Name;

			public Vector3 Pos;
		}

		public struct Aim
		{
			public bool Valid;

			public string Name;

			public float Distance;

			public float Bearing;

			public int Left;

			public Sprite Icon;
		}

		public static float ArriveRadius = 15f;

		public static bool CheckOnArrival = true;

		public static bool Loop = false;

		private static readonly List<Stop> _stops = new List<Stop>();

		private static int _active;

		private static bool _announced;

		private static Vector3 _announcedPos;

		private const float SamePin = 1.5f;

		public static int Version { get; private set; }

		public static IList<Stop> Stops => _stops;

		public static int ActiveIndex => _active;

		public static bool Any => _stops.Count > 0;

		private static void Changed()
		{
			Version++;
		}

		public static void Add(PinData pin)
		{
			//IL_0005: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			if (pin != null && IndexOf(pin.m_pos) < 0)
			{
				_stops.Add(new Stop
				{
					Name = pin.m_name,
					Pos = pin.m_pos
				});
				Changed();
			}
		}

		public static void RemoveAt(int i)
		{
			if (i >= 0 && i < _stops.Count)
			{
				_stops.RemoveAt(i);
				if (_active > i)
				{
					_active--;
				}
				Clamp();
				Changed();
			}
		}

		public static void Clear()
		{
			_stops.Clear();
			_active = 0;
			_announced = false;
			Changed();
		}

		public static void Move(int from, int to)
		{
			if (from >= 0 && from < _stops.Count && to >= 0 && to < _stops.Count && to != from)
			{
				Stop item = _stops[from];
				_stops.RemoveAt(from);
				_stops.Insert(to, item);
				if (_active == from)
				{
					_active = to;
				}
				else if (from < _active && to >= _active)
				{
					_active--;
				}
				else if (from > _active && to <= _active)
				{
					_active++;
				}
				Clamp();
				Changed();
			}
		}

		public static void SetActive(int i)
		{
			if (i >= 0 && i < _stops.Count)
			{
				_active = i;
				Changed();
			}
		}

		public static void SetActivePin(PinData pin)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//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)
			if (pin != null)
			{
				int num = IndexOf(pin.m_pos);
				if (num >= 0)
				{
					_active = num;
					Changed();
					return;
				}
				_stops.Clear();
				_stops.Add(new Stop
				{
					Name = pin.m_name,
					Pos = pin.m_pos
				});
				_active = 0;
				Changed();
			}
		}

		public static void Append(PinData pin)
		{
			//IL_0005: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			if (pin != null && IndexOf(pin.m_pos) < 0)
			{
				_stops.Add(new Stop
				{
					Name = pin.m_name,
					Pos = pin.m_pos
				});
				Changed();
			}
		}

		public static void Insert(int index, PinData pin)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			if (pin == null)
			{
				return;
			}
			index = Mathf.Clamp(index, 0, _stops.Count);
			int num = IndexOf(pin.m_pos);
			if (num >= 0)
			{
				Stop item = _stops[num];
				_stops.RemoveAt(num);
				if (num < index)
				{
					index--;
				}
				_stops.Insert(index, item);
			}
			else
			{
				_stops.Insert(index, new Stop
				{
					Name = pin.m_name,
					Pos = pin.m_pos
				});
			}
			_active = index;
			_announced = false;
			Changed();
		}

		public static void Restore(IList<Stop> stops, int active)
		{
			_stops.Clear();
			if (stops != null)
			{
				_stops.AddRange(stops);
			}
			_active = active;
			_announced = false;
			Clamp();
			Changed();
		}

		public static int IndexOf(Vector3 pos)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: 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)
			for (int i = 0; i < _stops.Count; i++)
			{
				Vector3 val = _stops[i].Pos - pos;
				if (((Vector3)(ref val)).sqrMagnitude < 2.25f)
				{
					return i;
				}
			}
			return -1;
		}

		public static void Sync()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			Minimap instance = Minimap.instance;
			if ((Object)(object)instance == (Object)null || instance.m_pins == null)
			{
				return;
			}
			for (int num = _stops.Count - 1; num >= 0; num--)
			{
				if (instance.GetClosestPin(_stops[num].Pos, 1.5f, false) == null)
				{
					RemoveAt(num);
				}
			}
			Clamp();
		}

		public static PinData ActivePin()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!Any)
			{
				return null;
			}
			Minimap instance = Minimap.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return null;
			}
			return instance.GetClosestPin(_stops[_active].Pos, 1.5f, false);
		}

		public static Aim Current()
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00a0: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			Aim result = default(Aim);
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || !Any)
			{
				return result;
			}
			Clamp();
			Stop stop = _stops[_active];
			Vector3 val = (((Object)(object)GameCamera.instance != (Object)null) ? ((Component)GameCamera.instance).transform.forward : ((Component)localPlayer).transform.forward);
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = Vector3.forward;
			}
			((Vector3)(ref val)).Normalize();
			Vector3 val2 = stop.Pos - ((Component)localPlayer).transform.position;
			Vector3 val3 = default(Vector3);
			((Vector3)(ref val3))..ctor(val2.x, 0f, val2.z);
			result.Valid = true;
			result.Name = stop.Name;
			result.Distance = ((Vector3)(ref val3)).magnitude;
			result.Bearing = ((((Vector3)(ref val3)).sqrMagnitude < 0.0001f) ? 0f : Vector3.SignedAngle(val, val3, Vector3.up));
			result.Left = _stops.Count - _active - 1;
			PinData val4 = ActivePin();
			if (val4 != null)
			{
				result.Icon = val4.m_icon;
			}
			return result;
		}

		public static string CheckArrival()
		{
			//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_0040: 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_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			if (!Any)
			{
				return null;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return null;
			}
			Clamp();
			Stop stop = _stops[_active];
			Vector3 val = stop.Pos - ((Component)localPlayer).transform.position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude > ArriveRadius * ArriveRadius)
			{
				return null;
			}
			if (_announced)
			{
				Vector3 val2 = _announcedPos - ((Component)localPlayer).transform.position;
				val2.y = 0f;
				float num = ArriveRadius * 1.5f;
				if (((Vector3)(ref val2)).sqrMagnitude > num * num)
				{
					_announced = false;
				}
			}
			if (_announced)
			{
				Vector3 val3 = _announcedPos - stop.Pos;
				if (((Vector3)(ref val3)).sqrMagnitude < 2.25f)
				{
					return null;
				}
			}
			_announced = true;
			_announcedPos = stop.Pos;
			if (CheckOnArrival)
			{
				PinData val4 = ActivePin();
				if (val4 != null)
				{
					val4.m_checked = true;
				}
			}
			if (_active + 1 < _stops.Count)
			{
				_active++;
				Changed();
			}
			else if (Loop && _stops.Count > 1)
			{
				_active = 0;
				Changed();
			}
			else
			{
				Clear();
			}
			return stop.Name;
		}

		public static void Advance()
		{
			if (Any)
			{
				_active++;
				if (_active >= _stops.Count)
				{
					_active = ((!Loop) ? (_stops.Count - 1) : 0);
				}
				Changed();
			}
		}

		public static void Back()
		{
			if (Any)
			{
				_active--;
				if (_active < 0)
				{
					_active = (Loop ? (_stops.Count - 1) : 0);
				}
				Changed();
			}
		}

		private static void Clamp()
		{
			if (_stops.Count == 0)
			{
				_active = 0;
				return;
			}
			if (_active < 0)
			{
				_active = 0;
			}
			if (_active >= _stops.Count)
			{
				_active = _stops.Count - 1;
			}
		}
	}
	[BepInPlugin("dev.forgeplanner.routeplan", "RoutePlanner", "1.0.1")]
	[BepInProcess("valheim.exe")]
	public class RouteplanPlugin : BaseUnityPlugin
	{
		public const string Guid = "dev.forgeplanner.routeplan";

		public const string Version = "1.0.1";

		internal static ManualLogSource Log;

		private ConfigEntry<KeyboardShortcut> _next;

		private ConfigEntry<KeyboardShortcut> _prev;

		private ConfigEntry<KeyboardShortcut> _toggleHud;

		private ConfigEntry<KeyboardShortcut> _toggleRoute;

		private ConfigEntry<float> _routeX;

		private ConfigEntry<float> _routeY;

		private ConfigEntry<float> _arriveRadius;

		private ConfigEntry<bool> _checkOnArrival;

		private ConfigEntry<bool> _loop;

		private ConfigEntry<bool> _hud;

		private ConfigEntry<bool> _hudCoords;

		private ConfigEntry<bool> _hudBack;

		private ConfigEntry<string> _colArrow;

		private ConfigEntry<string> _colName;

		private ConfigEntry<string> _colInfo;

		private ConfigEntry<float> _hudX;

		private ConfigEntry<float> _hudY;

		private ConfigEntry<float> _arrowScale;

		private ConfigEntry<float> _textScale;

		private ConfigEntry<float> _uiScale;

		private ConfigEntry<float> _cursorScale;

		private ConfigEntry<float> _opacity;

		private ConfigEntry<bool> _playSound;

		private ConfigEntry<bool> _showIcon;

		private ConfigEntry<bool> _pinDeath;

		private ConfigEntry<string> _sound;

		private ConfigEntry<string> _deathName;

		private ConfigEntry<float> _soundVolume;

		private ConfigEntry<bool> _listSounds;

		private ConfigEntry<bool> _russian;

		private ConfigEntry<KeyCode> _modifier;

		private ConfigEntry<string> _markName;

		private Harmony _harmony;

		private bool _writing;

		private static readonly HashSet<string> _warned = new HashSet<string>();

		private void Awake()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Expected O, but got Unknown
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Expected O, but got Unknown
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Expected O, but got Unknown
			//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Expected O, but got Unknown
			//IL_03f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Expected O, but got Unknown
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Expected O, but got Unknown
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_060b: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			_next = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Next", new KeyboardShortcut((KeyCode)281, Array.Empty<KeyCode>()), "Skip to the next stop of the route without walking there.");
			_prev = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Previous", new KeyboardShortcut((KeyCode)280, Array.Empty<KeyCode>()), "Go back to the previous stop.");
			_toggleHud = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "ToggleHud", new KeyboardShortcut((KeyCode)289, Array.Empty<KeyCode>()), "Show or hide the on-screen arrow block. Coordinates, the map itself and the settings window are not affected.");
			_toggleRoute = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "ToggleRoute", new KeyboardShortcut((KeyCode)290, Array.Empty<KeyCode>()), "Show or hide the list of stops. Not the same key as ToggleHud - that one shows and hides the arrow. If F9 already does something on your setup - it can touch the gamepad button preset - put any other key here.");
			_routeX = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "RouteX", 0.82f, "Route window position across the screen, 0 is the left edge.");
			_routeY = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "RouteY", 0.3f, "Route window position down the screen, 0 is the top.");
			_arriveRadius = ((BaseUnityPlugin)this).Config.Bind<float>("Route", "ArriveRadius", 2f, "How close you have to get for a stop to count as reached, in metres.");
			_checkOnArrival = ((BaseUnityPlugin)this).Config.Bind<bool>("Route", "TickOffOnArrival", true, "Tick the map pin off when you reach it, the same tick the game uses.");
			_pinDeath = ((BaseUnityPlugin)this).Config.Bind<bool>("Route", "DeathFirst", true, "After dying, put the grave at the head of the route and steer there. The rest of the route is kept - the errand is still there, it just has a detour in front of it.");
			_deathName = ((BaseUnityPlugin)this).Config.Bind<string>("Route", "DeathPinName", "", "Name of the pin the mod puts on your grave, when the game has not already put one there itself. Empty follows the mod's language; anything else is used as given, in either language.");
			_loop = ((BaseUnityPlugin)this).Config.Bind<bool>("Route", "Loop", false, "After the last stop, start over from the first one.");
			_playSound = ((BaseUnityPlugin)this).Config.Bind<bool>("Route", "PlayArrivalSound", false, "Play a sound on reaching a stop. Off by default: a noise on arriving somewhere you were already walking to interrupts more often than it informs.");
			_sound = ((BaseUnityPlugin)this).Config.Bind<string>("Route", "ArrivalSound", "sfx_lootspawn", "Name of the game's sound prefab to play on reaching a stop. The mod borrows the clip out of it and plays that, so nothing is spawned into the world. Leave it empty for silence.");
			_soundVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Route", "ArrivalVolume", 0.2f, new ConfigDescription("How loud that sound is, on top of the game's own effects volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
			_showIcon = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "PinIcon", true, "Draw the target pin's own icon beside the arrow.");
			_russian = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Russian", false, "Show the mod in Russian instead of English. The same switch sits on the flag button in the settings window. Pin names the game itself supplies are not affected - those follow the language the game is running in.");
			_listSounds = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ListSounds", false, "Write the name of every sound the loaded game has to the log, once, so one can be chosen for ArrivalSound. The names are not documented anywhere else.");
			_hud = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Enabled", true, "Show the arrow on screen.");
			_hudX = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "X", 0.5f, "Arrow position across the screen, 0 is the left edge and 1 the right.");
			_hudY = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "Y", 0.12f, "Arrow position down the screen, 0 is the top and 1 the bottom.");
			_arrowScale = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "ArrowScale", 1f, new ConfigDescription("Size of the arrow alone, inside the block.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f / 3f, 3f), Array.Empty<object>()));
			_textScale = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "TextScale", 1f, new ConfigDescription("Size of the target name and the distance line.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f / 3f, 3f), Array.Empty<object>()));
			_uiScale = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "UiScale", 1f, new ConfigDescription("Size of the settings window. The strip under the map keeps a fixed size, so enlarging the window to read it does not shove the coordinates around.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2.5f), Array.Empty<object>()));
			_cursorScale = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "CursorScale", 1f, new ConfigDescription("Size of the whole on-screen block, arrow and text together. The two scales above are relative to it.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f / 3f, 3f), Array.Empty<object>()));
			_opacity = ((BaseUnityPlugin)this).Config.Bind<float>("HUD", "Opacity", 1f, new ConfigDescription("How solid the on-screen block is, arrow and captions together. One is opaque.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.15f, 1f), Array.Empty<object>()));
			_hudCoords = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Coordinates", true, "Show your coordinates under the map while it is open.");
			_hudBack = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "Background", false, "Draw a dark box behind the text. Off by default: the text carries its own outline, and the box read as a foreign element on screen.");
			_colArrow = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "ArrowColor", "E7CCAF", "Colour of the arrow, six hex digits. The dark outline is derived from it and is not configurable: its whole job is to stay darker than the fill so the arrow reads on snow and at night.");
			_colName = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "NameColor", "E7CCAF", "Colour of the target name, six hex digits.");
			_colInfo = ((BaseUnityPlugin)this).Config.Bind<string>("Colors", "DistanceColor", "C9963F", "Colour of the distance line and the coordinates, six hex digits.");
			_modifier = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Map", "Modifier", (KeyCode)306, "Held with a map click: left click sets a new target, right click makes the pin under the cursor the target. Without it the map behaves exactly as the game does.");
			_markName = ((BaseUnityPlugin)this).Config.Bind<string>("Map", "MarkName", "", "Name given to a pin you place with the modifier held. Empty follows the mod's language; anything else is used as given.");
			if (_deathName.Value == "Надгробье")
			{
				_deathName.Value = "";
			}
			if (_markName.Value == "Цель")
			{
				_markName.Value = "";
			}
			Apply();
			Sound.Init(((Component)this).gameObject);
			Hud.Moved = SavePlace;
			Hud.RouteMoved = SaveRoutePlace;
			Hud.Changed = SaveLook;
			Hud.LanguageChanged = SaveLanguage;
			((BaseUnityPlugin)this).Config.SettingChanged += delegate
			{
				if (!_writing)
				{
					Apply();
				}
			};
			_harmony = new Harmony("dev.forgeplanner.routeplan");
			_harmony.PatchAll();
			Log.LogInfo((object)"RoutePlanner 1.0.1 loaded");
		}

		private void Apply()
		{
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: 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_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: 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_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Invalid comparison between Unknown and I4
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Invalid comparison between Unknown and I4
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: 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_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: 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_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			if (L.Ru != _russian.Value)
			{
				Hud.SetLanguage(_russian.Value);
			}
			Route.ArriveRadius = _arriveRadius.Value;
			Route.CheckOnArrival = _checkOnArrival.Value;
			Route.Loop = _loop.Value;
			Death.Enabled = _pinDeath.Value;
			Death.PinName = _deathName.Value;
			Sound.Enabled = _playSound.Value;
			Sound.Name = _sound.Value;
			Sound.Volume = _soundVolume.Value;
			Sound.List = _listSounds.Value;
			Hud.Enabled = _hud.Value;
			Hud.ArrowScale = _arrowScale.Value;
			Hud.TextScale = _textScale.Value;
			Hud.UiScale = _uiScale.Value;
			Hud.CursorScale = _cursorScale.Value;
			Hud.Opacity = _opacity.Value;
			Hud.ShowCoords = _hudCoords.Value;
			Hud.ShowIcon = _showIcon.Value;
			Hud.Background = _hudBack.Value;
			Hud.ArrowColor = Hex(_colArrow.Value, Hud.ArrowColor);
			Hud.NameColor = Hex(_colName.Value, Hud.NameColor);
			Hud.InfoColor = Hex(_colInfo.Value, Hud.InfoColor);
			MapInput.Modifier = _modifier.Value;
			MapInput.MarkName = _markName.Value;
			Hud.KeyModifier = (((int)_modifier.Value == 306 || (int)_modifier.Value == 305) ? "Ctrl" : ((object)_modifier.Value/*cast due to .constrained prefix*/).ToString());
			Hud.KeyNext = ((object)_next.Value/*cast due to .constrained prefix*/).ToString();
			Hud.KeyPrev = ((object)_prev.Value/*cast due to .constrained prefix*/).ToString();
			Hud.KeyToggle = ((object)_toggleHud.Value/*cast due to .constrained prefix*/).ToString();
			Hud.KeyRoute = ((object)_toggleRoute.Value/*cast due to .constrained prefix*/).ToString();
			Hud.X = _hudX.Value;
			Hud.Y = _hudY.Value;
			Hud.RouteX = _routeX.Value;
			Hud.RouteY = _routeY.Value;
		}

		private void SavePlace()
		{
			_writing = true;
			_hudX.Value = Hud.X;
			_hudY.Value = Hud.Y;
			_writing = false;
		}

		private void SaveRoutePlace()
		{
			_writing = true;
			_routeX.Value = Hud.RouteX;
			_routeY.Value = Hud.RouteY;
			_writing = false;
		}

		private void SaveLanguage(bool russian)
		{
			_writing = true;
			_russian.Value = russian;
			_writing = false;
		}

		private void SaveLook()
		{
			//IL_010d: 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_0137: Unknown result type (might be due to invalid IL or missing references)
			_writing = true;
			_arrowScale.Value = Mathf.Clamp(Hud.ArrowScale, 1f / 3f, 3f);
			_textScale.Value = Mathf.Clamp(Hud.TextScale, 1f / 3f, 3f);
			_uiScale.Value = Mathf.Clamp(Hud.UiScale, 0.5f, 2.5f);
			_cursorScale.Value = Mathf.Clamp(Hud.CursorScale, 1f / 3f, 3f);
			_opacity.Value = Mathf.Clamp(Hud.Opacity, 0.15f, 1f);
			_soundVolume.Value = Mathf.Clamp01(Sound.Volume);
			_hudBack.Value = Hud.Background;
			_hudCoords.Value = Hud.ShowCoords;
			_showIcon.Value = Hud.ShowIcon;
			_playSound.Value = Sound.Enabled;
			_pinDeath.Value = Death.Enabled;
			_colArrow.Value = Hex(Hud.ArrowColor);
			_colName.Value = Hex(Hud.NameColor);
			_colInfo.Value = Hex(Hud.InfoColor);
			_writing = false;
		}

		private static Color Hex(string text, Color fallback)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(text))
			{
				return fallback;
			}
			string text2 = text.Trim().TrimStart(new char[1] { '#' });
			if (text2.Length != 6)
			{
				return fallback;
			}
			try
			{
				return Color32.op_Implicit(new Color32(Convert.ToByte(text2.Substring(0, 2), 16), Convert.ToByte(text2.Substring(2, 2), 16), Convert.ToByte(text2.Substring(4, 2), 16), byte.MaxValue));
			}
			catch (Exception)
			{
				return fallback;
			}
		}

		private static string Hex(Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Color32 val = Color32.op_Implicit(c);
			return val.r.ToString("X2") + val.g.ToString("X2") + val.b.ToString("X2");
		}

		private void Update()
		{
			try
			{
				Step();
			}
			catch (Exception e)
			{
				Warn("update", e);
			}
		}

		private void Step()
		{
			//IL_0044: 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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			Storage.Tick();
			Death.Tick();
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				return;
			}
			if (Hud.SettingsOpen && Input.GetKeyDown((KeyCode)27))
			{
				Hud.CloseSettings();
			}
			if (!TextInputBusy())
			{
				KeyboardShortcut value;
				if (Route.Any)
				{
					value = _next.Value;
					if (((KeyboardShortcut)(ref value)).IsDown())
					{
						Route.Advance();
					}
				}
				if (Route.Any)
				{
					value = _prev.Value;
					if (((KeyboardShortcut)(ref value)).IsDown())
					{
						Route.Back();
					}
				}
				value = _toggleRoute.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					Hud.ToggleRoute();
				}
				value = _toggleHud.Value;
				if (((KeyboardShortcut)(ref value)).IsDown())
				{
					Hud.Enabled = !Hud.Enabled;
					_hud.Value = Hud.Enabled;
					Say.Show(Hud.Enabled ? L.ArrowShown : L.ArrowHidden, Hud.Enabled ? "arrow shown" : "arrow hidden");
				}
			}
			Sound.Ready();
			if (Route.Any && !Phase.Busy)
			{
				Route.Sync();
				string text = Route.CheckArrival();
				if (text != null)
				{
					Say.Show(L.Arrived(string.IsNullOrEmpty(text) ? L.SomeStop : Naming.Pin(text)), "arrived at a stop");
					Hud.Flash();
					Sound.Arrived();
				}
			}
		}

		internal static void Warn(string where, Exception e)
		{
			if (Log != null && _warned.Add(where + e.GetType()))
			{
				Log.LogWarning((object)(where + ": " + e.Message));
			}
		}

		private void LateUpdate()
		{
			try
			{
				Hud.Tick();
			}
			catch (Exception e)
			{
				Warn("hud", e);
			}
		}

		private static bool TextInputBusy()
		{
			if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus())
			{
				return true;
			}
			if (TextInput.IsVisible())
			{
				return true;
			}
			return false;
		}

		private void OnDestroy()
		{
			Storage.Flush();
			if (_harmony != null)
			{
				_harmony.UnpatchSelf();
			}
			Hud.Destroy();
		}
	}
	public static class Say
	{
		public static void Show(string text)
		{
			Show(text, null);
		}

		public static void Show(string text, string logged)
		{
			if ((Object)(object)MessageHud.instance != (Object)null)
			{
				MessageHud.instance.ShowMessage((MessageType)1, text, 0, (Sprite)null, false, true);
			}
			if (logged != null && RouteplanPlugin.Log != null)
			{
				RouteplanPlugin.Log.LogInfo((object)logged);
			}
		}
	}
	public static class Sound
	{
		private static readonly string[] Fallbacks = new string[5] { "sfx_lootspawn", "sfx_coins_placed", "sfx_gui_craft_item", "sfx_guardstone_permitted_add", "sfx_gui_select" };

		public static bool Enabled;

		public static string Name = "sfx_lootspawn";

		public static float Volume = 0.2f;

		public static bool List;

		private static AudioSource _out;

		private static readonly Dictionary<string, AudioClip> _clips = new Dictionary<string, AudioClip>();

		private static bool _listed;

		private static bool _complained;

		public static void Init(GameObject host)
		{
			if (!((Object)(object)_out != (Object)null) && !((Object)(object)host == (Object)null))
			{
				_out = host.AddComponent<AudioSource>();
				_out.playOnAwake = false;
				_out.spatialBlend = 0f;
				_out.ignoreListenerPause = true;
			}
		}

		public static void Ready()
		{
			ZNetScene instance = ZNetScene.instance;
			if ((Object)(object)instance != (Object)null)
			{
				Dump(instance);
			}
		}

		public static void Arrived()
		{
			if (Enabled)
			{
				AudioClip val = Clip();
				if (!((Object)(object)val == (Object)null) && !((Object)(object)_out == (Object)null))
				{
					Route();
					_out.PlayOneShot(val, Mathf.Clamp01(Volume));
				}
			}
		}

		private static void Route()
		{
			if (!((Object)(object)_out.outputAudioMixerGroup != (Object)null))
			{
				AudioMan instance = AudioMan.instance;
				if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_guiMixer != (Object)null)
				{
					_out.outputAudioMixerGroup = instance.m_guiMixer;
				}
			}
		}

		private static AudioClip Clip()
		{
			ZNetScene instance = ZNetScene.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return null;
			}
			if (_clips.TryGetValue(Name, out var value))
			{
				return value;
			}
			AudioClip val = Find(instance, Name);
			if ((Object)(object)val == (Object)null)
			{
				string[] fallbacks = Fallbacks;
				foreach (string text in fallbacks)
				{
					val = Find(instance, text);
					if (!((Object)(object)val == (Object)null))
					{
						RouteplanPlugin.Log.LogInfo((object)("arrival sound: " + Name + " not found, using " + text));
						break;
					}
				}
			}
			if ((Object)(object)val == (Object)null && !_complained)
			{
				_complained = true;
				RouteplanPlugin.Log.LogWarning((object)"arrival sound not found. Set General.ListSounds = true to write every sound the game has to the log, and pick a name for Route.ArrivalSound");
			}
			_clips[Name] = val;
			return val;
		}

		private static AudioClip Find(ZNetScene scene, string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return null;
			}
			GameObject val = null;
			try
			{
				val = scene.GetPrefab(name);
			}
			catch (Exception e)
			{
				RouteplanPlugin.Warn("prefab lookup", e);
			}
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			AudioSource[] componentsInChildren = val.GetComponentsInChildren<AudioSource>(true);
			foreach (AudioSource val2 in componentsInChildren)
			{
				if ((Object)(object)val2.clip != (Object)null)
				{
					return val2.clip;
				}
			}
			MonoBehaviour[] componentsInChildren2 = val.GetComponentsInChildren<MonoBehaviour>(true);
			foreach (MonoBehaviour val3 in componentsInChildren2)
			{
				if ((Object)(object)val3 == (Object)null)
				{
					continue;
				}
				FieldInfo field = ((object)val3).GetType().GetField("m_audioClips");
				if (field == null || field.FieldType != typeof(AudioClip[]) || !(field.GetValue(val3) is AudioClip[] array))
				{
					continue;
				}
				AudioClip[] array2 = array;
				foreach (AudioClip val4 in array2)
				{
					if ((Object)(object)val4 != (Object)null)
					{
						return val4;
					}
				}
			}
			return null;
		}

		private static void Dump(ZNetScene scene)
		{
			if (!List || _listed)
			{
				return;
			}
			_listed = true;
			List<string> list = new List<string>();
			Collect(scene.m_prefabs, list);
			Collect(scene.m_nonNetViewPrefabs, list);
			list.Sort();
			RouteplanPlugin.Log.LogInfo((object)("sounds in the game: " + list.Count));
			foreach (string item in list)
			{
				RouteplanPlugin.Log.LogInfo((object)("  " + item));
			}
		}

		private static void Collect(List<GameObject> from, List<string> into)
		{
			if (from == null)
			{
				return;
			}
			foreach (GameObject item in from)
			{
				if (!((Object)(object)item == (Object)null) && ((Object)item).name.IndexOf("sfx", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					into.Add(((Object)item).name);
				}
			}
		}
	}
	public static class Storage
	{
		private const float Gap = 3f;

		private static long _world;

		private static int _written = -1;

		private static float _due;

		private static string Folder => Path.Combine(Paths.ConfigPath, "RoutePlanner");

		private static string FileFor(long world)
		{
			return Path.Combine(Folder, "route_" + world.ToString(CultureInfo.InvariantCulture) + ".txt");
		}

		public static void Tick()
		{
			ZNet instance = ZNet.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null)
			{
				if (_world != 0L && Route.Version != _written)
				{
					Save(_world);
				}
				_world = 0L;
				return;
			}
			long num = 0L;
			try
			{
				num = instance.GetWorldUID();
			}
			catch (Exception e)
			{
				RouteplanPlugin.Warn("world id", e);
			}
			if (num != 0L)
			{
				if (num != _world)
				{
					_world = num;
					Load(num);
					_written = Route.Version;
				}
				else if (Route.Version != _written && !(Time.unscaledTime < _due))
				{
					_due = Time.unscaledTime + 3f;
					_written = Route.Version;
					Save(num);
				}
			}
		}

		public static void Flush()
		{
			if (_world != 0L && Route.Version != _written)
			{
				_written = Route.Version;
				Save(_world);
			}
		}

		private static void Save(long world)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Directory.CreateDirectory(Folder);
				string path = FileFor(world);
				if (!Route.Any)
				{
					if (File.Exists(path))
					{
						File.Delete(path);
					}
					return;
				}
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.Append("active ").Append(Route.ActiveIndex).Append('\n');
				foreach (Route.Stop stop in Route.Stops)
				{
					float x = stop.Pos.x;
					StringBuilder stringBuilder2 = stringBuilder.Append(x.ToString("R", CultureInfo.InvariantCulture)).Append('\t');
					x = stop.Pos.y;
					StringBuilder stringBuilder3 = stringBuilder2.Append(x.ToString("R", CultureInfo.InvariantCulture)).Append('\t');
					x = stop.Pos.z;
					stringBuilder3.Append(x.ToString("R", CultureInfo.InvariantCulture)).Append('\t').Append((stop.Name == null) ? "" : stop.Name.Replace('\t', ' ').Replace('\n', ' '))
						.Append('\n');
				}
				File.WriteAllText(path, stringBuilder.ToString());
			}
			catch (Exception e)
			{
				RouteplanPlugin.Warn("route save", e);
			}
		}

		private static void Load(long world)
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				string path = FileFor(world);
				if (!File.Exists(path))
				{
					Route.Clear();
					return;
				}
				List<Route.Stop> list = new List<Route.Stop>();
				int result = 0;
				string[] array = File.ReadAllLines(path);
				foreach (string text in array)
				{
					if (string.IsNullOrEmpty(text))
					{
						continue;
					}
					if (text.StartsWith("active "))
					{
						int.TryParse(text.Substring(7).Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out result);
						continue;
					}
					string[] array2 = text.Split(new char[1] { '\t' });
					if (array2.Length >= 3 && float.TryParse(array2[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array2[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3) && float.TryParse(array2[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result4))
					{
						list.Add(new Route.Stop
						{
							Pos = new Vector3(result2, result3, result4),
							Name = ((array2.Length > 3) ? array2[3] : "")
						});
					}
				}
				Route.Restore(list, result);
				if (list.Count > 0)
				{
					RouteplanPlugin.Log.LogInfo((object)("route restored, stops " + list.Count));
				}
			}
			catch (Exception e)
			{
				RouteplanPlugin.Warn("route load", e);
				Route.Clear();
			}
		}
	}
	internal static class Build
	{
		public const string Version = "1.0.1";
	}
}
namespace Routeplan.Ui
{
	public class ArrowGraphic : MaskableGraphic
	{
		private static readonly Vector2[] Shape = (Vector2[])(object)new Vector2[4]
		{
			new Vector2(0f, 0.5f),
			new Vector2(-0.5f, -0.5f),
			new Vector2(0f, -0.22f),
			new Vector2(0.5f, -0.5f)
		};

		private const float RimWidth = 0.075f;

		private const float MitreLimit = 2.6f;

		[SerializeField]
		private Color _fill = Color.white;

		[SerializeField]
		private Color _rim = Color.black;

		private readonly Vector2[] _inner = (Vector2[])(object)new Vector2[4];

		public void SetColors(Color fill, Color rim)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (!(_fill == fill) || !(_rim == rim))
			{
				_fill = fill;
				_rim = rim;
				((Graphic)this).SetVerticesDirty();
			}
		}

		protected override void OnPopulateMesh(VertexHelper vh)
		{
			//IL_0007: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			vh.Clear();
			Rect pixelAdjustedRect = ((Graphic)this).GetPixelAdjustedRect();
			Inset(Shape, 0.075f, _inner);
			for (int i = 0; i < 4; i++)
			{
				Add(vh, pixelAdjustedRect, Shape[i], _rim);
			}
			for (int j = 0; j < 4; j++)
			{
				Add(vh, pixelAdjustedRect, _inner[j], _rim);
			}
			for (int k = 0; k < 4; k++)
			{
				Add(vh, pixelAdjustedRect, _inner[k], _fill);
			}
			for (int l = 0; l < 4; l++)
			{
				int num = (l + 1) & 3;
				vh.AddTriangle(l, num, 4 + num);
				vh.AddTriangle(l, 4 + num, 4 + l);
			}
			vh.AddTriangle(8, 9, 10);
			vh.AddTriangle(8, 10, 11);
		}

		private static void Add(VertexHelper vh, Rect r, Vector2 unit, Color color)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_003d: 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)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			vh.AddVert(new Vector3(((Rect)(ref r)).center.x + unit.x * ((Rect)(ref r)).width, ((Rect)(ref r)).center.y + unit.y * ((Rect)(ref r)).height), Color32.op_Implicit(color), Vector4.op_Implicit(new Vector2(unit.x + 0.5f, unit.y + 0.5f)));
		}

		private static void Inset(Vector2[] src, float width, Vector2[] into)
		{
			//IL_0013: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0089: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			int num = src.Length;
			for (int i = 0; i < num; i++)
			{
				Vector2 val = Normal(src[(i + num - 1) % num], src[i]);
				Vector2 val2 = Normal(src[i], src[(i + 1) % num]);
				float num2 = 1f + Vector2.Dot(val, val2);
				Vector2 val3 = ((num2 > 0.0001f) ? ((val + val2) * (width / num2)) : (val2 * width));
				float num3 = width * 2.6f;
				if (((Vector2)(ref val3)).sqrMagnitude > num3 * num3)
				{
					val3 = ((Vector2)(ref val3)).normalized * num3;
				}
				into[i] = src[i] + val3;
			}
		}

		private static Vector2 Normal(Vector2 from, Vector2 to)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//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_0007: 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_000f: 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_0017: 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)
			Vector2 val = to - from;
			Vector2 normalized = ((Vector2)(ref val)).normalized;
			return new Vector2(0f - normalized.y, normalized.x);
		}
	}
	public class DragMove : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler
	{
		public RectTransform Target;

		public Action Dropped;

		private Vector2 _grab;

		public void OnBeginDrag(PointerEventData e)
		{
			//IL_002c: 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_004b: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Target == (Object)null))
			{
				Transform parent = ((Transform)Target).parent;
				RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
				if (!((Object)(object)val == (Object)null))
				{
					Vector2 val2 = default(Vector2);
					RectTransformUtility.ScreenPointToLocalPointInRectangle(val, e.position, e.pressEventCamera, ref val2);
					_grab = Target.anchoredPosition - val2;
				}
			}
		}

		public void OnDrag(PointerEventData e)
		{
			//IL_002c: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Target == (Object)null))
			{
				Transform parent = ((Transform)Target).parent;
				RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
				Vector2 val2 = default(Vector2);
				if (!((Object)(object)val == (Object)null) && RectTransformUtility.ScreenPointToLocalPointInRectangle(val, e.position, e.pressEventCamera, ref val2))
				{
					Target.anchoredPosition = val2 + _grab;
				}
			}
		}

		public void OnEndDrag(PointerEventData e)
		{
			if (Dropped != null)
			{
				Dropped();
			}
		}
	}
	public class HudView
	{
		public const float ArrowPx = 56f;

		public const float NamePx = 20f;

		public const float InfoPx = 16f;

		private const float PadPx = 6f;

		private const float GapPx = 8f;

		private const float LineFactor = 1.35f;

		private const float TextW = 240f;

		private const float IconShare = 0.55f;

		private const float IconGap = 10f;

		private readonly RectTransform _root;

		private readonly RectTransform _arrow;

		private readonly ArrowGraphic _arrowGfx;

		private readonly Image _icon;

		private readonly Image _back;

		private readonly Image _grab;

		private readonly CanvasGroup _fade;

		private readonly TextMeshProUGUI _name;

		private readonly TextMeshProUGUI _info;

		public RectTransform Root => _root;

		public bool Visible => ((Component)_root).gameObject.activeSelf;

		public HudView(Transform parent, string name, bool grabbable)
		{
			//IL_0023: 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)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: 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_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			_root = UiKit.Rect(parent, name);
			_root.pivot = new Vector2(0.5f, 0.5f);
			_fade = ((Component)_root).gameObject.AddComponent<CanvasGroup>();
			_back = UiKit.Box((Transform)(object)_root, "back", UiKit.FieldSprite, new Color(0f, 0f, 0f, 0.45f));
			((Graphic)_back).raycastTarget = false;
			((Component)_back).gameObject.SetActive(false);
			if (grabbable)
			{
				_grab = UiKit.Box((Transform)(object)_root, "grab", null, new Color(0f, 0f, 0f, 0f));
				((Graphic)_grab).raycastTarget = false;
			}
			_arrow = UiKit.Rect((Transform)(object)_root, "arrow");
			RectTransform arrow = _arrow;
			RectTransform arrow2 = _arrow;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			arrow2.anchorMax = val;
			arrow.anchorMin = val;
			_arrow.pivot = new Vector2(0.5f, 0.5f);
			_arrowGfx = ((Component)_arrow).gameObject.AddComponent<ArrowGraphic>();
			((Graphic)_arrowGfx).raycastTarget = false;
			RectTransform val2 = UiKit.Rect((Transform)(object)_root, "pin");
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			val2.anchorMax = val;
			val2.anchorMin = val;
			val2.pivot = new Vector2(0.5f, 0.5f);
			_icon = ((Component)val2).gameObject.AddComponent<Image>();
			_icon.preserveAspect = true;
			((Graphic)_icon).raycastTarget = false;
			((Component)val2).gameObject.SetActive(false);
			_name = Caption(_root, "name", 20f);
			_info = Caption(_root, "info", 16f);
		}

		private static TextMeshProUGUI Caption(RectTransform parent, string name, float size)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_004b: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = UiKit.Label((Transform)(object)parent, name, "", size, UiKit.Ink, (TextAlignmentOptions)514);
			RectTransform val = (RectTransform)((TMP_Text)obj).transform;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			val.anchorMax = val2;
			val.anchorMin = val2;
			val.pivot = new Vector2(0.5f, 0.5f);
			Widgets.GameText((TMP_Text)(object)obj);
			return obj;
		}

		public static Vector2 Measure(float arrowScale, float textScale)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			float num = 56f * arrowScale;
			float num2 = 20f * textScale * 1.35f;
			float num3 = 16f * textScale * 1.35f;
			return new Vector2(Mathf.Max(240f * textScale, num + (10f * arrowScale + num * 0.55f) * 2f + 24f), 6f + num + 8f + num2 + num3 + 6f);
		}

		public void SetIcon(Sprite icon)
		{
			bool flag = (Object)(object)icon != (Object)null;
			if ((Object)(object)_icon.sprite != (Object)(object)icon)
			{
				_icon.sprite = icon;
			}
			if (((Component)_icon).gameObject.activeSelf != flag)
			{
				((Component)_icon).gameObject.SetActive(flag);
			}
		}

		public void Set(string title, string info, float bearing)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (((TMP_Text)_name).text != title)
			{
				((TMP_Text)_name).text = title;
			}
			if (((TMP_Text)_info).text != info)
			{
				((TMP_Text)_info).text = info;
			}
			((Transform)_arrow).localRotation = Quaternion.Euler(0f, 0f, 0f - bearing);
		}

		public void Apply(float blockScale, float arrowScale, float textScale, float opacity, bool background, Color arrow, Color name, Color info)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_010f: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: 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_01a1: 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)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			float num = 56f * arrowScale;
			float num2 = 20f * textScale;
			float num3 = 16f * textScale;
			float num4 = num2 * 1.35f;
			float num5 = num3 * 1.35f;
			bool activeSelf = ((Component)_icon).gameObject.activeSelf;
			float num6 = (activeSelf ? (num * 0.55f) : 0f);
			float num7 = (activeSelf ? (10f * arrowScale) : 0f);
			float num8 = 6f + num + 8f + num4 + num5 + 6f;
			float num9 = Mathf.Max(240f * textScale, num + (num7 + num6) * 2f + 24f);
			((Transform)_root).localScale = Vector3.one * blockScale;
			_root.sizeDelta = new Vector2(num9, num8);
			float num10 = num8 / 2f;
			_arrow.sizeDelta = new Vector2(num, num);
			_arrow.anchoredPosition = new Vector2(0f, num10 - 6f - num / 2f);
			RectTransform val = (RectTransform)((Component)_icon).transform;
			val.sizeDelta = new Vector2(num6, num6);
			val.anchoredPosition = new Vector2(0f - (num / 2f + num7 + num6 / 2f), _arrow.anchoredPosition.y);
			float num11 = num10 - 6f - num - 8f;
			Put(_name, num2, num9, num4, num11 - num4 / 2f);
			Put(_info, num3, num9, num5, num11 - num4 - num5 / 2f);
			_arrowGfx.SetColors(arrow, new Color(arrow.r * 0.18f, arrow.g * 0.18f, arrow.b * 0.18f, arrow.a));
			((Graphic)_name).color = name;
			((Graphic)_info).color = info;
			_fade.alpha = opacity;
			if (((Component)_back).gameObject.activeSelf != background)
			{
				((Component)_back).gameObject.SetActive(background);
			}
		}

		private static void Put(TextMeshProUGUI t, float size, float width, float height, float centreY)
		{
			//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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (!Mathf.Approximately(((TMP_Text)t).fontSize, size))
			{
				((TMP_Text)t).fontSize = size;
			}
			RectTransform val = (RectTransform)((TMP_Text)t).transform;
			val.sizeDelta = new Vector2(width, height);
			val.anchoredPosition = new Vector2(0f, centreY);
		}

		public void Show(bool on)
		{
			if (((Component)_root).gameObject.activeSelf != on)
			{
				((Component)_root).gameObject.SetActive(on);
			}
		}

		public void MakeDraggable(Action dropped)
		{
			if (!((Object)(object)_grab == (Object)null))
			{
				DragMove dragMove = ((Component)_grab).gameObject.AddComponent<DragMove>();
				dragMove.Target = _root;
				dragMove.Dropped = dropped;
			}
		}

		public void Grabbable(bool on)
		{
			if ((Object)(object)_grab != (Object)null && ((Graphic)_grab).raycastTarget != on)
			{
				((Graphic)_grab).raycastTarget = on;
			}
		}
	}
	public static class L
	{
		public static bool Ru;

		public static string OtherLang
		{
			get
			{
				if (!Ru)
				{
					return "RU";
				}
				return "EN";
			}
		}

		public static string M => T("m", "м");

		public static string UnnamedPin => T("target", "цель");

		public static string GravePin => T("Grave", "Надгробье");

		public static string TargetPin => T("Target", "Цель");

		public static string SomeStop => T("a stop", "точка");

		public static string NoPinUnderCursor => T("No pin under the cursor", "Под курсором нет метки");

		public static string ArrowShown => T("Arrow shown", "Стрелка показана");

		public static string ArrowHidden => T("Arrow hidden", "Стрелка скрыта");

		public static string DeathFirst => T("Death spot put first on the route", "Место смерти — первой точкой маршрута");

		public static string Settings => T("Settings", "Настройки");

		public static string RouteTitle => T("Route", "Маршрут");

		public static string ClearRoute => T("clear", "очистить");

		public static string RouteEmpty => T("The route is empty.\nCtrl + Shift + click on the map adds a stop.", "Маршрут пуст.\nCtrl + Shift + клик по карте добавляет точку.");

		public static string SettingsTitle => "RoutePlanner — " + T("look", "вид");

		public static string CapSizes => T("SIZES", "РАЗМЕРЫ");

		public static string CapColour => T("COLOUR", "ЦВЕТ");

		public static string CapOther => T("OTHER", "ПРОЧЕЕ");

		public static string CapPreview => T("PREVIEW", "ПРЕВЬЮ");

		public static string CapControls => T("CONTROLS", "УПРАВЛЕНИЕ");

		public static string TabArrow => T("arrow", "стрелка");

		public static string TabName => T("name", "название");

		public static string TabDistance => T("distance", "расстояние");

		public static string SizeArrow => T("arrow", "стрелка");

		public static string SizeText => T("text", "текст");

		public static string SizeBlock => T("whole block", "блок целиком");

		public static string Red => T("red", "красный");

		public static string Green => T("green", "зелёный");

		public static string Blue => T("blue", "синий");

		public static string Opacity => T("block opacity", "прозрачность блока");

		public static string OptBackdrop => T("backdrop behind the text", "подложка под текстом");

		public static string OptCoords => T("coordinates under the map", "координаты под картой");

		public static string OptIcon => T("target icon beside the arrow", "иконка цели у стрелки");

		public static string OptDeath => T("death spot first on the route", "место смерти первой точкой");

		public static string OptSound => T("sound on reaching a stop", "звук при достижении точки");

		public static string Volume => T("volume", "громкость");

		public static string Listen => T("listen", "прослушать");

		public static string PreviewHint => T("Dark ground on the left, pale on the right:\nthe colour has to read on both.", "Слева тёмный фон, справа светлый:\nцвет должен читаться на обоих.");

		public static string ResetLook => T("Reset look", "Сбросить вид");

		public static string Close => T("Close", "Закрыть");

		public static string UiSize => T("interface size", "размер интерфейса");

		public static string PreviewName => T("Target", "Цель");

		public static string PreviewInfo => Distance(128, 2);

		private static string T(string en, string ru)
		{
			if (!Ru)
			{
				return en;
			}
			return ru;
		}

		public static string Distance(int metres, int left)
		{
			string text = metres + " " + M;
			if (left <= 0)
			{
				return text;
			}
			return text + "   ·   " + T(left + " more", "дальше ещё " + left);
		}

		public static string Arrived(string what)
		{
			return T("Arrived: " + what, "Пришли: " + what);
		}

		public static string TargetIs(string what)
		{
			return T("Target: " + what, "Цель: " + what);
		}

		public static string AddedToRoute(string what, int count)
		{
			return T("Added: " + what, "В маршрут: " + what) + "   (" + count + ")";
		}

		public static string Coords(int x, int y, int z)
		{
			return $"X {x}      Y {y}      Z {z}";
		}

		public static string Keys(string mod, string next, string prev, string toggle, string route)
		{
			string text = T("LMB", "ЛКМ");
			string text2 = T("RMB", "ПКМ");
			return T(mod + " + " + text + " on the map  —  place a pin and steer to it\n" + mod + " + " + text2 + " on a pin  —  make it the target\n" + mod + " + Shift + click  —  append a stop to the route\n" + next + " / " + prev + "  —  next and previous stop\n" + toggle + "  —  show or hide the arrow\n" + route + "  —  the list of stops\nThe block and the windows drag with the mouse while the cursor is free", mod + " + " + text + " по карте  —  поставить метку и вести к ней\n" + mod + " + " + text2 + " по метке  —  сделать её целью\n" + mod + " + Shift + клик  —  дописать точку в маршрут\n" + next + " / " + prev + "  —  следующая и предыдущая точка\n" + toggle + "  —  показать или скрыть стрелку\n" + route + "  —  список точек маршрута\nБлок и окна перетаскиваются мышью, пока курсор свободен");
		}
	}
	public class MapBar
	{
		private const char Gear = '⚙';

		private const float Scale = 1.25f;

		private readonly RectTransform _root;

		private readonly TextMeshProUGUI _coords;

		private readonly GameObject _gear;

		private const float InsetX = 120f;

		private const float InsetY = 6f;

		private readonly Vector3[] _corners = (Vector3[])(object)new Vector3[4];

		public RectTransform Root => _root;

		public MapBar(Transform parent, Action onGear)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			_root = UiKit.Rect(parent, "routeplanner map bar");
			RectTransform root = _root;
			RectTransform root2 = _root;
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			root2.anchorMax = val;
			root.anchorMin = val;
			_root.pivot = new Vector2(0f, 1f);
			((Transform)_root).localScale = Vector3.one * 1.25f;
			UiKit.Horizontal(_root, 10f);
			ContentSizeFitter obj = ((Component)_root).gameObject.AddComponent<ContentSizeFitter>();
			obj.horizontalFit = (FitMode)2;
			obj.verticalFit = (FitMode)2;
			_gear = ((Component)(((Object)(object)UiKit.Font != (Object)null && UiKit.Font.HasCharacter('⚙', false, false)) ? UiKit.Button((Transform)(object)_root, '⚙'.ToString(), 36f, 30f, (UnityAction)delegate
			{
				onGear();
			}, 19f, (TextAlignmentOptions)514) : UiKit.ButtonAuto((Transform)(object)_root, L.Settings, 30f, (UnityAction)delegate
			{
				onGear();
			}, 14f))).gameObject;
			_coords = UiKit.Label((Transform)(object)_root, "coords", "", 16f, Color.white, (TextAlignmentOptions)513);
			LayoutElement obj2 = ((Component)_coords).gameObject.AddComponent<LayoutElement>();
			obj2.minHeight = (obj2.preferredHeight = 30f);
			obj2.minWidth = (obj2.preferredWidth = 250f);
			Widgets.GameText((TMP_Text)(object)_coords);
		}

		public void Follow(RectTransform layer)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)layer == (Object)null)
			{
				return;
			}
			Minimap instance = Minimap.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_mapLarge == (Object)null)
			{
				return;
			}
			Transform transform = instance.m_mapLarge.transform;
			RectTransform val = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			if (!((Object)(object)val == (Object)null))
			{
				val.GetWorldCorners(_corners);
				Vector2 val2 = default(Vector2);
				if (RectTransformUtility.ScreenPointToLocalPointInRectangle(layer, Vector2.op_Implicit(_corners[0]), (Camera)null, ref val2))
				{
					_root.anchoredPosition = val2 + new Vector2(120f, -6f);
				}
			}
		}

		public void Set(Vector3 position, bool showCoords)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)_coords).gameObject.activeSelf != showCoords)
			{
				((Component)_coords).gameObject.SetActive(showCoords);
			}
			if (showCoords)
			{
				((TMP_Text)_coords).text = L.Coords(Mathf.RoundToInt(position.x), Mathf.RoundToInt(position.y), Mathf.RoundToInt(position.z));
			}
		}

		public void Show(bool on)
		{
			if (((Component)_root).gameObject.activeSelf != on)
			{
				((Component)_root).gameObject.SetActive(on);
			}
		}
	}
	public class RouteWindow
	{
		private class Row
		{
			public GameObject Go;

			public TextMeshProUGUI Number;

			public TextMeshProUGUI Name;

			public TextMeshProUGUI Distance;

			public Image Icon;

			public int Index;
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__Clear;
		}

		private const float WinW = 380f;

		private const float TitleH = 30f;

		private const float RowH = 30f;

		private const float Pad = 8f;

		private const int MaxRows = 9;

		private readonly RectTransform _root;

		private readonly RectTransform _list;

		private readonly TextMeshProUGUI _empty;

		private readonly List<Row> _rows = new List<Row>();

		private int _builtFor = -1;

		public float X = 0.82f;

		public float Y = 0.3f;

		public Action Moved;

		private float _placedX = float.NaN;

		private float _placedY = float.NaN;

		private Vector2 _placedIn;

		public RectTransform Root => _root;

		public bool Open
		{
			get
			{
				if ((Object)(object)_root != (Object)null)
				{
					return ((Component)_root).gameObject.activeSelf;
				}
				return false;
			}
		}

		public RouteWindow(Transform parent)
		{
			//IL_0061: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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_009d: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			//IL_01a7: 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_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Expected O, but got Unknown
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: 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_022f: 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_023a: Expected O, but got Unknown
			_root = UiKit.Rect(parent, "routeplanner route");
			_root.anchorMin = (_root.anchorMax = Vector2.zero);
			_root.pivot = new Vector2(0.5f, 0.5f);
			_root.sizeDelta = new Vector2(380f, 200f);
			UiKit.Box((Transform)(object)_root, "wood", UiKit.PanelSprite, new Color(0.22f, 0.2f, 0.17f, 0.97f));
			UiKit.Frame(_root, UiKit.Line);
			RectTransform obj = UiKit.Rect((Transform)(object)_root, "title");
			obj.anchorMin = new Vector2(0f, 1f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(0.5f, 1f);
			obj.sizeDelta = new Vector2(0f, 30f);
			((Graphic)((Component)obj).gameObject.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.25f);
			RectTransform val = (RectTransform)((TMP_Text)UiKit.Label((Transform)(object)obj, "name", L.RouteTitle, 15f, UiKit.Ink, (TextAlignmentOptions)513)).transform;
			UiKit.Stretch(val);
			val.offsetMin = new Vector2(10f, 0f);
			val.offsetMax = new Vector2(-118f, 0f);
			Place(UiKit.Button((Transform)(object)obj, Widgets.Glyph('✕', "X"), 22f, 20f, (UnityAction)delegate
			{
				Show(on: false);
			}, 14f, (TextAlignmentOptions)514), -8f);
			string clearRoute = L.ClearRoute;
			object obj2 = <>O.<0>__Clear;
			if (obj2 == null)
			{
				UnityAction val2 = Clear;
				<>O.<0>__Clear = val2;
				obj2 = (object)val2;
			}
			Place(UiKit.Button((Transform)(object)obj, clearRoute, 72f, 20f, (UnityAction)obj2, 12f, (TextAlignmentOptions)514), -36f);
			DragMove dragMove = ((Component)obj).gameObject.AddComponent<DragMove>();
			dragMove.Target = _root;
			dragMove.Dropped = Dropped;
			RectTransform val3 = UiKit.Rect((Transform)(object)_root, "frame");
			val3.anchorMin = new Vector2(0f, 0f);
			val3.anchorMax = new Vector2(1f, 1f);
			val3.offsetMin = new Vector2(8f, 8f);
			val3.offsetMax = new Vector2(-8f, -38f);
			_list = UiKit.ScrollBox(val3);
			_empty = UiKit.Label((Transform)(object)_root, "empty", L.RouteEmpty, 13f, UiKit.Dim, (TextAlignmentOptions)514);
			RectTransform val4 = (RectTransform)((TMP_Text)_empty).transform;
			val4.anchorMin = new Vector2(0f, 0f);
			val4.anchorMax = new Vector2(1f, 1f);
			val4.offsetMin = new Vector2(8f, 8f);
			val4.offsetMax = new Vector2(-8f, -38f);
			((TMP_Text)_empty).textWrappingMode = (TextWrappingModes)1;
			((Component)_root).gameObject.SetActive(false);
		}

		private static void Place(Button button, float fromRight)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: 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)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = (RectTransform)((Component)button).transform;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(1f, 0.5f);
			val.anchorMax = val2;
			val.anchorMin = val2;
			val.pivot = new Vector2(1f, 0.5f);
			val.anchoredPosition = new Vector2(fromRight, 0f);
		}

		private static void Clear()
		{
			Route.Clear();
		}

		private void Rebuild()
		{
			//IL_0102: Unknown result type (might be due to invalid IL or miss