diff --git a/TarkovUniformAim/TarkovUniformAim.csproj b/TarkovUniformAim/TarkovUniformAim.csproj
index 0bf7c0a..d133598 100644
--- a/TarkovUniformAim/TarkovUniformAim.csproj
+++ b/TarkovUniformAim/TarkovUniformAim.csproj
@@ -56,8 +56,9 @@
+
-
+
diff --git a/TarkovUniformAim/UniformAim.cs b/TarkovUniformAim/UniformAim.cs
new file mode 100644
index 0000000..9be8a4d
--- /dev/null
+++ b/TarkovUniformAim/UniformAim.cs
@@ -0,0 +1,101 @@
+using System;
+using UnityEngine;
+using UniformAimPatch;
+using BepInEx;
+using UniformAimPlugin;
+
+
+namespace UniformAimLogic
+{
+ [BepInPlugin("com.greg.tarkovuniformaim", "Uniform Aim for Tarkov", "0.1.1")]
+ [BepInProcess("EscapeFromTarkov.exe")]
+ public class Logic : MonoBehaviour
+ {
+ void Awake()
+ {
+ new UpdateSensitivityPatch().Enable();
+ }
+
+ //Return aspect ratio based on game window resolution
+ float GetAspectRatio()
+ {
+ string screenWidth = Screen.width.ToString();
+ string screenHeight = Screen.height.ToString();
+ float resX = Convert.ToUInt16(screenWidth);
+ float resY = Convert.ToUInt16(screenHeight);
+
+ //Logger.LogInfo("GetAspectRatio(): resX: " + resX + " resY: " + resY);
+ return (resX / resY);
+ }
+ //convert degrees to radians
+ //calculate horizontal FOV based on vertical FOV
+ float CalculateHFOV(float FOV)
+ {
+ float vFOVRad = FOV * Mathf.Deg2Rad;
+ float hFOVRad = (float)(2 * Math.Atan(Math.Tan(FOV / 2) * Mathf.Deg2Rad) * GetAspectRatio());
+
+ return (float)(Math.Round(hFOVRad * Mathf.Rad2Deg));
+ }
+ //calculate sensitivity based on FOV difference and coefficient
+ float CalculateSensitivity(float aimedFOV, float hipFOV)
+ { //clamp to avoid invalid values
+ aimedFOV = Mathf.Clamp(aimedFOV, 0.1f, 90f);
+ hipFOV = Mathf.Clamp(hipFOV, 0.1f, 90f);
+
+ //halve and convert to radians
+ aimedFOV = aimedFOV / 2 * Mathf.Deg2Rad;
+ hipFOV = hipFOV /2 * Mathf.Deg2Rad;
+
+ //ratio of tangents as sensitivity
+ float sensitivity = (float)(Math.Tan(aimedFOV) / Math.Tan(hipFOV));
+
+ return sensitivity;
+ }
+
+
+ public static float adjustedSensitivity = (float)(Config.configSens.Value) / 100;
+
+ float lastFOV = -1f;
+ float lastFOV2 = -1f;
+
+ float FPSCameraFOV = -1f;
+ float ScopeFOV = -1f;
+ float currentFOV = -1f;
+
+ float configFOV = (float)Config.configFOV.Value;
+ float configSens = (float)Config.configSens.Value;
+
+ void Update()
+ {
+ if (Camera.allCamerasCount >= 1)
+ {
+ FPSCameraFOV = Camera.allCameras[0].fieldOfView;
+ }
+ if (Camera.allCamerasCount >= 2)
+ {
+ ScopeFOV = Camera.allCameras[1].fieldOfView;
+ }
+ if (Camera.allCamerasCount >= 1 && FPSCameraFOV != lastFOV)
+ {
+ //Logger.LogInfo("[0] FOV: " + FPSCameraFOV);
+ lastFOV = FPSCameraFOV;
+ }
+ if (Camera.allCamerasCount >= 2 && ScopeFOV != lastFOV2)
+ {
+ //Logger.LogInfo("[1] FOV: " + ScopeFOV);
+ lastFOV2 = ScopeFOV;
+ }
+
+ //nasty workaround for sensitivity while using PIP scopes, WILL break when FOV is set to 50
+ if (35 < FPSCameraFOV && FPSCameraFOV < Config.configFOV.Value) { currentFOV = FPSCameraFOV; }
+ if (Camera.allCamerasCount >= 2)
+ {
+ if (FPSCameraFOV == 35) { currentFOV = ScopeFOV; }
+ if (FPSCameraFOV == Config.configFOV.Value - 15) { currentFOV = FPSCameraFOV; }
+ }
+
+ adjustedSensitivity = configSens * CalculateSensitivity(currentFOV, configFOV);
+
+ }
+ }
+}
diff --git a/TarkovUniformAim/UniformAimPatch.cs b/TarkovUniformAim/UniformAimPatch.cs
index 01dfb82..b6c4709 100644
--- a/TarkovUniformAim/UniformAimPatch.cs
+++ b/TarkovUniformAim/UniformAimPatch.cs
@@ -1,9 +1,10 @@
using System.Reflection;
using Aki.Reflection.Patching;
using EFT;
-using UniformAim;
+using UniformAimLogic;
+using UniformAimPlugin;
-namespace TarkovUniformAim
+namespace UniformAimPatch
{
public class UpdateSensitivityPatch : ModulePatch
{
@@ -15,7 +16,7 @@ namespace TarkovUniformAim
[PatchPostfix]
public static void PatchPostfix(ref float ____aimingSens)
{
- ____aimingSens = UniformAimUtils.adjustedSensitivity;
+ ____aimingSens = Logic.adjustedSensitivity;
}
}
}
diff --git a/TarkovUniformAim/UniformAimPlugin.cs b/TarkovUniformAim/UniformAimPlugin.cs
new file mode 100644
index 0000000..d55e5f9
--- /dev/null
+++ b/TarkovUniformAim/UniformAimPlugin.cs
@@ -0,0 +1,34 @@
+using BepInEx;
+using BepInEx.Configuration;
+using UniformAimPatch;
+using UniformAimLogic;
+
+
+namespace UniformAimPlugin
+{
+ [BepInPlugin("com.greg.tarkovuniformaim", "Uniform Aim for Tarkov", "0.1.1")]
+ [BepInProcess("EscapeFromTarkov.exe")]
+ public class Config : BaseUnityPlugin
+ {
+ //Bepinex.Configurator fields
+ public static ConfigEntry configFOV;
+ public static ConfigEntry configCoeff;
+ public static ConfigEntry configSens;
+
+ void Awake()
+ {
+ //Enable uniform aim patch
+ new UpdateSensitivityPatch().Enable();
+
+ //add configuration slider for field of view
+ configFOV = Config.Bind("General", "FOV", 75, new ConfigDescription("In-game Field of View value", new AcceptableValueRange(50, 75)));
+
+ //add coefficient slider
+ configCoeff = Config.Bind("General", "Coefficient", 1.33f, new ConfigDescription("Coefficient - increases sensitivity at higher zoom levels, default 4/3", new AcceptableValueRange(0.001f, 5.0f)));
+
+ //add secondary sensitivity slider for greater control
+ configSens = Config.Bind("General", "Sensitivity", 25, new ConfigDescription("Secondary sensitivity multiplier in case Tarkov's default isn't enough", new AcceptableValueRange(1, 200)));
+
+ }
+ }
+}
diff --git a/TarkovUniformAim/UniformAimUtils.cs b/TarkovUniformAim/UniformAimUtils.cs
deleted file mode 100644
index b5d5dc3..0000000
--- a/TarkovUniformAim/UniformAimUtils.cs
+++ /dev/null
@@ -1,129 +0,0 @@
-using BepInEx;
-using BepInEx.Configuration;
-using System;
-using UnityEngine;
-using TarkovUniformAim;
-
-namespace UniformAim
-{
-
- [BepInPlugin("com.greg.tarkovuniformaim", "Uniform Aim for Tarkov", "0.1.1")]
- [BepInProcess("EscapeFromTarkov.exe")]
-
- public class UniformAimConfig : BaseUnityPlugin
- {
- //Bepinex.Configurator fields
- public static ConfigEntry configFOV;
- public static ConfigEntry configCoeff;
- public static ConfigEntry configSens;
-
- void Awake()
- {
-
- //Enable uniform aim patch
- new UpdateSensitivityPatch().Enable();
-
- //add configuration slider for field of view
- configFOV = Config.Bind("General", "FOV", 75, new ConfigDescription("In-game Field of View value", new AcceptableValueRange(50, 75)));
-
- //add coefficient slider
- configCoeff = Config.Bind("General", "Coefficient", 1.33f, new ConfigDescription("Coefficient - increases sensitivity at higher zoom levels, default 4/3", new AcceptableValueRange(0.001f, 5.0f)));
-
- //add secondary sensitivity slider for greater control
- configSens = Config.Bind("General", "Sensitivity", 25, new ConfigDescription("Secondary sensitivity multiplier in case Tarkov's default isn't enough", new AcceptableValueRange(1, 200)));
-
- }
- }
-
- public class UniformAimUtils : MonoBehaviour
- {
- //Return aspect ratio based on game window resolution
- float GetAspectRatio()
- {
- string screenWidth = Screen.width.ToString();
- string screenHeight = Screen.height.ToString();
- float resX = Convert.ToUInt16(screenWidth);
- float resY = Convert.ToUInt16(screenHeight);
-
- //Logger.LogInfo("GetAspectRatio(): resX: " + resX + " resY: " + resY);
- return (resX / resY);
- }
- //convert degrees to radians
- float Deg2Rad(float angle)
- {
- return (float)(angle * Math.PI / 180);
- }
- //convert radians to degrees
- float Rad2Deg(float radian)
- {
- return (float)(radian * 180 / Math.PI);
- }
- //calculate horizontal FOV based on vertical FOV
- float CalculateHFOV(float FOV)
- {
- float vFOVRad = Deg2Rad(FOV);
- float hFOVRad = (float)(2 * Math.Atan(Math.Tan(Deg2Rad(FOV) / 2) * GetAspectRatio()));
-
- return (float)(Math.Round(Rad2Deg(hFOVRad)));
- }
- //calculate sensitivity based on FOV difference and coefficient
- float CalculateSensitivity(float aimedFOV, float hipFOV)
- { //clamp to avoid invalid values
- aimedFOV = Mathf.Clamp(aimedFOV, 0.001f, 90f);
- hipFOV = Mathf.Clamp(hipFOV, 0.001f, 90f);
-
- //halve and convert to radians
- aimedFOV = Deg2Rad(aimedFOV / 2);
- hipFOV = Deg2Rad(hipFOV / 2);
-
- //ratio of tangents as sensitivity
- float sensitivity = (float)(Math.Tan(aimedFOV) / Math.Tan(hipFOV));
-
- return sensitivity;
-
-
- }
-
- public static float adjustedSensitivity = -1f;
-
- float lastFOV = -1f;
- float lastFOV2 = -1f;
-
- float FPSCameraFOV = -1f;
- float ScopeFOV = -1f;
- float currentFOV = -1f;
-
- void Update()
- {
- if (Camera.allCamerasCount >= 1)
- {
- FPSCameraFOV = Camera.allCameras[0].fieldOfView;
- }
- if (Camera.allCamerasCount >= 2)
- {
- ScopeFOV = Camera.allCameras[1].fieldOfView;
- }
- if (Camera.allCamerasCount >= 1 && FPSCameraFOV != lastFOV)
- {
- //Logger.LogInfo("[0] FOV: " + FPSCameraFOV);
- lastFOV = FPSCameraFOV;
- }
- if (Camera.allCamerasCount >= 2 && ScopeFOV != lastFOV2)
- {
- //Logger.LogInfo("[1] FOV: " + ScopeFOV);
- lastFOV2 = ScopeFOV;
- }
-
- //nasty workaround for sensitivity while using PIP scopes, WILL break when FOV is set to 50
- if (35 < FPSCameraFOV && FPSCameraFOV < UniformAimConfig.configFOV.Value) { currentFOV = FPSCameraFOV; }
- if (Camera.allCamerasCount >= 2)
- {
- if (FPSCameraFOV == 35) { currentFOV = ScopeFOV; }
- if (FPSCameraFOV == UniformAimConfig.configFOV.Value - 15) { currentFOV = FPSCameraFOV; }
- }
-
- adjustedSensitivity = CalculateSensitivity(currentFOV, UniformAimConfig.configFOV.Value) * 0.25f; //(float)(UniformAimConfig.configSens.Value/100)
-
- }
- }
-}