2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Patching;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
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.Reflection;
|
2024-07-04 14:11:11 +00:00
|
|
|
|
using BTRDialog = EFT.UI.TraderDialogScreen.BTRDialogClass;
|
2024-01-05 08:58:15 +00:00
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.Custom.BTR.Patches
|
2024-01-05 08:58:15 +00:00
|
|
|
|
{
|
2024-01-23 08:47:09 +00:00
|
|
|
|
public class BTRActivateTraderDialogPatch : ModulePatch
|
2024-01-05 08:58:15 +00:00
|
|
|
|
{
|
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");
|
|
|
|
|
|
2024-01-14 09:05:13 +00:00
|
|
|
|
var targetType = AccessTools.FirstInner(typeof(GetActionsClass), 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");
|
|
|
|
|
|
2024-04-05 08:10:37 +00:00
|
|
|
|
return btrField != null && btrField.FieldType == typeof(BTRSide);
|
2024-01-08 08:53:35 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-01-05 08:58:15 +00:00
|
|
|
|
[PatchPrefix]
|
2024-01-20 09:20:32 +00:00
|
|
|
|
private static bool PatchPrefix()
|
2024-01-05 08:58:15 +00:00
|
|
|
|
{
|
|
|
|
|
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-24 11:08:16 +00:00
|
|
|
|
BTRDialog btrDialog = new BTRDialog(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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|