feat: chapter select system, multi-chapter support, scene manager refactor, and docs update

This commit is contained in:
2026-06-09 11:35:11 +08:00
parent 655b9a23d0
commit ace5ed1fb3
14 changed files with 413 additions and 17 deletions

View File

@@ -1,12 +1,14 @@
import type { GameData, SceneNode, Choice, Condition } from '../types'
import type { GameData, SceneNode, ChapterInfo, Choice, Condition } from '../types'
export class SceneManager {
private scenes: Record<string, SceneNode> = {}
private startScene: string = ''
chapters: ChapterInfo[] = []
load(data: GameData) {
this.scenes = data.scenes
this.startScene = data.startScene
this.chapters = data.chapters || []
}
getScene(id: string): SceneNode | undefined {
@@ -23,6 +25,14 @@ export class SceneManager {
return Object.keys(this.scenes)
}
getChapterBySceneId(sceneId: string): ChapterInfo | undefined {
return this.chapters.find((ch) => ch.startScene === sceneId)
}
getChapter(chapterId: string): ChapterInfo | undefined {
return this.chapters.find((ch) => ch.id === chapterId)
}
getCandidateTargetIds(scene: SceneNode, evaluateCondition: (conds?: Condition[]) => boolean): string[] {
const targets: string[] = []