Skip to content

Commit d38b96e

Browse files
committed
feat: POST_ENTITY_REMOVE_FILTER
1 parent c00bf38 commit d38b96e

File tree

8 files changed

+56
-1
lines changed

8 files changed

+56
-1
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,5 +88,6 @@
8888
},
8989
"devDependencies": {
9090
"eslint": "9.32.0"
91-
}
91+
},
92+
"packageManager": "[email protected]+sha512.1fc009bc09d13cfd0e19efa44cbfc2b9cf6ca61482725eb35bbc5e257e093ebf4130db6dfe15d604ff4b79efd8e1e8e99b25fa7d0a6197c9f9826358d4d65c3c"
9293
}

packages/docs/docs/main/change-log.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ This page lists the changes to the IsaacScript framework.
99

1010
<br />
1111

12+
## July 26th, 2024
13+
14+
- Added the following custom callbacks:
15+
- `POST_ENTITY_REMOVE_FILTER`
16+
1217
## September 11th, 2024
1318

1419
- Breaking changes:

packages/isaacscript-common/src/callbackClasses.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export { PostEffectRenderFilter } from "./classes/callbacks/PostEffectRenderFilt
2525
export { PostEffectStateChanged } from "./classes/callbacks/PostEffectStateChanged";
2626
export { PostEffectUpdateFilter } from "./classes/callbacks/PostEffectUpdateFilter";
2727
export { PostEntityKillFilter } from "./classes/callbacks/PostEntityKillFilter";
28+
export { PostEntityRemoveFilter } from "./classes/callbacks/PostEntityRemoveFilter";
2829
export { PostEsauJr } from "./classes/callbacks/PostEsauJr";
2930
export { PostFamiliarInitFilter } from "./classes/callbacks/PostFamiliarInitFilter";
3031
export { PostFamiliarInitLate } from "./classes/callbacks/PostFamiliarInitLate";

packages/isaacscript-common/src/callbacks.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ const MOD_CALLBACK_CUSTOM_TO_CLASS = {
2828
[ModCallbackCustom.POST_EFFECT_STATE_CHANGED]: cc.PostEffectStateChanged,
2929
[ModCallbackCustom.POST_EFFECT_UPDATE_FILTER]: cc.PostEffectUpdateFilter,
3030
[ModCallbackCustom.POST_ENTITY_KILL_FILTER]: cc.PostEntityKillFilter,
31+
[ModCallbackCustom.POST_ENTITY_REMOVE_FILTER]: cc.PostEntityRemoveFilter,
3132
[ModCallbackCustom.POST_ESAU_JR]: cc.PostEsauJr,
3233
[ModCallbackCustom.POST_FAMILIAR_INIT_FILTER]: cc.PostFamiliarInitFilter,
3334
[ModCallbackCustom.POST_FAMILIAR_INIT_LATE]: cc.PostFamiliarInitLate,
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ModCallback } from "isaac-typescript-definitions";
2+
import type { ModCallbackCustom } from "../../enums/ModCallbackCustom";
3+
import { shouldFireEntity } from "../../shouldFire";
4+
import { CustomCallback } from "../private/CustomCallback";
5+
6+
export class PostEntityRemoveFilter extends CustomCallback<ModCallbackCustom.POST_ENTITY_REMOVE_FILTER> {
7+
constructor() {
8+
super();
9+
10+
this.callbacksUsed = [
11+
// 67
12+
[ModCallback.POST_ENTITY_REMOVE, this.postEntityRemove],
13+
];
14+
}
15+
16+
protected override shouldFire = shouldFireEntity;
17+
18+
// ModCallback.POST_ENTITY_REMOVE (67)
19+
private readonly postEntityRemove = (entity: Entity) => {
20+
this.fire(entity);
21+
};
22+
}

packages/isaacscript-common/src/enums/ModCallbackCustom.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,24 @@ export enum ModCallbackCustom {
415415
*/
416416
POST_ENTITY_KILL_FILTER,
417417

418+
/**
419+
* The exact same thing as the vanilla `POST_ENTITY_REMOVE` callback, except this callback allows
420+
* you to specify extra arguments for additional filtration.
421+
*
422+
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
423+
* - You can provide an optional third argument that will make the callback only fire if it
424+
* matches the `EntityType` provided.
425+
* - You can provide an optional fourth argument that will make the callback only fire if it
426+
* matches the variant provided.
427+
* - You can provide an optional fifth argument that will make the callback only fire if it
428+
* matches the sub-type provided.
429+
*
430+
* ```ts
431+
* function postEntityRemoveFilter(entity: Entity): void {}
432+
* ```
433+
*/
434+
POST_ENTITY_REMOVE_FILTER,
435+
418436
/**
419437
* Fires one `POST_UPDATE` frame after the player has used the Esau Jr. item. (The player is not
420438
* updated to the new character until a game frame has passed.)

packages/isaacscript-common/src/interfaces/private/AddCallbackParametersCustom.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,13 @@ export interface AddCallbackParametersCustom {
215215
subType?: int,
216216
];
217217

218+
[ModCallbackCustom.POST_ENTITY_REMOVE_FILTER]: [
219+
callback: (entity: Entity) => void,
220+
entityType?: EntityType,
221+
variant?: int,
222+
subType?: int,
223+
];
224+
218225
// - Co-op babies cannot turn into Esau Jr, so it does not make sense to filter by
219226
// `PlayerVariant`.
220227
// - The character of Esau Jr. is equal to `PlayerType.ISAAC`, so it does not make sense to filter

packages/isaacscript-common/yarn.lock

Whitespace-only changes.

0 commit comments

Comments
 (0)