2024-01-13 22:08:29 +00:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Patching;
|
|
|
|
|
using SPT.Reflection.Utils;
|
2023-10-21 21:44:06 +01:00
|
|
|
|
using EFT.UI.Matchmaker;
|
2024-01-13 22:08:29 +00:00
|
|
|
|
using HarmonyLib;
|
2023-10-21 21:44:06 +01:00
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.Custom.Patches
|
2023-10-21 21:44:06 +01:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Copy over scav-only quests from PMC profile to scav profile on pre-raid screen
|
|
|
|
|
/// Allows scavs to see and complete quests
|
|
|
|
|
/// </summary>
|
2024-07-12 09:32:49 +01:00
|
|
|
|
public class CopyPmcQuestsToPlayerScavPatch : ModulePatch
|
2023-10-21 21:44:06 +01:00
|
|
|
|
{
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
|
return AccessTools.GetDeclaredMethods(typeof(MatchmakerOfflineRaidScreen))
|
|
|
|
|
.SingleCustom(m => m.Name == nameof(MatchmakerOfflineRaidScreen.Show) && m.GetParameters().Length == 1);
|
2023-10-21 21:44:06 +01:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPostfix]
|
2024-08-02 16:57:59 +01:00
|
|
|
|
public static void PatchPostfix()
|
2023-10-21 21:44:06 +01:00
|
|
|
|
{
|
|
|
|
|
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))
|
|
|
|
|
{
|
2024-08-28 12:52:54 +01:00
|
|
|
|
// If quest doesn't exist in scav, add it
|
|
|
|
|
bool any = false;
|
|
|
|
|
foreach (var questInProfile in scavProfile.QuestsData)
|
|
|
|
|
{
|
|
|
|
|
if (questInProfile.Id == quest.Id)
|
|
|
|
|
{
|
|
|
|
|
any = true;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!any)
|
2023-10-21 21:44:06 +01:00
|
|
|
|
{
|
|
|
|
|
scavProfile.QuestsData.Add(quest);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|