void FChunkManifestGenerator::GenerateChunkManifestForPackage(const FName& PackageFName, const FString& PackagePathName, const FString& SandboxFilename, const FString& LastLoadedMapName, FSandboxPlatformFile* InSandboxFile) { TArray<int32> TargetChunks; TArray<int32> ExistingChunkIDs; if (!bGenerateChunks) { TargetChunks.AddUnique(0); ExistingChunkIDs.AddUnique(0); } if (bGenerateChunks) { // Collect all chunk IDs associated with this package from the asset registry TArray<int32> RegistryChunkIDs = GetAssetRegistryChunkAssignments(PackageFName); ExistingChunkIDs = GetExistingPackageChunkAssignments(PackageFName); // Try to call game-specific delegate to determine the target chunk ID // FString Name = Package->GetPathName(); if (FGameDelegates::Get().GetAssignStreamingChunkDelegate().IsBound()) { FGameDelegates::Get().GetAssignStreamingChunkDelegate().ExecuteIfBound(PackagePathName, LastLoadedMapName, RegistryChunkIDs, ExistingChunkIDs, TargetChunks); } else { //Take asset registry assignments and existing assignments TargetChunks.Append(RegistryChunkIDs); TargetChunks.Append(ExistingChunkIDs); } } bool bAssignedToChunk = false; // if the delegate requested a specific chunk assignment, add them package to it now. for (const auto& PackageChunk : TargetChunks) { AddPackageToManifest(SandboxFilename, PackageFName, PackageChunk); bAssignedToChunk = true; } // If the delegate requested to remove the package from any chunk, remove it now for (const auto& PackageChunk : ExistingChunkIDs) { if (!TargetChunks.Contains(PackageChunk)) { RemovePackageFromManifest(PackageFName, PackageChunk); } } }
void FChunkManifestGenerator::AddPackageToChunkManifest(UPackage* Package, const FString& SandboxFilename, const FString& LastLoadedMapName, FSandboxPlatformFile* InSandboxFile) { TArray<int32> TargetChunks; TArray<int32> ExistingChunkIDs; if (!bGenerateChunks) { TargetChunks.AddUnique(0); ExistingChunkIDs.AddUnique(0); } auto PackageFName = Package->GetFName(); if (bGenerateChunks) { // Try to determine if this package has been loaded as a result of loading a map package. FString MapThisAssetWasLoadedWith; if (!LastLoadedMapName.IsEmpty()) { if (AssetsLoadedWithLastPackage.Contains(PackageFName)) { MapThisAssetWasLoadedWith = LastLoadedMapName; } } // Collect all chunk IDs associated with this package from the asset registry TArray<int32> RegistryChunkIDs = GetAssetRegistryChunkAssignments(Package); ExistingChunkIDs = GetExistingPackageChunkAssignments(PackageFName); // Try to call game-specific delegate to determine the target chunk ID FString Name = Package->GetPathName(); if (FGameDelegates::Get().GetAssignStreamingChunkDelegate().IsBound()) { FGameDelegates::Get().GetAssignStreamingChunkDelegate().ExecuteIfBound(Name, MapThisAssetWasLoadedWith, RegistryChunkIDs, ExistingChunkIDs, TargetChunks); } else { //Take asset registry assignments and existing assignments TargetChunks.Append(RegistryChunkIDs); TargetChunks.Append(ExistingChunkIDs); } } NotifyPackageWasCooked(SandboxFilename, PackageFName); bool bAssignedToChunk = false; // if the delegate requested a specific chunk assignment, add them package to it now. for (const auto& PackageChunk : TargetChunks) { AddPackageToManifest(SandboxFilename, PackageFName, PackageChunk); bAssignedToChunk = true; } // If the delegate requested to remove the package from any chunk, remove it now for (const auto& PackageChunk : ExistingChunkIDs) { if (!TargetChunks.Contains(PackageChunk)) { RemovePackageFromManifest(PackageFName, PackageChunk); } } if (!bAssignedToChunk) { NotifyPackageWasNotAssigned(SandboxFilename, PackageFName); } }