Decompiled source of WayfarerRecall v1.2.0

WayfarerRecall.dll

Decompiled 15 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 BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WayfarerRecall")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.2.0.0")]
[assembly: AssemblyInformationalVersion("1.2.0")]
[assembly: AssemblyProduct("WayfarerRecall")]
[assembly: AssemblyTitle("WayfarerRecall")]
[assembly: AssemblyVersion("1.2.0.0")]
[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 WayfarerRecall
{
	internal struct RecallPoint
	{
		private const char Separator = '|';

		internal Vector3 Position { get; }

		internal float Yaw { get; }

		internal Quaternion Rotation => Quaternion.Euler(0f, Yaw, 0f);

		internal RecallPoint(Vector3 position, float yaw)
		{
			//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)
			Position = position;
			Yaw = yaw;
		}

		internal string Serialize()
		{
			//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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			return string.Join('|'.ToString(), Position.x.ToString("R", CultureInfo.InvariantCulture), Position.y.ToString("R", CultureInfo.InvariantCulture), Position.z.ToString("R", CultureInfo.InvariantCulture), Yaw.ToString("R", CultureInfo.InvariantCulture));
		}

		internal static bool TryParse(string value, out RecallPoint point)
		{
			//IL_0057: 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)
			point = default(RecallPoint);
			if (string.IsNullOrWhiteSpace(value))
			{
				return false;
			}
			string[] array = value.Split('|');
			if (array.Length != 4 || !TryFloat(array[0], out var result) || !TryFloat(array[1], out var result2) || !TryFloat(array[2], out var result3) || !TryFloat(array[3], out var result4))
			{
				return false;
			}
			point = new RecallPoint(new Vector3(result, result2, result3), result4);
			if (IsFinite(point.Position) && !float.IsNaN(result4))
			{
				return !float.IsInfinity(result4);
			}
			return false;
		}

		private static bool TryFloat(string value, out float result)
		{
			return float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out result);
		}

		private static bool IsFinite(Vector3 value)
		{
			//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)
			//IL_001a: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!float.IsNaN(value.x) && !float.IsInfinity(value.x) && !float.IsNaN(value.y) && !float.IsInfinity(value.y) && !float.IsNaN(value.z))
			{
				return !float.IsInfinity(value.z);
			}
			return false;
		}
	}
	internal sealed class RecallState
	{
		internal ConfigEntry<string> SavedLocation1 { get; }

		internal ConfigEntry<string> SavedLocation2 { get; }

		internal ConfigEntry<int> NextLocationIndex { get; }

		internal ConfigEntry<string> BoatUserId { get; }

		internal ConfigEntry<string> BoatObjectId { get; }

		internal ConfigEntry<string> BoatFallback { get; }

		internal ConfigEntry<string> BoatToken1 { get; }

		internal ConfigEntry<string> BoatPrefab1 { get; }

		internal RecallState(ConfigFile file, string section)
		{
			SavedLocation1 = file.Bind<string>(section, "SavedLocation1", string.Empty, "Newest non-boat departure point saved by the spawn recall.");
			SavedLocation2 = file.Bind<string>(section, "SavedLocation2", string.Empty, "Second-newest non-boat departure point saved by the spawn recall.");
			NextLocationIndex = file.Bind<int>(section, "NextLocationIndex", 0, "Which saved location the Last Location key will use next.");
			BoatUserId = file.Bind<string>(section, "BoatUserId", string.Empty, "Network owner portion of the last-used boat identifier.");
			BoatObjectId = file.Bind<string>(section, "BoatObjectId", string.Empty, "Object portion of the last-used boat identifier.");
			BoatFallback = file.Bind<string>(section, "BoatFallback", string.Empty, "Last observed position and facing of the last-used boat.");
			BoatToken1 = file.Bind<string>(section, "BoatToken1", string.Empty, "Persistent Wayfarer Recall identity token for the last-used boat.");
			BoatPrefab1 = file.Bind<string>(section, "BoatPrefab1", string.Empty, "Prefab name of the last-used boat.");
		}

		internal void PushLocation(RecallPoint point)
		{
			//IL_0016: 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)
			if (RecallPoint.TryParse(SavedLocation1.Value, out var point2) && Vector3.Distance(point2.Position, point.Position) < 1f)
			{
				SavedLocation1.Value = point.Serialize();
				NextLocationIndex.Value = 0;
			}
			else
			{
				SavedLocation2.Value = SavedLocation1.Value;
				SavedLocation1.Value = point.Serialize();
				NextLocationIndex.Value = 0;
			}
		}

		internal bool TryGetNextLocation(out RecallPoint point, out int count)
		{
			RecallPoint point2;
			bool flag = RecallPoint.TryParse(SavedLocation1.Value, out point2);
			RecallPoint point3;
			bool flag2 = RecallPoint.TryParse(SavedLocation2.Value, out point3);
			count = (flag ? 1 : 0) + (flag2 ? 1 : 0);
			point = default(RecallPoint);
			if (count == 0)
			{
				return false;
			}
			if (count == 1)
			{
				point = (flag ? point2 : point3);
				return true;
			}
			int num = NextLocationIndex.Value;
			if (num < 0 || num > 1)
			{
				num = 0;
			}
			point = ((num == 0) ? point2 : point3);
			return true;
		}

		internal void AdvanceLocation(int count)
		{
			if (count < 2)
			{
				NextLocationIndex.Value = 0;
				return;
			}
			int num = NextLocationIndex.Value;
			if (num < 0 || num > 1)
			{
				num = 0;
			}
			NextLocationIndex.Value = (num + 1) % 2;
		}
	}
	[BepInPlugin("MaddCatter.WayfarerRecall", "Wayfarer Recall", "1.2.0")]
	public sealed class WayfarerRecallPlugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ZInput), "GetKeyDown", new Type[]
		{
			typeof(KeyCode),
			typeof(bool)
		})]
		private static class SuppressVanillaEscapePatch
		{
			private static bool Prefix(KeyCode __0, ref bool __result)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Invalid comparison between Unknown and I4
				if ((int)__0 == 27 && (_playerMenuCursorActive || Time.frameCount == _suppressVanillaEscapeFrame))
				{
					__result = false;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
		private static class GameCameraUpdateMouseCapturePatch
		{
			private static bool Prefix()
			{
				if (!Input.GetKey((KeyCode)308) && !_playerMenuCursorActive)
				{
					return true;
				}
				ZCursor.LockState = (CursorLockMode)0;
				ZCursor.Show();
				return false;
			}
		}

		[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
		private static class GameCameraUpdateCameraPatch
		{
			private static bool Prefix()
			{
				if (!Input.GetKey((KeyCode)308))
				{
					return !_playerMenuCursorActive;
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(ZInput))]
		private static class AltCursorZInputPatch
		{
			[HarmonyPostfix]
			[HarmonyPatch("GetButton")]
			private static void GetButtonPostfix(string name, ref bool __result)
			{
				if (__result && ShouldSuppressAltMouseAction(name))
				{
					__result = false;
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("GetButtonDown")]
			private static void GetButtonDownPostfix(string name, ref bool __result)
			{
				if (__result && ShouldSuppressAltMouseAction(name))
				{
					__result = false;
				}
			}

			[HarmonyPostfix]
			[HarmonyPatch("GetButtonUp")]
			private static void GetButtonUpPostfix(string name, ref bool __result)
			{
				if (__result && ShouldSuppressAltMouseAction(name))
				{
					__result = false;
				}
			}
		}

		private enum NotificationMode
		{
			ErrorsOnly,
			All,
			Off
		}

		private sealed class PlayerDestination
		{
			public string Name { get; }

			public ZDOID CharacterId { get; }

			public bool HasPublicPosition { get; }

			public Vector3 Position { get; }

			public PlayerDestination(string name, ZDOID characterId, bool hasPublicPosition, Vector3 position)
			{
				//IL_000e: 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_001c: 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)
				Name = name;
				CharacterId = characterId;
				HasPublicPosition = hasPublicPosition;
				Position = position;
			}
		}

		public const string PluginGuid = "MaddCatter.WayfarerRecall";

		public const string PluginName = "Wayfarer Recall";

		public const string PluginVersion = "1.2.0";

		private const string BoatTokenZdoKey = "MaddCatter.WayfarerRecall.BoatToken";

		private const float InputCooldownSeconds = 0.35f;

		private const float BoatSaveIntervalSeconds = 3f;

		private const float BoatMoveSaveDistance = 1f;

		private const float PlayerListRefreshSeconds = 1f;

		private readonly Dictionary<string, RecallState> _states = new Dictionary<string, RecallState>();

		private readonly List<PlayerDestination> _playerDestinations = new List<PlayerDestination>();

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<KeyboardShortcut> _playerMenuKey;

		private ConfigEntry<float> _playerStatusFontSize;

		private ConfigEntry<NotificationMode> _notificationMode;

		private ConfigEntry<float> _notificationDuration;

		private ConfigFile _stateFile;

		private Harmony _harmony;

		private float _nextInputTime;

		private float _nextBoatSaveTime;

		private string _lastTrackedBoatId = string.Empty;

		private Vector3 _lastTrackedBoatPosition;

		private bool _boatTokenSearchActive;

		private string _boatTokenSearchToken = string.Empty;

		private string _boatTokenSearchPrefab = string.Empty;

		private readonly List<ZDO> _boatTokenSearchResults = new List<ZDO>();

		private int _boatTokenSearchIndex;

		private bool _wasAboardBoat;

		private string _noticeText = string.Empty;

		private float _noticeUntil;

		private bool _noticeIsError;

		private GUIStyle _noticeStyle;

		private GUIStyle _outlineStyle;

		private bool _playerMenuOpen;

		private static bool _playerMenuCursorActive;

		private static int _suppressVanillaEscapeFrame = -1;

		private bool _playerDropdownOpen;

		private int _selectedPlayerIndex;

		private float _nextPlayerListRefreshTime;

		private float _nextUiAttachAttemptTime;

		private string _playerListSignature = string.Empty;

		private InventoryGui _attachedInventoryGui;

		private GameObject _minimapPlayerButton;

		private GameObject _playerMenuBlocker;

		private GameObject _playerMenuPanel;

		private GameObject _playerDropdownButton;

		private GameObject _playerOptionsRoot;

		private GameObject _playerStatusLabel;

		private GameObject _playerPortButton;

		private GameObject _playerRefreshButton;

		private GameObject _playerCloseButton;

		private Component _nativeButtonSource;

		private Component _nativeTextSource;

		private Texture2D _compassTexture;

		private Sprite _compassSprite;

		private Texture2D _spawnIconTexture;

		private Sprite _spawnIconSprite;

		private Texture2D _locationIconTexture;

		private Sprite _locationIconSprite;

		private Texture2D _boatIconTexture;

		private Sprite _boatIconSprite;

		private Texture2D _deathIconTexture;

		private Sprite _deathIconSprite;

		private readonly List<GameObject> _playerOptionButtons = new List<GameObject>();

		private void Awake()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_005a: 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_00a7: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			Game.isModded = true;
			_harmony = new Harmony("MaddCatter.WayfarerRecall");
			_harmony.PatchAll();
			_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable Wayfarer Recall.");
			_playerMenuKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "PlayerMenu", new KeyboardShortcut((KeyCode)111, Array.Empty<KeyCode>()), "Open the menu used to teleport to another player on the server.");
			_playerStatusFontSize = ((BaseUnityPlugin)this).Config.Bind<float>("Player Travel", "StatusFontSize", 18f, new ConfigDescription("Font size used for the Port to Player status message.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(12f, 30f), Array.Empty<object>()));
			_notificationMode = ((BaseUnityPlugin)this).Config.Bind<NotificationMode>("Notifications", "Mode", NotificationMode.ErrorsOnly, "ErrorsOnly shows only problems, All shows success and error notices, and Off hides all notices.");
			_notificationDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Notifications", "DurationSeconds", 4f, new ConfigDescription("How long a notice remains visible.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
			((BaseUnityPlugin)this).Config.Save();
			string text = Path.Combine(Paths.ConfigPath, "MaddCatter.WayfarerRecall.state.cfg");
			_stateFile = new ConfigFile(text, true);
			_stateFile.SaveOnConfigSet = false;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Wayfarer Recall 1.2.0 loaded. Defaults: O player menu, Left Alt cursor.");
		}

		private void Update()
		{
			//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)
			if (_enabled == null || !_enabled.Value)
			{
				if (_playerMenuOpen)
				{
					ClosePlayerMenu();
				}
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)Game.instance == (Object)null || (Object)(object)ZNet.instance == (Object)null)
			{
				return;
			}
			GetCurrentState();
			EnsurePlayerTravelUi();
			if (Input.GetKey((KeyCode)308) || _playerMenuCursorActive)
			{
				ZCursor.LockState = (CursorLockMode)0;
				ZCursor.Show();
			}
			if (_boatTokenSearchActive)
			{
				ProcessBoatTokenSearch(localPlayer);
				return;
			}
			TrackCurrentBoat();
			if (_playerMenuOpen)
			{
				if (Input.GetKeyDown((KeyCode)27))
				{
					_suppressVanillaEscapeFrame = Time.frameCount;
					ClosePlayerMenu();
				}
				else if (Time.unscaledTime >= _nextPlayerListRefreshTime)
				{
					RefreshPlayerList();
				}
			}
			else
			{
				if (Time.unscaledTime < _nextInputTime || !CanUseHotkeys(localPlayer))
				{
					return;
				}
				try
				{
					KeyboardShortcut value = _playerMenuKey.Value;
					if (((KeyboardShortcut)(ref value)).IsDown())
					{
						OpenPlayerMenu();
						_nextInputTime = Time.unscaledTime + 0.35f;
					}
				}
				catch (Exception arg)
				{
					((BaseUnityPlugin)this).Logger.LogError((object)$"Recall failed: {arg}");
					ShowError("Recall failed; see the BepInEx log for details.");
					_nextInputTime = Time.unscaledTime + 0.35f;
				}
			}
		}

		private void OnDestroy()
		{
			DestroyPlayerTravelUi();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			if (_stateFile != null)
			{
				_stateFile.Save();
			}
		}

		private void OnGUI()
		{
			if (!string.IsNullOrEmpty(_noticeText) && Time.unscaledTime < _noticeUntil)
			{
				DrawNotice();
			}
		}

		private void DrawNotice()
		{
			//IL_005e: 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_00fb: 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_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			EnsureNoticeStyles();
			int num = Mathf.Clamp(Screen.height / 36, 20, 34);
			_noticeStyle.fontSize = num;
			_outlineStyle.fontSize = num;
			_noticeStyle.normal.textColor = (Color)(_noticeIsError ? new Color(1f, 0.93f, 0.55f, 1f) : Color.white);
			float num2 = Mathf.Min((float)Screen.width * 0.84f, 1100f);
			float num3 = Mathf.Max(72f, (float)num * 3.2f);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((float)Screen.width - num2) * 0.5f, (float)Screen.height * 0.18f, num2, num3);
			float num4 = Mathf.Clamp((float)Screen.height / 360f, 2f, 4f);
			GUI.depth = -1000;
			GUI.Label(new Rect(((Rect)(ref val)).x - num4, ((Rect)(ref val)).y, ((Rect)(ref val)).width, ((Rect)(ref val)).height), _noticeText, _outlineStyle);
			GUI.Label(new Rect(((Rect)(ref val)).x + num4, ((Rect)(ref val)).y, ((Rect)(ref val)).width, ((Rect)(ref val)).height), _noticeText, _outlineStyle);
			GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y - num4, ((Rect)(ref val)).width, ((Rect)(ref val)).height), _noticeText, _outlineStyle);
			GUI.Label(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y + num4, ((Rect)(ref val)).width, ((Rect)(ref val)).height), _noticeText, _outlineStyle);
			GUI.Label(new Rect(((Rect)(ref val)).x - num4, ((Rect)(ref val)).y - num4, ((Rect)(ref val)).width, ((Rect)(ref val)).height), _noticeText, _outlineStyle);
			GUI.Label(new Rect(((Rect)(ref val)).x + num4, ((Rect)(ref val)).y - num4, ((Rect)(ref val)).width, ((Rect)(ref val)).height), _noticeText, _outlineStyle);
			GUI.Label(new Rect(((Rect)(ref val)).x - num4, ((Rect)(ref val)).y + num4, ((Rect)(ref val)).width, ((Rect)(ref val)).height), _noticeText, _outlineStyle);
			GUI.Label(new Rect(((Rect)(ref val)).x + num4, ((Rect)(ref val)).y + num4, ((Rect)(ref val)).width, ((Rect)(ref val)).height), _noticeText, _outlineStyle);
			GUI.Label(val, _noticeText, _noticeStyle);
		}

		private void EnsurePlayerTravelUi()
		{
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance == (Object)null || ((Object)(object)_attachedInventoryGui == (Object)(object)instance && (Object)(object)_minimapPlayerButton != (Object)null && (Object)(object)_playerMenuPanel != (Object)null) || Time.unscaledTime < _nextUiAttachAttemptTime)
			{
				return;
			}
			try
			{
				DestroyPlayerTravelUi();
				_attachedInventoryGui = instance;
				_nativeButtonSource = (Component)(object)(instance.m_tabUpgrade ?? instance.m_tabCraft);
				TMP_Text craftingStationName = instance.m_craftingStationName;
				_nativeTextSource = (Component)(object)(((craftingStationName != null) ? Object.op_Implicit((Object)(object)craftingStationName) : ((Object)(object)_nativeButtonSource != (Object)null)) ? _nativeButtonSource.gameObject.GetComponentInChildren<TMP_Text>(true) : null);
				if ((Object)(object)_nativeButtonSource == (Object)null || (Object)(object)_nativeTextSource == (Object)null || (Object)(object)instance.m_inventoryRoot == (Object)null)
				{
					throw new InvalidOperationException("The required Valheim inventory UI templates were not available.");
				}
				CreateMinimapCompassButton();
				CreatePlayerMenu(instance);
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)string.Format("{0} {1}: could not attach the native player UI: {2}", "Wayfarer Recall", "1.2.0", arg));
				DestroyPlayerTravelUi();
				_nextUiAttachAttemptTime = Time.unscaledTime + 2f;
			}
		}

		private void CreateMinimapCompassButton()
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: 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_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Expected O, but got Unknown
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Expected O, but got Unknown
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			Minimap instance = Minimap.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.m_smallRoot == (Object)null)
			{
				throw new InvalidOperationException("The Valheim small minimap was not available.");
			}
			RectTransform component = instance.m_smallRoot.GetComponent<RectTransform>();
			Button val = FindButtonComponent(((Object)(object)_nativeButtonSource != (Object)null) ? _nativeButtonSource.gameObject : null);
			if ((Object)(object)component == (Object)null || (Object)(object)((Transform)component).parent == (Object)null || (Object)(object)val == (Object)null)
			{
				throw new InvalidOperationException("The minimap anchor or Valheim button style was not available.");
			}
			_minimapPlayerButton = new GameObject("WayfarerRecall_MinimapCompass", new Type[4]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Button)
			});
			_minimapPlayerButton.transform.SetParent(((Transform)component).parent, false);
			RectTransform component2 = _minimapPlayerButton.GetComponent<RectTransform>();
			Rect rect = component.rect;
			float num = Mathf.Abs(((Rect)(ref rect)).width);
			rect = component.rect;
			float num2 = Mathf.Abs(((Rect)(ref rect)).height);
			if (num < 8f)
			{
				num = Mathf.Abs(component.sizeDelta.x);
			}
			if (num2 < 8f)
			{
				num2 = Mathf.Abs(component.sizeDelta.y);
			}
			component2.anchorMin = component.anchorMin;
			component2.anchorMax = component.anchorMax;
			component2.pivot = component.pivot;
			component2.sizeDelta = new Vector2(42f, 42f);
			((Transform)component2).localScale = ((Transform)component).localScale;
			((Transform)component2).localRotation = Quaternion.identity;
			float num3 = component.anchoredPosition.x + num * (1f - component.pivot.x) - 42f * (1f - component.pivot.x);
			float num4 = component.anchoredPosition.y - num2 * component.pivot.y - 8f - 42f * (1f - component.pivot.y);
			component2.anchoredPosition = new Vector2(num3, num4);
			Image component3 = _minimapPlayerButton.GetComponent<Image>();
			component3.sprite = CreateCompassSprite();
			component3.overrideSprite = CreateCompassSprite();
			((Graphic)component3).color = Color.white;
			((Graphic)component3).raycastTarget = true;
			component3.preserveAspect = true;
			Button component4 = _minimapPlayerButton.GetComponent<Button>();
			((Selectable)component4).transition = ((Selectable)val).transition;
			((Selectable)component4).colors = ((Selectable)val).colors;
			((Selectable)component4).navigation = ((Selectable)val).navigation;
			((Selectable)component4).targetGraphic = (Graphic)(object)component3;
			component4.onClick = new ButtonClickedEvent();
			((UnityEvent)component4.onClick).AddListener((UnityAction)delegate
			{
				OpenPlayerMenu();
			});
			AddNativeTooltip(_minimapPlayerButton, _nativeButtonSource.gameObject, "Port to Player");
			_minimapPlayerButton.transform.SetAsLastSibling();
			_minimapPlayerButton.SetActive(true);
		}

		private Sprite CreateCompassSprite()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_00c8: 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)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: 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)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: 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_0158: 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_016e: 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_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: 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_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_compassSprite != (Object)null)
			{
				return _compassSprite;
			}
			_compassTexture = new Texture2D(96, 96, (TextureFormat)4, false);
			((Object)_compassTexture).name = "WayfarerRecall_GoldCompassTexture";
			((Texture)_compassTexture).filterMode = (FilterMode)1;
			((Texture)_compassTexture).wrapMode = (TextureWrapMode)1;
			Color32 val = default(Color32);
			((Color32)(ref val))..ctor((byte)0, (byte)0, (byte)0, (byte)0);
			Color32 outline = default(Color32);
			((Color32)(ref outline))..ctor((byte)55, (byte)35, (byte)17, byte.MaxValue);
			Color32 val2 = default(Color32);
			((Color32)(ref val2))..ctor((byte)181, (byte)122, (byte)36, byte.MaxValue);
			Color32 fill = default(Color32);
			((Color32)(ref fill))..ctor((byte)222, (byte)173, (byte)65, byte.MaxValue);
			Color32 fill2 = default(Color32);
			((Color32)(ref fill2))..ctor(byte.MaxValue, (byte)226, (byte)139, byte.MaxValue);
			Color32[] array = (Color32[])(object)new Color32[9216];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = val;
			}
			Vector2 center = default(Vector2);
			((Vector2)(ref center))..ctor(47.5f, 47.5f);
			DrawCompassRing(array, 96, center, outline, val2);
			DrawCompassPoint(array, 96, center, new Vector2(0f, 43f), 10f, outline, fill2);
			DrawCompassPoint(array, 96, center, new Vector2(43f, 0f), 10f, outline, fill);
			DrawCompassPoint(array, 96, center, new Vector2(0f, -43f), 10f, outline, fill);
			DrawCompassPoint(array, 96, center, new Vector2(-43f, 0f), 10f, outline, fill);
			DrawCompassPoint(array, 96, center, new Vector2(27f, 27f), 7f, outline, val2);
			DrawCompassPoint(array, 96, center, new Vector2(27f, -27f), 7f, outline, val2);
			DrawCompassPoint(array, 96, center, new Vector2(-27f, -27f), 7f, outline, val2);
			DrawCompassPoint(array, 96, center, new Vector2(-27f, 27f), 7f, outline, val2);
			DrawCompassCenter(array, 96, center, outline, fill2);
			_compassTexture.SetPixels32(array);
			_compassTexture.Apply(false, false);
			_compassSprite = Sprite.Create(_compassTexture, new Rect(0f, 0f, 96f, 96f), new Vector2(0.5f, 0.5f), 96f);
			((Object)_compassSprite).name = "WayfarerRecall_GoldCompassRose";
			return _compassSprite;
		}

		private Sprite CreateSpawnIconSprite()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_00c8: 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)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: 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_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: 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_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: 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_0235: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_spawnIconSprite != (Object)null)
			{
				return _spawnIconSprite;
			}
			_spawnIconTexture = new Texture2D(96, 96, (TextureFormat)4, false);
			((Object)_spawnIconTexture).name = "WayfarerRecall_SpawnIconTexture";
			((Texture)_spawnIconTexture).filterMode = (FilterMode)1;
			((Texture)_spawnIconTexture).wrapMode = (TextureWrapMode)1;
			Color32 val = default(Color32);
			((Color32)(ref val))..ctor((byte)0, (byte)0, (byte)0, (byte)0);
			Color32 val2 = default(Color32);
			((Color32)(ref val2))..ctor((byte)55, (byte)35, (byte)17, byte.MaxValue);
			Color32 val3 = default(Color32);
			((Color32)(ref val3))..ctor((byte)145, (byte)88, (byte)24, byte.MaxValue);
			Color32 val4 = default(Color32);
			((Color32)(ref val4))..ctor((byte)222, (byte)173, (byte)65, byte.MaxValue);
			Color32 color = default(Color32);
			((Color32)(ref color))..ctor(byte.MaxValue, (byte)226, (byte)139, byte.MaxValue);
			Color32[] array = (Color32[])(object)new Color32[9216];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = val;
			}
			for (int j = 19; j <= 57; j++)
			{
				for (int k = 23; k <= 72; k++)
				{
					array[j * 96 + k] = val2;
				}
			}
			for (int l = 23; l <= 55; l++)
			{
				for (int m = 27; m <= 68; m++)
				{
					array[l * 96 + m] = val4;
				}
			}
			FillTriangle(array, 96, new Vector2(13f, 54f), new Vector2(47f, 84f), new Vector2(81f, 54f), val2);
			FillTriangle(array, 96, new Vector2(21f, 56f), new Vector2(47f, 78f), new Vector2(73f, 56f), val3);
			FillTriangle(array, 96, new Vector2(30f, 59f), new Vector2(47f, 73f), new Vector2(47f, 59f), color);
			for (int n = 19; n <= 43; n++)
			{
				for (int num = 41; num <= 55; num++)
				{
					array[n * 96 + num] = val2;
				}
			}
			for (int num2 = 23; num2 <= 41; num2++)
			{
				for (int num3 = 45; num3 <= 52; num3++)
				{
					array[num2 * 96 + num3] = val3;
				}
			}
			_spawnIconTexture.SetPixels32(array);
			_spawnIconTexture.Apply(false, false);
			_spawnIconSprite = Sprite.Create(_spawnIconTexture, new Rect(0f, 0f, 96f, 96f), new Vector2(0.5f, 0.5f), 96f);
			((Object)_spawnIconSprite).name = "WayfarerRecall_SpawnHouse";
			return _spawnIconSprite;
		}

		private Sprite CreateLocationIconSprite()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_00c8: 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)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: 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_0340: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_locationIconSprite != (Object)null)
			{
				return _locationIconSprite;
			}
			_locationIconTexture = new Texture2D(96, 96, (TextureFormat)4, false);
			((Object)_locationIconTexture).name = "WayfarerRecall_LocationIconTexture";
			((Texture)_locationIconTexture).filterMode = (FilterMode)1;
			((Texture)_locationIconTexture).wrapMode = (TextureWrapMode)1;
			Color32 val = default(Color32);
			((Color32)(ref val))..ctor((byte)0, (byte)0, (byte)0, (byte)0);
			Color32 val2 = default(Color32);
			((Color32)(ref val2))..ctor((byte)55, (byte)35, (byte)17, byte.MaxValue);
			Color32 val3 = default(Color32);
			((Color32)(ref val3))..ctor((byte)145, (byte)88, (byte)24, byte.MaxValue);
			Color32 val4 = default(Color32);
			((Color32)(ref val4))..ctor((byte)222, (byte)173, (byte)65, byte.MaxValue);
			Color32 val5 = default(Color32);
			((Color32)(ref val5))..ctor(byte.MaxValue, (byte)226, (byte)139, byte.MaxValue);
			Color32[] array = (Color32[])(object)new Color32[9216];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = val;
			}
			Vector2 val6 = default(Vector2);
			((Vector2)(ref val6))..ctor(47.5f, 47.5f);
			for (int j = 0; j < 96; j++)
			{
				for (int k = 0; k < 96; k++)
				{
					float num = Vector2.Distance(new Vector2((float)k, (float)j), val6);
					if (num >= 30f && num <= 35f)
					{
						array[j * 96 + k] = val2;
					}
					else if (num >= 24f && num < 30f)
					{
						array[j * 96 + k] = val4;
					}
					else if (num >= 14f && num <= 18f)
					{
						array[j * 96 + k] = val2;
					}
					else if (num < 14f)
					{
						array[j * 96 + k] = ((num >= 8f) ? val3 : val5);
					}
				}
			}
			for (int l = 73; l <= 90; l++)
			{
				for (int m = 45; m <= 50; m++)
				{
					array[l * 96 + m] = val2;
				}
			}
			for (int n = 76; n <= 88; n++)
			{
				for (int num2 = 47; num2 <= 48; num2++)
				{
					array[n * 96 + num2] = val4;
				}
			}
			for (int num3 = 5; num3 <= 22; num3++)
			{
				for (int num4 = 45; num4 <= 50; num4++)
				{
					array[num3 * 96 + num4] = val2;
				}
			}
			for (int num5 = 7; num5 <= 19; num5++)
			{
				for (int num6 = 47; num6 <= 48; num6++)
				{
					array[num5 * 96 + num6] = val4;
				}
			}
			for (int num7 = 45; num7 <= 50; num7++)
			{
				for (int num8 = 5; num8 <= 22; num8++)
				{
					array[num7 * 96 + num8] = val2;
				}
			}
			for (int num9 = 47; num9 <= 48; num9++)
			{
				for (int num10 = 7; num10 <= 19; num10++)
				{
					array[num9 * 96 + num10] = val4;
				}
			}
			for (int num11 = 45; num11 <= 50; num11++)
			{
				for (int num12 = 73; num12 <= 90; num12++)
				{
					array[num11 * 96 + num12] = val2;
				}
			}
			for (int num13 = 47; num13 <= 48; num13++)
			{
				for (int num14 = 76; num14 <= 88; num14++)
				{
					array[num13 * 96 + num14] = val4;
				}
			}
			_locationIconTexture.SetPixels32(array);
			_locationIconTexture.Apply(false, false);
			_locationIconSprite = Sprite.Create(_locationIconTexture, new Rect(0f, 0f, 96f, 96f), new Vector2(0.5f, 0.5f), 96f);
			((Object)_locationIconSprite).name = "WayfarerRecall_LastLocationCrosshair";
			return _locationIconSprite;
		}

		private Sprite CreateBoatIconSprite()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_00c8: 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)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: 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_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: 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_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: 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)
			if ((Object)(object)_boatIconSprite != (Object)null)
			{
				return _boatIconSprite;
			}
			_boatIconTexture = new Texture2D(96, 96, (TextureFormat)4, false);
			((Object)_boatIconTexture).name = "WayfarerRecall_BoatIconTexture";
			((Texture)_boatIconTexture).filterMode = (FilterMode)1;
			((Texture)_boatIconTexture).wrapMode = (TextureWrapMode)1;
			Color32 val = default(Color32);
			((Color32)(ref val))..ctor((byte)0, (byte)0, (byte)0, (byte)0);
			Color32 val2 = default(Color32);
			((Color32)(ref val2))..ctor((byte)55, (byte)35, (byte)17, byte.MaxValue);
			Color32 color = default(Color32);
			((Color32)(ref color))..ctor((byte)145, (byte)88, (byte)24, byte.MaxValue);
			Color32 color2 = default(Color32);
			((Color32)(ref color2))..ctor((byte)222, (byte)173, (byte)65, byte.MaxValue);
			Color32 val3 = default(Color32);
			((Color32)(ref val3))..ctor(byte.MaxValue, (byte)226, (byte)139, byte.MaxValue);
			Color32[] array = (Color32[])(object)new Color32[9216];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = val;
			}
			FillTriangle(array, 96, new Vector2(15f, 34f), new Vector2(81f, 34f), new Vector2(66f, 17f), val2);
			FillTriangle(array, 96, new Vector2(15f, 34f), new Vector2(66f, 17f), new Vector2(29f, 17f), val2);
			FillTriangle(array, 96, new Vector2(22f, 32f), new Vector2(74f, 32f), new Vector2(63f, 21f), color2);
			FillTriangle(array, 96, new Vector2(22f, 32f), new Vector2(63f, 21f), new Vector2(32f, 21f), color);
			for (int j = 33; j <= 76; j++)
			{
				for (int k = 46; k <= 50; k++)
				{
					array[j * 96 + k] = val2;
				}
			}
			for (int l = 35; l <= 74; l++)
			{
				for (int m = 47; m <= 49; m++)
				{
					array[l * 96 + m] = val3;
				}
			}
			FillTriangle(array, 96, new Vector2(50f, 72f), new Vector2(50f, 40f), new Vector2(76f, 46f), val2);
			FillTriangle(array, 96, new Vector2(53f, 67f), new Vector2(53f, 44f), new Vector2(70f, 48f), color2);
			FillTriangle(array, 96, new Vector2(54f, 63f), new Vector2(54f, 48f), new Vector2(62f, 50f), val3);
			_boatIconTexture.SetPixels32(array);
			_boatIconTexture.Apply(false, false);
			_boatIconSprite = Sprite.Create(_boatIconTexture, new Rect(0f, 0f, 96f, 96f), new Vector2(0.5f, 0.5f), 96f);
			((Object)_boatIconSprite).name = "WayfarerRecall_LastBoat";
			return _boatIconSprite;
		}

		private Sprite CreateDeathIconSprite()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_00c8: 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)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: 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_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: 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_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: 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_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0432: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_047d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04af: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0500: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_deathIconSprite != (Object)null)
			{
				return _deathIconSprite;
			}
			_deathIconTexture = new Texture2D(96, 96, (TextureFormat)4, false);
			((Object)_deathIconTexture).name = "WayfarerRecall_DeathIconTexture";
			((Texture)_deathIconTexture).filterMode = (FilterMode)1;
			((Texture)_deathIconTexture).wrapMode = (TextureWrapMode)1;
			Color32 val = default(Color32);
			((Color32)(ref val))..ctor((byte)0, (byte)0, (byte)0, (byte)0);
			Color32 color = default(Color32);
			((Color32)(ref color))..ctor((byte)55, (byte)35, (byte)17, byte.MaxValue);
			Color32 color2 = default(Color32);
			((Color32)(ref color2))..ctor((byte)145, (byte)88, (byte)24, byte.MaxValue);
			Color32 color3 = default(Color32);
			((Color32)(ref color3))..ctor((byte)222, (byte)173, (byte)65, byte.MaxValue);
			Color32 color4 = default(Color32);
			((Color32)(ref color4))..ctor(byte.MaxValue, (byte)226, (byte)139, byte.MaxValue);
			Color32[] array = (Color32[])(object)new Color32[9216];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = val;
			}
			FillTriangle(array, 96, new Vector2(42f, 48f), new Vector2(54f, 48f), new Vector2(67f, 82f), color);
			FillTriangle(array, 96, new Vector2(42f, 48f), new Vector2(67f, 82f), new Vector2(29f, 82f), color);
			FillTriangle(array, 96, new Vector2(42f, 48f), new Vector2(29f, 14f), new Vector2(67f, 14f), color);
			FillTriangle(array, 96, new Vector2(42f, 48f), new Vector2(67f, 14f), new Vector2(54f, 48f), color);
			FillTriangle(array, 96, new Vector2(48f, 42f), new Vector2(48f, 54f), new Vector2(14f, 67f), color);
			FillTriangle(array, 96, new Vector2(48f, 42f), new Vector2(14f, 67f), new Vector2(14f, 29f), color);
			FillTriangle(array, 96, new Vector2(48f, 42f), new Vector2(82f, 29f), new Vector2(82f, 67f), color);
			FillTriangle(array, 96, new Vector2(48f, 42f), new Vector2(82f, 67f), new Vector2(48f, 54f), color);
			FillTriangle(array, 96, new Vector2(44f, 49f), new Vector2(52f, 49f), new Vector2(61f, 76f), color3);
			FillTriangle(array, 96, new Vector2(44f, 49f), new Vector2(61f, 76f), new Vector2(35f, 76f), color2);
			FillTriangle(array, 96, new Vector2(44f, 47f), new Vector2(35f, 20f), new Vector2(61f, 20f), color2);
			FillTriangle(array, 96, new Vector2(44f, 47f), new Vector2(61f, 20f), new Vector2(52f, 47f), color3);
			FillTriangle(array, 96, new Vector2(47f, 44f), new Vector2(47f, 52f), new Vector2(20f, 61f), color3);
			FillTriangle(array, 96, new Vector2(47f, 44f), new Vector2(20f, 61f), new Vector2(20f, 35f), color2);
			FillTriangle(array, 96, new Vector2(49f, 44f), new Vector2(76f, 35f), new Vector2(76f, 61f), color2);
			FillTriangle(array, 96, new Vector2(49f, 44f), new Vector2(76f, 61f), new Vector2(49f, 52f), color3);
			FillTriangle(array, 96, new Vector2(48f, 34f), new Vector2(62f, 48f), new Vector2(48f, 62f), color);
			FillTriangle(array, 96, new Vector2(48f, 34f), new Vector2(48f, 62f), new Vector2(34f, 48f), color);
			FillTriangle(array, 96, new Vector2(48f, 39f), new Vector2(57f, 48f), new Vector2(48f, 57f), color4);
			FillTriangle(array, 96, new Vector2(48f, 39f), new Vector2(48f, 57f), new Vector2(39f, 48f), color3);
			_deathIconTexture.SetPixels32(array);
			_deathIconTexture.Apply(false, false);
			_deathIconSprite = Sprite.Create(_deathIconTexture, new Rect(0f, 0f, 96f, 96f), new Vector2(0.5f, 0.5f), 96f);
			((Object)_deathIconSprite).name = "WayfarerRecall_LastDeathMalteseCross";
			return _deathIconSprite;
		}

		private static void DrawCompassRing(Color32[] pixels, int size, Vector2 center, Color32 outline, Color32 gold)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003e: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num = Vector2.Distance(new Vector2((float)j, (float)i), center);
					if (num >= 31f && num <= 35f)
					{
						pixels[i * size + j] = ((num < 32.5f || num > 33.5f) ? outline : gold);
					}
				}
			}
		}

		private static void DrawCompassPoint(Color32[] pixels, int size, Vector2 center, Vector2 direction, float halfWidth, Color32 outline, Color32 fill)
		{
			//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_0008: 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_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)
			//IL_001f: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_004a: 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_0050: 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_0054: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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)
			//IL_006b: 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_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_0079: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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)
			Vector2 val = center + direction;
			Vector2 val2 = center - ((Vector2)(ref direction)).normalized * 5f;
			Vector2 val3 = new Vector2(0f - direction.y, direction.x);
			Vector2 val4 = ((Vector2)(ref val3)).normalized * halfWidth;
			Vector2 val5 = val2 + val4;
			Vector2 val6 = val2 - val4;
			FillTriangle(pixels, size, val, val5, val6, outline);
			Vector2 a = Vector2.Lerp(center, val, 0.88f);
			Vector2 b = Vector2.Lerp(center, val5, 0.72f);
			Vector2 c = Vector2.Lerp(center, val6, 0.72f);
			FillTriangle(pixels, size, a, b, c, fill);
		}

		private static void DrawCompassCenter(Color32[] pixels, int size, Vector2 center, Color32 outline, Color32 fill)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < size; i++)
			{
				for (int j = 0; j < size; j++)
				{
					float num = Vector2.Distance(new Vector2((float)j, (float)i), center);
					if (num <= 9f)
					{
						pixels[i * size + j] = ((num >= 6.5f) ? outline : fill);
					}
				}
			}
		}

		private static void FillTriangle(Color32[] pixels, int size, Vector2 a, Vector2 b, Vector2 c, Color32 color)
		{
			//IL_0000: 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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0064: 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_0089: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Clamp(Mathf.FloorToInt(Mathf.Min(a.x, Mathf.Min(b.x, c.x))), 0, size - 1);
			int num2 = Mathf.Clamp(Mathf.CeilToInt(Mathf.Max(a.x, Mathf.Max(b.x, c.x))), 0, size - 1);
			int num3 = Mathf.Clamp(Mathf.FloorToInt(Mathf.Min(a.y, Mathf.Min(b.y, c.y))), 0, size - 1);
			int num4 = Mathf.Clamp(Mathf.CeilToInt(Mathf.Max(a.y, Mathf.Max(b.y, c.y))), 0, size - 1);
			for (int i = num3; i <= num4; i++)
			{
				for (int j = num; j <= num2; j++)
				{
					Vector2 point = new Vector2((float)j + 0.5f, (float)i + 0.5f);
					float num5 = TriangleSign(point, a, b);
					float num6 = TriangleSign(point, b, c);
					float num7 = TriangleSign(point, c, a);
					bool flag = num5 < 0f || num6 < 0f || num7 < 0f;
					bool flag2 = num5 > 0f || num6 > 0f || num7 > 0f;
					if (!(flag && flag2))
					{
						pixels[i * size + j] = color;
					}
				}
			}
		}

		private static float TriangleSign(Vector2 point, Vector2 a, Vector2 b)
		{
			//IL_0000: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0021: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			return (point.x - b.x) * (a.y - b.y) - (a.x - b.x) * (point.y - b.y);
		}

		private static void AddNativeTooltip(GameObject target, GameObject source, string text)
		{
			if (!((Object)(object)target == (Object)null) && !((Object)(object)source == (Object)null))
			{
				UITooltip val = source.GetComponentInChildren<UITooltip>(true);
				if ((Object)(object)val == (Object)null && (Object)(object)InventoryGui.instance != (Object)null && (Object)(object)InventoryGui.instance.m_pvp != (Object)null)
				{
					val = ((Component)InventoryGui.instance.m_pvp).gameObject.GetComponent<UITooltip>();
				}
				if (!((Object)(object)val == (Object)null))
				{
					UITooltip obj = target.AddComponent<UITooltip>();
					obj.m_tooltipPrefab = val.m_tooltipPrefab;
					obj.m_text = text;
					obj.m_topic = string.Empty;
				}
			}
		}

		private void CreatePlayerMenu(InventoryGui inventory)
		{
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: 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)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Expected O, but got Unknown
			Hud instance = Hud.instance;
			if ((Object)(object)instance == (Object)null)
			{
				throw new InvalidOperationException("The Valheim HUD was not available.");
			}
			Transform transform = ((Component)instance).transform;
			Component pvp = (Component)(object)inventory.m_pvp;
			Transform val = (((Object)(object)pvp != (Object)null) ? pvp.transform.parent : null);
			Transform val2 = (((Object)(object)val != (Object)null) ? val.Find("Bkg") : null);
			Component val3 = (((Object)(object)val2 != (Object)null) ? FindImageComponent(((Component)val2).gameObject) : null);
			if (val3 == null)
			{
				object obj = FindImageComponent(((Object)(object)inventory.m_crafting != (Object)null) ? ((Component)inventory.m_crafting).gameObject : _nativeButtonSource.gameObject);
				if (obj == null)
				{
					Button obj2 = FindButtonComponent(((Object)(object)_nativeButtonSource != (Object)null) ? _nativeButtonSource.gameObject : null);
					obj = ((obj2 != null) ? ((Selectable)obj2).targetGraphic : null);
				}
				val3 = (Component)obj;
			}
			if ((Object)(object)val3 == (Object)null)
			{
				throw new InvalidOperationException("A Valheim panel image could not be found.");
			}
			_playerMenuBlocker = CreateImageObject("WayfarerRecall_PlayerMenuBlocker", transform, val3);
			RectTransform component = _playerMenuBlocker.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			((Transform)component).localScale = Vector3.one;
			Component obj3 = FindImageComponent(_playerMenuBlocker);
			Image val4 = (Image)(object)((obj3 is Image) ? obj3 : null);
			if (val4 != null)
			{
				val4.sprite = null;
			}
			Graphic val5 = (Graphic)(object)((obj3 is Graphic) ? obj3 : null);
			if (val5 != null)
			{
				val5.color = new Color(0f, 0f, 0f, 0.62f);
				val5.raycastTarget = true;
			}
			_playerMenuPanel = CreateImageObject("WayfarerRecall_PlayerMenu", transform, val3);
			RectTransform component2 = _playerMenuPanel.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0.5f, 0.5f);
			component2.anchorMax = new Vector2(0.5f, 0.5f);
			component2.pivot = new Vector2(0.5f, 0.5f);
			component2.anchoredPosition = Vector2.zero;
			component2.sizeDelta = new Vector2(460f, 230f);
			((Transform)component2).localScale = Vector3.one;
			Component obj4 = FindImageComponent(_playerMenuPanel);
			Graphic val6 = (Graphic)(object)((obj4 is Graphic) ? obj4 : null);
			if ((Object)(object)val6 != (Object)null)
			{
				val6.raycastTarget = true;
			}
			GameObject obj5 = CreateNativeLabel(_playerMenuPanel.transform, "WayfarerRecall_Title", "Port to Player");
			SetTopRect(obj5, 18f, 220f, 32f);
			TMP_Text componentInChildren = obj5.GetComponentInChildren<TMP_Text>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				componentInChildren.fontSize = 24f;
			}
			SetTopRect(CreateHeaderIconButton(_playerMenuPanel.transform, "WayfarerRecall_SpawnButton", CreateSpawnIconSprite(), "Return to Spawn", delegate
			{
				RecallFromPlayerMenu(RecallSpawn);
			}), 14f, 34f, 34f, -185f);
			SetTopRect(CreateHeaderIconButton(_playerMenuPanel.transform, "WayfarerRecall_LastLocationButton", CreateLocationIconSprite(), "Last Location", delegate
			{
				RecallFromPlayerMenu(RecallLastLocation);
			}), 14f, 34f, 34f, -125f);
			SetTopRect(CreateHeaderIconButton(_playerMenuPanel.transform, "WayfarerRecall_LastBoatButton", CreateBoatIconSprite(), "Last Boat", delegate
			{
				RecallFromPlayerMenu(RecallBoat);
			}), 14f, 34f, 34f, 125f);
			SetTopRect(CreateHeaderIconButton(_playerMenuPanel.transform, "WayfarerRecall_LastDeathButton", CreateDeathIconSprite(), "Last Death", delegate
			{
				RecallFromPlayerMenu(RecallDeath);
			}), 14f, 34f, 34f, 185f);
			_playerDropdownButton = CreateStyledButton(_playerMenuPanel.transform, "WayfarerRecall_PlayerDropdown", "No players connected", TogglePlayerDropdown);
			SetTopRect(_playerDropdownButton, 58f, 410f, 38f);
			_playerOptionsRoot = new GameObject("WayfarerRecall_PlayerOptions", new Type[1] { typeof(RectTransform) });
			_playerOptionsRoot.transform.SetParent(_playerMenuPanel.transform, false);
			_playerStatusLabel = CreateNativeLabel(_playerMenuPanel.transform, "WayfarerRecall_Status", "No other players are currently connected.");
			TMP_Text componentInChildren2 = _playerStatusLabel.GetComponentInChildren<TMP_Text>(true);
			if ((Object)(object)componentInChildren2 != (Object)null)
			{
				componentInChildren2.fontSize = _playerStatusFontSize.Value;
			}
			_playerPortButton = CreateStyledButton(_playerMenuPanel.transform, "WayfarerRecall_Port", "Port", PortToSelectedPlayer);
			_playerRefreshButton = CreateStyledButton(_playerMenuPanel.transform, "WayfarerRecall_Refresh", "Refresh", RefreshPlayerList);
			_playerCloseButton = CreateStyledButton(_playerMenuPanel.transform, "WayfarerRecall_Close", "Close", delegate
			{
				ClosePlayerMenu();
			});
			_playerMenuBlocker.transform.SetAsLastSibling();
			_playerMenuPanel.transform.SetAsLastSibling();
			_playerMenuBlocker.SetActive(false);
			_playerMenuPanel.SetActive(false);
			UpdatePlayerMenuUi();
		}

		private GameObject CreateImageObject(string name, Transform parent, Component imageSource)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[2]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer)
			});
			val.transform.SetParent(parent, false);
			Component obj = val.AddComponent(((object)imageSource).GetType());
			Graphic val2 = (Graphic)(object)((imageSource is Graphic) ? imageSource : null);
			Graphic val3 = (Graphic)(object)((obj is Graphic) ? obj : null);
			if ((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null)
			{
				val3.material = val2.material;
				val3.color = val2.color;
			}
			Image val4 = (Image)(object)((imageSource is Image) ? imageSource : null);
			Image val5 = (Image)(object)((obj is Image) ? obj : null);
			if ((Object)(object)val4 != (Object)null && (Object)(object)val5 != (Object)null)
			{
				val5.sprite = val4.sprite;
				val5.overrideSprite = val4.overrideSprite;
				val5.type = val4.type;
				val5.fillCenter = val4.fillCenter;
				val5.pixelsPerUnitMultiplier = val4.pixelsPerUnitMultiplier;
			}
			return val;
		}

		private GameObject CreateNativeLabel(Transform parent, string name, string text)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_0095: 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_00ad: 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)
			GameObject val = new GameObject(name, new Type[2]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer)
			});
			val.SetActive(false);
			val.transform.SetParent(parent, false);
			Component obj = val.AddComponent(((object)_nativeTextSource).GetType());
			Component nativeTextSource = _nativeTextSource;
			TMP_Text val2 = (TMP_Text)(object)((nativeTextSource is TMP_Text) ? nativeTextSource : null);
			TMP_Text val3 = (TMP_Text)(object)((obj is TMP_Text) ? obj : null);
			if ((Object)(object)val2 != (Object)null && (Object)(object)val3 != (Object)null)
			{
				val3.font = val2.font;
				val3.fontSharedMaterial = val2.fontSharedMaterial;
				val3.fontSize = val2.fontSize;
				val3.fontStyle = val2.fontStyle;
				((Graphic)val3).color = ((Graphic)val2).color;
				val3.alignment = val2.alignment;
				val3.overflowMode = val2.overflowMode;
			}
			if ((Object)(object)val3 != (Object)null)
			{
				val3.textWrappingMode = (TextWrappingModes)1;
				((Graphic)val3).raycastTarget = false;
				val3.text = text;
			}
			val.SetActive(true);
			return val;
		}

		private GameObject CreateHeaderIconButton(Transform parent, string name, Sprite iconSprite, string tooltipText, Action callback)
		{
			//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_0091: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_0125: Expected O, but got Unknown
			Button val = FindButtonComponent(((Object)(object)_nativeButtonSource != (Object)null) ? _nativeButtonSource.gameObject : null);
			if ((Object)(object)val == (Object)null)
			{
				throw new InvalidOperationException("A Valheim button style was not available.");
			}
			GameObject val2 = new GameObject(name, new Type[4]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image),
				typeof(Button)
			});
			val2.transform.SetParent(parent, false);
			Image component = val2.GetComponent<Image>();
			component.sprite = iconSprite;
			component.overrideSprite = iconSprite;
			((Graphic)component).color = Color.white;
			((Graphic)component).raycastTarget = true;
			component.preserveAspect = true;
			Button component2 = val2.GetComponent<Button>();
			((Selectable)component2).transition = ((Selectable)val).transition;
			((Selectable)component2).colors = ((Selectable)val).colors;
			((Selectable)component2).navigation = ((Selectable)val).navigation;
			((Selectable)component2).targetGraphic = (Graphic)(object)component;
			component2.onClick = new ButtonClickedEvent();
			((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
			{
				callback();
			});
			AddNativeTooltip(val2, _nativeButtonSource.gameObject, tooltipText);
			return val2;
		}

		private GameObject CreateStyledButton(Transform parent, string name, string text, Action callback)
		{
			GameObject obj = Object.Instantiate<GameObject>(_nativeButtonSource.gameObject, parent, false);
			((Object)obj).name = name;
			obj.SetActive(false);
			SetAllUiText(obj, text);
			BindNativeButton(obj, callback);
			obj.SetActive(true);
			return obj;
		}

		private static void SetTopRect(GameObject gameObject, float top, float width, float height, float x = 0f)
		{
			//IL_0028: 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_0052: 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_006e: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = (((Object)(object)gameObject != (Object)null) ? gameObject.GetComponent<RectTransform>() : null);
			if (!((Object)(object)val == (Object)null))
			{
				val.anchorMin = new Vector2(0.5f, 1f);
				val.anchorMax = new Vector2(0.5f, 1f);
				val.pivot = new Vector2(0.5f, 1f);
				val.sizeDelta = new Vector2(width, height);
				val.anchoredPosition = new Vector2(x, 0f - top);
				((Transform)val).localScale = Vector3.one;
				((Transform)val).localRotation = Quaternion.identity;
			}
		}

		private void TogglePlayerDropdown()
		{
			_playerDropdownOpen = _playerDestinations.Count > 0 && !_playerDropdownOpen;
			UpdatePlayerMenuUi();
		}

		private void SelectPlayer(int index)
		{
			if (index >= 0 && index < _playerDestinations.Count)
			{
				_selectedPlayerIndex = index;
				_playerDropdownOpen = false;
				UpdatePlayerMenuUi();
			}
		}

		private void OpenPlayerMenu()
		{
			EnsurePlayerTravelUi();
			if ((Object)(object)_playerMenuPanel == (Object)null || (Object)(object)_playerMenuBlocker == (Object)null)
			{
				ShowError("The player menu could not be attached to the HUD; see the BepInEx log.");
				return;
			}
			RefreshPlayerList();
			_playerMenuOpen = true;
			_playerMenuCursorActive = true;
			_playerDropdownOpen = false;
			_playerMenuBlocker.SetActive(true);
			_playerMenuPanel.SetActive(true);
			_playerMenuBlocker.transform.SetAsLastSibling();
			_playerMenuPanel.transform.SetAsLastSibling();
			UpdatePlayerMenuUi();
		}

		private void ClosePlayerMenu()
		{
			_playerMenuOpen = false;
			_playerMenuCursorActive = false;
			_playerDropdownOpen = false;
			if ((Object)(object)_playerMenuBlocker != (Object)null)
			{
				_playerMenuBlocker.SetActive(false);
			}
			if ((Object)(object)_playerMenuPanel != (Object)null)
			{
				_playerMenuPanel.SetActive(false);
			}
		}

		private void RecallFromPlayerMenu(Action<Player> recallAction)
		{
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null) && recallAction != null)
			{
				ClosePlayerMenu();
				recallAction(localPlayer);
			}
		}

		private void RefreshPlayerList()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			ZDOID val = ZDOID.None;
			if (_playerDestinations.Count > 0 && _selectedPlayerIndex >= 0 && _selectedPlayerIndex < _playerDestinations.Count)
			{
				val = _playerDestinations[_selectedPlayerIndex].CharacterId;
			}
			_playerDestinations.Clear();
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)ZNet.instance == (Object)null)
			{
				_selectedPlayerIndex = 0;
				FinishPlayerListRefresh();
				return;
			}
			ZDOID zDOID = ((Character)localPlayer).GetZDOID();
			List<PlayerInfo> playerList = ZNet.instance.GetPlayerList();
			if (playerList != null)
			{
				foreach (PlayerInfo item in playerList)
				{
					ZDOID characterID = item.m_characterID;
					if (!((ZDOID)(ref characterID)).IsNone() && !(item.m_characterID == zDOID))
					{
						string playerDisplayName = GetPlayerDisplayName(item);
						_playerDestinations.Add(new PlayerDestination(playerDisplayName, item.m_characterID, item.m_publicPosition, item.m_position));
					}
				}
			}
			_playerDestinations.Sort((PlayerDestination left, PlayerDestination right) => string.Compare(left.Name, right.Name, StringComparison.OrdinalIgnoreCase));
			_selectedPlayerIndex = 0;
			if (!((ZDOID)(ref val)).IsNone())
			{
				for (int num = 0; num < _playerDestinations.Count; num++)
				{
					if (_playerDestinations[num].CharacterId == val)
					{
						_selectedPlayerIndex = num;
						break;
					}
				}
			}
			_nextPlayerListRefreshTime = Time.unscaledTime + 1f;
			FinishPlayerListRefresh();
		}

		private void FinishPlayerListRefresh()
		{
			//IL_0029: 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)
			string text = string.Empty;
			foreach (PlayerDestination playerDestination in _playerDestinations)
			{
				text = text + ((object)playerDestination.CharacterId/*cast due to .constrained prefix*/).ToString() + ":" + playerDestination.Name + ":" + playerDestination.HasPublicPosition + "|";
			}
			if (!string.Equals(text, _playerListSignature, StringComparison.Ordinal))
			{
				_playerListSignature = text;
				RebuildPlayerOptionButtons();
			}
			UpdatePlayerMenuUi();
		}

		private void RebuildPlayerOptionButtons()
		{
			foreach (GameObject playerOptionButton in _playerOptionButtons)
			{
				if ((Object)(object)playerOptionButton != (Object)null)
				{
					Object.Destroy((Object)(object)playerOptionButton);
				}
			}
			_playerOptionButtons.Clear();
			if ((Object)(object)_playerOptionsRoot == (Object)null || (Object)(object)_nativeButtonSource == (Object)null)
			{
				return;
			}
			for (int i = 0; i < _playerDestinations.Count && i < 9; i++)
			{
				int optionIndex = i;
				PlayerDestination playerDestination = _playerDestinations[i];
				string text = playerDestination.Name + (playerDestination.HasPublicPosition ? string.Empty : " — location hidden");
				GameObject item = CreateStyledButton(_playerOptionsRoot.transform, "WayfarerRecall_PlayerOption_" + i, text, delegate
				{
					SelectPlayer(optionIndex);
				});
				_playerOptionButtons.Add(item);
			}
		}

		private void UpdatePlayerMenuUi()
		{
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_playerMenuPanel == (Object)null))
			{
				if (_playerDestinations.Count == 0)
				{
					_selectedPlayerIndex = 0;
					_playerDropdownOpen = false;
					SetAllUiText(_playerDropdownButton, "No players connected");
					SetAllUiText(_playerStatusLabel, "No other players are currently connected.");
					SetNativeButtonInteractable(_playerPortButton, interactable: false);
				}
				else
				{
					_selectedPlayerIndex = Mathf.Clamp(_selectedPlayerIndex, 0, _playerDestinations.Count - 1);
					PlayerDestination playerDestination = _playerDestinations[_selectedPlayerIndex];
					SetAllUiText(_playerDropdownButton, playerDestination.Name + (playerDestination.HasPublicPosition ? string.Empty : " — location hidden"));
					SetAllUiText(_playerStatusLabel, playerDestination.HasPublicPosition ? "Travel arrives just beside this player's shared map position." : "This player is hiding their map position, so travel to them is unavailable.");
					SetNativeButtonInteractable(_playerPortButton, playerDestination.HasPublicPosition);
				}
				int num = (_playerDropdownOpen ? Mathf.Min(_playerOptionButtons.Count, 9) : 0);
				if ((Object)(object)_playerOptionsRoot != (Object)null)
				{
					_playerOptionsRoot.SetActive(_playerDropdownOpen && num > 0);
					SetTopRect(_playerOptionsRoot, 102f, 410f, (float)num * 36f);
				}
				for (int i = 0; i < _playerOptionButtons.Count; i++)
				{
					GameObject obj = _playerOptionButtons[i];
					obj.SetActive(_playerDropdownOpen && i < num);
					SetTopRect(obj, (float)i * 36f, 410f, 34f);
				}
				float num2 = 110f + (float)num * 36f;
				float num3 = num2 + 64f;
				SetTopRect(_playerStatusLabel, num2, 410f, 54f);
				SetTopRect(_playerPortButton, num3, 126f, 38f, -142f);
				SetTopRect(_playerRefreshButton, num3, 126f, 38f);
				SetTopRect(_playerCloseButton, num3, 126f, 38f, 142f);
				RectTransform component = _playerMenuPanel.GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.sizeDelta = new Vector2(460f, num3 + 58f);
				}
			}
		}

		private static Component FindImageComponent(GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return null;
			}
			Transform val = gameObject.transform;
			int num = 0;
			while ((Object)(object)val != (Object)null && num < 3)
			{
				Component[] components = ((Component)val).gameObject.GetComponents<Component>();
				foreach (Component val2 in components)
				{
					if ((Object)(object)val2 != (Object)null && (((object)val2).GetType().FullName == "UnityEngine.UI.Image" || ((object)val2).GetType().FullName == "UnityEngine.UI.RawImage"))
					{
						return val2;
					}
				}
				num++;
				val = val.parent;
			}
			return null;
		}

		private static Button FindButtonComponent(GameObject gameObject)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return null;
			}
			return gameObject.GetComponent<Button>();
		}

		private static void SetAllUiText(GameObject gameObject, string text)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			TMP_Text[] componentsInChildren = gameObject.GetComponentsInChildren<TMP_Text>(true);
			foreach (TMP_Text val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.text = text;
				}
			}
		}

		private static void SetNativeButtonInteractable(GameObject gameObject, bool interactable)
		{
			Button val = FindButtonComponent(gameObject);
			if ((Object)(object)val != (Object)null)
			{
				((Selectable)val).interactable = interactable;
			}
		}

		private static void BindNativeButton(GameObject gameObject, Action callback)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			Button obj = FindButtonComponent(gameObject);
			if ((Object)(object)obj == (Object)null)
			{
				throw new InvalidOperationException("A cloned Valheim button did not contain a Button component.");
			}
			obj.onClick = new ButtonClickedEvent();
			((UnityEvent)obj.onClick).AddListener((UnityAction)delegate
			{
				callback();
			});
		}

		private void DestroyPlayerTravelUi()
		{
			if ((Object)(object)_minimapPlayerButton != (Object)null)
			{
				Object.Destroy((Object)(object)_minimapPlayerButton);
			}
			if ((Object)(object)_playerMenuBlocker != (Object)null)
			{
				Object.Destroy((Object)(object)_playerMenuBlocker);
			}
			if ((Object)(object)_playerMenuPanel != (Object)null)
			{
				Object.Destroy((Object)(object)_playerMenuPanel);
			}
			if ((Object)(object)_compassSprite != (Object)null)
			{
				Object.Destroy((Object)(object)_compassSprite);
			}
			if ((Object)(object)_compassTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_compassTexture);
			}
			if ((Object)(object)_spawnIconSprite != (Object)null)
			{
				Object.Destroy((Object)(object)_spawnIconSprite);
			}
			if ((Object)(object)_spawnIconTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_spawnIconTexture);
			}
			if ((Object)(object)_locationIconSprite != (Object)null)
			{
				Object.Destroy((Object)(object)_locationIconSprite);
			}
			if ((Object)(object)_locationIconTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_locationIconTexture);
			}
			if ((Object)(object)_boatIconSprite != (Object)null)
			{
				Object.Destroy((Object)(object)_boatIconSprite);
			}
			if ((Object)(object)_boatIconTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_boatIconTexture);
			}
			if ((Object)(object)_deathIconSprite != (Object)null)
			{
				Object.Destroy((Object)(object)_deathIconSprite);
			}
			if ((Object)(object)_deathIconTexture != (Object)null)
			{
				Object.Destroy((Object)(object)_deathIconTexture);
			}
			_minimapPlayerButton = null;
			_playerMenuBlocker = null;
			_playerMenuPanel = null;
			_playerDropdownButton = null;
			_playerOptionsRoot = null;
			_playerStatusLabel = null;
			_playerPortButton = null;
			_playerRefreshButton = null;
			_playerCloseButton = null;
			_nativeButtonSource = null;
			_nativeTextSource = null;
			_compassSprite = null;
			_compassTexture = null;
			_spawnIconSprite = null;
			_spawnIconTexture = null;
			_locationIconSprite = null;
			_locationIconTexture = null;
			_boatIconSprite = null;
			_boatIconTexture = null;
			_deathIconSprite = null;
			_deathIconTexture = null;
			_attachedInventoryGui = null;
			_playerOptionButtons.Clear();
			_playerListSignature = string.Empty;
			_playerMenuOpen = false;
			_playerMenuCursorActive = false;
			_playerDropdownOpen = false;
		}

		private static string GetPlayerDisplayName(PlayerInfo playerInfo)
		{
			//IL_0000: 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_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(playerInfo.m_name))
			{
				return playerInfo.m_name;
			}
			if (!string.IsNullOrEmpty(playerInfo.m_userInfo.m_displayName))
			{
				return playerInfo.m_userInfo.m_displayName;
			}
			return "Unnamed player";
		}

		private void PortToSelectedPlayer()
		{
			//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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			if (_selectedPlayerIndex < 0 || _selectedPlayerIndex >= _playerDestinations.Count)
			{
				ShowError("Select a connected player first.");
				return;
			}
			PlayerDestination playerDestination = _playerDestinations[_selectedPlayerIndex];
			RefreshPlayerList();
			PlayerDestination playerDestination2 = null;
			foreach (PlayerDestination playerDestination3 in _playerDestinations)
			{
				if (playerDestination3.CharacterId == playerDestination.CharacterId)
				{
					playerDestination2 = playerDestination3;
					break;
				}
			}
			if (playerDestination2 == null)
			{
				ShowError(playerDestination.Name + " is no longer connected.");
				return;
			}
			if (!playerDestination2.HasPublicPosition)
			{
				ShowError(playerDestination2.Name + " is hiding their map position.");
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				ShowError("No local player is available.");
				return;
			}
			Ship localShip = Ship.GetLocalShip();
			bool flag = (Object)(object)localShip != (Object)null;
			if (flag)
			{
				SaveBoat(localShip, force: true);
			}
			Vector3 position = ((Component)localPlayer).transform.position;
			Quaternion rotation = ((Component)localPlayer).transform.rotation;
			RecallPoint point = new RecallPoint(position, ((Quaternion)(ref rotation)).eulerAngles.y);
			Vector3 destination = playerDestination2.Position + ((Component)localPlayer).transform.right * 1.5f + Vector3.up * 1.25f;
			if (!TryTeleport(localPlayer, destination, ((Component)localPlayer).transform.rotation))
			{
				return;
			}
			if (!flag)
			{
				RecallState currentState = GetCurrentState();
				if (currentState != null)
				{
					currentState.PushLocation(point);
					_stateFile.Save();
				}
			}
			ClosePlayerMenu();
			ShowSuccess(flag ? ("Ported to " + playerDestination2.Name + ". Your ordinary return locations were left unchanged.") : ("Ported to " + playerDestination2.Name + " and saved your departure location.