mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
Should make the BTR work again. I've also switched named methods to use "nameof" where it made sense. And removed an unnecessary method call and fixed an incorrect async on one of my patches Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com> Reviewed-on: SPT-AKI/Modules#59 Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com> Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
57 lines
1.8 KiB
C#
57 lines
1.8 KiB
C#
using Aki.Reflection.Patching;
|
|
using Comfort.Common;
|
|
using EFT;
|
|
using EFT.Vehicle;
|
|
using HarmonyLib;
|
|
using System;
|
|
using System.Reflection;
|
|
|
|
namespace Aki.Debugging.BTR.Patches
|
|
{
|
|
public class BTRInteractionPatch : ModulePatch
|
|
{
|
|
protected override MethodBase GetTargetMethod()
|
|
{
|
|
return AccessTools.FirstMethod(typeof(Player), IsTargetMethod);
|
|
}
|
|
|
|
/**
|
|
* Find the "BtrInteraction" method that takes parameters
|
|
*/
|
|
private bool IsTargetMethod(MethodBase method)
|
|
{
|
|
return method.Name == nameof(Player.BtrInteraction) && method.GetParameters().Length > 0;
|
|
}
|
|
|
|
[PatchPostfix]
|
|
public static void PatchPostfix(object __instance, BTRSide btr, byte placeId, EInteractionType interaction)
|
|
{
|
|
var gameWorld = Singleton<GameWorld>.Instance;
|
|
var player = (Player)__instance;
|
|
var btrManager = gameWorld.GetComponent<BTRManager>();
|
|
|
|
try
|
|
{
|
|
var interactionBtrPacket = btr.GetInteractWithBtrPacket(placeId, interaction);
|
|
player.UpdateInteractionCast();
|
|
|
|
if (interactionBtrPacket.HasInteraction)
|
|
{
|
|
BTRView btrView = gameWorld.BtrController.BtrView;
|
|
if (btrView == null)
|
|
{
|
|
throw new NullReferenceException("BtrView not found");
|
|
}
|
|
|
|
btrManager.OnPlayerInteractDoor(interactionBtrPacket);
|
|
btrView.Interaction(player, interactionBtrPacket);
|
|
}
|
|
}
|
|
catch (Exception ex19)
|
|
{
|
|
UnityEngine.Debug.LogException(ex19);
|
|
}
|
|
}
|
|
}
|
|
}
|