ActionModel.ts 1.55 KB
export const enum ActionType {
    // TransitionIn = -2,
    // TransitionOut = -1,
    // TweenAnimation = 0,
    // EffectAnimation = 1,
    ModifyVariable = 2,
    PlayAudio = 3,
    EmitEvent = 4,
    // TextAnimation = 5,
    Custom = 10
}

export const enum TriggerType {
    PreviousStart,
    PreviousEnd,
    Click,
    Event
}

export interface ActionBase {
    name: string;
    type: ActionType;
    trigger: TriggerType;
    triggerEvent?: string;
    delay: number;
}

export const enum VariableOperator {
    Assign = 1,
    Plus = 2,
    Minus = 3,
    Multiply = 4,
    Divide = 5,
    Modulo = 6
}

export const enum OperandType {
    Variable = 1,
    Const = 2,
    Random = 3
}

export interface ModifyVariableAction extends ActionBase {
    type: ActionType.ModifyVariable;
    target: string;
    operator: VariableOperator;
    oprand: { type: OperandType, value: string }
}

export interface PlayMusicAction extends ActionBase {
    type: ActionType.PlayAudio;
    audioType: "music";
    filePath: string;
}

export interface PlaySoundEffectAction extends ActionBase {
    type: ActionType.PlayAudio
    audioType: "effect";
    loopCount: number;
    stopPreviousSound: boolean;
    volume: number;
    filePath: string;
}

export type PlayAudioAction = PlayMusicAction | PlaySoundEffectAction;

export interface EmitEventAction extends ActionBase {
    type: ActionType.EmitEvent;
    emitEvent: string;
    param: string;
}

export type Action = ModifyVariableAction | PlayAudioAction | EmitEventAction;

export interface Actions {
    actions: Action[];
}