Files
tianshu-engine/src/stores/gameStore.ts
2026-06-07 13:50:05 +08:00

28 lines
684 B
TypeScript

import { defineStore } from 'pinia'
import { ref, shallowRef } from 'vue'
import type { SceneNode, Choice } from '@engine/types'
export const useGameStore = defineStore('game', () => {
const currentScene = shallowRef<SceneNode | null>(null)
const choices = ref<Choice[]>([])
const gameEnded = ref(false)
function setScene(scene: SceneNode) {
currentScene.value = scene
}
function setChoices(list: Choice[]) {
choices.value = list
}
function clearChoices() {
choices.value = []
}
function setGameEnded(val: boolean) {
gameEnded.value = val
}
return { currentScene, choices, gameEnded, setScene, setChoices, clearChoices, setGameEnded }
})