MC_survival/control.d.ts

1096 lines
30 KiB
TypeScript
Raw Normal View History

2025-01-14 12:27:52 +08:00
/**
*
*/
type FrameFunc = (time: number) => void;
/**
* true表示执行成功
*/
type ReplayFunc = (action: string) => boolean;
/**
*
*/
type ResizeFunc = (obj: DeepReadonly<ResizeObj>) => void;
/**
*
*/
type NumbericHeroStatus = SelectType<HeroStatus, number>;
/**
*
*/
type SLType =
| 'save'
| 'load'
| 'reload'
| 'replayLoad'
| 'replayRemain'
| 'replaySince';
/**
*
*/
type WeatherLevel = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10;
/**
* resize函数的参数
*/
interface ResizeObj {
/**
* body元素的宽度
*/
clientWidth: number;
/**
* body元素的高度
*/
clientHeight: number;
/**
*
*/
BORDER: 3;
/**
*
*/
BAR_WIDTH: number;
/**
*
*/
TOOLBAR_HEIGHT: 38;
/**
*
*/
outerWidth: number;
/**
*
*/
outerHeight: number;
/**
*
*/
globalAttribute: GlobalAttribute;
/**
* css字符串
*/
border: string;
/**
*
*/
statusDisplayArr: string[];
/**
*
*/
count: number;
/**
*
*/
col: number;
/**
*
*/
statusBarHeightInVertical: number;
/**
*
*/
toolbarHeightInVertical: number;
/**
*
*/
extendToolbar: number;
/**
* @deprecated
* 15x15
*/
is15x15: false;
}
interface RenderFrame {
/**
*
*/
name: string;
/**
*
*/
needPlaying: boolean;
/**
*
*/
func: FrameFunc;
}
interface ReplayAction {
/**
*
*/
name: string;
/**
*
*/
func: ReplayFunc;
}
interface ResizeAction {
/**
* resize操作的名称
*/
name: string;
/**
*
*/
func: ResizeFunc;
}
interface WeatherAction {
/**
*
*/
frameFunc?: (time: number, level: WeatherLevel) => void;
/**
*
*/
initFunc: (level: WeatherLevel) => void;
}
interface FrameObj {
angle: number;
index: number;
mirror: number;
opacity: number;
x: number;
y: number;
zoom: number;
}
/**
*
*/
interface Control {
/**
*
*/
readonly noAutoEvent: boolean;
/**
*
*/
readonly renderFrameFunc: RenderFrame[];
/**
*
*/
readonly replayActions: ReplayAction[];
/**
* resize操作
*/
readonly resizes: ResizeAction[];
/**
*
*/
readonly weathers: Record<string, WeatherAction>;
/**
* control函数列表
*/
readonly controlData: ControlData;
/**
* animationFrame
* @param name 使
* @param needPlaying
* @param func time
*/
registerAnimationFrame(
name: string,
needPlaying: boolean,
func: FrameFunc
): void;
/**
* animationFrame
* @param name
*/
unregisterAnimationFrame(name: string): void;
/**
*
* @example core.showStartAnimate(); // 重启游戏但不重置bgm
* @param noAnimate
* @param callback
*/
showStartAnimate(noAnimate?: boolean, callback?: () => void): void;
/**
*
* @example core.hideStartAnimate(core.startGame); // 淡出标题画面并开始新游戏,跳过难度选择
* @param callback
*/
hideStartAnimate(callback?: () => void): void;
/**
*
*/
isPlaying(): boolean;
/**
*
*/
clearStatus(): void;
/**
* 线
*/
clearAutomaticRouteNode(x: number, y: number): void;
/**
*
*/
stopAutomaticRoute(): void;
/**
*
*/
saveAndStopAutomaticRoute(): void;
/**
*
*/
continueAutomaticRoute(): void;
/**
*
*/
clearContinueAutomaticRoute(callback?: () => any): void;
/**
*
* @param destX
* @param destY
* @param stepPostfix
*/
setAutomaticRoute(destX: number, destY: number, stepPostfix: Loc[]): void;
/**
*
* @param steps
*/
setAutoHeroMove(steps: CompressedStep[]): void;
/**
*
*/
setHeroMoveInterval(callback?: () => any): void;
/**
*
*/
moveOneStep(callback?: () => any): void;
/**
*
* @example core.moveAction(core.doAction); // 尝试前进一步,然后继续事件处理
* @param callback
*/
moveAction(callback?: () => void): void;
/**
*
* @example core.moveHero(); // 连续前进
* @param direction
* @param callback
*/
moveHero(direction?: Dir, callback?: () => void): void;
/**
*
*/
isMoving(): boolean;
/**
*
* @example core.waitHeroToStop(core.vibrate); // 等待勇士停下然后视野左右抖动1秒
* @param callback
*/
waitHeroToStop(callback?: () => void): void;
/**
*
* @example core.turnHero(); // 主角顺时针旋转即单击主角或按下Z键的效果
* @param direction up, down, left, right, :left, :right, :back七种之一不填视为:right
*/
turnHero(direction?: TurnDir): void;
/**
*
* @param x
* @param y
* @param ignoreSteps
*/
moveDirectly(x: number, y: number, ignoreSteps?: number): boolean;
/**
* //
* @example core.tryMoveDirectly(6, 0); // 尝试瞬移到地图顶部的正中央以样板0层为例实际效果是瞬移到了上楼梯下面一格然后向上走一步并触发上楼事件
* @param destX
* @param destY
*/
tryMoveDirectly(destX: number, destY: number): boolean;
/**
*
* @example core.drawHero(); // 原地绘制主角的静止帧
* @param status
* @param offset
* @param frame
*/
drawHero(
status?: Exclude<keyof MaterialIcon['hero']['down'], 'loc'>,
offset?: number,
frame?: number
): void;
/**
*
* @param opacity
* @param moveMode
* @param time
* @param callback
*/
setHeroOpacity(
opacity: number,
moveMode?: EaseMode,
time?: any,
callback?: () => any
): void;
/**
*
* @param canvasId ts的说法应该只能填数字
*
* @param x
* @param y
*/
setGameCanvasTranslate(
canvasId: string | number,
x: number,
y: number
): void;
/**
*
* @param x
* @param y
*/
addGameCanvasTranslate(x: number, y: number): void;
/**
* @deprecated
*
*/
updateViewport(): void;
/**
* @deprecated
*
* @param px
* @param py
*/
setViewport(px?: number, py?: number): void;
/**
* @deprecated
* 西... + setViewport就完事了
* @param x
* @param y
* @param moveMode
* @param time
* @param callback
*/
moveViewport(
x: number,
y: number,
moveMode?: EaseMode,
time?: number,
callback?: () => void
): void;
/**
* n格的横坐标
* @example core.closeDoor(core.nextX(), core.nextY(), 'yellowDoor', core.turnHero); // 在主角面前关上一扇黄门然后主角顺时针旋转90°
* @param n 01
*/
nextX(n?: number): number;
/**
* n格的纵坐标
* @example core.jumpHero(core.nextX(2), core.nextY(2)); // 主角向前跃过一格,即跳跃靴道具的使用效果
* @param n 01
*/
nextY(n?: number): number;
/**
* 齿()
* @example core.nearHero(6, 6, 6); // 判定主角是否身处点66的半径为6的锯齿领域
* @param x
* @param y
* @param n 1
*/
nearHero(x: number, y: number, n?: number): boolean;
/**
*
*/
gatherFollowers(): void;
/**
*
*/
updateFollowers(): void;
/**
*
*/
checkBlock(): void;
/**
* @deprecated 使core.updateStatusBar代替
* @example core.updateDamage(); // 更新当前地图的显伤,绘制在显伤层(废话)
* @param floorId id
* @param ctx
*/
updateDamage(floorId?: FloorIds, ctx?: CtxRefer): void;
/**
*
* @param ctx
*/
drawDamage(ctx?: CtxRefer, floorId: FloorIds): void;
/**
*
*/
chooseReplayFile(): void;
/**
*
*/
startReplay(list: string[]): void;
/**
*
*/
triggerReplay(): void;
/**
*
*/
pauseReplay(): void;
/**
*
*/
resumeReplay(): void;
/**
*
*/
stepReplay(): void;
/**
*
*/
speedUpReplay(): void;
/**
*
*/
speedDownReplay(): void;
/**
*
*/
setReplaySpeed(speed: number): void;
/**
*
* @param force
*/
stopReplay(force?: boolean): void;
/**
* 退
*/
rewindReplay(): void;
/**
*
*/
isReplaying(): boolean;
/**
*
*/
replay(): void;
/**
*
* @param name 使
* @param func
* action参数
* func返回true代表成功处理了此录像行为false代表没有处理此录像行为
*/
registerReplayAction(name: string, func: ReplayFunc): void;
/**
*
* @param
*/
unregisterReplayAction(name: string): void;
/**
*
* @param removeLast
*/
autosave(removeLast?: any): void;
/**
*
*/
checkAutosave(): void;
/**
*
*/
doSL(id: string, type: SLType): void;
/**
*
* @param type all表示所有都同步
*/
syncSave(type?: 'all'): void;
/**
*
*/
syncLoad(): void;
/**
*
*/
saveData(): Save;
/**
*
*/
loadData(data: Save, callback?: () => void): void;
/**
*
*/
getSave(index: number, callback?: (data?: Save) => void): void;
/**
*
*/
getSaves(ids: number, callback?: (data?: Save) => void): void;
getSaves(
ids: number[],
callback?: (data?: Record<number, Save>) => void
): void;
/**
*
*/
getAllSaves(callback?: (data?: Save[]) => void): void;
/**
*
*/
getSaveIndexes(callback?: (data: Record<number, true>) => void): void;
/**
*
*/
hasSave(index: number): boolean;
/**
*
*/
removeSave(index: number, callback?: () => void): void;
/**
* @deprecated
*
* @example core.setStatus('loc', {x : 0, y : 0, direction : 'up'}); // 设置主角位置为地图左上角,脸朝上
* @param name
* @param value
*/
setStatus<K extends keyof HeroStatus>(name: K, value: HeroStatus[K]): void;
/**
* @deprecated
* core.setStatus(name, core.getStatus(name) + value)
* @example core.addStatus('name', '酱'); // 在主角的名字后加一个“酱”字
* @param name
* @param value
*/
addStatus<K extends keyof SelectType<HeroStatus, number | string>>(
name: K,
value: HeroStatus[K]
): void;
/**
* @deprecated
*
* @example core.getStatus('loc'); // 读取主角的坐标和朝向
* @param name
* @returns
*/
getStatus<K extends keyof HeroStatus>(name: K): HeroStatus[K];
/**
* @deprecated
* status中获得属性
* @param status
* @param name
*/
getStatusOrDefault<K extends keyof HeroStatus>(
status?: DeepPartial<HeroStatus>,
name?: K
): HeroStatus[K];
/**
* @deprecated
*
* @example core.getRealStatus('atk'); // 计算主角的攻击力,包括百分比修正。战斗使用的就是这个值
* @param name
*/
getRealStatus<K extends keyof NumbericHeroStatus>(name: K): number;
/**
* @deprecated
* status中获得增幅后的属性
* @param status
* @param name
*/
getRealStatusOrDefault<K extends keyof NumbericHeroStatus>(
status?: DeepPartial<NumbericHeroStatus>,
name?: K
): number;
/**
* @deprecated
*
* @param name
*/
getNakedStatus(name?: keyof NumbericHeroStatus): number;
/**
* 1
* flag: `__${name}_${buff}__`
* @example core.setBuff('atk', 0.5); // 主角能发挥出的攻击力减半
* @param name
* @param value 1
*/
setBuff<K extends keyof NumbericHeroStatus>(name: K, value?: number): void;
/**
* core.setBuff(name, core.getBuff(name) + value)
* @example core.addBuff('atk', -0.1); // 主角获得一层“攻击力减一成”的负面效果
* @param name
* @param value
*/
addBuff<K extends keyof NumbericHeroStatus>(name: K, value: number): void;
/**
* 1
* @example core.getBuff('atk'); // 主角当前能发挥出多大比例的攻击力
* @param name
*/
getBuff(name: keyof NumbericHeroStatus): number;
/**
*
* 使使
* core.clearMap('hero'); core.drawHero();
* @example core.setHeroLoc('x', 5) // 将勇士当前位置的横坐标设置为5。
* @param name
* @param value
* @param noGather
*/
setHeroLoc(name: 'x' | 'y', value: number, noGather?: boolean): void;
setHeroLoc(name: 'direction', value: Dir, noGather?: boolean): void;
/**
*
* @example core.getHeroLoc(); // 获取主角的位置和朝向
* @param name
*/
getHeroLoc(): DiredLoc;
getHeroLoc<K extends keyof DiredLoc>(name: K): DiredLoc[K];
/**
*
* @example core.getLvName(); // 获取主角当前级别的名称,如“下级佣兵”
* @param lv
* @returns
*/
getLvName(lv?: number): string;
/**
*
*
* null
*/
getNextLvUpNeed(): number | null;
/**
* flag变量
* @example core.setFlag('poison', true); // 令主角中毒
* @param name 西
* @param value null视为删除
*/
setFlag(name: string, value?: any): void;
/**
* flag变量 core.setFlag(name, core.getFlag(name, 0) + value)
* @example core.addFlag('hatred', 1); // 增加1点仇恨值
* @param name
* @param value
*/
addFlag(name: string, value: number | string): void;
/**
* flag变量
* @param name 西
* @param defaultValue 0
* @returns flags[name] ?? defaultValue
*/
getFlag<T>(name: string, defaultValue?: T): T;
/**
* flag变量是否不为falsy
* @example core.hasFlag('poison'); // 判断主角当前是否中毒
* @param name 西
*/
hasFlag(name: string): boolean;
/**
* flag
* @param name
*/
removeFlag(name: string): void;
/**
*
* @param x
* @param y
* @param floorId id
* @param name
* @param value
*/
setSwitch(
x?: number,
y?: number,
floorId?: FloorIds,
name?: string,
value?: any
): void;
/**
*
* @param x
* @param y
* @param floorId id
* @param name
* @param value
*/
getSwitch<T>(
x?: number,
y?: number,
floorId?: FloorIds,
name?: string,
defaultValue?: T
): T;
/**
*
* @param x
* @param y
* @param floorId id
* @param name
* @param value
*/
addSwitch(
x?: number,
y?: number,
floorId?: FloorIds,
name?: string,
value?: number | string
): void;
/**
*
* @param x
* @param y
* @param floorId id
* @param name
*/
hasSwitch(
x?: number,
y?: number,
floorId?: FloorIds,
name?: string
): boolean;
/**
*
* @param x
* @param y
* @param floorId id
* @param name
*/
removeSwitch(
x?: number,
y?: number,
floorId?: FloorIds,
name?: string
): void;
/**
*
*/
lockControl(): void;
/**
*
*/
unlockControl(): void;
/**
* , Ctrl键进行穿墙,
*
*/
debug(): void;
/**
*
*/
clearRouteFolding(): void;
/**
*
*/
checkRouteFolding(): void;
/**
*
*/
getMappedName<K extends keyof NameMap>(name: K): NameMap[K];
/**
* 使core.events._action_setWeather()
* @example core.setWeather('fog', 10); // 设置十级大雾天
* @param type
* @param level 105
*/
setWeather(type?: string, level?: WeatherLevel): void;
/**
*
* @param name
* @param initFunc
* @param frameFunc
*/
registerWeather(
name: string,
initFunc: WeatherAction['initFunc'],
frameFunc?: WeatherAction['frameFunc']
): void;
/**
*
* @param name
*/
unregisterWeather(name: string): void;
/**
* 使core.events._action_setCurtain()
* @example core.setCurtain(); // 恢复画面色调,用时四分之三秒
* @param color [0, 0, 0, 0]
* @param time 750ms
* @param moveMode
* @param callback
*/
setCurtain(
color?: RGBArray,
time?: number,
moveMode?: EaseMode,
callback?: () => void
): void;
/**
*
* @example core.screenFlash([255, 0, 0, 1], 3); // 红屏一闪而过
* @param color
* @param time
* @param times 01
* @param moveMode
* @param callback
*/
screenFlash(
color: RGBArray,
time: number,
times?: number,
moveMode?: string,
callback?: () => void
): void;
/**
*
* flags.__bgm__
* @example core.playBgm('bgm.mp3', 30); // 播放bgm.mp3并跳过前半分钟
* @param bgm
* @param startTime
*/
playBgm(bgm: BgmIds | NameMapIn<BgmIds>, startTime?: number): void;
/**
* @deprecated
*
*/
pauseBgm(): void;
/**
* @deprecated
*
*/
resumeBgm(resumeTime?: number): void;
/**
* @deprecated
*
*/
setMusicBtn(): void;
/**
* @deprecated
*
*/
triggerBgm(): void;
/**
*
*
* @param sound
* @param pitch 100
* @param callback
* @returns
*/
playSound(
sound: SoundIds | NameMapIn<SoundIds>,
pitch?: number,
callback?: () => void
): number;
/**
* @deprecated
*
* @param id
*/
stopSound(id?: number): void;
/**
* @deprecated
* id列表
* @param name
*/
getPlayingSounds(name?: SoundIds | NameMapIn<SoundIds>): number[];
/**
* @deprecated
* bgm状态
*/
checkBgm(): void;
/**
*
* @param delta
*/
setDisplayScale(delta: number): void;
/**
*
*/
clearStatusBar(): void;
/**
*
* @param doNotCheckAutoEvents
* @param immediate
*/
updateStatusBar(doNotCheckAutoEvents?: boolean, immediate?: boolean): void;
/**
*
*/
showStatusBar(): void;
/**
*
* @param showToolbox
*/
hideStatusBar(showToolbox?: boolean): void;
/**
* 1-8
* @param useButton 1-8
*/
setToolbarButton(useButton?: boolean): void;
/**
* resize函数
* @param name 使
* @param func
*/
registerResize(name: string, func: ResizeFunc): void;
/**
* resize函数
*/
unregisterResize(name: string): void;
/**
*
*/
resize(): void;
_drawHero_updateViewport(x: number, y: number, offset: Loc): void;
_moveAction_moving(callback: () => void): void;
}
declare const control: new () => Control;