60 lines
2.3 KiB
Python
60 lines
2.3 KiB
Python
"""Move the Third Person gameplay Blueprints into /Game/Pogo and clean up redirectors.
|
|
|
|
Idempotent. Run headless (editor closed):
|
|
UnrealEditor pogo.uproject -run=pythonscript -script=Scripts/setup_pogo_content.py -nullrhi -unattended -FullStdOutLogOutput
|
|
"""
|
|
import unreal
|
|
|
|
MOVES = {
|
|
"/Game/ThirdPerson/Blueprints/BP_ThirdPersonCharacter": "/Game/Pogo/Blueprints/BP_PogoCharacter",
|
|
"/Game/ThirdPerson/Blueprints/BP_ThirdPersonGameMode": "/Game/Pogo/Blueprints/BP_PogoGameMode",
|
|
"/Game/ThirdPerson/Blueprints/BP_ThirdPersonPlayerController": "/Game/Pogo/Blueprints/BP_PogoPlayerController",
|
|
}
|
|
FOLDERS = ["/Game/Pogo/Blueprints", "/Game/Pogo/Maps", "/Game/Pogo/Characters",
|
|
"/Game/Pogo/Input", "/Game/Pogo/UI", "/Game/Pogo/Materials", "/Game/Pogo/Audio"]
|
|
|
|
eal = unreal.EditorAssetLibrary
|
|
tools = unreal.AssetToolsHelpers.get_asset_tools()
|
|
registry = unreal.AssetRegistryHelpers.get_asset_registry()
|
|
# Commandlets start with a partial registry: rename needs every referencer discovered.
|
|
registry.search_all_assets(True)
|
|
registry.wait_for_completion()
|
|
|
|
|
|
def log(msg):
|
|
unreal.log(f"POGO_SETUP {msg}")
|
|
|
|
|
|
for folder in FOLDERS:
|
|
if not eal.does_directory_exist(folder):
|
|
eal.make_directory(folder)
|
|
log(f"mkdir {folder}")
|
|
|
|
for src, dst in MOVES.items():
|
|
if eal.does_asset_exist(dst):
|
|
log(f"already {dst}")
|
|
continue
|
|
if not eal.does_asset_exist(src):
|
|
log(f"MISSING {src}")
|
|
continue
|
|
ok = eal.rename_asset(src, dst)
|
|
log(f"rename {src} -> {dst} ok={ok}")
|
|
|
|
# Maps that reference the moved Blueprints (World Settings GameMode override, placed actors).
|
|
# Resaving them writes the new paths so the redirectors left behind can be deleted.
|
|
MAPS_TO_RESAVE = ["/Game/ThirdPerson/Lvl_ThirdPerson"]
|
|
for m in MAPS_TO_RESAVE:
|
|
if eal.load_asset(m):
|
|
log(f"resave {m} ok={eal.save_asset(m, only_if_is_dirty=False)}")
|
|
|
|
EXPECTED_PARENT = {
|
|
"BP_PogoCharacter": unreal.PogoCharacter,
|
|
"BP_PogoGameMode": unreal.PogoGameMode,
|
|
"BP_PogoPlayerController": unreal.PogoPlayerController,
|
|
}
|
|
for dst in MOVES.values():
|
|
bp = eal.load_asset(dst)
|
|
name = dst.rsplit("/", 1)[1]
|
|
cdo = unreal.get_default_object(bp.generated_class()) if bp else None
|
|
log(f"CHECK {name} loaded={bp is not None} child_of_{EXPECTED_PARENT[name].__name__}={isinstance(cdo, EXPECTED_PARENT[name])}")
|