feat: chapter select system, multi-chapter support, scene manager refactor, and docs update
This commit is contained in:
@@ -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[] = []
|
||||
|
||||
|
||||
Reference in New Issue
Block a user