0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/Aki.Custom/BTR/Patches/BTRTurretCanShootPatch.cs
Arys eb443aaa5e Fixed BTR movement speed being tied to a static framerate (!73)
By multiplying `moveSpeed` by `Time.deltaTime` in `BTRVehicle.Update()`, it prevents the BTR movement from desyncing, and possibly going faster or slower than expected.

Reviewed-on: SPT-AKI/Modules#73
Co-authored-by: Arys <arys@noreply.dev.sp-tarkov.com>
Co-committed-by: Arys <arys@noreply.dev.sp-tarkov.com>
2024-01-30 09:37:33 +00:00

30 lines
1023 B
C#

using Aki.Reflection.Patching;
using EFT.Vehicle;
using HarmonyLib;
using System.Reflection;
using UnityEngine;
namespace Aki.Custom.BTR.Patches
{
public class BTRTurretCanShootPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(BTRTurretServer), nameof(BTRTurretServer.method_1));
}
[PatchPrefix]
private static bool PatchPrefix(BTRTurretServer __instance, Transform ___defaultTargetTransform)
{
bool flag = __instance.targetTransform != null && __instance.targetTransform != ___defaultTargetTransform;
bool flag2 = __instance.method_2();
bool flag3 = __instance.targetPosition != __instance.defaultAimingPosition;
var isCanShootProperty = AccessTools.DeclaredProperty(__instance.GetType(), nameof(__instance.IsCanShoot));
isCanShootProperty.SetValue(__instance, (flag || flag3) && flag2);
return false;
}
}
}