UNPKG

isaacscript-common

Version:

Helper functions and features for IsaacScript mods.

60 lines 2.89 kB
/** * If you decide to structure your mod as a set of feature classes, you can use decorators to * automatically register callbacks. * * Currently, there are two decorators: * - `@Callback` * - `@CallbackCustom` * * For example: * * ```ts * export class MyFeature extends ModFeature { * @Callback(ModCallback.POST_GAME_STARTED) * postGameStarted(isContinued: boolean): void { * Isaac.DebugString(`Callback fired: POST_GAME_STARTED`); * } * } * ``` * * @module */ import type { ModCallback } from "isaac-typescript-definitions"; import { CallbackPriority } from "isaac-typescript-definitions"; import type { ModFeature } from "../classes/ModFeature"; import type { ModCallbackCustom } from "../enums/ModCallbackCustom"; import type { AddCallbackParametersCustom } from "../interfaces/private/AddCallbackParametersCustom"; import type { AllButFirst } from "../types/AllButFirst"; /** * A decorator function that signifies that the decorated class method should be automatically * registered with `Mod.AddCallback`. * * @allowEmptyVariadic * @ignore */ export declare function Callback<T extends ModCallback>(modCallback: T, ...optionalArgs: AllButFirst<AddCallbackParameters[T]>): <Fn extends AddCallbackParameters[T][0]>(target: ModFeature, propertyKey: string, _descriptor: TypedPropertyDescriptor<Fn>) => void; /** * A decorator function that signifies that the decorated class method should be automatically * registered with `ModUpgraded.AddCallbackCustom`. * * @allowEmptyVariadic * @ignore */ export declare function CallbackCustom<T extends ModCallbackCustom>(modCallbackCustom: T, ...optionalArgs: AllButFirst<AddCallbackParametersCustom[T]>): <Fn extends AddCallbackParametersCustom[T][0]>(target: ModFeature, propertyKey: string, _descriptor: TypedPropertyDescriptor<Fn>) => void; /** * A decorator function that signifies that the decorated class method should be automatically * registered with `Mod.AddPriorityCallback`. * * @allowEmptyVariadic * @ignore */ export declare function PriorityCallback<T extends ModCallback>(modCallback: T, priority: CallbackPriority | int, ...optionalArgs: AllButFirst<AddCallbackParameters[T]>): <Fn extends AddCallbackParameters[T][0]>(target: ModFeature, propertyKey: string, _descriptor: TypedPropertyDescriptor<Fn>) => void; /** * A decorator function that signifies that the decorated class method should be automatically * registered with `ModUpgraded.AddCallbackCustom`. * * @allowEmptyVariadic * @ignore */ export declare function PriorityCallbackCustom<T extends ModCallbackCustom>(modCallbackCustom: T, priority: CallbackPriority | int, ...optionalArgs: AllButFirst<AddCallbackParametersCustom[T]>): <Fn extends AddCallbackParametersCustom[T][0]>(target: ModFeature, propertyKey: string, _descriptor: TypedPropertyDescriptor<Fn>) => void; //# sourceMappingURL=decorators.d.ts.map