import type { BattlePhase } from 'db://assets/mx/module/battle'; import type { ChapterNewPlayTypeEnum, ChapterPlayData } from '../../game/ChapterPlayTypes'; import type { BattleRuntime } from '../runtime/BattleRuntime'; import type { BattleSession } from 'db://assets/mx/module/battle'; export interface MechanismContext { readonly runtime: BattleRuntime; readonly session: BattleSession; get battleTime(): number; get timeScale(): number; canTick(): boolean; } export interface IBattleMechanism { readonly typeId: ChapterNewPlayTypeEnum; init(ctx: MechanismContext, config: ChapterPlayData): void; onPhaseChanged?(phase: BattlePhase): void; tick(dt: number): void; destroy(): void; } export function createMechanismContext(runtime: BattleRuntime): MechanismContext { return { runtime, session: runtime.session, get battleTime() { return runtime.BattleTime; }, get timeScale() { return runtime.TimeScale; }, canTick() { return runtime.canUpdateFrame(); }, }; }