Added peripheral resolution scale.
This commit is contained in:
parent
184787a525
commit
caac7fdbcb
@ -8,6 +8,7 @@ using EFT.Settings.Graphics;
|
|||||||
//using System.Reflection;
|
//using System.Reflection;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering.PostProcessing;
|
||||||
|
|
||||||
/* Dependencies:
|
/* Dependencies:
|
||||||
* ../BepInEx/core/
|
* ../BepInEx/core/
|
||||||
@ -28,7 +29,7 @@ namespace ScopeTweaks
|
|||||||
[BepInDependency("FOVFix", BepInDependency.DependencyFlags.SoftDependency)]
|
[BepInDependency("FOVFix", BepInDependency.DependencyFlags.SoftDependency)]
|
||||||
public class Plugin : BaseUnityPlugin
|
public class Plugin : BaseUnityPlugin
|
||||||
{
|
{
|
||||||
//ConfigEntry<int> scopeCameraResolutionScale;
|
ConfigEntry<int> peripheralResolutionScale;
|
||||||
ConfigEntry<bool> enableDebug;
|
ConfigEntry<bool> enableDebug;
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
@ -42,11 +43,11 @@ namespace ScopeTweaks
|
|||||||
new CalculateScaleValueByFovPatch().Enable();
|
new CalculateScaleValueByFovPatch().Enable();
|
||||||
}
|
}
|
||||||
|
|
||||||
//scopeCameraResolutionScale = Config.Bind(
|
peripheralResolutionScale = Config.Bind(
|
||||||
// "General",
|
"General",
|
||||||
// "Scope camera scale %",
|
"Peripheral resolution scale %",
|
||||||
// 80,
|
80,
|
||||||
// new ConfigDescription("Additional override applied on top of currently enabled resolution scaling method.", new AcceptableValueRange<int>(10, 100)));
|
new ConfigDescription("Changes the resolution of peripheral vision while aiming.", new AcceptableValueRange<int>(25, 100)));
|
||||||
|
|
||||||
enableDebug = Config.Bind("Debug", "Enable debug logging", false);
|
enableDebug = Config.Bind("Debug", "Enable debug logging", false);
|
||||||
}
|
}
|
||||||
@ -67,11 +68,13 @@ namespace ScopeTweaks
|
|||||||
{
|
{
|
||||||
mainPlayer.RibcageScaleCurrent = 1.0f;
|
mainPlayer.RibcageScaleCurrent = 1.0f;
|
||||||
mainPlayer.RibcageScaleCurrentTarget = 1.0f;
|
mainPlayer.RibcageScaleCurrentTarget = 1.0f;
|
||||||
|
ssaaImplInstance.Switch(peripheralResolutionScale.Value / 100.0f * getcurrentResoScalingFactor()); //resoScalingFactor is potentially applied twice while ADS?
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
mainPlayer.RibcageScaleCurrentTarget = target_scale;
|
mainPlayer.RibcageScaleCurrentTarget = target_scale;
|
||||||
mainPlayer.RibcageScaleCurrent = target_scale;
|
mainPlayer.RibcageScaleCurrent = target_scale;
|
||||||
|
ssaaImplInstance.Switch(1.0f * getcurrentResoScalingFactor());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +87,8 @@ namespace ScopeTweaks
|
|||||||
{
|
{
|
||||||
if (enableDebug.Value) Logger.LogInfo("Getting local player");
|
if (enableDebug.Value) Logger.LogInfo("Getting local player");
|
||||||
mainPlayer = getLocalPlayer();
|
mainPlayer = getLocalPlayer();
|
||||||
|
mainCamera = Camera.main;
|
||||||
|
ssaaImplInstance = Camera.main.GetComponent<SSAAImpl>();
|
||||||
subscribeHandsChangedEvent();
|
subscribeHandsChangedEvent();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -93,9 +97,9 @@ namespace ScopeTweaks
|
|||||||
case GameStatus.Stopped:
|
case GameStatus.Stopped:
|
||||||
{
|
{
|
||||||
if (enableDebug.Value) Logger.LogInfo("Resetting...");
|
if (enableDebug.Value) Logger.LogInfo("Resetting...");
|
||||||
scopeCamera = null;
|
mainCamera = null;
|
||||||
mainPlayer = null;
|
mainPlayer = null;
|
||||||
|
ssaaImplInstance = null;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default: break;
|
default: break;
|
||||||
@ -125,39 +129,8 @@ namespace ScopeTweaks
|
|||||||
return localPlayer;
|
return localPlayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
SSAAImpl ssaaImplInstance = null;
|
||||||
/// CAMERA SETUP
|
Camera mainCamera = null;
|
||||||
/// </summary>
|
|
||||||
Camera scopeCamera = null;
|
|
||||||
async void tryGetScopeCamera()
|
|
||||||
{
|
|
||||||
string cameraName = "BaseOpticCamera(Clone)";
|
|
||||||
if (await Task.Run(() => GameObject.Find(cameraName) != null))
|
|
||||||
{
|
|
||||||
scopeCamera = await Task.Run(() => GameObject.Find(cameraName).GetComponent<Camera>());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//SSAAOptic ssaaOpticInstance = null; //Component has been nuked by BSG, thanks Nikita :)
|
|
||||||
//TODO: Find a workaround to achieve the same result (scale scope resolution while ADS)
|
|
||||||
|
|
||||||
//void setScopeCameraResolutionScale(int value)
|
|
||||||
//{
|
|
||||||
// if (scopeCamera == null || !scopeCamera.isActiveAndEnabled)
|
|
||||||
// {
|
|
||||||
// if (enableDebug.Value) Logger.LogInfo("ScopeCam inactive or absent!");
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (enableDebug.Value) Logger.LogInfo($"Setting Scope res scale to {value}%");
|
|
||||||
|
|
||||||
// if (ssaaOpticInstance == null)
|
|
||||||
// {
|
|
||||||
// ssaaOpticInstance = scopeCamera.GetComponent<SSAAOptic>();
|
|
||||||
// }
|
|
||||||
|
|
||||||
// ssaaOpticInstance.OpticCameraToMainCameraResolutionRatio = (float)(currentResoScalingFactor * (value / 100.0f));
|
|
||||||
//}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// PLAYER WEAPON EVENTS
|
/// PLAYER WEAPON EVENTS
|
||||||
@ -178,18 +151,13 @@ namespace ScopeTweaks
|
|||||||
if (enableDebug.Value) Logger.LogInfo("Subscribing to OnAimingChanged Event");
|
if (enableDebug.Value) Logger.LogInfo("Subscribing to OnAimingChanged Event");
|
||||||
mainPlayer.HandsController.OnAimingChanged += (aimingArgs) =>
|
mainPlayer.HandsController.OnAimingChanged += (aimingArgs) =>
|
||||||
{
|
{
|
||||||
currentResoScalingFactor = getcurrentResoScalingFactor();
|
|
||||||
tryGetScopeCamera();
|
|
||||||
if (mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
if (mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
||||||
{
|
{
|
||||||
target_scale = 1.0f;
|
target_scale = 1.0f;
|
||||||
//setScopeCameraResolutionScale(scopeCameraResolutionScale.Value);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
float currentResoScalingFactor = 1.0f;
|
|
||||||
|
|
||||||
float getcurrentResoScalingFactor()
|
float getcurrentResoScalingFactor()
|
||||||
{
|
{
|
||||||
if (enableDebug.Value) Logger.LogInfo("Getting current scaling factor:");
|
if (enableDebug.Value) Logger.LogInfo("Getting current scaling factor:");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user