SkyPortal-plugin/Source/SkyPortal/Private/SkyPortalRunner.cpp

59 lines
1.4 KiB
C++
Raw Normal View History

2024-09-24 22:17:52 +00:00
#include "SkyPortalRunner.h"
2024-09-25 15:33:25 +00:00
#include "SkyPortalSubsystem.h"
2024-09-24 22:17:52 +00:00
2024-09-25 15:33:25 +00:00
FPortalStatusChecker::FPortalStatusChecker(UEngineSubsystem* InSubsystem, float InCheckInterval)
: SkyPortalSubsystemRef(InSubsystem), CheckInterval(InCheckInterval), bShouldRun(true)
2024-09-25 11:47:11 +00:00
{
}
bool FPortalStatusChecker::Init()
{
// Initialization logic, if necessary (e.g., logging)
return true;
}
uint32 FPortalStatusChecker::Run()
{
// Main loop of the thread, runs until Stop() is called
while (bShouldRun)
{
// Check the portal status
CheckPortalStatus();
// Sleep for the specified interval
FPlatformProcess::Sleep(CheckInterval);
}
return 0; // Exit code for the thread
}
void FPortalStatusChecker::Stop()
{
// Signal the thread to stop running
bShouldRun = false;
}
void FPortalStatusChecker::Exit()
{
// Cleanup after the thread has stopped
}
void FPortalStatusChecker::CheckPortalStatus()
{
// Ensure the subsystem is valid
2024-09-25 15:33:25 +00:00
if (SkyPortalSubsystemRef && Cast<USkyPortalSubsystem>(SkyPortalSubsystemRef))
2024-09-25 11:47:11 +00:00
{
2024-09-25 15:33:25 +00:00
USkyPortalIO* PortalHandleRef = Cast<USkyPortalSubsystem>(SkyPortalSubsystemRef)->PortalHandle;
2024-09-25 11:47:11 +00:00
UE_LOG(LogSkyportalIO, Verbose, TEXT("Check portal"));
2024-09-25 15:33:25 +00:00
if (PortalHandleRef && PortalHandleRef->bPortalReady)
{
// Call the subsystem function to get portal status
2024-09-25 11:47:11 +00:00
2024-09-25 15:33:25 +00:00
Cast<USkyPortalSubsystem>(SkyPortalSubsystemRef);
2024-09-25 11:47:11 +00:00
2024-09-25 15:33:25 +00:00
// Do something with the status (log, notify, etc.)
UE_LOG(LogSkyportalIO, Verbose, TEXT("Portal Status:"));
}
2024-09-25 11:47:11 +00:00
}
}