"use client";
// 回响星核 / Echo Nexus — 音频 React 适配
import { useEffect } from "react";
import { getAudio } from "@/lib/game/audio";
import { useGameStore } from "@/store/gameStore";

/** 同步全局音频开关到音频引擎 */
export function useAudioSync() {
  const soundOn = useGameStore((s) => s.soundOn);
  useEffect(() => {
    getAudio().setEnabled(soundOn);
  }, [soundOn]);
}

/** 便捷播放函数（组件内调用） */
export function sfx(
  name: Parameters<ReturnType<typeof getAudio>["play"]>[0],
  opts?: { color?: string; combo?: number }
) {
  getAudio().play(name, opts);
}
