2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Patching;
|
|
|
|
|
using SPT.Reflection.Utils;
|
|
|
|
|
using SPT.SinglePlayer.Utils.InRaid;
|
2024-02-15 08:55:41 +00:00
|
|
|
|
using EFT;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.SinglePlayer.Patches.ScavMode
|
2024-02-15 08:55:41 +00:00
|
|
|
|
{
|
|
|
|
|
/**
|
|
|
|
|
* At the start of a scav raid, copy the PMC encyclopedia to the scav profile, and
|
|
|
|
|
* make sure the scav knows all of the items it has in its inventory
|
|
|
|
|
*/
|
|
|
|
|
internal class ScavEncyclopediaPatch : ModulePatch
|
|
|
|
|
{
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
|
|
|
|
return typeof(GameWorld).GetMethod(nameof(GameWorld.OnGameStarted));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPostfix]
|
|
|
|
|
public static void PatchPostFix()
|
|
|
|
|
{
|
|
|
|
|
if (RaidChangesUtil.IsScavRaid)
|
|
|
|
|
{
|
|
|
|
|
var scavProfile = PatchConstants.BackEndSession.ProfileOfPet;
|
|
|
|
|
var pmcProfile = PatchConstants.BackEndSession.Profile;
|
|
|
|
|
|
|
|
|
|
// Handle old profiles where the scav doesn't have an encyclopedia
|
|
|
|
|
if (scavProfile.Encyclopedia == null)
|
|
|
|
|
{
|
|
|
|
|
scavProfile.Encyclopedia = new Dictionary<string, bool>();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Sync the PMC encyclopedia to the scav profile
|
|
|
|
|
foreach (var item in pmcProfile.Encyclopedia.Where(item => !scavProfile.Encyclopedia.ContainsKey(item.Key)))
|
|
|
|
|
{
|
|
|
|
|
scavProfile.Encyclopedia.Add(item.Key, item.Value);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Auto examine any items the scav doesn't know that are in their inventory
|
|
|
|
|
scavProfile.LearnAll();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|