mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 02:10:45 -05:00
Fix BTR when NVidia Reflex is enabled (!71)
- Before `Application.targetFrameRate` is used in the BTR code, set it to 60. Then set it back afterwards - Remove an unnecessary error from BTRExtractPassengersPatch, not actually an error state All credit goes to Ngst for figuring out that NVidia Reflex was causing the BTR issues Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: SPT-AKI/Modules#71 Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
2d2b4fb78f
commit
c01bd92c78
@ -64,6 +64,8 @@ namespace Aki.Custom
|
|||||||
new BTRTransferItemsPatch().Enable();
|
new BTRTransferItemsPatch().Enable();
|
||||||
new BTREndRaidItemDeliveryPatch().Enable();
|
new BTREndRaidItemDeliveryPatch().Enable();
|
||||||
new BTRDestroyAtRaidEndPatch().Enable();
|
new BTRDestroyAtRaidEndPatch().Enable();
|
||||||
|
new BTRAppFrameratePatches.VehicleBaseInitFpsPatch().Enable();
|
||||||
|
new BTRAppFrameratePatches.VehicleBaseResetFpsPatch().Enable();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
60
project/Aki.Custom/BTR/Patches/BTRAppFrameratePatches.cs
Normal file
60
project/Aki.Custom/BTR/Patches/BTRAppFrameratePatches.cs
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
using Aki.Reflection.Patching;
|
||||||
|
using HarmonyLib;
|
||||||
|
using System.Reflection;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace Aki.Custom.BTR.Patches
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* This class contains two patches because it's the two places that Application.targetFrameRate are used
|
||||||
|
* and I wanted to keep the patches together
|
||||||
|
*
|
||||||
|
* These patches are used to set the target framerate used by vehicle movement calculations to a static
|
||||||
|
* value, avoiding issues caused by enabling NVidia Reflex. These values are then set back after the methods
|
||||||
|
* complete
|
||||||
|
*/
|
||||||
|
public static class BTRAppFrameratePatches
|
||||||
|
{
|
||||||
|
public class VehicleBaseInitFpsPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(VehicleBase), nameof(VehicleBase.Initialization));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPrefix]
|
||||||
|
private static void PrefixPatch(out int __state)
|
||||||
|
{
|
||||||
|
__state = Application.targetFrameRate;
|
||||||
|
Application.targetFrameRate = 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
private static void PostfixPatch(int __state)
|
||||||
|
{
|
||||||
|
Application.targetFrameRate = __state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class VehicleBaseResetFpsPatch : ModulePatch
|
||||||
|
{
|
||||||
|
protected override MethodBase GetTargetMethod()
|
||||||
|
{
|
||||||
|
return AccessTools.Method(typeof(VehicleBase), nameof(VehicleBase.Reset));
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPrefix]
|
||||||
|
private static void PrefixPatch(out int __state)
|
||||||
|
{
|
||||||
|
__state = Application.targetFrameRate;
|
||||||
|
Application.targetFrameRate = 60;
|
||||||
|
}
|
||||||
|
|
||||||
|
[PatchPostfix]
|
||||||
|
private static void PostfixPatch(int __state)
|
||||||
|
{
|
||||||
|
Application.targetFrameRate = __state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,7 +24,6 @@ namespace Aki.Custom.BTR.Patches
|
|||||||
var btrSide = btrManager.LastInteractedBtrSide;
|
var btrSide = btrManager.LastInteractedBtrSide;
|
||||||
if (btrSide == null)
|
if (btrSide == null)
|
||||||
{
|
{
|
||||||
Logger.LogError($"[AKI-BTR] BTRExtractPassengersPatch - btrSide is null");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user