feat: P15 ending gallery, chapter recap, visited tracking, save system v6

This commit is contained in:
2026-06-09 17:49:07 +08:00
parent 47d6ce50fe
commit 9297117544
14 changed files with 517 additions and 48 deletions

View File

@@ -28,6 +28,7 @@ export class Engine {
private loopActive = false
private onUnlockChapter: ((chapterId: string) => void) | null = null
private onMarkWatched: ((sceneId: string) => void) | null = null
private onMarkVisited: ((sceneId: string) => void) | null = null
setChapterUnlockHandler(handler: (chapterId: string) => void) {
this.onUnlockChapter = handler
@@ -37,6 +38,10 @@ export class Engine {
this.onMarkWatched = handler
}
setMarkVisitedHandler(handler: (sceneId: string) => void) {
this.onMarkVisited = handler
}
constructor() {
this.sceneManager = new SceneManager()
this.videoManager = new VideoManager()
@@ -74,40 +79,16 @@ export class Engine {
}
private goToScene(scene: SceneNode) {
this.currentScene = scene
const chapter = this.sceneManager.getChapterBySceneId(scene.id)
if (chapter) {
this.onUnlockChapter?.(chapter.id)
this.emit('chapterUnlock', chapter)
}
if (scene.onEnter) {
this.stateManager.apply(scene.onEnter)
}
this.onMarkVisited?.(scene.id)
if (scene.videoMuted) {
this.videoManager.setMuted(true)
} else {
this.videoManager.setMuted(false)
}
const bgmUrl = scene.bgmUrl || null
if (bgmUrl) {
this.audioSystem.play(
bgmUrl,
scene.bgmVolume ?? 0.8,
scene.bgmCrossFade ?? 2.0,
scene.bgmDuckLevel,
scene.bgmDuckFade,
)
} else {
this.audioSystem.stop(scene.bgmCrossFade ?? 2.0)
}
this.enterScene(scene)
}
private enterScene(scene: SceneNode) {
this.currentScene = scene
this.qteTriggered = false
this.qteResolved = false
this.loopActive = false
@@ -405,7 +386,7 @@ export class Engine {
this.ended = false
this.isInitialScene = false
this.enterScene(scene)
this.goToScene(scene)
}
destroy() {