namespace XFEEDToolBox.Plugin; internal static unsafe partial class Navigation { private static volatile bool healthFlowActive; // ExitOptions is the original, still live game exit submenu. Health // observation stays armed there; flight FlowState remains InGame-only. private static bool HealthFlowNames(bool currentGame,bool currentPause,bool nextGame,bool nextPause,bool currentExitOptions=false,bool nextExitOptions=false) =>(currentGame||currentPause||currentExitOptions)&&(nextGame||nextPause||nextExitOptions); private static bool HealthFlowState(nuint context) { try { var flow=Pointer(context+0x30);if(Pointer(Pointer(flow)+0x20)!=image+FlowAction)return false; var csm=Pointer(flow+0x310);var current=Pointer(Pointer(csm+0x100));var next=Pointer(Pointer(csm+0x108)); return HealthFlowNames(Bytes(current,"InGame\0"u8),Bytes(current,"Pause\0"u8),Bytes(next,"InGame\0"u8),Bytes(next,"Pause\0"u8),Bytes(current,"ExitOptions\0"u8),Bytes(next,"ExitOptions\0"u8)); } catch{return false;} } private static bool HealthFrameReady(bool active,in Snapshot health,ulong now) =>active&&health.healthValid&&health.entity!=0&&health.life!=0&&health.inputRoot!=0&&health.sequence>0 &&now>=health.tick&&now-health.tick<=300; private static uint HealthFlowSelfTest() { uint passed=0; if(HealthFlowNames(true,false,true,false))passed|=1; if(HealthFlowNames(false,true,false,true)&&HealthFlowNames(false,false,false,false,true,true))passed|=2; if(HealthFlowNames(true,false,false,true)&&HealthFlowNames(false,true,true,false) &&HealthFlowNames(false,true,false,false,false,true)&&HealthFlowNames(false,false,false,true,true,false))passed|=4; if(!HealthFlowNames(false,false,true,false)&&!HealthFlowNames(true,false,false,false) &&!HealthFlowNames(false,false,false,false,false,true)&&!HealthFlowNames(false,false,false,false,true,false))passed|=8; var h=new Snapshot{healthValid=true,entity=7,life=0x10000,inputRoot=0x20000,sequence=1,tick=100}; if(HealthFrameReady(true,h,400)&&!HealthFrameReady(true,h,401))passed|=16; if(!HealthFrameReady(false,h,150)&&!HealthFrameReady(true,h,99))passed|=32; var bad=h;bad.entity=0;if(!HealthFrameReady(true,bad,150)){bad=h;bad.healthValid=false;if(!HealthFrameReady(true,bad,150))passed|=64;} bad=h;bad.inputRoot=0;if(!HealthFrameReady(true,bad,150)){bad=h;bad.life=0;if(!HealthFrameReady(true,bad,150))passed|=128;} return passed; } #if PLUGIN_NAVIGATION [UnmanagedCallersOnly(EntryPoint="XFENavigationHealthFlowSelfTest")] internal static uint ExportHealthFlowSelfTest()=>RunTest(HealthFlowSelfTest); #endif }