0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/SPT.SinglePlayer/Patches/Progression/HideoutQuestIgnorePatch.cs
2024-05-21 19:10:17 +01:00

36 lines
1.2 KiB
C#

using SPT.Reflection.Patching;
using EFT;
using HarmonyLib;
using System.Reflection;
namespace SPT.SinglePlayer.Patches.Progression
{
/**
* There is no reason to update quest counters when exiting the hideout, so set the
* player's QuestController to null while calling HideoutPlayer.OnGameSessionEnd to
* avoid the quest controller counters from being triggered
*
* Note: Player.OnGameSessionEnd handles the player's quest controller not being set gracefully
*/
public class HideoutQuestIgnorePatch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return AccessTools.Method(typeof(HideoutPlayer), nameof(HideoutPlayer.OnGameSessionEnd));
}
[PatchPrefix]
private static void PatchPrefix(ref AbstractQuestControllerClass __state, ref AbstractQuestControllerClass ____questController)
{
__state = ____questController;
____questController = null;
}
[PatchPostfix]
private static void PatchPostfix(AbstractQuestControllerClass __state, ref AbstractQuestControllerClass ____questController)
{
____questController = __state;
}
}
}