Reimplemented non-ADS weapon scaling.
This commit is contained in:
parent
16daa9b33c
commit
8d0a20c7e0
@ -8,7 +8,7 @@ namespace ScopeTweaks
|
|||||||
{
|
{
|
||||||
protected override MethodBase GetTargetMethod()
|
protected override MethodBase GetTargetMethod()
|
||||||
{
|
{
|
||||||
return typeof(EFT.Player).GetMethod("CalculateScaleValueByFov");
|
return typeof(Player).GetMethod("CalculateScaleValueByFov");
|
||||||
}
|
}
|
||||||
[PatchPostfix]
|
[PatchPostfix]
|
||||||
public static void PatchPostfix(ref float ___float_10)
|
public static void PatchPostfix(ref float ___float_10)
|
||||||
|
@ -5,6 +5,7 @@ using Comfort.Common;
|
|||||||
using EFT;
|
using EFT;
|
||||||
using EFT.Settings.Graphics;
|
using EFT.Settings.Graphics;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
/* Dependencies:
|
/* Dependencies:
|
||||||
@ -29,7 +30,6 @@ namespace ScopeTweaks
|
|||||||
ConfigEntry<int> scopeCameraResolutionScale;
|
ConfigEntry<int> scopeCameraResolutionScale;
|
||||||
ConfigEntry<bool> enableDebug;
|
ConfigEntry<bool> enableDebug;
|
||||||
|
|
||||||
|
|
||||||
void Awake()
|
void Awake()
|
||||||
{
|
{
|
||||||
if (Chainloader.PluginInfos.ContainsKey("FOVFix"))
|
if (Chainloader.PluginInfos.ContainsKey("FOVFix"))
|
||||||
@ -50,12 +50,30 @@ namespace ScopeTweaks
|
|||||||
enableDebug = Config.Bind("Debug", "Enable debug logging", false);
|
enableDebug = Config.Bind("Debug", "Enable debug logging", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FixedUpdate()
|
void Update()
|
||||||
{
|
{
|
||||||
//Check if the game is in a valid state and execute logic depening on the status of the game
|
//Check if the game is in a valid state and execute logic depening on the status of the game
|
||||||
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 (mainPlayer != null)
|
||||||
|
{
|
||||||
|
int inGameFov = Singleton<SharedGameSettingsClass>.Instance.Game.Settings.FieldOfView;
|
||||||
|
float fov_clamped = Mathf.Clamp(inGameFov, 50, 75);
|
||||||
|
target_scale = Mathf.Lerp(1.0f, 0.65f, (fov_clamped - 50) / 25);
|
||||||
|
|
||||||
|
if (mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
||||||
|
{
|
||||||
|
mainPlayer.RibcageScaleCurrent = 1.0f;
|
||||||
|
mainPlayer.RibcageScaleCurrentTarget = 1.0f;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
mainPlayer.RibcageScaleCurrentTarget = target_scale;
|
||||||
|
mainPlayer.RibcageScaleCurrent = target_scale;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//logic should only execute once per game instead of every frame
|
//logic should only execute once per game instead of every frame
|
||||||
if (!gameStateChanged(currentGameState)) return;
|
if (!gameStateChanged(currentGameState)) return;
|
||||||
|
|
||||||
@ -144,7 +162,7 @@ namespace ScopeTweaks
|
|||||||
ssaaOpticInstance = scopeCamera.GetComponent<SSAAOptic>();
|
ssaaOpticInstance = scopeCamera.GetComponent<SSAAOptic>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ssaaOpticInstance.OpticCameraToMainCameraResolutionRatio = (float)(currentScalingFactor * (value / 100.0f));
|
ssaaOpticInstance.OpticCameraToMainCameraResolutionRatio = (float)(currentResoScalingFactor * (value / 100.0f));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -160,24 +178,26 @@ namespace ScopeTweaks
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal static float target_scale = 1.0f;
|
||||||
void subscribeOnAimingChangedEvent()
|
void subscribeOnAimingChangedEvent()
|
||||||
{
|
{
|
||||||
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) =>
|
||||||
{
|
{
|
||||||
currentScalingFactor = getCurrentScalingFactor();
|
currentResoScalingFactor = getcurrentResoScalingFactor();
|
||||||
StartCoroutine(tryGetScopeCamera());
|
StartCoroutine(tryGetScopeCamera());
|
||||||
|
|
||||||
if (mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
if (mainPlayer.ProceduralWeaponAnimation.IsAiming)
|
||||||
{
|
{
|
||||||
|
target_scale = 1.0f;
|
||||||
setScopeCameraResolutionScale(scopeCameraResolutionScale.Value);
|
setScopeCameraResolutionScale(scopeCameraResolutionScale.Value);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
float currentScalingFactor = 1.0f;
|
float currentResoScalingFactor = 1.0f;
|
||||||
|
|
||||||
float getCurrentScalingFactor()
|
float getcurrentResoScalingFactor()
|
||||||
{
|
{
|
||||||
if (enableDebug.Value) Logger.LogInfo("Getting current scaling factor:");
|
if (enableDebug.Value) Logger.LogInfo("Getting current scaling factor:");
|
||||||
var graphics = Singleton<SharedGameSettingsClass>.Instance.Graphics.Settings;
|
var graphics = Singleton<SharedGameSettingsClass>.Instance.Graphics.Settings;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user