Decompiled source of Fast Travel v1.2.0

FastTravel.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using SoftReferenceableAssets;
using Splatform;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("FastTravel")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1547adf59f552b01e38429c5609acd41d4de414f")]
[assembly: AssemblyProduct("FastTravel")]
[assembly: AssemblyTitle("FastTravel")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace FastTravel;

public static class CompanionBridge
{
	public class CompanionFlightData
	{
		public MonoBehaviour Setup;

		public GameObject Go;

		public Rigidbody Body;

		public ZSyncAnimation Zanim;

		public Character Character;

		public bool HasPlayerAnims;
	}

	private static bool _initialized;

	private static bool _available;

	private static Type _tCompanionSetup;

	private static Type _tCompanionAI;

	private static Type _tCompanionRest;

	private static PropertyInfo _pAllCompanions;

	private static FieldInfo _fOwnerHash;

	private static FieldInfo _fActionModeHash;

	private static FieldInfo _fFollowHash;

	private static int _ownerHashValue;

	private static int _actionModeHashValue;

	private static int _followHashValue;

	private static MethodInfo _mCanWearArmor;

	private static FieldInfo _fFreezeTimer;

	private static MethodInfo _mSetFollowTarget;

	private static MethodInfo _mCancelDirected;

	private static readonly List<CompanionFlightData> _attached = new List<CompanionFlightData>();

	public static bool HasAttachedCompanions => _attached.Count > 0;

	private static void Init()
	{
		if (_initialized)
		{
			return;
		}
		_initialized = true;
		Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
		foreach (Assembly assembly in assemblies)
		{
			_tCompanionSetup = assembly.GetType("Companions.CompanionSetup");
			if (_tCompanionSetup != null)
			{
				_tCompanionAI = assembly.GetType("Companions.CompanionAI");
				_tCompanionRest = assembly.GetType("Companions.CompanionRest");
				break;
			}
		}
		if (_tCompanionSetup == null)
		{
			_available = false;
			ZLog.Log((object)"[FastTravel] HaldorCompanions not detected — companion support disabled");
			return;
		}
		_available = true;
		BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
		_pAllCompanions = _tCompanionSetup.GetProperty("AllCompanions", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
		_fOwnerHash = _tCompanionSetup.GetField("OwnerHash", bindingAttr);
		_fActionModeHash = _tCompanionSetup.GetField("ActionModeHash", bindingAttr);
		_fFollowHash = _tCompanionSetup.GetField("FollowHash", bindingAttr);
		_mCanWearArmor = _tCompanionSetup.GetMethod("CanWearArmor", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
		if (_fOwnerHash != null)
		{
			_ownerHashValue = (int)_fOwnerHash.GetValue(null);
		}
		if (_fActionModeHash != null)
		{
			_actionModeHashValue = (int)_fActionModeHash.GetValue(null);
		}
		if (_fFollowHash != null)
		{
			_followHashValue = (int)_fFollowHash.GetValue(null);
		}
		if (_tCompanionAI != null)
		{
			_fFreezeTimer = _tCompanionAI.GetField("FreezeTimer", bindingAttr);
			_mSetFollowTarget = _tCompanionAI.GetMethod("SetFollowTarget", BindingFlags.Instance | BindingFlags.Public);
		}
		if (_tCompanionRest != null)
		{
			_mCancelDirected = _tCompanionRest.GetMethod("CancelDirected", BindingFlags.Instance | BindingFlags.Public);
		}
		ZLog.Log((object)"[FastTravel] HaldorCompanions detected — companion fast travel enabled");
	}

	public static int GatherAndAttachCompanions(float maxRange)
	{
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: 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_0147: Unknown result type (might be due to invalid IL or missing references)
		Init();
		_attached.Clear();
		if (!_available)
		{
			return 0;
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null)
		{
			return 0;
		}
		string text = localPlayer.GetPlayerID().ToString();
		if (!(_pAllCompanions?.GetValue(null) is IEnumerable enumerable))
		{
			return 0;
		}
		foreach (object item in enumerable)
		{
			MonoBehaviour val = (MonoBehaviour)((item is MonoBehaviour) ? item : null);
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			ZNetView component = ((Component)val).GetComponent<ZNetView>();
			if (((component != null) ? component.GetZDO() : null) == null)
			{
				continue;
			}
			ZDO zDO = component.GetZDO();
			if (zDO.GetString(_ownerHashValue, "") != text || zDO.GetInt(_actionModeHashValue, 0) == 4 || !zDO.GetBool(_followHashValue, true) || Vector3.Distance(((Component)val).transform.position, ((Component)localPlayer).transform.position) > maxRange)
			{
				continue;
			}
			if (_tCompanionRest != null && _mCancelDirected != null)
			{
				Component component2 = ((Component)val).GetComponent(_tCompanionRest);
				MonoBehaviour val2 = (MonoBehaviour)(object)((component2 is MonoBehaviour) ? component2 : null);
				if ((Object)(object)val2 != (Object)null)
				{
					try
					{
						_mCancelDirected.Invoke(val2, null);
					}
					catch
					{
					}
				}
			}
			if (_tCompanionAI != null)
			{
				Component component3 = ((Component)val).GetComponent(_tCompanionAI);
				MonoBehaviour val3 = (MonoBehaviour)(object)((component3 is MonoBehaviour) ? component3 : null);
				if ((Object)(object)val3 != (Object)null)
				{
					_mSetFollowTarget?.Invoke(val3, new object[1]);
					_fFreezeTimer?.SetValue(val3, 999999f);
				}
			}
			CompanionFlightData companionFlightData = new CompanionFlightData
			{
				Setup = val,
				Go = ((Component)val).gameObject,
				Body = ((Component)val).GetComponent<Rigidbody>(),
				Zanim = ((Component)val).GetComponent<ZSyncAnimation>(),
				Character = ((Component)val).GetComponent<Character>(),
				HasPlayerAnims = false
			};
			if (_mCanWearArmor != null)
			{
				try
				{
					companionFlightData.HasPlayerAnims = (bool)_mCanWearArmor.Invoke(val, null);
				}
				catch
				{
				}
			}
			if ((Object)(object)companionFlightData.Body != (Object)null)
			{
				companionFlightData.Body.linearVelocity = Vector3.zero;
				companionFlightData.Body.angularVelocity = Vector3.zero;
				companionFlightData.Body.useGravity = false;
				companionFlightData.Body.isKinematic = true;
			}
			if ((Object)(object)companionFlightData.Zanim != (Object)null && companionFlightData.HasPlayerAnims)
			{
				try
				{
					companionFlightData.Zanim.SetBool("attach_chair", true);
				}
				catch
				{
				}
			}
			Character character = companionFlightData.Character;
			Humanoid val4 = (Humanoid)(object)((character is Humanoid) ? character : null);
			if ((Object)(object)val4 != (Object)null)
			{
				try
				{
					val4.HideHandItems(false, true);
				}
				catch
				{
				}
			}
			_attached.Add(companionFlightData);
			ZLog.Log((object)("[FastTravel] Attached companion '" + ((Object)((Component)val).gameObject).name + "' for flight"));
		}
		ZLog.Log((object)$"[FastTravel] {_attached.Count} companion(s) attached for fast travel");
		return _attached.Count;
	}

	public static void SyncCompanionPositions(Transform playerMount, Transform vehicleRoot)
	{
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: 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_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: 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_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: 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_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		if (_attached.Count == 0 || (Object)(object)playerMount == (Object)null)
		{
			return;
		}
		Vector3 val = (((Object)(object)vehicleRoot != (Object)null) ? (-vehicleRoot.forward) : (-playerMount.forward));
		Vector3 val2 = playerMount.position + val * 0.7f + new Vector3(0f, -0.25f, 0f);
		Quaternion rotation = (((Object)(object)vehicleRoot != (Object)null) ? vehicleRoot.rotation : playerMount.rotation);
		for (int i = 0; i < _attached.Count; i++)
		{
			CompanionFlightData companionFlightData = _attached[i];
			if ((Object)(object)companionFlightData.Go == (Object)null)
			{
				continue;
			}
			float num = 0f;
			if (_attached.Count > 1)
			{
				int num2 = i + 1;
				float num3 = ((num2 % 2 == 0) ? 1f : (-1f));
				float num4 = (float)((num2 + 1) / 2) * 0.6f;
				num = num3 * num4;
			}
			Vector3 val3 = (((Object)(object)vehicleRoot != (Object)null) ? (vehicleRoot.right * num) : (Vector3.right * num));
			companionFlightData.Go.transform.position = val2 + val3;
			companionFlightData.Go.transform.rotation = rotation;
			if ((Object)(object)companionFlightData.Body != (Object)null)
			{
				companionFlightData.Body.position = companionFlightData.Go.transform.position;
				companionFlightData.Body.linearVelocity = Vector3.zero;
			}
			if (_fFreezeTimer != null && _tCompanionAI != null)
			{
				Component component = companionFlightData.Go.GetComponent(_tCompanionAI);
				if ((Object)(object)component != (Object)null)
				{
					_fFreezeTimer.SetValue(component, 999999f);
				}
			}
		}
	}

	public static void DetachAllCompanions(Vector3 destination)
	{
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: 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_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		FieldInfo fieldInfo = AccessTools.Field(typeof(Character), "m_maxAirAltitude");
		foreach (CompanionFlightData item in _attached)
		{
			if ((Object)(object)item.Go == (Object)null)
			{
				continue;
			}
			if ((Object)(object)item.Zanim != (Object)null && item.HasPlayerAnims)
			{
				try
				{
					item.Zanim.SetBool("attach_chair", false);
				}
				catch
				{
				}
			}
			Vector3 val = FindNearbyPosition(destination, 3f);
			item.Go.transform.position = val;
			fieldInfo?.SetValue(item.Character, val.y + 1f);
			if ((Object)(object)item.Body != (Object)null)
			{
				item.Body.isKinematic = false;
				item.Body.useGravity = true;
				item.Body.linearVelocity = Vector3.zero;
				item.Body.position = val;
			}
			if (_tCompanionAI != null)
			{
				Component component = item.Go.GetComponent(_tCompanionAI);
				MonoBehaviour val2 = (MonoBehaviour)(object)((component is MonoBehaviour) ? component : null);
				if ((Object)(object)val2 != (Object)null)
				{
					_fFreezeTimer?.SetValue(val2, 0f);
					if ((Object)(object)Player.m_localPlayer != (Object)null)
					{
						_mSetFollowTarget?.Invoke(val2, new object[1] { ((Component)Player.m_localPlayer).gameObject });
					}
				}
			}
			ZLog.Log((object)$"[FastTravel] Detached companion '{((Object)item.Go).name}' at {val:F1}");
		}
		_attached.Clear();
	}

	public static bool IsAttachedCompanion(Character character)
	{
		for (int i = 0; i < _attached.Count; i++)
		{
			if ((Object)(object)_attached[i].Character == (Object)(object)character)
			{
				return true;
			}
		}
		return false;
	}

	public static void EmergencyDetach()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		if (_attached.Count != 0)
		{
			Player localPlayer = Player.m_localPlayer;
			Vector3 destination = (((Object)(object)localPlayer != (Object)null) ? ((Component)localPlayer).transform.position : Vector3.zero);
			DetachAllCompanions(destination);
		}
	}

	private static Vector3 FindNearbyPosition(Vector3 origin, float radius)
	{
		//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_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: 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_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: 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_0041: 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_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		float y = default(float);
		for (int i = 0; i < 20; i++)
		{
			Vector2 val = Random.insideUnitCircle * radius;
			Vector3 val2 = origin + new Vector3(val.x, 0f, val.y);
			if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.FindFloor(val2, ref y))
			{
				val2.y = y;
				return val2;
			}
		}
		return origin + Vector3.right * 2f;
	}
}
[BepInPlugin("com.shadow.fasttravel", "Fast Travel", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static ConsoleEvent <>9__17_0;

		public static ConsoleEvent <>9__17_1;

		internal void <Awake>b__17_0(ConsoleEventArgs args)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				args.Context.AddString("No player found");
				return;
			}
			Minimap instance = Minimap.instance;
			if ((Object)(object)instance == (Object)null)
			{
				args.Context.AddString("Minimap not available");
				return;
			}
			_runestoneCount++;
			string text = "[Runestone] Runestone " + _runestoneCount;
			Vector3 position = ((Component)localPlayer).transform.position;
			EnsureRunestoneIcon(instance);
			instance.AddPin(position, RunestonePinType, text, true, false, 0L, default(PlatformUserID));
			args.Context.AddString($"Placed '{text}' at {position:F0}");
		}

		internal void <Awake>b__17_1(ConsoleEventArgs args)
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			Minimap instance = Minimap.instance;
			if ((Object)(object)instance == (Object)null)
			{
				args.Context.AddString("Minimap not available");
				return;
			}
			if ((Object)(object)ZoneSystem.instance == (Object)null)
			{
				args.Context.AddString("ZoneSystem not available");
				return;
			}
			EnsureRunestoneIcon(instance);
			int num = 0;
			foreach (LocationInstance location in ZoneSystem.instance.GetLocationList())
			{
				string name = location.m_location.m_prefab.Name;
				if (name.IndexOf("Runestone", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("RuneStone", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					_runestoneCount++;
					string text = "[Runestone] " + name + " " + _runestoneCount;
					instance.AddPin(location.m_position, RunestonePinType, text, true, false, 0L, default(PlatformUserID));
					num++;
				}
			}
			args.Context.AddString($"Added {num} runestone pins to the map");
		}
	}

	public const string PluginGUID = "com.shadow.fasttravel";

	public const string PluginName = "Fast Travel";

	public const string PluginVersion = "1.0.0";

	public static ConfigEntry<KeyCode> TravelHotkey;

	public static ConfigEntry<float> TravelSpeed;

	public static ConfigEntry<float> TravelAltitude;

	public static ConfigEntry<float> AssumedOverlandSpeed;

	private Harmony _harmony;

	public const string RunestonePrefix = "[Runestone] ";

	public static readonly PinType RunestonePinType = (PinType)100;

	private static bool _iconRegistered;

	private static int _runestoneCount;

	private static SoftReference<GameObject> _loadedValkyrie;

	private float _controllerHoldTimer;

	private const float ControllerHoldDuration = 1f;

	private static MethodInfo _screenToWorldMethod;

	private static bool _screenToWorldLookupDone;

	public static Plugin Instance { get; private set; }

	private void Awake()
	{
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Expected O, but got Unknown
		//IL_011c: 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_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_0113: Expected O, but got Unknown
		Instance = this;
		TravelHotkey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "TravelHotkey", (KeyCode)291, "Hotkey to initiate fast travel to the closest map pin under your cursor (map must be open)");
		TravelSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TravelSpeed", 25f, "Valkyrie flight speed during fast travel");
		TravelAltitude = ((BaseUnityPlugin)this).Config.Bind<float>("General", "TravelAltitude", 100f, "Starting altitude for the Valkyrie during fast travel");
		AssumedOverlandSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AssumedOverlandSpeed", 1.67f, "Assumed player overland speed (m/s) for calculating time passage during fast travel. Lower values = more time passes. Default 1.67 ≈ one-third walking speed for significant time passage");
		_harmony = Harmony.CreateAndPatchAll(typeof(ValkyriePatches), "com.shadow.fasttravel");
		object obj = <>c.<>9__17_0;
		if (obj == null)
		{
			ConsoleEvent val = delegate(ConsoleEventArgs args)
			{
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					args.Context.AddString("No player found");
				}
				else
				{
					Minimap instance2 = Minimap.instance;
					if ((Object)(object)instance2 == (Object)null)
					{
						args.Context.AddString("Minimap not available");
					}
					else
					{
						_runestoneCount++;
						string text2 = "[Runestone] Runestone " + _runestoneCount;
						Vector3 position = ((Component)localPlayer).transform.position;
						EnsureRunestoneIcon(instance2);
						instance2.AddPin(position, RunestonePinType, text2, true, false, 0L, default(PlatformUserID));
						args.Context.AddString($"Placed '{text2}' at {position:F0}");
					}
				}
			};
			<>c.<>9__17_0 = val;
			obj = (object)val;
		}
		new ConsoleCommand("spawn_runestone", "Places a runestone fast travel pin at your location", (ConsoleEvent)obj, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
		object obj2 = <>c.<>9__17_1;
		if (obj2 == null)
		{
			ConsoleEvent val2 = delegate(ConsoleEventArgs args)
			{
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0076: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				Minimap instance = Minimap.instance;
				if ((Object)(object)instance == (Object)null)
				{
					args.Context.AddString("Minimap not available");
				}
				else if ((Object)(object)ZoneSystem.instance == (Object)null)
				{
					args.Context.AddString("ZoneSystem not available");
				}
				else
				{
					EnsureRunestoneIcon(instance);
					int num = 0;
					foreach (LocationInstance location in ZoneSystem.instance.GetLocationList())
					{
						string name = location.m_location.m_prefab.Name;
						if (name.IndexOf("Runestone", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("RuneStone", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							_runestoneCount++;
							string text = "[Runestone] " + name + " " + _runestoneCount;
							instance.AddPin(location.m_position, RunestonePinType, text, true, false, 0L, default(PlatformUserID));
							num++;
						}
					}
					args.Context.AddString($"Added {num} runestone pins to the map");
				}
			};
			<>c.<>9__17_1 = val2;
			obj2 = (object)val2;
		}
		new ConsoleCommand("show_runestones", "Adds runestone pins for all RuneStone locations in the world", (ConsoleEvent)obj2, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
		((BaseUnityPlugin)this).Logger.LogInfo((object)string.Format("{0} v{1} loaded. Press {2} on the map to fast travel to a runestone pin.", "Fast Travel", "1.0.0", TravelHotkey.Value));
	}

	private void Update()
	{
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		if (!_iconRegistered && (Object)(object)Minimap.instance != (Object)null)
		{
			EnsureRunestoneIcon(Minimap.instance);
		}
		if (FastTravelState.LandingGraceTimer > 0f)
		{
			FastTravelState.LandingGraceTimer -= Time.deltaTime;
		}
		if (Input.GetKeyDown(TravelHotkey.Value))
		{
			TryInitiateFastTravel();
		}
		if ((Object)(object)Minimap.instance != (Object)null && Minimap.instance.m_largeRoot.activeSelf && !FastTravelState.IsActive)
		{
			if (Input.GetKey((KeyCode)333))
			{
				_controllerHoldTimer += Time.deltaTime;
				if (_controllerHoldTimer >= 1f)
				{
					_controllerHoldTimer = 0f;
					TryInitiateFastTravel();
				}
			}
			else
			{
				_controllerHoldTimer = 0f;
			}
		}
		else
		{
			_controllerHoldTimer = 0f;
		}
	}

	private void TryInitiateFastTravel()
	{
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: 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_0122: 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_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Expected O, but got Unknown
		//IL_0247: Expected O, but got Unknown
		//IL_0242: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Expected O, but got Unknown
		Player player = Player.m_localPlayer;
		if ((Object)(object)player == (Object)null || ((Character)player).IsDead() || ((Character)player).InCutscene() || ((Character)player).IsTeleporting() || FastTravelState.IsActive)
		{
			return;
		}
		Minimap instance = Minimap.instance;
		if ((Object)(object)instance == (Object)null || !instance.m_largeRoot.activeSelf)
		{
			return;
		}
		Vector3 worldPos;
		bool cursorWorldPoint = GetCursorWorldPoint(instance, out worldPos);
		ZLog.Log((object)$"[FastTravel] Cursor world pos: {worldPos}, hasCursor: {cursorWorldPoint}, gamepad: {ZInput.IsGamepadActive()}");
		if (!cursorWorldPoint)
		{
			worldPos = ((Component)player).transform.position;
		}
		PinData closestPin = FindClosestPin(instance, worldPos);
		if (closestPin == null)
		{
			((Character)player).Message((MessageType)2, "No runestone found near cursor", 0, (Sprite)null);
			return;
		}
		float num = Utils.DistanceXZ(((Component)player).transform.position, closestPin.m_pos);
		ZLog.Log((object)$"[FastTravel] Selected pin '{closestPin.m_name}' at {closestPin.m_pos}, dist={num:F0}m");
		if (num < 50f)
		{
			((Character)player).Message((MessageType)2, "Too close to runestone to fast travel", 0, (Sprite)null);
			return;
		}
		string pinName = (closestPin.m_name.StartsWith("[Runestone] ") ? closestPin.m_name.Substring("[Runestone] ".Length) : closestPin.m_name);
		float num2 = num / AssumedOverlandSpeed.Value;
		int num3 = Mathf.Max(1, Mathf.RoundToInt(num2 / 60f));
		UnifiedPopup.Push((PopupBase)new YesNoPopup("Fast Travel", string.Format("Travel to {0}?\n\nEstimated time: ~{1} minute{2}\n(Food and status effects will advance)", pinName, num3, (num3 != 1) ? "s" : ""), (PopupButtonCallback)delegate
		{
			UnifiedPopup.Pop();
			StartFastTravel(player, closestPin, pinName);
		}, (PopupButtonCallback)delegate
		{
			UnifiedPopup.Pop();
			((Character)player).Message((MessageType)2, "Travel cancelled", 0, (Sprite)null);
		}, false));
	}

	private void StartFastTravel(Player player, PinData pin, string pinName)
	{
		//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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		Minimap instance = Minimap.instance;
		if ((Object)(object)instance != (Object)null)
		{
			instance.SetMapMode((MapMode)0);
		}
		((Character)player).Message((MessageType)2, "Fast traveling to " + pinName + "...", 0, (Sprite)null);
		FastTravelState.IsActive = true;
		FastTravelState.Phase = FastTravelPhase.Pickup;
		FastTravelState.Destination = pin.m_pos;
		FastTravelState.StartPosition = ((Component)player).transform.position;
		FastTravelState.Speed = TravelSpeed.Value;
		FastTravelState.Altitude = TravelAltitude.Value;
		SpawnVehicle(player);
	}

	private void SpawnVehicle(Player player)
	{
		//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_0011: Unknown result type (might be due to invalid IL or missing references)
		_loadedValkyrie = player.m_valkyrie;
		_loadedValkyrie.Load();
		GameObject asset = _loadedValkyrie.Asset;
		if ((Object)(object)asset == (Object)null)
		{
			ZLog.LogError((object)"[FastTravel] Failed to load Valkyrie prefab");
			FastTravelState.Reset();
			return;
		}
		bool activeSelf = asset.activeSelf;
		asset.SetActive(false);
		GameObject val = Object.Instantiate<GameObject>(asset);
		asset.SetActive(activeSelf);
		MonoBehaviour[] componentsInChildren = val.GetComponentsInChildren<MonoBehaviour>(true);
		foreach (MonoBehaviour val2 in componentsInChildren)
		{
			Object.DestroyImmediate((Object)(object)val2);
		}
		Rigidbody[] componentsInChildren2 = val.GetComponentsInChildren<Rigidbody>(true);
		foreach (Rigidbody val3 in componentsInChildren2)
		{
			Object.DestroyImmediate((Object)(object)val3);
		}
		Collider[] componentsInChildren3 = val.GetComponentsInChildren<Collider>(true);
		foreach (Collider val4 in componentsInChildren3)
		{
			Object.DestroyImmediate((Object)(object)val4);
		}
		LODGroup[] componentsInChildren4 = val.GetComponentsInChildren<LODGroup>(true);
		foreach (LODGroup val5 in componentsInChildren4)
		{
			Object.DestroyImmediate((Object)(object)val5);
		}
		Animator componentInChildren = val.GetComponentInChildren<Animator>();
		if ((Object)(object)componentInChildren != (Object)null)
		{
			componentInChildren.applyRootMotion = false;
		}
		List<AudioClip> list = new List<AudioClip>();
		ZSFX[] componentsInChildren5 = asset.GetComponentsInChildren<ZSFX>(true);
		foreach (ZSFX val6 in componentsInChildren5)
		{
			if (val6.m_audioClips == null)
			{
				continue;
			}
			AudioClip[] audioClips = val6.m_audioClips;
			foreach (AudioClip val7 in audioClips)
			{
				if ((Object)(object)val7 != (Object)null)
				{
					list.Add(val7);
				}
			}
		}
		AudioSource[] componentsInChildren6 = asset.GetComponentsInChildren<AudioSource>(true);
		foreach (AudioSource val8 in componentsInChildren6)
		{
			if ((Object)(object)val8.clip != (Object)null)
			{
				list.Add(val8.clip);
			}
		}
		FastTravelVehicle.PendingAudioClips = list.ToArray();
		val.AddComponent<FastTravelVehicle>();
		val.SetActive(true);
	}

	private bool GetCursorWorldPoint(Minimap minimap, out Vector3 worldPos)
	{
		//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_00fa: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: 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)
		worldPos = Vector3.zero;
		if (!_screenToWorldLookupDone)
		{
			_screenToWorldLookupDone = true;
			string[] array = new string[3] { "ScreenToWorldPoint", "MapPointToWorld", "GetMapWorldPoint" };
			string[] array2 = array;
			foreach (string text in array2)
			{
				_screenToWorldMethod = AccessTools.Method(typeof(Minimap), text, (Type[])null, (Type[])null);
				if (_screenToWorldMethod != null)
				{
					ZLog.Log((object)("[FastTravel] Found minimap method: " + text));
					break;
				}
			}
			if (_screenToWorldMethod == null)
			{
				ZLog.LogWarning((object)"[FastTravel] Could not find ScreenToWorldPoint method on Minimap");
			}
		}
		if (_screenToWorldMethod == null)
		{
			return false;
		}
		Vector3 val = (Vector3)(ZInput.IsGamepadActive() ? new Vector3((float)Screen.width / 2f, (float)Screen.height / 2f, 0f) : ZInput.mousePosition);
		worldPos = (Vector3)_screenToWorldMethod.Invoke(minimap, new object[1] { val });
		return true;
	}

	private PinData FindClosestPin(Minimap minimap, Vector3 worldPos)
	{
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		FieldInfo fieldInfo = AccessTools.Field(typeof(Minimap), "m_pins");
		if (fieldInfo == null)
		{
			return null;
		}
		if (!(fieldInfo.GetValue(minimap) is List<PinData> list))
		{
			return null;
		}
		PinData result = null;
		float num = float.MaxValue;
		foreach (PinData item in list)
		{
			if (item.m_save && !string.IsNullOrEmpty(item.m_name) && item.m_name.StartsWith("[Runestone] "))
			{
				float num2 = Utils.DistanceXZ(worldPos, item.m_pos);
				if (num2 < num)
				{
					num = num2;
					result = item;
				}
			}
		}
		return result;
	}

	public static void EnsureRunestoneIcon(Minimap minimap)
	{
		//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)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Expected O, but got Unknown
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: 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_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: 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_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0312: Unknown result type (might be due to invalid IL or missing references)
		//IL_0388: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bf: 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_03d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_033b: 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_0357: Unknown result type (might be due to invalid IL or missing references)
		if (_iconRegistered)
		{
			return;
		}
		_iconRegistered = true;
		foreach (SpriteData icon in minimap.m_icons)
		{
			if (icon.m_name == RunestonePinType)
			{
				return;
			}
		}
		int num = 32;
		Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
		((Texture)val).filterMode = (FilterMode)0;
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
		Color val3 = default(Color);
		((Color)(ref val3))..ctor(0.45f, 0.42f, 0.38f, 1f);
		Color val4 = default(Color);
		((Color)(ref val4))..ctor(0.55f, 0.52f, 0.48f, 1f);
		Color val5 = default(Color);
		((Color)(ref val5))..ctor(0.2f, 0.7f, 0.9f, 1f);
		Color val6 = default(Color);
		((Color)(ref val6))..ctor(0.3f, 0.8f, 1f, 0.6f);
		Color val7 = default(Color);
		((Color)(ref val7))..ctor(0.35f, 0.3f, 0.25f, 1f);
		for (int i = 0; i < num; i++)
		{
			for (int j = 0; j < num; j++)
			{
				val.SetPixel(i, j, val2);
			}
		}
		for (int k = 8; k < 24; k++)
		{
			for (int l = 0; l < 4; l++)
			{
				val.SetPixel(k, l, val7);
			}
		}
		for (int m = 4; m < 28; m++)
		{
			float num2 = (float)(m - 4) / 24f;
			int num3 = (int)Mathf.Lerp(6f, 4f, num2);
			int num4 = 16;
			for (int n = num4 - num3; n <= num4 + num3; n++)
			{
				Color val8 = ((n < num4) ? val3 : val4);
				val.SetPixel(n, m, val8);
			}
		}
		val.SetPixel(15, 28, val3);
		val.SetPixel(16, 28, val4);
		val.SetPixel(15, 29, val3);
		val.SetPixel(16, 29, val4);
		val.SetPixel(16, 30, val3);
		for (int num5 = 8; num5 < 24; num5++)
		{
			val.SetPixel(16, num5, val5);
		}
		val.SetPixel(14, 12, val5);
		val.SetPixel(15, 12, val5);
		val.SetPixel(17, 12, val5);
		val.SetPixel(18, 12, val5);
		val.SetPixel(14, 18, val5);
		val.SetPixel(15, 18, val5);
		val.SetPixel(17, 18, val5);
		val.SetPixel(18, 18, val5);
		val.SetPixel(15, 15, val5);
		val.SetPixel(17, 15, val5);
		val.SetPixel(14, 21, val5);
		val.SetPixel(18, 21, val5);
		for (int num6 = 7; num6 < 25; num6++)
		{
			if (val.GetPixel(15, num6).a < 0.1f)
			{
				val.SetPixel(15, num6, val6);
			}
			if (val.GetPixel(17, num6).a < 0.1f)
			{
				val.SetPixel(17, num6, val6);
			}
		}
		val.Apply();
		Sprite val9 = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f);
		((Object)val9).name = "mapicon_runestone";
		SpriteData item = default(SpriteData);
		item.m_name = RunestonePinType;
		item.m_icon = val9;
		minimap.m_icons.Add(item);
		ZLog.Log((object)"[FastTravel] Registered runestone map icon");
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}
public enum FastTravelPhase
{
	None,
	Pickup,
	Travel
}
public static class FastTravelState
{
	public static bool IsActive;

	public static FastTravelPhase Phase;

	public static Vector3 Destination;

	public static Vector3 StartPosition;

	public static float Speed;

	public static float Altitude;

	public static float LandingGraceTimer;

	public static bool IsDamageImmune => IsActive || LandingGraceTimer > 0f;

	public static void Reset()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		IsActive = false;
		Phase = FastTravelPhase.None;
		Destination = Vector3.zero;
		StartPosition = Vector3.zero;
		Speed = 25f;
		Altitude = 100f;
		LandingGraceTimer = 3f;
	}
}
public static class ValkyriePatches
{
	[HarmonyPostfix]
	[HarmonyPatch(typeof(Player), "Update")]
	private static void Player_Update_Postfix(Player __instance)
	{
		SyncPlayerToMount(__instance);
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Player), "LateUpdate")]
	private static void Player_LateUpdate_Postfix(Player __instance)
	{
		SyncPlayerToMount(__instance);
	}

	private static void SyncPlayerToMount(Player player)
	{
		//IL_003c: 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_0055: 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)
		if (FastTravelVehicle.IsPlayerAttached && !((Object)(object)player != (Object)(object)Player.m_localPlayer) && !((Object)(object)FastTravelVehicle.MountPoint == (Object)null))
		{
			((Component)player).transform.position = FastTravelVehicle.MountPoint.position + new Vector3(0f, -0.25f, 0f);
			Transform vehicleRoot = FastTravelVehicle.VehicleRoot;
			if ((Object)(object)vehicleRoot != (Object)null)
			{
				((Component)player).transform.rotation = vehicleRoot.rotation;
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Character), "IsOnGround")]
	private static void Character_IsOnGround_Postfix(Character __instance, ref bool __result)
	{
		if (FastTravelVehicle.IsPlayerAttached && ((Object)(object)__instance == (Object)(object)Player.m_localPlayer || CompanionBridge.IsAttachedCompanion(__instance)))
		{
			__result = true;
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(Character), "RPC_Damage")]
	private static bool Character_RPC_Damage_Prefix(Character __instance)
	{
		if (!FastTravelState.IsDamageImmune)
		{
			return true;
		}
		if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer)
		{
			return false;
		}
		if (CompanionBridge.IsAttachedCompanion(__instance))
		{
			return false;
		}
		return true;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(RuneStone), "Interact")]
	private static void RuneStone_Interact_Postfix(RuneStone __instance, bool hold)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: 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_0120: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		if (hold)
		{
			return;
		}
		Minimap instance = Minimap.instance;
		if ((Object)(object)instance == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)__instance).transform.position;
		FieldInfo fieldInfo = AccessTools.Field(typeof(Minimap), "m_pins");
		if (fieldInfo != null && fieldInfo.GetValue(instance) is List<PinData> list)
		{
			foreach (PinData item in list)
			{
				if (item.m_name != null && item.m_name.StartsWith("[Runestone] ") && Utils.DistanceXZ(item.m_pos, position) < 10f)
				{
					return;
				}
			}
		}
		Plugin.EnsureRunestoneIcon(instance);
		string text = (string.IsNullOrEmpty(__instance.m_name) ? "Unknown Runestone" : __instance.m_name);
		string text2 = "[Runestone] " + text;
		instance.AddPin(position, Plugin.RunestonePinType, text2, true, false, 0L, default(PlatformUserID));
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer != (Object)null)
		{
			((Character)localPlayer).Message((MessageType)1, "Runestone discovered: " + text, 0, (Sprite)null);
		}
	}
}
public class FastTravelVehicle : MonoBehaviour
{
	private float m_speed;

	private float m_turnRate = 90f;

	private GameObject m_mountPointObj;

	public static Transform MountPoint;

	public static Transform VehicleRoot;

	public static bool IsPlayerAttached;

	private Vector3 m_targetPoint;

	private Vector3 m_flyAwayPoint;

	private bool m_droppedPlayer;

	private Animator m_animator;

	private float m_cruiseY;

	private float m_textTimer;

	private int m_textIndex;

	private static FieldInfo _fCharBody;

	private static FieldInfo _fMaxAirAlt;

	private static FieldInfo _fZanim;

	private static MethodInfo _mAttachStart;

	private static MethodInfo _mAttachStop;

	private static bool _reflectionCached;

	private const float DropHeight = 3f;

	private const float DescentDist = 200f;

	private const float PickupHeight = 3f;

	private static readonly string[] m_texts = new string[5] { "The Valkyries are watching over you.", "Your journey is blessed by the gods.", "The wind carries you swiftly.", "Odin guides your path.", "The ravens watch from above." };

	public static AudioClip[] PendingAudioClips;

	private List<AudioSource> m_flightAudioSources = new List<AudioSource>();

	private static void CacheReflection()
	{
		if (!_reflectionCached)
		{
			_reflectionCached = true;
			_fCharBody = AccessTools.Field(typeof(Character), "m_body");
			_fMaxAirAlt = AccessTools.Field(typeof(Character), "m_maxAirAltitude");
			_fZanim = AccessTools.Field(typeof(Character), "m_zanim");
			_mAttachStart = AccessTools.Method(typeof(Character), "AttachStart", (Type[])null, (Type[])null);
			_mAttachStop = AccessTools.Method(typeof(Character), "AttachStop", (Type[])null, (Type[])null);
			if (_mAttachStart == null)
			{
				ZLog.LogWarning((object)"[FastTravel] AttachStart not found");
			}
			if (_mAttachStop == null)
			{
				ZLog.LogWarning((object)"[FastTravel] AttachStop not found");
			}
		}
	}

	private void Awake()
	{
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Expected O, but got Unknown
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: 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_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0198: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: 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_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: 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_0239: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0240: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_0249: 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)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		CacheReflection();
		m_speed = FastTravelState.Speed;
		m_animator = ((Component)this).GetComponentInChildren<Animator>();
		VehicleRoot = ((Component)this).transform;
		StringBuilder stringBuilder = new StringBuilder("[FastTravel] Valkyrie bones: ");
		Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true);
		foreach (Transform val in componentsInChildren)
		{
			stringBuilder.Append(((Object)val).name).Append(", ");
		}
		ZLog.Log((object)stringBuilder.ToString());
		Transform val2 = null;
		Transform[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Transform>(true);
		foreach (Transform val3 in componentsInChildren2)
		{
			if (((Object)val3).name == "spine2")
			{
				val2 = val3;
				break;
			}
		}
		Transform val4 = (((Object)(object)val2 != (Object)null) ? val2 : ((Component)this).transform);
		ZLog.Log((object)("[FastTravel] Mount parent: " + ((Object)val4).name));
		m_mountPointObj = new GameObject("FastTravelMountPoint");
		m_mountPointObj.transform.parent = val4;
		m_mountPointObj.transform.localPosition = Vector3.zero;
		m_mountPointObj.transform.localRotation = Quaternion.Euler(0f, 180f, 0f);
		MountPoint = m_mountPointObj.transform;
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		m_targetPoint = position + new Vector3(0f, 3f, 0f);
		Vector3 destination = FastTravelState.Destination;
		Vector3 val5 = default(Vector3);
		((Vector3)(ref val5))..ctor(position.x - destination.x, 0f, position.z - destination.z);
		Vector3 val6 = ((((Vector3)(ref val5)).sqrMagnitude > 1f) ? ((Vector3)(ref val5)).normalized : (((Component)Player.m_localPlayer).transform.forward * -1f));
		Vector3 val7 = m_targetPoint + val6 * 40f;
		val7.y = m_targetPoint.y;
		((Component)this).transform.position = val7;
		Transform transform = ((Component)this).transform;
		Vector3 val8 = m_targetPoint - val7;
		transform.rotation = Quaternion.LookRotation(((Vector3)(ref val8)).normalized);
		m_flyAwayPoint = destination - val6 * 200f;
		m_flyAwayPoint.y = 200f;
		ZLog.Log((object)$"[FastTravel] Vehicle spawned at {val7:F0}, pickup at {m_targetPoint:F0}");
	}

	private void Update()
	{
		float deltaTime = Time.deltaTime;
		if (FastTravelState.IsActive)
		{
			if (FastTravelState.Phase == FastTravelPhase.Pickup)
			{
				UpdatePickup(deltaTime);
			}
			else if (FastTravelState.Phase == FastTravelPhase.Travel)
			{
				UpdateTravel(deltaTime);
			}
		}
		if (IsPlayerAttached && (Object)(object)MountPoint != (Object)null)
		{
			CompanionBridge.SyncCompanionPositions(MountPoint, VehicleRoot);
		}
		if (m_droppedPlayer)
		{
			UpdateFlyAway(deltaTime);
		}
	}

	private void UpdatePickup(float dt)
	{
		//IL_0002: 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_00dd: 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_0048: 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)
		if (Utils.DistanceXZ(m_targetPoint, ((Component)this).transform.position) < 0.5f)
		{
			FastTravelState.Phase = FastTravelPhase.Travel;
			float num = ((Component)this).transform.position.y;
			float num2 = default(float);
			if (ZoneSystem.instance.GetGroundHeight(((Component)this).transform.position, ref num2))
			{
				num = num2;
			}
			m_cruiseY = num + FastTravelState.Altitude;
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				AttachPlayer(localPlayer);
			}
			CompanionBridge.GatherAndAttachCompanions(30f);
			StartFlightAudio();
			m_textTimer = 0f;
			m_textIndex = 0;
			ShowNextText();
			ZLog.Log((object)$"[FastTravel] Picked up player. MountPoint world pos: {MountPoint.position:F1}, cruiseY={m_cruiseY:F1}");
		}
		else
		{
			FlyToward(m_targetPoint, dt);
		}
	}

	private void UpdateTravel(float dt)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: 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_001f: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: 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_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		Vector3 destination = FastTravelState.Destination;
		Vector3 position = ((Component)this).transform.position;
		float num = destination.y;
		float num2 = default(float);
		if (ZoneSystem.instance.GetGroundHeight(destination, ref num2))
		{
			num = num2;
		}
		float num3 = num + 3f;
		float num4 = Utils.DistanceXZ(position, destination);
		if (num4 < 2f)
		{
			HandleArrival(destination, num, num3);
			return;
		}
		Vector3 val = new Vector3(destination.x - position.x, 0f, destination.z - position.z);
		Vector3 normalized = ((Vector3)(ref val)).normalized;
		Vector3 target = position + normalized * 25f;
		target.y = ((num4 > 200f) ? m_cruiseY : Mathf.Lerp(num3, m_cruiseY, num4 / 200f));
		FlyToward(target, dt);
		m_textTimer += dt;
		if (m_textTimer > 30f)
		{
			m_textTimer = 0f;
			ShowNextText();
		}
	}

	private void FlyToward(Vector3 target, float dt)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//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_0014: 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_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: 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)
		Vector3 position = ((Component)this).transform.position;
		Vector3 val = target - position;
		Vector3 normalized = ((Vector3)(ref val)).normalized;
		Vector3 val2 = position + normalized * 25f;
		float num = default(float);
		if (ZoneSystem.instance.GetGroundHeight(val2, ref num))
		{
			val2.y = Mathf.Max(val2.y, num + 3f);
		}
		val = val2 - position;
		Vector3 normalized2 = ((Vector3)(ref val)).normalized;
		Quaternion val3 = Quaternion.LookRotation(normalized2);
		Vector3 val4 = normalized2;
		val4.y = 0f;
		((Vector3)(ref val4)).Normalize();
		Vector3 forward = ((Component)this).transform.forward;
		forward.y = 0f;
		((Vector3)(ref forward)).Normalize();
		float num2 = Mathf.Clamp(Vector3.SignedAngle(forward, val4, Vector3.up), -30f, 30f) / 30f;
		val3 = Quaternion.Euler(0f, 0f, num2 * 45f) * val3;
		((Component)this).transform.rotation = Quaternion.RotateTowards(((Component)this).transform.rotation, val3, m_turnRate * dt);
		Vector3 val5 = position + ((Component)this).transform.forward * m_speed * dt;
		float num3 = default(float);
		if (ZoneSystem.instance.GetGroundHeight(val5, ref num3))
		{
			val5.y = Mathf.Max(val5.y, num3 + 3f);
		}
		((Component)this).transform.position = val5;
	}

	private void UpdateFlyAway(float dt)
	{
		//IL_0003: 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_001b: Unknown result type (might be due to invalid IL or missing references)
		FlyToward(m_flyAwayPoint, dt);
		if (Utils.DistanceXZ(((Component)this).transform.position, m_flyAwayPoint) < 1f)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}
	}

	private void HandleArrival(Vector3 dest, float destGroundY, float dropY)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Expected O, but got Unknown
		//IL_00e6: 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_0100: Unknown result type (might be due to invalid IL or missing references)
		ZLog.Log((object)"[FastTravel] Arrived at destination.");
		((Component)this).transform.position = new Vector3(dest.x, dropY, dest.z);
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer != (Object)null)
		{
			DetachPlayer(localPlayer);
			Vector3 forward = ((Component)this).transform.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			Quaternion rotation = Quaternion.LookRotation(forward);
			((Component)localPlayer).transform.position = new Vector3(dest.x, dropY, dest.z);
			((Component)localPlayer).transform.rotation = rotation;
			_fMaxAirAlt?.SetValue(localPlayer, dropY);
			if (_fCharBody != null)
			{
				Rigidbody val = (Rigidbody)_fCharBody.GetValue(localPlayer);
				if ((Object)(object)val != (Object)null)
				{
					val.linearVelocity = Vector3.zero;
					val.angularVelocity = Vector3.zero;
					val.rotation = rotation;
				}
			}
			if (_fZanim != null)
			{
				object? value = _fZanim.GetValue(localPlayer);
				ZSyncAnimation val2 = (ZSyncAnimation)((value is ZSyncAnimation) ? value : null);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.SetBool("attach_chair", false);
				}
			}
			ApplyTravelTime(localPlayer);
		}
		CompanionBridge.DetachAllCompanions(dest);
		MountPoint = null;
		VehicleRoot = null;
		m_droppedPlayer = true;
		if ((Object)(object)m_animator != (Object)null)
		{
			m_animator.SetBool("dropped", true);
		}
		StopFlightAudio();
		if ((Object)(object)Chat.instance != (Object)null)
		{
			Chat.instance.ClearNpcText(((Component)this).gameObject);
		}
		FastTravelState.Reset();
	}

	private void AttachPlayer(Player player)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		if (_mAttachStart != null)
		{
			try
			{
				_mAttachStart.Invoke(player, new object[8]
				{
					MountPoint,
					null,
					true,
					false,
					false,
					"attach_chair",
					Vector3.zero,
					null
				});
				ZLog.Log((object)"[FastTravel] AttachStart succeeded");
			}
			catch (Exception ex)
			{
				ZLog.LogWarning((object)("[FastTravel] AttachStart failed: " + ex.Message));
				FreezePlayer(player);
			}
		}
		else
		{
			FreezePlayer(player);
		}
		IsPlayerAttached = true;
	}

	private void DetachPlayer(Player player)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		IsPlayerAttached = false;
		float num = ((Component)player).transform.position.y;
		float num2 = default(float);
		if ((Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(((Component)player).transform.position, ref num2))
		{
			num = num2;
		}
		_fMaxAirAlt?.SetValue(player, num + 1f);
		if (_mAttachStop != null)
		{
			try
			{
				_mAttachStop.Invoke(player, null);
				return;
			}
			catch (Exception ex)
			{
				ZLog.LogWarning((object)("[FastTravel] AttachStop failed: " + ex.Message));
				UnfreezePlayer(player);
				return;
			}
		}
		UnfreezePlayer(player);
	}

	private static void FreezePlayer(Player player)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		if (!(_fCharBody == null))
		{
			Rigidbody val = (Rigidbody)_fCharBody.GetValue(player);
			if ((Object)(object)val != (Object)null)
			{
				val.linearVelocity = Vector3.zero;
				val.isKinematic = true;
			}
		}
	}

	private static void UnfreezePlayer(Player player)
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		if (!(_fCharBody == null))
		{
			Rigidbody val = (Rigidbody)_fCharBody.GetValue(player);
			if ((Object)(object)val != (Object)null)
			{
				val.isKinematic = false;
			}
		}
	}

	private static void ApplyTravelTime(Player player)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		float num = Utils.DistanceXZ(FastTravelState.StartPosition, FastTravelState.Destination);
		float num2 = Plugin.AssumedOverlandSpeed.Value;
		if (num2 <= 0f)
		{
			num2 = 1.67f;
		}
		float num3 = num / num2;
		if (num3 < 1f)
		{
			return;
		}
		int num4 = 0;
		List<Food> foods = player.GetFoods();
		for (int num5 = foods.Count - 1; num5 >= 0; num5--)
		{
			Food val = foods[num5];
			val.m_time -= num3;
			if (val.m_time <= 0f)
			{
				foods.RemoveAt(num5);
				num4++;
			}
			else
			{
				float num6 = Mathf.Pow(Mathf.Clamp01(val.m_time / val.m_item.m_shared.m_foodBurnTime), 0.3f);
				val.m_health = val.m_item.m_shared.m_food * num6;
				val.m_stamina = val.m_item.m_shared.m_foodStamina * num6;
				val.m_eitr = val.m_item.m_shared.m_foodEitr * num6;
			}
		}
		MethodInfo methodInfo = AccessTools.Method(typeof(Player), "GetTotalFoodValue", new Type[3]
		{
			typeof(float).MakeByRefType(),
			typeof(float).MakeByRefType(),
			typeof(float).MakeByRefType()
		}, (Type[])null);
		object[] array = new object[3] { 0f, 0f, 0f };
		methodInfo?.Invoke(player, array);
		AccessTools.Method(typeof(Player), "SetMaxHealth", new Type[2]
		{
			typeof(float),
			typeof(bool)
		}, (Type[])null)?.Invoke(player, new object[2]
		{
			(float)array[0],
			false
		});
		AccessTools.Method(typeof(Player), "SetMaxStamina", new Type[2]
		{
			typeof(float),
			typeof(bool)
		}, (Type[])null)?.Invoke(player, new object[2]
		{
			(float)array[1],
			false
		});
		AccessTools.Method(typeof(Player), "SetMaxEitr", new Type[2]
		{
			typeof(float),
			typeof(bool)
		}, (Type[])null)?.Invoke(player, new object[2]
		{
			(float)array[2],
			false
		});
		int num7 = 0;
		FieldInfo fieldInfo = AccessTools.Field(typeof(StatusEffect), "m_time");
		foreach (StatusEffect statusEffect in ((Character)player).GetSEMan().GetStatusEffects())
		{
			if (statusEffect.m_ttl > 0f && fieldInfo != null)
			{
				fieldInfo.SetValue(statusEffect, (float)fieldInfo.GetValue(statusEffect) + num3);
				num7++;
			}
		}
		int num8 = Mathf.FloorToInt(num3 / 60f);
		if (num8 > 0)
		{
			((Character)player).Message((MessageType)1, string.Format("{0} minute{1} have passed during your journey.", num8, (num8 != 1) ? "s" : ""), 0, (Sprite)null);
		}
		else
		{
			((Character)player).Message((MessageType)1, "A short time has passed during your journey.", 0, (Sprite)null);
		}
		ZLog.Log((object)$"[FastTravel] Travel time: {num3:F1}s ({num:F0}m), expired {num4} foods, advanced {num7} effects");
	}

	private void ShowNextText()
	{
		//IL_001d: 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 (!((Object)(object)Chat.instance == (Object)null))
		{
			Chat.instance.SetNpcText(((Component)this).gameObject, Vector3.up * 3f, 20f, 14f, "", m_texts[m_textIndex++ % m_texts.Length], false);
		}
	}

	private void StartFlightAudio()
	{
		AudioSource[] componentsInChildren = ((Component)this).GetComponentsInChildren<AudioSource>(true);
		foreach (AudioSource val in componentsInChildren)
		{
			if ((Object)(object)val.clip != (Object)null)
			{
				val.loop = true;
				val.volume = 0.5f;
				val.spatialBlend = 0f;
				val.Play();
				m_flightAudioSources.Add(val);
				ZLog.Log((object)("[FastTravel] Playing existing AudioSource clip: " + ((Object)val.clip).name));
			}
		}
		if (PendingAudioClips != null)
		{
			AudioClip[] pendingAudioClips = PendingAudioClips;
			foreach (AudioClip val2 in pendingAudioClips)
			{
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				bool flag = false;
				foreach (AudioSource flightAudioSource in m_flightAudioSources)
				{
					if ((Object)(object)flightAudioSource.clip == (Object)(object)val2)
					{
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					AudioSource val3 = ((Component)this).gameObject.AddComponent<AudioSource>();
					val3.clip = val2;
					val3.loop = true;
					val3.volume = 0.5f;
					val3.spatialBlend = 0f;
					val3.Play();
					m_flightAudioSources.Add(val3);
					ZLog.Log((object)("[FastTravel] Playing pending AudioClip: " + ((Object)val2).name));
				}
			}
		}
		ZLog.Log((object)$"[FastTravel] Flight audio: {m_flightAudioSources.Count} source(s) playing");
	}

	private void StopFlightAudio()
	{
		foreach (AudioSource flightAudioSource in m_flightAudioSources)
		{
			if ((Object)(object)flightAudioSource != (Object)null)
			{
				flightAudioSource.Stop();
				Object.Destroy((Object)(object)flightAudioSource);
			}
		}
		m_flightAudioSources.Clear();
	}

	private void OnDestroy()
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		IsPlayerAttached = false;
		MountPoint = null;
		VehicleRoot = null;
		if (FastTravelState.IsActive)
		{
			ZLog.LogWarning((object)"[FastTravel] Vehicle destroyed mid-flight.");
			CompanionBridge.EmergencyDetach();
			FastTravelState.Reset();
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				DetachPlayer(localPlayer);
				_fMaxAirAlt?.SetValue(localPlayer, ((Component)localPlayer).transform.position.y);
			}
		}
	}
}