feat: P25 conditional routing, nextScene supports Choice[] with conditions
This commit is contained in:
@@ -296,11 +296,26 @@ export class Engine {
|
||||
}
|
||||
)
|
||||
} else if (scene.nextScene) {
|
||||
const next = this.sceneManager.getScene(scene.nextScene)
|
||||
if (next) {
|
||||
this.goToScene(next)
|
||||
} else {
|
||||
if (Array.isArray(scene.nextScene)) {
|
||||
for (const route of scene.nextScene) {
|
||||
if (!route.conditions || this.stateManager.evaluate(route.conditions)) {
|
||||
const next = this.sceneManager.getScene(route.targetScene)
|
||||
if (next) {
|
||||
this.goToScene(next)
|
||||
} else {
|
||||
this.endGame()
|
||||
}
|
||||
return
|
||||
}
|
||||
}
|
||||
this.endGame()
|
||||
} else {
|
||||
const next = this.sceneManager.getScene(scene.nextScene)
|
||||
if (next) {
|
||||
this.goToScene(next)
|
||||
} else {
|
||||
this.endGame()
|
||||
}
|
||||
}
|
||||
} else if (scene.hotspots?.length) {
|
||||
return
|
||||
|
||||
@@ -50,8 +50,13 @@ export class SceneManager {
|
||||
}
|
||||
}
|
||||
|
||||
if (scene.nextScene && !targets.includes(scene.nextScene)) {
|
||||
targets.push(scene.nextScene)
|
||||
if (scene.nextScene) {
|
||||
const nextIds = Array.isArray(scene.nextScene)
|
||||
? scene.nextScene.map(r => r.targetScene)
|
||||
: [scene.nextScene]
|
||||
for (const id of nextIds) {
|
||||
if (!targets.includes(id)) targets.push(id)
|
||||
}
|
||||
}
|
||||
|
||||
return targets
|
||||
|
||||
@@ -10,7 +10,7 @@ export interface SceneNode {
|
||||
choices?: Choice[]
|
||||
hotspots?: Hotspot[]
|
||||
qte?: QTEDefinition
|
||||
nextScene?: string
|
||||
nextScene?: string | Choice[]
|
||||
onEnter?: Effect[]
|
||||
loopStart?: number
|
||||
loopEnd?: number
|
||||
|
||||
Reference in New Issue
Block a user