-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathSensPatches.cs
57 lines (52 loc) · 2.02 KB
/
SensPatches.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
using Comfort.Common;
using EFT;
using EFT.InventoryLogic;
using RealismMod;
using SPT.Reflection.Patching;
using System.Reflection;
using UnityEngine;
namespace FOVFix
{
public class AimingSensitivityPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return typeof(Player.FirearmController).GetMethod("get_AimingSensitivity");
}
[PatchPrefix]
public static void PatchPrefix(Player.FirearmController __instance, ref float ____aimingSens)
{
if (Plugin.ChangeMouseSens.Value)
{
float newSens = 1f;
bool isOptic = Plugin.FovController.OpticWatcher.WatchedValue;
bool isAiming = Plugin.FovController.ADSWatcher.WatchedValue;
bool calledToggleZoom = Plugin.FovController.IsToggleZoom;
float toggleZoomMulti =
calledToggleZoom && isAiming && isOptic ? Plugin.ToggleZoomOpticSensMulti.Value :
calledToggleZoom && isAiming ? Plugin.ToggleZoomAimSensMulti.Value :
calledToggleZoom ? Plugin.ToggleZoomUnAimSensMulti.Value : 1f;
float scopeFOVMulti = isOptic && isAiming ? Utils.GetZoomSensValue(Plugin.FovController.CurrentScopeFOV) : Plugin.NonOpticSensMulti.Value;
newSens = Singleton<SharedGameSettingsClass>.Instance.Control.Settings.MouseAimingSensitivity * toggleZoomMulti * scopeFOVMulti;
____aimingSens = newSens;
}
}
}
public class ScopeSensitivityPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return typeof(SightComponent).GetMethod("get_GetCurrentSensitivity");
}
[PatchPrefix]
public static bool PatchPrefix(SightComponent __instance, ref float __result)
{
if (Plugin.ChangeMouseSens.Value)
{
__result = 1f;
return false;
}
return true;
}
}
}