#!/usr/bin/env bash
set -euo pipefail

ROOT_DIR="$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")/.." && pwd)"
VENDOR_DIR="$ROOT_DIR/vendor"
OPENVT_DIR="$VENDOR_DIR/open-vt"

mkdir -p "$VENDOR_DIR"

if ! command -v git >/dev/null 2>&1; then
  echo "git is required"
  exit 1
fi

if ! command -v godot4 >/dev/null 2>&1 && ! command -v godot >/dev/null 2>&1; then
  echo "Godot 4 is required. Enter devenv or install godot_4 first."
  exit 1
fi

if [ ! -d "$OPENVT_DIR/.git" ]; then
  git clone https://github.com/erodozer/open-vt "$OPENVT_DIR"
fi

git -C "$OPENVT_DIR" submodule update --init --recursive

cat <<'EOF'

OpenVT source is present at:
  vendor/open-vt

Next manual steps:
  1. cd vendor/open-vt
  2. inspect thirdparty/ readmes and licensing requirements
  3. run ./build_dependencies.sh
  4. open the project in Godot 4.6+
  5. load a model and verify local rendering

Notes:
  - Full Live2D support may require proprietary Cubism components.
  - OpenSeeFace is separate if you want webcam tracking.
  - This script intentionally does not fake or skip upstream dependency steps.

EOF
