Decompiled source of SledTpMod v1.0.2

SledTpMod.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using Il2Cpp;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using MelonLoader;
using SledTpMod;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(global::SledTpMod.SledTpMod), "Sled Theft Auto — TP", "1.0.2", "Mute", null)]
[assembly: MelonGame("", "Sledding Game")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("SledTpMod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SledTpMod")]
[assembly: AssemblyTitle("SledTpMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SledTpMod;

public class SledTpMod : MelonMod
{
	private class Waypoint
	{
		public string Name;

		public float X;

		public float Y;

		public float Z;

		public Waypoint(string n, float x, float y, float z)
		{
			Name = n;
			X = x;
			Y = y;
			Z = z;
		}
	}

	private class PlayerEntry
	{
		public string Name;

		public Vector3 Pos;

		public string PosStr;

		public PlayerEntry(string n, Vector3 p)
		{
			//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_001a: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			Name = n;
			Pos = p;
			PosStr = $"({p.x:F0}, {p.y:F0}, {p.z:F0})";
		}
	}

	private bool _show;

	private Rect _winRect;

	private bool _rectInit;

	private Vector2 _scroll;

	private const int WIN_ID = 22337;

	private bool _stylesReady;

	private GUIStyle _winStyle;

	private GUIStyle _titleStyle;

	private GUIStyle _sectionStyle;

	private GUIStyle _btnStyle;

	private GUIStyle _btnDangerStyle;

	private GUIStyle _labelStyle;

	private GUIStyle _dimStyle;

	private GUIStyle _accentStyle;

	private GUIStyle _fieldStyle;

	private GUIStyle _toggleStyle;

	private GUIStyle _tagStyle;

	private GUIStyle _statusStyle;

	private GUIStyle _closeStyle;

	private string _status = "";

	private float _statusUntil;

	private readonly Dictionary<string, MethodInfo> _miCache = new Dictionary<string, MethodInfo>();

	private Camera _mainCamCache;

	private bool _tpLocked;

	private GUIStyle _bannerStyle;

	private bool _bannerStyleReady;

	private static readonly string WaypointsFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "SledTpMod_Waypoints.json");

	private float _tpHeight = 50f;

	private string _tpX = "0";

	private string _tpY = "100";

	private string _tpZ = "0";

	private readonly List<Waypoint> _waypoints = new List<Waypoint>();

	private string _wpName = "MyWaypoint";

	private readonly List<PlayerEntry> _players = new List<PlayerEntry>();

	private bool _gtaCamActive;

	private float _gtaCamProgress;

	private const float _gtaCamDuration = 8f;

	private GameObject _gtaCamGO;

	private Camera _gtaCam;

	private static readonly Color GTA_BLACK = new Color(0.06f, 0.06f, 0.06f, 1f);

	private static readonly Color GTA_DARK = new Color(0.1f, 0.1f, 0.1f, 1f);

	private static readonly Color GTA_PANEL = new Color(0.13f, 0.12f, 0.1f, 1f);

	private static readonly Color GTA_ORANGE = new Color(1f, 0.5f, 0.05f, 1f);

	private static readonly Color GTA_ORANGE2 = new Color(0.9f, 0.38f, 0f, 1f);

	private static readonly Color GTA_WHITE = new Color(0.92f, 0.9f, 0.85f, 1f);

	private static readonly Color GTA_DIM = new Color(0.55f, 0.52f, 0.45f, 1f);

	private static readonly Color GTA_GREEN = new Color(0.25f, 1f, 0.45f, 1f);

	private static readonly Color GTA_RED = new Color(1f, 0.22f, 0.18f, 1f);

	private static readonly Color GTA_ACCENT = new Color(1f, 0.75f, 0.1f, 1f);

	private Texture2D _txBtnN;

	private Texture2D _txBtnH;

	private Texture2D _txBtnA;

	private Texture2D _txBtnDN;

	private Texture2D _txBtnDH;

	private Texture2D _txPanel;

	private Texture2D _txWindow;

	private Texture2D _txHR;

	private Texture2D _txSect;

	private Texture2D _txField;

	private Texture2D _txClose;

	private Texture2D _txCloseH;

	public override void OnUpdate()
	{
		if (_tpLocked && _show)
		{
			_show = false;
		}
		if (!_tpLocked && Input.GetKeyDown((KeyCode)287))
		{
			_show = !_show;
			if (_show)
			{
				InitRect();
			}
		}
		if (_show && Input.GetKeyDown((KeyCode)27))
		{
			_show = false;
		}
		if (_gtaCamActive)
		{
			TickGtaCam();
		}
	}

	public override void OnGUI()
	{
		//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_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: 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_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		if (_tpLocked)
		{
			DrawTpBanner();
		}
		else if (_show)
		{
			EnsureStyles();
			EnsureRect();
			Color color = GUI.color;
			GUI.color = Color.white;
			GUI.DrawTexture(_winRect, (Texture)(object)(_txWindow ?? Tex(GTA_BLACK)));
			GUI.color = color;
			Color backgroundColor = GUI.backgroundColor;
			GUI.backgroundColor = Color.white;
			_winRect = GUI.Window(22337, _winRect, WindowFunction.op_Implicit((Action<int>)delegate(int id)
			{
				DrawWindow(id);
			}), "", _winStyle ?? GUI.skin.window);
			GUI.backgroundColor = backgroundColor;
		}
	}

	private void DrawTpBanner()
	{
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: 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_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		if (!_bannerStyleReady)
		{
			_bannerStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = 20,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)4
			};
			_bannerStyle.normal.textColor = new Color(0.06f, 0.06f, 0.06f, 1f);
			_bannerStyleReady = true;
		}
		float bw = 500f;
		float bh = 44f;
		float num = ((float)Screen.width - bw) / 2f;
		float num2 = (float)Screen.height - bh - 30f;
		Color backgroundColor = GUI.backgroundColor;
		Color color = GUI.color;
		GUI.backgroundColor = new Color(0f, 0f, 0f, 0f);
		GUI.color = new Color(0f, 0f, 0f, 0f);
		GUI.Window(22338, new Rect(num, num2, bw, bh), WindowFunction.op_Implicit((Action<int>)delegate
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			GUI.color = Color.white;
			GUI.Label(new Rect(0f, 0f, bw, bh), "You are currently teleporting...", _bannerStyle);
		}), "", GUIStyle.none);
		GUI.backgroundColor = backgroundColor;
		GUI.color = color;
	}

	private void DrawWindow(int id)
	{
		//IL_0010: 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_0081: Unknown result type (might be due to invalid IL or missing references)
		DrawHeader();
		DrawStatusBar();
		bool flag = false;
		try
		{
			_scroll = GUILayout.BeginScrollView(_scroll, false, false, GUI.skin.horizontalScrollbar, GUI.skin.verticalScrollbar, GUI.skin.scrollView, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			flag = true;
			DrawContent();
		}
		finally
		{
			if (flag)
			{
				GUILayout.EndScrollView();
			}
		}
		DrawFooter();
		GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _winRect)).width, 28f));
	}

	private void DrawHeader()
	{
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Expected O, but got Unknown
		//IL_005f: 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)
		GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
		string obj = (_gtaCamActive ? $"O {_gtaCamProgress * 100f:F0}%" : "* WANTED");
		GUIStyle val = new GUIStyle(_tagStyle ?? GUI.skin.label);
		val.normal.textColor = (_gtaCamActive ? GTA_ORANGE : GTA_RED);
		GUILayout.Label(obj, val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
		GUILayout.Label("SLED THEFT AUTO - Teleportation", _titleStyle ?? GUI.skin.label, (Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.FlexibleSpace();
		GUILayout.Label("F6", _dimStyle ?? GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(30f) });
		GUILayout.Space(2f);
		if (GUILayout.Button("X", _closeStyle ?? GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(24f) }))
		{
			_show = false;
		}
		GUILayout.EndHorizontal();
		DrawHR();
	}

	private void DrawStatusBar()
	{
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Expected O, but got Unknown
		//IL_007d: 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)
		if (!string.IsNullOrEmpty(_status) && !(Time.realtimeSinceStartup >= _statusUntil))
		{
			bool flag = _status.StartsWith("ERR") || _status.Contains("not found") || _status.StartsWith("Error");
			GUIStyle val = new GUIStyle(_statusStyle ?? GUI.skin.label);
			val.normal.textColor = (flag ? GTA_RED : GTA_GREEN);
			float num = _statusUntil - Time.realtimeSinceStartup;
			GUILayout.Label(((num > 3f) ? "####" : ((num > 2f) ? "###-" : ((num > 1f) ? "##--" : "#---"))) + "  " + _status, val, (Il2CppReferenceArray<GUILayoutOption>)null);
		}
	}

	private void DrawContent()
	{
		DrawSection_QuickTp();
		DrawSection_CoordTp();
		DrawSection_Waypoints();
		DrawSection_Players();
		if (_gtaCamActive)
		{
			GUILayout.Space(6f);
			Sect("CINEMATIC IN PROGRESS");
			GUILayout.Label($"Progress : {_gtaCamProgress * 100f:F0} %", _accentStyle ?? GUI.skin.label, (Il2CppReferenceArray<GUILayoutOption>)null);
			if (BtnDanger("X  CANCEL CINEMATIC"))
			{
				StopGtaCam(cancel: true);
			}
		}
	}

	private void DrawFooter()
	{
		DrawHR();
		GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.Label($"{(int)((Rect)(ref _winRect)).width}x{(int)((Rect)(ref _winRect)).height}", _dimStyle ?? GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) });
		GUILayout.FlexibleSpace();
		GUILayout.Label("F6 to close", _dimStyle ?? GUI.skin.label, (Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.EndHorizontal();
	}

	private PlayerControl P()
	{
		try
		{
			return PlayerControl.LocalPlayerInstance;
		}
		catch
		{
			return null;
		}
	}

	private void Status(string msg)
	{
		_status = msg;
		_statusUntil = Time.realtimeSinceStartup + 4f;
		MelonLogger.Msg("[SledTpMod] " + msg);
	}

	private void Try(Action a)
	{
		try
		{
			a();
		}
		catch (Exception ex)
		{
			Status("ERR " + ex.Message);
			MelonLogger.Msg("[SledTpMod][ERR] " + ex);
		}
	}

	private void DrawSection_QuickTp()
	{
		Sect("QUICK TELEPORT");
		Slider("Height (m)", ref _tpHeight, 1f, 1000f, 50f);
		GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
		if (Btn("↑  Move up " + (int)_tpHeight + " m"))
		{
			TpUp(_tpHeight);
		}
		if (Btn("Y = 0"))
		{
			TpY(0f);
		}
		if (Btn("Y = 200"))
		{
			TpY(200f);
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
		if (Btn("↺  Reset position"))
		{
			ResetPosition();
		}
		if (Btn("\ud83c\udfe0  Lodge"))
		{
			ResetToLodge();
		}
		if (Btn("\ud83c\udfc1  Race start"))
		{
			ResetToRaceStart();
		}
		GUILayout.EndHorizontal();
	}

	private void DrawSection_CoordTp()
	{
		//IL_0179: Unknown result type (might be due to invalid IL or missing references)
		Sect("TELEPORT BY COORDINATES  ·  GTA CINEMATIC");
		GUILayout.Label("The camera flies GTA-style before diving to the destination.", _dimStyle ?? GUI.skin.label, (Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.Label("X:", _dimStyle ?? GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(18f) });
		_tpX = Field(_tpX, 75f);
		GUILayout.Space(4f);
		GUILayout.Label("Y:", _dimStyle ?? GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(18f) });
		_tpY = Field(_tpY, 75f);
		GUILayout.Space(4f);
		GUILayout.Label("Z:", _dimStyle ?? GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(18f) });
		_tpZ = Field(_tpZ, 75f);
		GUILayout.Space(4f);
		if (Btn("✈  GO", 70f))
		{
			float num = ParseF(_tpX, 0f);
			float num2 = ParseF(_tpY, 100f);
			float num3 = ParseF(_tpZ, 0f);
			TpGTA(new Vector3(num, num2, num3));
		}
		GUILayout.EndHorizontal();
		GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
		if (Btn("\ud83d\udccb  Copy my position"))
		{
			CopyPos();
		}
		GUILayout.EndHorizontal();
	}

	private void DrawSection_Waypoints()
	{
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Expected O, but got Unknown
		//IL_00f1: 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)
		Sect("SAVED WAYPOINTS  ·  GTA CINEMATIC");
		GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.Label("Name:", _dimStyle ?? GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) });
		_wpName = Field(_wpName, 140f);
		GUILayout.Space(4f);
		if (Btn("\ud83d\udcbe  Save here", 130f))
		{
			SaveWaypoint();
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		if (_waypoints.Count == 0)
		{
			GUILayout.Label("  (no waypoints — save your position first)", _dimStyle ?? GUI.skin.label, (Il2CppReferenceArray<GUILayoutOption>)null);
			return;
		}
		for (int i = 0; i < _waypoints.Count; i++)
		{
			Waypoint waypoint = _waypoints[i];
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUIStyle val = new GUIStyle(_labelStyle ?? GUI.skin.label);
			val.normal.textColor = GTA_ORANGE;
			val.fontStyle = (FontStyle)1;
			GUILayout.Label(waypoint.Name, val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(140f) });
			GUILayout.Label($"{waypoint.X:F0},{waypoint.Y:F0},{waypoint.Z:F0}", _dimStyle ?? GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if (Btn("✈ TP", 50f))
			{
				TpGTA(new Vector3(waypoint.X, waypoint.Y, waypoint.Z));
			}
			if (Btn("\ud83d\udcdd", 26f))
			{
				LoadWpToInput(waypoint);
			}
			if (Btn("✕", 24f))
			{
				_waypoints.RemoveAt(i);
				SaveWaypoints();
				break;
			}
			GUILayout.EndHorizontal();
		}
	}

	private void DrawSection_Players()
	{
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Expected O, but got Unknown
		//IL_0127: 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)
		Sect("TELEPORT TO PLAYER  ·  GTA CINEMATIC");
		GUILayout.Label("Scans all PlayerControl instances in the scene.", _dimStyle ?? GUI.skin.label, (Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.Space(4f);
		GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
		if (Btn("\ud83d\udd0d  Scan"))
		{
			ScanPlayers();
		}
		if (Btn("\ud83d\udd04  Refresh"))
		{
			ScanPlayers();
		}
		GUILayout.EndHorizontal();
		GUILayout.Space(4f);
		if (_players.Count == 0)
		{
			GUILayout.Label("  ● No players found — press Scan", _dimStyle ?? GUI.skin.label, (Il2CppReferenceArray<GUILayoutOption>)null);
			return;
		}
		GUILayout.Label("  " + _players.Count + " player(s) online:", _dimStyle ?? GUI.skin.label, (Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.Space(3f);
		foreach (PlayerEntry player in _players)
		{
			if (player != null)
			{
				GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
				GUIStyle val = new GUIStyle(_labelStyle ?? GUI.skin.label);
				val.normal.textColor = GTA_ORANGE;
				val.fontStyle = (FontStyle)1;
				GUILayout.Label(player.Name, val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(170f) });
				GUILayout.Label(player.PosStr, _dimStyle ?? GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
				if (Btn("✈ TP", 54f))
				{
					TpGTA(player.Pos);
				}
				GUILayout.EndHorizontal();
			}
		}
	}

	private void TpUp(float delta)
	{
		Try(delegate
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			PlayerControl val = P();
			if ((Object)(object)val == (Object)null)
			{
				Status("✗ PlayerControl not found");
			}
			else
			{
				ForceTeleport(val, ((Component)val).transform.position + new Vector3(0f, delta, 0f));
				Status($"↑ Moved up {delta:F0} m");
			}
		});
	}

	private void TpY(float y)
	{
		Try(delegate
		{
			//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_0046: Unknown result type (might be due to invalid IL or missing references)
			PlayerControl val = P();
			if ((Object)(object)val == (Object)null)
			{
				Status("✗ PlayerControl not found");
			}
			else
			{
				Vector3 position = ((Component)val).transform.position;
				position.y = y;
				ForceTeleport(val, position);
				Status("Y → " + y);
			}
		});
	}

	private void ResetPosition()
	{
		Try(delegate
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			PlayerControl val = P();
			if (!((Object)(object)val == (Object)null))
			{
				MethodInfo method = ((object)val).GetType().GetMethod("ResetPosition", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (method != null && method.GetParameters().Length == 0)
				{
					method.Invoke(val, null);
					Status("Position reset");
				}
				else
				{
					ForceTeleport(val, Vector3.zero);
					Status("Reset → (0,0,0)");
				}
			}
		});
	}

	private void ResetToLodge()
	{
		Try(delegate
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)P() == (Object)null))
			{
				TpGTA(new Vector3(28f, 31f, 129f));
			}
		});
	}

	private void ResetToRaceStart()
	{
		Try(delegate
		{
			PlayerControl val = P();
			if (!((Object)(object)val == (Object)null))
			{
				string[] array = new string[4] { "RespawnAtStart", "ResetToStart", "SpawnAtRaceStart", "GoToRaceStart" };
				foreach (string name in array)
				{
					MethodInfo method = ((object)val).GetType().GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (method != null && method.GetParameters().Length == 0)
					{
						method.Invoke(val, null);
						Status("→ Race start");
						return;
					}
				}
				Status("✗ Race start method not found");
			}
		});
	}

	private void CopyPos()
	{
		Try(delegate
		{
			//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)
			//IL_0077: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			PlayerControl val = P();
			if (!((Object)(object)val == (Object)null))
			{
				Vector3 position = ((Component)val).transform.position;
				_tpX = position.x.ToString("F2", CultureInfo.InvariantCulture);
				_tpY = position.y.ToString("F2", CultureInfo.InvariantCulture);
				_tpZ = position.z.ToString("F2", CultureInfo.InvariantCulture);
				Status($"Position copied: {position.x:F1}, {position.y:F1}, {position.z:F1}");
			}
		});
	}

	private void SaveWaypoint()
	{
		Try(delegate
		{
			//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)
			//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_0068: Unknown result type (might be due to invalid IL or missing references)
			PlayerControl val = P();
			if (!((Object)(object)val == (Object)null))
			{
				Vector3 position = ((Component)val).transform.position;
				string text = (string.IsNullOrWhiteSpace(_wpName) ? ("WP" + _waypoints.Count) : _wpName.Trim());
				_waypoints.Add(new Waypoint(text, position.x, position.y, position.z));
				SaveWaypoints();
				Status("Waypoint \"" + text + "\" saved");
			}
		});
	}

	private void LoadWpToInput(Waypoint wp)
	{
		_tpX = wp.X.ToString("F2", CultureInfo.InvariantCulture);
		_tpY = wp.Y.ToString("F2", CultureInfo.InvariantCulture);
		_tpZ = wp.Z.ToString("F2", CultureInfo.InvariantCulture);
	}

	public override void OnApplicationStart()
	{
		LoadWaypoints();
	}

	private void SaveWaypoints()
	{
		try
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("[");
			for (int i = 0; i < _waypoints.Count; i++)
			{
				Waypoint waypoint = _waypoints[i];
				string text = waypoint.Name.Replace("\\", "\\\\").Replace("\"", "\\\"");
				stringBuilder.AppendFormat(CultureInfo.InvariantCulture, "{{\"name\":\"{0}\",\"x\":{1},\"y\":{2},\"z\":{3}}}", text, waypoint.X, waypoint.Y, waypoint.Z);
				if (i < _waypoints.Count - 1)
				{
					stringBuilder.Append(",");
				}
			}
			stringBuilder.Append("]");
			File.WriteAllText(WaypointsFilePath, stringBuilder.ToString(), Encoding.UTF8);
			MelonLogger.Msg("[SledTpMod] Waypoints saved to " + WaypointsFilePath);
		}
		catch (Exception ex)
		{
			MelonLogger.Msg("[SledTpMod][ERR] Could not save waypoints: " + ex.Message);
		}
	}

	private void LoadWaypoints()
	{
		try
		{
			if (!File.Exists(WaypointsFilePath))
			{
				return;
			}
			string text = File.ReadAllText(WaypointsFilePath, Encoding.UTF8).Trim();
			if (string.IsNullOrEmpty(text) || text == "[]")
			{
				return;
			}
			_waypoints.Clear();
			text = text.TrimStart('[').TrimEnd(']');
			int num = 0;
			int num2 = -1;
			for (int i = 0; i < text.Length; i++)
			{
				if (text[i] == '{')
				{
					if (num++ == 0)
					{
						num2 = i;
					}
				}
				else if (text[i] == '}' && --num == 0 && num2 >= 0)
				{
					Waypoint waypoint = ParseWaypointJson(text.Substring(num2, i - num2 + 1));
					if (waypoint != null)
					{
						_waypoints.Add(waypoint);
					}
					num2 = -1;
				}
			}
			MelonLogger.Msg($"[SledTpMod] Loaded {_waypoints.Count} waypoint(s) from {WaypointsFilePath}");
		}
		catch (Exception ex)
		{
			MelonLogger.Msg("[SledTpMod][ERR] Could not load waypoints: " + ex.Message);
		}
	}

	private static Waypoint ParseWaypointJson(string obj)
	{
		try
		{
			string n = ExtractJsonString(obj, "name") ?? "WP";
			float x = ExtractJsonFloat(obj, "x");
			float y = ExtractJsonFloat(obj, "y");
			float z = ExtractJsonFloat(obj, "z");
			return new Waypoint(n, x, y, z);
		}
		catch
		{
			return null;
		}
	}

	private static string ExtractJsonString(string json, string key)
	{
		string text = "\"" + key + "\":\"";
		int num = json.IndexOf(text, StringComparison.Ordinal);
		if (num < 0)
		{
			return null;
		}
		int num2 = num + text.Length;
		StringBuilder stringBuilder = new StringBuilder();
		for (int i = num2; i < json.Length; i++)
		{
			if (json[i] == '\\' && i + 1 < json.Length)
			{
				stringBuilder.Append(json[++i]);
				continue;
			}
			if (json[i] == '"')
			{
				break;
			}
			stringBuilder.Append(json[i]);
		}
		return stringBuilder.ToString();
	}

	private static float ExtractJsonFloat(string json, string key)
	{
		string text = "\"" + key + "\":";
		int num = json.IndexOf(text, StringComparison.Ordinal);
		if (num < 0)
		{
			return 0f;
		}
		int num2 = num + text.Length;
		int i;
		for (i = num2; i < json.Length && (char.IsDigit(json[i]) || json[i] == '-' || json[i] == '.' || json[i] == 'E' || json[i] == 'e' || json[i] == '+'); i++)
		{
		}
		return ParseF(json.Substring(num2, i - num2), 0f);
	}

	private void ScanPlayers()
	{
		Try(delegate
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			_players.Clear();
			Il2CppReferenceArray<Object> val = Object.FindObjectsOfType(Il2CppType.Of<PlayerControl>());
			if (val == null || ((Il2CppArrayBase<Object>)(object)val).Length == 0)
			{
				Status("No players found");
			}
			else
			{
				foreach (Object item in (Il2CppArrayBase<Object>)(object)val)
				{
					PlayerControl val2 = ((Il2CppObjectBase)item).Cast<PlayerControl>();
					if (!((Object)(object)val2 == (Object)null) && !IsLocalPlayer(val2))
					{
						string n = ResolvePlayerName(val2);
						_players.Add(new PlayerEntry(n, ((Component)val2).transform.position));
					}
				}
				Status((_players.Count == 0) ? "No other players" : (_players.Count + " player(s) found"));
			}
		});
	}

	private bool IsLocalPlayer(PlayerControl pc)
	{
		try
		{
			return (Object)(object)pc == (Object)(object)PlayerControl.LocalPlayerInstance;
		}
		catch
		{
			return false;
		}
	}

	private static string ResolvePlayerName(PlayerControl pc)
	{
		if ((Object)(object)pc == (Object)null)
		{
			return "Unknown";
		}
		Type type = ((object)pc).GetType();
		string[] array;
		try
		{
			object obj = null;
			PropertyInfo property = type.GetProperty("usernameController", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (property != null)
			{
				obj = property.GetValue(pc);
			}
			if (obj == null)
			{
				FieldInfo field = type.GetField("usernameController", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					obj = field.GetValue(pc);
				}
			}
			if (obj != null)
			{
				MethodInfo method = obj.GetType().GetMethod("GetUsername", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (method != null)
				{
					string text = method.Invoke(obj, null)?.ToString();
					if (IsValidName(text))
					{
						return text;
					}
				}
				array = new string[4] { "_username", "username", "Username", "_name" };
				foreach (string name in array)
				{
					FieldInfo field2 = obj.GetType().GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field2 != null)
					{
						string text2 = field2.GetValue(obj)?.ToString();
						if (IsValidName(text2))
						{
							return text2;
						}
					}
					PropertyInfo property2 = obj.GetType().GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property2 != null)
					{
						string text3 = property2.GetValue(obj)?.ToString();
						if (IsValidName(text3))
						{
							return text3;
						}
					}
				}
			}
		}
		catch
		{
		}
		array = new string[2] { "_playerReference", "playerReference" };
		foreach (string name2 in array)
		{
			try
			{
				object obj3 = null;
				FieldInfo field3 = type.GetField(name2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field3 != null)
				{
					obj3 = field3.GetValue(pc);
				}
				if (obj3 == null)
				{
					PropertyInfo property3 = type.GetProperty(name2, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property3 != null)
					{
						obj3 = property3.GetValue(pc);
					}
				}
				if (obj3 == null)
				{
					continue;
				}
				Type type2 = obj3.GetType();
				MethodInfo method2 = type2.GetMethod("GetUsername", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (method2 != null)
				{
					string text4 = method2.Invoke(obj3, null)?.ToString();
					if (IsValidName(text4))
					{
						return text4;
					}
				}
				MethodInfo method3 = type2.GetMethod("GetPlayerName", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (method3 != null)
				{
					string text5 = method3.Invoke(obj3, null)?.ToString();
					if (IsValidName(text5))
					{
						return text5;
					}
				}
				string[] array2 = new string[8] { "_username", "username", "Username", "_PlayerName_k__BackingField", "playerName", "PlayerName", "displayName", "FrameworkDisplayName" };
				foreach (string name3 in array2)
				{
					FieldInfo field4 = type2.GetField(name3, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field4 != null)
					{
						string text6 = field4.GetValue(obj3)?.ToString();
						if (IsValidName(text6))
						{
							return text6;
						}
					}
					PropertyInfo property4 = type2.GetProperty(name3, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (property4 != null)
					{
						string text7 = property4.GetValue(obj3)?.ToString();
						if (IsValidName(text7))
						{
							return text7;
						}
					}
				}
			}
			catch
			{
			}
		}
		array = new string[5] { "playerName", "_PlayerName_k__BackingField", "username", "_username", "displayName" };
		foreach (string name4 in array)
		{
			try
			{
				FieldInfo field5 = type.GetField(name4, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field5 != null)
				{
					string text8 = field5.GetValue(pc)?.ToString();
					if (IsValidName(text8))
					{
						return text8;
					}
				}
				PropertyInfo property5 = type.GetProperty(name4, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (property5 != null)
				{
					string text9 = property5.GetValue(pc)?.ToString();
					if (IsValidName(text9))
					{
						return text9;
					}
				}
			}
			catch
			{
			}
		}
		try
		{
			PlayerSavedStats component = ((Component)pc).gameObject.GetComponent<PlayerSavedStats>();
			if (component != null)
			{
				Type type3 = ((object)component).GetType();
				array = new string[4] { "playerName", "PlayerName", "username", "Username" };
				foreach (string name5 in array)
				{
					FieldInfo field6 = type3.GetField(name5, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (field6 != null)
					{
						string text10 = field6.GetValue(component)?.ToString();
						if (IsValidName(text10))
						{
							return text10;
						}
					}
				}
			}
		}
		catch
		{
		}
		try
		{
			foreach (MonoBehaviour component2 in ((Component)pc).gameObject.GetComponents<MonoBehaviour>())
			{
				if ((Object)(object)component2 == (Object)null)
				{
					continue;
				}
				Type type4 = ((object)component2).GetType();
				array = new string[11]
				{
					"playerName", "PlayerName", "NickName", "nickName", "username", "Username", "displayName", "DisplayName", "OwnerName", "ownerName",
					"ActorName"
				};
				foreach (string name6 in array)
				{
					try
					{
						FieldInfo field7 = type4.GetField(name6, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field7 != null)
						{
							string text11 = field7.GetValue(component2)?.ToString();
							if (IsValidName(text11))
							{
								return text11;
							}
						}
						PropertyInfo property6 = type4.GetProperty(name6, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (property6 != null)
						{
							string text12 = property6.GetValue(component2)?.ToString();
							if (IsValidName(text12))
							{
								return text12;
							}
						}
					}
					catch
					{
					}
				}
			}
		}
		catch
		{
		}
		try
		{
			string name7 = ((Object)((Component)pc).gameObject).name;
			name7 = Regex.Replace(name7, "\\s*\\(Clone\\)\\s*|\\s*\\(\\d+\\)\\s*", "").Trim();
			if (IsValidName(name7))
			{
				return name7;
			}
		}
		catch
		{
		}
		return "Player#" + ((Object)pc).GetHashCode().ToString("X4");
	}

	private static bool IsValidName(string n)
	{
		if (!string.IsNullOrWhiteSpace(n) && n.Length > 1 && n.Length < 40 && n != "PlayerControl" && n != "Player" && n != "PlayerNetworked" && n != "PlayerNetwork" && !n.StartsWith("Il2Cpp"))
		{
			return !n.StartsWith("PlayerNetwork");
		}
		return false;
	}

	private void TpGTA(Vector3 target)
	{
		//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)
		Try(delegate
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)P() == (Object)null)
			{
				Status("✗ PlayerControl not found");
			}
			else if (_tpLocked)
			{
				Status("✗ Teleport already in progress");
			}
			else
			{
				MelonCoroutines.Start(GtaCoroutine(target));
			}
		});
	}

	private IEnumerator GtaCoroutine(Vector3 finalPos)
	{
		//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)
		_tpLocked = true;
		_show = false;
		_gtaCamGO = new GameObject("STA_Cam");
		_gtaCam = _gtaCamGO.AddComponent<Camera>();
		_gtaCam.nearClipPlane = 0.3f;
		_gtaCam.farClipPlane = 5000f;
		_gtaCam.depth = 100f;
		_gtaCam.fieldOfView = 58f;
		_mainCamCache = Camera.main;
		if ((Object)(object)_mainCamCache != (Object)null)
		{
			((Behaviour)_mainCamCache).enabled = false;
		}
		_gtaCamActive = true;
		_gtaCamProgress = 0f;
		PlayerControl val = P();
		Vector3 val2 = (((Object)(object)val != (Object)null) ? ((Component)val).transform.position : Vector3.zero);
		Vector3 upA_start = new Vector3(val2.x, val2.y + 6f, val2.z);
		Vector3 upA_end = new Vector3(val2.x, val2.y + 300f, val2.z);
		Vector3 upB_end = new Vector3(val2.x, 800f, val2.z);
		Vector3 downTop = new Vector3(finalPos.x, finalPos.y + 800f, finalPos.z);
		Vector3 downMid = new Vector3(finalPos.x, finalPos.y + 300f, finalPos.z);
		Vector3 downLow = new Vector3(finalPos.x, finalPos.y + 18f, finalPos.z);
		Vector3 downFinal = finalPos + new Vector3(0f, 6f, -10f);
		float num = 8f;
		float durA = num * 0.14f;
		float durB = num * 0.16f;
		float durT = num * 0.05f;
		float dur0 = num * 0.34f;
		float dur1 = num * 0.13f;
		float dur2 = num * 0.11f;
		float dur3 = num * 0.07f;
		float totalD = durA + durB + durT + dur0 + dur1 + dur2 + dur3;
		Quaternion rotDown = Quaternion.Euler(90f, 0f, 0f);
		float elapsed = 0f;
		bool tpDone = false;
		while (elapsed < totalD)
		{
			elapsed += Time.deltaTime;
			_gtaCamProgress = Mathf.Clamp01(elapsed / totalD);
			float num2 = durA;
			float num3 = durA + durB;
			float num4 = num3 + durT;
			float num5 = num4 + dur0;
			float num6 = num5 + dur1;
			float num7 = num6 + dur2;
			Vector3 val3;
			Quaternion rotation;
			if (elapsed < num2)
			{
				float num8 = EaseOutExpo(elapsed / durA);
				val3 = Vector3.Lerp(upA_start, upA_end, num8);
				rotation = rotDown;
				_gtaCam.fieldOfView = Mathf.Lerp(58f, 55f, num8);
			}
			else if (elapsed < num3)
			{
				float num9 = (elapsed - num2) / durB;
				float num10 = EaseInExpo(num9);
				val3 = Vector3.Lerp(upA_end, upB_end, num10);
				rotation = rotDown;
				_gtaCam.fieldOfView = Mathf.Lerp(55f, 52f, num10);
				if (!tpDone && num9 >= 0.95f)
				{
					tpDone = true;
					PlayerControl val4 = P();
					if ((Object)(object)val4 != (Object)null)
					{
						ForceTeleport(val4, finalPos);
					}
				}
			}
			else if (elapsed < num4)
			{
				float num11 = SmootherStep((elapsed - num3) / durT);
				val3 = Vector3.Lerp(upB_end, downTop, num11);
				rotation = rotDown;
				_gtaCam.fieldOfView = 52f;
			}
			else if (elapsed < num5)
			{
				float num12 = (elapsed - num4) / dur0;
				float num13 = Mathf.Sin(num12 * (float)Math.PI * 0.8f) * 3f;
				val3 = downTop + new Vector3(num13, 0f, 0f);
				val3.y = Mathf.Max(val3.y, finalPos.y + 2f);
				rotation = rotDown;
				_gtaCam.fieldOfView = Mathf.Lerp(52f, 58f, num12);
			}
			else if (elapsed < num6)
			{
				float num14 = EaseInExpo((elapsed - num5) / dur1);
				val3 = Vector3.Lerp(downTop, downMid, num14);
				val3.y = Mathf.Max(val3.y, finalPos.y + 2f);
				rotation = rotDown;
				_gtaCam.fieldOfView = Mathf.Lerp(58f, 55f, num14);
			}
			else if (elapsed < num7)
			{
				float t = (elapsed - num6) / dur2;
				float num15 = EaseInQuad(t);
				val3 = Vector3.Lerp(downMid, downLow, num15);
				val3.y = Mathf.Max(val3.y, finalPos.y + 2f);
				Quaternion val5 = LookAtSmooth(val3, finalPos + new Vector3(0f, 1.2f, 0f));
				rotation = Quaternion.Slerp(rotDown, val5, SmootherStep(t) * 0.6f);
				_gtaCam.fieldOfView = Mathf.Lerp(55f, 60f, num15);
			}
			else
			{
				float num16 = SmootherStep((elapsed - num7) / dur3);
				val3 = Vector3.Lerp(downLow, downFinal, num16);
				val3.y = Mathf.Max(val3.y, finalPos.y + 1.5f);
				Quaternion val6 = LookAtSmooth(val3, finalPos + new Vector3(0f, 1.2f, 0f));
				rotation = Quaternion.Slerp(LookAtSmooth(downLow, finalPos + new Vector3(0f, 1.2f, 0f)), val6, num16);
				_gtaCam.fieldOfView = Mathf.Lerp(60f, 68f, num16);
			}
			if ((Object)(object)_gtaCamGO != (Object)null)
			{
				_gtaCamGO.transform.position = val3;
				_gtaCamGO.transform.rotation = rotation;
			}
			yield return null;
		}
		StopGtaCam(cancel: false);
	}

	private void ForceTeleport(PlayerControl p, Vector3 pos)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: 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_0025: 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_00cb: 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_013e: Unknown result type (might be due to invalid IL or missing references)
		Quaternion rotation = ((Component)p).transform.rotation;
		Rigidbody val = null;
		try
		{
			val = ((Component)p).GetComponent<Rigidbody>();
		}
		catch
		{
		}
		try
		{
			if ((Object)(object)val != (Object)null)
			{
				val.linearVelocity = Vector3.zero;
				val.angularVelocity = Vector3.zero;
				val.isKinematic = true;
			}
		}
		catch
		{
		}
		try
		{
			((Component)p).transform.position = pos;
		}
		catch
		{
		}
		try
		{
			((Component)p).transform.rotation = rotation;
		}
		catch
		{
		}
		try
		{
			PlayerMovement movement = p.movement;
			if ((Object)(object)movement != (Object)null)
			{
				Type type = ((object)movement).GetType();
				MethodInfo method = type.GetMethod("ResetPosition", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2]
				{
					typeof(Vector3),
					typeof(Quaternion)
				}, null);
				if (method != null)
				{
					method.Invoke(movement, new object[2] { pos, rotation });
				}
				string[] array = new string[3] { "velocity", "_velocity", "currentVelocity" };
				foreach (string name in array)
				{
					try
					{
						FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field != null && field.FieldType == typeof(Vector3))
						{
							field.SetValue(movement, Vector3.zero);
						}
					}
					catch
					{
					}
				}
			}
		}
		catch
		{
		}
		try
		{
			if ((Object)(object)val != (Object)null)
			{
				val.isKinematic = false;
			}
		}
		catch
		{
		}
		MelonCoroutines.Start(PinPositionCoroutine(p, pos, rotation));
	}

	private IEnumerator PinPositionCoroutine(PlayerControl p, Vector3 pos, Quaternion rot)
	{
		//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_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < 6; i++)
		{
			try
			{
				if ((Object)(object)p != (Object)null)
				{
					((Component)p).transform.position = pos;
					((Component)p).transform.rotation = rot;
				}
			}
			catch
			{
				break;
			}
			yield return null;
		}
	}

	private void StopGtaCam(bool cancel)
	{
		_gtaCamActive = false;
		_gtaCamProgress = 0f;
		_tpLocked = false;
		if ((Object)(object)_gtaCamGO != (Object)null)
		{
			Object.Destroy((Object)(object)_gtaCamGO);
			_gtaCamGO = null;
			_gtaCam = null;
		}
		if ((Object)(object)_mainCamCache != (Object)null)
		{
			((Behaviour)_mainCamCache).enabled = true;
			_mainCamCache = null;
		}
		if (!cancel)
		{
			Status("✔ Teleportation complete");
		}
	}

	private void TickGtaCam()
	{
		if ((Object)(object)_gtaCamGO == (Object)null && _gtaCamActive)
		{
			StopGtaCam(cancel: false);
		}
	}

	private float EaseOutExpo(float t)
	{
		t = Mathf.Clamp01(t);
		if (!(t >= 1f))
		{
			return 1f - Mathf.Pow(2f, -10f * t);
		}
		return 1f;
	}

	private float EaseInExpo(float t)
	{
		t = Mathf.Clamp01(t);
		if (t != 0f)
		{
			return Mathf.Pow(2f, 10f * t - 10f);
		}
		return 0f;
	}

	private float EaseInQuad(float t)
	{
		t = Mathf.Clamp01(t);
		return t * t;
	}

	private float SmootherStep(float t)
	{
		t = Mathf.Clamp01(t);
		return t * t * t * (t * (t * 6f - 15f) + 10f);
	}

	private Quaternion LookAtSmooth(Vector3 from, Vector3 to)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: 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_001e: 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_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: 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)
		Vector3 val = to - from;
		Vector3 normalized = ((Vector3)(ref val)).normalized;
		if (((Vector3)(ref normalized)).sqrMagnitude < 0.001f)
		{
			return Quaternion.identity;
		}
		Vector3 val2 = ((Mathf.Abs(Vector3.Dot(normalized, Vector3.up)) > 0.99f) ? Vector3.forward : Vector3.up);
		return Quaternion.LookRotation(normalized, val2);
	}

	private void EnsureStyles()
	{
		//IL_000a: 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_002a: 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_005e: 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_007e: 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_00b2: 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_00fa: 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_0124: 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_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Expected O, but got Unknown
		//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_014b: Expected O, but got Unknown
		//IL_014b: 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_015a: Expected O, but got Unknown
		//IL_015f: Expected O, but got Unknown
		//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Expected O, but got Unknown
		//IL_0232: Expected O, but got Unknown
		//IL_023d: 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_025e: 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_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Expected O, but got Unknown
		//IL_0275: 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_0284: Expected O, but got Unknown
		//IL_0289: Expected O, but got Unknown
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: 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_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_02df: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: Expected O, but got Unknown
		//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Expected O, but got Unknown
		//IL_02fd: Expected O, but got Unknown
		//IL_031e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0349: Unknown result type (might be due to invalid IL or missing references)
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_039f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ba: Expected O, but got Unknown
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0406: Unknown result type (might be due to invalid IL or missing references)
		//IL_042d: 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_043a: 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_0450: Expected O, but got Unknown
		//IL_0455: Expected O, but got Unknown
		//IL_0476: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c3: 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_04d2: Expected O, but got Unknown
		//IL_04d7: Expected O, but got Unknown
		//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fd: Expected O, but got Unknown
		//IL_0508: Unknown result type (might be due to invalid IL or missing references)
		//IL_0525: Unknown result type (might be due to invalid IL or missing references)
		//IL_052a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0536: Expected O, but got Unknown
		//IL_0541: Unknown result type (might be due to invalid IL or missing references)
		//IL_0552: Unknown result type (might be due to invalid IL or missing references)
		//IL_0557: 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_0566: Unknown result type (might be due to invalid IL or missing references)
		//IL_0572: Expected O, but got Unknown
		//IL_057d: Unknown result type (might be due to invalid IL or missing references)
		//IL_058e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0593: Unknown result type (might be due to invalid IL or missing references)
		//IL_059a: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a7: Expected O, but got Unknown
		//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e3: Expected O, but got Unknown
		//IL_05e8: Expected O, but got Unknown
		//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0608: Unknown result type (might be due to invalid IL or missing references)
		//IL_0647: Unknown result type (might be due to invalid IL or missing references)
		//IL_0661: Unknown result type (might be due to invalid IL or missing references)
		//IL_0666: Unknown result type (might be due to invalid IL or missing references)
		//IL_0673: Expected O, but got Unknown
		//IL_067e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0693: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
		if (!_stylesReady)
		{
			_txBtnN = Tex(GTA_DARK);
			_txBtnH = Tex(GTA_ORANGE);
			_txBtnA = Tex(GTA_ORANGE2);
			_txBtnDN = Tex(new Color(0.3f, 0.07f, 0.05f, 1f));
			_txBtnDH = Tex(GTA_RED);
			_txPanel = Tex(GTA_PANEL);
			_txWindow = Tex(GTA_BLACK);
			_txHR = Tex(GTA_ORANGE);
			_txSect = Tex(new Color(0.14f, 0.12f, 0.06f, 1f));
			_txField = Tex(new Color(0.09f, 0.08f, 0.07f, 1f));
			_txClose = Tex(new Color(0.22f, 0.08f, 0.06f, 1f));
			_txCloseH = Tex(GTA_RED);
			_winStyle = new GUIStyle(GUI.skin.window)
			{
				padding = new RectOffset(14, 14, 10, 10),
				margin = new RectOffset(0, 0, 0, 0),
				border = new RectOffset(0, 0, 0, 0)
			};
			_winStyle.normal.background = _txWindow;
			_winStyle.onNormal.background = _txWindow;
			_winStyle.focused.background = _txWindow;
			_winStyle.onFocused.background = _txWindow;
			_winStyle.hover.background = _txWindow;
			_winStyle.active.background = _txWindow;
			_winStyle.normal.textColor = GTA_WHITE;
			_titleStyle = new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)1,
				fontSize = 13,
				alignment = (TextAnchor)3,
				padding = new RectOffset(4, 4, 2, 2)
			};
			_titleStyle.normal.textColor = GTA_ORANGE;
			_sectionStyle = new GUIStyle(GUI.skin.label)
			{
				fontStyle = (FontStyle)1,
				fontSize = 11,
				padding = new RectOffset(8, 4, 5, 5),
				margin = new RectOffset(0, 0, 8, 3)
			};
			_sectionStyle.normal.background = _txSect;
			_sectionStyle.normal.textColor = GTA_ORANGE;
			_btnStyle = new GUIStyle(GUI.skin.button)
			{
				fontStyle = (FontStyle)1,
				fontSize = 11,
				alignment = (TextAnchor)4,
				padding = new RectOffset(8, 8, 5, 5),
				margin = new RectOffset(2, 2, 2, 2)
			};
			_btnStyle.normal.background = _txBtnN;
			_btnStyle.normal.textColor = GTA_WHITE;
			_btnStyle.hover.background = _txBtnH;
			_btnStyle.hover.textColor = GTA_BLACK;
			_btnStyle.active.background = _txBtnA;
			_btnStyle.active.textColor = GTA_BLACK;
			_btnStyle.focused.background = _txBtnH;
			_btnStyle.focused.textColor = GTA_BLACK;
			_btnDangerStyle = new GUIStyle(_btnStyle);
			_btnDangerStyle.normal.background = _txBtnDN;
			_btnDangerStyle.normal.textColor = GTA_RED;
			_btnDangerStyle.hover.background = _txBtnDH;
			_btnDangerStyle.hover.textColor = GTA_WHITE;
			_btnDangerStyle.active.background = _txBtnDH;
			_closeStyle = new GUIStyle(_btnStyle)
			{
				fontSize = 12,
				fontStyle = (FontStyle)1,
				padding = new RectOffset(4, 4, 3, 3)
			};
			_closeStyle.normal.background = _txClose;
			_closeStyle.normal.textColor = GTA_RED;
			_closeStyle.hover.background = _txCloseH;
			_closeStyle.hover.textColor = GTA_WHITE;
			_labelStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = 11,
				padding = new RectOffset(4, 4, 2, 2)
			};
			_labelStyle.normal.textColor = GTA_WHITE;
			_dimStyle = new GUIStyle(_labelStyle);
			_dimStyle.normal.textColor = GTA_DIM;
			_dimStyle.fontStyle = (FontStyle)2;
			_accentStyle = new GUIStyle(_labelStyle)
			{
				fontStyle = (FontStyle)1
			};
			_accentStyle.normal.textColor = GTA_ORANGE;
			_tagStyle = new GUIStyle(_labelStyle)
			{
				fontStyle = (FontStyle)1,
				fontSize = 10,
				alignment = (TextAnchor)4
			};
			_tagStyle.normal.textColor = GTA_ACCENT;
			_statusStyle = new GUIStyle(_labelStyle)
			{
				fontStyle = (FontStyle)1,
				fontSize = 11
			};
			_statusStyle.normal.textColor = GTA_GREEN;
			_fieldStyle = new GUIStyle(GUI.skin.textField)
			{
				fontSize = 11,
				padding = new RectOffset(6, 6, 4, 4)
			};
			_fieldStyle.normal.textColor = GTA_WHITE;
			_fieldStyle.focused.textColor = GTA_WHITE;
			_fieldStyle.normal.background = _txField;
			_fieldStyle.focused.background = Tex(new Color(0.14f, 0.12f, 0.07f, 1f));
			_toggleStyle = new GUIStyle(GUI.skin.toggle)
			{
				fontSize = 11
			};
			_toggleStyle.normal.textColor = GTA_WHITE;
			_toggleStyle.onNormal.textColor = GTA_ORANGE;
			_toggleStyle.onHover.textColor = GTA_ORANGE;
			_stylesReady = true;
		}
	}

	private void DrawHR()
	{
		//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_0006: 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)
		Color backgroundColor = GUI.backgroundColor;
		GUI.backgroundColor = GTA_ORANGE;
		GUILayout.Label("", (GUILayoutOption[])(object)new GUILayoutOption[2]
		{
			GUILayout.Height(1f),
			GUILayout.ExpandWidth(true)
		});
		GUI.backgroundColor = backgroundColor;
	}

	private void Sect(string label)
	{
		GUILayout.Space(2f);
		string text = label.Trim();
		string[] array = new string[8] { "▶", "◈", "⚡", "\ud83d\udccd", "\ud83d\udcbe", "\ud83c\udf0d", "✈", "·" };
		foreach (string text2 in array)
		{
			while (text.StartsWith(text2))
			{
				text = text.Substring(text2.Length).TrimStart();
			}
		}
		GUILayout.Label("▶  " + text, _sectionStyle ?? GUI.skin.label, (Il2CppReferenceArray<GUILayoutOption>)null);
		GUILayout.Space(1f);
	}

	private bool Btn(string lbl)
	{
		return GUILayout.Button(lbl, _btnStyle ?? GUI.skin.button, Array.Empty<GUILayoutOption>());
	}

	private bool Btn(string lbl, float w)
	{
		return GUILayout.Button(lbl, _btnStyle ?? GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(w) });
	}

	private bool BtnDanger(string lbl)
	{
		return GUILayout.Button(lbl, _btnDangerStyle ?? GUI.skin.button, Array.Empty<GUILayoutOption>());
	}

	private void Slider(string label, ref float val, float min, float max, float def)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Expected O, but got Unknown
		//IL_003a: 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_00cb: 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_00db: 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_0108: Unknown result type (might be due to invalid IL or missing references)
		GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
		bool flag = Mathf.Approximately(val, def);
		GUIStyle val2 = new GUIStyle(_labelStyle ?? GUI.skin.label);
		val2.normal.textColor = (flag ? GTA_DIM : GTA_ORANGE);
		val2.fontStyle = (FontStyle)((!flag) ? 1 : 0);
		GUILayout.Label(label + ":", _labelStyle ?? GUI.skin.label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(165f) });
		GUILayout.Label(val.ToString("F2"), val2, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(44f) });
		val = GUILayout.HorizontalSlider(val, min, max, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MinWidth(80f) });
		Color backgroundColor = GUI.backgroundColor;
		GUI.backgroundColor = (flag ? GTA_DIM : GTA_ORANGE);
		if (GUILayout.Button("R", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(22f) }))
		{
			val = def;
		}
		GUI.backgroundColor = backgroundColor;
		GUILayout.EndHorizontal();
	}

	private string Field(string val, float w = 100f)
	{
		return GUILayout.TextField(val, _fieldStyle ?? GUI.skin.textField, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(w) });
	}

	private static float ParseF(string s, float fallback)
	{
		if (float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
		{
			return result;
		}
		return fallback;
	}

	private void InitRect()
	{
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		int num = Mathf.Min(620, Screen.width - 20);
		int num2 = Mathf.Min(700, Screen.height - 40);
		_winRect = new Rect((float)(Screen.width - num) / 2f, (float)(Screen.height - num2) / 2f, (float)num, (float)num2);
		_rectInit = true;
	}

	private void EnsureRect()
	{
		if (!_rectInit)
		{
			InitRect();
			return;
		}
		int num = Screen.width - 4;
		int num2 = Screen.height - 4;
		if (((Rect)(ref _winRect)).width > (float)num)
		{
			((Rect)(ref _winRect)).width = num;
		}
		if (((Rect)(ref _winRect)).height > (float)num2)
		{
			((Rect)(ref _winRect)).height = num2;
		}
		if (((Rect)(ref _winRect)).x < 0f)
		{
			((Rect)(ref _winRect)).x = 0f;
		}
		if (((Rect)(ref _winRect)).y < 0f)
		{
			((Rect)(ref _winRect)).y = 0f;
		}
		if (((Rect)(ref _winRect)).x + ((Rect)(ref _winRect)).width > (float)Screen.width)
		{
			((Rect)(ref _winRect)).x = (float)Screen.width - ((Rect)(ref _winRect)).width;
		}
		if (((Rect)(ref _winRect)).y + ((Rect)(ref _winRect)).height > (float)Screen.height)
		{
			((Rect)(ref _winRect)).y = (float)Screen.height - ((Rect)(ref _winRect)).height;
		}
	}

	private static Texture2D Tex(Color c)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_0010: 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_0018: 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_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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)
		Texture2D val = new Texture2D(2, 2);
		Color[] array = (Color[])(object)new Color[4] { c, c, c, c };
		val.SetPixels(Il2CppStructArray<Color>.op_Implicit(array));
		val.Apply();
		return val;
	}
}