Temporarily disabled FOV FIx until more robust solution is found.

This commit is contained in:
notGreg 2023-04-03 11:47:11 +02:00
parent d6347aad11
commit d491111a48
2 changed files with 91 additions and 63 deletions

View File

@ -6,9 +6,7 @@ using EFT;
using EFT.Settings.Graphics;
using System.Collections;
using System.ComponentModel;
using System.Reflection;
using UnityEngine;
using UnityEngine.Rendering.PostProcessing;
/* Dependencies:
* ../BepInEx/core/
@ -30,7 +28,7 @@ namespace ScopeTweaks
public class Plugin : BaseUnityPlugin
{
ConfigEntry<int> scopeCameraResolutionScale;
ConfigEntry<EFOVScalingMode> scopeFixType;
//ConfigEntry<EFOVScalingMode> scopeFixType;
ConfigEntry<bool> enableDebug;
enum EFOVScalingMode
@ -63,11 +61,11 @@ namespace ScopeTweaks
80,
new ConfigDescription("Additional override applied on top of currently enabled resolution scaling method.", new AcceptableValueRange<int>(10, 100)));
scopeFixType = Config.Bind(
"General",
"High FOV sight tweak",
EFOVScalingMode.ScopesOnly,
new ConfigDescription(""));
//scopeFixType = Config.Bind(
//"General",
//"High FOV sight tweak",
//EFOVScalingMode.ScopesOnly,
//new ConfigDescription(""));
enableDebug = Config.Bind("Debug", "Enable debug logging", false);
}
@ -78,6 +76,34 @@ namespace ScopeTweaks
if (Singleton<AbstractGame>.Instance == null) return;
GameStatus currentGameState = Singleton<AbstractGame>.Instance.Status;
if (mainPlayer != null)
{
if (Input.GetKeyDown("["))
{
StopAllCoroutines();
CameraClass.Instance.SetFov(35, 1.0f, true);
}
if (Input.GetKeyDown("]"))
{
StopAllCoroutines();
CameraClass.Instance.SetFov(defaultInGameFOV, 1.0f, true);
}
}
//if (mainPlayer != null && mainPlayer.ProceduralWeaponAnimation.IsAiming)
//{
// if (Input.GetMouseButtonDown(0))
// {
// inGameFOV = 50;
// }
// if (Input.GetMouseButtonUp(0))
// {
// inGameFOV = defaultInGameFOV;
// }
//}
//logic should only execute once per game instead of every frame
if (!gameStateChanged(currentGameState)) return;
@ -94,7 +120,6 @@ namespace ScopeTweaks
StartCoroutine(tryGetScopeCamera());
defaultInGameFOV = inGameFOV;
break;
}
case GameStatus.SoftStopping:
@ -148,12 +173,10 @@ namespace ScopeTweaks
get
{
int fov = Singleton<SharedGameSettingsClass>.Instance.Game.Settings.FieldOfView.Value;
if (enableDebug.Value) Logger.LogInfo($"get_defaultInGameFOV: Reading from settings: {fov}");
return fov;
}
set
{
if (enableDebug.Value) Logger.LogInfo($"set_defaultInGameFOV: Writing to settings: {value}");
Singleton<SharedGameSettingsClass>.Instance.Game.Settings.FieldOfView.Value = value;
}
}
@ -198,6 +221,7 @@ namespace ScopeTweaks
/// <summary>
/// PLAYER WEAPON EVENTS
/// </summary>
void subscribeHandsChangedEvent()
{
if (enableDebug.Value) Logger.LogInfo("Subscribing to HandsChanged Event");
@ -214,41 +238,41 @@ namespace ScopeTweaks
{
currentScalingFactor = getCurrentScalingFactor();
StartCoroutine(tryGetScopeCamera());
if (!mainPlayer.ProceduralWeaponAnimation.IsAiming)
{
float aimSpeed = 0.7f * mainPlayer.ProceduralWeaponAnimation.AimingSpeed;
switch (scopeFixType.Value)
{
case EFOVScalingMode.Disabled:
{
break;
}
case EFOVScalingMode.ScopesOnly:
{
if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic)
{
//setFovLibrary.SetFov(defaultInGameFOV, aimSpeed, false);
inGameFOV = defaultInGameFOV;
//if (!mainPlayer.ProceduralWeaponAnimation.IsAiming)
//{
// float aimSpeed = 0.7f * mainPlayer.ProceduralWeaponAnimation.AimingSpeed;
mainPlayer.ProceduralWeaponAnimation.ResetFovAdjustments(mainPlayer);
}
// switch (scopeFixType.Value)
// {
// case EFOVScalingMode.Disabled:
// {
// break;
// }
// case EFOVScalingMode.ScopesOnly:
// {
// if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic)
// {
// inGameFOV = defaultInGameFOV;
// StopAllCoroutines();
// setFovLibrary.SetFov(defaultInGameFOV, aimSpeed, true);
// //mainPlayer.ProceduralWeaponAnimation.ApplyFovAdjustments(mainPlayer);
// }
break;
}
case EFOVScalingMode.All:
{
//setFovLibrary.SetFov(defaultInGameFOV, aimSpeed, false);
inGameFOV = defaultInGameFOV;
// break;
// }
// case EFOVScalingMode.All:
// {
// inGameFOV = defaultInGameFOV;
// StopAllCoroutines();
// setFovLibrary.SetFov(defaultInGameFOV, aimSpeed, true);
// //mainPlayer.ProceduralWeaponAnimation.ApplyFovAdjustments(mainPlayer);
mainPlayer.ProceduralWeaponAnimation.ResetFovAdjustments(mainPlayer);
break;
}
}
return;
}
// break;
// }
// }
// return;
//}
if (mainPlayer.ProceduralWeaponAnimation.IsAiming)
{
@ -258,26 +282,26 @@ namespace ScopeTweaks
setScopeCameraResolutionScale(scopeCameraResolutionScale.Value);
defaultInGameFOV = inGameFOV;
switch (scopeFixType.Value)
{
case EFOVScalingMode.Disabled:
{
break;
}
case EFOVScalingMode.ScopesOnly:
{
if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic)
{
forceADSFOV();
}
break;
}
case EFOVScalingMode.All:
{
forceADSFOV();
break;
}
}
//switch (scopeFixType.Value)
//{
// case EFOVScalingMode.Disabled:
// {
// break;
// }
// case EFOVScalingMode.ScopesOnly:
// {
// if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic)
// {
// forceADSFOV();
// }
// break;
// }
// case EFOVScalingMode.All:
// {
// forceADSFOV();
// break;
// }
//}
}
};
}
@ -290,7 +314,7 @@ namespace ScopeTweaks
//Doesn't take effect if Fontaine's FOV Fix is loaded.
if (!Chainloader.PluginInfos.ContainsKey("FOVFix"))
{
{
setFovLibrary.SetFov(35, aimSpeed, false);
inGameFOV = 50;
}

View File

@ -60,6 +60,10 @@
<Reference Include="UnityEngine.CoreModule">
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.3\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.InputLegacyModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.3\EscapeFromTarkov_Data\Managed\UnityEngine.InputLegacyModule.dll</HintPath>
</Reference>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>