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

View File

@ -60,6 +60,10 @@
<Reference Include="UnityEngine.CoreModule"> <Reference Include="UnityEngine.CoreModule">
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.3\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll</HintPath> <HintPath>E:\SPT-AKI\SPT-AKI 3.5.3\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
</Reference> </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> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project> </Project>