0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 05:30:43 -05:00
modules/project/SPT.Custom/Patches/MergeScavPmcQuestsOnInventoryLoadPatch.cs
DrakiaXYZ 3ac4f1e4bb Resolve exception caused by opening inventory preview during raid loading (!174)
Co-authored-by: DrakiaXYZ <565558+TheDgtl@users.noreply.github.com>
Reviewed-on: SPT/Modules#174
Co-authored-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
Co-committed-by: DrakiaXYZ <drakiaxyz@noreply.dev.sp-tarkov.com>
2024-11-05 18:44:04 +00:00

40 lines
1.2 KiB
C#

using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using SPT.Reflection.Patching;
using SPT.Reflection.Utils;
using Comfort.Common;
using EFT;
using EFT.UI.DragAndDrop;
using HarmonyLib;
namespace SPT.Custom.Patches
{
public class MergeScavPmcQuestsOnInventoryLoadPatch : ModulePatch
{
/// <summary>
/// This patch runs both in raid and on main Menu everytime the inventory is loaded
/// Aim is to let Scavs see what required items your PMC needs for quests like Live using the FiR status
/// </summary>
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(QuestItemViewPanel), nameof(QuestItemViewPanel.smethod_0));
}
[PatchPrefix]
public static void PatchPreFix(ref IEnumerable<QuestDataClass> quests)
{
var gameWorld = Singleton<GameWorld>.Instance;
if (gameWorld != null)
{
if (gameWorld.MainPlayer?.Location != "hideout" && gameWorld.MainPlayer?.Fraction == ETagStatus.Scav)
{
var pmcQuests = PatchConstants.BackEndSession.Profile.QuestsData;
var scavQuests = PatchConstants.BackEndSession.ProfileOfPet.QuestsData;
quests = pmcQuests.Concat(scavQuests);
}
}
}
}
}