2023-11-14 18:49:42 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Patching;
|
2023-11-14 18:49:42 +00:00
|
|
|
|
using Comfort.Common;
|
|
|
|
|
using EFT;
|
|
|
|
|
using HarmonyLib;
|
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.SinglePlayer.Patches.RaidFix
|
2023-11-14 18:49:42 +00:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Patch to remove the Labs Access Card from player inventory upon entering Labs
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class LabsKeycardRemovalPatch : ModulePatch
|
|
|
|
|
{
|
|
|
|
|
private const string LabsAccessCardTemplateId = "5c94bbff86f7747ee735c08f";
|
|
|
|
|
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
|
return AccessTools.Method(typeof(GameWorld), nameof(GameWorld.OnGameStarted));
|
2023-11-14 18:49:42 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPostfix]
|
2024-08-02 16:57:59 +01:00
|
|
|
|
public static void PatchPostfix()
|
2023-11-14 18:49:42 +00:00
|
|
|
|
{
|
|
|
|
|
var gameWorld = Singleton<GameWorld>.Instance;
|
|
|
|
|
var player = gameWorld?.MainPlayer;
|
|
|
|
|
|
|
|
|
|
if (gameWorld == null || player == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (gameWorld.MainPlayer.Location.ToLower() != "laboratory")
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var accessCardItem = player.Profile.Inventory.AllRealPlayerItems.FirstOrDefault(x => x.TemplateId == LabsAccessCardTemplateId);
|
|
|
|
|
|
|
|
|
|
if (accessCardItem == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var inventoryController = Traverse.Create(player).Field<InventoryControllerClass>("_inventoryController").Value;
|
2024-03-21 11:10:37 +00:00
|
|
|
|
InteractionsHandlerClass.Remove(accessCardItem, inventoryController, false, true);
|
2023-11-14 18:49:42 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|