HumanBreak/src/types/action.d.ts

140 lines
3.1 KiB
TypeScript
Raw Normal View History

/**
*
*/
type MotaMouseFunc = (x: number, y: number, px: number, py: number) => boolean;
/**
*
*/
type MotaKeyboardFunc = (e: KeyboardEvent) => boolean;
/**
*
*/
interface RegisteredActionMap {
keyDown: (keyCode: number) => boolean;
keyDownCtrl: () => boolean;
keyUp: (keyCode: number, altKey: boolean, fromReplay: boolean) => boolean;
longClick: MotaMouseFunc;
onStatusBarClick: (px: number, py: number, vertical: boolean) => boolean;
ondown: MotaMouseFunc;
onkeyDown: MotaKeyboardFunc;
onkeyUp: MotaKeyboardFunc;
onmousewheel: (direct: 1 | -1) => boolean;
onmove: MotaMouseFunc;
onup: MotaMouseFunc;
pressKey: (keyCode: number) => boolean;
}
type ActionKey = keyof RegisteredActionMap;
/**
* void就变成了actions上的函数...
*/
type VoidedActionFuncs = {
[P in ActionKey]: (...params: Parameters<RegisteredActionMap[P]>) => void;
};
/**
*
*/
interface ClickLoc extends Loc {
2022-11-13 18:02:05 +08:00
/**
* 32
2022-11-13 18:02:05 +08:00
*/
size: 32;
}
2022-11-13 18:02:05 +08:00
interface RegisteredActionOf<K extends ActionKey> {
/**
*
*/
action: K;
2022-11-13 18:02:05 +08:00
/**
*
*/
name: string;
2022-11-13 18:02:05 +08:00
/**
*
*/
priority: number;
2022-11-13 18:02:05 +08:00
/**
*
*/
func: RegisteredActionMap[K];
}
2022-11-13 18:02:05 +08:00
/**
*
*/
interface Actions extends VoidedActionFuncs {
/**
*
*/
readonly LAST: number;
2022-11-13 18:02:05 +08:00
/**
*
*/
readonly _HX_: number;
2022-11-13 18:02:05 +08:00
/**
*
*/
readonly _HY_: number;
2022-11-13 18:02:05 +08:00
/**
*
*/
readonly actionsdata: ActionData;
2022-11-13 18:02:05 +08:00
/**
*
*/
readonly actions: {
[P in ActionKey]: RegisteredActionOf<P>[];
};
2022-11-13 18:02:05 +08:00
/**
*
* @param action
* @param name 使
* @param func func返回true
* @param priority 0
*/
registerAction<K extends ActionKey>(
action: K,
name: string,
func: RegisteredActionMap[K],
priority?: number
2022-11-13 18:02:05 +08:00
): void;
/**
*
* @param action
* @param name
*/
unregisterAction(action: ActionKey, name: string): void;
2022-11-13 18:02:05 +08:00
/**
*
*/
doRegisteredAction<K extends ActionKey>(
action: K,
...params: Parameters<RegisteredActionMap[K]>
2022-11-13 18:02:05 +08:00
): void;
/**
* (_HX_ - 2, _HX_ + 2)
* @param x
*/
_out(x: number): boolean;
2023-01-01 22:02:58 +08:00
_getNextFlyFloor(delta: number, index: number): number;
2022-11-13 18:02:05 +08:00
}
declare const actions: new () => Actions;