diff --git a/project/Aki.Debugging/BTR/Patches/BTRActivateTraderDialogPatch.cs b/project/Aki.Debugging/BTR/Patches/BTRActivateTraderDialogPatch.cs index b99ee01..9d906a8 100644 --- a/project/Aki.Debugging/BTR/Patches/BTRActivateTraderDialogPatch.cs +++ b/project/Aki.Debugging/BTR/Patches/BTRActivateTraderDialogPatch.cs @@ -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"); } diff --git a/project/Aki.Debugging/BTR/Patches/BTREndRaidItemDeliveryPatch.cs b/project/Aki.Debugging/BTR/Patches/BTREndRaidItemDeliveryPatch.cs index f42ad99..991bf83 100644 --- a/project/Aki.Debugging/BTR/Patches/BTREndRaidItemDeliveryPatch.cs +++ b/project/Aki.Debugging/BTR/Patches/BTREndRaidItemDeliveryPatch.cs @@ -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("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] diff --git a/project/Aki.Debugging/BTR/Patches/BTRExtractPassengersPatch.cs b/project/Aki.Debugging/BTR/Patches/BTRExtractPassengersPatch.cs index 594dffc..5b1a73e 100644 --- a/project/Aki.Debugging/BTR/Patches/BTRExtractPassengersPatch.cs +++ b/project/Aki.Debugging/BTR/Patches/BTRExtractPassengersPatch.cs @@ -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] diff --git a/project/Aki.Debugging/BTR/Patches/BTRInteractionPatch.cs b/project/Aki.Debugging/BTR/Patches/BTRInteractionPatch.cs index a672dcf..1ec1a78 100644 --- a/project/Aki.Debugging/BTR/Patches/BTRInteractionPatch.cs +++ b/project/Aki.Debugging/BTR/Patches/BTRInteractionPatch.cs @@ -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] diff --git a/project/Aki.Debugging/BTR/Patches/BTRIsDoorsClosedPatch.cs b/project/Aki.Debugging/BTR/Patches/BTRIsDoorsClosedPatch.cs index c49cd24..eb78f2c 100644 --- a/project/Aki.Debugging/BTR/Patches/BTRIsDoorsClosedPatch.cs +++ b/project/Aki.Debugging/BTR/Patches/BTRIsDoorsClosedPatch.cs @@ -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] diff --git a/project/Aki.Debugging/BTR/Patches/BTRPatch.cs b/project/Aki.Debugging/BTR/Patches/BTRPatch.cs index ae75e74..5e4e14b 100644 --- a/project/Aki.Debugging/BTR/Patches/BTRPatch.cs +++ b/project/Aki.Debugging/BTR/Patches/BTRPatch.cs @@ -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] diff --git a/project/Aki.Debugging/BTR/Patches/BTRPathLoadPatch.cs b/project/Aki.Debugging/BTR/Patches/BTRPathLoadPatch.cs index 5948e87..60e2b4a 100644 --- a/project/Aki.Debugging/BTR/Patches/BTRPathLoadPatch.cs +++ b/project/Aki.Debugging/BTR/Patches/BTRPathLoadPatch.cs @@ -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"); } diff --git a/project/Aki.Debugging/BTR/Patches/BTRTransferItemsPatch.cs b/project/Aki.Debugging/BTR/Patches/BTRTransferItemsPatch.cs index e91a078..c459d7f 100644 --- a/project/Aki.Debugging/BTR/Patches/BTRTransferItemsPatch.cs +++ b/project/Aki.Debugging/BTR/Patches/BTRTransferItemsPatch.cs @@ -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); diff --git a/project/Aki.Debugging/BTR/Patches/BTRTurretDefaultAimingPositionPatch.cs b/project/Aki.Debugging/BTR/Patches/BTRTurretDefaultAimingPositionPatch.cs index a050483..8647efe 100644 --- a/project/Aki.Debugging/BTR/Patches/BTRTurretDefaultAimingPositionPatch.cs +++ b/project/Aki.Debugging/BTR/Patches/BTRTurretDefaultAimingPositionPatch.cs @@ -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]