isaacscript-common
Version:
Helper functions and features for IsaacScript mods.
40 lines (39 loc) • 1.35 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Feature = void 0;
/**
* The IsaacScript standard library contains many optional features, such as the ability to create
* custom pickups. All features are optional and are only initialized when needed. This class
* contains elements to facilitate that.
*
* Additionally, all custom callbacks extend from this class.
*/
class Feature {
/**
* All features should only be instantiated once and are passed around to other features using
* dependency injection. We provide a run-time check in order to prevent the bug of any feature
* accidentally being instantiated twice.
*/
static constructedClassNames = new Set();
/** @internal */
initialized = false;
/** @internal */
numConsumers = 0;
/** @internal */
v;
/** @internal */
vConditionalFunc;
/** @internal */
featuresUsed;
/** @internal */
callbacksUsed;
/** @internal */
customCallbacksUsed;
constructor() {
if (Feature.constructedClassNames.has(this.constructor.name)) {
error(`Failed to instantiate feature class "${this.constructor.name}" because it has already been instantiated once.`);
}
Feature.constructedClassNames.add(this.constructor.name);
}
}
exports.Feature = Feature;