0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/SPT.Custom/BTR/Patches/BTRIsDoorsClosedPatch.cs
2024-05-21 19:10:17 +01:00

43 lines
1.2 KiB
C#

using SPT.Reflection.Patching;
using Comfort.Common;
using EFT;
using HarmonyLib;
using System.Reflection;
namespace SPT.Custom.BTR.Patches
{
public class BTRIsDoorsClosedPath : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(VehicleBase), nameof(VehicleBase.IsDoorsClosed));
}
[PatchPrefix]
private static bool PatchPrefix(ref bool __result)
{
var gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld == null)
{
Logger.LogError("[SPT-BTR] BTRIsDoorsClosedPatch - GameWorld is null");
return true;
}
var serverSideBTR = gameWorld.BtrController.BtrVehicle;
if (serverSideBTR == null)
{
Logger.LogError("[SPT-BTR] BTRIsDoorsClosedPatch - serverSideBTR is null");
return true;
}
if (serverSideBTR.LeftSideState == 0 && serverSideBTR.RightSideState == 0)
{
__result = true;
return false;
}
return true;
}
}
}