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 BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using SmartFPController; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("RawInputFix")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Fixes laggy mouse input in In Silence")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+7f2a281da3aa146f362236916b09211ddb44953f")] [assembly: AssemblyProduct("RawInputFix")] [assembly: AssemblyTitle("RawInputFix")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [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 RawInputFix { [BepInPlugin("com.mrbub.rawinputfix", "Raw Input Fix", "1.0.0")] public class Plugin : BaseUnityPlugin { internal static ConfigEntry EnableRawInput; internal static ConfigEntry CameraSmoothness; internal static ConfigEntry MouseSensitivityMultiplier; internal static ManualLogSource Log; private void Awake() { //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Expected O, but got Unknown //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; EnableRawInput = ((BaseUnityPlugin)this).Config.Bind("Mouse Input", "EnableRawInput", true, "Enable raw mouse input (removes Unity's input smoothing for instant response)."); CameraSmoothness = ((BaseUnityPlugin)this).Config.Bind("Camera", "CameraSmoothness", 100f, new ConfigDescription("Camera rotation smoothness. 100 = instant (no smoothing), 40 = default game value.", (AcceptableValueBase)(object)new AcceptableValueRange(10f, 100f), Array.Empty())); MouseSensitivityMultiplier = ((BaseUnityPlugin)this).Config.Bind("Mouse Input", "SensitivityMultiplier", 1f, new ConfigDescription("Additional mouse sensitivity multiplier. 1.0 = default.", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 5f), Array.Empty())); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Raw Input Fix v1.0.0 loaded!"); Harmony.CreateAndPatchAll(typeof(FirstPersonControllerPatch), (string)null); Harmony.CreateAndPatchAll(typeof(SmartInputManagerPatch), (string)null); } } public class CameraUpdateHelper : MonoBehaviour { private FirstPersonController controller; private MethodInfo handleCameraLookMethod; public void Initialize(FirstPersonController fpc) { controller = fpc; handleCameraLookMethod = typeof(FirstPersonController).GetMethod("HandleCameraLook", BindingFlags.Instance | BindingFlags.NonPublic); } private void Update() { if ((Object)(object)controller != (Object)null && handleCameraLookMethod != null) { handleCameraLookMethod.Invoke(controller, null); } } } [HarmonyPatch(typeof(FirstPersonController))] public class FirstPersonControllerPatch { [HarmonyPatch("Awake")] [HarmonyPostfix] public static void Awake_Postfix(FirstPersonController __instance) { __instance.defaultLookSmooth = (__instance.lookSmooth = Plugin.CameraSmoothness.Value / 100f); ((Component)__instance).gameObject.AddComponent().Initialize(__instance); } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPrefix] public static void CameraLook_Prefix(FirstPersonController __instance) { float num = Plugin.CameraSmoothness.Value / 100f; if (__instance.lookSmooth != num) { __instance.lookSmooth = num; } } [HarmonyPatch("FixedUpdate")] [HarmonyPrefix] public static bool FixedUpdate_Prefix(FirstPersonController __instance) { MethodInfo? method = typeof(FirstPersonController).GetMethod("HandleUpdateStates", BindingFlags.Instance | BindingFlags.NonPublic); MethodInfo method2 = typeof(FirstPersonController).GetMethod("HandleMoveAngle", BindingFlags.Instance | BindingFlags.NonPublic); method?.Invoke(__instance, null); method2?.Invoke(__instance, null); return false; } } [HarmonyPatch(typeof(SmartInputManager))] public class SmartInputManagerPatch { private static PropertyInfo lookHorizontalProp; private static PropertyInfo lookVerticalProp; static SmartInputManagerPatch() { lookHorizontalProp = typeof(SmartInputManager).GetProperty("lookHorizontal", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); lookVerticalProp = typeof(SmartInputManager).GetProperty("lookVertical", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); } [HarmonyPatch(/*Could not decode attribute arguments.*/)] [HarmonyPostfix] public static void MoveRotateInput_Postfix(SmartInputManager __instance) { if (!(lookHorizontalProp == null) && !(lookVerticalProp == null)) { if (Plugin.EnableRawInput.Value) { float axisRaw = Input.GetAxisRaw("Mouse X"); float axisRaw2 = Input.GetAxisRaw("Mouse Y"); float value = Plugin.MouseSensitivityMultiplier.Value; float num = axisRaw * GameSettings.GetLookSensitivityByInvert_X * value; float num2 = axisRaw2 * GameSettings.GetLookSensitivityByInvert_Y * value; lookHorizontalProp.SetValue(__instance, num); lookVerticalProp.SetValue(__instance, num2); } else if (Plugin.MouseSensitivityMultiplier.Value != 1f) { float num3 = (float)lookHorizontalProp.GetValue(__instance); float num4 = (float)lookVerticalProp.GetValue(__instance); lookHorizontalProp.SetValue(__instance, num3 * Plugin.MouseSensitivityMultiplier.Value); lookVerticalProp.SetValue(__instance, num4 * Plugin.MouseSensitivityMultiplier.Value); } } } } public static class PluginInfo { public const string PLUGIN_GUID = "com.mrbub.rawinputfix"; public const string PLUGIN_NAME = "Raw Input Fix"; public const string PLUGIN_VERSION = "1.0.0"; } }