Decompiled source of malzeki123chestmod v1.4.0

plugins/malzeki123chestmod.dll

Decompiled 4 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using SonsuzSandik.Car;
using SonsuzSandik.Plane;
using SonsuzSandik.Vehicles;
using TMPro;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_guiutils")]
[assembly: IgnoresAccessChecksTo("assembly_utils")]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("malzeki123chestmod")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("malzeki123chestmod")]
[assembly: AssemblyTitle("malzeki123chestmod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SonsuzSandik
{
	internal static class Endless
	{
		public static bool IsOurs(Inventory inv)
		{
			if (inv != null)
			{
				return inv.m_name == "$piece_sonsuzsandik";
			}
			return false;
		}

		public static int DesiredHeight(Inventory inv)
		{
			int num = -1;
			foreach (ItemData item in inv.m_inventory)
			{
				if (item.m_gridPos.y > num)
				{
					num = item.m_gridPos.y;
				}
			}
			int num2 = Mathf.Max(1, Plugin.MinRows.Value);
			int num3 = Mathf.Max(1, Plugin.FreeRows.Value);
			return Mathf.Max(num2, num + 1 + num3);
		}

		public static bool IsOpenInGui(Inventory inv)
		{
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.m_currentContainer != (Object)null)
			{
				return instance.m_currentContainer.GetInventory() == inv;
			}
			return false;
		}

		public static void Resize(Inventory inv)
		{
			int num = DesiredHeight(inv);
			if (num > inv.m_height)
			{
				inv.m_height = num;
			}
			else if (num < inv.m_height && !IsOpenInGui(inv))
			{
				inv.m_height = num;
			}
		}
	}
	[HarmonyPatch]
	internal static class InventoryPatches
	{
		[HarmonyPatch(typeof(Inventory), "Changed")]
		[HarmonyPrefix]
		private static void Changed_Prefix(Inventory __instance)
		{
			if (Endless.IsOurs(__instance))
			{
				Endless.Resize(__instance);
			}
		}

		[HarmonyPatch(typeof(Inventory), "SetHeight")]
		[HarmonyPrefix]
		private static void SetHeight_Prefix(Inventory __instance, ref int height)
		{
			if (Endless.IsOurs(__instance))
			{
				int num = Endless.DesiredHeight(__instance);
				height = (Endless.IsOpenInGui(__instance) ? Mathf.Max(num, __instance.m_height) : num);
			}
		}

		[HarmonyPatch(typeof(Inventory), "FindEmptySlot")]
		[HarmonyPrefix]
		private static bool FindEmptySlot_Prefix(Inventory __instance, ref Vector2i __result)
		{
			//IL_0036: 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_003d: 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_0051: 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_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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			if (!Endless.IsOurs(__instance))
			{
				return true;
			}
			int width = __instance.m_width;
			int height = __instance.m_height;
			bool[] array = new bool[width * height];
			foreach (ItemData item in __instance.m_inventory)
			{
				Vector2i gridPos = item.m_gridPos;
				if (gridPos.x >= 0 && gridPos.x < width && gridPos.y >= 0 && gridPos.y < height)
				{
					array[gridPos.y * width + gridPos.x] = true;
				}
			}
			for (int i = 0; i < array.Length; i++)
			{
				if (!array[i])
				{
					__result = new Vector2i(i % width, i / width);
					return false;
				}
			}
			__instance.m_height = height + Mathf.Max(1, Plugin.FreeRows.Value);
			__result = new Vector2i(0, height);
			return false;
		}

		[HarmonyPatch(typeof(Inventory), "CanAddItem", new Type[]
		{
			typeof(ItemData),
			typeof(int)
		})]
		[HarmonyPostfix]
		private static void CanAddItem_Postfix(Inventory __instance, ref bool __result)
		{
			if (!__result && Endless.IsOurs(__instance))
			{
				__result = true;
			}
		}

		[HarmonyPatch(typeof(Inventory), "HaveEmptySlot")]
		[HarmonyPostfix]
		private static void HaveEmptySlot_Postfix(Inventory __instance, ref bool __result)
		{
			if (!__result && Endless.IsOurs(__instance))
			{
				__result = true;
			}
		}
	}
	[BepInPlugin("ferhat.sonsuzsandik", "malzeki123chestmod", "1.4.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		public const string Guid = "ferhat.sonsuzsandik";

		public const string Name = "malzeki123chestmod";

		public const string Version = "1.4.0";

		public const string PieceName = "piece_sonsuzsandik";

		public const string InventoryToken = "$piece_sonsuzsandik";

		public const int Width = 8;

		internal static ConfigEntry<int> MinRows;

		internal static ConfigEntry<int> FreeRows;

		internal static ConfigEntry<float> Scale;

		internal static ConfigEntry<float> SearchWidth;

		internal static ConfigEntry<float> SearchOffsetX;

		internal static ConfigEntry<float> SearchOffsetY;

		internal static ConfigEntry<bool> CarBuildable;

		internal static ConfigEntry<Color> CarColor;

		internal static ConfigEntry<float> CarMaxSpeed;

		internal static ConfigEntry<float> CarBoostSpeed;

		internal static ConfigEntry<float> CarPower;

		internal static ConfigEntry<float> CarCamDistance;

		internal static ConfigEntry<bool> PlaneBuildable;

		internal static ConfigEntry<float> PlaneScale;

		internal static ConfigEntry<float> PlaneTakeoffSpeed;

		internal static ConfigEntry<float> PlaneMaxSpeed;

		internal static ConfigEntry<float> PlaneThrust;

		internal static ConfigEntry<float> PlaneCamDistance;

		internal static ConfigEntry<float> CarVolume;

		internal static ConfigEntry<float> SeatHeight;

		internal static ConfigEntry<float> SeatForward;

		internal static ConfigEntry<KeyCode> HornKey;

		internal static ConfigEntry<KeyCode> LightsKey;

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			Log = ((BaseUnityPlugin)this).Logger;
			MinRows = ((BaseUnityPlugin)this).Config.Bind<int>("Sandik", "MinSatir", 6, "Sandigin en az kac satir gosterecegi (8 sutun).");
			FreeRows = ((BaseUnityPlugin)this).Config.Bind<int>("Sandik", "BosSatir", 2, "Son dolu satirin altinda her zaman bos tutulacak satir sayisi (sinirsizlik bu sekilde saglanir).");
			Scale = ((BaseUnityPlugin)this).Config.Bind<float>("Sandik", "Boyut", 1.25f, "Sandik modelinin buyuklugu (oyunu yeniden baslatinca uygulanir).");
			SearchWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Arama", "Genislik", 230f, "Arama kutusunun genisligi.");
			SearchOffsetX = ((BaseUnityPlugin)this).Config.Bind<float>("Arama", "KaydirX", 0f, "Arama kutusu yatay kaydirma (konum kotuyse buradan ayarla).");
			SearchOffsetY = ((BaseUnityPlugin)this).Config.Bind<float>("Arama", "KaydirY", 0f, "Arama kutusu dikey kaydirma.");
			CarBuildable = ((BaseUnityPlugin)this).Config.Bind<bool>("Araba", "Yapabilir", false, "Arabayi Hammer menusunde gosterir (sadece bu bilgisayarda).");
			CarColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Araba", "Renk", new Color(0.92f, 0.92f, 0.93f), "Boya rengi (sadece senin ekraninda).");
			CarMaxSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Araba", "MaksHiz", 120f, "Normal azami hiz (km/s).");
			CarBoostSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Araba", "TurboHiz", 170f, "Shift basiliyken azami hiz (km/s).");
			CarPower = ((BaseUnityPlugin)this).Config.Bind<float>("Araba", "Guc", 1f, "Motor gucu carpani (1 = 3000 Nm/teker, 4 ceker).");
			CarCamDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Araba", "KameraMesafe", 8f, "Takip kamerasinin arabaya uzakligi.");
			PlaneBuildable = ((BaseUnityPlugin)this).Config.Bind<bool>("Ucak", "Yapabilir", false, "747'yi Hammer menusunde gosterir (sadece bu bilgisayarda).");
			PlaneScale = ((BaseUnityPlugin)this).Config.Bind<float>("Ucak", "Boyut", 0.9f, "Ucak boyutu (1 = gercek 747). Icinde yurumek icin 0.85+ onerilir. Herkeste ayni olmali, oyunu yeniden baslatinca uygulanir.");
			PlaneTakeoffSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Ucak", "KalkisHizi", 70f, "Havalanma hizi (km/s). Dusuk = kisa pist.");
			PlaneMaxSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Ucak", "MaksHiz", 320f, "Tam gazda azami hiz (km/s).");
			PlaneThrust = ((BaseUnityPlugin)this).Config.Bind<float>("Ucak", "Itki", 9f, "Hizlanma (m/s2). Yuksek = daha kisa kalkis.");
			PlaneCamDistance = ((BaseUnityPlugin)this).Config.Bind<float>("Ucak", "KameraMesafe", 60f, "Takip kamerasi uzakligi (boyutla carpilir).");
			CarVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Araba", "SesSeviyesi", 0.8f, "Motor/korna ses seviyesi (0-1).");
			SeatHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Araba", "KoltukYukseklik", 0f, "Oturma yuksekligi duzeltmesi (karakter gomulu/havada gorunurse).");
			SeatForward = ((BaseUnityPlugin)this).Config.Bind<float>("Araba", "KoltukIleri", 0f, "Oturma ileri/geri duzeltmesi.");
			HornKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Araba", "KornaTusu", (KeyCode)104, "Korna.");
			LightsKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Araba", "FarTusu", (KeyCode)108, "Farlari ac/kapa.");
			AddLocalization();
			PrefabManager.OnVanillaPrefabsAvailable += AddPiece;
			new Harmony("ferhat.sonsuzsandik").PatchAll(typeof(Plugin).Assembly);
		}

		private void AddLocalization()
		{
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			string text = "English";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "piece_sonsuzsandik", "Endless Chest" },
				{ "piece_sonsuzsandik_desc", "A mighty chest with unlimited storage." },
				{ "piece_malzeki_car", "Mercedes-Benz GLS 580" },
				{ "piece_malzeki_car_desc", "Vroom." },
				{ "piece_malzeki_747", "Boeing 747" },
				{ "piece_malzeki_747_desc", "Short take-off jumbo jet." }
			});
			text = "Turkish";
			localization.AddTranslation(ref text, new Dictionary<string, string>
			{
				{ "piece_sonsuzsandik", "Sonsuz Sandık" },
				{ "piece_sonsuzsandik_desc", "Sınırsız eşya alan heybetli sandık." },
				{ "piece_malzeki_car", "Mercedes-Benz GLS 580" },
				{ "piece_malzeki_car_desc", "Vınnn." },
				{ "piece_malzeki_747", "Boeing 747" },
				{ "piece_malzeki_747_desc", "Kısa pistten kalkan jumbo jet." }
			});
		}

		private void AddPiece()
		{
			//IL_0011: 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)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			PrefabManager.OnVanillaPrefabsAvailable -= AddPiece;
			try
			{
				PieceConfig val = new PieceConfig
				{
					Name = "$piece_sonsuzsandik",
					Description = "$piece_sonsuzsandik_desc",
					PieceTable = PieceTables.Hammer,
					Category = PieceCategories.Furniture
				};
				GameObject prefab = PrefabManager.Instance.GetPrefab("piece_chest_wood");
				Piece val2 = ((prefab != null) ? prefab.GetComponent<Piece>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					val.Requirements = val2.m_resources.Where((Requirement r) => (Object)(object)r.m_resItem != (Object)null).Select((Func<Requirement, RequirementConfig>)((Requirement r) => new RequirementConfig(((Object)((Component)r.m_resItem).gameObject).name, r.m_amount, r.m_amountPerLevel, r.m_recover))).ToArray();
					if ((Object)(object)val2.m_craftingStation != (Object)null)
					{
						val.CraftingStation = ((Object)((Component)val2.m_craftingStation).gameObject).name;
					}
				}
				else
				{
					val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
					{
						new RequirementConfig("Wood", 10, 0, true)
					};
					val.CraftingStation = "piece_workbench";
				}
				CustomPiece val3 = new CustomPiece("piece_sonsuzsandik", "piece_chest_blackmetal", val);
				GameObject piecePrefab = val3.PiecePrefab;
				piecePrefab.transform.localScale = Vector3.one * Mathf.Clamp(Scale.Value, 0.5f, 3f);
				Container component = piecePrefab.GetComponent<Container>();
				component.m_name = "$piece_sonsuzsandik";
				component.m_width = 8;
				component.m_height = Mathf.Max(1, MinRows.Value);
				component.m_privacy = (PrivacySetting)2;
				component.m_autoDestroyEmpty = false;
				PieceManager.Instance.AddPiece(val3);
				Log.LogInfo((object)"Sonsuz Sandik eklendi.");
			}
			catch (Exception ex)
			{
				Log.LogError((object)("Sonsuz Sandik eklenemedi: " + ex));
			}
			try
			{
				CarPrefab.Register();
			}
			catch (Exception ex2)
			{
				Log.LogError((object)("Araba eklenemedi: " + ex2));
			}
			try
			{
				PlanePrefab.Register();
			}
			catch (Exception ex3)
			{
				Log.LogError((object)("Ucak eklenemedi: " + ex3));
			}
		}
	}
	internal static class SearchUI
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__13_0;

			internal void <Ensure>b__13_0()
			{
				Clear();
			}
		}

		private static GameObject s_root;

		private static TMP_InputField s_input;

		private static Inventory s_lastInventory;

		public static string Query = "";

		public static bool QueryChanged;

		public static int MatchCount;

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

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

		private static readonly List<Rect> s_obstacles = new List<Rect>();

		public static bool HasQuery => Query.Length > 0;

		public static bool IsFocused
		{
			get
			{
				if ((Object)(object)s_input != (Object)null && s_input.isFocused)
				{
					return s_root.activeInHierarchy;
				}
				return false;
			}
		}

		public static string Normalize(string s)
		{
			if (string.IsNullOrEmpty(s))
			{
				return "";
			}
			StringBuilder stringBuilder = new StringBuilder(s.Length);
			foreach (char c in s)
			{
				char value;
				switch (c)
				{
				case 'I':
				case 'İ':
				case 'ı':
					value = 'i';
					break;
				case 'Ş':
				case 'ş':
					value = 's';
					break;
				case 'Ğ':
				case 'ğ':
					value = 'g';
					break;
				case 'Ü':
				case 'ü':
					value = 'u';
					break;
				case 'Ö':
				case 'ö':
					value = 'o';
					break;
				case 'Ç':
				case 'ç':
					value = 'c';
					break;
				default:
					value = char.ToLowerInvariant(c);
					break;
				}
				stringBuilder.Append(value);
			}
			return stringBuilder.ToString().Trim();
		}

		public static bool Matches(ItemData item)
		{
			if (item?.m_shared == null)
			{
				return false;
			}
			string text = (((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : "");
			string key = item.m_shared.m_name + "|" + text;
			if (!s_nameCache.TryGetValue(key, out var value))
			{
				string s = ((Localization.instance != null) ? Localization.instance.Localize(item.m_shared.m_name) : item.m_shared.m_name);
				value = Normalize(s) + "\n" + Normalize(text) + "\n" + Normalize(item.m_shared.m_name.TrimStart('$'));
				s_nameCache[key] = value;
			}
			return value.Contains(Query);
		}

		public static void Ensure(InventoryGui gui)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Expected O, but got Unknown
			//IL_0162: 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_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: 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_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Expected O, but got Unknown
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: 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_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0457: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Expected O, but got Unknown
			if ((Object)(object)s_root != (Object)null)
			{
				return;
			}
			TMP_FontAsset font = gui.m_containerName.font;
			s_root = new GameObject("SonsuzSandik_Search", new Type[1] { typeof(RectTransform) });
			s_root.SetActive(false);
			s_root.transform.SetParent((Transform)(object)gui.m_container, false);
			RectTransform val = (RectTransform)s_root.transform;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			val.anchorMax = val2;
			val.anchorMin = val2;
			val.pivot = new Vector2(0f, 0.5f);
			val.sizeDelta = new Vector2(Plugin.SearchWidth.Value, 30f);
			Image val3 = s_root.AddComponent<Image>();
			((Graphic)val3).color = new Color(0.06f, 0.05f, 0.04f, 0.9f);
			Outline obj = s_root.AddComponent<Outline>();
			((Shadow)obj).effectColor = new Color(0.85f, 0.65f, 0.25f, 0.8f);
			((Shadow)obj).effectDistance = new Vector2(1.5f, -1.5f);
			GameObject val4 = new GameObject("TextArea", new Type[1] { typeof(RectTransform) });
			val4.transform.SetParent(s_root.transform, false);
			RectTransform val5 = (RectTransform)val4.transform;
			val5.anchorMin = Vector2.zero;
			val5.anchorMax = Vector2.one;
			val5.offsetMin = new Vector2(8f, 2f);
			val5.offsetMax = new Vector2(-28f, -2f);
			val4.AddComponent<RectMask2D>();
			TextMeshProUGUI val6 = MakeText("Text", val5, font);
			((Graphic)val6).color = Color.white;
			TextMeshProUGUI val7 = MakeText("Placeholder", val5, font);
			((TMP_Text)val7).text = "Eşya ara...";
			((TMP_Text)val7).fontStyle = (FontStyles)2;
			((Graphic)val7).color = new Color(1f, 1f, 1f, 0.45f);
			s_input = s_root.AddComponent<TMP_InputField>();
			s_input.textViewport = val5;
			s_input.textComponent = (TMP_Text)(object)val6;
			s_input.placeholder = (Graphic)(object)val7;
			if ((Object)(object)font != (Object)null)
			{
				s_input.fontAsset = font;
			}
			s_input.pointSize = 18f;
			s_input.lineType = (LineType)0;
			s_input.characterLimit = 40;
			s_input.restoreOriginalTextOnEscape = false;
			s_input.customCaretColor = true;
			s_input.caretColor = Color.white;
			s_input.selectionColor = new Color(0.85f, 0.65f, 0.25f, 0.5f);
			TMP_InputField obj2 = s_input;
			Navigation navigation = default(Navigation);
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)obj2).navigation = navigation;
			((Selectable)s_input).targetGraphic = (Graphic)(object)val3;
			((UnityEvent<string>)(object)s_input.onValueChanged).AddListener((UnityAction<string>)OnValueChanged);
			GameObject val8 = new GameObject("Clear", new Type[1] { typeof(RectTransform) });
			val8.transform.SetParent(s_root.transform, false);
			RectTransform val9 = (RectTransform)val8.transform;
			val9.anchorMin = new Vector2(1f, 0f);
			val9.anchorMax = new Vector2(1f, 1f);
			val9.pivot = new Vector2(1f, 0.5f);
			val9.sizeDelta = new Vector2(26f, 0f);
			val9.anchoredPosition = Vector2.zero;
			Image val10 = val8.AddComponent<Image>();
			((Graphic)val10).color = new Color(0f, 0f, 0f, 0f);
			Button obj3 = val8.AddComponent<Button>();
			((Selectable)obj3).targetGraphic = (Graphic)(object)val10;
			navigation = default(Navigation);
			((Navigation)(ref navigation)).mode = (Mode)0;
			((Selectable)obj3).navigation = navigation;
			ButtonClickedEvent onClick = obj3.onClick;
			object obj4 = <>c.<>9__13_0;
			if (obj4 == null)
			{
				UnityAction val11 = delegate
				{
					Clear();
				};
				<>c.<>9__13_0 = val11;
				obj4 = (object)val11;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj4);
			TextMeshProUGUI obj5 = MakeText("X", val9, font);
			((TMP_Text)obj5).text = "×";
			((TMP_Text)obj5).alignment = (TextAlignmentOptions)514;
			((Graphic)obj5).color = new Color(1f, 0.8f, 0.5f, 0.9f);
			((TMP_Text)obj5).fontSize = 22f;
		}

		private static TextMeshProUGUI MakeText(string name, RectTransform parent, TMP_FontAsset font)
		{
			//IL_0014: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0052: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent((Transform)(object)parent, false);
			RectTransform val2 = (RectTransform)val.transform;
			val2.anchorMin = Vector2.zero;
			val2.anchorMax = Vector2.one;
			val2.offsetMin = Vector2.zero;
			val2.offsetMax = Vector2.zero;
			TextMeshProUGUI val3 = val.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)font != (Object)null)
			{
				((TMP_Text)val3).font = font;
			}
			((TMP_Text)val3).fontSize = 18f;
			((TMP_Text)val3).alignment = (TextAlignmentOptions)4097;
			((TMP_Text)val3).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)val3).overflowMode = (TextOverflowModes)1;
			((Graphic)val3).raycastTarget = false;
			return val3;
		}

		private static void OnValueChanged(string value)
		{
			string text = Normalize(value);
			if (text != Query)
			{
				Query = text;
				QueryChanged = true;
			}
		}

		public static void Clear()
		{
			if ((Object)(object)s_input != (Object)null && s_input.text.Length > 0)
			{
				s_input.text = "";
			}
			if (Query.Length > 0)
			{
				Query = "";
				QueryChanged = true;
			}
		}

		public static void SetVisible(bool visible)
		{
			if (!((Object)(object)s_root == (Object)null))
			{
				if (!visible && (Object)(object)s_input != (Object)null && s_input.isFocused)
				{
					s_input.DeactivateInputField(false);
				}
				if (s_root.activeSelf != visible)
				{
					s_root.SetActive(visible);
				}
			}
		}

		public static void OnContainerShown(Inventory inv)
		{
			if (inv != s_lastInventory)
			{
				s_lastInventory = inv;
				Clear();
			}
		}

		public static void OnGuiHidden()
		{
			s_lastInventory = null;
			Clear();
			SetVisible(visible: false);
		}

		private static Rect LocalRect(RectTransform panel, RectTransform rt)
		{
			//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)
			//IL_0021: 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_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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_005b: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			rt.GetWorldCorners(s_corners);
			Vector2 val = Vector2.op_Implicit(((Transform)panel).InverseTransformPoint(s_corners[0]));
			Vector2 val2 = Vector2.op_Implicit(((Transform)panel).InverseTransformPoint(s_corners[2]));
			return Rect.MinMaxRect(Mathf.Min(val.x, val2.x), Mathf.Min(val.y, val2.y), Mathf.Max(val.x, val2.x), Mathf.Max(val.y, val2.y));
		}

		private static void CollectObstacles(Transform t, RectTransform panel, Transform skipA, Transform skipB, Transform skipC)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < t.childCount; i++)
			{
				Transform child = t.GetChild(i);
				if ((Object)(object)child == (Object)(object)skipA || (Object)(object)child == (Object)(object)skipB || (Object)(object)child == (Object)(object)skipC || !((Component)child).gameObject.activeInHierarchy)
				{
					continue;
				}
				RectTransform val = (RectTransform)(object)((child is RectTransform) ? child : null);
				if (val != null && ((Object)(object)((Component)child).GetComponent<Button>() != (Object)null || (Object)(object)((Component)child).GetComponent<TMP_Text>() != (Object)null || (Object)(object)((Component)child).GetComponent<Image>() != (Object)null))
				{
					Rect item = LocalRect(panel, val);
					if (((Rect)(ref item)).width > 1f && ((Rect)(ref item)).height > 1f)
					{
						float width = ((Rect)(ref item)).width;
						Rect rect = panel.rect;
						if (width < ((Rect)(ref rect)).width * 0.6f && ((Rect)(ref item)).height < 80f)
						{
							s_obstacles.Add(item);
						}
					}
				}
				CollectObstacles(child, panel, skipA, skipB, skipC);
			}
		}

		public static void Place(InventoryGui gui)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//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_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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: 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_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)s_root == (Object)null)
			{
				return;
			}
			RectTransform container = gui.m_container;
			RectTransform val = (RectTransform)s_root.transform;
			RectTransform val2 = (RectTransform)((Component)gui.m_containerGrid).transform;
			RectTransform rectTransform = gui.m_containerName.rectTransform;
			Rect val3 = LocalRect(container, val2);
			Rect val4 = LocalRect(container, rectTransform);
			float num = ((((Transform)container).lossyScale.x > 0f) ? (((Transform)rectTransform).lossyScale.x / ((Transform)container).lossyScale.x) : 1f);
			float num2 = ((Rect)(ref val4)).xMin + gui.m_containerName.preferredWidth * num;
			float num3 = Mathf.Max(100f, Plugin.SearchWidth.Value);
			float num4 = ((Rect)(ref val4)).center.y;
			float num5 = ((Rect)(ref val3)).xMax;
			float num6 = Mathf.Max(num2 + 12f, num5 - num3);
			s_obstacles.Clear();
			CollectObstacles((Transform)(object)container, container, (Transform)(object)val2, s_root.transform, (Transform)(object)rectTransform);
			for (int i = 0; i < 8; i++)
			{
				bool flag = false;
				foreach (Rect s_obstacle in s_obstacles)
				{
					Rect current = s_obstacle;
					if (((Rect)(ref current)).yMax > num4 - 15f && ((Rect)(ref current)).yMin < num4 + 15f && ((Rect)(ref current)).xMax > num6 && ((Rect)(ref current)).xMin < num5)
					{
						num5 = ((Rect)(ref current)).xMin - 8f;
						num6 = Mathf.Max(num2 + 12f, num5 - num3);
						flag = true;
					}
				}
				if (!flag)
				{
					break;
				}
			}
			Rect rect;
			if (num5 - num6 < 110f)
			{
				rect = container.rect;
				num4 = ((Rect)(ref rect)).yMax + 15f + 6f;
				num5 = ((Rect)(ref val3)).xMax;
				num6 = num5 - num3;
			}
			val.sizeDelta = new Vector2(num5 - num6, 30f);
			Vector2 val5 = new Vector2(num6, num4);
			rect = container.rect;
			val.anchoredPosition = val5 - ((Rect)(ref rect)).center + new Vector2(Plugin.SearchOffsetX.Value, Plugin.SearchOffsetY.Value);
		}
	}
	[HarmonyPatch]
	internal static class SearchPatches
	{
		private static readonly Dictionary<InventoryElement, Vector2> s_orig = new Dictionary<InventoryElement, Vector2>();

		private static bool s_filtered;

		private static readonly Vector2 Hidden = new Vector2(-100000f, 100000f);

		[HarmonyPatch(typeof(InventoryGui), "UpdateContainer")]
		[HarmonyPostfix]
		private static void UpdateContainer_Postfix(InventoryGui __instance)
		{
			Container currentContainer = __instance.m_currentContainer;
			if (!((Object)(object)currentContainer != (Object)null) || !((Component)__instance.m_container).gameObject.activeSelf || !Endless.IsOurs(currentContainer.GetInventory()))
			{
				SearchUI.SetVisible(visible: false);
				return;
			}
			SearchUI.Ensure(__instance);
			SearchUI.OnContainerShown(currentContainer.GetInventory());
			SearchUI.SetVisible(visible: true);
			SearchUI.Place(__instance);
			if (SearchUI.HasQuery)
			{
				TMP_Text containerName = __instance.m_containerName;
				containerName.text += $"  <size=75%><color=#ffd27a>({SearchUI.MatchCount} sonuç)</color></size>";
			}
		}

		[HarmonyPatch(typeof(InventoryGui), "Hide")]
		[HarmonyPostfix]
		private static void Hide_Postfix()
		{
			SearchUI.OnGuiHidden();
		}

		[HarmonyPatch(typeof(InventoryGrid), "UpdateGui")]
		[HarmonyPostfix]
		[HarmonyPriority(200)]
		private static void UpdateGui_Postfix(InventoryGrid __instance)
		{
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			InventoryGui instance = InventoryGui.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)__instance != (Object)(object)instance.m_containerGrid)
			{
				return;
			}
			List<InventoryElement> elements = __instance.m_elements;
			if (s_orig.Count > elements.Count + 64)
			{
				List<InventoryElement> list = new List<InventoryElement>();
				foreach (KeyValuePair<InventoryElement, Vector2> item in s_orig)
				{
					if ((Object)(object)item.Key == (Object)null)
					{
						list.Add(item.Key);
					}
				}
				foreach (InventoryElement item2 in list)
				{
					s_orig.Remove(item2);
				}
			}
			foreach (InventoryElement item3 in elements)
			{
				if ((Object)(object)item3 != (Object)null && !s_orig.ContainsKey(item3))
				{
					s_orig[item3] = ((RectTransform)((Component)item3).transform).anchoredPosition;
				}
			}
			Inventory inventory = __instance.m_inventory;
			if (!Endless.IsOurs(inventory) || !SearchUI.HasQuery)
			{
				if (s_filtered)
				{
					foreach (InventoryElement item4 in elements)
					{
						if ((Object)(object)item4 != (Object)null && s_orig.TryGetValue(item4, out var value))
						{
							((RectTransform)((Component)item4).transform).anchoredPosition = value;
						}
					}
					s_filtered = false;
					__instance.ResetView();
				}
				SearchUI.QueryChanged = false;
				return;
			}
			s_filtered = true;
			int num = Mathf.Max(1, __instance.m_width);
			List<ItemData> list2 = new List<ItemData>(inventory.m_inventory);
			list2.Sort((ItemData a, ItemData b) => (a.m_gridPos.y == b.m_gridPos.y) ? a.m_gridPos.x.CompareTo(b.m_gridPos.x) : a.m_gridPos.y.CompareTo(b.m_gridPos.y));
			HashSet<InventoryElement> hashSet = new HashSet<InventoryElement>();
			int num2 = 0;
			foreach (ItemData item5 in list2)
			{
				if (!SearchUI.Matches(item5))
				{
					continue;
				}
				int num3 = item5.m_gridPos.y * num + item5.m_gridPos.x;
				if (num3 >= 0 && num3 < elements.Count && num2 < elements.Count)
				{
					InventoryElement val = elements[num3];
					if (!((Object)(object)val == (Object)null) && s_orig.TryGetValue(elements[num2], out var value2))
					{
						((RectTransform)((Component)val).transform).anchoredPosition = value2;
						hashSet.Add(val);
						num2++;
					}
				}
			}
			foreach (InventoryElement item6 in elements)
			{
				if ((Object)(object)item6 != (Object)null && !hashSet.Contains(item6))
				{
					((RectTransform)((Component)item6).transform).anchoredPosition = Hidden;
				}
			}
			SearchUI.MatchCount = num2;
			int num4 = Mathf.Max(1, (num2 + num - 1) / num);
			__instance.m_gridRoot.SetSizeWithCurrentAnchors((Axis)1, (float)num4 * __instance.m_elementSpace);
			if (SearchUI.QueryChanged)
			{
				SearchUI.QueryChanged = false;
				__instance.ResetView();
			}
		}

		[HarmonyPatch(typeof(Chat), "HasFocus")]
		[HarmonyPostfix]
		private static void Chat_HasFocus(ref bool __result)
		{
			if (!__result && SearchUI.IsFocused)
			{
				__result = true;
			}
		}

		[HarmonyPatch(typeof(ZInput), "GetButtonDown")]
		[HarmonyPatch(typeof(ZInput), "GetButtonUp")]
		[HarmonyPatch(typeof(ZInput), "GetButton")]
		[HarmonyPostfix]
		private static void ZInput_Button(ref bool __result)
		{
			if (__result && SearchUI.IsFocused)
			{
				__result = false;
			}
		}

		[HarmonyPatch(typeof(ZInput), "GetKeyDown")]
		[HarmonyPatch(typeof(ZInput), "GetKeyUp")]
		[HarmonyPatch(typeof(ZInput), "GetKey")]
		[HarmonyPostfix]
		private static void ZInput_Key(ref bool __result)
		{
			if (__result && SearchUI.IsFocused)
			{
				__result = false;
			}
		}

		[HarmonyPatch(typeof(KeyboardShortcut), "IsDown")]
		[HarmonyPatch(typeof(KeyboardShortcut), "IsPressed")]
		[HarmonyPatch(typeof(KeyboardShortcut), "IsUp")]
		[HarmonyPostfix]
		private static void Shortcut(ref bool __result)
		{
			if (__result && SearchUI.IsFocused)
			{
				__result = false;
			}
		}
	}
}
namespace SonsuzSandik.Vehicles
{
	internal static class VehicleUtil
	{
		private static Shader s_lit;

		public static Shader LitShader()
		{
			if ((Object)(object)s_lit != (Object)null)
			{
				return s_lit;
			}
			s_lit = Shader.Find("Standard");
			if ((Object)(object)s_lit == (Object)null)
			{
				string[] array = new string[4] { "piece_chest_wood", "piece_chest", "Cart", "piece_bench01" };
				foreach (string text in array)
				{
					GameObject prefab = PrefabManager.Instance.GetPrefab(text);
					MeshRenderer val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponentInChildren<MeshRenderer>(true) : null);
					if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((Renderer)val).sharedMaterial) && Object.op_Implicit((Object)(object)((Renderer)val).sharedMaterial.shader))
					{
						s_lit = ((Renderer)val).sharedMaterial.shader;
						break;
					}
				}
			}
			if ((Object)(object)s_lit == (Object)null)
			{
				s_lit = Shader.Find("Custom/Piece") ?? Shader.Find("Diffuse") ?? Shader.Find("Sprites/Default");
			}
			Plugin.Log.LogInfo((object)("Arac shader: " + (Object.op_Implicit((Object)(object)s_lit) ? ((Object)s_lit).name : "YOK")));
			return s_lit;
		}

		public static LayerMask PassThroughLayers(bool includeCharacters)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			List<string> list = new List<string> { "Default_small", "item", "piece_nonsolid", "character_trigger", "viewblock" };
			if (includeCharacters)
			{
				list.AddRange(new string[4] { "character", "character_net", "character_ghost", "character_noenv" });
			}
			int num = 0;
			foreach (string item in list)
			{
				int num2 = LayerMask.NameToLayer(item);
				if (num2 >= 0)
				{
					num |= 1 << num2;
				}
			}
			return LayerMask.op_Implicit(num);
		}

		public static bool TrySmash(Collision c, Rigidbody body, Collider[] ownColliders, Vector3 lastVel, Vector3 lastAngVel, float minSpeed)
		{
			//IL_009e: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Expected O, but got Unknown
			Collider collider = c.collider;
			if ((Object)(object)collider == (Object)null || (Object)(object)collider.attachedRigidbody == (Object)(object)body)
			{
				return false;
			}
			IDestructible componentInParent = ((Component)collider).GetComponentInParent<IDestructible>();
			if (componentInParent == null || componentInParent is WearNTear || componentInParent is Character)
			{
				return false;
			}
			Component val = (Component)(object)((componentInParent is Component) ? componentInParent : null);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			foreach (Collider val2 in ownColliders)
			{
				if (Object.op_Implicit((Object)(object)val2))
				{
					Collider[] componentsInChildren = val.GetComponentsInChildren<Collider>();
					foreach (Collider val3 in componentsInChildren)
					{
						Physics.IgnoreCollision(val2, val3, true);
					}
				}
			}
			body.linearVelocity = lastVel;
			body.angularVelocity = lastAngVel;
			if (((Vector3)(ref lastVel)).magnitude >= minSpeed)
			{
				HitData val4 = new HitData
				{
					m_point = ((c.contacts.Length != 0) ? ((ContactPoint)(ref c.contacts[0])).point : ((Component)collider).transform.position),
					m_dir = ((Vector3)(ref lastVel)).normalized,
					m_toolTier = 100
				};
				val4.m_damage.m_chop = 5000f;
				val4.m_damage.m_pickaxe = 5000f;
				val4.m_damage.m_blunt = 5000f;
				try
				{
					componentInParent.Damage(val4);
				}
				catch
				{
				}
			}
			return true;
		}

		public static void UpdateChaseCam(Transform camPoint, Transform vehicle, Vector3 pivotLocal, float distance)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)camPoint == (Object)null)
			{
				return;
			}
			Vector3 val = ((((Vector3)(ref ((Character)localPlayer).m_lookDir)).sqrMagnitude > 0.01f) ? ((Vector3)(ref ((Character)localPlayer).m_lookDir)).normalized : vehicle.forward);
			Vector3 val2 = vehicle.TransformPoint(pivotLocal);
			Vector3 val3 = val2 - val * distance;
			if ((Object)(object)ZoneSystem.instance != (Object)null)
			{
				float groundHeight = ZoneSystem.instance.GetGroundHeight(val3);
				if (val3.y < groundHeight + 1.2f)
				{
					val3.y = groundHeight + 1.2f;
				}
			}
			camPoint.position = val3;
			camPoint.rotation = Quaternion.LookRotation(val2 + val * 4f - val3);
		}

		public static void Place(Player p, Vector3 pos, Quaternion rot, Vector3 vel)
		{
			//IL_0006: 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_0036: 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_002f: Unknown result type (might be due to invalid IL or missing references)
			((Component)p).transform.position = pos;
			((Component)p).transform.rotation = rot;
			Rigidbody component = ((Component)p).GetComponent<Rigidbody>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.position = pos;
				component.linearVelocity = vel;
			}
			((Character)p).m_maxAirAltitude = pos.y;
		}

		public static float HeightAboveGround(Vector3 pos)
		{
			//IL_0018: 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)
			if ((Object)(object)ZoneSystem.instance == (Object)null)
			{
				return 0f;
			}
			float groundHeight = ZoneSystem.instance.GetGroundHeight(pos);
			float waterLevel = ZoneSystem.instance.m_waterLevel;
			return pos.y - Mathf.Max(groundHeight, waterLevel);
		}
	}
	internal class Parachute : MonoBehaviour
	{
		private Player m_player;

		private float m_start;

		private static readonly int s_slowFall = StringExtensionMethods.GetStableHashCode("SlowFall");

		private bool m_addedSE;

		public static void Deploy(Player p)
		{
			if (!((Object)(object)p == (Object)null) && !((Object)(object)((Component)p).GetComponent<Parachute>() != (Object)null))
			{
				Parachute parachute = ((Component)p).gameObject.AddComponent<Parachute>();
				parachute.m_player = p;
				parachute.m_start = Time.time;
				if ((Object)(object)ObjectDB.instance != (Object)null && (Object)(object)ObjectDB.instance.GetStatusEffect(s_slowFall) != (Object)null && !((Character)p).GetSEMan().HaveStatusEffect(s_slowFall))
				{
					((Character)p).GetSEMan().AddStatusEffect(s_slowFall, true, 0, 0f, (short)(-1));
					parachute.m_addedSE = true;
				}
				((Character)p).Message((MessageType)2, "Paraşüt açıldı!", 0, (Sprite)null, false);
			}
		}

		private void Update()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_player == (Object)null || ((Character)m_player).IsDead())
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			((Character)m_player).m_maxAirAltitude = ((Component)m_player).transform.position.y;
			if (Time.time - m_start > 0.5f && (((Character)m_player).IsOnGround() || ((Character)m_player).InWater() || ((Character)m_player).IsAttached()))
			{
				if (m_addedSE)
				{
					((Character)m_player).GetSEMan().RemoveStatusEffect(s_slowFall, false);
				}
				Object.Destroy((Object)(object)this);
			}
		}
	}
	[HarmonyPatch]
	internal static class FirstPerson
	{
		public static bool Active;

		private static bool s_hidden;

		private static float s_nextRefresh;

		[HarmonyPatch(typeof(GameCamera), "GetCameraPosition")]
		[HarmonyPostfix]
		private static void GetCameraPosition_Postfix(ref Vector3 pos, ref Quaternion rot)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_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_008b: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			bool flag = Active && (Object)(object)localPlayer != (Object)null && !((Character)localPlayer).IsDead() && !((Character)localPlayer).IsAttached() && !((Character)localPlayer).InPlaceMode();
			SetBodyHidden(localPlayer, flag);
			if (flag)
			{
				Vector3 val = ((((Vector3)(ref ((Character)localPlayer).m_lookDir)).sqrMagnitude > 0.01f) ? ((Vector3)(ref ((Character)localPlayer).m_lookDir)).normalized : ((Component)localPlayer).transform.forward);
				pos = ((Character)localPlayer).m_eye.position + val * 0.12f;
				rot = Quaternion.LookRotation(val);
			}
		}

		private static void SetBodyHidden(Player p, bool hide)
		{
			if ((Object)(object)p == (Object)null || (hide == s_hidden && (!hide || Time.time < s_nextRefresh)))
			{
				return;
			}
			s_hidden = hide;
			s_nextRefresh = Time.time + 0.5f;
			if (!((Object)(object)((Character)p).m_visual == (Object)null))
			{
				Renderer[] componentsInChildren = ((Character)p).m_visual.GetComponentsInChildren<Renderer>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].shadowCastingMode = (ShadowCastingMode)((!hide) ? 1 : 3);
				}
			}
		}
	}
}
namespace SonsuzSandik.Plane
{
	internal static class PlaneAssets
	{
		public static Mesh Body;

		public static Material[] Materials;

		public static Material LightGlow;

		public static void Load(float scale)
		{
			//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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Expected O, but got Unknown
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)Body != (Object)null)
			{
				return;
			}
			using (Stream input = typeof(PlaneAssets).Assembly.GetManifestResourceStream("SonsuzSandik.plane.bin"))
			{
				using BinaryReader binaryReader = new BinaryReader(input);
				if (new string(binaryReader.ReadChars(4)) != "PLN1")
				{
					throw new IOException("plane.bin bozuk");
				}
				int num = binaryReader.ReadInt32();
				Color[] array = (Color[])(object)new Color[num];
				for (int i = 0; i < num; i++)
				{
					array[i] = new Color(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle());
				}
				binaryReader.ReadInt32();
				binaryReader.ReadChars(binaryReader.ReadInt32());
				binaryReader.ReadSingle();
				binaryReader.ReadSingle();
				binaryReader.ReadSingle();
				int num2 = binaryReader.ReadInt32();
				Vector3[] array2 = (Vector3[])(object)new Vector3[num2];
				for (int j = 0; j < num2; j++)
				{
					array2[j] = new Vector3(binaryReader.ReadSingle(), binaryReader.ReadSingle(), binaryReader.ReadSingle()) * scale;
				}
				Vector3[] array3 = (Vector3[])(object)new Vector3[num2];
				for (int k = 0; k < num2; k++)
				{
					array3[k] = new Vector3((float)binaryReader.ReadSByte(), (float)binaryReader.ReadSByte(), (float)binaryReader.ReadSByte()) / 127f;
				}
				int num3 = binaryReader.ReadInt32();
				Mesh val = new Mesh
				{
					name = "plane_747",
					indexFormat = (IndexFormat)1
				};
				val.vertices = array2;
				val.normals = array3;
				val.subMeshCount = num3;
				Materials = (Material[])(object)new Material[num3];
				Shader shader = VehicleUtil.LitShader();
				for (int l = 0; l < num3; l++)
				{
					int num4 = binaryReader.ReadInt32();
					int num5 = binaryReader.ReadInt32();
					int[] array4 = new int[num5];
					for (int m = 0; m < num5; m++)
					{
						array4[m] = (int)binaryReader.ReadUInt32();
					}
					val.SetTriangles(array4, l, false);
					Materials[l] = MakeMaterial(shader, array[num4]);
				}
				val.RecalculateBounds();
				Body = val;
			}
			LightGlow = MakeMaterial(VehicleUtil.LitShader(), Color.white);
			if (LightGlow.HasProperty("_EmissionColor"))
			{
				LightGlow.EnableKeyword("_EMISSION");
				LightGlow.SetColor("_EmissionColor", Color.white * 3f);
			}
		}

		private static Material MakeMaterial(Shader shader, Color c)
		{
			//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_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_0060: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(shader)
			{
				color = c
			};
			if (val.HasProperty("_MainTex"))
			{
				val.mainTexture = (Texture)(object)Texture2D.whiteTexture;
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", 0.1f);
			}
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", 0.55f);
			}
			if (c.a < 0.99f && ((Object)val.shader).name != "Standard")
			{
				val.color = new Color(0.25f, 0.3f, 0.35f, 1f);
			}
			else if (c.a < 0.99f)
			{
				val.SetFloat("_Mode", 3f);
				val.SetInt("_SrcBlend", 1);
				val.SetInt("_DstBlend", 10);
				val.SetInt("_ZWrite", 0);
				val.DisableKeyword("_ALPHATEST_ON");
				val.DisableKeyword("_ALPHABLEND_ON");
				val.EnableKeyword("_ALPHAPREMULTIPLY_ON");
				val.renderQueue = 3000;
				val.SetFloat("_Glossiness", 0.9f);
			}
			return val;
		}
	}
	internal static class PlaneAudio
	{
		private const int Rate = 44100;

		private static AudioClip s_jet;

		private static AudioClip s_spool;

		public static AudioClip Jet => s_jet ?? (s_jet = MakeJet());

		public static AudioClip Spool => s_spool ?? (s_spool = MakeSpool());

		private static AudioClip MakeJet()
		{
			int num = 88200;
			float[] array = new float[num];
			Random random = new Random(747);
			float num2 = 0f;
			float num3 = 0f;
			float num4 = 0f;
			float num5 = 0f;
			for (int i = 0; i < num; i++)
			{
				float num6 = (float)i / 44100f;
				float num7 = (float)(random.NextDouble() * 2.0 - 1.0);
				num2 += (num7 - num2) * 0.05f;
				num3 += (num7 - num3) * 0.35f;
				num4 = num3 - num5;
				num5 = num3;
				float num8 = 0.22f * Mathf.Sin(MathF.PI * 2400f * num6 + 0.6f * Mathf.Sin(MathF.PI * 6f * num6)) + 0.12f * Mathf.Sin(MathF.PI * 4800f * num6) + 0.1f * Mathf.Sin(MathF.PI * 1200f * num6);
				float num9 = 0.25f * Mathf.Sin(MathF.PI * 110f * num6) * (0.7f + 0.3f * Mathf.Sin(MathF.PI * 8f * num6));
				array[i] = num2 * 1.6f + num4 * 0.5f + num8 * 0.5f + num9;
				array[i] *= 0.45f;
			}
			float[] array2 = new float[num - 4000];
			Array.Copy(array, array2, array2.Length);
			for (int j = 0; j < 4000; j++)
			{
				float num10 = (float)j / 4000f;
				array2[j] = array[j] * num10 + array[array2.Length + j] * (1f - num10);
			}
			AudioClip obj = AudioClip.Create("jet_loop", array2.Length, 1, 44100, false);
			obj.SetData(array2, 0);
			return obj;
		}

		private static AudioClip MakeSpool()
		{
			float num = 3f;
			int num2 = (int)(44100f * num);
			float[] array = new float[num2];
			Random random = new Random(1);
			float num3 = 0f;
			float num4 = 0f;
			for (int i = 0; i < num2; i++)
			{
				float num5 = (float)i / 44100f;
				float num6 = num5 / num;
				float num7 = Mathf.Lerp(150f, 1300f, Mathf.SmoothStep(0f, 1f, num6));
				num3 += MathF.PI * 2f * num7 / 44100f;
				float num8 = (float)(random.NextDouble() * 2.0 - 1.0);
				num4 += (num8 - num4) * Mathf.Lerp(0.01f, 0.08f, num6);
				float num9 = Mathf.Clamp01(num5 / 0.2f) * Mathf.Clamp01((num - num5) / 0.6f);
				array[i] = (0.35f * Mathf.Sin(num3) + num4 * 1.5f * num6) * num9 * 0.6f;
			}
			AudioClip obj = AudioClip.Create("jet_spool", num2, 1, 44100, false);
			obj.SetData(array, 0);
			return obj;
		}
	}
	public class PlaneSeat : MonoBehaviour, Hoverable, Interactable
	{
		public int m_index;

		private PlaneController Ctrl => ((Component)this).GetComponentInParent<PlaneController>();

		public string GetHoverText()
		{
			if (!Object.op_Implicit((Object)(object)Ctrl))
			{
				return "";
			}
			return Ctrl.SeatHoverText(m_index);
		}

		public string GetHoverName()
		{
			if (!Object.op_Implicit((Object)(object)Ctrl))
			{
				return "";
			}
			return Ctrl.GetHoverName();
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			if (!hold && Object.op_Implicit((Object)(object)Ctrl))
			{
				return Ctrl.InteractSeat((Player)(object)((user is Player) ? user : null), m_index);
			}
			return false;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}

		public float GetHoverOffset()
		{
			return 0f;
		}
	}
	public class PlaneDoor : MonoBehaviour, Hoverable, Interactable
	{
		private PlaneController Ctrl => ((Component)this).GetComponentInParent<PlaneController>();

		public string GetHoverText()
		{
			if (!Object.op_Implicit((Object)(object)Ctrl))
			{
				return "";
			}
			return Localization.instance.Localize("Kapı\n[<color=yellow><b>$KEY_Use</b></color>] Uçaktan in");
		}

		public string GetHoverName()
		{
			return "Kapı";
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			if (!hold && Object.op_Implicit((Object)(object)Ctrl))
			{
				return Ctrl.ExitThroughDoor((Player)(object)((user is Player) ? user : null));
			}
			return false;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}

		public float GetHoverOffset()
		{
			return 0f;
		}
	}
	public class PlaneController : MonoBehaviour, Interactable, Hoverable, IDoodadController
	{
		private static readonly int s_pilotKey = StringExtensionMethods.GetStableHashCode("malzeki_747_pilot");

		private static readonly int s_throttleKey = StringExtensionMethods.GetStableHashCode("malzeki_747_thr");

		private static readonly int s_lightsKey = StringExtensionMethods.GetStableHashCode("malzeki_747_lights");

		private ZNetView m_nview;

		private Rigidbody m_body;

		private Transform[] m_seats;

		private Transform m_cam;

		private GameObject m_landingLights;

		private AudioSource m_engine;

		private AudioSource m_oneShot;

		private WheelCollider[] m_wheels;

		private Collider[] m_colliders;

		private float m_scale;

		private float m_throttle;

		private float m_inPitchKey;

		private float m_inSteer;

		private bool m_inBoost;

		private bool m_inBrake;

		private float m_inputTime;

		private Vector3 m_lastVel;

		private Vector3 m_lastAngVel;

		private Vector3 m_lastPos;

		private float m_speed;

		private bool m_grounded = true;

		private bool m_localWasInside;

		private bool m_localWasAttachedHere;

		private Transform m_tempAttach;

		private static PlaneController s_piloting;

		private bool m_regrab;

		private float S => m_scale;

		private void Awake()
		{
			//IL_0102: 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_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			m_scale = Mathf.Clamp(Plugin.PlaneScale.Value, 0.3f, 1.2f);
			m_nview = ((Component)this).GetComponent<ZNetView>();
			m_body = ((Component)this).GetComponent<Rigidbody>();
			Transform val = ((Component)this).transform.Find("Seats");
			m_seats = (Transform[])(object)new Transform[val.childCount];
			for (int i = 0; i < m_seats.Length; i++)
			{
				m_seats[i] = val.GetChild(i);
			}
			m_cam = ((Component)this).transform.Find("CamPoint");
			Transform obj = ((Component)this).transform.Find("LandingLights");
			m_landingLights = ((obj != null) ? ((Component)obj).gameObject : null);
			if ((Object)(object)m_nview == (Object)null || m_nview.GetZDO() == null)
			{
				if (Object.op_Implicit((Object)(object)m_body))
				{
					m_body.isKinematic = true;
				}
				((Behaviour)this).enabled = false;
				return;
			}
			m_colliders = ((Component)this).GetComponentsInChildren<Collider>(true);
			m_body.centerOfMass = PlaneLayout.CenterOfMass * S;
			m_body.excludeLayers = VehicleUtil.PassThroughLayers(includeCharacters: false);
			m_engine = ((Component)this).GetComponent<AudioSource>();
			m_engine.clip = PlaneAudio.Jet;
			m_engine.volume = 0f;
			m_oneShot = ((Component)this).gameObject.AddComponent<AudioSource>();
			m_oneShot.spatialBlend = 1f;
			m_oneShot.rolloffMode = (AudioRolloffMode)1;
			m_oneShot.minDistance = 15f;
			m_oneShot.maxDistance = 250f;
			m_oneShot.dopplerLevel = 0f;
			AudioMixerGroup val2 = CarController.FindSfxMixer();
			if (Object.op_Implicit((Object)(object)val2))
			{
				m_engine.outputAudioMixerGroup = val2;
				m_oneShot.outputAudioMixerGroup = val2;
			}
			CreateWheels();
			m_nview.Register<long>("malzeki_747_release", (Action<long, long>)RPC_Release);
			m_nview.Register("malzeki_747_start", (Action<long>)delegate
			{
				if (Object.op_Implicit((Object)(object)m_oneShot))
				{
					m_oneShot.PlayOneShot(PlaneAudio.Spool, Plugin.CarVolume.Value);
				}
			});
			m_lastPos = ((Component)this).transform.position;
		}

		private void CreateWheels()
		{
			//IL_0008: 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_0014: 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_0025: 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)
			//IL_0067: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: 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_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: 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)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			Vector3[] array = (Vector3[])(object)new Vector3[3]
			{
				PlaneLayout.NoseGear,
				PlaneLayout.MainGearL,
				PlaneLayout.MainGearR
			};
			m_wheels = (WheelCollider[])(object)new WheelCollider[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				GameObject val = new GameObject("Gear" + i)
				{
					layer = ((Component)this).gameObject.layer
				};
				val.transform.SetParent(((Component)this).transform, false);
				val.transform.localPosition = (array[i] + Vector3.up * 0.25f) * S;
				WheelCollider val2 = val.AddComponent<WheelCollider>();
				val2.mass = 200f;
				val2.radius = 0.6f * S;
				val2.suspensionDistance = 0.5f * S;
				val2.forceAppPointDistance = 0.3f;
				JointSpring suspensionSpring = val2.suspensionSpring;
				suspensionSpring.spring = 400000f;
				suspensionSpring.damper = 40000f;
				suspensionSpring.targetPosition = 0.5f;
				val2.suspensionSpring = suspensionSpring;
				WheelFrictionCurve forwardFriction = val2.forwardFriction;
				((WheelFrictionCurve)(ref forwardFriction)).stiffness = 1.2f;
				val2.forwardFriction = forwardFriction;
				WheelFrictionCurve sidewaysFriction = val2.sidewaysFriction;
				((WheelFrictionCurve)(ref sidewaysFriction)).stiffness = 1.6f;
				val2.sidewaysFriction = sidewaysFriction;
				m_wheels[i] = val2;
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)s_piloting == (Object)(object)this)
			{
				s_piloting = null;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null && (Object)/*isinst with value type is only supported in some contexts*/ == (Object)(object)this)
			{
				localPlayer.StopDoodadControl();
			}
			if (m_localWasInside)
			{
				FirstPerson.Active = false;
			}
		}

		private long GetPilot()
		{
			if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
			{
				return 0L;
			}
			return m_nview.GetZDO().GetLong(s_pilotKey, 0L);
		}

		private bool IsLocalPilot()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer != (Object)null)
			{
				IDoodadController doodadController = localPlayer.GetDoodadController();
				return (Object)(object)((doodadController is Object) ? doodadController : null) == (Object)(object)this;
			}
			return false;
		}

		private bool HavePilot()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			long pilot = GetPilot();
			if (pilot == 0L)
			{
				return false;
			}
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (allPlayer.GetPlayerID() == pilot)
				{
					return Vector3.Distance(((Component)allPlayer).transform.position, m_seats[0].position) < 3f;
				}
			}
			return false;
		}

		private bool SeatTaken(int i)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (i == 0 && HavePilot())
			{
				return true;
			}
			foreach (Player allPlayer in Player.GetAllPlayers())
			{
				if (Vector3.Distance(((Component)allPlayer).transform.position, m_seats[i].position) < 0.4f * S + 0.2f)
				{
					return true;
				}
			}
			return false;
		}

		private bool IsInside(Player p)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)p != (Object)null)
			{
				return PlaneLayout.InsideCabin(((Component)this).transform.InverseTransformPoint(((Component)p).transform.position), S);
			}
			return false;
		}

		private bool IsAttachedHere(Player p)
		{
			if ((Object)(object)p == (Object)null || !((Character)p).IsAttached())
			{
				return false;
			}
			Transform attachPoint = p.GetAttachPoint();
			if ((Object)(object)attachPoint != (Object)null)
			{
				return attachPoint.IsChildOf(((Component)this).transform);
			}
			return false;
		}

		private bool IsFlipped()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)this).transform.up.y < 0.4f;
		}

		public string GetHoverName()
		{
			return Localization.instance.Localize("$piece_malzeki_747");
		}

		public string GetHoverText()
		{
			if (!Object.op_Implicit((Object)(object)m_nview) || !m_nview.IsValid())
			{
				return "";
			}
			Player localPlayer = Player.m_localPlayer;
			if (IsInside(localPlayer) || IsAttachedHere(localPlayer))
			{
				return "";
			}
			string hoverName = GetHoverName();
			if (IsFlipped())
			{
				return hoverName + Localization.instance.Localize("\n[<color=yellow><b>$KEY_Use</b></color>] Uçağı düzelt");
			}
			return hoverName + Localization.instance.Localize("\n[<color=yellow><b>$KEY_Use</b></color>] Uçağa bin");
		}

		public float GetHoverOffset()
		{
			return 25f * S;
		}

		public bool Interact(Humanoid character, bool hold, bool alt)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: 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_008e: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//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_0132: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			if (hold || !m_nview.IsValid())
			{
				return false;
			}
			Player val = (Player)(object)((character is Player) ? character : null);
			if ((Object)(object)val == (Object)null || (Object)(object)val != (Object)(object)Player.m_localPlayer || ((Character)val).IsAttached() || IsInside(val))
			{
				return false;
			}
			if (IsFlipped())
			{
				m_nview.ClaimOwnership();
				Transform transform = ((Component)this).transform;
				transform.position += Vector3.up * 3f;
				((Component)this).transform.rotation = Quaternion.Euler(0f, ((Component)this).transform.eulerAngles.y, 0f);
				m_body.position = ((Component)this).transform.position;
				m_body.rotation = ((Component)this).transform.rotation;
				m_body.linearVelocity = Vector3.zero;
				m_body.angularVelocity = Vector3.zero;
				return true;
			}
			if (m_speed > 6f || !m_grounded)
			{
				((Character)val).Message((MessageType)2, "Uçak hareket halinde", 0, (Sprite)null, false);
				return true;
			}
			VehicleUtil.Place(val, ((Component)this).transform.TransformPoint(PlaneLayout.EnterPoint * S), ((Component)this).transform.rotation, m_body.linearVelocity);
			((Character)val).Message((MessageType)1, "Pilot koltuğuna gidip E'ye bas", 0, (Sprite)null, false);
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}

		public string SeatHoverText(int i)
		{
			if (SeatTaken(i))
			{
				return Localization.instance.Localize((i == 0) ? "Pilot koltuğu\n<color=#888888>Dolu</color>" : "Koltuk\n<color=#888888>Dolu</color>");
			}
			return Localization.instance.Localize((i == 0) ? "Pilot koltuğu\n[<color=yellow><b>$KEY_Use</b></color>] Uçağı uçur" : "Koltuk\n[<color=yellow><b>$KEY_Use</b></color>] Otur");
		}

		public bool InteractSeat(Player p, int i)
		{
			if ((Object)(object)p == (Object)null || (Object)(object)p != (Object)(object)Player.m_localPlayer || ((Character)p).IsAttached())
			{
				return false;
			}
			if (SeatTaken(i))
			{
				((Character)p).Message((MessageType)2, "$msg_inuse", 0, (Sprite)null, false);
				return true;
			}
			if (i == 0)
			{
				m_nview.ClaimOwnership();
				m_nview.GetZDO().Set(s_pilotKey, p.GetPlayerID());
				m_throttle = 0f;
				p.StartDoodadControl((IDoodadController)(object)this);
				m_nview.InvokeRPC(ZNetView.Everybody, "malzeki_747_start", Array.Empty<object>());
				s_piloting = this;
			}
			Sit(p, m_seats[i]);
			return true;
		}

		private void Sit(Player p, Transform seat)
		{
			//IL_0001: 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_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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = new Vector3((seat.localPosition.x > 0f) ? (-0.8f) : 0.8f, 0.1f, 0f) * S;
			val = Quaternion.Inverse(seat.localRotation) * val;
			((Character)p).AttachStart(seat, ((Component)this).gameObject, true, false, true, "attach_chair", val, m_cam);
		}

		public bool ExitThroughDoor(Player p)
		{
			//IL_0026: 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_0036: 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_0042: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)p == (Object)null || (Object)(object)p != (Object)(object)Player.m_localPlayer || ((Character)p).IsAttached())
			{
				return false;
			}
			Vector3 val = ((Component)this).transform.TransformPoint(PlaneLayout.ExitOutside * S);
			if (VehicleUtil.HeightAboveGround(((Component)this).transform.TransformPoint(PlaneLayout.EnterPoint * S)) < 12f * S)
			{
				val.y = ZoneSystem.instance.GetGroundHeight(val) + 0.3f;
				VehicleUtil.Place(p, val, Quaternion.LookRotation(-((Component)this).transform.right), Vector3.zero);
			}
			else
			{
				val = ((Component)this).transform.TransformPoint(new Vector3(-6.5f, 5.3f, 26f) * S);
				VehicleUtil.Place(p, val, Quaternion.LookRotation(-((Component)this).transform.right), Vector3.zero);
				Parachute.Deploy(p);
			}
			FirstPerson.Active = false;
			m_localWasInside = false;
			return true;
		}

		public void OnUseStop(Player player)
		{
			if (!m_grounded && Mathf.Abs(m_speed) > 5f && (Object)(object)player == (Object)(object)Player.m_localPlayer)
			{
				((Character)player).Message((MessageType)2, "Havada pilot koltuğundan kalkamazsın, önce in!", 0, (Sprite)null, false);
				m_regrab = true;
				return;
			}
			if ((Object)(object)s_piloting == (Object)(object)this)
			{
				s_piloting = null;
			}
			if (Object.op_Implicit((Object)(object)m_nview) && m_nview.IsValid())
			{
				if (m_nview.IsOwner())
				{
					m_nview.GetZDO().Set(s_pilotKey, 0L);
				}
				else
				{
					m_nview.InvokeRPC("malzeki_747_release", new object[1] { player.GetPlayerID() });
				}
			}
			((Character)player).AttachStop();
		}

		public void ApplyControlls(Vector3 moveDir, Vector3 lookDir, bool run, bool autoRun, bool block)
		{
			//IL_0001: 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)
			m_inPitchKey = Mathf.Clamp(moveDir.z, -1f, 1f);
			m_inSteer = Mathf.Clamp(moveDir.x, -1f, 1f);
			m_inBoost = run;
			m_inBrake = block;
			m_inputTime = Time.time;
		}

		public Component GetControlledComponent()
		{
			return (Component)(object)this;
		}

		public Vector3 GetPosition()
		{
			//IL_001c: 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)
			if (m_seats == null)
			{
				return ((Component)this).transform.position;
			}
			return m_seats[0].position;
		}

		public bool IsValid()
		{
			if ((Object)(object)this != (Object)null && (Object)(object)m_nview != (Object)null)
			{
				return m_nview.IsValid();
			}
			return false;
		}

		private void RPC_Release(long sender, long id)
		{
			if (m_nview.IsOwner() && GetPilot() == id)
			{
				m_nview.GetZDO().Set(s_pilotKey, 0L);
			}
		}

		private void FixedUpdate()
		{
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: 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_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: 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_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: 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_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0261: 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_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_066d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: 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_0554: Unknown result type (might be due to invalid IL or missing references)
			//IL_0559: 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_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_0577: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0580: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_052f: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_060b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Unknown result type (might be due to invalid IL or missing references)
			//IL_061f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_0634: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0653: Unknown result type (might be due to invalid IL or missing references)
			//IL_065c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0486: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0499: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
			if (!m_nview.IsValid())
			{
				return;
			}
			bool flag = m_nview.IsOwner();
			bool flag2 = IsLocalPilot();
			if (flag2 && !flag)
			{
				m_nview.ClaimOwnership();
				flag = true;
			}
			if (m_body.isKinematic == flag)
			{
				m_body.isKinematic = !flag;
			}
			if (!flag)
			{
				return;
			}
			float fixedDeltaTime = Time.fixedDeltaTime;
			int num;
			float num2;
			if (flag2)
			{
				num = ((Time.time - m_inputTime < 0.3f) ? 1 : 0);
				if (num != 0)
				{
					num2 = m_inPitchKey;
					goto IL_0084;
				}
			}
			else
			{
				num = 0;
			}
			num2 = 0f;
			goto IL_0084;
			IL_0084:
			float num3 = num2;
			float num4 = ((num != 0) ? m_inSteer : 0f);
			if (flag2)
			{
				m_throttle = Mathf.Clamp01(m_throttle + num3 * 0.6f * fixedDeltaTime);
			}
			else
			{
				m_throttle = Mathf.MoveTowards(m_throttle, 0f, fixedDeltaTime * 0.5f);
			}
			Vector3 linearVelocity = m_body.linearVelocity;
			Vector3 forward = ((Component)this).transform.forward;
			float num5 = Vector3.Dot(linearVelocity, forward);
			m_grounded = false;
			WheelCollider[] wheels = m_wheels;
			for (int i = 0; i < wheels.Length; i++)
			{
				if (wheels[i].isGrounded)
				{
					m_grounded = true;
				}
			}
			float num6 = Plugin.PlaneTakeoffSpeed.Value / 3.6f;
			float num7 = (m_inBoost ? 1.35f : 1f) * Plugin.PlaneMaxSpeed.Value / 3.6f;
			float num8 = Plugin.PlaneThrust.Value * (m_inBoost ? 1.4f : 1f);
			m_body.AddForce(forward * m_throttle * num8, (ForceMode)5);
			float num9 = Plugin.PlaneThrust.Value / (num7 * num7);
			m_body.AddForce(-linearVelocity * ((Vector3)(ref linearVelocity)).magnitude * num9, (ForceMode)5);
			float num10 = Mathf.Clamp01(num5 / num6);
			Vector3 val = Physics.gravity;
			float num11 = ((Vector3)(ref val)).magnitude * num10 * num10 * Mathf.Clamp01(((Component)this).transform.up.y * 1.5f);
			m_body.AddForce(Vector3.up * num11, (ForceMode)5);
			if (!m_grounded)
			{
				Vector3 val2 = linearVelocity - forward * num5;
				m_body.AddForce(-val2 * 2f * num10, (ForceMode)5);
			}
			Vector3 forward2 = Vector3.forward;
			Player localPlayer = Player.m_localPlayer;
			forward2 = ((!flag2 || !((Object)(object)localPlayer != (Object)null) || !(((Vector3)(ref ((Character)localPlayer).m_lookDir)).sqrMagnitude > 0.01f)) ? forward : ((Vector3)(ref ((Character)localPlayer).m_lookDir)).normalized);
			if (m_grounded)
			{
				val = Vector3.ProjectOnPlane(forward, Vector3.up);
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				val = Vector3.ProjectOnPlane(forward2, Vector3.up);
				Vector3 normalized2 = ((Vector3)(ref val)).normalized;
				float steerAngle = Mathf.Clamp(flag2 ? Vector3.SignedAngle(normalized, normalized2, Vector3.up) : 0f, -45f, 45f) * Mathf.Lerp(1f, 0.25f, Mathf.Clamp01(num5 / num6)) + num4 * 30f;
				m_wheels[0].steerAngle = steerAngle;
				bool num12 = !flag2;
				bool flag3 = num12 || m_inBrake || (m_throttle < 0.02f && num3 < -0.1f);
				float brakeTorque = (num12 ? 1000000f : (flag3 ? 200000f : 0f));
				wheels = m_wheels;
				foreach (WheelCollider obj in wheels)
				{
					obj.brakeTorque = brakeTorque;
					obj.motorTorque = ((flag2 && m_throttle > 0.01f && Mathf.Abs(num5) < 0.5f) ? 1f : 0f);
				}
				float num13 = Mathf.Asin(Mathf.Clamp(forward2.y, -1f, 1f)) * 57.29578f;
				float num14 = Mathf.Asin(Mathf.Clamp(forward.y, -1f, 1f)) * 57.29578f;
				if (flag2 && num5 > num6 * 0.7f && num13 > 3f)
				{
					float num15 = Mathf.Clamp(Mathf.Min(num13, 15f) - num14, 0f, 15f);
					Vector3 val3 = ((Component)this).transform.right * (0f - num15) * 0.04f;
					m_body.angularVelocity = Vector3.Lerp(m_body.angularVelocity, val3 + Vector3.up * Vector3.Dot(m_body.angularVelocity, Vector3.up), 4f * fixedDeltaTime);
				}
			}
			else
			{
				wheels = m_wheels;
				foreach (WheelCollider obj2 in wheels)
				{
					obj2.brakeTorque = 0f;
					obj2.steerAngle = 0f;
				}
				if (flag2 && num10 > 0.3f)
				{
					if (num5 < num6 * 0.8f)
					{
						forward2 = Vector3.Slerp(forward2, Vector3.down, (1f - num5 / (num6 * 0.8f)) * 0.6f);
					}
					val = Vector3.ProjectOnPlane(forward, Vector3.up);
					Vector3 normalized3 = ((Vector3)(ref val)).normalized;
					val = Vector3.ProjectOnPlane(forward2, Vector3.up);
					Vector3 normalized4 = ((Vector3)(ref val)).normalized;
					float num16 = Mathf.Clamp((0f - Vector3.SignedAngle(normalized3, normalized4, Vector3.up)) * 1.3f - num4 * 50f, -70f, 70f);
					Quaternion val4 = Quaternion.LookRotation(forward2, Vector3.up) * Quaternion.Euler(0f, 0f, num16) * Quaternion.Inverse(m_body.rotation);
					float num17 = default(float);
					Vector3 val5 = default(Vector3);
					((Quaternion)(ref val4)).ToAngleAxis(ref num17, ref val5);
					if (num17 > 180f)
					{
						num17 -= 360f;
					}
					Vector3 val6 = ((Vector3)(ref val5)).normalized * num17 * (MathF.PI / 180f) * 1.8f;
					val6 = Vector3.ClampMagnitude(val6, 1.1f);
					if (!float.IsNaN(val6.x))
					{
						m_body.angularVelocity = Vector3.Lerp(m_body.angularVelocity, val6, 3f * fixedDeltaTime);
					}
				}
			}
			m_lastVel = m_body.linearVelocity;
			m_lastAngVel = m_body.angularVelocity;
			if (flag2 && Time.frameCount % 6 == 0)
			{
				ZDO zDO = m_nview.GetZDO();
				if (Mathf.Abs(zDO.GetFloat(s_throttleKey, 0f) - m_throttle) > 0.03f)
				{
					zDO.Set(s_throttleKey, m_throttle);
				}
			}
		}

		private void OnCollisionEnter(Collision c)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)m_nview == (Object)null) && m_nview.IsValid() && m_nview.IsOwner())
			{
				VehicleUtil.TrySmash(c, m_body, m_colliders, m_lastVel, m_lastAngVel, 3f);
			}
		}

		private void Update()
		{
			//IL_004f: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_0061: 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_00ae: 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_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			if (!m_nview.IsValid())
			{
				return;
			}
			float num = Mathf.Max(Time.deltaTime, 0.0001f);
			Vector3 val = (m_nview.IsOwner() ? m_body.linearVelocity : ((((Component)this).transform.position - m_lastPos) / num));
			m_lastPos = ((Component)this).transform.position;
			m_speed = Mathf.Lerp(m_speed, Vector3.Dot(val, ((Component)this).transform.forward), 1f - Mathf.Exp(-6f * num));
			if (!m_nview.IsOwner())
			{
				m_grounded = VehicleUtil.HeightAboveGround(((Component)this).transform.position) < 1.5f * S + 0.5f;
			}
			if (m_regrab)
			{
				m_regrab = false;
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer != (Object)null && (Object)(object)localPlayer.GetAttachPoint() == (Object)(object)m_seats[0] && localPlayer.GetDoodadController() == null)
				{
					localPlayer.StartDoodadControl((IDoodadController)(object)this);
				}
			}
			UpdateLocalPlayer();
			bool num2 = IsLocalPilot();
			if (num2)
			{
				s_piloting = this;
			}
			else if ((Object)(object)s_piloting == (Object)(object)this)
			{
				s_piloting = null;
			}
			if (num2 && ((Character)Player.m_localPlayer).TakeInput() && ZInput.GetKeyDown(Plugin.LightsKey.Value, false))
			{
				ZDO zDO = m_nview.GetZDO();
				zDO.Set(s_lightsKey, !zDO.GetBool(s_lightsKey, false));
			}
			if (Object.op_Implicit((Object)(object)m_landingLights))
			{
				bool flag = m_nview.GetZDO().GetBool(s_lightsKey, false);
				if (m_landingLights.activeSelf != flag)
				{
					m_landingLights.SetActive(flag);
				}
			}
			if (IsAttachedHere(Player.m_localPlayer))
			{
				VehicleUtil.UpdateChaseCam(m_cam, ((Component)this).transform, PlaneLayout.CamPivot * S, Plugin.PlaneCamDistance.Value * S);
			}
			UpdateSound(num);
		}

		private void UpdateLocalPlayer()
		{
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Obj