FOV scaling is now fixed via a method patch instead of arcane workarounds. This might be the one.
Removed FOV scaling settings.
This commit is contained in:
parent
d491111a48
commit
16daa9b33c
19
CameraResolutionScale/Patch.cs
Normal file
19
CameraResolutionScale/Patch.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Aki.Reflection.Patching;
|
||||
using EFT;
|
||||
using System.Reflection;
|
||||
|
||||
namespace ScopeTweaks
|
||||
{
|
||||
internal class CalculateScaleValueByFovPatch : ModulePatch
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return typeof(EFT.Player).GetMethod("CalculateScaleValueByFov");
|
||||
}
|
||||
[PatchPostfix]
|
||||
public static void PatchPostfix(ref float ___float_10)
|
||||
{
|
||||
___float_10 = 1.0f;
|
||||
}
|
||||
}
|
||||
}
|
@ -5,7 +5,6 @@ using Comfort.Common;
|
||||
using EFT;
|
||||
using EFT.Settings.Graphics;
|
||||
using System.Collections;
|
||||
using System.ComponentModel;
|
||||
using UnityEngine;
|
||||
|
||||
/* Dependencies:
|
||||
@ -23,30 +22,13 @@ using UnityEngine;
|
||||
*/
|
||||
namespace ScopeTweaks
|
||||
{
|
||||
[BepInPlugin("com.notGreg.scopeTweaks", "notGreg's Scope Tweaks", "3.5.3")]
|
||||
[BepInPlugin("com.notGreg.scopeTweaks", "notGreg's Scope Tweaks", "3.5.4")]
|
||||
[BepInDependency("FOVFix", BepInDependency.DependencyFlags.SoftDependency)]
|
||||
public class Plugin : BaseUnityPlugin
|
||||
{
|
||||
ConfigEntry<int> scopeCameraResolutionScale;
|
||||
//ConfigEntry<EFOVScalingMode> scopeFixType;
|
||||
ConfigEntry<bool> enableDebug;
|
||||
|
||||
enum EFOVScalingMode
|
||||
{
|
||||
Disabled,
|
||||
[Description("Magnified optics")]
|
||||
ScopesOnly,
|
||||
[Description("All sights")]
|
||||
All,
|
||||
}
|
||||
|
||||
//The following assignments should allow for faster patching in the future.
|
||||
|
||||
//The correct GClass can be found by searching for "ClearSettings" in Assembly-CSharp.dll via dnSpy, netFiddle, ilSpy, etc.
|
||||
SharedGameSettingsClass settingsLibrary = Singleton<SharedGameSettingsClass>.Instance;
|
||||
|
||||
//The correct GClass can be found by searching for "SetFov" in Assembly-CSharp.dll via dnSpy, netFiddle, ilSpy, etc.
|
||||
CameraClass setFovLibrary = CameraClass.Instance;
|
||||
|
||||
void Awake()
|
||||
{
|
||||
@ -54,6 +36,10 @@ namespace ScopeTweaks
|
||||
{
|
||||
Logger.LogWarning("Fontaine's FOV Fix detected! FOV Fix will NOT be available.");
|
||||
}
|
||||
else
|
||||
{
|
||||
new CalculateScaleValueByFovPatch().Enable();
|
||||
}
|
||||
|
||||
scopeCameraResolutionScale = Config.Bind(
|
||||
"General",
|
||||
@ -61,12 +47,6 @@ 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(""));
|
||||
|
||||
enableDebug = Config.Bind("Debug", "Enable debug logging", false);
|
||||
}
|
||||
|
||||
@ -76,34 +56,6 @@ 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;
|
||||
|
||||
@ -119,21 +71,16 @@ namespace ScopeTweaks
|
||||
if (enableDebug.Value) Logger.LogInfo("Assigning cameras...");
|
||||
StartCoroutine(tryGetScopeCamera());
|
||||
|
||||
defaultInGameFOV = inGameFOV;
|
||||
break;
|
||||
}
|
||||
case GameStatus.SoftStopping:
|
||||
case GameStatus.Stopping:
|
||||
case GameStatus.Stopped:
|
||||
{
|
||||
|
||||
if (enableDebug.Value) Logger.LogInfo("Resetting...");
|
||||
scopeCamera = null;
|
||||
mainPlayer = null;
|
||||
|
||||
if (enableDebug.Value) Logger.LogInfo($"Restoring FOV in settings: {defaultInGameFOV}");
|
||||
inGameFOV = defaultInGameFOV;
|
||||
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
@ -163,24 +110,6 @@ namespace ScopeTweaks
|
||||
return localPlayer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// FIELD OF VIEW
|
||||
/// </summary>
|
||||
///
|
||||
private int defaultInGameFOV;
|
||||
private int inGameFOV
|
||||
{
|
||||
get
|
||||
{
|
||||
int fov = Singleton<SharedGameSettingsClass>.Instance.Game.Settings.FieldOfView.Value;
|
||||
return fov;
|
||||
}
|
||||
set
|
||||
{
|
||||
Singleton<SharedGameSettingsClass>.Instance.Game.Settings.FieldOfView.Value = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CAMERA SETUP
|
||||
/// </summary>
|
||||
@ -239,87 +168,13 @@ 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)
|
||||
// {
|
||||
// inGameFOV = defaultInGameFOV;
|
||||
// StopAllCoroutines();
|
||||
// setFovLibrary.SetFov(defaultInGameFOV, aimSpeed, true);
|
||||
// //mainPlayer.ProceduralWeaponAnimation.ApplyFovAdjustments(mainPlayer);
|
||||
// }
|
||||
|
||||
// break;
|
||||
// }
|
||||
// case EFOVScalingMode.All:
|
||||
// {
|
||||
// inGameFOV = defaultInGameFOV;
|
||||
// StopAllCoroutines();
|
||||
// setFovLibrary.SetFov(defaultInGameFOV, aimSpeed, true);
|
||||
// //mainPlayer.ProceduralWeaponAnimation.ApplyFovAdjustments(mainPlayer);
|
||||
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// return;
|
||||
//}
|
||||
|
||||
if (mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
||||
{
|
||||
if(enableDebug.Value) Logger.LogInfo($"Scope: {mainPlayer.ProceduralWeaponAnimation.CurrentAimingMod.Item.LocalizedName()} isOptic: {mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic}");
|
||||
|
||||
if (enableDebug.Value) Logger.LogInfo("Updating scope resolution");
|
||||
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;
|
||||
// }
|
||||
//}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
void forceADSFOV()
|
||||
{
|
||||
if (enableDebug.Value) Logger.LogInfo("Applying aiming tweaks");
|
||||
|
||||
float aimSpeed = mainPlayer.ProceduralWeaponAnimation.AimingSpeed * 0.7f;
|
||||
|
||||
//Doesn't take effect if Fontaine's FOV Fix is loaded.
|
||||
if (!Chainloader.PluginInfos.ContainsKey("FOVFix"))
|
||||
{
|
||||
setFovLibrary.SetFov(35, aimSpeed, false);
|
||||
inGameFOV = 50;
|
||||
}
|
||||
}
|
||||
|
||||
float currentScalingFactor = 1.0f;
|
||||
|
||||
float getCurrentScalingFactor()
|
||||
|
@ -31,6 +31,7 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Patch.cs" />
|
||||
<Compile Include="Plugin.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
</ItemGroup>
|
||||
|
Loading…
x
Reference in New Issue
Block a user