Decompiled source of VehicleTools v1.0.2

Zichen-VehicleTools-1.0.2.dll

Decompiled 4 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Zichen-VehicleTools-1.0.2")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+e78fd5280699057c5719cca97f6e71c777226865")]
[assembly: AssemblyProduct("Zichen-VehicleTools-1.0.2")]
[assembly: AssemblyTitle("Zichen-VehicleTools-1.0.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 Zichen_VehicleTools
{
	[BepInPlugin("zichen.vehicletools", "VehicleTools", "1.0.2")]
	public class Plugin : BaseUnityPlugin
	{
		public class CustomPassengerInfo
		{
			public PlayerAvatar Player;

			public float MountTime;

			public bool HasReleasedGrabSinceMount;
		}

		internal sealed class CfgI18N
		{
			public string SectionCN;

			public string SectionEN;

			public string KeyCN;

			public string KeyEN;

			public string DescCN;

			public string DescEN;

			public ConfigurationManagerAttributes Attrs;

			public ConfigDefinition Definition;

			public string ValueEN;

			public string ValueCN;

			public ConfigEntry<string> ReadOnlyEntry;

			public string DisplayEN;

			public string[] SliderOptionsEN;

			public string[] SliderOptionsCN;
		}

		internal sealed class LiveLabel
		{
			public WeakReference<TextMeshProUGUI> Tmp;

			public CfgI18N I18N;

			public bool IsSection;
		}

		internal sealed class LiveValue
		{
			public WeakReference<Object> InputField;

			public CfgI18N I18N;
		}

		[CompilerGenerated]
		private sealed class <WaitForMenuReady>d__233 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public float deadlineSeconds;

			public Action<MenuManager> onReady;

			private float <deadline>5__2;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitForMenuReady>d__233(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<deadline>5__2 = Time.unscaledTime + deadlineSeconds;
					goto IL_00a6;
				case 1:
				{
					<>1__state = -1;
					MenuManager instance = MenuManager.instance;
					if ((Object)(object)instance != (Object)null && !IsPopupSlotBusy(instance))
					{
						onReady?.Invoke(instance);
						return false;
					}
					goto IL_008f;
				}
				case 2:
					{
						<>1__state = -1;
						goto IL_00a6;
					}
					IL_00a6:
					if (Time.unscaledTime < <deadline>5__2)
					{
						MenuManager instance = MenuManager.instance;
						if ((Object)(object)instance != (Object)null && !IsPopupSlotBusy(instance))
						{
							<>2__current = null;
							<>1__state = 1;
							return true;
						}
						goto IL_008f;
					}
					return false;
					IL_008f:
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public const string PluginGuid = "zichen.vehicletools";

		public const string PluginName = "VehicleTools";

		public const string PluginVersion = "1.0.2";

		internal const byte JumpEventCode = 152;

		internal const byte SpeedLimitEventCode = 153;

		private float _syncTimer = 2f;

		private bool _eventRegistered;

		internal static readonly CompatibilityState Compat = new CompatibilityState();

		internal static Plugin Instance;

		private static readonly FieldInfo F_isVehicleAirborne = typeof(ItemVehicle).GetField("isVehicleAirborne", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private static readonly FieldInfo F_inputY = typeof(ItemVehicle).GetField("inputY", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

		private Harmony _harmony;

		private static ConfigEntry<bool> _cfgModEnabled;

		private ConfigEntry<string> _openKey;

		private static ConfigEntry<DisplayLanguage> _cfgLanguage;

		private static ConfigEntry<string> _moduleNameInfo;

		private static ConfigEntry<string> _moduleVersionInfo;

		private ConfigFile _runtimeConfig;

		private static ConfigEntry<int> _cfgMaxPassengerLimit;

		private static int _currentTab = 0;

		private static ConfigEntry<bool> _cfgGlobalFeaturesEnabled;

		private static ConfigEntry<bool> _cfgCargoFeaturesEnabled;

		private static ConfigEntry<bool> _cfgSpeedLimitEnabled;

		private static ConfigEntry<bool> _cfgVehicleProtectEnabled;

		private static ConfigEntry<string> _cfgLastRuntimeVersion;

		private static ConfigEntry<float> _cfgMaxSpeedLimit;

		private static ConfigEntry<bool> _cfgJumpEnabled;

		private static ConfigEntry<bool> _cfgContinuousJump;

		private static ConfigEntry<float> _cfgJumpForce;

		private static ConfigEntry<bool> _cfgCargoInfiniteInventory;

		private static ConfigEntry<bool> _cfgCargoIgnoreSizeLimit;

		private static ConfigEntry<float> _cfgCargoSuckRangeMultiplier;

		private static ConfigEntry<PassengerMountMode> _cfgPassengerMountModeSetting;

		private static ConfigEntry<bool> _cfgVehicleNoBatteryDrain;

		private static ConfigEntry<bool> _cfgOptimizeCamera;

		private static ConfigEntry<bool> _cfgTurnNoDecelEnabled;

		public static bool IsLocalPlayerInVehicle = false;

		private static Vector3? _origPlayerOffset = null;

		public static float LastVehicleTime = 0f;

		public static Vector3 originalPlayerOffset = Vector3.zero;

		private Vector2 _scrollPos = Vector2.zero;

		private float _lastVirtualHeight = 600f;

		internal static float _jumpCooldownTimer;

		internal static float _tumbleProtectTimer;

		internal static ItemVehicle _pendingVehicle;

		internal static int _pendingFrame = -1;

		private static readonly Dictionary<ItemVehicle, List<Vector3>> _origSeatPositions = new Dictionary<ItemVehicle, List<Vector3>>();

		private static readonly Dictionary<ItemVehicle, List<Quaternion>> _origSeatRotations = new Dictionary<ItemVehicle, List<Quaternion>>();

		private static readonly Dictionary<VehicleSeat, Vector3> _origSeatLocalPositions = new Dictionary<VehicleSeat, Vector3>();

		private static readonly Dictionary<VehicleSeat, Vector3> _origGrabPointLocalPositions = new Dictionary<VehicleSeat, Vector3>();

		internal static readonly Dictionary<ItemVehicle, (Vector3 pos, Quaternion rot)> _vehicleSpawnPositions = new Dictionary<ItemVehicle, (Vector3, Quaternion)>();

		internal static readonly Dictionary<PhysGrabObjectImpactDetector, bool> _vehicleDestroyDisableOriginalValues = new Dictionary<PhysGrabObjectImpactDetector, bool>();

		private bool _windowOpen;

		private bool _windowCentered;

		private Rect _windowRect = new Rect(0f, 0f, 780f, 700f);

		private string _status = "按 F1 打开/关闭车辆工具箱。";

		private bool _useChinese = true;

		private const float Pad = 16f;

		private const int GuiWindowId = 33005;

		private static CursorLockMode _prevLockMode;

		private static bool _prevVisible;

		private bool _stylesInit;

		private GUIStyle _sWindow;

		private GUIStyle _sTitle;

		private GUIStyle _sLabel;

		private GUIStyle _sStatus;

		private GUIStyle _sSection;

		private GUIStyle _sBtnGreen;

		private GUIStyle _sBtnRed;

		private GUIStyle _sBtnNormal;

		private GUIStyle _sToggle;

		private GUIStyle _sToggleOn;

		private GUIStyle _sTextField;

		private GUIStyle _sCheckmarkStyle;

		private GUIStyle _sCheckmarkStyleWhite;

		private GUIStyle _sSlider;

		private GUIStyle _sThumb;

		private GUIStyle _sBtnClose;

		private Texture2D _texDark;

		private Texture2D _texMid;

		private Texture2D _texLight;

		private Texture2D _texGreen;

		private Texture2D _texRed;

		private Texture2D _texSection;

		private Texture2D _texBorder;

		private static readonly FieldInfo F_CursorUnlockTimer = AccessTools.Field(typeof(CursorManager), "unlockTimer");

		private static readonly FieldInfo F_PlayerTumble = AccessTools.Field(typeof(PlayerAvatar), "tumble");

		private static readonly FieldInfo F_TumblePhysGrabObject = AccessTools.Field(typeof(PlayerTumble), "physGrabObject");

		private static readonly FieldInfo F_TumbleRb = AccessTools.Field(typeof(PlayerTumble), "rb");

		private static readonly FieldInfo F_TumbleIsTumbling = AccessTools.Field(typeof(PlayerTumble), "isTumbling");

		private static readonly FieldInfo F_PlayerAvatarIsDisabled = AccessTools.Field(typeof(PlayerAvatar), "isDisabled");

		private static readonly FieldInfo F_PhysGrabObjectImpactDetector = AccessTools.Field(typeof(PhysGrabObject), "impactDetector");

		private static readonly FieldInfo F_VehicleIsFullyDestroyed = AccessTools.Field(typeof(ItemVehicle), "isFullyDestroyed");

		private static readonly FieldInfo F_VehicleGrabArea = AccessTools.Field(typeof(ItemVehicle), "grabArea");

		private static readonly FieldInfo F_GrabAreaListOfGrabbers = AccessTools.Field(typeof(GrabArea), "listOfGrabbers");

		private bool _wasInRoom;

		private static readonly string[] _chineseModKeywords = new string[6] { "chinese", "简体", "繁體", "繁体", "汉化", "中文" };

		private static readonly string[] _chineseEnvironmentPluginGuids = new string[1] { "gravydevsupreme.xunity.autotranslator" };

		public static readonly Dictionary<ItemVehicle, List<CustomPassengerInfo>> VehiclePassengers = new Dictionary<ItemVehicle, List<CustomPassengerInfo>>();

		private static readonly Dictionary<ItemVehicle, HashSet<PlayerAvatar>> _vehiclePrevGrabbers = new Dictionary<ItemVehicle, HashSet<PlayerAvatar>>();

		internal static readonly string[] AvailableKeybinds = new string[55]
		{
			"A", "B", "C", "D", "E", "F", "G", "H", "I", "J",
			"K", "L", "M", "N", "O", "P", "Q", "R", "S", "T",
			"U", "V", "W", "X", "Y", "Z", "0", "1", "2", "3",
			"4", "5", "6", "7", "8", "9", "F1", "F2", "F3", "F4",
			"F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "Space", "Enter",
			"Tab", "LeftShift", "RightShift", "LeftControl", "RightControl"
		};

		private const int OpenInputKeyValue = 335;

		private static readonly InputKey OpenInputKey = (InputKey)335;

		private static string _lastAppliedOpenKey;

		private static readonly FieldRef<MenuManager, bool> PagePopUpScheduledRef = AccessTools.FieldRefAccess<MenuManager, bool>("pagePopUpScheduled");

		private static readonly FieldRef<MenuManager, MenuPageIndex> CurrentMenuPageIndexRef = AccessTools.FieldRefAccess<MenuManager, MenuPageIndex>("currentMenuPageIndex");

		private static readonly FieldRef<MenuManager, MenuPage> CurrentMenuPageRef = AccessTools.FieldRefAccess<MenuManager, MenuPage>("currentMenuPage");

		internal static readonly Dictionary<string, CfgI18N> _cfgByEnSection = new Dictionary<string, CfgI18N>(StringComparer.Ordinal);

		internal static readonly Dictionary<string, CfgI18N> _cfgByEnKey = new Dictionary<string, CfgI18N>(StringComparer.Ordinal);

		private static readonly List<CfgI18N> _cfgI18Ns = new List<CfgI18N>(20);

		private static readonly List<LiveLabel> _liveLabels = new List<LiveLabel>(64);

		private static readonly List<LiveValue> _liveValues = new List<LiveValue>(8);

		private static readonly Dictionary<Type, FieldInfo> _labelTmpFieldCache = new Dictionary<Type, FieldInfo>(8);

		private static FieldInfo _inputStringSystemField;

		private static MethodInfo _inputStringSystemSetValue;

		private static ConfigEntry<bool> _cfgAutoSpawnCargoVehicle;

		private static bool _hasSpawnedThisLevel = false;

		private static float _spawnDelayTimer = -1f;

		private static bool _isPendingSpawn = false;

		private static string _cargoVehicleResourcePath = null;

		private static ConfigEntry<float> _cfgJumpCooldown;

		private static ConfigEntry<float> _cfgTumbleProtectDuration;

		private static ConfigEntry<bool> _cfgPassengerMountEnabled;

		private static ConfigEntry<bool> _cfgPassengerReduceTumble;

		internal static ManualLogSource Log
		{
			get
			{
				Plugin instance = Instance;
				if (instance == null)
				{
					return null;
				}
				return ((BaseUnityPlugin)instance).Logger;
			}
		}

		public static int MaxPassengerLimit
		{
			get
			{
				if (_cfgMaxPassengerLimit == null)
				{
					return 10;
				}
				return _cfgMaxPassengerLimit.Value;
			}
			set
			{
				if (_cfgMaxPassengerLimit == null || _cfgMaxPassengerLimit.Value == value)
				{
					return;
				}
				_cfgMaxPassengerLimit.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool GlobalFeaturesEnabled
		{
			get
			{
				if (_cfgGlobalFeaturesEnabled == null)
				{
					return true;
				}
				return _cfgGlobalFeaturesEnabled.Value;
			}
			set
			{
				if (_cfgGlobalFeaturesEnabled == null || _cfgGlobalFeaturesEnabled.Value == value)
				{
					return;
				}
				_cfgGlobalFeaturesEnabled.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool CargoFeaturesEnabled
		{
			get
			{
				if (GlobalFeaturesEnabled)
				{
					if (_cfgCargoFeaturesEnabled == null)
					{
						return true;
					}
					return _cfgCargoFeaturesEnabled.Value;
				}
				return false;
			}
			set
			{
				if (_cfgCargoFeaturesEnabled == null || _cfgCargoFeaturesEnabled.Value == value)
				{
					return;
				}
				_cfgCargoFeaturesEnabled.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool SpeedLimitEnabled
		{
			get
			{
				if (GlobalFeaturesEnabled)
				{
					if (_cfgSpeedLimitEnabled == null)
					{
						return true;
					}
					return _cfgSpeedLimitEnabled.Value;
				}
				return false;
			}
			set
			{
				if (_cfgSpeedLimitEnabled == null || _cfgSpeedLimitEnabled.Value == value)
				{
					return;
				}
				_cfgSpeedLimitEnabled.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool VehicleProtectEnabled
		{
			get
			{
				if (GlobalFeaturesEnabled)
				{
					if (_cfgVehicleProtectEnabled == null)
					{
						return true;
					}
					return _cfgVehicleProtectEnabled.Value;
				}
				return false;
			}
			set
			{
				if (_cfgVehicleProtectEnabled == null || _cfgVehicleProtectEnabled.Value == value)
				{
					return;
				}
				_cfgVehicleProtectEnabled.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static float MaxSpeedLimit
		{
			get
			{
				if (_cfgMaxSpeedLimit == null)
				{
					return 45f;
				}
				return _cfgMaxSpeedLimit.Value;
			}
			set
			{
				if (_cfgMaxSpeedLimit == null || _cfgMaxSpeedLimit.Value == value)
				{
					return;
				}
				_cfgMaxSpeedLimit.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool JumpEnabled
		{
			get
			{
				if (GlobalFeaturesEnabled)
				{
					if (_cfgJumpEnabled == null)
					{
						return false;
					}
					return _cfgJumpEnabled.Value;
				}
				return false;
			}
			set
			{
				if (_cfgJumpEnabled == null || _cfgJumpEnabled.Value == value)
				{
					return;
				}
				_cfgJumpEnabled.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool ContinuousJump
		{
			get
			{
				if (JumpEnabled)
				{
					if (_cfgContinuousJump == null)
					{
						return false;
					}
					return _cfgContinuousJump.Value;
				}
				return false;
			}
			set
			{
				if (_cfgContinuousJump == null || _cfgContinuousJump.Value == value)
				{
					return;
				}
				_cfgContinuousJump.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static float JumpForce
		{
			get
			{
				if (_cfgJumpForce == null)
				{
					return 40f;
				}
				return _cfgJumpForce.Value;
			}
			set
			{
				if (_cfgJumpForce == null || _cfgJumpForce.Value == value)
				{
					return;
				}
				_cfgJumpForce.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool CargoInfiniteInventory
		{
			get
			{
				if (CargoFeaturesEnabled)
				{
					if (_cfgCargoInfiniteInventory == null)
					{
						return true;
					}
					return _cfgCargoInfiniteInventory.Value;
				}
				return false;
			}
			set
			{
				if (_cfgCargoInfiniteInventory == null || _cfgCargoInfiniteInventory.Value == value)
				{
					return;
				}
				_cfgCargoInfiniteInventory.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool CargoIgnoreSizeLimit
		{
			get
			{
				if (CargoFeaturesEnabled)
				{
					if (_cfgCargoIgnoreSizeLimit == null)
					{
						return true;
					}
					return _cfgCargoIgnoreSizeLimit.Value;
				}
				return false;
			}
			set
			{
				if (_cfgCargoIgnoreSizeLimit == null || _cfgCargoIgnoreSizeLimit.Value == value)
				{
					return;
				}
				_cfgCargoIgnoreSizeLimit.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static float CargoSuckRangeMultiplier
		{
			get
			{
				if (!CargoFeaturesEnabled)
				{
					return 1f;
				}
				if (_cfgCargoSuckRangeMultiplier == null)
				{
					return 3f;
				}
				return _cfgCargoSuckRangeMultiplier.Value;
			}
			set
			{
				if (_cfgCargoSuckRangeMultiplier == null || _cfgCargoSuckRangeMultiplier.Value == value)
				{
					return;
				}
				_cfgCargoSuckRangeMultiplier.Value = Mathf.Max(1f, value);
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static PassengerMountMode PassengerMountModeSetting
		{
			get
			{
				if (!PassengerMountEnabled)
				{
					return PassengerMountMode.Default;
				}
				if (_cfgPassengerMountModeSetting == null)
				{
					return PassengerMountMode.Head;
				}
				return _cfgPassengerMountModeSetting.Value;
			}
			set
			{
				if (_cfgPassengerMountModeSetting == null || _cfgPassengerMountModeSetting.Value == value)
				{
					return;
				}
				_cfgPassengerMountModeSetting.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool VehicleNoBatteryDrain
		{
			get
			{
				if (GlobalFeaturesEnabled)
				{
					if (_cfgVehicleNoBatteryDrain == null)
					{
						return true;
					}
					return _cfgVehicleNoBatteryDrain.Value;
				}
				return false;
			}
			set
			{
				if (_cfgVehicleNoBatteryDrain == null || _cfgVehicleNoBatteryDrain.Value == value)
				{
					return;
				}
				_cfgVehicleNoBatteryDrain.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool OptimizeCamera
		{
			get
			{
				if (GlobalFeaturesEnabled)
				{
					if (_cfgOptimizeCamera == null)
					{
						return true;
					}
					return _cfgOptimizeCamera.Value;
				}
				return false;
			}
			set
			{
				if (_cfgOptimizeCamera == null || _cfgOptimizeCamera.Value == value)
				{
					return;
				}
				_cfgOptimizeCamera.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool TurnNoDecelEnabled
		{
			get
			{
				if (GlobalFeaturesEnabled)
				{
					if (_cfgTurnNoDecelEnabled == null)
					{
						return true;
					}
					return _cfgTurnNoDecelEnabled.Value;
				}
				return false;
			}
			set
			{
				if (_cfgTurnNoDecelEnabled == null || _cfgTurnNoDecelEnabled.Value == value)
				{
					return;
				}
				_cfgTurnNoDecelEnabled.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool RuntimeFeaturesEnabled
		{
			get
			{
				if (IsStaticModEnabled())
				{
					return GlobalFeaturesEnabled;
				}
				return false;
			}
		}

		public static bool AutoSpawnCargoVehicle
		{
			get
			{
				if (GlobalFeaturesEnabled)
				{
					if (_cfgAutoSpawnCargoVehicle == null)
					{
						return true;
					}
					return _cfgAutoSpawnCargoVehicle.Value;
				}
				return false;
			}
			set
			{
				if (_cfgAutoSpawnCargoVehicle == null || _cfgAutoSpawnCargoVehicle.Value == value)
				{
					return;
				}
				_cfgAutoSpawnCargoVehicle.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static float JumpCooldown
		{
			get
			{
				if (_cfgJumpCooldown == null)
				{
					return 0.1f;
				}
				return _cfgJumpCooldown.Value;
			}
			set
			{
				if (_cfgJumpCooldown == null || _cfgJumpCooldown.Value == value)
				{
					return;
				}
				_cfgJumpCooldown.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static float TumbleProtectDuration
		{
			get
			{
				if (_cfgTumbleProtectDuration == null)
				{
					return 0.1f;
				}
				return _cfgTumbleProtectDuration.Value;
			}
			set
			{
				if (_cfgTumbleProtectDuration == null || _cfgTumbleProtectDuration.Value == value)
				{
					return;
				}
				_cfgTumbleProtectDuration.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool PassengerMountEnabled
		{
			get
			{
				if (GlobalFeaturesEnabled)
				{
					if (_cfgPassengerMountEnabled == null)
					{
						return true;
					}
					return _cfgPassengerMountEnabled.Value;
				}
				return false;
			}
			set
			{
				if (_cfgPassengerMountEnabled == null || _cfgPassengerMountEnabled.Value == value)
				{
					return;
				}
				_cfgPassengerMountEnabled.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool PassengerReduceTumble
		{
			get
			{
				if (PassengerMountEnabled)
				{
					if (_cfgPassengerReduceTumble == null)
					{
						return true;
					}
					return _cfgPassengerReduceTumble.Value;
				}
				return false;
			}
			set
			{
				if (_cfgPassengerReduceTumble == null || _cfgPassengerReduceTumble.Value == value)
				{
					return;
				}
				_cfgPassengerReduceTumble.Value = value;
				if (!SemiFunc.IsMasterClientOrSingleplayer())
				{
					return;
				}
				Plugin instance = Instance;
				if (instance != null)
				{
					ConfigFile runtimeConfig = instance._runtimeConfig;
					if (runtimeConfig != null)
					{
						runtimeConfig.Save();
					}
				}
				BroadcastConfigToOthers();
			}
		}

		public static bool GetIsVehicleAirborne(ItemVehicle vehicle)
		{
			if ((Object)(object)vehicle != (Object)null)
			{
				return (bool)(F_isVehicleAirborne?.GetValue(vehicle) ?? ((object)false));
			}
			return false;
		}

		public static float GetInputY(ItemVehicle vehicle)
		{
			if (!((Object)(object)vehicle != (Object)null))
			{
				return 0f;
			}
			return (float)(F_inputY?.GetValue(vehicle) ?? ((object)0f));
		}

		private static void BroadcastConfigToOthers()
		{
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Expected O, but got Unknown
			if (PhotonNetwork.IsConnected && SemiFunc.IsMasterClientOrSingleplayer())
			{
				try
				{
					object[] array = new object[20]
					{
						_cfgSpeedLimitEnabled == null || _cfgSpeedLimitEnabled.Value,
						(_cfgMaxSpeedLimit != null) ? _cfgMaxSpeedLimit.Value : 45f,
						_cfgJumpEnabled != null && _cfgJumpEnabled.Value,
						_cfgContinuousJump != null && _cfgContinuousJump.Value,
						(_cfgJumpForce != null) ? _cfgJumpForce.Value : 40f,
						(int)((_cfgPassengerMountModeSetting != null) ? _cfgPassengerMountModeSetting.Value : PassengerMountMode.Head),
						(_cfgMaxPassengerLimit != null) ? _cfgMaxPassengerLimit.Value : 10,
						_cfgCargoInfiniteInventory == null || _cfgCargoInfiniteInventory.Value,
						(_cfgCargoSuckRangeMultiplier != null) ? _cfgCargoSuckRangeMultiplier.Value : 3f,
						_cfgTurnNoDecelEnabled == null || _cfgTurnNoDecelEnabled.Value,
						_cfgCargoIgnoreSizeLimit == null || _cfgCargoIgnoreSizeLimit.Value,
						_cfgVehicleNoBatteryDrain == null || _cfgVehicleNoBatteryDrain.Value,
						_cfgAutoSpawnCargoVehicle == null || _cfgAutoSpawnCargoVehicle.Value,
						(_cfgJumpCooldown != null) ? _cfgJumpCooldown.Value : 0.1f,
						(_cfgTumbleProtectDuration != null) ? _cfgTumbleProtectDuration.Value : 0.1f,
						_cfgPassengerReduceTumble == null || _cfgPassengerReduceTumble.Value,
						_cfgGlobalFeaturesEnabled == null || _cfgGlobalFeaturesEnabled.Value,
						_cfgPassengerMountEnabled == null || _cfgPassengerMountEnabled.Value,
						_cfgCargoFeaturesEnabled == null || _cfgCargoFeaturesEnabled.Value,
						_cfgVehicleProtectEnabled == null || _cfgVehicleProtectEnabled.Value
					};
					PhotonNetwork.RaiseEvent((byte)153, (object)array, new RaiseEventOptions
					{
						Receivers = (ReceiverGroup)0
					}, SendOptions.SendReliable);
				}
				catch
				{
				}
			}
		}

		public static bool IsArenaOrRace()
		{
			try
			{
				return (Object)(object)ArenaRace.instance != (Object)null || (Object)(object)Arena.instance != (Object)null;
			}
			catch
			{
				return false;
			}
		}

		public static bool IsStaticModEnabled()
		{
			if (_cfgModEnabled != null)
			{
				return _cfgModEnabled.Value;
			}
			return false;
		}

		public static bool UseChinese()
		{
			if (_cfgLanguage != null)
			{
				return _cfgLanguage.Value == DisplayLanguage.中文;
			}
			return false;
		}

		public static PlayerTumble GetPlayerTumble(PlayerAvatar player)
		{
			object? obj = F_PlayerTumble?.GetValue(player);
			return (PlayerTumble)((obj is PlayerTumble) ? obj : null);
		}

		public static PhysGrabObjectGrabArea GetVehicleGrabArea(ItemVehicle vehicle)
		{
			object? obj = F_VehicleGrabArea?.GetValue(vehicle);
			return (PhysGrabObjectGrabArea)((obj is PhysGrabObjectGrabArea) ? obj : null);
		}

		public static List<PhysGrabber> GetGrabAreaListOfGrabbers(GrabArea area)
		{
			return F_GrabAreaListOfGrabbers?.GetValue(area) as List<PhysGrabber>;
		}

		public static void RightUpVehicle(ItemVehicle vehicle)
		{
			//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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)vehicle == (Object)null)
			{
				return;
			}
			try
			{
				Quaternion rotation = ((Component)vehicle).transform.rotation;
				Vector3 eulerAngles = ((Quaternion)(ref rotation)).eulerAngles;
				Quaternion rotation2 = Quaternion.Euler(0f, eulerAngles.y, 0f);
				((Component)vehicle).transform.rotation = rotation2;
				if ((Object)(object)vehicle.rb != (Object)null)
				{
					vehicle.rb.rotation = rotation2;
					vehicle.rb.angularVelocity = Vector3.zero;
					Rigidbody rb = vehicle.rb;
					rb.position += Vector3.up * 0.15f;
					Vector3 velocity = vehicle.rb.velocity;
					velocity.y = Mathf.Max(0f, velocity.y);
					vehicle.rb.velocity = velocity;
				}
			}
			catch
			{
			}
		}

		public static void IgnorePassengerVehicleColliders(ItemVehicle vehicle, PlayerAvatar player, bool ignore)
		{
			if ((Object)(object)vehicle == (Object)null || (Object)(object)player == (Object)null)
			{
				return;
			}
			try
			{
				Collider[] componentsInChildren = ((Component)player).GetComponentsInChildren<Collider>(true);
				Collider[] componentsInChildren2 = ((Component)vehicle).GetComponentsInChildren<Collider>(true);
				if (componentsInChildren == null || componentsInChildren2 == null)
				{
					return;
				}
				Collider[] array = componentsInChildren;
				foreach (Collider val in array)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					Collider[] array2 = componentsInChildren2;
					foreach (Collider val2 in array2)
					{
						if (!((Object)(object)val2 == (Object)null))
						{
							Physics.IgnoreCollision(val, val2, ignore);
						}
					}
				}
			}
			catch
			{
			}
		}

		public static PhysGrabObject GetTumblePhysGrabObject(PlayerTumble tumble)
		{
			object? obj = F_TumblePhysGrabObject?.GetValue(tumble);
			return (PhysGrabObject)((obj is PhysGrabObject) ? obj : null);
		}

		public static Rigidbody GetTumbleRb(PlayerTumble tumble)
		{
			object? obj = F_TumbleRb?.GetValue(tumble);
			return (Rigidbody)((obj is Rigidbody) ? obj : null);
		}

		public static bool IsPlayerTumbling(PlayerTumble tumble)
		{
			return (bool)(F_TumbleIsTumbling?.GetValue(tumble) ?? ((object)false));
		}

		public static bool IsPlayerDisabled(PlayerAvatar player)
		{
			return (bool)(F_PlayerAvatarIsDisabled?.GetValue(player) ?? ((object)false));
		}

		public static bool IsVehicleFullyDestroyed(ItemVehicle vehicle)
		{
			return (bool)(F_VehicleIsFullyDestroyed?.GetValue(vehicle) ?? ((object)false));
		}

		public static void DisablePhysGrabObjectImpact(PhysGrabObject physGrabObject, float duration)
		{
			if ((Object)(object)physGrabObject == (Object)null)
			{
				return;
			}
			object obj = F_PhysGrabObjectImpactDetector?.GetValue(physGrabObject);
			if (obj == null)
			{
				return;
			}
			try
			{
				obj.GetType().GetMethod("ImpactDisable", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(obj, new object[1] { duration });
			}
			catch
			{
			}
		}

		private void Awake()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			Instance = this;
			DetachFromManager();
			ResetConfigIfVersionChanged();
			BindConfig();
			_openKey.SettingChanged += delegate
			{
				RebindOpenKey();
			};
			if (_cfgLanguage != null)
			{
				_cfgLanguage.SettingChanged += delegate
				{
					_useChinese = _cfgLanguage.Value == DisplayLanguage.中文;
					RefreshAllI18N();
				};
			}
			RunCompatibilityCheck();
			_harmony = new Harmony("zichen.vehicletools");
			InstallPatches();
			TryHookREPOConfig(_harmony);
			InitializeSceneLoadEvent();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"VehicleTools v1.0.2 loaded.");
			if (!Compat.HasIssues)
			{
				return;
			}
			((BaseUnityPlugin)this).Logger.LogWarning((object)("兼容自检发现问题: " + string.Join(", ", Compat.AffectedFeatures)));
			foreach (string detailLog in Compat.DetailLogs)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("  " + detailLog));
			}
		}

		private static bool IsInGame()
		{
			return true;
		}

		private bool IsOpenKeyPressed()
		{
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Expected O, but got Unknown
			try
			{
				string text = _openKey?.Value ?? "F1";
				Keyboard current = Keyboard.current;
				if (current != null)
				{
					KeyControl val = null;
					if (string.Equals(text, "F1", StringComparison.OrdinalIgnoreCase))
					{
						val = current.f1Key;
					}
					else if (string.Equals(text, "F2", StringComparison.OrdinalIgnoreCase))
					{
						val = current.f2Key;
					}
					else if (string.Equals(text, "F3", StringComparison.OrdinalIgnoreCase))
					{
						val = current.f3Key;
					}
					else if (string.Equals(text, "F4", StringComparison.OrdinalIgnoreCase))
					{
						val = current.f4Key;
					}
					else if (string.Equals(text, "F5", StringComparison.OrdinalIgnoreCase))
					{
						val = current.f5Key;
					}
					else if (string.Equals(text, "F6", StringComparison.OrdinalIgnoreCase))
					{
						val = current.f6Key;
					}
					else if (string.Equals(text, "F7", StringComparison.OrdinalIgnoreCase))
					{
						val = current.f7Key;
					}
					else if (string.Equals(text, "F8", StringComparison.OrdinalIgnoreCase))
					{
						val = current.f8Key;
					}
					else if (string.Equals(text, "F9", StringComparison.OrdinalIgnoreCase))
					{
						val = current.f9Key;
					}
					else if (string.Equals(text, "F10", StringComparison.OrdinalIgnoreCase))
					{
						val = current.f10Key;
					}
					else if (string.Equals(text, "F11", StringComparison.OrdinalIgnoreCase))
					{
						val = current.f11Key;
					}
					else if (string.Equals(text, "F12", StringComparison.OrdinalIgnoreCase))
					{
						val = current.f12Key;
					}
					else
					{
						string text2 = text;
						if (text2.Length == 1)
						{
							char c = char.ToLowerInvariant(text2[0]);
							if (c >= 'a' && c <= 'z')
							{
								PropertyInfo property = ((object)current).GetType().GetProperty(c + "Key");
								if (property != null)
								{
									val = (KeyControl)property.GetValue(current);
								}
							}
							else if (c >= '0' && c <= '9')
							{
								PropertyInfo propertyInfo = ((object)current).GetType().GetProperty("numpad" + c + "Key") ?? ((object)current).GetType().GetProperty("digit" + c + "Key");
								if (propertyInfo != null)
								{
									val = (KeyControl)propertyInfo.GetValue(current);
								}
							}
						}
					}
					if (val != null && ((ButtonControl)val).wasPressedThisFrame)
					{
						return true;
					}
				}
			}
			catch
			{
			}
			try
			{
				if ((Object)(object)InputManager.instance != (Object)null && SemiFunc.InputDown(OpenInputKey))
				{
					return true;
				}
			}
			catch
			{
			}
			return false;
		}

		private void Update()
		{
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			if (!IsStaticModEnabled())
			{
				SetWindowOpen(open: false);
				return;
			}
			bool flag = PhotonNetwork.IsConnected && PhotonNetwork.InRoom;
			if (_wasInRoom && !flag)
			{
				try
				{
					Plugin instance = Instance;
					if (instance != null)
					{
						((BaseUnityPlugin)instance).Config.Reload();
					}
					Plugin instance2 = Instance;
					if (instance2 != null)
					{
						ConfigFile runtimeConfig = instance2._runtimeConfig;
						if (runtimeConfig != null)
						{
							runtimeConfig.Reload();
						}
					}
					Log.LogInfo((object)"[VehicleTools] Left room. Restored local config.");
				}
				catch
				{
				}
			}
			_wasInRoom = flag;
			float deltaTime = Time.deltaTime;
			if (_jumpCooldownTimer > 0f)
			{
				_jumpCooldownTimer -= deltaTime;
			}
			if (_tumbleProtectTimer > 0f)
			{
				_tumbleProtectTimer -= deltaTime;
			}
			if (_eventRegistered && !PhotonNetwork.IsConnected)
			{
				_eventRegistered = false;
			}
			if (!_eventRegistered && PhotonNetwork.IsConnected)
			{
				PhotonNetwork.NetworkingClient.EventReceived += OnNetworkEventReceived;
				_eventRegistered = true;
			}
			bool flag2 = IsInGame();
			if (_windowOpen && !flag2)
			{
				SetWindowOpen(open: false);
			}
			if (IsOpenKeyPressed())
			{
				if (flag2)
				{
					SetWindowOpen(!_windowOpen);
				}
				else
				{
					SetWindowOpen(open: false);
				}
			}
			if (_windowOpen)
			{
				KeepCursorFree();
			}
			if (IsStaticModEnabled() && IsInGame())
			{
				bool isLocalPlayerInVehicle = false;
				ItemVehicle[] array = Object.FindObjectsOfType<ItemVehicle>();
				if (array != null)
				{
					ItemVehicle[] array2 = array;
					foreach (ItemVehicle val in array2)
					{
						if ((Object)(object)val != (Object)null && val.seats != null && val.seats.Length != 0 && val.seats[0] != null && (Object)(object)val.seats[0].seatedPlayer == (Object)(object)SemiFunc.PlayerGetLocal())
						{
							isLocalPlayerInVehicle = true;
							break;
						}
					}
				}
				IsLocalPlayerInVehicle = isLocalPlayerInVehicle;
				if (IsLocalPlayerInVehicle && OptimizeCamera && (Object)(object)CameraPosition.instance != (Object)null)
				{
					if (!_origPlayerOffset.HasValue)
					{
						_origPlayerOffset = CameraPosition.instance.playerOffset;
					}
					CameraPosition.instance.playerOffset = _origPlayerOffset.Value + new Vector3(0f, 0.55f, 0f);
				}
				else if (_origPlayerOffset.HasValue && (Object)(object)CameraPosition.instance != (Object)null)
				{
					CameraPosition.instance.playerOffset = _origPlayerOffset.Value;
					_origPlayerOffset = null;
				}
				if (PhotonNetwork.IsConnected && SemiFunc.IsMasterClientOrSingleplayer())
				{
					_syncTimer -= Time.deltaTime;
					if (_syncTimer <= 0f)
					{
						_syncTimer = 1f;
						BroadcastConfigToOthers();
					}
				}
			}
			if (_isPendingSpawn && _spawnDelayTimer > 0f)
			{
				_spawnDelayTimer -= deltaTime;
				if (_spawnDelayTimer <= 0f)
				{
					_isPendingSpawn = false;
					TrySpawnCargoVehicleForLevel();
				}
			}
		}

		private void LateUpdate()
		{
			if (_windowOpen && IsStaticModEnabled() && IsInGame())
			{
				KeepCursorFree();
			}
		}

		private void OnDestroy()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			SetWindowOpen(open: false);
			if (_origPlayerOffset.HasValue && (Object)(object)CameraPosition.instance != (Object)null)
			{
				CameraPosition.instance.playerOffset = _origPlayerOffset.Value;
				_origPlayerOffset = null;
			}
			if (_eventRegistered && PhotonNetwork.IsConnected)
			{
				PhotonNetwork.NetworkingClient.EventReceived -= OnNetworkEventReceived;
			}
			try
			{
				Harmony harmony = _harmony;
				if (harmony != null)
				{
					harmony.UnpatchSelf();
				}
			}
			catch
			{
			}
			_harmony = null;
			UninitializeSceneLoadEvent();
			if (Instance == this)
			{
				Instance = null;
			}
		}

		private static void RunCompatibilityCheck()
		{
			CheckField(typeof(ItemVehicle), "localPlayerIsMounted", "跳跃输入");
			CheckField(typeof(ItemVehicle), "isAnyWheelGrounded", "跳跃输入");
			CheckField(typeof(ItemVehicle), "photonView", "跳跃网络");
			CheckField(typeof(ItemVehicle), "seatSlowdownRate", "座椅物理");
			CheckField(typeof(ItemVehicle), "seatVelocityDrag", "座椅物理");
			CheckMethod(typeof(ItemVehicle), "Update", Type.EmptyTypes, "跳跃按键监听");
			CheckMethod(typeof(ItemVehicle), "FixedUpdateActive", Type.EmptyTypes, "极速物理限速");
			CheckMethod(typeof(ItemVehicle), "TumbleVehicle", new Type[1] { typeof(float) }, "翻车保护拦截");
		}

		private static void CheckField(Type type, string name, string feature)
		{
			if (type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) == null)
			{
				Compat.MarkFailed(feature, "字段 " + type.Name + "." + name + " 缺失");
			}
		}

		private static void CheckMethod(Type type, string name, Type[] args, string feature)
		{
			if (type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, args, null) == null)
			{
				Compat.MarkFailed(feature, "方法 " + type.Name + "." + name + " 缺失");
			}
		}

		private void InstallPatches()
		{
			SafePatch(typeof(Patch_InputInitialize), "键位初始化");
			SafePatch(typeof(Patch_PlayerCtrlStart), "键位配置重绑");
			SafePatch(typeof(Patch_FixedUpdateActive), "极速物理限速");
			SafePatch(typeof(Patch_Update), "跳跃按键监听");
			SafePatch(typeof(Patch_TumbleVehicle), "翻车保护拦截");
			SafePatch(typeof(Patch_ValuableBoxUpdate), "载货车无限库存");
			SafePatch(typeof(Patch_BoxCheckerUpdate), "载货车吸取范围");
			SafePatch(typeof(Patch_ValuableBoxOnObjectsFound), "载货车无视物品大小");
			SafePatch(typeof(Patch_FixedUpdate), "载人物理拉力");
			SafePatch(typeof(Patch_OnDestroy), "载人状态清理");
			SafePatch(typeof(Patch_SetSeatGrabber), "上车前扶正车辆");
		}

		private void SafePatch(Type patchType, string feature)
		{
			try
			{
				_harmony.CreateClassProcessor(patchType).Patch();
			}
			catch (Exception ex)
			{
				Compat.MarkFailed(feature, "安装补丁异常: " + ex.Message);
				((BaseUnityPlugin)this).Logger.LogWarning((object)("补丁 [" + patchType.Name + "] 安装失败: " + ex.Message));
			}
		}

		private void OnNetworkEventReceived(EventData photonEvent)
		{
			if (!IsStaticModEnabled())
			{
				return;
			}
			if (photonEvent.Code == 153)
			{
				if (SemiFunc.IsMasterClientOrSingleplayer() || !(photonEvent.CustomData is object[] array) || array.Length < 10)
				{
					return;
				}
				try
				{
					if (_cfgSpeedLimitEnabled != null)
					{
						_cfgSpeedLimitEnabled.Value = (bool)array[0];
					}
					if (_cfgMaxSpeedLimit != null)
					{
						_cfgMaxSpeedLimit.Value = (float)array[1];
					}
					if (_cfgJumpEnabled != null)
					{
						_cfgJumpEnabled.Value = (bool)array[2];
					}
					if (_cfgContinuousJump != null)
					{
						_cfgContinuousJump.Value = (bool)array[3];
					}
					if (_cfgJumpForce != null)
					{
						_cfgJumpForce.Value = (float)array[4];
					}
					if (_cfgPassengerMountModeSetting != null)
					{
						_cfgPassengerMountModeSetting.Value = (PassengerMountMode)(int)array[5];
					}
					if (_cfgMaxPassengerLimit != null)
					{
						_cfgMaxPassengerLimit.Value = (int)array[6];
					}
					if (_cfgCargoInfiniteInventory != null)
					{
						_cfgCargoInfiniteInventory.Value = (bool)array[7];
					}
					if (_cfgCargoSuckRangeMultiplier != null)
					{
						_cfgCargoSuckRangeMultiplier.Value = (float)array[8];
					}
					if (_cfgTurnNoDecelEnabled != null)
					{
						_cfgTurnNoDecelEnabled.Value = (bool)array[9];
					}
					if (array.Length > 10 && _cfgCargoIgnoreSizeLimit != null)
					{
						_cfgCargoIgnoreSizeLimit.Value = (bool)array[10];
					}
					if (array.Length > 11 && _cfgVehicleNoBatteryDrain != null)
					{
						_cfgVehicleNoBatteryDrain.Value = (bool)array[11];
					}
					if (array.Length > 12 && _cfgAutoSpawnCargoVehicle != null)
					{
						_cfgAutoSpawnCargoVehicle.Value = (bool)array[12];
					}
					if (array.Length > 13 && _cfgJumpCooldown != null)
					{
						_cfgJumpCooldown.Value = (float)array[13];
					}
					if (array.Length > 14 && _cfgTumbleProtectDuration != null)
					{
						_cfgTumbleProtectDuration.Value = (float)array[14];
					}
					if (array.Length > 15 && _cfgPassengerReduceTumble != null)
					{
						_cfgPassengerReduceTumble.Value = (bool)array[15];
					}
					if (array.Length > 16 && _cfgGlobalFeaturesEnabled != null)
					{
						_cfgGlobalFeaturesEnabled.Value = (bool)array[16];
					}
					if (array.Length > 17 && _cfgPassengerMountEnabled != null)
					{
						_cfgPassengerMountEnabled.Value = (bool)array[17];
					}
					if (array.Length > 18 && _cfgCargoFeaturesEnabled != null)
					{
						_cfgCargoFeaturesEnabled.Value = (bool)array[18];
					}
					if (array.Length > 19 && _cfgVehicleProtectEnabled != null)
					{
						_cfgVehicleProtectEnabled.Value = (bool)array[19];
					}
					return;
				}
				catch
				{
					return;
				}
			}
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !Compat.CanForce || photonEvent.Code != 152 || !JumpEnabled || !(photonEvent.CustomData is object[] array2))
			{
				return;
			}
			PhotonView val = PhotonView.Find((int)array2[0]);
			if (!((Object)(object)val == (Object)null))
			{
				ItemVehicle component = ((Component)val).GetComponent<ItemVehicle>();
				if (!((Object)(object)component == (Object)null))
				{
					ApplyJumpForce(component);
				}
			}
		}

		internal static void ApplyJumpForce(ItemVehicle vehicle)
		{
			//IL_0021: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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 (!JumpEnabled)
			{
				return;
			}
			Rigidbody rb = vehicle.rb;
			if (!((Object)(object)rb == (Object)null))
			{
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(0f, rb.velocity.y, 0f);
				rb.AddForce(Vector3.up * JumpForce - val, (ForceMode)2);
				_tumbleProtectTimer = TumbleProtectDuration;
				FieldInfo field = typeof(ItemVehicle).GetField("currentFallGravity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field != null)
				{
					field.SetValue(vehicle, 0f);
				}
				FieldInfo field2 = typeof(ItemVehicle).GetField("accumulatedFallVelocity", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field2 != null)
				{
					field2.SetValue(vehicle, 0f);
				}
				FieldInfo field3 = typeof(ItemVehicle).GetField("currentCustomGravitySpeed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field3 != null)
				{
					field3.SetValue(vehicle, 0f);
				}
				FieldInfo field4 = typeof(ItemVehicle).GetField("fallGravityStartHeight", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				if (field4 != null)
				{
					field4.SetValue(vehicle, ((Component)vehicle).transform.position.y);
				}
			}
		}

		private static void KeepCursorFree()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Cursor.lockState != 0)
			{
				Cursor.lockState = (CursorLockMode)0;
			}
			if (!Cursor.visible)
			{
				Cursor.visible = true;
			}
			try
			{
				if (F_CursorUnlockTimer != null && (Object)(object)CursorManager.instance != (Object)null)
				{
					F_CursorUnlockTimer.SetValue(CursorManager.instance, 99999f);
				}
			}
			catch
			{
			}
		}

		private static void TakeCursor()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			_prevLockMode = Cursor.lockState;
			_prevVisible = Cursor.visible;
			try
			{
				if ((Object)(object)CursorManager.instance != (Object)null)
				{
					CursorManager.instance.Unlock(99999f);
				}
			}
			catch
			{
			}
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
		}

		private static void ReleaseCursor()
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (F_CursorUnlockTimer != null && (Object)(object)CursorManager.instance != (Object)null)
				{
					F_CursorUnlockTimer.SetValue(CursorManager.instance, 0f);
				}
			}
			catch
			{
			}
			try
			{
				if (SemiFunc.IsMainMenu() || SemiFunc.RunIsLobbyMenu())
				{
					Cursor.lockState = (CursorLockMode)0;
					Cursor.visible = true;
					return;
				}
			}
			catch
			{
			}
			Cursor.lockState = _prevLockMode;
			Cursor.visible = _prevVisible;
		}

		private void SetWindowOpen(bool open)
		{
			if (_windowOpen != open)
			{
				_windowOpen = open;
				if (open)
				{
					_windowCentered = false;
					TakeCursor();
					_status = (_useChinese ? "载具工具箱面板已打开。" : "VehicleTools panel opened.");
				}
				else
				{
					ReleaseCursor();
					_status = (_useChinese ? "载具工具箱面板已关闭。" : "VehicleTools panel closed.");
				}
			}
		}

		private void InitStyles()
		{
			//IL_0025: 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_006d: 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_00ab: 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_00f3: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: 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_016f: Expected O, but got Unknown
			//IL_0174: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Expected O, but got Unknown
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Expected O, but got Unknown
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Expected O, but got Unknown
			//IL_02d4: Expected O, but got Unknown
			//IL_02df: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Expected O, but got Unknown
			//IL_031d: Expected O, but got Unknown
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0335: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0369: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Expected O, but got Unknown
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Expected O, but got Unknown
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: 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_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Expected O, but got Unknown
			//IL_0416: Expected O, but got Unknown
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0435: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0460: Expected O, but got Unknown
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Expected O, but got Unknown
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Expected O, but got Unknown
			//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_0527: Expected O, but got Unknown
			if (!_stylesInit)
			{
				_stylesInit = true;
				_texDark = MakeTex(new Color(0.08f, 0.08f, 0.1f, 0.98f));
				_texMid = MakeTex(new Color(0.15f, 0.15f, 0.18f, 0.95f));
				_texLight = MakeTex(new Color(0.2f, 0.2f, 0.25f, 0.95f));
				_texGreen = MakeTex(new Color(0.12f, 0.6f, 0.3f));
				_texRed = MakeTex(new Color(0.75f, 0.22f, 0.22f));
				_texSection = MakeTex(new Color(0.12f, 0.12f, 0.16f, 0.95f));
				_texBorder = MakeTex(new Color(0.25f, 0.25f, 0.3f, 0.8f));
				GUIStyle val = new GUIStyle(GUI.skin.window);
				val.normal.background = _texDark;
				val.normal.textColor = Color.white;
				val.onNormal.background = _texDark;
				val.onNormal.textColor = Color.white;
				val.fontSize = 22;
				val.padding = new RectOffset(16, 16, 36, 16);
				_sWindow = val;
				GUIStyle val2 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 20,
					fontStyle = (FontStyle)1
				};
				val2.normal.textColor = new Color(0.95f, 0.85f, 0.55f);
				_sTitle = val2;
				GUIStyle val3 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 18
				};
				val3.normal.textColor = new Color(0.92f, 0.92f, 0.95f);
				_sLabel = val3;
				GUIStyle val4 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 16
				};
				val4.normal.textColor = new Color(0.72f, 0.92f, 0.72f);
				_sStatus = val4;
				_sBtnGreen = MakeBtn(_texGreen, new Color(0.18f, 0.72f, 0.38f));
				_sBtnRed = MakeBtn(_texRed, new Color(0.88f, 0.28f, 0.28f));
				_sBtnNormal = MakeBtn(_texLight, new Color(0.28f, 0.28f, 0.35f));
				_sBtnClose = new GUIStyle(_sBtnRed)
				{
					fontSize = 22,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4,
					padding = new RectOffset(0, 0, 0, 0)
				};
				GUIStyle val5 = new GUIStyle(GUI.skin.box);
				val5.normal.background = _texSection;
				val5.normal.textColor = Color.white;
				val5.padding = new RectOffset(10, 10, 10, 10);
				_sSection = val5;
				GUIStyle val6 = new GUIStyle(GUI.skin.toggle)
				{
					fontSize = 18
				};
				val6.normal.textColor = new Color(0.92f, 0.92f, 0.95f);
				val6.onNormal.textColor = new Color(0.45f, 0.95f, 0.45f);
				_sToggle = val6;
				GUIStyle val7 = new GUIStyle(_sLabel);
				val7.normal.textColor = new Color(0.45f, 0.95f, 0.45f);
				_sToggleOn = val7;
				GUIStyle val8 = new GUIStyle(GUI.skin.textField)
				{
					fontSize = 18
				};
				val8.normal.background = _texMid;
				val8.normal.textColor = Color.white;
				val8.focused.background = _texLight;
				val8.focused.textColor = Color.white;
				val8.padding = new RectOffset(8, 8, 6, 6);
				_sTextField = val8;
				GUIStyle val9 = new GUIStyle(GUI.skin.label)
				{
					fontSize = 20,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4
				};
				val9.normal.textColor = new Color(0.45f, 0.95f, 0.45f);
				_sCheckmarkStyle = val9;
				GUIStyle val10 = new GUIStyle(_sCheckmarkStyle);
				val10.normal.textColor = Color.white;
				_sCheckmarkStyleWhite = val10;
				GUIStyle val11 = new GUIStyle(GUI.skin.horizontalSlider)
				{
					fixedHeight = 8f
				};
				val11.normal.background = _texSection;
				_sSlider = val11;
				GUIStyle val12 = new GUIStyle(GUI.skin.horizontalSliderThumb)
				{
					fixedWidth = 18f,
					fixedHeight = 18f
				};
				val12.normal.background = _texGreen;
				val12.hover.background = MakeTex(new Color(0.18f, 0.72f, 0.38f));
				val12.active.background = MakeTex(Color.yellow);
				_sThumb = val12;
			}
		}

		private static GUIStyle MakeBtn(Texture2D bg, Color hover)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_0041: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_008b: Expected O, but got Unknown
			Texture2D background = MakeTex(hover);
			GUIStyle val = new GUIStyle(GUI.skin.button)
			{
				fontSize = 18,
				fontStyle = (FontStyle)1
			};
			val.normal.background = bg;
			val.normal.textColor = Color.white;
			val.hover.background = background;
			val.hover.textColor = Color.white;
			val.active.background = background;
			val.active.textColor = Color.yellow;
			val.padding = new RectOffset(12, 12, 6, 6);
			return val;
		}

		private static Texture2D MakeTex(Color c)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_0013: 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_001b: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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)
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			val.SetPixels((Color[])(object)new Color[4] { c, c, c, c });
			val.Apply();
			((Object)val).hideFlags = (HideFlags)61;
			return val;
		}

		private void DrawCloseButton()
		{
			//IL_0035: 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_0050: Expected O, but got Unknown
			string text = (_useChinese ? "关闭" : "Close");
			if (GUI.Button(new Rect(((Rect)(ref _windowRect)).width - 46f, 4f, 42f, 34f), new GUIContent("✕", text), _sBtnClose))
			{
				SetWindowOpen(open: false);
			}
		}

		private bool DrawStyledToggle(Rect rect, bool value, string text)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			float num = 22f;
			float num2 = ((Rect)(ref rect)).y + (((Rect)(ref rect)).height - num) * 0.5f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref rect)).x, num2, num, num);
			Rect val2 = new Rect(((Rect)(ref rect)).x + num + 8f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - num - 8f, ((Rect)(ref rect)).height);
			if (GUI.Button(rect, GUIContent.none, GUIStyle.none))
			{
				value = !value;
			}
			if (value)
			{
				GUI.DrawTexture(val, (Texture)(object)_texGreen);
				GUI.Label(val, "✓", _sCheckmarkStyleWhite);
			}
			else
			{
				GUI.Box(val, "", _sSection);
				DrawBorderRect(val, _texBorder);
			}
			GUI.Label(val2, text, value ? _sToggleOn : _sLabel);
			return value;
		}

		private void DrawBorderRect(Rect rect, Texture2D tex)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)tex == (Object)null))
			{
				GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, 1f), (Texture)(object)tex);
				GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + ((Rect)(ref rect)).height - 1f, ((Rect)(ref rect)).width, 1f), (Texture)(object)tex);
				GUI.DrawTexture(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)tex);
				GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + ((Rect)(ref rect)).width - 1f, ((Rect)(ref rect)).y, 1f, ((Rect)(ref rect)).height), (Texture)(object)tex);
			}
		}

		private void OnGUI()
		{
			//IL_009b: 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_00b8: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			if (!IsStaticModEnabled() || !_windowOpen)
			{
				return;
			}
			if (!IsInGame())
			{
				SetWindowOpen(open: false);
				return;
			}
			GUI.enabled = true;
			InitStyles();
			if (!_windowCentered)
			{
				((Rect)(ref _windowRect)).x = ((float)Screen.width - ((Rect)(ref _windowRect)).width) * 0.5f;
				((Rect)(ref _windowRect)).y = ((float)Screen.height - ((Rect)(ref _windowRect)).height) * 0.5f;
				_windowCentered = true;
			}
			string text = (UseChinese() ? "载具工具箱" : "✦ VehicleTools");
			_windowRect = GUI.Window(33005, _windowRect, new WindowFunction(DrawWindow), text, _sWindow);
		}

		private void DrawWindow(int id)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: 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_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_08dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ea2: Unknown result type (might be due to invalid IL or missing references)
			//IL_1493: Unknown result type (might be due to invalid IL or missing references)
			//IL_14c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_10d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0946: Unknown result type (might be due to invalid IL or missing references)
			//IL_0959: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f1e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f44: Unknown result type (might be due to invalid IL or missing references)
			//IL_1141: Unknown result type (might be due to invalid IL or missing references)
			//IL_1154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0999: Unknown result type (might be due to invalid IL or missing references)
			//IL_1195: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f92: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a08: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_11e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fdf: Unknown result type (might be due to invalid IL or missing references)
			//IL_1223: Unknown result type (might be due to invalid IL or missing references)
			//IL_1020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a60: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_1276: Unknown result type (might be due to invalid IL or missing references)
			//IL_12b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_1079: Unknown result type (might be due to invalid IL or missing references)
			//IL_12f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_134d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1389: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abe: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_13ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_1423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f5: 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_06b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0740: Unknown result type (might be due to invalid IL or missing references)
			//IL_0753: Unknown result type (might be due to invalid IL or missing references)
			//IL_077d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0824: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c7f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d8a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dda: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e32: Unknown result type (might be due to invalid IL or missing references)
			GUI.enabled = true;
			float num = ((Rect)(ref _windowRect)).width - 32f;
			float num2 = 36f;
			DrawCloseButton();
			string text = (_useChinese ? "重置所有" : "Reset All");
			GUI.enabled = SemiFunc.IsMasterClientOrSingleplayer();
			if (GUI.Button(new Rect(16f, num2 - 4f, 100f, 32f), text, _sBtnRed))
			{
				ResetAllSettings();
			}
			GUI.enabled = true;
			string text2 = (_useChinese ? "载具控制中心" : "✦ Vehicle Control Center");
			GUI.Label(new Rect(128f, num2, num - 330f, 30f), text2, _sTitle);
			string text3 = (_useChinese ? "Switch to English" : "切换中文");
			if (GUI.Button(new Rect(((Rect)(ref _windowRect)).width - 220f, num2 - 4f, 170f, 36f), text3, _sBtnNormal))
			{
				_useChinese = !_useChinese;
				_cfgLanguage.Value = ((!_useChinese) ? DisplayLanguage.English : DisplayLanguage.中文);
			}
			num2 += 44f;
			string[] array = ((!_useChinese) ? new string[4] { "⚙\ufe0f Global", "\ud83d\udc65 Passengers", "\ud83d\ude9b Cargo Settings", "\ud83e\udd98 Vehicle Jump" } : new string[4] { "⚙\ufe0f 全局辅助", "\ud83d\udc65 载具载人", "\ud83d\ude9b 载物设置", "\ud83e\udd98 车辆跳跃" });
			float num3 = num / 4f;
			for (int i = 0; i < 4; i++)
			{
				bool flag = _currentTab == i;
				if (GUI.Button(new Rect(16f + (float)i * num3, num2, num3 - 4f, 36f), array[i], flag ? _sBtnGreen : _sBtnNormal))
				{
					_currentTab = i;
				}
			}
			num2 += 44f;
			ItemVehicle[] array2 = Object.FindObjectsOfType<ItemVehicle>();
			List<ItemVehicle> list = new List<ItemVehicle>();
			List<ItemVehicle> list2 = new List<ItemVehicle>();
			if (array2 != null)
			{
				ItemVehicle[] array3 = array2;
				foreach (ItemVehicle val in array3)
				{
					if (!((Object)(object)val == (Object)null))
					{
						if (!val.isRacingVehicle && (Object)(object)val.valuableBox != (Object)null)
						{
							list2.Add(val);
						}
						else
						{
							list.Add(val);
						}
					}
				}
			}
			float num4 = ((Rect)(ref _windowRect)).height - num2 - 16f - 36f;
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(16f, num2, num, num4);
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(0f, 0f, num - 16f, _lastVirtualHeight);
			_scrollPos = GUI.BeginScrollView(val2, _scrollPos, val3);
			float num5 = 0f;
			float num6 = num - 18f;
			float num7 = 0f;
			float num8 = num7 + 12f;
			float num9 = num6 - 24f;
			if (_currentTab == 0)
			{
				GUI.enabled = true;
				float num10 = 254f;
				Rect val4 = default(Rect);
				((Rect)(ref val4))..ctor(num7, num5, num6, num10);
				GUI.Box(val4, GUIContent.none, _sSection);
				DrawBorderRect(val4, _texBorder);
				float num11 = num5 + 12f;
				bool flag2 = DrawStyledToggle(new Rect(num8, num11, 340f, 28f), GlobalFeaturesEnabled, _useChinese ? "启用全局功能" : "Enable All Features");
				if (flag2 != GlobalFeaturesEnabled)
				{
					GlobalFeaturesEnabled = flag2;
				}
				num11 += 32f;
				GUI.enabled = IsStaticModEnabled() && GlobalFeaturesEnabled;
				bool flag3 = DrawStyledToggle(new Rect(num8, num11, 260f, 28f), OptimizeCamera, _useChinese ? "优化开车视角 (稍微调高视野)" : "Optimize Driving Camera");
				if (flag3 != OptimizeCamera)
				{
					OptimizeCamera = flag3;
				}
				num11 += 32f;
				GUI.enabled = IsStaticModEnabled() && GlobalFeaturesEnabled && SemiFunc.IsMasterClientOrSingleplayer();
				bool flag4 = DrawStyledToggle(new Rect(num8, num11, 260f, 28f), VehicleNoBatteryDrain, _useChinese ? "车辆不耗电" : "Vehicle No Battery Drain");
				if (flag4 != VehicleNoBatteryDrain)
				{
					VehicleNoBatteryDrain = flag4;
				}
				num11 += 32f;
				GUI.enabled = IsStaticModEnabled() && GlobalFeaturesEnabled;
				bool flag5 = DrawStyledToggle(new Rect(num8, num11, 420f, 28f), VehicleProtectEnabled, _useChinese ? "启用车辆防摔落/销毁保护" : "Vehicle Fall/Destroy Protection");
				if (flag5 != VehicleProtectEnabled)
				{
					VehicleProtectEnabled = flag5;
				}
				num11 += 32f;
				GUI.enabled = IsStaticModEnabled() && GlobalFeaturesEnabled && SemiFunc.IsMasterClientOrSingleplayer();
				bool flag6 = DrawStyledToggle(new Rect(num8, num11, 360f, 28f), AutoSpawnCargoVehicle, _useChinese ? "每局自动生成载货车 (主机/单机)" : "Auto Spawn Cargo Vehicle (Host)");
				if (flag6 != AutoSpawnCargoVehicle)
				{
					AutoSpawnCargoVehicle = flag6;
				}
				num11 += 32f;
				GUI.enabled = IsStaticModEnabled() && GlobalFeaturesEnabled && SemiFunc.IsMasterClientOrSingleplayer();
				bool flag7 = DrawStyledToggle(new Rect(num8, num11, 340f, 28f), SpeedLimitEnabled, _useChinese ? "启用载具限速" : "Enable Speed Limit");
				if (flag7 != SpeedLimitEnabled)
				{
					SpeedLimitEnabled = flag7;
				}
				num11 += 32f;
				GUI.enabled = IsStaticModEnabled() && GlobalFeaturesEnabled && SpeedLimitEnabled && SemiFunc.IsMasterClientOrSingleplayer();
				GUI.Label(new Rect(num8, num11, 200f, 28f), _useChinese ? "最大移速 (km/h):" : "Max Speed Limit (km/h):", _sLabel);
				float num12 = GUI.HorizontalSlider(new Rect(num8 + 210f, num11 + 4f, num9 - 280f, 24f), MaxSpeedLimit, 10f, 150f, _sSlider, _sThumb);
				if (Math.Abs(num12 - MaxSpeedLimit) > 0.5f)
				{
					MaxSpeedLimit = num12;
				}
				GUI.Label(new Rect(num8 + num9 - 70f, num11, 70f, 28f), $"{(int)MaxSpeedLimit} km/h", _sLabel);
				num11 += 38f;
				GUI.enabled = true;
				num5 += num10;
				num5 += 20f;
				string text4 = (_useChinese ? "\ud83d\udd0d 场景载具快捷控制" : "\ud83d\udd0d Detected Vehicles Control");
				GUI.Label(new Rect(num7, num5, num6, 28f), text4, _sTitle);
				num5 += 32f;
				if (array2 == null || array2.Length == 0)
				{
					float num13 = num5;
					num5 += 16f;
					GUI.Label(new Rect(num8, num5, num9, 28f), _useChinese ? "当前关卡未检测到载具。" : "No vehicle detected in current level.", _sLabel);
					num5 += 28f;
					num5 += 16f;
					Rect val5 = default(Rect);
					((Rect)(ref val5))..ctor(num7, num13, num6, num5 - num13);
					GUI.Box(val5, GUIContent.none, _sSection);
					DrawBorderRect(val5, _texBorder);
				}
				else
				{
					if (list.Count > 0)
					{
						GUI.Label(new Rect(num7, num5, num6, 28f), _useChinese ? "\ud83c\udfce 赛车列表" : "\ud83c\udfce Racing Vehicles", _sLabel);
						num5 += 30f;
						for (int k = 0; k < list.Count; k++)
						{
							ItemVehicle v = list[k];
							num5 = DrawVehicleRow(v, num7, num5, num6, _useChinese ? $"赛车 #{k + 1}" : $"Racing Car #{k + 1}");
						}
					}
					if (list2.Count > 0)
					{
						GUI.Label(new Rect(num7, num5, num6, 28f), _useChinese ? "\ud83d\ude9b 载货车列表" : "\ud83d\ude9b Cargo Trucks", _sLabel);
						num5 += 30f;
						for (int l = 0; l < list2.Count; l++)
						{
							ItemVehicle v2 = list2[l];
							num5 = DrawVehicleRow(v2, num7, num5, num6, _useChinese ? $"载货车 #{l + 1}" : $"Cargo Truck #{l + 1}");
						}
					}
				}
				GUI.enabled = true;
			}
			if (_currentTab == 1)
			{
				GUI.enabled = GlobalFeaturesEnabled;
				bool flag8 = DrawStyledToggle(new Rect(num8, num5, 340f, 28f), PassengerMountEnabled, _useChinese ? "启用乘客挂载功能" : "Enable Passenger Mount Features");
				if (flag8 != PassengerMountEnabled)
				{
					PassengerMountEnabled = flag8;
				}
				num5 += 38f;
				GUI.enabled = GlobalFeaturesEnabled && PassengerMountEnabled;
				float num14 = 170f;
				Rect val6 = default(Rect);
				((Rect)(ref val6))..ctor(num7, num5, num6, num14);
				GUI.Box(val6, GUIContent.none, _sSection);
				DrawBorderRect(val6, _texBorder);
				float num15 = num5 + 12f;
				GUI.enabled = GlobalFeaturesEnabled && PassengerMountEnabled && SemiFunc.IsMasterClientOrSingleplayer();
				GUI.Label(new Rect(num8, num15, 200f, 28f), _useChinese ? "乘客挂载模式:" : "Mount Mode:", _sLabel);
				float num16 = (num9 - 210f - 12f) / 3f;
				bool flag9 = PassengerMountModeSetting == PassengerMountMode.Default;
				bool flag10 = PassengerMountModeSetting == PassengerMountMode.Sides;
				bool flag11 = PassengerMountModeSetting == PassengerMountMode.Head;
				if (GUI.Button(new Rect(num8 + 210f, num15 - 4f, num16, 32f), _useChinese ? "不载人" : "No Passengers", flag9 ? _sBtnGreen : _sBtnNormal))
				{
					PassengerMountModeSetting = PassengerMountMode.Default;
				}
				if (GUI.Button(new Rect(num8 + 210f + num16 + 6f, num15 - 4f, num16, 32f), _useChinese ? "左右悬挂" : "Sides", flag10 ? _sBtnGreen : _sBtnNormal))
				{
					PassengerMountModeSetting = PassengerMountMode.Sides;
				}
				if (GUI.Button(new Rect(num8 + 210f + (num16 + 6f) * 2f, num15 - 4f, num16, 32f), _useChinese ? "头顶旋转" : "Head/Top Rot", flag11 ? _sBtnGreen : _sBtnNormal))
				{
					PassengerMountModeSetting = PassengerMountMode.Head;
				}
				num15 += 38f;
				GUI.Label(new Rect(num8, num15, 200f, 28f), _useChinese ? "乘客挂载模式:" : "Mount Mode:", _sLabel);
				float num17 = (num9 - 210f - 24f) / 5f;
				if (GUI.Button(new Rect(num8 + 210f, num15 - 4f, num17, 32f), _useChinese ? "大光环" : "Halo", (PassengerMountModeSetting == PassengerMountMode.Halo) ? _sBtnGreen : _sBtnNormal))
				{
					PassengerMountModeSetting = PassengerMountMode.Halo;
				}
				if (GUI.Button(new Rect(num8 + 210f + num17 + 6f, num15 - 4f, num17, 32f), _useChinese ? "叠罗汉" : "Totem", (PassengerMountModeSetting == PassengerMountMode.Totem) ? _sBtnGreen : _sBtnNormal))
				{
					PassengerMountModeSetting = PassengerMountMode.Totem;
				}
				if (GUI.Button(new Rect(num8 + 210f + (num17 + 6f) * 2f, num15 - 4f, num17, 32f), _useChinese ? "放风筝" : "Kite", (PassengerMountModeSetting == PassengerMountMode.Kite) ? _sBtnGreen : _sBtnNormal))
				{
					PassengerMountModeSetting = PassengerMountMode.Kite;
				}
				if (GUI.Button(new Rect(num8 + 210f + (num17 + 6f) * 3f, num15 - 4f, num17, 32f), _useChinese ? "V字编队" : "V-Form", (PassengerMountModeSetting == PassengerMountMode.VFormation) ? _sBtnGreen : _sBtnNormal))
				{
					PassengerMountModeSetting = PassengerMountMode.VFormation;
				}
				if (GUI.Button(new Rect(num8 + 210f + (num17 + 6f) * 4f, num15 - 4f, num17, 32f), _useChinese ? "行李架" : "RoofRack", (PassengerMountModeSetting == PassengerMountMode.RoofRack) ? _sBtnGreen : _sBtnNormal))
				{
					PassengerMountModeSetting = PassengerMountMode.RoofRack;
				}
				num15 += 38f;
				GUI.enabled = GlobalFeaturesEnabled && PassengerMountEnabled;
				GUI.Label(new Rect(num8, num15, 200f, 28f), _useChinese ? "最多乘车人数:" : "Max Passengers:", _sLabel);
				int num18 = (int)GUI.HorizontalSlider(new Rect(num8 + 210f, num15 + 4f, num9 - 280f, 24f), (float)MaxPassengerLimit, 1f, 20f, _sSlider, _sThumb);
				if (num18 != MaxPassengerLimit)
				{
					MaxPassengerLimit = num18;
				}
				GUI.Label(new Rect(num8 + num9 - 60f, num15, 60f, 28f), $"{MaxPassengerLimit}", _sLabel);
				num15 += 38f;
				GUI.enabled = GlobalFeaturesEnabled && PassengerMountEnabled && SemiFunc.IsMasterClientOrSingleplayer();
				bool flag12 = DrawStyledToggle(new Rect(num8, num15, 340f, 28f), PassengerReduceTumble, _useChinese ? "有乘客时减少翻车 (翻了立马自动站起)" : "Reduce Tumble With Passengers (Auto-Right-Up)");
				if (flag12 != PassengerReduceTumble)
				{
					PassengerReduceTumble = flag12;
				}
				GUI.enabled = true;
				num5 += num14;
				num5 += 20f;
			}
			if (_currentTab == 2)
			{
				GUI.enabled = GlobalFeaturesEnabled;
				bool flag13 = DrawStyledToggle(new Rect(num8, num5, 340f, 28f), CargoFeaturesEnabled, _useChinese ? "启用载货车增强功能" : "Enable Cargo Truck Features");
				if (flag13 != CargoFeaturesEnabled)
				{
					CargoFeaturesEnabled = flag13;
				}
				num5 += 38f;
				GUI.enabled = GlobalFeaturesEnabled && CargoFeaturesEnabled;
				float num19 = 134f;
				Rect val7 = default(Rect);
				((Rect)(ref val7))..ctor(num7, num5, num6, num19);
				GUI.Box(val7, GUIContent.none, _sSection);
				DrawBorderRect(val7, _texBorder);
				float num20 = num5 + 12f;
				bool flag14 = DrawStyledToggle(new Rect(num8, num20, 340f, 28f), CargoInfiniteInventory, _useChinese ? "库存无限 (不限重量与价值)" : "Infinite Inventory (No Weight/Value Limit)");
				if (flag14 != CargoInfiniteInventory)
				{
					CargoInfiniteInventory = flag14;
				}
				num20 += 36f;
				bool flag15 = DrawStyledToggle(new Rect(num8, num20, 340f, 28f), CargoIgnoreSizeLimit, _useChinese ? "无视物品大小限制" : "Ignore Item Size Limit");
				if (flag15 != CargoIgnoreSizeLimit)
				{
					CargoIgnoreSizeLimit = flag15;
				}
				num20 += 36f;
				GUI.Label(new Rect(num8, num20, 200f, 28f), _useChinese ? "吸取范围倍率:" : "Magnet Range Multiplier:", _sLabel);
				float num21 = GUI.HorizontalSlider(new Rect(num8 + 210f, num20 + 4f, num9 - 280f, 24f), CargoSuckRangeMultiplier, 1f, 5f, _sSlider, _sThumb);
				if (Math.Abs(num21 - CargoSuckRangeMultiplier) > 0.05f)
				{
					CargoSuckRangeMultiplier = num21;
				}
				GUI.Label(new Rect(num8 + num9 - 60f, num20, 60f, 28f), $"{CargoSuckRangeMultiplier:F1}x", _sLabel);
				GUI.enabled = true;
				num5 += num19;
				num5 += 20f;
			}
			if (_currentTab == 3)
			{
				GUI.enabled = GlobalFeaturesEnabled;
				bool flag16 = DrawStyledToggle(new Rect(num8, num5, 340f, 28f), JumpEnabled, _useChinese ? "启用载具跳跃 (Space)" : "Enable Vehicle Jump");
				if (flag16 != JumpEnabled)
				{
					JumpEnabled = flag16;
				}
				num5 += 38f;
				GUI.enabled = GlobalFeaturesEnabled && JumpEnabled;
				float num22 = 174f;
				Rect val8 = default(Rect);
				((Rect)(ref val8))..ctor(num7, num5, num6, num22);
				GUI.Box(val8, GUIContent.none, _sSection);
				DrawBorderRect(val8, _texBorder);
				float num23 = num5 + 12f;
				GUI.enabled = GlobalFeaturesEnabled && JumpEnabled && SemiFunc.IsMasterClientOrSingleplayer();
				bool flag17 = DrawStyledToggle(new Rect(num8, num23, 260f, 28f), ContinuousJump, _useChinese ? "允许连续跳跃 (空中)" : "Continuous Jump (Air)");
				if (flag17 != ContinuousJump)
				{
					ContinuousJump = flag17;
				}
				num23 += 36f;
				GUI.Label(new Rect(num8, num23, 180f, 28f), _useChinese ? "跳跃力:" : "Jump Force:", _sLabel);
				int num24 = (int)GUI.HorizontalSlider(new Rect(num8 + 210f, num23 + 4f, num9 - 280f, 24f), (float)(int)JumpForce, 5f, 80f, _sSlider, _sThumb);
				if (num24 != (int)JumpForce)
				{
					JumpForce = num24;
				}
				GUI.Label(new Rect(num8 + num9 - 60f, num23, 60f, 28f), $"{(int)JumpForce}", _sLabel);
				num23 += 38f;
				GUI.Label(new Rect(num8, num23, 180f, 28f), _useChinese ? "跳跃间隔 (秒):" : "Jump Cooldown (s):", _sLabel);
				float num25 = GUI.HorizontalSlider(new Rect(num8 + 210f, num23 + 4f, num9 - 280f, 24f), JumpCooldown, 0.05f, 2f, _sSlider, _sThumb);
				if (Math.Abs(num25 - JumpCooldown) > 0.02f)
				{
					JumpCooldown = num25;
				}
				GUI.Label(new Rect(num8 + num9 - 60f, num23, 60f, 28f), $"{JumpCooldown:F1}s", _sLabel);
				num23 += 38f;
				GUI.Label(new Rect(num8, num23, 180f, 28f), _useChinese ? "翻车保护 (秒):" : "Tumble Protect (s):", _sLabel);
				float num26 = GUI.HorizontalSlider(new Rect(num8 + 210f, num23 + 4f, num9 - 280f, 24f), TumbleProtectDuration, 0f, 5f, _sSlider, _sThumb);
				if (Math.Abs(num26 - TumbleProtectDuration) > 0.05f)
				{
					TumbleProtectDuration = num26;
				}
				GUI.Label(new Rect(num8 + num9 - 60f, num23, 60f, 28f), $"{TumbleProtectDuration:F1}s", _sLabel);
				GUI.enabled = true;
				num23 += 38f;
				num5 += num22;
				num5 += 20f;
			}
			_lastVirtualHeight = num5;
			GUI.EndScrollView();
			num2 = ((Rect)(ref _windowRect)).height - 32f;
			GUI.Label(new Rect(16f, num2, num, 24f), _status, _sStatus);
			GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref _windowRect)).width - 40f, 32f));
		}

		private float DrawVehicleRow(ItemVehicle v, float x, float y, float w, string name)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)v == (Object)null)
			{
				return y;
			}
			float num = 98f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(x, y, w, num);
			GUI.Box(val, GUIContent.none, _sSection);
			DrawBorderRect(val, _texBorder);
			float num2 = x + 12f;
			float num3 = w - 24f;
			float num4 = y + 12f;
			float num5;
			if (!((Object)(object)v.rb != (Object)null))
			{
				num5 = 0f;
			}
			else
			{
				Vector3 velocity = v.rb.velocity;
				num5 = ((Vector3)(ref velocity)).magnitude * 3.6f;
			}
			float num6 = num5;
			int num7 = 0;
			if (v.seats != null)
			{
				VehicleSeat[] seats = v.seats;
				for (int i = 0; i < seats.Length; i++)
				{
					if ((Object)(object)seats[i].seatedPlayer != (Object)null)
					{
						num7++;
					}
				}
			}
			string text = ((object)(State)(ref v.currentState)).ToString();
			string text2;
			if (!_useChinese)
			{
				object[] obj = new object[5] { name, text, num6, num7, null };
				VehicleSeat[] seats2 = v.seats;
				obj[4] = ((seats2 != null) ? seats2.Length : 0);
				text2 = string.Format("{0} | State: {1} | Speed: {2:F1} km/h | Seats: {3} / {4}", obj);
			}
			else
			{
				object[] obj2 = new object[5] { name, text, num6, num7, null };
				VehicleSeat[] seats3 = v.seats;
				obj2[4] = ((seats3 != null) ? seats3.Length : 0);
				text2 = string.Format("{0} | 状态: {1} | 速度: {2:F1} km/h | 乘员: {3} / {4}", obj2);
			}
			string text3 = text2;
			GUI.Label(new Rect(num2, num4, num3, 28f), text3, _sLabel);
			num4 += 32f;
			float num8 = (num3 - 12f) / 4f;
			bool enabled = GUI.enabled;
			GUI.enabled = enabled && GlobalFeaturesEnabled;
			if (GUI.Button(new Rect(num2, num4, num8, 38f), _useChinese ? "传送到车上" : "Teleport to Seat", _sBtnNormal))
			{
				TeleportPlayerToSeat(v);
			}
			if (GUI.Button(new Rect(num2 + num8 + 4f, num4, num8, 38f), _useChinese ? "车传送到面前" : "Teleport Vehicle", _sBtnNormal))
			{
				TeleportVehicle(v);
			}
			if (GUI.Button(new Rect(num2 + (num8 + 4f) * 2f, num4, num8, 38f), _useChinese ? "氮气推进" : "Turbo Boost", _sBtnNormal))
			{
				BoostVehicle(v);
			}
			if (GUI.Button(new Rect(num2 + (num8 + 4f) * 3f, num4, num8, 38f), _useChinese ? "车辆翻正" : "Flip Upright", _sBtnNormal))
			{
				FlipVehicle(v);
			}
			GUI.enabled = enabled;
			return y + num + 12f;
		}

		private void FlipVehicle(ItemVehicle vehicle)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			if (RuntimeFeaturesEnabled && !((Object)(object)vehicle == (Object)null))
			{
				Vector3 eulerAngles = ((Component)vehicle).transform.eulerAngles;
				((Component)vehicle).transform.eulerAngles = new Vector3(0f, eulerAngles.y, 0f);
				vehicle.currentState = (State)1;
				if ((Object)(object)vehicle.rb != (Object)null)
				{
					vehicle.rb.angularVelocity = Vector3.zero;
					vehicle.rb.velocity = Vector3.zero;
				}
				_status = (_useChinese ? "已一键翻正车辆。" : "Vehicle flipped upright.");
			}
		}

		private void TeleportVehicle(ItemVehicle vehicle)
		{
			//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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00ec: 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_00aa: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			if (!RuntimeFeaturesEnabled)
			{
				return;
			}
			PlayerAvatar val = SemiFunc.PlayerGetLocal();
			if ((Object)(object)val == (Object)null || (Object)(object)vehicle == (Object)null)
			{
				return;
			}
			try
			{
				PhotonView component = ((Component)vehicle).GetComponent<PhotonView>();
				if ((Object)(object)component != (Object)null && component.Owner != PhotonNetwork.LocalPlayer)
				{
					component.RequestOwnership();
				}
			}
			catch
			{
			}
			Vector3 position = ((Component)val).transform.position + ((Component)val).transform.forward * 2.5f + Vector3.up * 0.5f;
			if ((Object)(object)vehicle.rb != (Object)null)
			{
				vehicle.rb.position = position;
				vehicle.rb.rotation = ((Component)val).transform.rotation;
				vehicle.rb.velocity = Vector3.zero;
				vehicle.rb.angularVelocity = Vector3.zero;
			}
			((Component)vehicle).transform.position = position;
			((Component)vehicle).transform.rotation = ((Component)val).transform.rotation;
			RightUpVehicle(vehicle);
			_status = (_useChinese ? "车辆已传送到您面前。" : "Vehicle teleported to front of you.");
		}

		internal static void TeleportVehicleToSpawnPoint(ItemVehicle vehicle)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown