feat: 建立关卡工坊并整理项目目录

- 加入 Godot 基础试玩、画风展示和通孔验证场景
- 支持自由放球、多层叠放、墙壁、锥口球洞及固定 +5 m/s 定向加速方块
- 保存 Blender 源资产、模型导出、资源制作脚本和关卡编辑存档逻辑
- 按七类目录归档工程,集中 zsh 启动入口并补充 AGENTS.md 文件索引
- 同步设计规则、依赖锁定、验证报告和目录迁移记录

验证:目录迁移后的资源导入与四个场景加载通过;本次提交前检查暂存内容,未重复运行整套物理测试。
This commit is contained in:
Yanchen
2026-11-16 11:12:21 +08:00
parent 151993e6df
commit 39ff1fd7b4
233 changed files with 147900 additions and 152 deletions
+106
View File
@@ -0,0 +1,106 @@
"""IntoHole native playtest launcher. Use the project's uv-managed environment."""
from __future__ import annotations
import argparse
import json
import os
from pathlib import Path
import shutil
import subprocess
import sys
ROOT = Path(__file__).resolve().parents[2]
GAME = ROOT / 'godot_engine'
VALIDATION = ROOT / 'playtest/artifacts/baseline'
def executable(name: str) -> Path:
override = os.environ.get(f'INTOHOLE_{name.upper()}')
candidates = [override] if override else []
if name == 'blender':
candidates += ['/Applications/Blender.app/Contents/MacOS/Blender', shutil.which('blender')]
else:
candidates += [str(ROOT/'godot_engine/bin/godot'), str(ROOT/'godot_engine/bin/Godot.app/Contents/MacOS/Godot')]
candidates += ['/Applications/Godot.app/Contents/MacOS/Godot', shutil.which('godot')]
for base in [Path('/Applications'), Path.home() / 'Applications']:
if base.exists():
for app in sorted(base.glob('*Godot*.app'), reverse=True):
candidates.append(str(app/'Contents/MacOS/Godot'))
for candidate in candidates:
if candidate and Path(candidate).is_file():
# Blender needs its real bundle path to locate Python/resources.
return Path(candidate).resolve()
raise SystemExit(f'{name} executable not found. Set INTOHOLE_{name.upper()}.')
def run(command: list[str | Path], name: str, live=False) -> None:
VALIDATION.mkdir(parents=True, exist_ok=True)
command = list(map(str, command))
print('Running:', ' '.join(command), flush=True)
if live:
subprocess.run(command, cwd=ROOT, check=True)
else:
log = VALIDATION / f'{name}.log'
with log.open('w') as stream:
result = subprocess.run(command, cwd=ROOT, stdout=stream, stderr=subprocess.STDOUT, timeout=180)
text = log.read_text(errors='replace')
if result.returncode or 'SCRIPT ERROR:' in text:
print(text[-10000:])
raise SystemExit(result.returncode or 1)
print(f'Log: {log}')
def import_assets(godot: Path) -> None:
run([godot, '--headless', '--path', GAME, '--log-file', VALIDATION/'import_engine.log', '--import'], 'import')
def build() -> None:
run([executable('blender'), '--background', '--factory-startup', '--python-exit-code', '1', '--python', ROOT/'assets/collections/baseline/source/build.py'], 'asset_build')
import_assets(executable('godot'))
report = json.loads((VALIDATION/'geometry_report.json').read_text())
for asset in report['assets']:
flag = 'OK' if asset['declared_size_compliant'] else 'PROTOTYPE EXCEEDS DECLARED SIZE'
print(f"{asset['id']}: {asset['size_m']} m — {flag}")
def ensure_imported(godot: Path) -> None:
if not (ROOT/'assets/collections/baseline/catalog.json').exists():
build()
elif not (GAME/'.godot').exists():
import_assets(godot)
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('command', nargs='?', default='play', choices=['doctor','build','play','merge','test','capture'])
args = parser.parse_args()
godot = executable('godot')
if args.command == 'doctor':
print('Python:', sys.executable)
for name in ['blender','godot']:
path = executable(name)
print(f'{name}: {path}')
subprocess.run([str(path), '--version'], check=True)
return
if args.command == 'build':
build()
return
ensure_imported(godot)
common = [godot, '--path', GAME, '--log-file', VALIDATION/'playtest_engine.log']
if args.command == 'play':
run(common+['--scene','res://playtest/baseline/scenes/main.tscn'],'playtest',live=True)
elif args.command == 'merge':
scenarios = json.loads((ROOT/'playtest/baseline/data/scenarios.json').read_text())
index = next(i for i, scenario in enumerate(scenarios) if scenario['id'] == 'dual_merge')
run(common+['--scene','res://playtest/baseline/scenes/main.tscn','--',f'--scenario={index}'],'merge',live=True)
elif args.command == 'test':
import_assets(godot)
run(common+['--headless','--fixed-fps','120','--script','res://playtest/baseline/checks/validate_physics.gd'],'physics_test')
run(common+['--headless','--fixed-fps','120','--script','res://playtest/baseline/checks/validate_playtest.gd'],'playtest_test')
run(common+['--headless','--fixed-fps','120','--script','res://playtest/baseline/checks/validate_merge.gd'],'merge_test')
print('Validation reports:', VALIDATION)
else:
run(common+['--scene','res://playtest/baseline/scenes/main.tscn','--',f'--capture={VALIDATION / "playtest_preview.png"}'],'capture')
print('Preview:', VALIDATION/'playtest_preview.png')
if __name__ == '__main__':
main()
+95
View File
@@ -0,0 +1,95 @@
"""Launch the isolated Railbound-inspired showcase and unlimited level workshop."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
import subprocess
from baseline import executable
ROOT = Path(__file__).resolve().parents[2]
GAME = ROOT / 'godot_engine'
OUTPUT = ROOT / 'playtest/artifacts/styled'
def run(command: list, log_name: str, live: bool = False) -> None:
OUTPUT.mkdir(parents=True, exist_ok=True)
if live:
subprocess.run(list(map(str, command)), cwd=ROOT, check=True)
return
path = OUTPUT / (log_name + '.log')
with path.open('w') as stream:
result = subprocess.run(list(map(str, command)), cwd=ROOT, stdout=stream,
stderr=subprocess.STDOUT, timeout=180)
log = path.read_text(errors='replace')
if result.returncode or 'SCRIPT ERROR:' in log or 'ERROR:' in log:
print(log[-12000:])
raise SystemExit(result.returncode or 1)
print(f'{log_name}: {path}')
def main() -> None:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument('command', nargs='?', default='showcase',
choices=['showcase', 'workshop', 'underpass', 'build', 'test', 'test-underpass', 'capture'])
args = parser.parse_args()
godot = executable('godot')
common = [godot, '--path', GAME, '--log-file', OUTPUT / 'engine.log']
OUTPUT.mkdir(parents=True, exist_ok=True)
scenes = {'workshop': 'res://designer/scenes/workshop.tscn',
'showcase': 'res://playtest/showcase/scenes/showcase.tscn',
'underpass': 'res://playtest/underpass/scenes/underpass.tscn'}
if args.command == 'build':
run([executable('blender'), '--background', '--factory-startup',
'--python-exit-code', '1', '--python', ROOT / 'assets/collections/storybook/source/build.py'], 'build')
# Import only this project's resource changes; never rebuild baseline assets.
run(common + ['--headless', '--import'], 'import')
if args.command == 'build':
return
if args.command == 'test-underpass':
run(common + ['--headless', '--fixed-fps', '120', '--script',
'res://playtest/checks/validate_underpass.gd'], 'underpass_test')
report = json.loads((OUTPUT / 'underpass_report.json').read_text())
print(f"Underpass checks: {report['passed']}; failed: {report['failed']}")
if report['failed']:
raise SystemExit(1)
elif args.command == 'test':
run([executable('blender'), '--background', '--factory-startup',
'--python-exit-code', '1', '--python', ROOT / 'assets/collections/storybook/source/verify.py'], 'source_verification')
run(common + ['--headless', '--fixed-fps', '120', '--script',
'res://playtest/checks/validate_studio.gd'], 'test')
run(common + ['--headless', '--fixed-fps', '120', '--script',
'res://playtest/checks/validate_entities.gd'], 'entities_test')
run(common + ['--headless', '--fixed-fps', '120', '--script',
'res://playtest/checks/validate_stacking.gd'], 'stacking_test')
run(common + ['--headless', '--fixed-fps', '120', '--script',
'res://playtest/checks/validate_ball_placement.gd'], 'ball_placement_test')
run(common + ['--headless', '--fixed-fps', '120', '--script',
'res://playtest/checks/validate_boost.gd'], 'boost_test')
run(common + ['--headless', '--fixed-fps', '120', '--script',
'res://playtest/checks/check_repeat.gd'], 'repeat')
report = json.loads((OUTPUT / 'report.json').read_text())
print(f"Passed: {report['passed']}; failed: {report['failed']}")
entities = json.loads((OUTPUT / 'entities_report.json').read_text())
print(f"Entity and free-ball checks: {entities['passed']}; failed: {entities['failed']}")
stacking = json.loads((OUTPUT / 'stacking_report.json').read_text())
print(f"Stacking and ground checks: {stacking['passed']}; failed: {stacking['failed']}")
ball_placement = json.loads((OUTPUT / 'ball_placement_report.json').read_text())
print(f"Ball placement checks: {ball_placement['passed']}; failed: {ball_placement['failed']}")
boost = json.loads((OUTPUT / 'boost_report.json').read_text())
print(f"Directional boost checks: {boost['passed']}; failed: {boost['failed']}")
repeats = json.loads((OUTPUT / 'repeat_runs.json').read_text())
print(f"Repeated full runs: {repeats['passed']}/30; failed: {repeats['failed']}")
if report['failed']:
raise SystemExit(1)
elif args.command == 'capture':
for scene in ['showcase', 'workshop']:
run(common + ['--scene', scenes[scene], '--',
f'--capture={OUTPUT / (scene + ".png")}'], scene + '_capture')
else:
run(common + ['--scene', scenes[args.command]], args.command, live=True)
if __name__ == '__main__':
main()