isaacscript-common 19.1.1 → 20.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts
CHANGED
|
@@ -11294,26 +11294,31 @@ declare class ModdedElementSets extends Feature {
|
|
|
11294
11294
|
export declare class ModFeature {
|
|
11295
11295
|
private mod;
|
|
11296
11296
|
/**
|
|
11297
|
-
* An optional
|
|
11297
|
+
* An optional method that allows for conditional callback execution. If specified, any class
|
|
11298
11298
|
* method that is annotated with a `@Callback` or `@CallbackCustom` decorator will only be fired
|
|
11299
11299
|
* if the executed conditional function returns true.
|
|
11300
11300
|
*
|
|
11301
11301
|
* This property is used to easily turn entire mod features on and off (rather than repeating
|
|
11302
11302
|
* conditional logic and early returning at the beginning of every callback function).
|
|
11303
11303
|
*
|
|
11304
|
-
*
|
|
11304
|
+
* Since the specific information for the firing callback is passed as arguments into the
|
|
11305
|
+
* conditional method, you can also write logic that would only apply to a specific type of
|
|
11306
|
+
* callback.
|
|
11307
|
+
*
|
|
11308
|
+
* By default, this is set to null, which means that all callback methods will fire
|
|
11309
|
+
* unconditionally. Override this property in your class if you need to use it.
|
|
11305
11310
|
*
|
|
11306
11311
|
* The function has the following signature:
|
|
11307
11312
|
*
|
|
11308
11313
|
* ```ts
|
|
11309
|
-
* (
|
|
11310
|
-
* vanilla:
|
|
11311
|
-
* modCallback: ModCallback
|
|
11312
|
-
* ...callbackArgs: unknown[]
|
|
11314
|
+
* <T extends boolean>(
|
|
11315
|
+
* vanilla: T, // Whether or not this is a vanilla or custom callback.
|
|
11316
|
+
* modCallback: T extends true ? ModCallback : ModCallbackCustom,
|
|
11317
|
+
* ...callbackArgs: unknown[] // This would be e.g. `pickup: EntityPickup` for the `POST_PICKUP_INIT` callback.
|
|
11313
11318
|
* ) => boolean;
|
|
11314
11319
|
* ```
|
|
11315
11320
|
*/
|
|
11316
|
-
protected
|
|
11321
|
+
protected shouldCallbackMethodsFire: (<T extends boolean>(vanilla: T, modCallback: T extends true ? ModCallback : ModCallbackCustom, ...callbackArgs: unknown[]) => boolean) | null;
|
|
11317
11322
|
/**
|
|
11318
11323
|
* Whether or not the feature has registered its callbacks yet (and submitted its variables to the
|
|
11319
11324
|
* save data manager, if any).
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common
|
|
3
|
+
isaacscript-common 20.0.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -49510,7 +49510,7 @@ function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, va
|
|
|
49510
49510
|
end
|
|
49511
49511
|
function addCallback(self, modFeature, modFeatureConstructor, mod, modCallback, callback, parameters, vanilla)
|
|
49512
49512
|
local function wrappedCallback(____, ...)
|
|
49513
|
-
local conditionalFunc = modFeature.
|
|
49513
|
+
local conditionalFunc = modFeature.shouldCallbackMethodsFire
|
|
49514
49514
|
if conditionalFunc ~= nil then
|
|
49515
49515
|
local shouldRun = conditionalFunc(nil, vanilla, modCallback, ...)
|
|
49516
49516
|
if not shouldRun then
|
|
@@ -49605,7 +49605,7 @@ function ModFeature.prototype.____constructor(self, mod, init)
|
|
|
49605
49605
|
if init == nil then
|
|
49606
49606
|
init = true
|
|
49607
49607
|
end
|
|
49608
|
-
self.
|
|
49608
|
+
self.shouldCallbackMethodsFire = nil
|
|
49609
49609
|
self.initialized = false
|
|
49610
49610
|
self.mod = mod
|
|
49611
49611
|
if init then
|
|
@@ -39,26 +39,31 @@ export declare const MOD_FEATURE_CUSTOM_CALLBACKS_KEY = "__customCallbacks";
|
|
|
39
39
|
export declare class ModFeature {
|
|
40
40
|
private mod;
|
|
41
41
|
/**
|
|
42
|
-
* An optional
|
|
42
|
+
* An optional method that allows for conditional callback execution. If specified, any class
|
|
43
43
|
* method that is annotated with a `@Callback` or `@CallbackCustom` decorator will only be fired
|
|
44
44
|
* if the executed conditional function returns true.
|
|
45
45
|
*
|
|
46
46
|
* This property is used to easily turn entire mod features on and off (rather than repeating
|
|
47
47
|
* conditional logic and early returning at the beginning of every callback function).
|
|
48
48
|
*
|
|
49
|
-
*
|
|
49
|
+
* Since the specific information for the firing callback is passed as arguments into the
|
|
50
|
+
* conditional method, you can also write logic that would only apply to a specific type of
|
|
51
|
+
* callback.
|
|
52
|
+
*
|
|
53
|
+
* By default, this is set to null, which means that all callback methods will fire
|
|
54
|
+
* unconditionally. Override this property in your class if you need to use it.
|
|
50
55
|
*
|
|
51
56
|
* The function has the following signature:
|
|
52
57
|
*
|
|
53
58
|
* ```ts
|
|
54
|
-
* (
|
|
55
|
-
* vanilla:
|
|
56
|
-
* modCallback: ModCallback
|
|
57
|
-
* ...callbackArgs: unknown[]
|
|
59
|
+
* <T extends boolean>(
|
|
60
|
+
* vanilla: T, // Whether or not this is a vanilla or custom callback.
|
|
61
|
+
* modCallback: T extends true ? ModCallback : ModCallbackCustom,
|
|
62
|
+
* ...callbackArgs: unknown[] // This would be e.g. `pickup: EntityPickup` for the `POST_PICKUP_INIT` callback.
|
|
58
63
|
* ) => boolean;
|
|
59
64
|
* ```
|
|
60
65
|
*/
|
|
61
|
-
protected
|
|
66
|
+
protected shouldCallbackMethodsFire: (<T extends boolean>(vanilla: T, modCallback: T extends true ? ModCallback : ModCallbackCustom, ...callbackArgs: unknown[]) => boolean) | null;
|
|
62
67
|
/**
|
|
63
68
|
* Whether or not the feature has registered its callbacks yet (and submitted its variables to the
|
|
64
69
|
* save data manager, if any).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAS/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,gCAAgC,sBAAsB,CAAC;AAyBpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAkB;IAE7B
|
|
1
|
+
{"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAS/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,gCAAgC,sBAAsB,CAAC;AAyBpE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAkB;IAE7B;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,SAAS,CAAC,yBAAyB,EAC/B,CAAC,CAAC,CAAC,SAAS,OAAO,EACjB,OAAO,EAAE,CAAC,EACV,WAAW,EAAE,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,iBAAiB,EAC7D,GAAG,YAAY,EAAE,OAAO,EAAE,KACvB,OAAO,CAAC,GACb,IAAI,CAAQ;IAEhB;;;;;;OAMG;IACI,WAAW,UAAS;gBAEf,GAAG,EAAE,eAAe,EAAE,IAAI,UAAO;IAQ7C;;;;;OAKG;IACI,IAAI,CAAC,IAAI,UAAO,GAAG,IAAI;IAqB9B;;;;;;OAMG;IACI,MAAM,IAAI,IAAI;CAGtB"}
|
|
@@ -64,7 +64,7 @@ function initDecoratedCallbacks(self, modFeature, constructor, tstlClassName, va
|
|
|
64
64
|
end
|
|
65
65
|
function addCallback(self, modFeature, modFeatureConstructor, mod, modCallback, callback, parameters, vanilla)
|
|
66
66
|
local function wrappedCallback(____, ...)
|
|
67
|
-
local conditionalFunc = modFeature.
|
|
67
|
+
local conditionalFunc = modFeature.shouldCallbackMethodsFire
|
|
68
68
|
if conditionalFunc ~= nil then
|
|
69
69
|
local shouldRun = conditionalFunc(nil, vanilla, modCallback, ...)
|
|
70
70
|
if not shouldRun then
|
|
@@ -190,7 +190,7 @@ function ModFeature.prototype.____constructor(self, mod, init)
|
|
|
190
190
|
if init == nil then
|
|
191
191
|
init = true
|
|
192
192
|
end
|
|
193
|
-
self.
|
|
193
|
+
self.shouldCallbackMethodsFire = nil
|
|
194
194
|
self.initialized = false
|
|
195
195
|
self.mod = mod
|
|
196
196
|
if init then
|
package/package.json
CHANGED
|
@@ -74,29 +74,34 @@ export class ModFeature {
|
|
|
74
74
|
private mod: ModUpgradedBase;
|
|
75
75
|
|
|
76
76
|
/**
|
|
77
|
-
* An optional
|
|
77
|
+
* An optional method that allows for conditional callback execution. If specified, any class
|
|
78
78
|
* method that is annotated with a `@Callback` or `@CallbackCustom` decorator will only be fired
|
|
79
79
|
* if the executed conditional function returns true.
|
|
80
80
|
*
|
|
81
81
|
* This property is used to easily turn entire mod features on and off (rather than repeating
|
|
82
82
|
* conditional logic and early returning at the beginning of every callback function).
|
|
83
83
|
*
|
|
84
|
-
*
|
|
84
|
+
* Since the specific information for the firing callback is passed as arguments into the
|
|
85
|
+
* conditional method, you can also write logic that would only apply to a specific type of
|
|
86
|
+
* callback.
|
|
87
|
+
*
|
|
88
|
+
* By default, this is set to null, which means that all callback methods will fire
|
|
89
|
+
* unconditionally. Override this property in your class if you need to use it.
|
|
85
90
|
*
|
|
86
91
|
* The function has the following signature:
|
|
87
92
|
*
|
|
88
93
|
* ```ts
|
|
89
|
-
* (
|
|
90
|
-
* vanilla:
|
|
91
|
-
* modCallback: ModCallback
|
|
92
|
-
* ...callbackArgs: unknown[]
|
|
94
|
+
* <T extends boolean>(
|
|
95
|
+
* vanilla: T, // Whether or not this is a vanilla or custom callback.
|
|
96
|
+
* modCallback: T extends true ? ModCallback : ModCallbackCustom,
|
|
97
|
+
* ...callbackArgs: unknown[] // This would be e.g. `pickup: EntityPickup` for the `POST_PICKUP_INIT` callback.
|
|
93
98
|
* ) => boolean;
|
|
94
99
|
* ```
|
|
95
100
|
*/
|
|
96
|
-
protected
|
|
97
|
-
| ((
|
|
98
|
-
vanilla:
|
|
99
|
-
modCallback: ModCallback
|
|
101
|
+
protected shouldCallbackMethodsFire:
|
|
102
|
+
| (<T extends boolean>(
|
|
103
|
+
vanilla: T,
|
|
104
|
+
modCallback: T extends true ? ModCallback : ModCallbackCustom,
|
|
100
105
|
...callbackArgs: unknown[]
|
|
101
106
|
) => boolean)
|
|
102
107
|
| null = null;
|
|
@@ -250,7 +255,7 @@ function addCallback(
|
|
|
250
255
|
// first argument. (Otherwise, the method will not be able to properly access `this`.
|
|
251
256
|
const wrappedCallback = (...callbackArgs: unknown[]) => {
|
|
252
257
|
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
253
|
-
const conditionalFunc = modFeature["
|
|
258
|
+
const conditionalFunc = modFeature["shouldCallbackMethodsFire"];
|
|
254
259
|
if (conditionalFunc !== null) {
|
|
255
260
|
const shouldRun = conditionalFunc(vanilla, modCallback, ...callbackArgs);
|
|
256
261
|
if (!shouldRun) {
|