You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
36 lines
1.1 KiB
36 lines
1.1 KiB
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();
|
|
},
|
|
};
|
|
}
|
|
|