MC_survival/event.d.ts

763 lines
24 KiB
TypeScript
Raw Normal View History

2025-01-14 12:27:52 +08:00
/**
*
*/
type SystemEventFunc = (data: any, callback: (...params: any[]) => any) => void;
/**
*
*/
type EventFunc = (data: any, x?: number, y?: number, prefix?: string) => void;
/**
*
*/
interface Events extends EventData {
/**
*
*/
eventdata: EventData;
/**
*
*/
commonEvent: Record<EventDeclaration, MotaEvent>;
/**
*
*/
systemEvent: Record<string, SystemEventFunc>;
/**
*
*/
actions: Record<string, EventFunc>;
/**
*
* @example core.startGame('咸鱼乱撞', 0, ''); // 开始一局咸鱼乱撞难度的新游戏随机种子为0
* @param hard
* @param seed
* @param route base64压缩后的录像
* @param callback
*/
startGame(
hard: string,
seed?: number,
route?: string,
callback?: () => void
): void;
/**
*
* @example core.gameOver(); // 游戏失败
* @param ending
* @param fromReplay true表示在播放录像
* @param norank true表示不计入榜单
*/
gameOver(ending?: string, fromReplay?: boolean, norank?: boolean): void;
/**
*
*/
restart(): void;
/**
*
*/
confirmRestart(): void;
/**
*
* @param type
* @param func (data,callback)
*/
registerSystemEvent(type: string, func: SystemEventFunc): void;
/**
*
* @param type
*/
unregisterSystemEvent(type: string): void;
/**
*
* @param type
* @param data
* @param callback
*/
doSystemEvent(
type: string,
data: any,
callback?: (...params: any[]) => any
): void;
/**
* (x,y)script属性
* @param x
* @param y
* @param callback
*/
trigger(x: number, y: number, callback?: () => void): void;
/**
*
* @example core.openDoor(0, 0, true, core.jumpHero); // 打开左上角的门,需要钥匙,然后主角原地跳跃半秒
* @param x
* @param y
* @param needKey true表示需要钥匙
* @param callback
*/
openDoor(
x: number,
y: number,
needKey?: boolean,
callback?: () => void
): void;
/**
*
* @example core.getItem('book'); // 获得敌人手册并提示
* @param id id
* @param num 1
* @param x
* @param y
* @param callback
*/
getItem(
id: AllIdsOf<'items'>,
num?: number,
x?: number,
y?: number,
callback?: () => void
): void;
/**
*
* @param noRoute true则不计入录像
*/
getNextItem(noRoute?: boolean): void;
/**
*
* @example core.changeFloor('MT0'); // 传送到主塔0层主角坐标和朝向不变黑屏时间取用户设置值
* @param floorId id':before'':after'
* @param stair ':now',':symmetry',':symmetry_x',':symmetry_y'id'downFloor''upFloor'
* @param heroLoc
* @param time
* @param callback
*/
changeFloor(
floorId: FloorIds,
stair?: FloorChangeStair | AllIds,
heroLoc?: Partial<Loc>,
time?: number,
callback?: () => void
): void;
/**
*
* @param floorId id
*/
hasVisitedFloor(floorId?: FloorIds): boolean;
/**
*
* @param floorId id
*/
visitFloor(floorId?: FloorIds): void;
/**
*
* @param data
*/
pushBox(data?: Block): void;
/**
*
*/
onSki(number?: number): boolean;
/**
*
* @param type
* @param func (data, x, y, prefix)
* data为事件内容x和y为当前点坐标nullprefix为当前点前缀
*/
registerEvent(type: string, func: EventFunc): void;
/**
*
* @param type
*/
unregisterEvent(type: string): void;
/**
*
* @param data
* @param x
* @param y
* @param prefix
*/
doEvent(data: any, x?: number, y?: number, prefix?: string): void;
/**
*
* @param list
* @param x
* @param y
* @param callback
*/
setEvents(
list: MotaEvent,
x?: number,
y?: number,
callback?: () => void
): void;
/**
*
* @param list
* @param x
* @param y
* @param callback
*/
startEvents(
list?: MotaEvent,
x?: number,
y?: number,
callback?: () => void
): void;
/**
*
* @example
* // 事件中的原生脚本,配合勾选“不自动执行下一个事件”来达到此改变色调只持续到下次场景切换的效果
* core.setCurtain([0,0,0,1], undefined, null, core.doAction);
*/
doAction(): void;
/**
* core.insertCommonEvent
* @example core.insertAction('一段文字'); // 插入一个显示文章
* @param action
* @param x
* @param y
* @param callback
* @param addToLast true表示插入到末尾
*/
insertAction(
action: MotaEvent | MotaAction,
x?: number,
y?: number,
callback?: () => void,
addToLast?: boolean
): void;
/**
*
* @example core.insertCommonEvent('加点事件', [3]);
* @param name
* @param args flag:arg1, flag:arg2, ...
* @param x
* @param y
* @param callback
* @param addToLast true表示插入到末尾
*/
insertCommonEvent(
name: EventDeclaration,
args?: any[],
x?: number,
y?: number,
callback?: () => void,
addToLast?: boolean
): void;
/**
*
* @param name
*/
getCommonEvent(name: EventDeclaration): any;
/**
*
* @param data
*/
recoverEvents(data?: any): boolean;
/**
*
*/
checkAutoEvents(): void;
/**
*
* @param symbol
* @param value
*/
autoEventExecuting(symbol?: string, value?: any): boolean;
/**
*
* @param symbol
* @param value
*/
autoEventExecuted(symbol?: string, value?: any): boolean;
/**
*
*/
pushEventLoc(x: number, y: number, floorId?: FloorIds): void;
/**
*
*/
popEventLoc(): void;
/**
*
* @param data
*/
precompile(data?: any): any;
/**
*
* @param fromUserAction
*/
openBook(fromUserAction?: boolean): void;
/**
*
* @param fromUserAction
*/
useFly(fromUserAction?: boolean): void;
/** 点击装备栏时的打开操作 */
openEquipbox(fromUserAction?: boolean): void;
/**
*
* @param fromUserAction
*/
openToolbox(fromUserAction?: boolean): void;
/**
*
* @param fromUserAction
*/
openQuickShop(fromUserAction?: boolean): void;
/**
*
* @param fromUserAction
*/
openKeyBoard(fromUserAction?: boolean): void;
/**
*
* @param fromUserAction
*/
save(fromUserAction?: boolean): void;
/**
*
* @param fromUserAction
*/
load(fromUserAction?: boolean): void;
/**
*
* @param fromUserAction
*/
openSettings(fromUserAction?: boolean): void;
/**
*
*/
hasAsync(): boolean;
/**
*
*/
stopAsync(): void;
/**
*
*/
hasAsyncAnimate(): boolean;
/**
*
* @param name 4x4的行走图名称
*/
follow(name: ImageIds | NameMapIn<ImageIds>): void;
/**
*
* @param name
*/
unfollow(name?: ImageIds | NameMapIn<ImageIds>): void;
/**
*
* @param name
* @param operator
* @param value
* @param prefix
*/
setValue(
name: `${EventValuePreffix}:${string}`,
operator: MotaOperator,
value: number,
prefix?: string
): void;
/**
* @deprecated
*
* @example core.setEnemy('greenSlime', 'def', 0); // 把绿头怪的防御设为0
* @param id id
* @param name
* @param value
* @param operator
* @param prefix
* @param norefresh
*/
setEnemy<K extends keyof Enemy>(
id: AllIdsOf<'enemys' | 'enemy48'>,
name: K,
value: Enemy[K],
operator?: MotaOperator,
prefix?: string,
norefresh?: boolean
): void;
/**
* @deprecated
*
* @param x
* @param y
* @param floorId id
* @param name
* @param value
* @param operator
* @param prefix
* @param norefresh
*/
setEnemyOnPoint<K extends keyof Enemy>(
x: number,
y: number,
floorId: FloorIds,
name: K,
value: Enemy[K],
operator?: MotaOperator,
prefix?: string,
norefresh?: boolean
): void;
/**
* @deprecated
*
* @param x
* @param y
* @param floorId id
* @param norefresh
*/
resetEnemyOnPoint(
x: number,
y: number,
floorId?: FloorIds,
norefresh?: boolean
): void;
/**
* @deprecated
*
* @param fromX
* @param fromY
* @param toX
* @param toY
* @param floorId id
* @param norefresh
*/
moveEnemyOnPoint(
fromX: number,
fromY: number,
toX: number,
toY: number,
floorId?: FloorIds,
norefresh?: boolean
): void;
/**
*
* @example core.setFloorInfo('ratio', 2, 'MT0'); // 把主塔0层的血瓶和宝石变为双倍效果
* @param name
* @param values
* @param floorId id
* @param prefix
*/
setFloorInfo<K extends keyof Floor>(
name: K,
values?: Floor[K],
floorId?: FloorIds,
prefix?: string
): void;
/**
*
* @param name
* @param value
*/
setGlobalAttribute<K extends keyof GlobalAttribute>(
name: K,
value: GlobalAttribute[K]
): void;
/**
*
* @example core.setGlobalFlag('steelDoorWithoutKey', true); // 使全塔的所有铁门都不再需要钥匙就能打开
* @param name
* @param value !core.flags[name]
*/
setGlobalFlag<K extends keyof CoreFlags>(
name: K,
value: CoreFlags[K]
): void;
/**
*
* @param name
* @param value
*/
setNameMap(name: string, value?: SourceIds): void;
/**
*
*/
setTextAttribute(data: Partial<TextAttribute>): void;
/**
*
* @param code
* @param loc
* @param relative
* @param moveMode
* @param time
* @param callback
*/
moveTextBox(
code: number,
loc: LocArr,
relative?: boolean,
moveMode?: EaseMode,
time?: number,
callback?: () => void
): void;
/**
*
* @param code
* @param callback
*/
clearTextBox(code: number, callback: () => void): void;
/**
*
* @example core.closeDoor(0, 0, 'yellowWall', core.jumpHero); // 在左上角关掉一堵黄墙,然后主角原地跳跃半秒
* @param x
* @param y
* @param id id
* @param callback
*/
closeDoor(
x: number,
y: number,
id: AllIdsOf<Exclude<Cls, 'enemys' | 'enemy48'>>,
callback?: () => void
): void;
/**
*
* @example
* // 裁剪winskin.png的最左边128×128px放大到铺满整个视野1秒内淡入到50%透明编号为1
* core.showImage(1, core.material.images.images['winskin.png'], [0,0,128,128], [0,0,416,416], 0.5, 1000);
* @param code 50100z值z值为125UI层为140
* @param image
* @param sloc
* @param loc
* @param opacityVal 11
* @param time 0
* @param callback
*/
showImage(
code: number,
image: ImageIds | NameMapIn<ImageIds> | ImageSource,
sloc?: [number, number, number, number],
loc?: [number, number, number?, number?],
opacityVal?: number,
time?: number,
callback?: () => void
): void;
/**
*
* @example core.hideImage(1, 1000, core.jumpHero); // 1秒内淡出1号图片然后主角原地跳跃半秒
* @param code
* @param time
* @param callback
*/
hideImage(code: number, time?: number, callback?: () => void): void;
/**
* /
* @example core.moveImage(1, null, 0.5); // 1秒内把1号图片变为50%透明
* @param code
* @param to
* @param opacityVal
* @param moveMode
* @param time 1
* @param callback
*/
moveImage(
code: number,
to?: LocArr,
opacityVal?: number,
moveMode?: string,
time?: number,
callback?: () => void
): void;
/**
*
* @param code
* @param center
* @param angle
* @param moveMode
* @param time 1
* @param callback
*/
rotateImage(
code: number,
center?: LocArr,
angle?: number,
moveMode?: EaseMode,
time?: number,
callback?: () => void
): void;
/**
*
* @param code
* @param center
* @param scale
* @param moveMode
* @param time 1
* @param callback
*/
scaleImage(
code: number,
center?: LocArr,
scale?: number,
moveMode?: string,
time?: number,
callback?: () => void
): void;
/**
*
* @example core.showGif(); // 擦除所有动图
* @param name
* @param x
* @param y
*/
showGif(
name?:
| Extract<ImageIds, EndsWith<'.gif'>>
| NameMapIn<Extract<ImageIds, EndsWith<'.gif'>>>,
x?: number,
y?: number
): void;
/**
* bgm的音量
* @example core.setVolume(0, 100, core.jumpHero); // 0.1秒内淡出bgm然后主角原地跳跃半秒
* @param value 01
* @param time 1000
* @param callback
*/
setVolume(value: number, time?: number, callback?: () => void): void;
/**
*
* @example core.vibrate(); // 视野左右抖动1秒
* @param direction
* @param time
* @param speed
* @param power
* @param callback
*/
vibrate(
direction?: string,
time?: number,
speed?: number,
power?: number,
callback?: () => void
): void;
/**
* 退
* @example core.eventMoveHero(['forward'], 125, core.jumpHero); // 主角强制前进一步用时1/8秒然后主角原地跳跃半秒
* @param steps 退
* @param time 00.1
* @param callback
*/
eventMoveHero(steps: Step[], time?: number, callback?: () => void): void;
/**
* ex和ey为目标点的坐标null表示原地跳跃time为总跳跃时间
* @example core.jumpHero(); // 主角原地跳跃半秒
* @param ex
* @param ey
* @param time
* @param callback
*/
jumpHero(
ex?: number,
ey?: number,
time?: number,
callback?: () => void
): void;
/**
*
* @example core.setHeroIcon('npc48.png', true); // 把主角从阳光变成样板0层左下角的小姐姐但不立即刷新
* @param name core.status.hero.image
* @param noDraw true表示不立即刷新
*/
setHeroIcon(name: string, noDraw?: boolean): void;
/** 检查升级事件 */
checkLvUp(): void;
/**
* 使
* @example core.tryUseItem('pickaxe'); // 尝试使用破墙镐
* @param itemId id
*/
tryUseItem(
itemId: ItemIdOf<'tools' | 'constants'>,
noRoute?: boolean,
callback?: () => void
): void;
_sys_battle(data: Block, callback?: () => void): void;
_action_battle(data: any, x?: number, y?: number, prefix?: any): void;
__action_getLoc(data: any, x?: number, y?: number, prefix?: any): any;
_changeFloor_beforeChange(info: any, callback: () => void): void;
}
declare const events: new () => Events;