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 ReadOnlyEntry; public string DisplayEN; public string[] SliderOptionsEN; public string[] SliderOptionsCN; } internal sealed class LiveLabel { public WeakReference Tmp; public CfgI18N I18N; public bool IsSection; } internal sealed class LiveValue { public WeakReference InputField; public CfgI18N I18N; } [CompilerGenerated] private sealed class d__233 : IEnumerator, IDisposable, IEnumerator { private int <>1__state; private object <>2__current; public float deadlineSeconds; public Action onReady; private float 5__2; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public 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; 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 < 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 _cfgModEnabled; private ConfigEntry _openKey; private static ConfigEntry _cfgLanguage; private static ConfigEntry _moduleNameInfo; private static ConfigEntry _moduleVersionInfo; private ConfigFile _runtimeConfig; private static ConfigEntry _cfgMaxPassengerLimit; private static int _currentTab = 0; private static ConfigEntry _cfgGlobalFeaturesEnabled; private static ConfigEntry _cfgCargoFeaturesEnabled; private static ConfigEntry _cfgSpeedLimitEnabled; private static ConfigEntry _cfgVehicleProtectEnabled; private static ConfigEntry _cfgLastRuntimeVersion; private static ConfigEntry _cfgMaxSpeedLimit; private static ConfigEntry _cfgJumpEnabled; private static ConfigEntry _cfgContinuousJump; private static ConfigEntry _cfgJumpForce; private static ConfigEntry _cfgCargoInfiniteInventory; private static ConfigEntry _cfgCargoIgnoreSizeLimit; private static ConfigEntry _cfgCargoSuckRangeMultiplier; private static ConfigEntry _cfgPassengerMountModeSetting; private static ConfigEntry _cfgVehicleNoBatteryDrain; private static ConfigEntry _cfgOptimizeCamera; private static ConfigEntry _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> _origSeatPositions = new Dictionary>(); private static readonly Dictionary> _origSeatRotations = new Dictionary>(); private static readonly Dictionary _origSeatLocalPositions = new Dictionary(); private static readonly Dictionary _origGrabPointLocalPositions = new Dictionary(); internal static readonly Dictionary _vehicleSpawnPositions = new Dictionary(); internal static readonly Dictionary _vehicleDestroyDisableOriginalValues = new Dictionary(); 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> VehiclePassengers = new Dictionary>(); private static readonly Dictionary> _vehiclePrevGrabbers = new Dictionary>(); 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 PagePopUpScheduledRef = AccessTools.FieldRefAccess("pagePopUpScheduled"); private static readonly FieldRef CurrentMenuPageIndexRef = AccessTools.FieldRefAccess("currentMenuPageIndex"); private static readonly FieldRef CurrentMenuPageRef = AccessTools.FieldRefAccess("currentMenuPage"); internal static readonly Dictionary _cfgByEnSection = new Dictionary(StringComparer.Ordinal); internal static readonly Dictionary _cfgByEnKey = new Dictionary(StringComparer.Ordinal); private static readonly List _cfgI18Ns = new List(20); private static readonly List _liveLabels = new List(64); private static readonly List _liveValues = new List(8); private static readonly Dictionary _labelTmpFieldCache = new Dictionary(8); private static FieldInfo _inputStringSystemField; private static MethodInfo _inputStringSystemSetValue; private static ConfigEntry _cfgAutoSpawnCargoVehicle; private static bool _hasSpawnedThisLevel = false; private static float _spawnDelayTimer = -1f; private static bool _isPendingSpawn = false; private static string _cargoVehicleResourcePath = null; private static ConfigEntry _cfgJumpCooldown; private static ConfigEntry _cfgTumbleProtectDuration; private static ConfigEntry _cfgPassengerMountEnabled; private static ConfigEntry _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 GetGrabAreaListOfGrabbers(GrabArea area) { return F_GrabAreaListOfGrabbers?.GetValue(area) as List; } 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(true); Collider[] componentsInChildren2 = ((Component)vehicle).GetComponentsInChildren(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(); 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(); 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(); List list = new List(); List list2 = new List(); 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(); 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 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_00aa: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)vehicle == (Object)null) { return; } Vector3 position; Quaternion rotation; if (_vehicleSpawnPositions.TryGetValue(vehicle, out (Vector3, Quaternion) value)) { (position, rotation) = value; } else { position = ((Component)vehicle).transform.position; rotation = ((Component)vehicle).transform.rotation; } try { PhotonView component = ((Component)vehicle).GetComponent(); if ((Object)(object)component != (Object)null && component.Owner != PhotonNetwork.LocalPlayer) { component.RequestOwnership(); } } catch { } if ((Object)(object)vehicle.rb != (Object)null) { vehicle.rb.position = position; vehicle.rb.rotation = rotation; vehicle.rb.velocity = Vector3.zero; vehicle.rb.angularVelocity = Vector3.zero; } ((Component)vehicle).transform.position = position; ((Component)vehicle).transform.rotation = rotation; RightUpVehicle(vehicle); vehicle.currentState = (State)1; try { FieldInfo field = typeof(ItemVehicle).GetField("isFullyDestroyed", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(vehicle, false); } } catch { } if (VehiclePassengers.TryGetValue(vehicle, out var value2)) { foreach (CustomPassengerInfo item in value2) { if (item != null && (Object)(object)item.Player != (Object)null) { PlayerTumble playerTumble = GetPlayerTumble(item.Player); if ((Object)(object)playerTumble != (Object)null) { playerTumble.TumbleRequest(false, false); } } } } if ((Object)(object)Instance != (Object)null) { Instance._status = (UseChinese() ? "车辆已触发防爆/防摔落保护,传送回出生点。" : "Vehicle protected and teleported back to spawn point."); } } internal static void ApplyVehicleDestroyProtection(ItemVehicle vehicle) { if ((Object)(object)vehicle == (Object)null) { return; } bool vehicleProtectEnabled = VehicleProtectEnabled; PhysGrabObjectImpactDetector[] componentsInChildren = ((Component)vehicle).GetComponentsInChildren(true); foreach (PhysGrabObjectImpactDetector val in componentsInChildren) { if ((Object)(object)val == (Object)null) { continue; } bool value; if (vehicleProtectEnabled) { if (!_vehicleDestroyDisableOriginalValues.ContainsKey(val)) { _vehicleDestroyDisableOriginalValues[val] = val.destroyDisable; } val.destroyDisable = true; } else if (_vehicleDestroyDisableOriginalValues.TryGetValue(val, out value)) { val.destroyDisable = value; _vehicleDestroyDisableOriginalValues.Remove(val); } } } private void TeleportPlayerToSeat(ItemVehicle vehicle) { //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: 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 || vehicle.seats == null || vehicle.seats.Length == 0) { return; } VehicleSeat val2 = vehicle.seats[0]; if (val2 == null) { return; } Vector3 position = val2.seatTransform.position + Vector3.up * 0.1f; try { PhotonView component = ((Component)vehicle).GetComponent(); if ((Object)(object)component != (Object)null && component.Owner != PhotonNetwork.LocalPlayer) { component.RequestOwnership(); } } catch { } PlayerTumble playerTumble = GetPlayerTumble(val); Rigidbody tumbleRb = GetTumbleRb(playerTumble); if ((Object)(object)playerTumble != (Object)null && (Object)(object)tumbleRb != (Object)null) { tumbleRb.position = position; tumbleRb.rotation = val2.seatTransform.rotation; if ((Object)(object)vehicle.rb != (Object)null) { tumbleRb.velocity = vehicle.rb.velocity; tumbleRb.angularVelocity = vehicle.rb.angularVelocity; } else { tumbleRb.velocity = Vector3.zero; tumbleRb.angularVelocity = Vector3.zero; } } ((Component)val).transform.position = position; ((Component)val).transform.rotation = val2.seatTransform.rotation; val2.reachedFirstMount = true; vehicle.ForceSeatPlayer(0, val); _status = (_useChinese ? "已传送到车上。" : "Teleported to vehicle seat."); } private void BoostVehicle(ItemVehicle vehicle) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (RuntimeFeaturesEnabled && !((Object)(object)vehicle == (Object)null) && !((Object)(object)vehicle.rb == (Object)null)) { vehicle.rb.AddForce(((Component)vehicle).transform.forward * 15f, (ForceMode)2); _status = (_useChinese ? "助推注入成功" : "Turbo boost injected!"); } } private void MigrateKey(string sectionEN, string sectionCN, string[] oldKeys, string newKey, T defaultValue) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Expected O, but got Unknown //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Expected O, but got Unknown //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown ConfigDefinition val = new ConfigDefinition(sectionEN, newKey); if (((BaseUnityPlugin)this).Config.ContainsKey(val)) { return; } foreach (string text in oldKeys) { ConfigDefinition[] array = (ConfigDefinition[])(object)new ConfigDefinition[2] { new ConfigDefinition(sectionEN, text), new ConfigDefinition(sectionCN, text) }; foreach (ConfigDefinition val2 in array) { if (((BaseUnityPlugin)this).Config.ContainsKey(val2)) { try { T value = ((BaseUnityPlugin)this).Config.Bind(val2.Section, val2.Key, defaultValue, (ConfigDescription)null).Value; ((BaseUnityPlugin)this).Config.Bind(sectionEN, newKey, value, (ConfigDescription)null).Value = value; ((BaseUnityPlugin)this).Config.Remove(val2); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"[VehicleTools] Config Migrated: {val2.Section}.{val2.Key} -> {sectionEN}.{newKey} (Value: {value})"); return; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("[VehicleTools] Failed to migrate config key " + val2.Key + ": " + ex.Message)); } } } } } private void BindConfig() { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Expected O, but got Unknown //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Expected O, but got Unknown DisplayLanguage displayLanguage = DetectDefaultLanguage(); MigrateKey("B.Global Settings", "B.全局设置", new string[2] { "Vehicle Tools Mod Enable", "模组启用" }, "Mod Enable", defaultValue: true); MigrateKey("B.Global Settings", "B.全局设置", new string[2] { "Vehicle Tools Toolbox Key", "工具箱按键" }, "Toolbox Key", "F1"); MigrateKey("A.Mod Info", "A.模组信息", new string[1] { "Language" }, "Vehicle Tools Language", DisplayLanguage.English); ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { Order = 1100 }; CfgI18N cfgI18N = NewI18N("A.Mod Info", "A.模组信息", "Vehicle Tools Language", "语言", "Switch display language. Live updates UI.", "切换显示语言。实时刷新面板。", configurationManagerAttributes); cfgI18N.DisplayEN = "Language"; ApplyI18N(cfgI18N); _cfgLanguage = ((BaseUnityPlugin)this).Config.Bind("A.Mod Info", "Vehicle Tools Language", displayLanguage, new ConfigDescription(cfgI18N.DescEN, (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); _moduleNameInfo = BindReadOnlyI18N("A.Mod Info", "A.模组信息", "Vehicle Tools Mod Name", "模组名称", "Vehicle Tools", "载具工具箱", 1000, "Mod Name"); _moduleVersionInfo = BindReadOnlyI18N("A.Mod Info", "A.模组信息", "Vehicle Tools Mod Version", "模组版本号", "1.0.2", "1.0.2", 990, "Mod Version"); _cfgModEnabled = BindI18N("B.Global Settings", "B.全局设置", "Mod Enable", "模组启用", "Disable to turn off the whole mod.", "关闭整个模组,使其彻底失效。", defaultValue: true, null, 975); _openKey = BindI18N("B.Global Settings", "B.全局设置", "Toolbox Key", "工具箱按键", "Shortcut key to open the vehicle tools panel.", "打开/关闭车辆工具箱面板的快捷键。", "F1", (AcceptableValueBase)(object)new AcceptableValueList(AvailableKeybinds), 970); _useChinese = UseChinese(); string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Config.ConfigFilePath), "zichen.vehicletoolsruntime.cfg"); _runtimeConfig = new ConfigFile(text, false); _cfgMaxPassengerLimit = _runtimeConfig.Bind("Runtime", "MaxPassengerLimit", 10, "Max Passenger Limit"); _cfgSpeedLimitEnabled = _runtimeConfig.Bind("Runtime", "SpeedLimitEnabled", true, "Speed Limit Enabled"); _cfgMaxSpeedLimit = _runtimeConfig.Bind("Runtime", "MaxSpeedLimit", 55f, "Max Speed Limit (km/h)"); if (_cfgMaxSpeedLimit.Value < 18f) { _cfgMaxSpeedLimit.Value *= 3.6f; _runtimeConfig.Save(); } _cfgJumpEnabled = _runtimeConfig.Bind("Runtime", "JumpEnabled", false, "Jump Enabled"); _cfgContinuousJump = _runtimeConfig.Bind("Runtime", "ContinuousJump", false, "Continuous Jump"); _cfgJumpForce = _runtimeConfig.Bind("Runtime", "JumpForce", 40f, "Jump Force"); _cfgCargoInfiniteInventory = _runtimeConfig.Bind("Runtime", "CargoInfiniteInventory", true, "Cargo Infinite Inventory"); _cfgCargoIgnoreSizeLimit = _runtimeConfig.Bind("Runtime", "CargoIgnoreSizeLimit", true, "Cargo Ignore Size Limit"); _cfgCargoSuckRangeMultiplier = _runtimeConfig.Bind("Runtime", "CargoSuckRangeMultiplier", 3f, "Cargo Suck Range Multiplier"); _cfgAutoSpawnCargoVehicle = _runtimeConfig.Bind("Runtime", "AutoSpawnCargoVehicle", true, "Auto Spawn Cargo Vehicle Every Round"); _cfgPassengerMountModeSetting = _runtimeConfig.Bind("Runtime", "PassengerMountMode", PassengerMountMode.Head, "Passenger Mount Mode"); _cfgOptimizeCamera = _runtimeConfig.Bind("Runtime", "OptimizeCamera", true, "Optimize Camera"); _cfgTurnNoDecelEnabled = _runtimeConfig.Bind("Runtime", "TurnNoDecelEnabled", true, "Turn No Decel Enabled"); _cfgVehicleNoBatteryDrain = _runtimeConfig.Bind("Runtime", "VehicleNoBatteryDrain", true, "Vehicle No Battery Drain"); _cfgJumpCooldown = _runtimeConfig.Bind("Runtime", "JumpCooldown", 0.1f, "Jump Cooldown (seconds)"); _cfgTumbleProtectDuration = _runtimeConfig.Bind("Runtime", "TumbleProtectDuration", 0.1f, "Tumble Protect Duration (seconds)"); _cfgPassengerReduceTumble = _runtimeConfig.Bind("Runtime", "PassengerReduceTumble", true, "Passenger Auto Right Up When Tumbled"); _cfgGlobalFeaturesEnabled = _runtimeConfig.Bind("Runtime", "GlobalFeaturesEnabled", true, "Global Features Enabled"); _cfgPassengerMountEnabled = _runtimeConfig.Bind("Runtime", "PassengerMountEnabled", true, "Passenger Mount Enabled"); _cfgCargoFeaturesEnabled = _runtimeConfig.Bind("Runtime", "CargoFeaturesEnabled", true, "Cargo Features Enabled"); _cfgVehicleProtectEnabled = _runtimeConfig.Bind("Runtime", "VehicleProtectEnabled", true, "Vehicle Protect Enabled"); _cfgLastRuntimeVersion = _runtimeConfig.Bind("Runtime", "LastConfigVersion", "1.0.1", "Last Config Version"); UpgradeRuntimeDefaults(); } private void UpgradeRuntimeDefaults() { bool flag = false; if (_cfgMaxPassengerLimit != null && _cfgMaxPassengerLimit.Value == 6) { _cfgMaxPassengerLimit.Value = 10; flag = true; } if (_cfgJumpForce != null && Math.Abs(_cfgJumpForce.Value - 25f) < 0.001f) { _cfgJumpForce.Value = 40f; flag = true; } if (_cfgLastRuntimeVersion != null && _cfgLastRuntimeVersion.Value != "1.0.2") { ((BaseUnityPlugin)this).Logger.LogInfo((object)("[VehicleTools] Version changed (" + _cfgLastRuntimeVersion.Value + " -> 1.0.2), resetting all settings...")); ResetAllSettings(); _cfgLastRuntimeVersion.Value = "1.0.2"; flag = true; } if (flag) { ConfigFile runtimeConfig = _runtimeConfig; if (runtimeConfig != null) { runtimeConfig.Save(); } } } private static DisplayLanguage DetectDefaultLanguage() { try { foreach (KeyValuePair pluginInfo in Chainloader.PluginInfos) { string text = pluginInfo.Key ?? string.Empty; PluginInfo value = pluginInfo.Value; object obj; if (value == null) { obj = null; } else { BepInPlugin metadata = value.Metadata; obj = ((metadata != null) ? metadata.Name : null); } if (obj == null) { obj = string.Empty; } string text2 = (string)obj; string[] chineseModKeywords = _chineseModKeywords; foreach (string value2 in chineseModKeywords) { if (text.IndexOf(value2, StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf(value2, StringComparison.OrdinalIgnoreCase) >= 0) { return DisplayLanguage.中文; } } chineseModKeywords = _chineseEnvironmentPluginGuids; foreach (string b in chineseModKeywords) { if (string.Equals(text, b, StringComparison.OrdinalIgnoreCase)) { return DisplayLanguage.中文; } } } } catch { } return DisplayLanguage.English; } private void ResetAllSettings() { MaxPassengerLimit = 10; SpeedLimitEnabled = true; MaxSpeedLimit = 55f; JumpEnabled = false; ContinuousJump = false; JumpForce = 40f; CargoInfiniteInventory = true; CargoIgnoreSizeLimit = true; CargoSuckRangeMultiplier = 3f; PassengerMountModeSetting = PassengerMountMode.Head; OptimizeCamera = true; TurnNoDecelEnabled = true; VehicleNoBatteryDrain = true; JumpCooldown = 0.1f; TumbleProtectDuration = 0.1f; PassengerReduceTumble = true; GlobalFeaturesEnabled = true; PassengerMountEnabled = true; CargoFeaturesEnabled = true; VehicleProtectEnabled = true; _status = (_useChinese ? "已恢复为默认值。" : "All settings reset to default."); } public static void UpdateVehicleSeats(ItemVehicle vehicle) { if (!((Object)(object)vehicle == (Object)null) && vehicle.seats != null && vehicle.seats.Length != 0) { VehicleSeat val = vehicle.seats[0]; if (val != null && (Object)(object)val.seatedPlayer != (Object)null && (Object)(object)val.seatedPlayer == (Object)(object)SemiFunc.PlayerGetLocal()) { IsLocalPlayerInVehicle = true; LastVehicleTime = Time.time; } } } public static void ProcessVehiclePhysicsPassenger(ItemVehicle vehicle) { if (!VehiclePassengers.TryGetValue(vehicle, out var value)) { value = new List(); VehiclePassengers[vehicle] = value; } if (PassengerMountModeSetting == PassengerMountMode.Default) { for (int num = value.Count - 1; num >= 0; num--) { Dismount(vehicle, value[num], "mode changed to Default"); value.RemoveAt(num); } return; } PhysGrabObject component = ((Component)vehicle).GetComponent(); if ((Object)(object)component == (Object)null) { return; } TryMountNewPassenger(vehicle, component, value); for (int num2 = value.Count - 1; num2 >= 0; num2--) { CustomPassengerInfo info = value[num2]; if (!MaintainPassenger(vehicle, component, info)) { value.RemoveAt(num2); } } } private static void TryMountNewPassenger(ItemVehicle vehicle, PhysGrabObject grabObj, List passengers) { //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e7: Invalid comparison between Unknown and I4 //IL_018f: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Unknown result type (might be due to invalid IL or missing references) if (grabObj.playerGrabbing == null) { if (_vehiclePrevGrabbers.ContainsKey(vehicle)) { _vehiclePrevGrabbers[vehicle].Clear(); } return; } if (!_vehiclePrevGrabbers.TryGetValue(vehicle, out var value)) { value = new HashSet(); _vehiclePrevGrabbers[vehicle] = value; } float num = -0.2f; PlayerAvatar val = ((vehicle.seats != null && vehicle.seats.Length != 0) ? vehicle.seats[0].seatedPlayer : null); HashSet hashSet = new HashSet(); List list = new List(); List list2 = new List(); for (int i = 0; i < grabObj.playerGrabbing.Count; i++) { PhysGrabber val2 = grabObj.playerGrabbing[i]; if ((Object)(object)val2 == (Object)null) { continue; } PlayerAvatar playerAvatar = val2.playerAvatar; if ((Object)(object)playerAvatar == (Object)null || (Object)(object)playerAvatar == (Object)(object)val || IsPlayerDisabled(playerAvatar) || (Object)(object)GetPlayerTumble(playerAvatar) == (Object)null) { continue; } bool flag = false; PhysGrabObjectGrabArea vehicleGrabArea = GetVehicleGrabArea(vehicle); if ((Object)(object)vehicleGrabArea != (Object)null && vehicleGrabArea.grabAreas != null) { foreach (GrabArea grabArea in vehicleGrabArea.grabAreas) { if (grabArea != null) { List grabAreaListOfGrabbers = GetGrabAreaListOfGrabbers(grabArea); if (grabAreaListOfGrabbers != null && grabAreaListOfGrabbers.Contains(val2)) { flag = true; break; } } } } if (flag) { continue; } hashSet.Add(playerAvatar); if (!value.Contains(playerAvatar)) { bool flag2 = false; try { flag2 = !((Object)(object)val2.physGrabPoint != (Object)null) || ((Component)vehicle).transform.InverseTransformPoint(val2.physGrabPoint.position).z > num; } catch { flag2 = true; } if (flag2) { list.Add(playerAvatar); } else { list2.Add(playerAvatar); } } } if ((int)vehicle.currentState != 2 && !IsVehicleFullyDestroyed(vehicle)) { foreach (PlayerAvatar item in list2) { if (passengers.Count >= MaxPassengerLimit) { break; } bool flag3 = false; foreach (CustomPassengerInfo passenger in passengers) { if ((Object)(object)passenger.Player == (Object)(object)item) { flag3 = true; break; } } if (!flag3 && !IsPlayerAlreadyMountedAnywhere(item)) { MountPlayer(vehicle, item, passengers); } } } _vehiclePrevGrabbers[vehicle] = hashSet; } private static bool IsPlayerAlreadyMountedAnywhere(PlayerAvatar player) { foreach (List value in VehiclePassengers.Values) { foreach (CustomPassengerInfo item in value) { if ((Object)(object)item.Player == (Object)(object)player) { return true; } } } return false; } private static void MountPlayer(ItemVehicle vehicle, PlayerAvatar player, List passengers) { RightUpVehicle(vehicle); CustomPassengerInfo item = new CustomPassengerInfo { Player = player, MountTime = Time.time, HasReleasedGrabSinceMount = false }; passengers.Add(item); IgnorePassengerVehicleColliders(vehicle, player, ignore: true); PlayerTumble playerTumble = GetPlayerTumble(player); if ((Object)(object)playerTumble != (Object)null) { playerTumble.TumbleRequest(true, false); playerTumble.TumbleOverrideTime(2f); } if ((Object)(object)player.physGrabber != (Object)null) { try { player.physGrabber.OverrideGrabRelease(-1, 0.5f); } catch { } } if (vehicle.seats != null && vehicle.seats.Length != 0 && (Object)(object)vehicle.seats[0].seatedPlayer == (Object)(object)player) { try { PhotonView component = ((Component)vehicle).GetComponent(); if ((Object)(object)component != (Object)null) { component.RPC("ClearSeatRPC", (RpcTarget)0, new object[1] { 0 }); } } catch { } } Log.LogInfo((object)("[VehicleTools] MOUNT: 乘客 " + SemiFunc.PlayerGetName(player) + " 成功挂载上车 (" + ((Object)vehicle).name + ")")); } private static bool MaintainPassenger(ItemVehicle vehicle, PhysGrabObject grabObj, CustomPassengerInfo info) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Invalid comparison between Unknown and I4 //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar player = info.Player; if ((Object)(object)player == (Object)null || IsPlayerDisabled(player) || (Object)(object)GetPlayerTumble(player) == (Object)null) { Dismount(vehicle, info, "passenger disabled"); return false; } if ((int)vehicle.currentState == 2 || IsVehicleFullyDestroyed(vehicle)) { Dismount(vehicle, info, "vehicle tumbled or destroyed"); return false; } if (vehicle.seats != null && vehicle.seats.Length != 0 && (Object)(object)vehicle.seats[0].seatedPlayer == (Object)(object)player) { Dismount(vehicle, info, "player entered driver seat"); return false; } PlayerTumble playerTumble = GetPlayerTumble(player); Rigidbody val = (((Object)(object)playerTumble != (Object)null) ? GetTumbleRb(playerTumble) : null); if ((Object)(object)val != (Object)null) { int index = VehiclePassengers[vehicle].IndexOf(info); Vector3 passengerMountWorldPos = GetPassengerMountWorldPos(vehicle, info, index, VehiclePassengers[vehicle].Count); float num = Vector3.Distance(val.position, passengerMountWorldPos); if (num > 12f) { Dismount(vehicle, info, $"too far {num:F1}m"); return false; } } bool flag = false; if (grabObj.playerGrabbing != null) { for (int i = 0; i < grabObj.playerGrabbing.Count; i++) { PhysGrabber val2 = grabObj.playerGrabbing[i]; if ((Object)(object)val2 != (Object)null && (Object)(object)val2.playerAvatar == (Object)(object)player) { flag = true; break; } } } if (!flag && Time.time - info.MountTime >= 0.3f) { info.HasReleasedGrabSinceMount = true; } if (info.HasReleasedGrabSinceMount && flag && Time.time - info.MountTime >= 0.5f) { if ((Object)(object)player.physGrabber != (Object)null) { try { player.physGrabber.OverrideGrabRelease(-1, 0.5f); } catch { } } Dismount(vehicle, info, "re-grab to dismount"); return false; } return true; } private static void Dismount(ItemVehicle vehicle, CustomPassengerInfo info, string reason) { PlayerAvatar player = info.Player; IgnorePassengerVehicleColliders(vehicle, player, ignore: false); info.Player = null; PlayerTumble playerTumble = GetPlayerTumble(player); if ((Object)(object)player != (Object)null && (Object)(object)playerTumble != (Object)null && IsPlayerTumbling(playerTumble)) { try { playerTumble.TumbleRequest(false, false); } catch { } } Log.LogInfo((object)("[VehicleTools] DISMOUNT: 卸载乘客 " + SemiFunc.PlayerGetName(player) + " (" + reason + ")")); } public static Vector3 GetPassengerMountWorldPos(ItemVehicle vehicle, CustomPassengerInfo info, int index, int total) { //IL_00af: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0143: 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_0146: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a4: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_01bc: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01cb: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_01fe: 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_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_0230: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_0248: Unknown result type (might be due to invalid IL or missing references) //IL_024a: 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_027c: Unknown result type (might be due to invalid IL or missing references) //IL_0281: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028b: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01ed: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) //IL_02d5: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Unknown result type (might be due to invalid IL or missing references) //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: 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_02b4: 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_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02c8: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_0373: 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_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_034f: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_0394: Unknown result type (might be due to invalid IL or missing references) //IL_0396: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_03bd: Unknown result type (might be due to invalid IL or missing references) //IL_03c5: Unknown result type (might be due to invalid IL or missing references) //IL_03cf: Unknown result type (might be due to invalid IL or missing references) //IL_03d4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_03db: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032b: 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_0343: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) if (PassengerMountModeSetting == PassengerMountMode.Sides) { float num = 1.2f; float num2 = ((index % 2 == 0) ? (0f - num) : num); int num3 = index / 2; float num4 = 0.3f - (float)num3 * 0.8f; float num5 = 1f; return ((Component)vehicle).transform.TransformPoint(new Vector3(num2, num5, num4)); } Vector3 val = ((vehicle.seats == null || vehicle.seats.Length == 0 || vehicle.seats[0] == null || !((Object)(object)vehicle.seats[0].seatTransform != (Object)null)) ? (((Component)vehicle).transform.position + ((Component)vehicle).transform.up * 2.3f) : (vehicle.seats[0].seatTransform.position + ((Component)vehicle).transform.up * 1.5f)); if (PassengerMountModeSetting == PassengerMountMode.Head) { float num6 = 0.8f; float num7 = 45f; float num8 = (Time.time * num7 + (float)index * 360f / (float)Mathf.Max(1, total)) * ((float)Math.PI / 180f); Vector3 val2 = (((Component)vehicle).transform.right * Mathf.Cos(num8) + ((Component)vehicle).transform.forward * Mathf.Sin(num8)) * num6; return val + val2; } if (PassengerMountModeSetting == PassengerMountMode.Halo) { float num9 = 2.5f; float num10 = 45f; float num11 = (Time.time * num10 + (float)index * 360f / (float)Mathf.Max(1, total)) * ((float)Math.PI / 180f); Vector3 val3 = (((Component)vehicle).transform.right * Mathf.Cos(num11) + ((Component)vehicle).transform.forward * Mathf.Sin(num11)) * num9; val3 += ((Component)vehicle).transform.up * ((index % 2 == 0) ? 0.3f : (-0.3f)); return val + val3; } if (PassengerMountModeSetting == PassengerMountMode.Totem) { return val + ((Component)vehicle).transform.up * ((float)index * 1.5f); } if (PassengerMountModeSetting == PassengerMountMode.Kite) { Vector3 val4 = -((Component)vehicle).transform.forward * (3f + (float)index * 2f); val4 += ((Component)vehicle).transform.up * (1f + Mathf.Sin(Time.time * 2f + (float)index * 1f) * 1.5f); return val + val4; } if (PassengerMountModeSetting == PassengerMountMode.VFormation) { int num12 = (index + 1) / 2; bool flag = index % 2 != 0; Vector3 val5; if (index == 0) { val5 = -((Component)vehicle).transform.forward * 2f; } else { val5 = -((Component)vehicle).transform.forward * (2f + (float)num12 * 1.5f); val5 += (flag ? (-((Component)vehicle).transform.right) : ((Component)vehicle).transform.right) * ((float)num12 * 1.5f); val5 += ((Component)vehicle).transform.up * ((float)num12 * 0.5f); } return val + val5; } if (PassengerMountModeSetting == PassengerMountMode.RoofRack) { int num13 = index / 2; Vector3 val6 = ((index % 2 == 0) ? (-((Component)vehicle).transform.right) : ((Component)vehicle).transform.right) * 0.7f; val6 += -((Component)vehicle).transform.forward * ((float)num13 * 1f); val6 += ((Component)vehicle).transform.up * -0.3f; return val + val6; } return ((Component)vehicle).transform.position; } public static Quaternion GetPassengerMountWorldRot(ItemVehicle vehicle, CustomPassengerInfo info, int index, int total) { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) if (PassengerMountModeSetting == PassengerMountMode.Head || PassengerMountModeSetting == PassengerMountMode.Halo) { float num = 45f; float num2 = (Time.time * num + (float)index * 360f / (float)Mathf.Max(1, total)) * ((float)Math.PI / 180f); float num3 = 1.5f * Mathf.Cos(num2); float num4 = 1.5f * Mathf.Sin(num2); Vector3 val = ((Component)vehicle).transform.TransformDirection(new Vector3(num3, 0f, num4)); if (val != Vector3.zero) { return Quaternion.LookRotation(val, ((Component)vehicle).transform.up); } } return ((Component)vehicle).transform.rotation; } public static void ApplyVehiclePassengersForces(ItemVehicle vehicle) { if ((Object)(object)vehicle == (Object)null || (Object)(object)vehicle.rb == (Object)null || !VehiclePassengers.TryGetValue(vehicle, out var value)) { return; } for (int i = 0; i < value.Count; i++) { CustomPassengerInfo customPassengerInfo = value[i]; if (customPassengerInfo != null && !((Object)(object)customPassengerInfo.Player == (Object)null) && ShouldApplyPhysics(customPassengerInfo.Player)) { ApplyPassengerPullForce(vehicle, customPassengerInfo, i, value.Count); } } } private static bool ShouldApplyPhysics(PlayerAvatar player) { if ((Object)(object)player == (Object)null) { return false; } if ((Object)(object)player == (Object)(object)SemiFunc.PlayerGetLocal()) { return true; } if (SemiFunc.IsMasterClientOrSingleplayer()) { return true; } return false; } private static void ApplyPassengerPullForce(ItemVehicle vehicle, CustomPassengerInfo info, int index, int total) { //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011c: 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_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0157: 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_015f: Unknown result type (might be due to invalid IL or missing references) PlayerAvatar player = info.Player; PlayerTumble playerTumble = GetPlayerTumble(player); if ((Object)(object)playerTumble == (Object)null) { return; } PhysGrabObject tumblePhysGrabObject = GetTumblePhysGrabObject(playerTumble); Rigidbody tumbleRb = GetTumbleRb(playerTumble); Rigidbody rb = vehicle.rb; if (!((Object)(object)tumblePhysGrabObject == (Object)null) && !((Object)(object)tumbleRb == (Object)null) && !((Object)(object)rb == (Object)null)) { if (!IsPlayerTumbling(playerTumble)) { playerTumble.TumbleRequest(true, false); } playerTumble.TumbleOverrideTime(0.5f); tumblePhysGrabObject.OverrideMaterial(SemiFunc.PhysicMaterialSlippery(), 0.1f); tumblePhysGrabObject.OverrideZeroGravity(0.2f); DisablePhysGrabObjectImpact(tumblePhysGrabObject, 0.2f); playerTumble.OverrideEnemyHurt(0.1f); if ((Object)(object)player.physGrabber != (Object)null && (Object)(object)player == (Object)(object)SemiFunc.PlayerGetLocal()) { player.physGrabber.OverrideDisableSpecialGrabPowers(1f); playerTumble.OverrideTumbleUIDisable(0.2f); } tumblePhysGrabObject.OverrideMass(0.05f, 0.1f); Vector3 passengerMountWorldPos = GetPassengerMountWorldPos(vehicle, info, index, total); Quaternion passengerMountWorldRot = GetPassengerMountWorldRot(vehicle, info, index, total); Vector3 pointVelocity = rb.GetPointVelocity(tumbleRb.position); tumbleRb.velocity = pointVelocity; Vector3 val = passengerMountWorldPos - tumbleRb.position; tumbleRb.velocity += val / Time.fixedDeltaTime * 0.08f; tumbleRb.angularVelocity = rb.angularVelocity; Vector3 val2 = SemiFunc.PhysFollowRotation(((Component)playerTumble).transform, passengerMountWorldRot, tumbleRb, 0.5f); tumbleRb.AddTorque(val2, (ForceMode)2); } } public static void ResetVehiclePassengers(ItemVehicle vehicle) { if ((Object)(object)vehicle == (Object)null) { return; } if (VehiclePassengers.TryGetValue(vehicle, out var value)) { for (int num = value.Count - 1; num >= 0; num--) { Dismount(vehicle, value[num], "vehicle destroyed"); } VehiclePassengers.Remove(vehicle); } if (_vehiclePrevGrabbers.ContainsKey(vehicle)) { _vehiclePrevGrabbers.Remove(vehicle); } } public static void ResetAllPassengers() { foreach (KeyValuePair> vehiclePassenger in VehiclePassengers) { if ((Object)(object)vehiclePassenger.Key != (Object)null && vehiclePassenger.Value != null) { for (int num = vehiclePassenger.Value.Count - 1; num >= 0; num--) { Dismount(vehiclePassenger.Key, vehiclePassenger.Value[num], "global reset"); } } } VehiclePassengers.Clear(); _vehiclePrevGrabbers.Clear(); } private void ResetConfigIfVersionChanged() { try { string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath; if (!File.Exists(configFilePath)) { return; } string text = ReadConfigPluginVersion(configFilePath); if (!(text == "1.0.2")) { ((BaseUnityPlugin)this).Config.Clear(); if (File.Exists(configFilePath)) { File.Delete(configFilePath); } ((BaseUnityPlugin)this).Config.Reload(); ((BaseUnityPlugin)this).Logger.LogWarning((object)("模组版本已改变,重置配置文件:" + text + " -> 1.0.2")); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("无法重置旧配置文件: " + ex.Message)); } } private static string ReadConfigPluginVersion(string configPath) { if (!File.Exists(configPath)) { return null; } string input = File.ReadAllText(configPath); Match match = Regex.Match(input, "(?m)^Vehicle Tools Mod Version\\s*=\\s*(.+?)\\s*$"); if (!match.Success) { match = Regex.Match(input, "(?m)^Mod Version\\s*=\\s*(.+?)\\s*$"); } if (!match.Success) { match = Regex.Match(input, "(?m)^模组版本号\\s*=\\s*(.+?)\\s*$"); } if (!match.Success) { return null; } return match.Groups[1].Value.Trim(); } private void DetachFromManager() { ((Component)this).gameObject.transform.parent = null; ((Object)((Component)this).gameObject).hideFlags = (HideFlags)61; Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject); } internal static string KeybindNameToBindingPath(string name) { if (string.IsNullOrEmpty(name)) { return "/f1"; } if (name.Length == 1 && name[0] >= '0' && name[0] <= '9') { return "/" + name; } if (name.Length == 1 && char.IsLetter(name[0])) { return "/" + name.ToLowerInvariant(); } if (name.Length > 1 && name[0] == 'F' && int.TryParse(name.Substring(1), out var _)) { return "/" + name; } return name switch { "Space" => "/space", "Enter" => "/enter", "Tab" => "/tab", "LeftShift" => "/leftShift", "RightShift" => "/rightShift", "LeftControl" => "/leftCtrl", "RightControl" => "/rightCtrl", _ => "/" + char.ToLower(name[0]) + name.Substring(1), }; } internal static void RebindOpenKey() { //IL_0051: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Instance == (Object)null) && Instance._openKey != null && !((Object)(object)InputManager.instance == (Object)null)) { string value = Instance._openKey.Value; if (!(_lastAppliedOpenKey == value)) { _lastAppliedOpenKey = value; InputManager.instance.Rebind(OpenInputKey, KeybindNameToBindingPath(value)); } } } internal static void InputManagerInitializeInputsPostfix() { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Expected O, but got Unknown //IL_005f: Unknown result type (might be due to invalid IL or missing references) Dictionary value = Traverse.Create((object)InputManager.instance).Field>("inputActions").Value; if (value != null && !value.ContainsKey(OpenInputKey)) { InputAction val = new InputAction("OpenVehicleTools", (InputActionType)0, KeybindNameToBindingPath(Instance?._openKey.Value ?? "F1"), (string)null, (string)null, (string)null); value.Add(OpenInputKey, val); val.Enable(); _lastAppliedOpenKey = Instance?._openKey.Value ?? "F1"; } } internal static void PlayerControllerStartPostfix() { RebindOpenKey(); } internal static void TryShowMenuPopup(MenuManager menuManager, string title, Color color, string body, string warnLabel) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) try { menuManager.PagePopUp(title, color, body, "OK", true); return; } catch { } try { menuManager.PagePopUpScheduled(title, color, body, "OK", true); } catch { Plugin instance = Instance; if (instance != null) { ((BaseUnityPlugin)instance).Logger.LogWarning((object)("无法显示 " + warnLabel + " 弹窗。")); } } } [IteratorStateMachine(typeof(d__233))] internal IEnumerator WaitForMenuReady(float deadlineSeconds, Action onReady) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__233(0) { deadlineSeconds = deadlineSeconds, onReady = onReady }; } private static bool IsPopupSlotBusy(MenuManager menuManager) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Invalid comparison between Unknown and I4 if ((Object)(object)menuManager == (Object)null) { return true; } if ((Object)(object)CurrentMenuPageRef.Invoke(menuManager) == (Object)null) { return true; } if (PagePopUpScheduledRef.Invoke(menuManager)) { return true; } MenuPageIndex val = CurrentMenuPageIndexRef.Invoke(menuManager); if ((int)val != 9) { return (int)val == 7; } return true; } private ConfigEntry BindI18N(string sectEN, string sectCN, string keyEN, string keyCN, string descEN, string descCN, T defaultValue, AcceptableValueBase acceptableValues = null, int order = 0, bool readOnly = false, Action customDrawer = null, string[] sliderOptionsEN = null, string[] sliderOptionsCN = null) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { Order = order, ReadOnly = (readOnly ? new bool?(true) : null), CustomDrawer = customDrawer }; CfgI18N cfgI18N = NewI18N(sectEN, sectCN, keyEN, keyCN, descEN, descCN, configurationManagerAttributes); if (sliderOptionsEN != null) { cfgI18N.SliderOptionsEN = sliderOptionsEN; } if (sliderOptionsCN != null) { cfgI18N.SliderOptionsCN = sliderOptionsCN; } return ((BaseUnityPlugin)this).Config.Bind(sectEN, keyEN, defaultValue, new ConfigDescription(descEN, acceptableValues, new object[1] { configurationManagerAttributes })); } private static CfgI18N NewI18N(string sectEN, string sectCN, string keyEN, string keyCN, string descEN, string descCN, ConfigurationManagerAttributes attrs) { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown CfgI18N cfgI18N = new CfgI18N { SectionEN = sectEN, SectionCN = sectCN, KeyEN = keyEN, KeyCN = keyCN, DescEN = descEN, DescCN = descCN, Attrs = attrs, Definition = new ConfigDefinition(sectEN, keyEN) }; ApplyI18N(cfgI18N); _cfgI18Ns.Add(cfgI18N); _cfgByEnSection[sectEN] = cfgI18N; _cfgByEnKey[keyEN] = cfgI18N; return cfgI18N; } private static void ApplyI18N(CfgI18N i18n) { bool flag = UseChinese(); i18n.Attrs.Category = (flag ? i18n.SectionCN : i18n.SectionEN); i18n.Attrs.DispName = (flag ? i18n.KeyCN : (i18n.DisplayEN ?? i18n.KeyEN)); i18n.Attrs.Description = (flag ? i18n.DescCN : i18n.DescEN); if (i18n.ReadOnlyEntry != null) { string text = (flag ? i18n.ValueCN : i18n.ValueEN); if (i18n.ReadOnlyEntry.Value != text) { i18n.ReadOnlyEntry.Value = text; } } } private ConfigEntry BindReadOnlyI18N(string sectEN, string sectCN, string keyEN, string keyCN, string valueEN, string valueCN, int order = 0, string displayEN = null) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown ConfigurationManagerAttributes configurationManagerAttributes = new ConfigurationManagerAttributes { Order = order, ReadOnly = true, HideDefaultButton = true }; CfgI18N cfgI18N = NewI18N(sectEN, sectCN, keyEN, keyCN, "", "", configurationManagerAttributes); cfgI18N.ValueEN = valueEN; cfgI18N.ValueCN = valueCN; cfgI18N.DisplayEN = displayEN; ApplyI18N(cfgI18N); cfgI18N.ReadOnlyEntry = ((BaseUnityPlugin)this).Config.Bind(sectEN, keyEN, UseChinese() ? valueCN : valueEN, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { configurationManagerAttributes })); string text = (UseChinese() ? valueCN : valueEN); if (cfgI18N.ReadOnlyEntry.Value != text) { cfgI18N.ReadOnlyEntry.Value = text; } return cfgI18N.ReadOnlyEntry; } private static void RefreshAllI18N() { for (int i = 0; i < _cfgI18Ns.Count; i++) { ApplyI18N(_cfgI18Ns[i]); } RefreshLiveLabels(); } internal static void TryHookREPOConfig(Harmony h) { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown try { Type type = AccessTools.TypeByName("MenuLib.MenuAPI"); if (type == null) { Log.LogInfo((object)"MenuLib 未安装,跳过 REPOConfig 双语劫持。"); return; } HarmonyMethod val = new HarmonyMethod(AccessTools.Method(typeof(REPOConfigCreateHook), "Postfix", (Type[])null, (Type[])null)); HashSet hashSet = new HashSet(StringComparer.Ordinal) { "CreateREPOLabel", "CreateREPOToggle", "CreateREPOSlider", "CreateREPOInputField", "CreateREPOButton" }; int num = 0; foreach (MethodInfo declaredMethod in AccessTools.GetDeclaredMethods(type)) { if (!hashSet.Contains(declaredMethod.Name)) { continue; } ParameterInfo[] parameters = declaredMethod.GetParameters(); if (parameters.Length != 0 && !(parameters[0].ParameterType != typeof(string))) { try { h.Patch((MethodBase)declaredMethod, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); num++; } catch { } } } if (num > 0) { Log.LogInfo((object)$"REPOConfig 双语显示已挂载({num} 个 UI 创建方法)。"); } else { Log.LogInfo((object)"REPOConfig 没找到可劫持的 UI 方法。"); } } catch (Exception ex) { Log.LogInfo((object)("REPOConfig 劫持失败:" + ex.Message)); } } internal static void RegisterLiveLabelIfMatched(string label, object uiElement) { if (string.IsNullOrEmpty(label) || uiElement == null) { return; } CfgI18N value; bool flag = _cfgByEnSection.TryGetValue(label, out value); if (!flag && !_cfgByEnKey.TryGetValue(label, out value)) { return; } TextMeshProUGUI labelTmp = GetLabelTmp(uiElement); if ((Object)(object)labelTmp == (Object)null) { return; } bool flag2 = UseChinese(); string text = ((!flag) ? (flag2 ? value.KeyCN : (value.DisplayEN ?? value.KeyEN)) : (flag2 ? value.SectionCN : value.SectionEN)); if (!string.IsNullOrEmpty(text)) { try { ((TMP_Text)labelTmp).text = text; } catch { } } _liveLabels.Add(new LiveLabel { Tmp = new WeakReference(labelTmp), I18N = value, IsSection = flag }); if (!flag && value.ReadOnlyEntry != null) { Object val = (Object)((uiElement is Object) ? uiElement : null); if (val != null && AccessTools.Field(uiElement.GetType(), "inputStringSystem") != null) { _liveValues.Add(new LiveValue { InputField = new WeakReference(val), I18N = value }); TrySetInputFieldValue(val, flag2 ? value.ValueCN : value.ValueEN); } } } private static TextMeshProUGUI GetLabelTmp(object uiElement) { try { Type type = uiElement.GetType(); if (!_labelTmpFieldCache.TryGetValue(type, out var value)) { value = AccessTools.Field(type, "labelTMP"); _labelTmpFieldCache[type] = value; } object? obj = value?.GetValue(uiElement); return (TextMeshProUGUI)((obj is TextMeshProUGUI) ? obj : null); } catch { return null; } } internal static void RefreshLiveLabels() { bool flag = UseChinese(); for (int num = _liveLabels.Count - 1; num >= 0; num--) { LiveLabel liveLabel = _liveLabels[num]; if (!liveLabel.Tmp.TryGetTarget(out var target) || (Object)(object)target == (Object)null || (Object)(object)((Component)target).gameObject == (Object)null) { _liveLabels.RemoveAt(num); } else { string text = ((!liveLabel.IsSection) ? (flag ? liveLabel.I18N.KeyCN : (liveLabel.I18N.DisplayEN ?? liveLabel.I18N.KeyEN)) : (flag ? liveLabel.I18N.SectionCN : liveLabel.I18N.SectionEN)); try { ((TMP_Text)target).text = text; } catch { _liveLabels.RemoveAt(num); } } } for (int num2 = _liveValues.Count - 1; num2 >= 0; num2--) { LiveValue liveValue = _liveValues[num2]; if (!liveValue.InputField.TryGetTarget(out var target2) || target2 == (Object)null) { _liveValues.RemoveAt(num2); } else { string newVal = (flag ? liveValue.I18N.ValueCN : liveValue.I18N.ValueEN); if (!TrySetInputFieldValue(target2, newVal)) { _liveValues.RemoveAt(num2); } } } } private static bool TrySetInputFieldValue(Object ifObj, string newVal) { try { Type type = ((object)ifObj).GetType(); if (_inputStringSystemField == null || _inputStringSystemField.DeclaringType != type) { _inputStringSystemField = AccessTools.Field(type, "inputStringSystem"); } if (_inputStringSystemField == null) { return false; } object value = _inputStringSystemField.GetValue(ifObj); if (value == null) { return false; } if (_inputStringSystemSetValue == null || _inputStringSystemSetValue.DeclaringType != value.GetType()) { _inputStringSystemSetValue = AccessTools.Method(value.GetType(), "SetValue", new Type[2] { typeof(string), typeof(bool) }, (Type[])null); } if (_inputStringSystemSetValue == null) { return false; } _inputStringSystemSetValue.Invoke(value, new object[2] { newVal ?? string.Empty, false }); return true; } catch { return false; } } private void InitializeSceneLoadEvent() { SceneManager.sceneLoaded += OnSceneLoaded; } private void UninitializeSceneLoadEvent() { SceneManager.sceneLoaded -= OnSceneLoaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { _hasSpawnedThisLevel = false; _spawnDelayTimer = 2f; _isPendingSpawn = true; } public static string GetCargoVehicleResourcePath() { if (!string.IsNullOrEmpty(_cargoVehicleResourcePath)) { return _cargoVehicleResourcePath; } try { if ((Object)(object)StatsManager.instance != (Object)null && StatsManager.instance.itemDictionary != null) { foreach (KeyValuePair item in StatsManager.instance.itemDictionary) { Item value = item.Value; if (!((Object)(object)value != (Object)null) || value.prefab == null || !((PrefabRef)(object)value.prefab).IsValid()) { continue; } GameObject prefab = ((PrefabRef)(object)value.prefab).Prefab; if (!((Object)(object)prefab != (Object)null)) { continue; } ItemVehicle component = prefab.GetComponent(); if (!((Object)(object)component != (Object)null) || component.isRacingVehicle || !((Object)(object)component.valuableBox != (Object)null)) { continue; } _cargoVehicleResourcePath = ((PrefabRef)(object)value.prefab).ResourcePath; Plugin instance = Instance; if (instance != null) { ManualLogSource logger = ((BaseUnityPlugin)instance).Logger; if (logger != null) { logger.LogInfo((object)("[VehicleTools] Found cargo vehicle prefab via StatsManager: " + _cargoVehicleResourcePath)); } } return _cargoVehicleResourcePath; } } } catch (Exception ex) { Plugin instance2 = Instance; if (instance2 != null) { ManualLogSource logger2 = ((BaseUnityPlugin)instance2).Logger; if (logger2 != null) { logger2.LogWarning((object)("[VehicleTools] Failed to search itemDictionary: " + ex.Message)); } } } try { if ((Object)(object)ShopManager.instance != (Object)null) { IEnumerable[] array = new IEnumerable[3] { ShopManager.instance.potentialItems, ShopManager.instance.potentialItemConsumables, ShopManager.instance.potentialItemUpgrades }; foreach (IEnumerable enumerable in array) { if (enumerable == null) { continue; } foreach (object item2 in enumerable) { if (item2 == null) { continue; } object? obj = item2.GetType().GetField("item", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(item2); Item val = (Item)((obj is Item) ? obj : null); if ((Object)(object)val == (Object)null) { val = (Item)((item2 is Item) ? item2 : null); } if (!((Object)(object)val != (Object)null) || val.prefab == null || !((PrefabRef)(object)val.prefab).IsValid()) { continue; } GameObject prefab2 = ((PrefabRef)(object)val.prefab).Prefab; if (!((Object)(object)prefab2 != (Object)null)) { continue; } ItemVehicle component2 = prefab2.GetComponent(); if (!((Object)(object)component2 != (Object)null) || component2.isRacingVehicle || !((Object)(object)component2.valuableBox != (Object)null)) { continue; } _cargoVehicleResourcePath = ((PrefabRef)(object)val.prefab).ResourcePath; Plugin instance3 = Instance; if (instance3 != null) { ManualLogSource logger3 = ((BaseUnityPlugin)instance3).Logger; if (logger3 != null) { logger3.LogInfo((object)("[VehicleTools] Found cargo vehicle prefab via ShopManager: " + _cargoVehicleResourcePath)); } } return _cargoVehicleResourcePath; } } } } catch (Exception ex2) { Plugin instance4 = Instance; if (instance4 != null) { ManualLogSource logger4 = ((BaseUnityPlugin)instance4).Logger; if (logger4 != null) { logger4.LogWarning((object)("[VehicleTools] Failed to search ShopManager: " + ex2.Message)); } } } return null; } private static void TrySpawnCargoVehicleForLevel() { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //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) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_0141: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) if (!IsStaticModEnabled() || IsArenaOrRace() || !AutoSpawnCargoVehicle || !SemiFunc.IsMasterClientOrSingleplayer()) { return; } try { if (!SemiFunc.RunIsLevel() || SemiFunc.RunIsLobby() || SemiFunc.RunIsShop()) { return; } } catch { } if (_hasSpawnedThisLevel) { return; } PlayerAvatar val = SemiFunc.PlayerGetLocal(); if ((Object)(object)val == (Object)null) { _spawnDelayTimer = 1f; _isPendingSpawn = true; return; } string cargoVehicleResourcePath = GetCargoVehicleResourcePath(); if (string.IsNullOrEmpty(cargoVehicleResourcePath)) { _spawnDelayTimer = 2f; _isPendingSpawn = true; return; } SpawnPoint val2 = Object.FindObjectOfType(); Vector3 val3; Quaternion rotation; if ((Object)(object)val2 != (Object)null) { val3 = ((Component)val2).transform.position + Vector3.up * 0.5f; rotation = ((Component)val2).transform.rotation; } else { val3 = ((Component)val).transform.position + ((Component)val).transform.forward * 3.5f + ((Component)val).transform.right * 1.5f + Vector3.up * 0.5f; rotation = ((Component)val).transform.rotation; } try { GameObject val4 = null; if (PhotonNetwork.InRoom && PhotonNetwork.IsConnectedAndReady) { val4 = PhotonNetwork.Instantiate(cargoVehicleResourcePath, val3, rotation, (byte)0, (object[])null); } else { GameObject val5 = Resources.Load(cargoVehicleResourcePath); if ((Object)(object)val5 != (Object)null) { val4 = Object.Instantiate(val5, val3, rotation); } } if (!((Object)(object)val4 != (Object)null)) { return; } _hasSpawnedThisLevel = true; Plugin instance = Instance; if (instance != null) { ManualLogSource logger = ((BaseUnityPlugin)instance).Logger; if (logger != null) { logger.LogInfo((object)$"[VehicleTools] Auto-spawned cargo vehicle at {val3}"); } } ItemVehicle component = val4.GetComponent(); if ((Object)(object)component != (Object)null) { RightUpVehicle(component); } } catch (Exception ex) { Plugin instance2 = Instance; if (instance2 != null) { ManualLogSource logger2 = ((BaseUnityPlugin)instance2).Logger; if (logger2 != null) { logger2.LogWarning((object)("[VehicleTools] Error while spawning cargo vehicle: " + ex.Message)); } } } } } public enum DisplayLanguage { 中文, English } public enum PassengerMountMode { Default, Sides, Head, Halo, Totem, Kite, VFormation, RoofRack } internal class CompatibilityState { private readonly HashSet _failed = new HashSet(); private readonly List _logs = new List(); public bool HasIssues => _failed.Count > 0; public HashSet AffectedFeatures => _failed; public List DetailLogs => _logs; public bool CanInput => !_failed.Contains("跳跃按键监听"); public bool CanForce { get { if (!_failed.Contains("极速物理限速")) { return !_failed.Contains("座椅物理"); } return false; } } public bool CanTumbleProtect => !_failed.Contains("翻车保护拦截"); public void MarkFailed(string feature, string detail) { _failed.Add(feature); _logs.Add("[" + feature + "] " + detail); } } internal sealed class ConfigurationManagerAttributes { public int? Order; public bool? ReadOnly; public bool? HideDefaultButton; public string Category; public string DispName; public string Description; public Action CustomDrawer; } [HarmonyPatch(typeof(InputManager), "InitializeInputs")] internal static class Patch_InputInitialize { private static void Postfix() { if (Plugin.IsStaticModEnabled()) { Plugin.InputManagerInitializeInputsPostfix(); } } } [HarmonyPatch(typeof(PlayerController), "Start")] internal static class Patch_PlayerCtrlStart { private static void Postfix() { if (Plugin.IsStaticModEnabled()) { Plugin.PlayerControllerStartPostfix(); } } } [HarmonyPatch(typeof(ItemVehicle), "FixedUpdateActive")] internal static class Patch_FixedUpdateActive { private static readonly Dictionary _origMaxSpeeds = new Dictionary(); private static readonly Dictionary _origSoftMaxSpeeds = new Dictionary(); private static readonly Dictionary _origMaxForwardSpeeds = new Dictionary(); private static readonly Dictionary _origHyperMaxSpeeds = new Dictionary(); private static readonly Dictionary _origDriftMaxSpeeds = new Dictionary(); private static void Prefix(ItemVehicle __instance) { if (!Plugin.IsStaticModEnabled() || Plugin.IsArenaOrRace()) { return; } Plugin.UpdateVehicleSeats(__instance); if (!_origMaxSpeeds.ContainsKey(__instance)) { _origMaxSpeeds[__instance] = __instance.maxSpeedKmh; _origSoftMaxSpeeds[__instance] = __instance.softMaxSpeedKmh; _origMaxForwardSpeeds[__instance] = __instance.maxForwardSpeed; _origHyperMaxSpeeds[__instance] = __instance.hyperMaxSpeed; _origDriftMaxSpeeds[__instance] = __instance.driftMaxSpeed; } if (Plugin.SpeedLimitEnabled) { float num = Plugin.MaxSpeedLimit; if (__instance.isRacingVehicle && num < 100f) { num = 100f; } __instance.maxSpeedKmh = num; __instance.softMaxSpeedKmh = num; if (_origMaxForwardSpeeds.TryGetValue(__instance, out var value)) { __instance.maxForwardSpeed = value; } if (_origHyperMaxSpeeds.TryGetValue(__instance, out var value2)) { __instance.hyperMaxSpeed = value2; } if (_origDriftMaxSpeeds.TryGetValue(__instance, out var value3)) { __instance.driftMaxSpeed = value3; } if ((Object)(object)__instance.rb != (Object)null) { __instance.rb.maxLinearVelocity = 100f; } } else { if (_origMaxSpeeds.TryGetValue(__instance, out var value4)) { __instance.maxSpeedKmh = value4; } if (_origSoftMaxSpeeds.TryGetValue(__instance, out var value5)) { __instance.softMaxSpeedKmh = value5; } if (_origMaxForwardSpeeds.TryGetValue(__instance, out var value6)) { __instance.maxForwardSpeed = value6; } if (_origHyperMaxSpeeds.TryGetValue(__instance, out var value7)) { __instance.hyperMaxSpeed = value7; } if (_origDriftMaxSpeeds.TryGetValue(__instance, out var value8)) { __instance.driftMaxSpeed = value8; } if ((Object)(object)__instance.rb != (Object)null) { __instance.rb.maxLinearVelocity = 100f; } } } private static void Postfix(ItemVehicle __instance) { if (!Plugin.IsStaticModEnabled() || Plugin.IsArenaOrRace() || !Plugin.Compat.CanForce) { return; } if ((Object)(object)Plugin._pendingVehicle == (Object)(object)__instance) { if (Time.frameCount - Plugin._pendingFrame > 10) { Plugin._pendingVehicle = null; return; } Plugin._pendingVehicle = null; Plugin.ApplyJumpForce(__instance); Plugin._jumpCooldownTimer = Plugin.JumpCooldown; } if (!(Plugin._tumbleProtectTimer > 0f)) { return; } try { FieldInfo field = typeof(ItemVehicle).GetField("seatSlowdownRate", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { field.SetValue(__instance, 0f); } FieldInfo field2 = typeof(ItemVehicle).GetField("seatVelocityDrag", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null) { field2.SetValue(__instance, 0f); } } catch { } } } [HarmonyPatch(typeof(ItemVehicle), "Update")] internal static class Patch_Update { private static void Prefix(ItemVehicle __instance) { if (Plugin.IsStaticModEnabled() && !Plugin.IsArenaOrRace()) { Plugin.UpdateVehicleSeats(__instance); } } private static void Postfix(ItemVehicle __instance) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Invalid comparison between Unknown and I4 //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: Unknown result type (might be due to invalid IL or missing references) //IL_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Expected O, but got Unknown if (!Plugin.IsStaticModEnabled() || Plugin.IsArenaOrRace()) { return; } Plugin.ProcessVehiclePhysicsPassenger(__instance); if (Plugin.VehicleNoBatteryDrain && SemiFunc.IsMasterClientOrSingleplayer()) { FieldInfo field = typeof(ItemVehicle).GetField("itemBattery", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field != null) { object? value = field.GetValue(__instance); ItemBattery val = (ItemBattery)((value is ItemBattery) ? value : null); if ((Object)(object)val != (Object)null) { val.batteryLife = 100f; } } } bool flag = false; try { FieldInfo field2 = typeof(ItemVehicle).GetField("localPlayerIsMounted", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field2 != null && (bool)field2.GetValue(__instance)) { flag = true; } } catch { } if (flag) { Plugin.IsLocalPlayerInVehicle = true; Plugin.LastVehicleTime = Time.time; } if (!Plugin.JumpEnabled || !Plugin.Compat.CanInput || !flag || (int)__instance.currentState != 1 || Plugin._jumpCooldownTimer > 0f || !SemiFunc.InputDown((InputKey)1)) { return; } if (!Plugin.ContinuousJump) { try { FieldInfo field3 = typeof(ItemVehicle).GetField("isAnyWheelGrounded", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field3 == null || !(bool)field3.GetValue(__instance)) { return; } } catch { return; } } if (SemiFunc.IsMasterClientOrSingleplayer()) { Plugin._pendingVehicle = __instance; Plugin._pendingFrame = Time.frameCount; } else { if (!PhotonNetwork.IsConnected) { return; } try { FieldInfo field4 = typeof(ItemVehicle).GetField("photonView", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); PhotonView val2 = (PhotonView)((!(field4 != null)) ? ((object)((Component)__instance).GetComponent()) : ((object)(PhotonView)field4.GetValue(__instance))); if ((Object)(object)val2 != (Object)null) { object[] array = new object[1] { val2.ViewID }; PhotonNetwork.RaiseEvent((byte)152, (object)array, new RaiseEventOptions { Receivers = (ReceiverGroup)2 }, SendOptions.SendReliable); } } catch { } Plugin._jumpCooldownTimer = Plugin.JumpCooldown; } } } [HarmonyPatch(typeof(ItemVehicle), "FixedUpdate")] internal static class Patch_FixedUpdate { private static void Postfix(ItemVehicle __instance) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Invalid comparison between Unknown and I4 //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: 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_01bb: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: 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_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_0145: 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_0150: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.IsStaticModEnabled() || Plugin.IsArenaOrRace()) { return; } if (!Plugin._vehicleSpawnPositions.ContainsKey(__instance)) { Plugin._vehicleSpawnPositions[__instance] = (((Component)__instance).transform.position, ((Component)__instance).transform.rotation); } Plugin.ApplyVehicleDestroyProtection(__instance); if (!Plugin.IsArenaOrRace() && Plugin.VehicleProtectEnabled && ((Component)__instance).transform.position.y < -15f && SemiFunc.IsMasterClientOrSingleplayer()) { Plugin.TeleportVehicleToSpawnPoint(__instance); } if (!Plugin.IsArenaOrRace() && Plugin.PassengerReduceTumble && (int)__instance.currentState == 2 && Plugin.VehiclePassengers.TryGetValue(__instance, out var value) && value.Count > 0) { Plugin.RightUpVehicle(__instance); __instance.currentState = (State)1; } if (Plugin.PassengerMountEnabled) { Plugin.ApplyVehiclePassengersForces(__instance); } if (Plugin.TurnNoDecelEnabled && (Object)(object)__instance.rb != (Object)null && !Plugin.GetIsVehicleAirborne(__instance)) { Vector3 velocity = __instance.rb.velocity; float magnitude = ((Vector3)(ref velocity)).magnitude; if (magnitude > 0.1f) { float inputY = Plugin.GetInputY(__instance); if (inputY > 0f) { __instance.rb.velocity = ((Component)__instance).transform.forward * magnitude; } else if (inputY < 0f) { __instance.rb.velocity = -((Component)__instance).transform.forward * magnitude; } } } if (Plugin.SpeedLimitEnabled && (Object)(object)__instance.rb != (Object)null) { Vector3 velocity2 = __instance.rb.velocity; Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor(velocity2.x, velocity2.z); float num = Plugin.MaxSpeedLimit / 3.6f / 2f; if (((Vector2)(ref val)).magnitude > num) { val = ((Vector2)(ref val)).normalized * num; __instance.rb.velocity = new Vector3(val.x, velocity2.y, val.y); } } } } [HarmonyPatch(typeof(ItemVehicle), "OnDestroy")] internal static class Patch_OnDestroy { private static void Prefix(ItemVehicle __instance) { if (!Plugin.IsStaticModEnabled()) { return; } Plugin.ResetVehiclePassengers(__instance); Plugin._vehicleSpawnPositions.Remove(__instance); PhysGrabObjectImpactDetector[] componentsInChildren = ((Component)__instance).GetComponentsInChildren(true); foreach (PhysGrabObjectImpactDetector val in componentsInChildren) { if ((Object)(object)val != (Object)null) { Plugin._vehicleDestroyDisableOriginalValues.Remove(val); } } } } [HarmonyPatch(typeof(ItemVehicle), "SetSeatGrabber")] internal static class Patch_SetSeatGrabber { private static void Prefix(ItemVehicle __instance) { if (Plugin.RuntimeFeaturesEnabled && !Plugin.IsArenaOrRace()) { Plugin.RightUpVehicle(__instance); } } } [HarmonyPatch(typeof(ItemVehicle), "TumbleVehicle", new Type[] { typeof(float) })] internal static class Patch_TumbleVehicle { private static bool Prefix(ItemVehicle __instance) { if (!Plugin.IsStaticModEnabled()) { return true; } if (!Plugin.RuntimeFeaturesEnabled) { return true; } if (Plugin.IsArenaOrRace()) { return true; } if (Plugin.Compat.CanTumbleProtect && Plugin._tumbleProtectTimer > 0f) { return false; } if (Plugin.PassengerReduceTumble && Plugin.VehiclePassengers.TryGetValue(__instance, out var value) && value.Count > 0) { Plugin.RightUpVehicle(__instance); return false; } return true; } } [HarmonyPatch(typeof(ItemValuableBox), "Update")] internal static class Patch_ValuableBoxUpdate { private static readonly Dictionary _originalLimits = new Dictionary(); private static void Prefix(ItemValuableBox __instance) { if (Plugin.IsStaticModEnabled() && !Plugin.IsArenaOrRace()) { if (!_originalLimits.ContainsKey(__instance)) { _originalLimits[__instance] = __instance.valueLimit; } if (Plugin.CargoInfiniteInventory) { __instance.valueLimit = 1E+09f; } else { __instance.valueLimit = _originalLimits[__instance]; } } } } [HarmonyPatch(typeof(PhysGrabObjectComponentInsideBoxChecker), "Update")] internal static class Patch_BoxCheckerUpdate { private static readonly Dictionary _origScales = new Dictionary(); private static void Prefix(PhysGrabObjectComponentInsideBoxChecker __instance) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (Plugin.IsStaticModEnabled() && !Plugin.IsArenaOrRace() && !((Object)(object)((Component)__instance).GetComponentInParent() == (Object)null)) { if (!_origScales.ContainsKey(__instance)) { _origScales[__instance] = ((Component)__instance).transform.localScale; } if (Plugin.CargoSuckRangeMultiplier > 1.01f) { ((Component)__instance).transform.localScale = _origScales[__instance] * Plugin.CargoSuckRangeMultiplier; } else { ((Component)__instance).transform.localScale = _origScales[__instance]; } } } private static void Postfix(PhysGrabObjectComponentInsideBoxChecker __instance) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (Plugin.IsStaticModEnabled() && !Plugin.IsArenaOrRace() && _origScales.TryGetValue(__instance, out var value)) { ((Component)__instance).transform.localScale = value; } } } [HarmonyPatch(typeof(ItemValuableBox), "OnObjectsFound")] internal static class Patch_ValuableBoxOnObjectsFound { private static readonly Dictionary _origVolumes = new Dictionary(); private static void Prefix(List foundObjects) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Invalid comparison between Unknown and I4 //IL_005e: 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) if (!Plugin.IsStaticModEnabled() || Plugin.IsArenaOrRace() || !Plugin.CargoIgnoreSizeLimit) { return; } _origVolumes.Clear(); if (foundObjects == null) { return; } foreach (PhysGrabObject foundObject in foundObjects) { if (!((Object)(object)foundObject == (Object)null)) { ValuableObject component = ((Component)foundObject).GetComponent(); if ((Object)(object)component != (Object)null && (int)component.volumeType > 1) { _origVolumes[component] = component.volumeType; component.volumeType = (Type)1; } } } } private static void Postfix() { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.IsStaticModEnabled()) { return; } foreach (KeyValuePair origVolume in _origVolumes) { if ((Object)(object)origVolume.Key != (Object)null) { origVolume.Key.volumeType = origVolume.Value; } } _origVolumes.Clear(); } } [HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "DestroyObject", new Type[] { typeof(bool) })] internal static class Patch_PhysGrabObjectImpactDetector_DestroyObject { private static bool Prefix(PhysGrabObjectImpactDetector __instance) { if (!Plugin.IsArenaOrRace() && Plugin.IsStaticModEnabled() && Plugin.VehicleProtectEnabled) { ItemVehicle val = ((Component)__instance).GetComponent(); if ((Object)(object)val == (Object)null) { val = ((Component)__instance).GetComponentInParent(); } if ((Object)(object)val != (Object)null) { Plugin.TeleportVehicleToSpawnPoint(val); return false; } } return true; } } internal static class REPOConfigCreateHook { public static void Postfix(object[] __args, object __result) { try { if (__args != null && __args.Length != 0 && __result != null && __args[0] is string label) { Plugin.RegisterLiveLabelIfMatched(label, __result); } } catch { } } } }