feat: battle system, state manager enhancements, engine and demo updates

This commit is contained in:
2026-06-14 15:35:31 +08:00
parent 4d066b53bf
commit d0e901bd1f
12 changed files with 515 additions and 6 deletions

View File

@@ -51,9 +51,9 @@ export class Engine {
this.audioSystem = new AudioSystem()
this.achievementSystem = new AchievementSystem()
this.stateManager.onAfterApply = (vars) => {
this.stateManager.onAfterApply.add((vars) => {
this.achievementSystem.check(vars)
}
})
this.videoManager.onTimeUpdate(this.onTimeUpdate)
}

View File

@@ -4,7 +4,7 @@ export class StateManager {
variables: Record<string, number> = {}
flags: Set<string> = new Set()
history: ChoiceRecord[] = []
onAfterApply: ((variables: Record<string, number>) => void) | null = null
onAfterApply: Set<((variables: Record<string, number>) => void)> = new Set()
init(initialVars: Record<string, number>) {
this.variables = { ...initialVars }
@@ -73,7 +73,7 @@ export class StateManager {
break
}
}
this.onAfterApply?.(this.variables)
this.onAfterApply.forEach((cb) => cb(this.variables))
}
recordChoice(choice: ChoiceRecord) {

View File

@@ -23,6 +23,8 @@ export interface SceneNode {
skippable?: boolean
streamingUrl?: Record<string, string>
keyMoment?: boolean
battleHUD?: BattleHUDEntry[]
battleResult?: BattleResultDef
}
export interface Choice {
@@ -166,3 +168,31 @@ export interface PlayerTreeNode {
isGateway?: boolean
gatewayChapterId?: string
}
export interface BattleHUDStat {
variable: string
label: string
labelKey?: string
max?: number
style?: 'bar' | 'number'
}
export interface BattleHUDEntry {
label: string
labelKey?: string
portrait?: string
stats: BattleHUDStat[]
}
export interface BattleResultStat {
label: string
labelKey?: string
variable: string
max?: number
}
export interface BattleResultDef {
title: string
titleKey?: string
stats: BattleResultStat[]
}