Removed main camera resolution scale while aiming due to performance issues.
Updated for SPT-AKI 3.5.3
This commit is contained in:
parent
bc0d156034
commit
dbfc74cd26
@ -23,10 +23,9 @@ using UnityEngine;
|
|||||||
*/
|
*/
|
||||||
namespace ScopeTweaks
|
namespace ScopeTweaks
|
||||||
{
|
{
|
||||||
[BepInPlugin("com.notGreg.scopeTweaks", "notGreg's Scope Tweaks", "3.5.0")]
|
[BepInPlugin("com.notGreg.scopeTweaks", "notGreg's Scope Tweaks", "3.5.3")]
|
||||||
public class Plugin : BaseUnityPlugin
|
public class Plugin : BaseUnityPlugin
|
||||||
{
|
{
|
||||||
ConfigEntry<int> cameraResolutionScale;
|
|
||||||
ConfigEntry<int> scopeCameraResolutionScale;
|
ConfigEntry<int> scopeCameraResolutionScale;
|
||||||
ConfigEntry<EFOVScalingMode> scopeFixType;
|
ConfigEntry<EFOVScalingMode> scopeFixType;
|
||||||
ConfigEntry<bool> enableDebug;
|
ConfigEntry<bool> enableDebug;
|
||||||
@ -41,25 +40,16 @@ namespace ScopeTweaks
|
|||||||
}
|
}
|
||||||
|
|
||||||
//The following assignments should allow for faster patching in the future.
|
//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.
|
|
||||||
|
|
||||||
//GClass1642 settingsLibrary = Singleton<GClass1642>.Instance; //used by SPT-AKI 3.2.3
|
//The correct GClass can be found by searching for "ClearSettings" in Assembly-CSharp.dll via dnSpy, netFiddle, ilSpy, etc.
|
||||||
//GClass1653 settingsLibrary = Singleton<GClass1653>.Instance; //used by SPT-AKI 3.3.0
|
SharedGameSettingsClass settingsLibrary = Singleton<SharedGameSettingsClass>.Instance;
|
||||||
//GClass1659 settingsLibrary = Singleton<GClass1659>.Instance; //used by SPT-AKI 3.4.1
|
|
||||||
|
|
||||||
//The correct GClass can be found by searching for "SetFov" in Assembly-CSharp.dll via dnSpy, netFiddle, ilSpy, etc.
|
//The correct GClass can be found by searching for "SetFov" in Assembly-CSharp.dll via dnSpy, netFiddle, ilSpy, etc.
|
||||||
|
CameraClass setFovLibrary = CameraClass.Instance;
|
||||||
//GClass1774 setFovLibrary = Singleton<GClass1774>.Instance; //used by SPT-AKI 3.2.3
|
|
||||||
//GClass1785 setFovLibrary = Singleton<GClass1785>.Instance; //used by SPT-AKI 3.3.0
|
|
||||||
CameraClass setFovLibrary = CameraClass.Instance; //used by SPT-AKI 3.4.1 and 3.5.0
|
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
cameraResolutionScale = Config.Bind(
|
|
||||||
"General",
|
|
||||||
"Main camera scale %",
|
|
||||||
80,
|
|
||||||
new ConfigDescription("Additional override applied on top of currently enabled resolution scaling method.", new AcceptableValueRange<int>(25, 100)));
|
|
||||||
|
|
||||||
scopeCameraResolutionScale = Config.Bind(
|
scopeCameraResolutionScale = Config.Bind(
|
||||||
"General",
|
"General",
|
||||||
@ -95,7 +85,6 @@ namespace ScopeTweaks
|
|||||||
subscribeHandsChangedEvent();
|
subscribeHandsChangedEvent();
|
||||||
|
|
||||||
if (enableDebug.Value) Logger.LogInfo("Assigning cameras...");
|
if (enableDebug.Value) Logger.LogInfo("Assigning cameras...");
|
||||||
StartCoroutine(tryGetMainCamera());
|
|
||||||
StartCoroutine(tryGetScopeCamera());
|
StartCoroutine(tryGetScopeCamera());
|
||||||
|
|
||||||
defaultInGameFOV = inGameFOV;
|
defaultInGameFOV = inGameFOV;
|
||||||
@ -108,7 +97,6 @@ namespace ScopeTweaks
|
|||||||
{
|
{
|
||||||
|
|
||||||
if (enableDebug.Value) Logger.LogInfo("Resetting...");
|
if (enableDebug.Value) Logger.LogInfo("Resetting...");
|
||||||
FPSCamera = null;
|
|
||||||
scopeCamera = null;
|
scopeCamera = null;
|
||||||
mainPlayer = null;
|
mainPlayer = null;
|
||||||
|
|
||||||
@ -134,7 +122,7 @@ namespace ScopeTweaks
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player mainPlayer;
|
Player mainPlayer = null;
|
||||||
//find and return the player character in the session
|
//find and return the player character in the session
|
||||||
Player getLocalPlayer()
|
Player getLocalPlayer()
|
||||||
{
|
{
|
||||||
@ -153,56 +141,22 @@ namespace ScopeTweaks
|
|||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
//int fov = settingsLibrary.Game.Settings.FieldOfView.Value;
|
int fov = Singleton<SharedGameSettingsClass>.Instance.Game.Settings.FieldOfView.Value;
|
||||||
//int fov = Singleton<GClass1659>.Instance.Game.Settings.FieldOfView.Value; //SPT-AKI 3.4.1
|
|
||||||
int fov = Singleton<GClass1776>.Instance.Game.Settings.FieldOfView.Value; // SPT-AKI 3.5.0
|
|
||||||
if (enableDebug.Value) Logger.LogInfo($"get_defaultInGameFOV: Reading from settings: {fov}");
|
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}");
|
if (enableDebug.Value) Logger.LogInfo($"set_defaultInGameFOV: Writing to settings: {value}");
|
||||||
//settingsLibrary.Game.Settings.FieldOfView.Value = value;
|
Singleton<SharedGameSettingsClass>.Instance.Game.Settings.FieldOfView.Value = value;
|
||||||
//int fov = Singleton<GClass1659>.Instance.Game.Settings.FieldOfView.Value;
|
|
||||||
Singleton<GClass1776>.Instance.Game.Settings.FieldOfView.Value = value; // SPT-AKI 3.5.0
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// CAMERA SETUP
|
/// CAMERA SETUP
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
||||||
Camera FPSCamera = null;
|
|
||||||
Camera scopeCamera = null;
|
Camera scopeCamera = null;
|
||||||
|
|
||||||
SSAA ssaaInstance = null;
|
|
||||||
FieldInfo _nextSSRation = null;
|
|
||||||
|
|
||||||
WaitForSeconds myDelaySec = new WaitForSeconds(1);
|
|
||||||
IEnumerator tryGetMainCamera()
|
|
||||||
{
|
|
||||||
string cameraName = "FPS Camera";
|
|
||||||
if (GameObject.Find(cameraName) != null)
|
|
||||||
{
|
|
||||||
FPSCamera = GameObject.Find(cameraName).GetComponent<Camera>();
|
|
||||||
if (enableDebug.Value) Logger.LogInfo($"{FPSCamera.name} found!");
|
|
||||||
StopCoroutine(tryGetMainCamera());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (enableDebug.Value) Logger.LogMessage($"Camera \"{cameraName}\" not found.");
|
|
||||||
yield return myDelaySec;
|
|
||||||
StartCoroutine(tryGetMainCamera());
|
|
||||||
yield break;
|
|
||||||
}
|
|
||||||
yield return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
FieldInfo getFieldInfo(string fieldName)
|
|
||||||
{
|
|
||||||
return typeof(SSAA).GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
IEnumerator tryGetScopeCamera()
|
IEnumerator tryGetScopeCamera()
|
||||||
{
|
{
|
||||||
string cameraName = "BaseOpticCamera(Clone)";
|
string cameraName = "BaseOpticCamera(Clone)";
|
||||||
@ -214,19 +168,6 @@ namespace ScopeTweaks
|
|||||||
}
|
}
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
void setMainCameraResolutionScale(int value = 100)
|
|
||||||
{
|
|
||||||
if (ssaaInstance == null)
|
|
||||||
{
|
|
||||||
ssaaInstance = FPSCamera.GetComponent<SSAA>();
|
|
||||||
_nextSSRation = getFieldInfo("_nextSSRation");
|
|
||||||
}
|
|
||||||
float target_res = currentScalingFactor * (value / 100.0f);
|
|
||||||
|
|
||||||
if (enableDebug.Value) Logger.LogInfo($"Setting MainCam res scale to {Mathf.Round(target_res*100.0f)}%");
|
|
||||||
//_nextSSRation.SetValue(ssaaInstance, (float)(currentScalingFactor * (value / 100.0f)));
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
SSAAOptic ssaaOpticInstance = null;
|
SSAAOptic ssaaOpticInstance = null;
|
||||||
|
|
||||||
@ -283,18 +224,19 @@ namespace ScopeTweaks
|
|||||||
case EFOVScalingMode.ScopesOnly:
|
case EFOVScalingMode.ScopesOnly:
|
||||||
{
|
{
|
||||||
if (enableDebug.Value) Logger.LogInfo($"Switch: Not Aiming: ScalingMode: {scopeFixType.Value}");
|
if (enableDebug.Value) Logger.LogInfo($"Switch: Not Aiming: ScalingMode: {scopeFixType.Value}");
|
||||||
setMainCameraResolutionScale();
|
if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic)
|
||||||
setFovLibrary.SetFov(defaultInGameFOV, aimSpeed, false);
|
{
|
||||||
inGameFOV = defaultInGameFOV;
|
setFovLibrary.SetFov(defaultInGameFOV, aimSpeed, false);
|
||||||
|
inGameFOV = defaultInGameFOV;
|
||||||
|
|
||||||
mainPlayer.ProceduralWeaponAnimation.ResetFovAdjustments(mainPlayer);
|
mainPlayer.ProceduralWeaponAnimation.ResetFovAdjustments(mainPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EFOVScalingMode.All:
|
case EFOVScalingMode.All:
|
||||||
{
|
{
|
||||||
if (enableDebug.Value) Logger.LogInfo($"Switch: Not Aiming: ScalingMode: {scopeFixType.Value}");
|
if (enableDebug.Value) Logger.LogInfo($"Switch: Not Aiming: ScalingMode: {scopeFixType.Value}");
|
||||||
setMainCameraResolutionScale();
|
|
||||||
|
|
||||||
setFovLibrary.SetFov(defaultInGameFOV, aimSpeed, false);
|
setFovLibrary.SetFov(defaultInGameFOV, aimSpeed, false);
|
||||||
inGameFOV = defaultInGameFOV;
|
inGameFOV = defaultInGameFOV;
|
||||||
@ -309,6 +251,7 @@ namespace ScopeTweaks
|
|||||||
|
|
||||||
if (mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
if (mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
||||||
{
|
{
|
||||||
|
Logger.LogInfo($"Scope: {mainPlayer.ProceduralWeaponAnimation.CurrentAimingMod.Item.LocalizedName()} isOptic: {mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic}");
|
||||||
defaultInGameFOV = inGameFOV;
|
defaultInGameFOV = inGameFOV;
|
||||||
switch (scopeFixType.Value)
|
switch (scopeFixType.Value)
|
||||||
{
|
{
|
||||||
@ -320,14 +263,10 @@ namespace ScopeTweaks
|
|||||||
case EFOVScalingMode.ScopesOnly:
|
case EFOVScalingMode.ScopesOnly:
|
||||||
{
|
{
|
||||||
if (enableDebug.Value) Logger.LogInfo($"Switch: Aiming: ScalingMode: {scopeFixType.Value}");
|
if (enableDebug.Value) Logger.LogInfo($"Switch: Aiming: ScalingMode: {scopeFixType.Value}");
|
||||||
if (scopeCamera != null && scopeCamera.isActiveAndEnabled)
|
if (mainPlayer.ProceduralWeaponAnimation.CurrentScope.IsOptic)
|
||||||
{
|
{
|
||||||
applyFixesWhileAiming();
|
applyFixesWhileAiming();
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
if (enableDebug.Value) Logger.LogInfo("ScopeCamera not found or disabled!");
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case EFOVScalingMode.All:
|
case EFOVScalingMode.All:
|
||||||
@ -345,37 +284,25 @@ namespace ScopeTweaks
|
|||||||
|
|
||||||
void applyFixesWhileAiming()
|
void applyFixesWhileAiming()
|
||||||
{
|
{
|
||||||
//if (enableDebug.Value) Logger.LogInfo($"AimingSpeed: {mainPlayer.ProceduralWeaponAnimation.AimingSpeed}");
|
|
||||||
if (enableDebug.Value) Logger.LogInfo("Applying aiming tweaks");
|
if (enableDebug.Value) Logger.LogInfo("Applying aiming tweaks");
|
||||||
|
|
||||||
float aimSpeed = mainPlayer.ProceduralWeaponAnimation.AimingSpeed * 0.7f;
|
float aimSpeed = mainPlayer.ProceduralWeaponAnimation.AimingSpeed * 0.7f;
|
||||||
|
|
||||||
|
// Classic method of forcing 50 fov while aiming
|
||||||
|
|
||||||
setFovLibrary.SetFov(35, aimSpeed, false);
|
setFovLibrary.SetFov(35, aimSpeed, false);
|
||||||
inGameFOV = 50;
|
inGameFOV = 50;
|
||||||
|
|
||||||
if (enableDebug.Value) Logger.LogInfo("Updating scope resolution");
|
if (enableDebug.Value) Logger.LogInfo("Updating scope resolution");
|
||||||
setMainCameraResolutionScale(cameraResolutionScale.Value);
|
|
||||||
setScopeCameraResolutionScale(scopeCameraResolutionScale.Value);
|
setScopeCameraResolutionScale(scopeCameraResolutionScale.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// IN-GAME SETTINGS
|
|
||||||
/// </summary>
|
|
||||||
|
|
||||||
float currentScalingFactor = 1.0f;
|
float currentScalingFactor = 1.0f;
|
||||||
|
|
||||||
float getCurrentScalingFactor()
|
float getCurrentScalingFactor()
|
||||||
{
|
{
|
||||||
if (enableDebug.Value) Logger.LogInfo("Getting current scaling factor:");
|
if (enableDebug.Value) Logger.LogInfo("Getting current scaling factor:");
|
||||||
//var graphics = settingsLibrary.Graphics.Settings; //SPT-AKI 3.3.0
|
var graphics = Singleton<SharedGameSettingsClass>.Instance.Graphics.Settings;
|
||||||
//var graphics = Singleton<GClass1659>.Instance.Graphics.Settings; // SPT-AKI 3.4.1
|
|
||||||
var graphics = Singleton<GClass1776>.Instance.Graphics.Settings; // SPT-AKI 3.5.0
|
|
||||||
|
|
||||||
//if (!graphics.DLSSEnabled && !graphics.FSREnabled)
|
|
||||||
//{
|
|
||||||
// if (enableDebug.Value) Logger.LogInfo($"Supersampling factor: {graphics.SuperSamplingFactor}");
|
|
||||||
// return graphics.SuperSamplingFactor;
|
|
||||||
//}
|
|
||||||
|
|
||||||
if (graphics.DLSSEnabled)
|
if (graphics.DLSSEnabled)
|
||||||
{
|
{
|
||||||
@ -422,9 +349,6 @@ namespace ScopeTweaks
|
|||||||
|
|
||||||
if (enableDebug.Value) Logger.LogInfo($"Supersampling factor: {graphics.SuperSamplingFactor}");
|
if (enableDebug.Value) Logger.LogInfo($"Supersampling factor: {graphics.SuperSamplingFactor}");
|
||||||
return graphics.SuperSamplingFactor;
|
return graphics.SuperSamplingFactor;
|
||||||
|
|
||||||
//if (enableDebug.Value) Logger.LogInfo($"GetCurrentScalingFactor(): Something went wrong. Returning 1.0f");
|
|
||||||
//return 1.0f;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -35,38 +35,30 @@
|
|||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="Aki.Reflection, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Aki.Reflection">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.3\EscapeFromTarkov_Data\Managed\Aki.Reflection.dll</HintPath>
|
||||||
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.0\EscapeFromTarkov_Data\Managed\Aki.Reflection.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Assembly-CSharp">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.3\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll</HintPath>
|
||||||
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.0\EscapeFromTarkov_Data\Managed\Assembly-CSharp.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="BepInEx, Version=5.4.21.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="BepInEx">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.3\BepInEx\core\BepInEx.dll</HintPath>
|
||||||
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.0\BepInEx\core\BepInEx.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Comfort, Version=1.0.0.4, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Comfort">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.3\EscapeFromTarkov_Data\Managed\Comfort.dll</HintPath>
|
||||||
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.0\EscapeFromTarkov_Data\Managed\Comfort.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="ItemComponent.Types, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="ItemComponent.Types">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.3\EscapeFromTarkov_Data\Managed\ItemComponent.Types.dll</HintPath>
|
||||||
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.0\EscapeFromTarkov_Data\Managed\ItemComponent.Types.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="System" />
|
<Reference Include="System" />
|
||||||
<Reference Include="Unity.Postprocessing.Runtime, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="Unity.Postprocessing.Runtime">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.3\EscapeFromTarkov_Data\Managed\Unity.Postprocessing.Runtime.dll</HintPath>
|
||||||
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.0\EscapeFromTarkov_Data\Managed\Unity.Postprocessing.Runtime.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="UnityEngine">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.3\EscapeFromTarkov_Data\Managed\UnityEngine.dll</HintPath>
|
||||||
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.0\EscapeFromTarkov_Data\Managed\UnityEngine.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
<Reference Include="UnityEngine.CoreModule">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.3\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||||
<HintPath>E:\SPT-AKI\SPT-AKI 3.5.0\EscapeFromTarkov_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
|
||||||
</Reference>
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user