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.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
|
||||
/* Dependencies:
|
||||
* ../BepInEx/core/
|
||||
@ -28,7 +29,7 @@ namespace ScopeTweaks
|
||||
[BepInDependency("FOVFix", BepInDependency.DependencyFlags.SoftDependency)]
|
||||
public class Plugin : BaseUnityPlugin
|
||||
{
|
||||
//ConfigEntry<int> scopeCameraResolutionScale;
|
||||
ConfigEntry<int> peripheralResolutionScale;
|
||||
ConfigEntry<bool> enableDebug;
|
||||
|
||||
void Awake()
|
||||
@ -42,11 +43,11 @@ namespace ScopeTweaks
|
||||
new CalculateScaleValueByFovPatch().Enable();
|
||||
}
|
||||
|
||||
//scopeCameraResolutionScale = Config.Bind(
|
||||
// "General",
|
||||
// "Scope camera scale %",
|
||||
// 80,
|
||||
// new ConfigDescription("Additional override applied on top of currently enabled resolution scaling method.", new AcceptableValueRange<int>(10, 100)));
|
||||
peripheralResolutionScale = Config.Bind(
|
||||
"General",
|
||||
"Peripheral resolution scale %",
|
||||
80,
|
||||
new ConfigDescription("Changes the resolution of peripheral vision while aiming.", new AcceptableValueRange<int>(25, 100)));
|
||||
|
||||
enableDebug = Config.Bind("Debug", "Enable debug logging", false);
|
||||
}
|
||||
@ -67,11 +68,13 @@ namespace ScopeTweaks
|
||||
{
|
||||
mainPlayer.RibcageScaleCurrent = 1.0f;
|
||||
mainPlayer.RibcageScaleCurrentTarget = 1.0f;
|
||||
ssaaImplInstance.Switch(peripheralResolutionScale.Value / 100.0f * getcurrentResoScalingFactor()); //resoScalingFactor is potentially applied twice while ADS?
|
||||
}
|
||||
else
|
||||
{
|
||||
mainPlayer.RibcageScaleCurrentTarget = 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");
|
||||
mainPlayer = getLocalPlayer();
|
||||
|
||||
mainCamera = Camera.main;
|
||||
ssaaImplInstance = Camera.main.GetComponent<SSAAImpl>();
|
||||
subscribeHandsChangedEvent();
|
||||
break;
|
||||
}
|
||||
@ -93,9 +97,9 @@ namespace ScopeTweaks
|
||||
case GameStatus.Stopped:
|
||||
{
|
||||
if (enableDebug.Value) Logger.LogInfo("Resetting...");
|
||||
scopeCamera = null;
|
||||
mainCamera = null;
|
||||
mainPlayer = null;
|
||||
|
||||
ssaaImplInstance = null;
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
@ -125,39 +129,8 @@ namespace ScopeTweaks
|
||||
return localPlayer;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// CAMERA SETUP
|
||||
/// </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));
|
||||
//}
|
||||
SSAAImpl ssaaImplInstance = null;
|
||||
Camera mainCamera = null;
|
||||
|
||||
/// <summary>
|
||||
/// PLAYER WEAPON EVENTS
|
||||
@ -178,18 +151,13 @@ namespace ScopeTweaks
|
||||
if (enableDebug.Value) Logger.LogInfo("Subscribing to OnAimingChanged Event");
|
||||
mainPlayer.HandsController.OnAimingChanged += (aimingArgs) =>
|
||||
{
|
||||
currentResoScalingFactor = getcurrentResoScalingFactor();
|
||||
tryGetScopeCamera();
|
||||
if (mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
||||
{
|
||||
target_scale = 1.0f;
|
||||
//setScopeCameraResolutionScale(scopeCameraResolutionScale.Value);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
float currentResoScalingFactor = 1.0f;
|
||||
|
||||
float getcurrentResoScalingFactor()
|
||||
{
|
||||
if (enableDebug.Value) Logger.LogInfo("Getting current scaling factor:");
|
||||
|
Loading…
x
Reference in New Issue
Block a user