0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 08:30:45 -05:00
modules/project/SPT.Custom/Patches/ScavQuestPatch.cs

39 lines
1.3 KiB
C#
Raw Normal View History

using System.Linq;
using System.Reflection;
2024-05-21 19:10:17 +01:00
using SPT.Reflection.Patching;
using SPT.Reflection.Utils;
using EFT.UI.Matchmaker;
using HarmonyLib;
2024-05-21 19:10:17 +01:00
namespace SPT.Custom.Patches
{
/// <summary>
/// Copy over scav-only quests from PMC profile to scav profile on pre-raid screen
/// Allows scavs to see and complete quests
/// </summary>
public class ScavQuestPatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.GetDeclaredMethods(typeof(MatchmakerOfflineRaidScreen))
.SingleCustom(m => m.Name == nameof(MatchmakerOfflineRaidScreen.Show) && m.GetParameters().Length == 1);
}
[PatchPostfix]
private static void PatchPostfix()
{
var pmcProfile = PatchConstants.BackEndSession.Profile;
var scavProfile = PatchConstants.BackEndSession.ProfileOfPet;
// Iterate over all quests on pmc that are flagged as being for scavs
foreach (var quest in pmcProfile.QuestsData.Where(x => x.Template?.PlayerGroup == EFT.EPlayerGroup.Scav))
{
// If quest doesnt exist in scav, add it
if (!scavProfile.QuestsData.Any(x => x.Id == quest.Id))
{
scavProfile.QuestsData.Add(quest);
}
}
}
}
}