2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Patching;
|
2024-01-04 08:51:06 +00:00
|
|
|
|
using Comfort.Common;
|
|
|
|
|
using EFT;
|
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.Custom.BTR.Patches
|
2024-01-04 08:51:06 +00:00
|
|
|
|
{
|
2024-01-23 08:47:09 +00:00
|
|
|
|
public class BTRIsDoorsClosedPath : ModulePatch
|
2024-01-04 08:51:06 +00:00
|
|
|
|
{
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
2024-01-14 09:05:13 +00:00
|
|
|
|
return AccessTools.Method(typeof(VehicleBase), nameof(VehicleBase.IsDoorsClosed));
|
2024-01-04 08:51:06 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPrefix]
|
2024-01-20 09:20:32 +00:00
|
|
|
|
private static bool PatchPrefix(ref bool __result)
|
2024-01-04 08:51:06 +00:00
|
|
|
|
{
|
2024-01-25 08:52:33 +00:00
|
|
|
|
var gameWorld = Singleton<GameWorld>.Instance;
|
|
|
|
|
if (gameWorld == null)
|
|
|
|
|
{
|
2024-05-20 13:51:52 +01:00
|
|
|
|
Logger.LogError("[SPT-BTR] BTRIsDoorsClosedPatch - GameWorld is null");
|
2024-01-25 08:52:33 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var serverSideBTR = gameWorld.BtrController.BtrVehicle;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
if (serverSideBTR == null)
|
2024-01-04 08:51:06 +00:00
|
|
|
|
{
|
2024-05-20 13:51:52 +01:00
|
|
|
|
Logger.LogError("[SPT-BTR] BTRIsDoorsClosedPatch - serverSideBTR is null");
|
2024-01-04 08:51:06 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-05 08:58:15 +00:00
|
|
|
|
if (serverSideBTR.LeftSideState == 0 && serverSideBTR.RightSideState == 0)
|
2024-01-04 08:51:06 +00:00
|
|
|
|
{
|
|
|
|
|
__result = true;
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|