2024-01-08 08:53:35 +00:00
|
|
|
|
using Aki.Debugging.BTR.Utils;
|
|
|
|
|
using Aki.Reflection.Patching;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
using Aki.Reflection.Utils;
|
|
|
|
|
using Comfort.Common;
|
|
|
|
|
using EFT;
|
|
|
|
|
using EFT.UI.Screens;
|
2024-01-08 08:53:35 +00:00
|
|
|
|
using EFT.Vehicle;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
using HarmonyLib;
|
2024-01-08 08:53:35 +00:00
|
|
|
|
using System;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using static EFT.UI.TraderDialogScreen;
|
|
|
|
|
|
|
|
|
|
namespace Aki.Debugging.BTR.Patches
|
|
|
|
|
{
|
|
|
|
|
public class BTRActivateTraderDialogPatch : ModulePatch
|
|
|
|
|
{
|
2024-01-08 08:53:35 +00:00
|
|
|
|
private static FieldInfo _playerInventoryControllerField;
|
|
|
|
|
private static FieldInfo _playerQuestControllerField;
|
|
|
|
|
|
2024-01-05 08:58:15 +00:00
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
2024-01-08 08:53:35 +00:00
|
|
|
|
_playerInventoryControllerField = AccessTools.Field(typeof(Player), "_inventoryController");
|
|
|
|
|
_playerQuestControllerField = AccessTools.Field(typeof(Player), "_questController");
|
|
|
|
|
|
|
|
|
|
var targetType = typeof(GetActionsClass).GetNestedTypes(PatchConstants.PrivateFlags).Single(IsTargetType);
|
2024-01-05 08:58:15 +00:00
|
|
|
|
return AccessTools.Method(targetType, "method_2");
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-08 08:53:35 +00:00
|
|
|
|
private bool IsTargetType(Type type)
|
|
|
|
|
{
|
|
|
|
|
FieldInfo btrField = type.GetField("btr");
|
|
|
|
|
|
|
|
|
|
if (btrField != null && btrField.FieldType == typeof(BTRSide))
|
|
|
|
|
{
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2024-01-05 08:58:15 +00:00
|
|
|
|
[PatchPrefix]
|
|
|
|
|
public static bool PatchPrefix()
|
|
|
|
|
{
|
|
|
|
|
var gameWorld = Singleton<GameWorld>.Instance;
|
|
|
|
|
var player = gameWorld.MainPlayer;
|
|
|
|
|
|
2024-01-08 08:53:35 +00:00
|
|
|
|
InventoryControllerClass inventoryController = _playerInventoryControllerField.GetValue(player) as InventoryControllerClass;
|
|
|
|
|
AbstractQuestControllerClass questController = _playerQuestControllerField.GetValue(player) as AbstractQuestControllerClass;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
|
2024-01-08 08:53:35 +00:00
|
|
|
|
GClass3130 btrDialog = new GClass3130(player.Profile, Profile.TraderInfo.TraderServiceToId[Profile.ETraderServiceSource.Btr], questController, inventoryController, null);
|
2024-01-05 08:58:15 +00:00
|
|
|
|
btrDialog.OnClose += player.UpdateInteractionCast;
|
|
|
|
|
btrDialog.ShowScreen(EScreenState.Queued);
|
|
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|