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
+3
View File
@@ -0,0 +1,3 @@
#!/bin/zsh
set -euo pipefail
exec "${0:A:h}/playtest.zsh" "$@"
+25
View File
@@ -0,0 +1,25 @@
# 启动与执行脚本
从根目录执行;脚本也支持从其他工作目录调用。
| 入口 | 用途 |
| --- | --- |
| [workshop.zsh](workshop.zsh) | 关卡工坊。 |
| [showcase.zsh](showcase.zsh) | 展示关卡。 |
| [underpass.zsh](underpass.zsh) | 通孔实验。 |
| [playtest.zsh](playtest.zsh) | 早期试玩。 |
| [run.zsh](run.zsh) | 统一入口;`--help` 查看操作名。 |
| [asset.zsh](asset.zsh) | 指定资产或整套资产的制作/检查入口;实际制作代码位于 `assets/`。 |
四个首字母大写的 `.command` 文件保留双击使用方式,只转调 zsh。Python 调度工具在 [python](python):`studio.py` 管理工坊和当前实验,`baseline.py` 管理早期实验并提供引擎定位。新入口优先 bash/zsh,不放回根目录。
```sh
./scripts/workshop.zsh
./scripts/run.zsh merge
./scripts/run.zsh doctor
./scripts/asset.zsh directional_boost
```
按需构建、检查和截图:`./scripts/run.zsh build`、`test`、`test-underpass`、`capture`;基础集合使用 `baseline-build` / `baseline-test`。普通启动不执行整套实验,仅导入变化的资源。
使用已有 `.venv`,不调整 uv 配置。引擎与 Blender 可分别用 `INTOHOLE_GODOT`、`INTOHOLE_BLENDER` 指定。日志写入 `playtest/artifacts/`。
+3
View File
@@ -0,0 +1,3 @@
#!/bin/zsh
set -euo pipefail
exec "${0:A:h}/showcase.zsh" "$@"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/zsh
set -euo pipefail
exec "${0:A:h}/underpass.zsh" "$@"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/zsh
set -euo pipefail
exec "${0:A:h}/workshop.zsh" "$@"
+26
View File
@@ -0,0 +1,26 @@
#!/bin/zsh
set -euo pipefail
INTOHOLE_ROOT="${0:A:h:h}"
cd "$INTOHOLE_ROOT"
case "${1:---help}" in
-h|--help)
print 'Usage: ./scripts/asset.zsh [straight|turn_cw|turn_ccw|gentle|steep|y_merge|iron_ball|wall|directional_boost|goal_hole|all|baseline|verify]'
exit 0 ;;
straight|turn_cw|turn_ccw|gentle|steep|y_merge) INTOHOLE_BUILD="assets/chutes/$1/source/build.py" ;;
iron_ball) INTOHOLE_BUILD='assets/balls/iron_ball/source/build.py' ;;
wall|directional_boost) INTOHOLE_BUILD="assets/blocks/$1/source/build.py" ;;
goal_hole) INTOHOLE_BUILD='assets/goals/goal_hole/source/build.py' ;;
all) INTOHOLE_BUILD='assets/collections/storybook/source/build.py' ;;
baseline) INTOHOLE_BUILD='assets/collections/baseline/source/build.py' ;;
verify) INTOHOLE_BUILD='assets/collections/storybook/source/verify.py' ;;
*) print -u2 "Unknown asset: $1"; exit 2 ;;
esac
INTOHOLE_BLENDER_BIN="${INTOHOLE_BLENDER:-/Applications/Blender.app/Contents/MacOS/Blender}"
if [[ ! -x "$INTOHOLE_BLENDER_BIN" ]]; then
INTOHOLE_BLENDER_BIN="$(command -v blender || true)"
fi
if [[ -z "$INTOHOLE_BLENDER_BIN" || ! -x "$INTOHOLE_BLENDER_BIN" ]]; then
print -u2 'Blender not found. Set INTOHOLE_BLENDER to its executable.'
exit 1
fi
exec "$INTOHOLE_BLENDER_BIN" --background --factory-startup --python-exit-code 1 --python "$INTOHOLE_ROOT/$INTOHOLE_BUILD"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/zsh
set -euo pipefail
exec "${0:A:h}/run.zsh" playtest "$@"
+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()
+26
View File
@@ -0,0 +1,26 @@
#!/bin/zsh
set -euo pipefail
INTOHOLE_ROOT="${0:A:h:h}"
cd "$INTOHOLE_ROOT"
export PYTHONDONTWRITEBYTECODE=1
case "${1:-workshop}" in
-h|--help)
print 'Usage: ./scripts/run.zsh [workshop|showcase|underpass|playtest|merge|doctor|build|test|test-underpass|capture|baseline-build|baseline-test]'
exit 0 ;;
esac
INTOHOLE_ACTION="${1:-workshop}"
if (( $# )); then shift; fi
INTOHOLE_PYTHON="$INTOHOLE_ROOT/.venv/bin/python"
if [[ ! -x "$INTOHOLE_PYTHON" ]]; then
print -u2 'Project Python environment missing. Run uv sync in the project root.'
exit 1
fi
case "$INTOHOLE_ACTION" in
playtest) exec "$INTOHOLE_PYTHON" scripts/python/baseline.py play "$@" ;;
merge|doctor) exec "$INTOHOLE_PYTHON" scripts/python/baseline.py "$INTOHOLE_ACTION" "$@" ;;
baseline-build) exec "$INTOHOLE_PYTHON" scripts/python/baseline.py build "$@" ;;
baseline-test) exec "$INTOHOLE_PYTHON" scripts/python/baseline.py test "$@" ;;
workshop|showcase|underpass|build|test|test-underpass|capture)
exec "$INTOHOLE_PYTHON" scripts/python/studio.py "$INTOHOLE_ACTION" "$@" ;;
*) print -u2 "Unknown action: $INTOHOLE_ACTION"; exit 2 ;;
esac
+3
View File
@@ -0,0 +1,3 @@
#!/bin/zsh
set -euo pipefail
exec "${0:A:h}/run.zsh" showcase "$@"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/zsh
set -euo pipefail
exec "${0:A:h}/run.zsh" underpass "$@"
+3
View File
@@ -0,0 +1,3 @@
#!/bin/zsh
set -euo pipefail
exec "${0:A:h}/run.zsh" workshop "$@"