2024-05-21 19:10:17 +01:00
using SPT.Reflection.Patching ;
2023-03-03 18:52:31 +00:00
using Comfort.Common ;
using EFT ;
using HarmonyLib ;
using System.Linq ;
using System.Reflection ;
2024-05-21 19:10:17 +01:00
namespace SPT.SinglePlayer.Patches.Progression
2023-03-03 18:52:31 +00:00
{
/// <summary>
2024-01-13 22:08:29 +00:00
/// After picking up a quest item, trigger CheckForStatusChange() from the questController to fully update a quest sub-tasks to show (e.g. `survive and extract item from raid` task)
2023-03-03 18:52:31 +00:00
/// </summary>
public class MidRaidQuestChangePatch : ModulePatch
{
protected override MethodBase GetTargetMethod ( )
{
2024-01-13 22:08:29 +00:00
return AccessTools . Method ( typeof ( Profile ) , nameof ( Profile . AddToCarriedQuestItems ) ) ;
2023-03-03 18:52:31 +00:00
}
[PatchPostfix]
private static void PatchPostfix ( )
{
var gameWorld = Singleton < GameWorld > . Instance ;
2024-01-10 11:54:15 +00:00
if ( gameWorld = = null )
2023-03-03 18:52:31 +00:00
{
2024-01-13 22:08:29 +00:00
Logger . LogDebug ( "[MidRaidQuestChangePatch] gameWorld instance was null" ) ;
2024-01-04 17:25:56 +00:00
return ;
}
var player = gameWorld . MainPlayer ;
2024-01-05 09:27:59 +00:00
var questController = Traverse . Create ( player ) . Field < AbstractQuestControllerClass > ( "_questController" ) . Value ;
2024-01-04 17:25:56 +00:00
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
}
}
}
}
}