import Barrage from './barrage'; import Player from './player'; /** hook function for interval tasks of an updater */ export declare type IntervalHook = (this: T, tick: number, wave: number) => void; /** hook function for general tasks of an updater */ export declare type TaskHook = (this: T, tick: number) => R; /** hook function for mounting tasks of an updater */ export declare type MountHook = (this: T) => void; /** general updating object */ export default class Updater { /** @private updater properties */ private __updater__; /** @private mounted hook */ _mounted?(): void; /** @public rendering context */ $context: CanvasRenderingContext2D; /** @public the current tick number */ $tick: number; /** @public parent object */ $parent: any; /** @public barrage */ $barrage: Barrage; /** @public player */ $player: Player; constructor(); /** initialize */ initialize(context: CanvasRenderingContext2D, parent: any, barrage?: Barrage): this; /** perform an update cycle */ update(): void; /** * set a scheduled task * @param callback the task callback * @param index the position where the task will be inserted (default: `Infinity`) * @param preserve whether the task will be preserved after executed (default: `true`) * @returns a number which indicates the task id */ setTask(callback: TaskHook, index?: number, preserve?: boolean): number; /** * set a timeout task * @param ticks the ticks to wait before the callback * @param callback the task callback * @returns a number which indicates the task id */ setTimeout(ticks: number, callback: TaskHook): number; /** * set an interval task * @param interval the ticks to wait during every interval * @param times the total times for callback to execute (default: `Infinity`) * @param offset the offset ticks before the first interval (default: `0`) * @param callback the task callback * @returns a number which indicates the task id */ setInterval(interval: number, callback: IntervalHook): number; setInterval(interval: number, times: number, callback: IntervalHook): number; setInterval(interval: number, times: number, offset: number, callback: IntervalHook): number; /** * remove a scheduled task * @param id task id (default: current task id) */ removeTask(id?: number): void; }