@@ -211,6 +211,12 @@ class BuildProject {
211211 Write-Host " No umaps to cook"
212212 $this.contentOptions | Add-Member - MemberType NoteProperty - Name ' umapsToCook' - Value @ ()
213213 }
214+
215+ if (($this.contentOptions.PSobject.Properties | ForEach-Object {$_.Name }) -notcontains " collectionMapsToCook" )
216+ {
217+ Write-Host " No collection maps to cook"
218+ $this.contentOptions | Add-Member - MemberType NoteProperty - Name ' collectionMapsToCook' - Value @ ()
219+ }
214220 }
215221
216222 [void ]_CopyModToSdk() {
@@ -516,6 +522,7 @@ class BuildProject {
516522
517523 $this.defaultEnginePath = " $ ( $this.sdkPath ) /XComGame/Config/DefaultEngine.ini"
518524 $this.defaultEngineContentOriginal = Get-Content $this.defaultEnginePath | Out-String
525+ $engineIniAdditions = $this._BuildEngineIniAdditionsFromContentOptions ()
519526
520527 $cookOutputDir = [io.path ]::combine($this.sdkPath , ' XComGame' , ' Published' , ' CookedPCConsole' )
521528 $sdkModsContentDir = [io.path ]::combine($this.sdkPath , ' XComGame' , ' Content' , ' Mods' )
@@ -561,31 +568,41 @@ class BuildProject {
561568 }
562569 }
563570
571+ # Prepare the list of maps to cook
572+ $mapsToCook = $this.contentOptions.umapsToCook
573+
574+ # Collection maps also need the actual empty umap file created
575+ foreach ($mapDef in $this.contentOptions.collectionMapsToCook ) {
576+ $mapsToCook += $mapDef.name
577+ Copy-Item " $global :buildCommonSelfPath \EmptyMap.umap" " $ ( $this.stagingPath ) \ContentForCook\$ ( $mapDef.name ) .umap"
578+ }
579+
564580 # Backup the DefaultEngine.ini
565581 Copy-Item $this.defaultEnginePath " $ ( $this.sdkPath ) /XComGame/Config/DefaultEngine.ini.bak_PRE_ASSET_COOKING"
566582
583+ # This try block needs to be kept as small as possible as it puts the SDK into a (temporary) invalid state
567584 try {
568585 # Redirect all the cook output to our local cache
569586 # This allows us to not recook everything when switching between projects (e.g. CHL)
570587 New-Junction $cookOutputDir $projectCookCacheDir
571588
572589 # "Inject" our assets into the SDK to make them visible to the cooker
573590 Remove-Item $sdkModsContentDir
574- New-Junction $sdkModsContentDir " $ ( $this.modSrcRoot ) \ContentForCook"
591+ New-Junction $sdkModsContentDir " $ ( $this.stagingPath ) \ContentForCook"
575592
576593 if ($firstModCook ) {
577594 # First do a cook without our assets since gfxCommon.upk still get included in the cook, polluting the TFCs, depsite the config hacks
578595
579596 Write-Host " Running first time mod assets cook"
580- $this._InvokeAssetCooker (@ (), @ () )
597+ $this._InvokeAssetCooker (@ (), " " )
581598
582599 # Now delete the polluted TFCs
583600 Get-ChildItem - Path $projectCookCacheDir - Filter " *$ ( $this.assetsCookTfcSuffix ) .tfc" | Remove-Item
584601
585602 Write-Host " First time cook done, proceeding with normal"
586603 }
587604
588- $this._InvokeAssetCooker ($this .contentOptions.packagesToMakeSF , $this .contentOptions.umapsToCook )
605+ $this._InvokeAssetCooker ($mapsToCook , $engineIniAdditions )
589606 }
590607 finally {
591608 Write-Host " Cleaning up the asset cooking hacks"
@@ -649,9 +666,9 @@ class BuildProject {
649666 Get-ChildItem - Path $projectCookCacheDir - Filter " *$ ( $this.assetsCookTfcSuffix ) .tfc" | Copy-Item - Destination $stagingCookedDir
650667
651668 # Copy over the maps
652- for ($i = 0 ; $i -lt $this .contentOptions.umapsToCook .Length ; $i ++ )
669+ for ($i = 0 ; $i -lt $mapsToCook .Length ; $i ++ )
653670 {
654- $umap = $this .contentOptions.umapsToCook [$i ];
671+ $umap = $mapsToCook [$i ];
655672 Copy-Item " $projectCookCacheDir \$umap .upk" - Destination $stagingCookedDir
656673 }
657674
@@ -671,7 +688,29 @@ class BuildProject {
671688 Write-Host " Assets cook completed"
672689 }
673690
674- [void ]_InvokeAssetCooker ([string []] $packagesToMakeSF , [string []] $umapsToCook ) {
691+ [string ]_BuildEngineIniAdditionsFromContentOptions () {
692+ $lines = @ ()
693+
694+ # SF Standalone packages
695+ $lines += " [Engine.PackagesToAlwaysCook]"
696+ foreach ($package in $this.contentOptions.packagesToMakeSF ) {
697+ $lines += " +SeekFreePackage=$package "
698+ }
699+
700+ # Collection maps
701+ $lines += " [Engine.PackagesToForceCookPerMap]"
702+ foreach ($mapDef in $this.contentOptions.collectionMapsToCook ) {
703+ $lines += " +Map=$ ( $mapDef.name ) "
704+
705+ foreach ($package in $mapDef.packages ) {
706+ $lines += " +Package=$package "
707+ }
708+ }
709+
710+ return $lines -join " `n "
711+ }
712+
713+ [void ]_InvokeAssetCooker ([string []] $umapsToCook , [string ] $engineIniAdditions ) {
675714 $defaultEngineContentNew = $this.defaultEngineContentOriginal
676715 $defaultEngineContentNew = " $defaultEngineContentNew `n ; HACKS FOR MOD ASSETS COOKING - $ ( $this.modNameCanonical ) "
677716
@@ -680,14 +719,11 @@ class BuildProject {
680719 $defaultEngineContentNew = " $defaultEngineContentNew `n [Engine.ScriptPackages]`n !EngineNativePackages=Empty`n !NetNativePackages=Empty`n !NativePackages=Empty"
681720 $defaultEngineContentNew = " $defaultEngineContentNew `n [Engine.StartupPackages]`n !Package=Empty"
682721 $defaultEngineContentNew = " $defaultEngineContentNew `n [Engine.PackagesToAlwaysCook]`n !SeekFreePackage=Empty"
722+
723+ # Add our stuff - must come after the !s above
724+ $defaultEngineContentNew = " $defaultEngineContentNew `n $engineIniAdditions "
683725
684- # Add our standalone seek free packages
685- for ($i = 0 ; $i -lt $packagesToMakeSF.Length ; $i ++ )
686- {
687- $package = $packagesToMakeSF [$i ];
688- $defaultEngineContentNew = " $defaultEngineContentNew `n +SeekFreePackage=$package "
689- }
690-
726+ # Ini ready
691727 $defaultEngineContentNew | Set-Content $this.defaultEnginePath - NoNewline;
692728
693729 # Invoke cooker
0 commit comments