isaacscript-common 15.2.0 → 15.3.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 +66 -44
- package/dist/isaacscript-common.lua +110 -59
- package/dist/src/classes/ModFeature.d.ts +12 -1
- package/dist/src/classes/ModFeature.d.ts.map +1 -1
- package/dist/src/classes/ModFeature.lua +112 -55
- package/dist/src/classes/callbacks/PostNPCInitFilter.d.ts +0 -5
- package/dist/src/classes/callbacks/PostNPCInitFilter.d.ts.map +1 -1
- package/dist/src/classes/callbacks/PostNPCInitFilter.lua +0 -3
- package/dist/src/classes/callbacks/PostNPCUpdateFilter.d.ts +0 -5
- package/dist/src/classes/callbacks/PostNPCUpdateFilter.d.ts.map +1 -1
- package/dist/src/classes/callbacks/PostNPCUpdateFilter.lua +0 -3
- package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.d.ts +21 -13
- package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.d.ts.map +1 -1
- package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.lua +7 -1
- package/dist/src/classes/features/other/CustomPickups.d.ts.map +1 -1
- package/dist/src/classes/features/other/DebugDisplay.lua +1 -1
- package/dist/src/enums/ModCallbackCustom.d.ts +33 -30
- package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/classes/ModFeature.ts +132 -75
- package/src/classes/callbacks/PostNPCInitFilter.ts +0 -6
- package/src/classes/callbacks/PostNPCUpdateFilter.ts +0 -6
- package/src/classes/features/callbackLogic/GameReorderedCallbacks.ts +21 -13
- package/src/classes/features/other/CustomPickups.ts +0 -4
- package/src/classes/features/other/DebugDisplay.ts +1 -1
- package/src/enums/ModCallbackCustom.ts +33 -30
- package/dist/src/indexLua.d.ts +0 -171
- package/dist/src/indexLua.d.ts.map +0 -1
- package/dist/src/indexLua.lua +0 -1042
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { ModCallback } from "isaac-typescript-definitions";
|
|
2
2
|
import { ModCallbackCustom } from "../enums/ModCallbackCustom";
|
|
3
|
+
import { isArray } from "../functions/array";
|
|
4
|
+
import { deepCopy } from "../functions/deepCopy";
|
|
3
5
|
import {
|
|
4
6
|
getTSTLClassConstructor,
|
|
5
7
|
getTSTLClassName,
|
|
@@ -11,10 +13,14 @@ import { ModUpgradedBase } from "./ModUpgradedBase";
|
|
|
11
13
|
|
|
12
14
|
export const ADD_CALLBACK_ARGS_KEY = "__addCallbackArgs";
|
|
13
15
|
export const ADD_CALLBACK_CUSTOM_ARGS_KEY = "__addCallbackCustomArgs";
|
|
16
|
+
const WRAPPED_CALLBACK_METHODS_KEY = "__wrappedCallbackMethods";
|
|
17
|
+
const WRAPPED_CUSTOM_CALLBACK_METHODS_KEY = "__wrappedCustomCallbacksMethods";
|
|
14
18
|
|
|
15
19
|
type ModFeatureConstructor = TSTLClassMetatable["constructor"] & {
|
|
16
|
-
[ADD_CALLBACK_ARGS_KEY]: unknown
|
|
17
|
-
[ADD_CALLBACK_CUSTOM_ARGS_KEY]: unknown
|
|
20
|
+
[ADD_CALLBACK_ARGS_KEY]: unknown | undefined;
|
|
21
|
+
[ADD_CALLBACK_CUSTOM_ARGS_KEY]: unknown | undefined;
|
|
22
|
+
[WRAPPED_CALLBACK_METHODS_KEY]: Map<ModCallback, AnyFunction>;
|
|
23
|
+
[WRAPPED_CUSTOM_CALLBACK_METHODS_KEY]: Map<ModCallbackCustom, AnyFunction>;
|
|
18
24
|
};
|
|
19
25
|
|
|
20
26
|
/**
|
|
@@ -42,86 +48,83 @@ type ModFeatureConstructor = TSTLClassMetatable["constructor"] & {
|
|
|
42
48
|
* }
|
|
43
49
|
* }
|
|
44
50
|
* ```
|
|
51
|
+
*
|
|
52
|
+
* In almost all cases, you will want the callback functions to be immediately subscribed after
|
|
53
|
+
* instantiating the class. However, if this is not the case, you can pass `false` as the optional
|
|
54
|
+
* second argument to the constructor.
|
|
45
55
|
*/
|
|
46
|
-
|
|
56
|
+
|
|
47
57
|
export class ModFeature {
|
|
48
|
-
|
|
58
|
+
private mod: ModUpgradedBase;
|
|
59
|
+
|
|
60
|
+
constructor(mod: ModUpgradedBase, init = true) {
|
|
61
|
+
this.mod = mod;
|
|
62
|
+
|
|
63
|
+
if (init) {
|
|
64
|
+
this.init();
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Runs the `Mod.AddCallback` and `ModUpgraded.AddCallbackCustom` methods for all of the decorated
|
|
70
|
+
* callbacks. Additionally, subscribes the `v` object to the save data manager, if present.
|
|
71
|
+
*/
|
|
72
|
+
public init(init = true): void {
|
|
49
73
|
const constructor = getTSTLClassConstructor(this);
|
|
50
74
|
if (constructor === undefined) {
|
|
51
75
|
error("Failed to get the TSTL class constructor for a mod feature.");
|
|
52
76
|
}
|
|
53
77
|
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
78
|
+
const tstlClassName = getTSTLClassName(constructor);
|
|
79
|
+
if (tstlClassName === undefined) {
|
|
80
|
+
error("Failed to get the TSTL class name for a mod feature.");
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
initDecoratedCallbacks(this, constructor, tstlClassName, true, init);
|
|
84
|
+
initDecoratedCallbacks(this, constructor, tstlClassName, false, init);
|
|
85
|
+
initSaveDataManager(this, tstlClassName, init);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public uninit(): void {
|
|
89
|
+
this.init(false);
|
|
58
90
|
}
|
|
59
91
|
}
|
|
60
92
|
|
|
61
|
-
function
|
|
62
|
-
mod: ModUpgradedBase,
|
|
63
|
-
modFeatureConstructor: ModFeatureConstructor,
|
|
93
|
+
function initDecoratedCallbacks(
|
|
64
94
|
modFeature: ModFeature,
|
|
95
|
+
constructor: TSTLClassMetatable["constructor"],
|
|
96
|
+
tstlClassName: string,
|
|
97
|
+
vanilla: boolean,
|
|
98
|
+
init: boolean,
|
|
65
99
|
) {
|
|
66
|
-
const
|
|
100
|
+
const modFeatureConstructor = constructor as ModFeatureConstructor;
|
|
101
|
+
const argsKey = vanilla
|
|
102
|
+
? ADD_CALLBACK_ARGS_KEY
|
|
103
|
+
: ADD_CALLBACK_CUSTOM_ARGS_KEY;
|
|
104
|
+
const addCallbackArgs = modFeatureConstructor[argsKey];
|
|
67
105
|
if (addCallbackArgs === undefined) {
|
|
68
106
|
return;
|
|
69
107
|
}
|
|
70
108
|
|
|
71
|
-
|
|
109
|
+
if (!isArray(addCallbackArgs)) {
|
|
110
|
+
error(
|
|
111
|
+
`Failed to initialize/uninitialize the decorated callbacks on a mod feature since the callback arguments on the key of "${argsKey}" was not an array.`,
|
|
112
|
+
);
|
|
113
|
+
}
|
|
72
114
|
|
|
73
115
|
for (const args of addCallbackArgs) {
|
|
74
|
-
|
|
75
|
-
const modCallback = parameters.shift() as ModCallback | undefined;
|
|
76
|
-
if (modCallback === undefined) {
|
|
116
|
+
if (!isArray(args)) {
|
|
77
117
|
error(
|
|
78
|
-
|
|
118
|
+
"Failed to initialize/uninitialize the decorated callbacks on a mod feature since one of the callback arguments was not an array.",
|
|
79
119
|
);
|
|
80
120
|
}
|
|
81
121
|
|
|
82
|
-
const
|
|
83
|
-
| ((this: void, ...callbackArgs: unknown[]) => void)
|
|
84
|
-
| undefined;
|
|
85
|
-
if (callback === undefined) {
|
|
86
|
-
error(
|
|
87
|
-
`Failed to get the callback from the parameters for class: ${tstlClassName}`,
|
|
88
|
-
);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* We need to wrap the callback in a new function so that we can explicitly pass the class as
|
|
93
|
-
* the first argument. (Otherwise, the method will not be able to properly access `this`.
|
|
94
|
-
*/
|
|
95
|
-
const newCallback = (...callbackArgs: unknown[]) => {
|
|
96
|
-
callback(modFeature, ...callbackArgs);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// @ts-expect-error The compiler does not know that the arguments match the method.
|
|
100
|
-
mod.AddCallback(modCallback, newCallback, ...parameters);
|
|
101
|
-
}
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
function checkAddDecoratedCallbacksCustom(
|
|
105
|
-
mod: ModUpgradedBase,
|
|
106
|
-
modFeatureConstructor: ModFeatureConstructor,
|
|
107
|
-
modFeature: ModFeature,
|
|
108
|
-
) {
|
|
109
|
-
const addCallbackCustomArgs =
|
|
110
|
-
modFeatureConstructor[ADD_CALLBACK_CUSTOM_ARGS_KEY];
|
|
111
|
-
if (addCallbackCustomArgs === undefined) {
|
|
112
|
-
return;
|
|
113
|
-
}
|
|
122
|
+
const parameters = deepCopy(args);
|
|
114
123
|
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
for (const args of addCallbackCustomArgs) {
|
|
118
|
-
const parameters = args as unknown[];
|
|
119
|
-
const modCallbackCustom = parameters.shift() as
|
|
120
|
-
| ModCallbackCustom
|
|
121
|
-
| undefined;
|
|
122
|
-
if (modCallbackCustom === undefined) {
|
|
124
|
+
const modCallback = parameters.shift();
|
|
125
|
+
if (modCallback === undefined) {
|
|
123
126
|
error(
|
|
124
|
-
`Failed to get the
|
|
127
|
+
`Failed to get the callback number from the parameters for class: ${tstlClassName}`,
|
|
125
128
|
);
|
|
126
129
|
}
|
|
127
130
|
|
|
@@ -130,26 +133,66 @@ function checkAddDecoratedCallbacksCustom(
|
|
|
130
133
|
| undefined;
|
|
131
134
|
if (callback === undefined) {
|
|
132
135
|
error(
|
|
133
|
-
`Failed to get the callback from the parameters for class: ${tstlClassName}`,
|
|
136
|
+
`Failed to get the callback function from the parameters for class: ${tstlClassName}`,
|
|
134
137
|
);
|
|
135
138
|
}
|
|
136
139
|
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
140
|
+
// eslint-disable-next-line prefer-destructuring, @typescript-eslint/dot-notation
|
|
141
|
+
const mod = modFeature["mod"];
|
|
142
|
+
|
|
143
|
+
if (init) {
|
|
144
|
+
// We need to wrap the callback in a new function so that we can explicitly pass the class as
|
|
145
|
+
// the first argument. (Otherwise, the method will not be able to properly access `this`.
|
|
146
|
+
const wrappedCallback = (...callbackArgs: unknown[]) => {
|
|
147
|
+
callback(modFeature, ...callbackArgs);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
// We need to save the wrapped function for later (so we can unregister them).
|
|
151
|
+
if (vanilla) {
|
|
152
|
+
const modCallbackVanilla = modCallback as ModCallback;
|
|
153
|
+
const wrappedMethodsMap =
|
|
154
|
+
modFeatureConstructor[WRAPPED_CALLBACK_METHODS_KEY];
|
|
155
|
+
wrappedMethodsMap.set(modCallbackVanilla, wrappedCallback);
|
|
156
|
+
} else {
|
|
157
|
+
const modCallbackCustom = modCallback as ModCallbackCustom;
|
|
158
|
+
const wrappedMethodsMap =
|
|
159
|
+
modFeatureConstructor[WRAPPED_CUSTOM_CALLBACK_METHODS_KEY];
|
|
160
|
+
wrappedMethodsMap.set(modCallbackCustom, wrappedCallback);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
if (vanilla) {
|
|
164
|
+
(mod.AddCallback as AnyFunction)(
|
|
165
|
+
modCallback,
|
|
166
|
+
wrappedCallback,
|
|
167
|
+
...parameters,
|
|
168
|
+
);
|
|
169
|
+
} else {
|
|
170
|
+
(mod.AddCallbackCustom as AnyFunction)(
|
|
171
|
+
modCallback,
|
|
172
|
+
wrappedCallback,
|
|
173
|
+
...parameters,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
} else if (vanilla) {
|
|
177
|
+
const modCallbackVanilla = modCallback as ModCallback;
|
|
178
|
+
const wrappedMethodsMap =
|
|
179
|
+
modFeatureConstructor[WRAPPED_CALLBACK_METHODS_KEY];
|
|
180
|
+
const wrappedCallback = wrappedMethodsMap.get(modCallbackVanilla);
|
|
181
|
+
(mod.RemoveCallback as AnyFunction)(modCallback, wrappedCallback);
|
|
182
|
+
} else {
|
|
183
|
+
const modCallbackCustom = modCallback as ModCallbackCustom;
|
|
184
|
+
const wrappedMethodsMap =
|
|
185
|
+
modFeatureConstructor[WRAPPED_CUSTOM_CALLBACK_METHODS_KEY];
|
|
186
|
+
const wrappedCallback = wrappedMethodsMap.get(modCallbackCustom);
|
|
187
|
+
(mod.RemoveCallbackCustom as AnyFunction)(modCallback, wrappedCallback);
|
|
188
|
+
}
|
|
147
189
|
}
|
|
148
190
|
}
|
|
149
191
|
|
|
150
|
-
function
|
|
151
|
-
mod: ModUpgradedBase,
|
|
192
|
+
function initSaveDataManager(
|
|
152
193
|
modFeature: ModFeature,
|
|
194
|
+
tstlClassName: string,
|
|
195
|
+
init: boolean,
|
|
153
196
|
) {
|
|
154
197
|
// Do nothing if this class does not have any variables.
|
|
155
198
|
const { v } = modFeature as unknown as Record<string, unknown>;
|
|
@@ -164,13 +207,27 @@ function checkRegisterSaveDataManager(
|
|
|
164
207
|
}
|
|
165
208
|
|
|
166
209
|
// Do nothing if we have not enabled the save data manager.
|
|
167
|
-
|
|
168
|
-
|
|
210
|
+
// eslint-disable-next-line @typescript-eslint/dot-notation
|
|
211
|
+
const mod = modFeature["mod"] as unknown as Record<string, unknown>;
|
|
212
|
+
const saveDataManagerMethodName = init
|
|
213
|
+
? "saveDataManager"
|
|
214
|
+
: "saveDataManagerRemove";
|
|
215
|
+
const saveDataManagerMethod = mod[saveDataManagerMethodName];
|
|
216
|
+
if (saveDataManagerMethod === undefined) {
|
|
169
217
|
error(
|
|
170
218
|
'Failed to initialize a mod feature class due to having a "v" object and not having the save data manager initialized. You must pass "ISCFeature.SAVE_DATA_MANAGER" to the "upgradeMod" function.',
|
|
171
219
|
);
|
|
172
220
|
}
|
|
173
221
|
|
|
174
|
-
|
|
175
|
-
|
|
222
|
+
if (typeof saveDataManagerMethod !== "function") {
|
|
223
|
+
error(
|
|
224
|
+
`The "${saveDataManagerMethodName}" property of the "ModUpgraded" object was not a function.`,
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
if (init) {
|
|
229
|
+
saveDataManagerMethod(tstlClassName, v);
|
|
230
|
+
} else {
|
|
231
|
+
saveDataManagerMethod(tstlClassName);
|
|
232
|
+
}
|
|
176
233
|
}
|
|
@@ -4,12 +4,6 @@ import { shouldFireNPC } from "../../shouldFire";
|
|
|
4
4
|
import { CustomCallback } from "../private/CustomCallback";
|
|
5
5
|
|
|
6
6
|
export class PostNPCInitFilter extends CustomCallback<ModCallbackCustom.POST_NPC_INIT_FILTER> {
|
|
7
|
-
public override v = {
|
|
8
|
-
room: {
|
|
9
|
-
firedSet: new Set<PtrHash>(),
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
7
|
constructor() {
|
|
14
8
|
super();
|
|
15
9
|
|
|
@@ -4,12 +4,6 @@ import { shouldFireNPC } from "../../shouldFire";
|
|
|
4
4
|
import { CustomCallback } from "../private/CustomCallback";
|
|
5
5
|
|
|
6
6
|
export class PostNPCUpdateFilter extends CustomCallback<ModCallbackCustom.POST_NPC_UPDATE_FILTER> {
|
|
7
|
-
public override v = {
|
|
8
|
-
room: {
|
|
9
|
-
firedSet: new Set<PtrHash>(),
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
|
|
13
7
|
constructor() {
|
|
14
8
|
super();
|
|
15
9
|
|
|
@@ -19,7 +19,13 @@ import { Feature } from "../../private/Feature";
|
|
|
19
19
|
* It is easier to write mod code if the callbacks run in a more logical order:
|
|
20
20
|
* - `POST_GAME_STARTED` --> `POST_NEW_LEVEL` --> `POST_NEW_ROOM`
|
|
21
21
|
*
|
|
22
|
-
*
|
|
22
|
+
* `isaacscript-common` provides three new callbacks that change the order to this:
|
|
23
|
+
* - `POST_GAME_STARTED_REORDERED`
|
|
24
|
+
* - `POST_NEW_LEVEL_REORDERED`
|
|
25
|
+
* - `POST_NEW_ROOM_REORDERED`
|
|
26
|
+
*
|
|
27
|
+
* Additionally, there are some helper functions listed below that can deal with some edge cases
|
|
28
|
+
* that you may run into with these callbacks.
|
|
23
29
|
*/
|
|
24
30
|
export class GameReorderedCallbacks extends Feature {
|
|
25
31
|
private currentStage: int | null = null;
|
|
@@ -140,12 +146,13 @@ export class GameReorderedCallbacks extends Feature {
|
|
|
140
146
|
* the next `POST_NEW_LEVEL`.
|
|
141
147
|
*
|
|
142
148
|
* If some specific cases, mods can change the current level during run initialization on the 0th
|
|
143
|
-
* frame.
|
|
144
|
-
*
|
|
145
|
-
*
|
|
149
|
+
* frame. (For example, if you had a mod that made the player start the run in Caves instead of
|
|
150
|
+
* Basement.) However, due to how the callback reordering works, the `POST_NEW_LEVEL_REORDERED`
|
|
151
|
+
* callback will never fire on the 0th frame. To get around this, call this function before
|
|
152
|
+
* changing levels to temporarily force the callback to fire.
|
|
146
153
|
*
|
|
147
154
|
* In order to use this function, you must upgrade your mod with
|
|
148
|
-
* `ISCFeature.
|
|
155
|
+
* `ISCFeature.GAME_REORDERED_CALLBACKS`.
|
|
149
156
|
*/
|
|
150
157
|
@Exported
|
|
151
158
|
public forceNewLevelCallback(): void {
|
|
@@ -157,12 +164,13 @@ export class GameReorderedCallbacks extends Feature {
|
|
|
157
164
|
* the next `POST_NEW_ROOM`.
|
|
158
165
|
*
|
|
159
166
|
* If some specific cases, mods can change the current room during run initialization on the 0th
|
|
160
|
-
* frame.
|
|
161
|
-
*
|
|
162
|
-
*
|
|
167
|
+
* frame. (For example, if you had a mod that made the player start the Treasure Room of Basement
|
|
168
|
+
* 1 instead of the normal starting room.) However, due to how the callback reordering works, the
|
|
169
|
+
* `POST_NEW_ROOM_REORDERED` callback will never fire on the 0th frame. To get around this, call
|
|
170
|
+
* this function before changing rooms to temporarily force the callback to fire.
|
|
163
171
|
*
|
|
164
172
|
* In order to use this function, you must upgrade your mod with
|
|
165
|
-
* `ISCFeature.
|
|
173
|
+
* `ISCFeature.GAME_REORDERED_CALLBACKS`.
|
|
166
174
|
*/
|
|
167
175
|
@Exported
|
|
168
176
|
public forceNewRoomCallback(): void {
|
|
@@ -170,14 +178,14 @@ export class GameReorderedCallbacks extends Feature {
|
|
|
170
178
|
}
|
|
171
179
|
|
|
172
180
|
/**
|
|
173
|
-
* Helper function to manually set the
|
|
181
|
+
* Helper function to manually set the variables that the reordered callback logic uses to track
|
|
174
182
|
* the current stage and stage type.
|
|
175
183
|
*
|
|
176
|
-
* This is useful because if the stage is changed with the `Game.SetStage` method
|
|
177
|
-
* callbacks will stop working.
|
|
184
|
+
* This is useful because if the stage is changed with the `Game.SetStage` method (or the
|
|
185
|
+
* `setStage` helper function), the reordered callbacks will stop working.
|
|
178
186
|
*
|
|
179
187
|
* In order to use this function, you must upgrade your mod with
|
|
180
|
-
* `ISCFeature.
|
|
188
|
+
* `ISCFeature.GAME_REORDERED_CALLBACKS`.
|
|
181
189
|
*/
|
|
182
190
|
@Exported
|
|
183
191
|
public reorderedCallbacksSetStage(
|
|
@@ -552,8 +552,8 @@ export enum ModCallbackCustom {
|
|
|
552
552
|
/**
|
|
553
553
|
* Fires when a new grid entity is initialized. Specifically, this is either:
|
|
554
554
|
*
|
|
555
|
-
* - in the `
|
|
556
|
-
* previously there on a previous room entry)
|
|
555
|
+
* - in the `POST_NEW_ROOM_REORDERED` callback (firing every time a room is entered, even if the
|
|
556
|
+
* entity was previously there on a previous room entry)
|
|
557
557
|
* - in the `POST_UPDATE` callback (if the entity appeared mid-way through the room, like when the
|
|
558
558
|
* trapdoor appears after defeating It Lives!)
|
|
559
559
|
*
|
|
@@ -658,8 +658,8 @@ export enum ModCallbackCustom {
|
|
|
658
658
|
POST_GRID_ENTITY_UPDATE,
|
|
659
659
|
|
|
660
660
|
/**
|
|
661
|
-
* Fires from the `
|
|
662
|
-
* collectible effect.
|
|
661
|
+
* Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when the player loses a Holy Mantle
|
|
662
|
+
* temporary collectible effect.
|
|
663
663
|
*
|
|
664
664
|
* This callback is useful because you might want to have code that happens when the player is hit
|
|
665
665
|
* from an enemy. Normally, you would accomplish this via the `ENTITY_TAKE_DMG` callback, but that
|
|
@@ -682,8 +682,8 @@ export enum ModCallbackCustom {
|
|
|
682
682
|
POST_HOLY_MANTLE_REMOVED,
|
|
683
683
|
|
|
684
684
|
/**
|
|
685
|
-
* Fires from `
|
|
686
|
-
* collectible item, implying that the item was just used.
|
|
685
|
+
* Fires from `POST_PEFFECT_UPDATE_REORDERED` callback when the player loses charge on their
|
|
686
|
+
* active collectible item, implying that the item was just used.
|
|
687
687
|
*
|
|
688
688
|
* This callback is useful because the `USE_ITEM` callback does not fire when The Candle, Red
|
|
689
689
|
* Candle, and Bob's Rotten Brain are discharged.
|
|
@@ -706,9 +706,9 @@ export enum ModCallbackCustom {
|
|
|
706
706
|
POST_ITEM_DISCHARGE,
|
|
707
707
|
|
|
708
708
|
/**
|
|
709
|
-
* Fires from the `
|
|
710
|
-
* animation of the player holding the item above their head is finished and the item is
|
|
711
|
-
* added to the player's inventory).
|
|
709
|
+
* Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when an item is no longer queued (i.e.
|
|
710
|
+
* when the animation of the player holding the item above their head is finished and the item is
|
|
711
|
+
* actually added to the player's inventory).
|
|
712
712
|
*
|
|
713
713
|
* Note that this callback will only fire once per Forgotten/Soul pair.
|
|
714
714
|
*
|
|
@@ -1008,8 +1008,9 @@ export enum ModCallbackCustom {
|
|
|
1008
1008
|
POST_PIT_UPDATE,
|
|
1009
1009
|
|
|
1010
1010
|
/**
|
|
1011
|
-
* Fires from the `
|
|
1012
|
-
* than what it was on the previous frame. For more information, see the `PlayerHealth`
|
|
1011
|
+
* Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when a player's health (i.e. hearts) is
|
|
1012
|
+
* different than what it was on the previous frame. For more information, see the `PlayerHealth`
|
|
1013
|
+
* enum.
|
|
1013
1014
|
*
|
|
1014
1015
|
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
1015
1016
|
* - You can provide an optional third argument that will make the callback only fire if it
|
|
@@ -1030,8 +1031,8 @@ export enum ModCallbackCustom {
|
|
|
1030
1031
|
POST_PLAYER_CHANGE_HEALTH,
|
|
1031
1032
|
|
|
1032
1033
|
/**
|
|
1033
|
-
* Fires from the `
|
|
1034
|
-
* they were on the previous frame.
|
|
1034
|
+
* Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when one of the player's stats change
|
|
1035
|
+
* from what they were on the previous frame.
|
|
1035
1036
|
*
|
|
1036
1037
|
* The type of `oldValue` and `newValue` will depend on what kind of stat it is. For example,
|
|
1037
1038
|
* `StatType.FLYING` will be a boolean. (You can use the "Types" helper functions to narrow the
|
|
@@ -1061,7 +1062,8 @@ export enum ModCallbackCustom {
|
|
|
1061
1062
|
POST_PLAYER_CHANGE_STAT,
|
|
1062
1063
|
|
|
1063
1064
|
/**
|
|
1064
|
-
* Fires from the `
|
|
1065
|
+
* Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when a player entity changes its player
|
|
1066
|
+
* type
|
|
1065
1067
|
* (i.e. character) from what it was on the previous frame. For example, it will fire after using
|
|
1066
1068
|
* Clicker, after dying with the Judas' Shadow collectible, etc.
|
|
1067
1069
|
*
|
|
@@ -1084,9 +1086,9 @@ export enum ModCallbackCustom {
|
|
|
1084
1086
|
POST_PLAYER_CHANGE_TYPE,
|
|
1085
1087
|
|
|
1086
1088
|
/**
|
|
1087
|
-
* Fires from the `
|
|
1088
|
-
* what it was on the previous frame, or when the active items change, or when the
|
|
1089
|
-
* rerolled.
|
|
1089
|
+
* Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when a player's collectible count is
|
|
1090
|
+
* higher than what it was on the previous frame, or when the active items change, or when the
|
|
1091
|
+
* build is rerolled.
|
|
1090
1092
|
*
|
|
1091
1093
|
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
1092
1094
|
* - You can provide an optional third argument that will make the callback only fire if the
|
|
@@ -1102,9 +1104,9 @@ export enum ModCallbackCustom {
|
|
|
1102
1104
|
POST_PLAYER_COLLECTIBLE_ADDED,
|
|
1103
1105
|
|
|
1104
1106
|
/**
|
|
1105
|
-
* Fires from the `
|
|
1106
|
-
* what it was on the previous frame, or when the active items change, or when the
|
|
1107
|
-
* rerolled.
|
|
1107
|
+
* Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when a player's collectible count is
|
|
1108
|
+
* lower than what it was on the previous frame, or when the active items change, or when the
|
|
1109
|
+
* build is rerolled.
|
|
1108
1110
|
*
|
|
1109
1111
|
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
1110
1112
|
* - You can provide an optional third argument that will make the callback only fire if the
|
|
@@ -1304,8 +1306,9 @@ export enum ModCallbackCustom {
|
|
|
1304
1306
|
POST_PROJECTILE_INIT_LATE,
|
|
1305
1307
|
|
|
1306
1308
|
/**
|
|
1307
|
-
* Fires from the `
|
|
1308
|
-
* pickup returned in the callback is assumed to be the first pickup that no longer
|
|
1309
|
+
* Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when a player first picks up a new
|
|
1310
|
+
* item. The pickup returned in the callback is assumed to be the first pickup that no longer
|
|
1311
|
+
* exists.
|
|
1309
1312
|
*
|
|
1310
1313
|
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
1311
1314
|
* - You can provide an optional third argument that will make the callback only fire if it
|
|
@@ -1442,8 +1445,8 @@ export enum ModCallbackCustom {
|
|
|
1442
1445
|
/**
|
|
1443
1446
|
* Fires when a new slot entity is initialized. Specifically, this is either:
|
|
1444
1447
|
*
|
|
1445
|
-
* - in the `
|
|
1446
|
-
* previously there on a previous room entry)
|
|
1448
|
+
* - in the `POST_NEW_ROOM_REORDERED` callback (firing every time a room is entered, even if the
|
|
1449
|
+
* entity was previously there on a previous room entry)
|
|
1447
1450
|
* - in the `POST_UPDATE` callback (if the entity appeared mid-way through the room, like when a
|
|
1448
1451
|
* Wheel of Fortune card is used)
|
|
1449
1452
|
*
|
|
@@ -1579,7 +1582,7 @@ export enum ModCallbackCustom {
|
|
|
1579
1582
|
POST_TNT_UPDATE,
|
|
1580
1583
|
|
|
1581
1584
|
/**
|
|
1582
|
-
* Fires from the `
|
|
1585
|
+
* Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when a player gains or loses a new
|
|
1583
1586
|
* transformation.
|
|
1584
1587
|
*
|
|
1585
1588
|
* Note that this callback will only fire once per Forgotten/Soul pair.
|
|
@@ -1615,9 +1618,9 @@ export enum ModCallbackCustom {
|
|
|
1615
1618
|
POST_TRINKET_BREAK,
|
|
1616
1619
|
|
|
1617
1620
|
/**
|
|
1618
|
-
* Fires from the `
|
|
1619
|
-
* the player is predicted to die (e.g. they currently have no health left or they took
|
|
1620
|
-
* a "Lost" form).
|
|
1621
|
+
* Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback on the frame before a Berserk effect
|
|
1622
|
+
* ends when the player is predicted to die (e.g. they currently have no health left or they took
|
|
1623
|
+
* damage in a "Lost" form).
|
|
1621
1624
|
*
|
|
1622
1625
|
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
1623
1626
|
* - You can provide an optional third argument that will make the callback only fire if it
|
|
@@ -1673,8 +1676,8 @@ export enum ModCallbackCustom {
|
|
|
1673
1676
|
PRE_GET_PEDESTAL,
|
|
1674
1677
|
|
|
1675
1678
|
/**
|
|
1676
|
-
* Fires from the `
|
|
1677
|
-
* begins to hold the item above their head).
|
|
1679
|
+
* Fires from the `POST_PEFFECT_UPDATE_REORDERED` callback when an item becomes queued (i.e. when
|
|
1680
|
+
* the player begins to hold the item above their head).
|
|
1678
1681
|
*
|
|
1679
1682
|
* Note that this callback will only fire once per Forgotten/Soul pair.
|
|
1680
1683
|
*
|