#pragma once 

#include "HAL/Runnable.h"




class FPortalStatusChecker : public FRunnable {
public:
	/* Constructor : pass the subsystem and desired check interval(in seconds)
	*
	* @param InSubsystem Should always be the SkyPortalSubsystem
	*/
	FPortalStatusChecker(UEngineSubsystem* InSubsystem, float InCheckInterval);

	// FRunnable interface
	virtual bool Init() override;
	virtual uint32 Run() override;
	virtual void Stop() override;
	virtual void Exit() override;

	UPROPERTY(BlueprintReadOnly)
	FPortalStatusData CurrentStatusData;

	UPROPERTY(BlueprintReadOnly)
	FPortalStatusData OldStatusData;

private:
	// Pointer to the subsystem that contains PortalStatus()
	UEngineSubsystem* SkyPortalSubsystemRef;

	// Time interval (in seconds) for status checking
	float CheckInterval;

	// Thread control variables
	FThreadSafeBool bShouldRun;

	// Helper function to check portal status
	void CheckPortalStatus();
};

