2023-03-03 18:52:31 +00:00
using Aki.Reflection.Patching ;
using Comfort.Common ;
using EFT ;
using HarmonyLib ;
using System.Linq ;
using System.Reflection ;
namespace Aki.SinglePlayer.Patches.Progression
{
/// <summary>
/// After picking up a quest item, trigger CheckForStatusChange() from the questController to fully update a quest subtasks to show (e.g. `survive and extract item from raid` task)
/// </summary>
public class MidRaidQuestChangePatch : ModulePatch
{
protected override MethodBase GetTargetMethod ( )
{
return typeof ( Profile ) . GetMethod ( "AddToCarriedQuestItems" , BindingFlags . Public | BindingFlags . Instance ) ;
}
[PatchPostfix]
private static void PatchPostfix ( )
{
var gameWorld = Singleton < GameWorld > . Instance ;
if ( gameWorld ! = null )
{
2024-01-04 17:25:56 +00:00
Logger . LogDebug ( $"[MidRaidQuestChangePatch] gameWorld instance was null" ) ;
return ;
}
var player = gameWorld . MainPlayer ;
2023-03-03 18:52:31 +00:00
2024-01-04 17:25:56 +00:00
var questController = Traverse . Create ( player ) . Field < GClass3201 > ( "_questController" ) . Value ;
if ( questController ! = null )
{
foreach ( var quest in questController . Quests . ToList ( ) )
2023-03-03 18:52:31 +00:00
{
2024-01-04 17:25:56 +00:00
quest . CheckForStatusChange ( true , true ) ;
2023-03-03 18:52:31 +00:00
}
}
}
}
}