mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
Fix BTR patches to work with new publicized Assembly (!59)
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>
This commit is contained in:
parent
337a0733ae
commit
7f5b068bb8
@ -23,7 +23,7 @@ namespace Aki.Debugging.BTR.Patches
|
||||
_playerInventoryControllerField = AccessTools.Field(typeof(Player), "_inventoryController");
|
||||
_playerQuestControllerField = AccessTools.Field(typeof(Player), "_questController");
|
||||
|
||||
var targetType = typeof(GetActionsClass).GetNestedTypes(PatchConstants.PrivateFlags).Single(IsTargetType);
|
||||
var targetType = AccessTools.FirstInner(typeof(GetActionsClass), IsTargetType);
|
||||
return AccessTools.Method(targetType, "method_2");
|
||||
}
|
||||
|
||||
|
@ -7,6 +7,7 @@ using Comfort.Common;
|
||||
using EFT;
|
||||
using HarmonyLib;
|
||||
using Newtonsoft.Json;
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
@ -22,8 +23,8 @@ namespace Aki.Debugging.BTR.Patches
|
||||
.First(t => t.GetField("Converters", BindingFlags.Static | BindingFlags.Public) != null);
|
||||
_defaultJsonConverters = Traverse.Create(converterClass).Field<JsonConverter[]>("Converters").Value;
|
||||
|
||||
return PatchConstants.EftTypes.Single(x => x.Name == "LocalGame").BaseType // BaseLocalGame
|
||||
.GetMethod("Stop", BindingFlags.FlattenHierarchy | BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
Type baseLocalGameType = PatchConstants.LocalGameType.BaseType;
|
||||
return AccessTools.Method(baseLocalGameType, nameof(LocalGame.Stop));
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
|
@ -12,7 +12,7 @@ namespace Aki.Debugging.BTR.Patches
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(VehicleBase), "ExtractPassengers");
|
||||
return AccessTools.Method(typeof(VehicleBase), nameof(VehicleBase.ExtractPassengers));
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
|
@ -2,6 +2,7 @@
|
||||
using Comfort.Common;
|
||||
using EFT;
|
||||
using EFT.Vehicle;
|
||||
using HarmonyLib;
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
@ -11,8 +12,15 @@ namespace Aki.Debugging.BTR.Patches
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
var bindingFlags = BindingFlags.NonPublic | BindingFlags.Instance;
|
||||
return typeof(Player).GetMethod("BtrInteraction", bindingFlags);
|
||||
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]
|
||||
|
@ -10,7 +10,7 @@ namespace Aki.Debugging.BTR.Patches
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(VehicleBase), "IsDoorsClosed");
|
||||
return AccessTools.Method(typeof(VehicleBase), nameof(VehicleBase.IsDoorsClosed));
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
|
@ -3,6 +3,7 @@ using Aki.Reflection.Patching;
|
||||
using Comfort.Common;
|
||||
using EFT;
|
||||
using EFT.UI;
|
||||
using HarmonyLib;
|
||||
|
||||
namespace Aki.Debugging.BTR.Patches
|
||||
{
|
||||
@ -13,7 +14,7 @@ namespace Aki.Debugging.BTR.Patches
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return typeof(GameWorld).GetMethod(nameof(GameWorld.OnGameStarted));
|
||||
return AccessTools.Method(typeof(GameWorld), nameof(GameWorld.OnGameStarted));
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
|
@ -14,7 +14,7 @@ namespace Aki.Debugging.BTR.Patches
|
||||
private static GameStatus originalStatus;
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
_statusProperty = AccessTools.Property(typeof(AbstractGame), "Status");
|
||||
_statusProperty = AccessTools.Property(typeof(AbstractGame), nameof(AbstractGame.Status));
|
||||
|
||||
return AccessTools.Method(typeof(BTRControllerClass), "method_1");
|
||||
}
|
||||
|
@ -14,11 +14,11 @@ namespace Aki.Debugging.BTR.Patches
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
|
||||
return AccessTools.Method(typeof(TransferItemsInRaidScreen), "Close");
|
||||
return AccessTools.Method(typeof(TransferItemsInRaidScreen), nameof(TransferItemsInRaidScreen.Close));
|
||||
}
|
||||
|
||||
[PatchPostfix]
|
||||
public static async void PatchPostfix(bool ___bool_1)
|
||||
public static void PatchPostfix(bool ___bool_1)
|
||||
{
|
||||
// Didn't extract items
|
||||
if (!___bool_1)
|
||||
@ -35,9 +35,6 @@ namespace Aki.Debugging.BTR.Patches
|
||||
return;
|
||||
}
|
||||
|
||||
// NOTE: This is just here so I remember how to get the items the player transfered
|
||||
gameWorld.BtrController.GetOrAddTransferContainer(player.Profile.Id);
|
||||
|
||||
// Update the trader services information now that we've used this service
|
||||
btrManager.SetServicePurchased(ETraderServiceType.BtrItemsDelivery, BTRUtil.BTRTraderId);
|
||||
BTRUtil.UpdateTraderServices(BTRUtil.BTRTraderId);
|
||||
|
@ -10,7 +10,7 @@ namespace Aki.Debugging.BTR.Patches
|
||||
{
|
||||
protected override MethodBase GetTargetMethod()
|
||||
{
|
||||
return AccessTools.Method(typeof(BTRTurretServer), "Start");
|
||||
return AccessTools.Method(typeof(BTRTurretServer), nameof(BTRTurretServer.Start));
|
||||
}
|
||||
|
||||
[PatchPrefix]
|
||||
|
Loading…
x
Reference in New Issue
Block a user