wip
This commit is contained in:
parent
c8728e5769
commit
98c7a6f899
@ -5,7 +5,9 @@ using UnityEngine;
|
|||||||
using Comfort.Common;
|
using Comfort.Common;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using EFT.UI;
|
||||||
|
using EFT.Animations;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ScopeTweaks
|
namespace ScopeTweaks
|
||||||
{
|
{
|
||||||
@ -17,12 +19,15 @@ namespace ScopeTweaks
|
|||||||
|
|
||||||
ConfigEntry<int> cameraResolutionScale;
|
ConfigEntry<int> cameraResolutionScale;
|
||||||
ConfigEntry<int> scopeCameraResolutionScale;
|
ConfigEntry<int> scopeCameraResolutionScale;
|
||||||
ConfigEntry<bool> fovCompDistScale;
|
ConfigEntry<EFOVScalingMode> scopeFixType;
|
||||||
|
|
||||||
enum fovScalingMode
|
enum EFOVScalingMode
|
||||||
{
|
{
|
||||||
Disabled,
|
Disabled,
|
||||||
Enabled
|
[Description("Only affect scopes")]
|
||||||
|
ScopesOnly,
|
||||||
|
[Description("Affect all sights")]
|
||||||
|
All
|
||||||
}
|
}
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
@ -39,15 +44,9 @@ namespace ScopeTweaks
|
|||||||
40,
|
40,
|
||||||
new ConfigDescription("Scope camera resolution scale", new AcceptableValueRange<int>(25, 100)));
|
new ConfigDescription("Scope camera resolution scale", new AcceptableValueRange<int>(25, 100)));
|
||||||
|
|
||||||
fovCompDistScale = Config.Bind(
|
scopeFixType = Config.Bind("General", "Disable ADS FOV scaling", EFOVScalingMode.ScopesOnly, new ConfigDescription(""));
|
||||||
"Fixes",
|
|
||||||
"High FOV scope fix",
|
|
||||||
true,
|
|
||||||
new ConfigDescription("Makes scopes more useable at high FOV values"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
float defaultSSRatio = 1.0f;
|
float defaultSSRatio = 1.0f;
|
||||||
Camera FPSCamera = null;
|
Camera FPSCamera = null;
|
||||||
Camera scopeCamera = null;
|
Camera scopeCamera = null;
|
||||||
@ -81,6 +80,7 @@ namespace ScopeTweaks
|
|||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
FPSCamera = scopeRes.getMainCamera();
|
FPSCamera = scopeRes.getMainCamera();
|
||||||
|
defaultFOVValue = (int)FPSCamera.fieldOfView;
|
||||||
|
|
||||||
//Logger.LogInfo("Get SSAAInstance (Camera)");
|
//Logger.LogInfo("Get SSAAInstance (Camera)");
|
||||||
ssaaInstance = scopeRes.getSSAAInstance(FPSCamera);
|
ssaaInstance = scopeRes.getSSAAInstance(FPSCamera);
|
||||||
@ -101,36 +101,66 @@ namespace ScopeTweaks
|
|||||||
yield return myDelaySec;
|
yield return myDelaySec;
|
||||||
StartCoroutine(tryGetScopeCamera());
|
StartCoroutine(tryGetScopeCamera());
|
||||||
yield break;
|
yield break;
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Logger.LogInfo("Assigning scopeCamera");
|
//Logger.LogInfo("Assigning scopeCamera");
|
||||||
scopeCamera = scopeRes.getScopeCamera();
|
scopeCamera = scopeRes.getScopeCamera();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void updateMainCameraResolution(float value)
|
||||||
|
{
|
||||||
|
Logger.LogInfo($"Updating {Camera.main.name} SSRatio to {value / 100f}");
|
||||||
|
_nextSSRation.SetValue(ssaaInstance, (float)(defaultSSRatio * value / 100f));
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateScopeCameraResolution(float value)
|
||||||
|
{
|
||||||
|
Logger.LogInfo($"Updating {scopeCamera.name} to {value / 100f}");
|
||||||
|
scopeCamera.GetComponent<SSAAOptic>().OpticCameraToMainCameraResolutionRatio = (float)(value / 100f);
|
||||||
|
}
|
||||||
|
|
||||||
|
void updateInGameFOVValue(int value)
|
||||||
|
{
|
||||||
|
Logger.LogInfo($"Updating in-game FOV value to: {value}");
|
||||||
|
Singleton<GClass1630>.Instance.Game.Settings.FieldOfView.Value = value;
|
||||||
|
}
|
||||||
void subscribeToOnAimingChanged()
|
void subscribeToOnAimingChanged()
|
||||||
{
|
{
|
||||||
//Logger.LogInfo($"subscribeToOnAimingChanged: player = {mainPlayer}");
|
|
||||||
mainPlayer.HandsController.OnAimingChanged += (args) =>
|
mainPlayer.HandsController.OnAimingChanged += (args) =>
|
||||||
{
|
{
|
||||||
|
switch (scopeFixType.Value)
|
||||||
|
{
|
||||||
|
case EFOVScalingMode.Disabled: { break; }
|
||||||
|
case EFOVScalingMode.ScopesOnly:
|
||||||
|
{
|
||||||
|
if (scopeCamera == null || !scopeCamera.isActiveAndEnabled) break;
|
||||||
|
updateScopeCameraResolution(scopeCameraResolutionScale.Value);
|
||||||
|
updateInGameFOVValue(50);
|
||||||
|
break; }
|
||||||
|
case EFOVScalingMode.All:
|
||||||
|
{
|
||||||
|
updateScopeCameraResolution(scopeCameraResolutionScale.Value);
|
||||||
|
updateInGameFOVValue(50);
|
||||||
|
break; }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
if (mainPlayer.HandsController.IsAiming)
|
if (mainPlayer.HandsController.IsAiming)
|
||||||
{
|
{
|
||||||
//Logger.LogInfo("Updating camera resolutions");
|
updateMainCameraResolution(cameraResolutionScale.Value);
|
||||||
_nextSSRation.SetValue(ssaaInstance, (float)(defaultSSRatio * cameraResolutionScale.Value / 100f));
|
|
||||||
|
|
||||||
if (scopeCamera != null && scopeCamera.isActiveAndEnabled)
|
if (scopeCamera != null && scopeCamera.isActiveAndEnabled)
|
||||||
{
|
{
|
||||||
scopeCamera.GetComponent<SSAAOptic>().OpticCameraToMainCameraResolutionRatio = (float)(scopeCameraResolutionScale.Value / 100f);
|
updateScopeCameraResolution(scopeCameraResolutionScale.Value);
|
||||||
|
updateInGameFOVValue(50);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!mainPlayer.HandsController.IsAiming)
|
if (!mainPlayer.HandsController.IsAiming)
|
||||||
{
|
{
|
||||||
//Logger.LogInfo("Restoring camera resolutions");
|
updateMainCameraResolution(defaultSSRatio);
|
||||||
_nextSSRation.SetValue(ssaaInstance, (float)(defaultSSRatio));
|
updateInGameFOVValue(defaultFOVValue);
|
||||||
|
GClass1762.Instance.SetFov(defaultFOVValue, 1f, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -151,19 +181,46 @@ namespace ScopeTweaks
|
|||||||
|
|
||||||
Player mainPlayer = null;
|
Player mainPlayer = null;
|
||||||
|
|
||||||
|
void hideoutWorkaround()
|
||||||
|
{
|
||||||
|
if (mainPlayer.HandsController.IsAiming)
|
||||||
|
{
|
||||||
|
if (mainPlayer.HandsController.IsAiming)
|
||||||
|
{
|
||||||
|
updateMainCameraResolution(cameraResolutionScale.Value);
|
||||||
|
if (scopeCamera != null && scopeCamera.isActiveAndEnabled)
|
||||||
|
{
|
||||||
|
updateScopeCameraResolution(scopeCameraResolutionScale.Value);
|
||||||
|
updateInGameFOVValue(50);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!mainPlayer.HandsController.IsAiming)
|
||||||
|
{
|
||||||
|
updateMainCameraResolution(defaultSSRatio);
|
||||||
|
|
||||||
|
updateInGameFOVValue(defaultFOVValue);
|
||||||
|
GClass1762.Instance.SetFov(defaultFOVValue, 1f, true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Update()
|
void Update()
|
||||||
{
|
{
|
||||||
|
|
||||||
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 (currentGameState == GameStatus.Started && mainPlayer != null)
|
if (currentGameState == GameStatus.Started && mainPlayer != null && mainPlayer.GetType() == typeof(HideoutPlayer))
|
||||||
{
|
{
|
||||||
if (mainPlayer.HandsController.IsAiming)
|
switch(scopeFixType.Value)
|
||||||
{
|
{
|
||||||
//Logger.LogInfo("Changing fovCompDist");
|
case EFOVScalingMode.Disabled: { break; }
|
||||||
if (fovCompDistScale.Value) { mainPlayer.ProceduralWeaponAnimation._fovCompensatoryDistance = 0; }
|
default: { hideoutWorkaround(); break; }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gameStateChanged(currentGameState)) return;
|
if (!gameStateChanged(currentGameState)) return;
|
||||||
@ -195,17 +252,9 @@ namespace ScopeTweaks
|
|||||||
//Logger.LogInfo("subscibeToOnAimingChanged()");
|
//Logger.LogInfo("subscibeToOnAimingChanged()");
|
||||||
subscribeToOnAimingChanged();
|
subscribeToOnAimingChanged();
|
||||||
|
|
||||||
|
defaultFOVValue = Singleton<GClass1630>.Instance.Game.Settings.FieldOfView;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//void updateSSRatio()
|
|
||||||
//{
|
|
||||||
// if (!isAiming && FPSCamera != null)
|
|
||||||
// {
|
|
||||||
// defaultSSRatio = (float)_nextSSRation.GetValue(ssaaInstance);
|
|
||||||
// //Logger.LogInfo($"Updating defaultSSRatio to {defaultSSRatio}");
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,7 +31,8 @@
|
|||||||
<WarningLevel>4</WarningLevel>
|
<WarningLevel>4</WarningLevel>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Assembly-CSharp">
|
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>E:\SPT-AKI\SPT-AKI 3.2.1\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll</HintPath>
|
<HintPath>E:\SPT-AKI\SPT-AKI 3.2.1\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="BepInEx">
|
<Reference Include="BepInEx">
|
||||||
|
Loading…
x
Reference in New Issue
Block a user