mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
- 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>
61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|