// © 2024 Long Ly. All rights reserved. Any unauthorized use, reproduction, or distribution of this trademark is strictly prohibited and may result in legal action. #include "Systems/OLSAssetManagerStartupJob.h" #include "OLSLog.h" DEFINE_LOG_CATEGORY(LogOLSAssetManagerStartupJob); TSharedPtr FOLSAssetManagerStartupJob::DoJob() const { const double jobStartTime = FPlatformTime::Seconds(); TSharedPtr handle; OLS_LOG_NO_WORLD(LogOLSAssetManagerStartupJob, Display, TEXT("Startup job \"%s\" starting"), *JobName); JobFunc(*this, handle); if (handle.IsValid()) { handle->BindUpdateDelegate(FStreamableUpdateDelegate::CreateRaw(this, &FOLSAssetManagerStartupJob::UpdateSubstepProgressFromStreamable)); handle->WaitUntilComplete(0.0f, false); handle->BindUpdateDelegate(FStreamableUpdateDelegate()); } OLS_LOG_NO_WORLD(LogOLSAssetManagerStartupJob, Display, TEXT("Startup job \"%s\" took %.2f seconds to complete"), *JobName, FPlatformTime::Seconds() - jobStartTime); return handle; } void FOLSAssetManagerStartupJob::UpdateSubstepProgress(float newProgress) const { SubstepProgressDelegate.ExecuteIfBound(newProgress); } void FOLSAssetManagerStartupJob::UpdateSubstepProgressFromStreamable( TSharedRef streamableHandle) const { if (SubstepProgressDelegate.IsBound()) { // StreamableHandle::GetProgress traverses() a large graph and is quite expensive double now = FPlatformTime::Seconds(); if (LastUpdate - now > 1.0 / 60) { SubstepProgressDelegate.Execute(streamableHandle->GetProgress()); LastUpdate = now; } } }