hypertwist/scripts/Invoke-HyperTwistClassicCubeMapAuthoring.ps1
2026-06-12 02:21:20 +00:00

116 lines
4.3 KiB
PowerShell

param(
[string]$ProjectRoot = 'C:\HyperTwist',
[string]$UnrealEditorCmdPath = 'C:\Program Files\Epic Games\UE_5.7\Engine\Binaries\Win64\UnrealEditor-Cmd.exe',
[string]$PythonScriptPath
)
$ErrorActionPreference = 'Stop'
if ([string]::IsNullOrWhiteSpace($PythonScriptPath))
{
$PythonScriptPath = Join-Path $ProjectRoot 'scripts\hypertwist_author_classic_cube_training_maps.py'
}
$UProjectPath = Join-Path $ProjectRoot 'UnrealHyperTwist\UnrealHyperTwist.uproject'
$ClassicMapPath = Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Maps\L_HyperTwist_ClassicTraining.umap'
$FollowAlongMapPath = Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Maps\L_HyperTwist_FollowAlongTraining.umap'
$ExpectedMaterialPaths = @(
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\M_HT_ClassicCubeFaceMaster.uasset'),
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Up.uasset'),
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Down.uasset'),
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Front.uasset'),
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Back.uasset'),
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Left.uasset'),
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Right.uasset'),
(Join-Path $ProjectRoot 'UnrealHyperTwist\Content\HyperTwistTraining\Materials\MI_HT_ClassicCube_Internal.uasset')
)
if (-not (Test-Path $UnrealEditorCmdPath))
{
throw "UnrealEditor-Cmd.exe was not found at '$UnrealEditorCmdPath'."
}
if (-not (Test-Path $UProjectPath))
{
throw "UnrealHyperTwist project file was not found at '$UProjectPath'."
}
if (-not (Test-Path $PythonScriptPath))
{
throw "Classic-cube map authoring script was not found at '$PythonScriptPath'."
}
$NormalizedPythonScriptPath = $PythonScriptPath -replace '\\', '/'
$AuthoredTargets = @(
@{
Label = 'classic'
ExpectedMapPath = $ClassicMapPath
},
@{
Label = 'followalong'
ExpectedMapPath = $FollowAlongMapPath
}
)
foreach ($Target in $AuthoredTargets)
{
$env:HYPERTWIST_CLASSIC_CUBE_MAP_KIND = $Target.Label
$AuthoringStartedAtUtc = [DateTime]::UtcNow
Write-Host "Authoring HyperTwist classic cube training map target '$($Target.Label)' through UnrealEditor-Cmd..."
& $UnrealEditorCmdPath `
$UProjectPath `
"-ExecutePythonScript=$NormalizedPythonScriptPath" `
-unattended `
-nop4 `
-nullrhi `
-nosound `
-nosplash `
-stdout `
-FullStdOutLogOutput `
-log
if ($LASTEXITCODE -ne 0)
{
$FreshMapExists = $false
if (Test-Path $Target.ExpectedMapPath)
{
$FreshMapExists = (Get-Item $Target.ExpectedMapPath).LastWriteTimeUtc -ge $AuthoringStartedAtUtc.AddSeconds(-2)
}
if ($FreshMapExists)
{
Write-Warning "UnrealEditor-Cmd exited with code $LASTEXITCODE after freshly writing '$($Target.ExpectedMapPath)'. Continuing because this host currently crashes during post-save shutdown on the headless authoring lane."
}
else
{
Remove-Item Env:\HYPERTWIST_CLASSIC_CUBE_MAP_KIND -ErrorAction SilentlyContinue
throw "Classic-cube map authoring failed with exit code $LASTEXITCODE."
}
}
if (-not (Test-Path $Target.ExpectedMapPath))
{
Remove-Item Env:\HYPERTWIST_CLASSIC_CUBE_MAP_KIND -ErrorAction SilentlyContinue
throw "Expected authored map was not found at '$($Target.ExpectedMapPath)'."
}
}
Remove-Item Env:\HYPERTWIST_CLASSIC_CUBE_MAP_KIND -ErrorAction SilentlyContinue
foreach ($ExpectedMapPath in @($ClassicMapPath, $FollowAlongMapPath))
{
if (-not (Test-Path $ExpectedMapPath))
{
throw "Expected authored map was not found at '$ExpectedMapPath'."
}
}
foreach ($ExpectedMaterialPath in $ExpectedMaterialPaths)
{
if (-not (Test-Path $ExpectedMaterialPath))
{
throw "Expected classic-cube material asset was not found at '$ExpectedMaterialPath'."
}
}
Write-Host 'Classic-cube authored maps verified.'