using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.InputSystem; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = "")] [assembly: AssemblyCompany("EDCOMouseSteering")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+625c8389ba7b01ed26f9ef2637adae303c2018e4")] [assembly: AssemblyProduct("EDCOMouseSteering")] [assembly: AssemblyTitle("EDCOMouseSteering")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace EDCOMouseSteering { [BepInPlugin("EDCOMouseSteering", "EDCOMouseSteering", "1.0.0")] public class EdcoMouseSteering : BaseUnityPlugin { private float _sensitivity = 1f; private InputActionAsset _customAsset; private InputActionMap _customMap; private InputAction _toggleMouseSteering; private InputAction _lookAction; private InputAction _decreaseSensitivity; private InputAction _increaseSensitivity; private bool _isInitialized; public static EdcoMouseSteering Instance { get; private set; } public bool MouseSteeringEnabled { get; private set; } public float MouseSteeringValue { get; private set; } private void Awake() { if (!Object.op_Implicit((Object)(object)Instance)) { Instance = this; } } private void Update() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0052: 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_007d: Unknown result type (might be due to invalid IL or missing references) if (!_isInitialized) { try { InitializeInputAndPatches(); _isInitialized = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"EDCOMouseSteering: Ввод и Harmony-патчи успешно инициализированы!"); } catch (TypeLoadException) { return; } } if (_lookAction != null) { Vector2 val = _lookAction.ReadValue(); if (val != Vector2.zero && MouseSteeringEnabled && !PauseSystem.paused) { MouseSteeringValue = Mathf.Clamp(MouseSteeringValue + val.x / 25f * _sensitivity * Time.deltaTime * 10f, -1f, 1f); } } } private void InitializeInputAndPatches() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown _customAsset = ScriptableObject.CreateInstance(); _customMap = InputActionSetupExtensions.AddActionMap(_customAsset, "ModInputMap"); _toggleMouseSteering = InputActionSetupExtensions.AddAction(_customMap, "ToggleMouseSteering", (InputActionType)0, "/leftButton", (string)null, (string)null, (string)null, (string)null); _lookAction = InputActionSetupExtensions.AddAction(_customMap, "MouseLook", (InputActionType)0, (string)null, (string)null, (string)null, (string)null, (string)null); InputActionSetupExtensions.AddBinding(_lookAction, "/delta", (string)null, (string)null, (string)null); _decreaseSensitivity = InputActionSetupExtensions.AddAction(_customMap, "DecreaseSensitivity", (InputActionType)0, "/minus", (string)null, (string)null, (string)null, (string)null); _increaseSensitivity = InputActionSetupExtensions.AddAction(_customMap, "IncreaseSensitivity", (InputActionType)0, "/equals", (string)null, (string)null, (string)null, (string)null); _toggleMouseSteering.performed += OnToggleMouseSteering; _decreaseSensitivity.performed += OnDecreaseSensitivity; _increaseSensitivity.performed += OnIncreaseSensitivity; _customAsset.Enable(); Harmony val = new Harmony("com.flyen256.mousesteering"); val.PatchAll(); } private void OnDestroy() { if (_toggleMouseSteering != null) { _toggleMouseSteering.performed -= OnToggleMouseSteering; } if (_decreaseSensitivity != null) { _decreaseSensitivity.performed -= OnDecreaseSensitivity; } if (_increaseSensitivity != null) { _increaseSensitivity.performed -= OnIncreaseSensitivity; } if (Object.op_Implicit((Object)(object)_customAsset)) { _customAsset.Disable(); Object.Destroy((Object)(object)_customAsset); } } private void OnToggleMouseSteering(CallbackContext context) { if (!PauseSystem.paused) { MouseSteeringEnabled = !MouseSteeringEnabled; MouseSteeringValue = 0f; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Mouse steering toggled: {MouseSteeringEnabled}"); } } private void OnIncreaseSensitivity(CallbackContext context) { _sensitivity += 0.05f; ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Sensitivity increased: {_sensitivity:F2}"); } private void OnDecreaseSensitivity(CallbackContext context) { _sensitivity = Mathf.Max(0.01f, _sensitivity - 0.05f); ((BaseUnityPlugin)this).Logger.LogInfo((object)$"Sensitivity decreased: {_sensitivity:F2}"); } } public static class PluginInfo { public const string PLUGIN_GUID = "EDCOMouseSteering"; public const string PLUGIN_NAME = "EDCOMouseSteering"; public const string PLUGIN_VERSION = "1.0.0"; } } namespace EDCOMouseSteering.Patches { [HarmonyPatch(typeof(sCameraRotate), "Update")] public class CameraRotate_Update_Prefix { public static bool Prefix(sCameraRotate __instance, ref sCarController ___car, ref Vector3 ___rotation, ref Vector3 ___targetRotation) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0095: 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_00ab: 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_00bb: 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_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)EdcoMouseSteering.Instance) || !EdcoMouseSteering.Instance.MouseSteeringEnabled) { return true; } if (PauseSystem.paused) { Cursor.lockState = (CursorLockMode)0; return true; } Cursor.lockState = (CursorLockMode)1; Vector3 linearVelocity = ___car.rb.linearVelocity; float num = ((Vector3)(ref linearVelocity)).magnitude / 10f; if (___car.GuyActive) { num = 0.5f; } ___targetRotation = Vector3.Lerp(___targetRotation, Vector3.zero, Time.deltaTime * num); ___rotation = Vector3.Lerp(___rotation, ___targetRotation, Time.deltaTime * 4f); __instance.target.localEulerAngles = Vector3.right * ___rotation.y; __instance.pivot.localEulerAngles = Vector3.up * ___rotation.x; return false; } } [HarmonyPatch(typeof(sCarController), "Move")] public class CarController_Move_Prefix { public static void Prefix(sCarController __instance, ref Vector2 ___targetInput) { if (EdcoMouseSteering.Instance.MouseSteeringEnabled) { __instance.input.x = EdcoMouseSteering.Instance.MouseSteeringValue; } } } [HarmonyPatch(typeof(sCarController), "SetInput", new Type[] { typeof(Vector2) })] public static class CarController_SetInput_Postfix { public static void Postfix(sCarController __instance, ref Vector2 input, ref Vector2 ___targetInput) { ___targetInput.x = input.x; } } [HarmonyPatch(typeof(sInputManager), "GetInput")] public static class InputManager_GetInput_Postfix { public static void Postfix(sInputManager __instance) { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) EdcoMouseSteering instance = EdcoMouseSteering.Instance; if (Object.op_Implicit((Object)(object)instance) && instance.MouseSteeringEnabled) { __instance.driveInput = new Vector2(instance.MouseSteeringValue, __instance.driveInput.y); } } } }