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