Skip to content

ModFeature

Defined in: packages/isaacscript-common/src/classes/ModFeature.ts:64

Helper class for mods that want to represent their individual features as classes. Extend your mod features from this class in order to enable the @Callback and @CustomCallback decorators that automatically subscribe to callbacks.

It is recommended that you use the initModFeatures helper function to instantiate all of your mod classes (instead of instantiating them yourself). This is so that any attached v objects are properly registered with the save data manager; see below.

If you are manually instantiating a mod feature yourself, then:

  • You must pass your upgraded mod as the first argument to the constructor.
  • In almost all cases, you will want the callback functions to be immediately subscribed after instantiating the class. However, if this is not the case, you can pass false as the optional second argument to the constructor.

If your mod feature has a property called v, it will be assumed that these are variables that should be managed by the save data manager. Unfortunately, due to technical limitations with classes, this registration will only occur if you initialize the class with the initModFeatures helper function. (This is because the parent class does not have access to the child’s properties upon first construction.)

new ModFeature(mod, init?): ModFeature

Defined in: packages/isaacscript-common/src/classes/ModFeature.ts:110

ModUpgraded

boolean = true

ModFeature

initialized: boolean = false

Defined in: packages/isaacscript-common/src/classes/ModFeature.ts:108

Whether the feature has registered its callbacks yet.

This will almost always be equal to true unless you explicitly passed false to the second argument of the constructor.

init(init?): void

Defined in: packages/isaacscript-common/src/classes/ModFeature.ts:124

Runs the Mod.AddCallback and ModUpgraded.AddCallbackCustom methods for all of the decorated callbacks. Also registers/unregisters the “v” variable on the save data manager.

boolean = true

Optional. Whether to initialize or uninitialize. Default is true.

void

uninit(): void

Defined in: packages/isaacscript-common/src/classes/ModFeature.ts:153

Runs the Mod.RemoveCallback and ModUpgraded.RemoveCallbackCustom methods for all of the decorated callbacks.

This is just an alias for ModFeature.init(false).

void

const MOD_FEATURE_CALLBACKS_KEY: "__callbacks" = "__callbacks"

Defined in: packages/isaacscript-common/src/classes/ModFeature.ts:17


const MOD_FEATURE_CUSTOM_CALLBACKS_KEY: "__customCallbacks" = "__customCallbacks"

Defined in: packages/isaacscript-common/src/classes/ModFeature.ts:18