"use client"; import { create } from "zustand"; import { sound } from "./sound"; interface SoundStore { sfx: boolean; music: boolean; toggleSfx: () => void; toggleMusic: () => void; /** Master mute: turns BOTH sfx and music off (or both back on). */ toggleAll: () => void; } export const useSoundStore = create((set, get) => ({ sfx: sound.sfxEnabled, music: sound.musicEnabled, toggleSfx: () => { const v = !get().sfx; sound.setSfxEnabled(v); set({ sfx: v }); }, toggleMusic: () => { const v = !get().music; sound.setMusicEnabled(v); set({ music: v }); }, toggleAll: () => { // If anything is on, mute everything; otherwise turn everything back on. const v = !(get().sfx || get().music); sound.setSfxEnabled(v); sound.setMusicEnabled(v); set({ sfx: v, music: v }); }, }));