isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
80 lines • 4.21 kB
TypeScript
import { CallbackPriority, ModCallback } from "isaac-typescript-definitions";
import { ModCallbackCustom } from "../enums/ModCallbackCustom";
import type { AddCallbackParametersCustom } from "../interfaces/private/AddCallbackParametersCustom";
/**
* `isaacscript-common` has many custom callbacks that you can use in your mods. Instead of
* hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to use, which
* extends the base class and adds a new method of `AddCallbackCustom`.
*
* To upgrade your mod, use the `upgradeMod` helper function.
*
* By specifying one or more optional features when upgrading your mod, you will get a version of
* `ModUpgraded` that has extra methods corresponding to the features that were specified. (This
* corresponds to the internal-type `ModUpgradedWithFeatures` type, which extends `ModUpgraded`.)
*/
export declare class ModUpgraded implements Mod {
Name: string;
/** We store a copy of the original mod object so that we can re-implement its functions. */
private readonly mod;
private readonly debug;
private readonly timeThreshold;
private readonly callbacks;
private readonly features;
constructor(mod: Mod, debug: boolean, timeThreshold?: float);
AddCallback<T extends keyof AddCallbackParameters | string>(modCallback: T, ...args: T extends keyof AddCallbackParameters ? AddCallbackParameters[T] : unknown[]): void;
AddPriorityCallback<T extends keyof AddCallbackParameters | string>(modCallback: T, priority: CallbackPriority | int, ...args: T extends keyof AddCallbackParameters ? AddCallbackParameters[T] : unknown[]): void;
HasData(): boolean;
LoadData(): string;
RemoveCallback<T extends ModCallback>(modCallback: T, callback: AddCallbackParameters[T][0]): void;
RemoveData(): void;
SaveData(data: string): void;
/**
* Registers a function to be executed when an in-game event happens.
*
* This method is specifically for events that are provided by the IsaacScript standard library.
* For example, the `ModCallbackCustom.POST_BOMB_EXPLODE` event corresponds to when a bomb
* explodes.
*/
AddCallbackCustom<T extends ModCallbackCustom>(modCallbackCustom: T, ...args: AddCallbackParametersCustom[T]): void;
/**
* The same as the `ModUpgraded.AddCallbackCustom` method, but allows setting a custom priority.
* By default, callbacks are added with a priority of 0, so this allows you to add early or late
* callbacks as necessary. See the `CallbackPriority` enum.
*/
AddPriorityCallbackCustom<T extends ModCallbackCustom>(modCallbackCustom: T, priority: CallbackPriority | int, ...args: AddCallbackParametersCustom[T]): void;
/**
* Unregisters a function that was previously registered with the `AddCallbackCustom` method.
*
* This method is specifically for events that are provided by the IsaacScript standard library.
* For example, the `ModCallbackCustom.POST_BOMB_EXPLODE` event corresponds to when a bomb
* explodes.
*
* This method does not care about the tertiary argument. In other words, regardless of the
* conditions of how you registered the callback, it will be removed.
*/
RemoveCallbackCustom<T extends ModCallbackCustom>(modCallbackCustom: T, callback: AddCallbackParametersCustom[T][0]): void;
/**
* Logs every custom callback or extra feature that is currently enabled. Useful for debugging or
* profiling.
*/
logUsedFeatures(): void;
/**
* This is used to initialize both custom callbacks and "extra features".
*
* This mirrors the `uninitFeature` method.
*/
private initFeature;
/**
* This is used to uninitialize both custom callbacks and "extra features".
*
* This mirrors the `initFeature` method.
*/
private uninitFeature;
/**
* Returns the names of the exported class methods from the features that were added. This is
* called from the "upgradeMod" function, but we want to mark it as private so that end-users
* don't have access to it.
*/
private initOptionalFeature;
}
//# sourceMappingURL=ModUpgraded.d.ts.map