isaacscript-common 15.3.7 → 15.4.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 +190 -95
- package/dist/isaacscript-common.lua +399 -244
- package/dist/src/callbacks.d.ts +105 -95
- package/dist/src/callbacks.d.ts.map +1 -1
- package/dist/src/callbacks.lua +16 -1
- package/dist/src/classes/callbacks/EntityTakeDmgFilter.d.ts +9 -0
- package/dist/src/classes/callbacks/EntityTakeDmgFilter.d.ts.map +1 -0
- package/dist/src/classes/callbacks/EntityTakeDmgFilter.lua +27 -0
- package/dist/src/classes/callbacks/PostGridEntityCollision.lua +1 -1
- package/dist/src/classes/callbacks/PostGridEntityCustomCollision.lua +1 -1
- package/dist/src/classes/callbacks/PostNPCDeathFilter.d.ts +9 -0
- package/dist/src/classes/callbacks/PostNPCDeathFilter.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostNPCDeathFilter.lua +23 -0
- package/dist/src/classes/callbacks/PostNPCRenderFilter.d.ts +9 -0
- package/dist/src/classes/callbacks/PostNPCRenderFilter.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PostNPCRenderFilter.lua +23 -0
- package/dist/src/classes/callbacks/PreNPCCollisionFilter.d.ts +9 -0
- package/dist/src/classes/callbacks/PreNPCCollisionFilter.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PreNPCCollisionFilter.lua +21 -0
- package/dist/src/classes/callbacks/PreNPCUpdateFilter.d.ts +9 -0
- package/dist/src/classes/callbacks/PreNPCUpdateFilter.d.ts.map +1 -0
- package/dist/src/classes/callbacks/PreNPCUpdateFilter.lua +21 -0
- package/dist/src/enums/ModCallbackCustom.d.ts +160 -95
- package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
- package/dist/src/enums/ModCallbackCustom.lua +105 -95
- package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts +30 -0
- package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts.map +1 -1
- package/dist/src/shouldFire.d.ts +8 -1
- package/dist/src/shouldFire.d.ts.map +1 -1
- package/dist/src/shouldFire.lua +5 -0
- package/package.json +2 -2
- package/src/callbacks.ts +10 -0
- package/src/classes/callbacks/EntityTakeDmgFilter.ts +25 -0
- package/src/classes/callbacks/PostGridEntityCollision.ts +1 -1
- package/src/classes/callbacks/PostGridEntityCustomCollision.ts +1 -1
- package/src/classes/callbacks/PostNPCDeathFilter.ts +21 -0
- package/src/classes/callbacks/PostNPCRenderFilter.ts +21 -0
- package/src/classes/callbacks/PreNPCCollisionFilter.ts +20 -0
- package/src/classes/callbacks/PreNPCUpdateFilter.ts +19 -0
- package/src/enums/ModCallbackCustom.ts +70 -0
- package/src/interfaces/private/AddCallbackParametersCustom.ts +45 -0
- package/src/shouldFire.ts +25 -1
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { DamageFlag, ModCallback } from "isaac-typescript-definitions";
|
|
2
|
+
import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
|
|
3
|
+
import { shouldFireEntity } from "../../shouldFire";
|
|
4
|
+
import { CustomCallback } from "../private/CustomCallback";
|
|
5
|
+
|
|
6
|
+
export class EntityTakeDmgFilter extends CustomCallback<ModCallbackCustom.ENTITY_TAKE_DMG_FILTER> {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
this.callbacksUsed = [
|
|
11
|
+
[ModCallback.ENTITY_TAKE_DMG, [this.entityTakeDmg]], // 11
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
protected override shouldFire = shouldFireEntity;
|
|
16
|
+
|
|
17
|
+
// ModCallback.ENTITY_TAKE_DMG (11)
|
|
18
|
+
private entityTakeDmg = (
|
|
19
|
+
entity: Entity,
|
|
20
|
+
amount: number,
|
|
21
|
+
damageFlags: BitFlags<DamageFlag>,
|
|
22
|
+
source: EntityRef,
|
|
23
|
+
countdownFrames: number,
|
|
24
|
+
) => this.fire(entity, amount, damageFlags, source, countdownFrames);
|
|
25
|
+
}
|
|
@@ -12,7 +12,7 @@ export class PostGridEntityCollision extends CustomCallback<T> {
|
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
14
|
|
|
15
|
-
this.featuresUsed = [ISCFeature.
|
|
15
|
+
this.featuresUsed = [ISCFeature.GRID_ENTITY_COLLISION_DETECTION];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// eslint-disable-next-line class-methods-use-this
|
|
@@ -12,7 +12,7 @@ export class PostGridEntityCustomCollision extends CustomCallback<T> {
|
|
|
12
12
|
constructor() {
|
|
13
13
|
super();
|
|
14
14
|
|
|
15
|
-
this.featuresUsed = [ISCFeature.
|
|
15
|
+
this.featuresUsed = [ISCFeature.GRID_ENTITY_COLLISION_DETECTION];
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// eslint-disable-next-line class-methods-use-this
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ModCallback } from "isaac-typescript-definitions";
|
|
2
|
+
import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
|
|
3
|
+
import { shouldFireNPC } from "../../shouldFire";
|
|
4
|
+
import { CustomCallback } from "../private/CustomCallback";
|
|
5
|
+
|
|
6
|
+
export class PostNPCDeathFilter extends CustomCallback<ModCallbackCustom.POST_NPC_DEATH_FILTER> {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
this.callbacksUsed = [
|
|
11
|
+
[ModCallback.POST_NPC_DEATH, [this.postNPCRender]], // 29
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
protected override shouldFire = shouldFireNPC;
|
|
16
|
+
|
|
17
|
+
// ModCallback.POST_NPC_DEATH (29)
|
|
18
|
+
private postNPCRender = (npc: EntityNPC) => {
|
|
19
|
+
this.fire(npc);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { ModCallback } from "isaac-typescript-definitions";
|
|
2
|
+
import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
|
|
3
|
+
import { shouldFireNPC } from "../../shouldFire";
|
|
4
|
+
import { CustomCallback } from "../private/CustomCallback";
|
|
5
|
+
|
|
6
|
+
export class PostNPCRenderFilter extends CustomCallback<ModCallbackCustom.POST_NPC_RENDER_FILTER> {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
this.callbacksUsed = [
|
|
11
|
+
[ModCallback.POST_NPC_RENDER, [this.postNPCRender]], // 28
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
protected override shouldFire = shouldFireNPC;
|
|
16
|
+
|
|
17
|
+
// ModCallback.POST_NPC_RENDER (28)
|
|
18
|
+
private postNPCRender = (npc: EntityNPC, renderOffset: Vector) => {
|
|
19
|
+
this.fire(npc, renderOffset);
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ModCallback } from "isaac-typescript-definitions";
|
|
2
|
+
import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
|
|
3
|
+
import { shouldFireNPC } from "../../shouldFire";
|
|
4
|
+
import { CustomCallback } from "../private/CustomCallback";
|
|
5
|
+
|
|
6
|
+
export class PreNPCCollisionFilter extends CustomCallback<ModCallbackCustom.PRE_NPC_COLLISION_FILTER> {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
this.callbacksUsed = [
|
|
11
|
+
[ModCallback.PRE_NPC_COLLISION, [this.preNPCCollision]], // 30
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
protected override shouldFire = shouldFireNPC;
|
|
16
|
+
|
|
17
|
+
// ModCallback.PRE_NPC_COLLISION (30)
|
|
18
|
+
private preNPCCollision = (npc: EntityNPC, collider: Entity, low: boolean) =>
|
|
19
|
+
this.fire(npc, collider, low);
|
|
20
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ModCallback } from "isaac-typescript-definitions";
|
|
2
|
+
import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
|
|
3
|
+
import { shouldFireNPC } from "../../shouldFire";
|
|
4
|
+
import { CustomCallback } from "../private/CustomCallback";
|
|
5
|
+
|
|
6
|
+
export class PreNPCUpdateFilter extends CustomCallback<ModCallbackCustom.PRE_NPC_UPDATE_FILTER> {
|
|
7
|
+
constructor() {
|
|
8
|
+
super();
|
|
9
|
+
|
|
10
|
+
this.callbacksUsed = [
|
|
11
|
+
[ModCallback.PRE_NPC_UPDATE, [this.preNPCUpdate]], // 69
|
|
12
|
+
];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
protected override shouldFire = shouldFireNPC;
|
|
16
|
+
|
|
17
|
+
// ModCallback.PRE_NPC_UPDATE (69)
|
|
18
|
+
private preNPCUpdate = (npc: EntityNPC) => this.fire(npc);
|
|
19
|
+
}
|
|
@@ -19,6 +19,20 @@ eslint isaacscript/member-ordering: [
|
|
|
19
19
|
* - You must upgrade your mod with the `upgradeMod` helper function before using a custom callback.
|
|
20
20
|
*/
|
|
21
21
|
export enum ModCallbackCustom {
|
|
22
|
+
/**
|
|
23
|
+
* The exact same thing as the vanilla `ENTITY_TAKE_DMG` callback, except this callback allows you
|
|
24
|
+
* to specify extra arguments for additional filtration.
|
|
25
|
+
*
|
|
26
|
+
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
27
|
+
* - You can provide an optional third argument that will make the callback only fire if it
|
|
28
|
+
* matches the `EntityType` provided.
|
|
29
|
+
* - You can provide an optional fourth argument that will make the callback only fire if it
|
|
30
|
+
* matches the variant provided.
|
|
31
|
+
* - You can provide an optional fifth argument that will make the callback only fire if it
|
|
32
|
+
* matches the sub-type provided.
|
|
33
|
+
*/
|
|
34
|
+
ENTITY_TAKE_DMG_FILTER,
|
|
35
|
+
|
|
22
36
|
/**
|
|
23
37
|
* Fires from the `POST_UPDATE` callback when a Challenge Room or Boss Rush is started.
|
|
24
38
|
* Specifically, this happens on the first frame that `Room.IsAmbushDone` is true.
|
|
@@ -811,6 +825,20 @@ export enum ModCallbackCustom {
|
|
|
811
825
|
*/
|
|
812
826
|
POST_NEW_ROOM_REORDERED,
|
|
813
827
|
|
|
828
|
+
/**
|
|
829
|
+
* The exact same thing as the vanilla `POST_NPC_DEATH` callback, except this callback allows you
|
|
830
|
+
* to specify extra arguments for additional filtration.
|
|
831
|
+
*
|
|
832
|
+
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
833
|
+
* - You can provide an optional third argument that will make the callback only fire if it
|
|
834
|
+
* matches the `EntityType` provided.
|
|
835
|
+
* - You can provide an optional fourth argument that will make the callback only fire if it
|
|
836
|
+
* matches the variant provided.
|
|
837
|
+
* - You can provide an optional fifth argument that will make the callback only fire if it
|
|
838
|
+
* matches the sub-type provided.
|
|
839
|
+
*/
|
|
840
|
+
POST_NPC_DEATH_FILTER,
|
|
841
|
+
|
|
814
842
|
/**
|
|
815
843
|
* The exact same thing as the vanilla `POST_NPC_INIT` callback, except this callback allows you
|
|
816
844
|
* to specify extra arguments for additional filtration.
|
|
@@ -845,6 +873,20 @@ export enum ModCallbackCustom {
|
|
|
845
873
|
*/
|
|
846
874
|
POST_NPC_INIT_LATE,
|
|
847
875
|
|
|
876
|
+
/**
|
|
877
|
+
* The exact same thing as the vanilla `POST_NPC_RENDER` callback, except this callback allows you
|
|
878
|
+
* to specify extra arguments for additional filtration.
|
|
879
|
+
*
|
|
880
|
+
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
881
|
+
* - You can provide an optional third argument that will make the callback only fire if it
|
|
882
|
+
* matches the `EntityType` provided.
|
|
883
|
+
* - You can provide an optional fourth argument that will make the callback only fire if it
|
|
884
|
+
* matches the variant provided.
|
|
885
|
+
* - You can provide an optional fifth argument that will make the callback only fire if it
|
|
886
|
+
* matches the sub-type provided.
|
|
887
|
+
*/
|
|
888
|
+
POST_NPC_RENDER_FILTER,
|
|
889
|
+
|
|
848
890
|
/**
|
|
849
891
|
* Fires from the `POST_NPC_UPDATE` callback when an NPC's state has changed from what it was on
|
|
850
892
|
* the previous frame. (In this context, "state" refers to the `EntityNPC.State` field.)
|
|
@@ -1710,4 +1752,32 @@ export enum ModCallbackCustom {
|
|
|
1710
1752
|
* ```
|
|
1711
1753
|
*/
|
|
1712
1754
|
PRE_NEW_LEVEL,
|
|
1755
|
+
|
|
1756
|
+
/**
|
|
1757
|
+
* The exact same thing as the vanilla `PRE_NPC_COLLISION` callback, except this callback allows
|
|
1758
|
+
* you to specify extra arguments for additional filtration.
|
|
1759
|
+
*
|
|
1760
|
+
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
1761
|
+
* - You can provide an optional third argument that will make the callback only fire if it
|
|
1762
|
+
* matches the `EntityType` provided.
|
|
1763
|
+
* - You can provide an optional fourth argument that will make the callback only fire if it
|
|
1764
|
+
* matches the variant provided.
|
|
1765
|
+
* - You can provide an optional fifth argument that will make the callback only fire if it
|
|
1766
|
+
* matches the sub-type provided.
|
|
1767
|
+
*/
|
|
1768
|
+
PRE_NPC_COLLISION_FILTER,
|
|
1769
|
+
|
|
1770
|
+
/**
|
|
1771
|
+
* The exact same thing as the vanilla `PRE_NPC_UPDATE` callback, except this callback allows you
|
|
1772
|
+
* to specify extra arguments for additional filtration.
|
|
1773
|
+
*
|
|
1774
|
+
* When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
|
|
1775
|
+
* - You can provide an optional third argument that will make the callback only fire if it
|
|
1776
|
+
* matches the `EntityType` provided.
|
|
1777
|
+
* - You can provide an optional fourth argument that will make the callback only fire if it
|
|
1778
|
+
* matches the variant provided.
|
|
1779
|
+
* - You can provide an optional fifth argument that will make the callback only fire if it
|
|
1780
|
+
* matches the sub-type provided.
|
|
1781
|
+
*/
|
|
1782
|
+
PRE_NPC_UPDATE_FILTER,
|
|
1713
1783
|
}
|
|
@@ -38,6 +38,19 @@ import {
|
|
|
38
38
|
import { StatTypeType } from "../StatTypeType";
|
|
39
39
|
|
|
40
40
|
export interface AddCallbackParametersCustom {
|
|
41
|
+
[ModCallbackCustom.ENTITY_TAKE_DMG_FILTER]: [
|
|
42
|
+
callback: (
|
|
43
|
+
entity: Entity,
|
|
44
|
+
amount: float,
|
|
45
|
+
damageFlags: BitFlags<DamageFlag>,
|
|
46
|
+
source: EntityRef,
|
|
47
|
+
countdownFrames: int,
|
|
48
|
+
) => boolean | undefined,
|
|
49
|
+
entityType?: EntityType,
|
|
50
|
+
variant?: number,
|
|
51
|
+
subType?: number,
|
|
52
|
+
];
|
|
53
|
+
|
|
41
54
|
[ModCallbackCustom.POST_AMBUSH_FINISHED]: [
|
|
42
55
|
callback: (ambushType: AmbushType) => void,
|
|
43
56
|
ambushType?: AmbushType,
|
|
@@ -334,6 +347,13 @@ export interface AddCallbackParametersCustom {
|
|
|
334
347
|
|
|
335
348
|
[ModCallbackCustom.POST_NEW_ROOM_REORDERED]: [callback: () => void];
|
|
336
349
|
|
|
350
|
+
[ModCallbackCustom.POST_NPC_DEATH_FILTER]: [
|
|
351
|
+
callback: (npc: EntityNPC) => void,
|
|
352
|
+
entityType?: EntityType,
|
|
353
|
+
variant?: int,
|
|
354
|
+
subType?: int,
|
|
355
|
+
];
|
|
356
|
+
|
|
337
357
|
[ModCallbackCustom.POST_NPC_INIT_FILTER]: [
|
|
338
358
|
callback: (npc: EntityNPC) => void,
|
|
339
359
|
entityType?: EntityType,
|
|
@@ -348,6 +368,13 @@ export interface AddCallbackParametersCustom {
|
|
|
348
368
|
subType?: int,
|
|
349
369
|
];
|
|
350
370
|
|
|
371
|
+
[ModCallbackCustom.POST_NPC_RENDER_FILTER]: [
|
|
372
|
+
callback: (npc: EntityNPC, renderOffset: Vector) => void,
|
|
373
|
+
entityType?: EntityType,
|
|
374
|
+
variant?: int,
|
|
375
|
+
subType?: int,
|
|
376
|
+
];
|
|
377
|
+
|
|
351
378
|
[ModCallbackCustom.POST_NPC_STATE_CHANGED]: [
|
|
352
379
|
callback: (npc: EntityNPC, previousState: int, currentState: int) => void,
|
|
353
380
|
entityType?: EntityType,
|
|
@@ -669,6 +696,24 @@ export interface AddCallbackParametersCustom {
|
|
|
669
696
|
];
|
|
670
697
|
|
|
671
698
|
[ModCallbackCustom.PRE_NEW_LEVEL]: [callback: (player: EntityPlayer) => void];
|
|
699
|
+
|
|
700
|
+
[ModCallbackCustom.PRE_NPC_COLLISION_FILTER]: [
|
|
701
|
+
callback: (
|
|
702
|
+
npc: EntityNPC,
|
|
703
|
+
collider: Entity,
|
|
704
|
+
low: boolean,
|
|
705
|
+
) => undefined | boolean,
|
|
706
|
+
entityType?: EntityType,
|
|
707
|
+
variant?: int,
|
|
708
|
+
subType?: int,
|
|
709
|
+
];
|
|
710
|
+
|
|
711
|
+
[ModCallbackCustom.PRE_NPC_UPDATE_FILTER]: [
|
|
712
|
+
callback: (npc: EntityNPC) => undefined | boolean,
|
|
713
|
+
entityType?: EntityType,
|
|
714
|
+
variant?: int,
|
|
715
|
+
subType?: int,
|
|
716
|
+
];
|
|
672
717
|
}
|
|
673
718
|
|
|
674
719
|
validateInterfaceMatchesEnum<AddCallbackParametersCustom, ModCallbackCustom>();
|
package/src/shouldFire.ts
CHANGED
|
@@ -124,6 +124,28 @@ export function shouldFireEffect(
|
|
|
124
124
|
);
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
+
export function shouldFireEntity(
|
|
128
|
+
fireArgs:
|
|
129
|
+
| [entity: Entity]
|
|
130
|
+
| [
|
|
131
|
+
entity: Entity,
|
|
132
|
+
amount: number,
|
|
133
|
+
damageFlags: BitFlags<DamageFlag>,
|
|
134
|
+
source: EntityRef,
|
|
135
|
+
countdownFrames: number,
|
|
136
|
+
],
|
|
137
|
+
optionalArgs: [entityType?: EntityType, variant?: int, subType?: int],
|
|
138
|
+
): boolean {
|
|
139
|
+
const [entity] = fireArgs;
|
|
140
|
+
const [callbackEntityType, callbackVariant, callbackSubType] = optionalArgs;
|
|
141
|
+
|
|
142
|
+
return (
|
|
143
|
+
(callbackEntityType === undefined || callbackEntityType === entity.Type) &&
|
|
144
|
+
(callbackVariant === undefined || callbackVariant === entity.Variant) &&
|
|
145
|
+
(callbackSubType === undefined || callbackSubType === entity.SubType)
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
127
149
|
export function shouldFireFamiliar(
|
|
128
150
|
fireArgs:
|
|
129
151
|
| [familiar: EntityFamiliar]
|
|
@@ -225,7 +247,9 @@ export function shouldFireLaser(
|
|
|
225
247
|
export function shouldFireNPC(
|
|
226
248
|
fireArgs:
|
|
227
249
|
| [npc: EntityNPC]
|
|
228
|
-
| [npc: EntityNPC, previousState: int, currentState: int]
|
|
250
|
+
| [npc: EntityNPC, previousState: int, currentState: int]
|
|
251
|
+
| [npc: EntityNPC, renderOffset: Vector]
|
|
252
|
+
| [npc: EntityNPC, collider: Entity, low: boolean],
|
|
229
253
|
optionalArgs: [entityType?: EntityType, variant?: int, subType?: int],
|
|
230
254
|
): boolean {
|
|
231
255
|
const [npc] = fireArgs;
|