// Copyright Epic Games, Inc. All Rights Reserved. #pragma once #include "CoreMinimal.h" #if WITH_COTF #include "Serialization/PackageStore.h" #include "CookOnTheFly.h" #include "Misc/ScopeRWLock.h" class FCookOnTheFlyPackageStoreBackend final : public IPackageStoreBackend { public: struct FEntryInfo { EPackageStoreEntryStatus Status = EPackageStoreEntryStatus::None; int32 EntryIndex = INDEX_NONE; }; struct FPackageStats { TAtomic Cooked{ 0 }; TAtomic Failed{ 0 }; }; FCookOnTheFlyPackageStoreBackend(UE::Cook::ICookOnTheFlyServerConnection& InCookOnTheFlyServerConnection); virtual void OnMounted(TSharedRef InContext) override { Context = InContext; } virtual void BeginRead() override; virtual void EndRead() override; bool DoesPackageExist(FPackageId PackageId); virtual EPackageStoreEntryStatus GetPackageStoreEntry(FPackageId PackageId, FName PackageName, FPackageStoreEntry& OutPackageStoreEntry) override; virtual bool GetPackageRedirectInfo(FPackageId PackageId, FName& OutSourcePackageName, FPackageId& OutRedirectedToPackageId) override { return false; } private: void SendCookRequest(TArray> PackageIds); EPackageStoreEntryStatus CreatePackageStoreEntry(const FEntryInfo& EntryInfo, FPackageStoreEntry& OutPackageStoreEntry); void AddPackages(TArray Entries, TArray FailedPackageIds, TArray> PackageIdsAndNames); void OnCookOnTheFlyMessage(const UE::Cook::FCookOnTheFlyMessage& Message); void CheckActivity(); UE::Cook::ICookOnTheFlyServerConnection& CookOnTheFlyServerConnection; TSharedPtr Context; FRWLock EntriesLock; TMap PackageIdToEntryInfo; TChunkedArray PackageEntries; TArray> RequestedPackageIds; FPackageStats PackageStats; const double MaxInactivityTime = 20; const double TimeBetweenWarning = 10; double LastClientActivtyTime = 0; double LastServerActivtyTime = 0; double LastWarningTime = 0; }; #endif // WITH_COTF