-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathclean_cooker_output.ps1
More file actions
138 lines (108 loc) · 5.07 KB
/
clean_cooker_output.ps1
File metadata and controls
138 lines (108 loc) · 5.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
function CleanModAssetCookerOutput (
[string] $sdkPath, # the path to your SDK installation ending in "XCOM 2 War of the Chosen SDK"
[string] $modNameCanonical,
[string[]] $sourceAssetsPaths # Intended for ContentForCook and CollectionMaps, but any folder that has .upk or .umap files will work
) {
# TODO: duplicates the logic in build_common.ps1
$actualTfcSuffix = "_$($modNameCanonical)_DLCTFC_XPACK_"
$cookerOutputPath = [io.path]::combine($sdkPath, 'XComGame', 'Published', 'CookedPCConsole')
if (!(Test-Path $cookerOutputPath)) {
Write-Host "No Published\CookedPCConsole directory - nothing to clean"
return
}
$modMaps = @()
$modPackages = @()
foreach ($assetPath in $sourceAssetsPaths) {
Write-Host "Asset path: $assetPath"
if (!(Test-Path $assetPath)) { continue }
$pathMaps = @(Get-ChildItem -Path $assetPath -Filter '*.umap' -Recurse -Force | Select-Object -ExpandProperty BaseName)
$pathPackages = @(Get-ChildItem -Path $assetPath -Filter '*.upk' -Recurse -Force | Select-Object -ExpandProperty BaseName)
Write-Host "Path maps: $pathMaps"
Write-Host "Path packages: $pathPackages"
$modMaps += $pathMaps
$modPackages += $pathPackages
}
Write-Host "Removing SeekFree maps: $modMaps"
$modMaps | ForEach-Object { Remove-Item -Force -LiteralPath "$cookerOutputPath\$_.upk" -WarningAction SilentlyContinue -ErrorAction SilentlyContinue }
Write-Host "Removing SeekFree standalone packages: $modPackages"
$modPackages | ForEach-Object { Remove-Item -Force -LiteralPath "$cookerOutputPath\$($_)_SF.upk" -WarningAction SilentlyContinue -ErrorAction SilentlyContinue }
Write-Host "Removing TFCs: $actualTfcSuffix"
Remove-Item -Force "$cookerOutputPath\*$actualTfcSuffix.tfc" -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
Write-Host "Removing GuidCache"
Remove-Item -Force "$cookerOutputPath\GuidCache_$modNameCanonical.upk" -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
}
function TryCleanHlCookerOutput (
[string] $sdkPath, # the path to your SDK installation ending in "XCOM 2 War of the Chosen SDK"
[string] $modSrcPath # the path to [mod root]/[mod project]/Src
) {
$nativeScriptPackagesNames = @("XComGame", "Core", "Engine", "GFxUI", "AkAudio", "GameFramework", "UnrealEd", "GFxUIEditor", "IpDrv", "OnlineSubsystemPC", "OnlineSubsystemLive", "OnlineSubsystemSteamworks", "OnlineSubsystemPSN")
$cookerOutputPath = [io.path]::combine($sdkPath, 'XComGame', 'Published', 'CookedPCConsole')
if (!(Test-Path $cookerOutputPath)) {
Write-Host "No Published\CookedPCConsole directory - nothing to clean"
return
}
#################################
### Check if this is a HL mod ###
#################################
if (!(Test-Path $modSrcPath)) {
Write-Host "No Src directory in mod - this is not a HL mod"
return
}
$modPackages = Get-ChildItem $modSrcPath -Directory | Select-Object -ExpandProperty "Name"
$anyNative = $false
foreach ($name in $modPackages)
{
if ($nativeScriptPackagesNames.Contains($name)) {
$anyNative = $true
break
}
}
if (!$anyNative) {
Write-Host $modPackages
Write-Host "Not a highlander mod - skipping cleaning HL cooker output"
return
}
#########################################
### Prepare a list of files to delete ###
#########################################
$filesToRemove = @()
# Native script packages
foreach ($package in $nativeScriptPackagesNames) {
$filesToRemove += "$package.upk"
$filesToRemove += "$package.upk.uncompressed_size"
}
# Startup (unlocalized)
$filesToRemove += "Startup.upk"
$filesToRemove += "Startup.upk.uncompressed_size"
# Startup (localized)
$gameLangs = @("INT", "FRA", "ITA", "DEU", "RUS", "POL", "KOR", "ESN")
foreach ($lang in $gameLangs) {
$filesToRemove += "Startup_LOC_$lang.upk"
$filesToRemove += "Startup_LOC_$lang.upk.uncompressed_size"
}
# TFC files
$tfcGroups = @("CharTextures", "Lighting", "Textures", "World")
foreach ($tfcGroup in $tfcGroups) {
# Unsuffixed
$filesToRemove += "$tfcGroup.tfc"
$filesToRemove += "$tfcGroup-a.tfc"
# Suffixed
$filesToRemove += "${tfcGroup}_XPACK_.tfc"
$filesToRemove += "$tfcGroup-a_XPACK_.tfc"
# TLE
$filesToRemove += "${tfcGroup}_TLE_DLCTFC_XPACK_.tfc"
$filesToRemove += "$tfcGroup-a_TLE_DLCTFC_XPACK_.tfc"
}
# Singletons
$filesToRemove += "GuidCache.upk"
$filesToRemove += "GlobalPersistentCookerData.upk"
$filesToRemove += "PersistentCookerShaderData.bin"
######################
### Actual removal ###
######################
Write-Host "Removing HL cooker output files from $cookerOutputPath"
foreach ($file in $filesToRemove) {
Write-Host " .\$file"
Remove-Item -Force "$cookerOutputPath\$file" -WarningAction SilentlyContinue -ErrorAction SilentlyContinue
}
}