ModFeature
Classes
Section titled “Classes”ModFeature
Section titled “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
falseas 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.)
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new ModFeature(
mod,init?):ModFeature
Defined in: packages/isaacscript-common/src/classes/ModFeature.ts:110
Parameters
Section titled “Parameters”boolean = true
Returns
Section titled “Returns”Properties
Section titled “Properties”initialized
Section titled “initialized”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.
Methods
Section titled “Methods”init()
Section titled “init()”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.
Parameters
Section titled “Parameters”boolean = true
Optional. Whether to initialize or uninitialize. Default is true.
Returns
Section titled “Returns”void
uninit()
Section titled “uninit()”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).
Returns
Section titled “Returns”void
Variables
Section titled “Variables”MOD_FEATURE_CALLBACKS_KEY
Section titled “MOD_FEATURE_CALLBACKS_KEY”
constMOD_FEATURE_CALLBACKS_KEY:"__callbacks"="__callbacks"
Defined in: packages/isaacscript-common/src/classes/ModFeature.ts:17
MOD_FEATURE_CUSTOM_CALLBACKS_KEY
Section titled “MOD_FEATURE_CUSTOM_CALLBACKS_KEY”
constMOD_FEATURE_CUSTOM_CALLBACKS_KEY:"__customCallbacks"="__customCallbacks"
Defined in: packages/isaacscript-common/src/classes/ModFeature.ts:18
