isaacscript-common 7.4.2 → 7.5.1

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.
Files changed (163) hide show
  1. package/dist/callbacks/postGridEntity.d.ts.map +1 -1
  2. package/dist/callbacks/postGridEntity.lua +53 -6
  3. package/dist/callbacks/postPlayerChangeStat.d.ts.map +1 -1
  4. package/dist/callbacks/postPlayerChangeStat.lua +9 -2
  5. package/dist/callbacks/subscriptions/postGridEntityCustomBroken.d.ts +1 -0
  6. package/dist/callbacks/subscriptions/postGridEntityCustomBroken.d.ts.map +1 -1
  7. package/dist/callbacks/subscriptions/postGridEntityCustomBroken.lua +5 -2
  8. package/dist/callbacks/subscriptions/postGridEntityCustomInit.d.ts +9 -0
  9. package/dist/callbacks/subscriptions/postGridEntityCustomInit.d.ts.map +1 -0
  10. package/dist/callbacks/subscriptions/postGridEntityCustomInit.lua +23 -0
  11. package/dist/callbacks/subscriptions/postGridEntityCustomRemove.d.ts +9 -0
  12. package/dist/callbacks/subscriptions/postGridEntityCustomRemove.d.ts.map +1 -0
  13. package/dist/callbacks/subscriptions/postGridEntityCustomRemove.lua +23 -0
  14. package/dist/callbacks/subscriptions/postGridEntityCustomStateChanged.d.ts +9 -0
  15. package/dist/callbacks/subscriptions/postGridEntityCustomStateChanged.d.ts.map +1 -0
  16. package/dist/callbacks/subscriptions/postGridEntityCustomStateChanged.lua +29 -0
  17. package/dist/callbacks/subscriptions/postPlayerChangeStat.d.ts +3 -2
  18. package/dist/callbacks/subscriptions/postPlayerChangeStat.d.ts.map +1 -1
  19. package/dist/classes/DefaultMap.d.ts +3 -2
  20. package/dist/classes/DefaultMap.d.ts.map +1 -1
  21. package/dist/classes/DefaultMap.lua +2 -1
  22. package/dist/enums/ModCallbackCustom.d.ts +131 -81
  23. package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
  24. package/dist/enums/ModCallbackCustom.lua +67 -61
  25. package/dist/enums/StatType.d.ts +3 -1
  26. package/dist/enums/StatType.d.ts.map +1 -1
  27. package/dist/enums/StatType.lua +2 -0
  28. package/dist/features/customGridEntity.d.ts +30 -13
  29. package/dist/features/customGridEntity.d.ts.map +1 -1
  30. package/dist/features/customGridEntity.lua +67 -48
  31. package/dist/features/customStage/customStageGridEntities.d.ts.map +1 -1
  32. package/dist/features/customStage/customStageGridEntities.lua +37 -31
  33. package/dist/features/customStage/customStageUtils.d.ts +2 -1
  34. package/dist/features/customStage/customStageUtils.d.ts.map +1 -1
  35. package/dist/features/customStage/customStageUtils.lua +40 -1
  36. package/dist/features/customStage/exports.d.ts +1 -25
  37. package/dist/features/customStage/exports.d.ts.map +1 -1
  38. package/dist/features/customStage/exports.lua +28 -29
  39. package/dist/features/customStage/v.d.ts +0 -2
  40. package/dist/features/customStage/v.d.ts.map +1 -1
  41. package/dist/features/customStage/v.lua +0 -2
  42. package/dist/features/customStage/versusScreen.d.ts.map +1 -1
  43. package/dist/features/customStage/versusScreen.lua +74 -60
  44. package/dist/functions/dev.d.ts +20 -0
  45. package/dist/functions/dev.d.ts.map +1 -0
  46. package/dist/functions/dev.lua +34 -0
  47. package/dist/functions/doors.d.ts +6 -5
  48. package/dist/functions/doors.d.ts.map +1 -1
  49. package/dist/functions/doors.lua +25 -12
  50. package/dist/functions/enums.d.ts +3 -3
  51. package/dist/functions/enums.lua +3 -3
  52. package/dist/functions/gridEntities.d.ts +3 -0
  53. package/dist/functions/gridEntities.d.ts.map +1 -1
  54. package/dist/functions/gridEntities.lua +35 -4
  55. package/dist/functions/playerStats.d.ts.map +1 -1
  56. package/dist/functions/playerStats.lua +2 -1
  57. package/dist/functions/players.d.ts.map +1 -1
  58. package/dist/functions/players.lua +3 -2
  59. package/dist/functions/rooms.d.ts +5 -0
  60. package/dist/functions/rooms.d.ts.map +1 -1
  61. package/dist/functions/rooms.lua +12 -2
  62. package/dist/index.d.ts +312 -198
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.lua +1134 -8
  65. package/dist/interfaces/{CustomStageLua.d.ts → CustomStageTSConfig.d.ts} +86 -60
  66. package/dist/interfaces/CustomStageTSConfig.d.ts.map +1 -0
  67. package/dist/interfaces/{CustomStageLua.lua → CustomStageTSConfig.lua} +0 -0
  68. package/dist/interfaces/JSONRoomsFile.d.ts +6 -5
  69. package/dist/interfaces/JSONRoomsFile.d.ts.map +1 -1
  70. package/dist/interfaces/StatTypeType.d.ts +1 -0
  71. package/dist/interfaces/StatTypeType.d.ts.map +1 -1
  72. package/dist/interfaces/private/AddCallbackParameterCustom.d.ts +6 -0
  73. package/dist/interfaces/private/AddCallbackParameterCustom.d.ts.map +1 -1
  74. package/dist/interfaces/private/CustomStage.d.ts +1 -1
  75. package/dist/interfaces/private/CustomStage.d.ts.map +1 -1
  76. package/dist/objects/callbackRegisterFunctions.d.ts.map +1 -1
  77. package/dist/objects/callbackRegisterFunctions.lua +9 -0
  78. package/dist/types/PossibleStatType.d.ts +7 -0
  79. package/dist/types/PossibleStatType.d.ts.map +1 -0
  80. package/dist/{interfaces/index.lua → types/PossibleStatType.lua} +0 -0
  81. package/package.json +1 -1
  82. package/src/callbacks/postGridEntity.ts +75 -10
  83. package/src/callbacks/postPlayerChangeStat.ts +8 -4
  84. package/src/callbacks/subscriptions/postGridEntityCustomBroken.ts +4 -0
  85. package/src/callbacks/subscriptions/postGridEntityCustomInit.ts +38 -0
  86. package/src/callbacks/subscriptions/postGridEntityCustomRemove.ts +35 -0
  87. package/src/callbacks/subscriptions/postGridEntityCustomStateChanged.ts +42 -0
  88. package/src/callbacks/subscriptions/postPlayerChangeStat.ts +4 -7
  89. package/src/classes/DefaultMap.ts +3 -2
  90. package/src/enums/ModCallbackCustom.ts +73 -20
  91. package/src/enums/StatType.ts +3 -3
  92. package/src/features/customGridEntity.ts +87 -61
  93. package/src/features/customStage/customStageGridEntities.ts +16 -7
  94. package/src/features/customStage/customStageUtils.ts +52 -1
  95. package/src/features/customStage/exports.ts +33 -45
  96. package/src/features/customStage/init.ts +1 -1
  97. package/src/features/customStage/v.ts +0 -6
  98. package/src/features/customStage/versusScreen.ts +70 -55
  99. package/src/functions/dev.ts +31 -0
  100. package/src/functions/doors.ts +37 -21
  101. package/src/functions/enums.ts +3 -3
  102. package/src/functions/gridEntities.ts +33 -1
  103. package/src/functions/playerStats.ts +1 -0
  104. package/src/functions/players.ts +7 -3
  105. package/src/functions/rooms.ts +18 -0
  106. package/src/index.ts +208 -9
  107. package/src/interfaces/{CustomStageLua.ts → CustomStageTSConfig.ts} +107 -41
  108. package/src/interfaces/JSONRoomsFile.ts +6 -5
  109. package/src/interfaces/StatTypeType.ts +1 -0
  110. package/src/interfaces/private/AddCallbackParameterCustom.ts +6 -0
  111. package/src/interfaces/private/CustomStage.ts +4 -1
  112. package/src/objects/callbackRegisterFunctions.ts +9 -0
  113. package/src/types/PossibleStatType.ts +12 -0
  114. package/dist/classes/index.d.ts +0 -3
  115. package/dist/classes/index.d.ts.map +0 -1
  116. package/dist/classes/index.lua +0 -18
  117. package/dist/core/index.d.ts +0 -5
  118. package/dist/core/index.d.ts.map +0 -1
  119. package/dist/core/index.lua +0 -34
  120. package/dist/enums/DecorationVariant.d.ts +0 -10
  121. package/dist/enums/DecorationVariant.d.ts.map +0 -1
  122. package/dist/enums/DecorationVariant.lua +0 -7
  123. package/dist/enums/index.d.ts +0 -11
  124. package/dist/enums/index.d.ts.map +0 -1
  125. package/dist/enums/index.lua +0 -82
  126. package/dist/features/index.d.ts +0 -30
  127. package/dist/features/index.d.ts.map +0 -1
  128. package/dist/features/index.lua +0 -216
  129. package/dist/functions/index.d.ts +0 -100
  130. package/dist/functions/index.d.ts.map +0 -1
  131. package/dist/functions/index.lua +0 -794
  132. package/dist/interfaces/CustomStageLua.d.ts.map +0 -1
  133. package/dist/interfaces/index.d.ts +0 -12
  134. package/dist/interfaces/index.d.ts.map +0 -1
  135. package/dist/maps/index.d.ts +0 -5
  136. package/dist/maps/index.d.ts.map +0 -1
  137. package/dist/maps/index.lua +0 -34
  138. package/dist/objects/index.d.ts +0 -2
  139. package/dist/objects/index.d.ts.map +0 -1
  140. package/dist/objects/index.lua +0 -10
  141. package/dist/types/index.d.ts +0 -11
  142. package/dist/types/index.d.ts.map +0 -1
  143. package/dist/types/index.lua +0 -10
  144. package/src/classes/index.ts +0 -2
  145. package/src/classes/indexTypeDoc.ts +0 -2
  146. package/src/core/index.ts +0 -4
  147. package/src/core/indexTypeDoc.ts +0 -4
  148. package/src/enums/DecorationVariant.ts +0 -10
  149. package/src/enums/index.ts +0 -10
  150. package/src/enums/indexTypeDoc.ts +0 -10
  151. package/src/features/index.ts +0 -59
  152. package/src/features/indexTypeDoc.ts +0 -30
  153. package/src/functions/index.ts +0 -101
  154. package/src/functions/indexTypeDoc.ts +0 -101
  155. package/src/indexTypeDoc.ts +0 -13
  156. package/src/interfaces/index.ts +0 -11
  157. package/src/interfaces/indexTypeDoc.ts +0 -11
  158. package/src/maps/index.ts +0 -4
  159. package/src/maps/indexTypeDoc.ts +0 -4
  160. package/src/objects/index.ts +0 -1
  161. package/src/objects/indexTypeDoc.ts +0 -1
  162. package/src/types/index.ts +0 -10
  163. package/src/types/indexTypeDoc.ts +0 -10
@@ -1,13 +1,19 @@
1
1
  // This provides the logic for the following callbacks:
2
2
  // - `POST_GRID_ENTITY_INIT`
3
+ // - `POST_GRID_ENTITY_CUSTOM_INIT`
3
4
  // - `POST_GRID_ENTITY_UPDATE`
5
+ // - `POST_GRID_ENTITY_CUSTOM_UPDATE`
4
6
  // - `POST_GRID_ENTITY_REMOVE`
7
+ // - `POST_GRID_ENTITY_CUSTOM_REMOVE`
5
8
  // - `POST_GRID_ENTITY_STATE_CHANGED`
9
+ // - `POST_GRID_ENTITY_CUSTOM_STATE_CHANGED`
6
10
  // - `POST_GRID_ENTITY_BROKEN`
11
+ // - `POST_GRID_ENTITY_CUSTOM_BROKEN`
7
12
 
8
13
  import { GridEntityType, ModCallback } from "isaac-typescript-definitions";
9
14
  import { ModUpgraded } from "../classes/ModUpgraded";
10
15
  import { ModCallbackCustom } from "../enums/ModCallbackCustom";
16
+ import { getCustomGridEntityType } from "../features/customGridEntity";
11
17
  import { saveDataManager } from "../features/saveDataManager/exports";
12
18
  import {
13
19
  getGridEntitiesMap,
@@ -17,6 +23,26 @@ import {
17
23
  postGridEntityBrokenFire,
18
24
  postGridEntityBrokenHasSubscriptions,
19
25
  } from "./subscriptions/postGridEntityBroken";
26
+ import {
27
+ postGridEntityCustomBrokenFire,
28
+ postGridEntityCustomBrokenHasSubscriptions,
29
+ } from "./subscriptions/postGridEntityCustomBroken";
30
+ import {
31
+ postGridEntityCustomInitFire,
32
+ postGridEntityCustomInitHasSubscriptions,
33
+ } from "./subscriptions/postGridEntityCustomInit";
34
+ import {
35
+ postGridEntityCustomRemoveFire,
36
+ postGridEntityCustomRemoveHasSubscriptions,
37
+ } from "./subscriptions/postGridEntityCustomRemove";
38
+ import {
39
+ postGridEntityCustomStateChangedFire,
40
+ postGridEntityCustomStateChangedHasSubscriptions,
41
+ } from "./subscriptions/postGridEntityCustomStateChanged";
42
+ import {
43
+ postGridEntityCustomUpdateFire,
44
+ postGridEntityCustomUpdateHasSubscriptions,
45
+ } from "./subscriptions/postGridEntityCustomUpdate";
20
46
  import {
21
47
  postGridEntityInitFire,
22
48
  postGridEntityInitHasSubscriptions,
@@ -60,10 +86,15 @@ export function postGridEntityCallbacksInit(mod: ModUpgraded): void {
60
86
  function hasSubscriptions() {
61
87
  return (
62
88
  postGridEntityInitHasSubscriptions() ||
89
+ postGridEntityCustomInitHasSubscriptions() ||
63
90
  postGridEntityUpdateHasSubscriptions() ||
91
+ postGridEntityCustomUpdateHasSubscriptions() ||
64
92
  postGridEntityRemoveHasSubscriptions() ||
93
+ postGridEntityCustomRemoveHasSubscriptions() ||
65
94
  postGridEntityStateChangedHasSubscriptions() ||
66
- postGridEntityBrokenHasSubscriptions()
95
+ postGridEntityCustomStateChangedHasSubscriptions() ||
96
+ postGridEntityBrokenHasSubscriptions() ||
97
+ postGridEntityCustomBrokenHasSubscriptions()
67
98
  );
68
99
  }
69
100
 
@@ -82,7 +113,13 @@ function postUpdate() {
82
113
  for (const [gridIndex, gridEntity] of gridEntitiesMap.entries()) {
83
114
  checkGridEntityStateChanged(gridIndex, gridEntity);
84
115
  checkNewGridEntity(gridIndex, gridEntity);
85
- postGridEntityUpdateFire(gridEntity);
116
+
117
+ const gridEntityTypeCustom = getCustomGridEntityType(gridIndex);
118
+ if (gridEntityTypeCustom === undefined) {
119
+ postGridEntityUpdateFire(gridEntity);
120
+ } else {
121
+ postGridEntityCustomUpdateFire(gridEntity, gridEntityTypeCustom);
122
+ }
86
123
  }
87
124
  }
88
125
 
@@ -98,11 +135,17 @@ function checkGridEntitiesRemoved(gridEntitiesMap: Map<int, GridEntity>) {
98
135
  gridEntity.GetType() !== storedGridEntityType
99
136
  ) {
100
137
  v.room.initializedGridEntities.delete(gridIndex);
101
- postGridEntityRemoveFire(
102
- gridIndex,
103
- storedGridEntityType,
104
- storedGridEntityVariant,
105
- );
138
+
139
+ const gridEntityTypeCustom = getCustomGridEntityType(gridIndex);
140
+ if (gridEntityTypeCustom === undefined) {
141
+ postGridEntityRemoveFire(
142
+ gridIndex,
143
+ storedGridEntityType,
144
+ storedGridEntityVariant,
145
+ );
146
+ } else {
147
+ postGridEntityCustomRemoveFire(gridIndex, gridEntityTypeCustom);
148
+ }
106
149
  }
107
150
  }
108
151
  }
@@ -119,10 +162,26 @@ function checkGridEntityStateChanged(gridIndex: int, gridEntity: GridEntity) {
119
162
  const newState = gridEntity.State;
120
163
  if (oldState !== newState) {
121
164
  updateTupleInMap(gridEntity);
122
- postGridEntityStateChangedFire(gridEntity, oldState, newState);
165
+
166
+ const gridEntityTypeCustom = getCustomGridEntityType(gridEntity);
167
+
168
+ if (gridEntityTypeCustom === undefined) {
169
+ postGridEntityStateChangedFire(gridEntity, oldState, newState);
170
+ } else {
171
+ postGridEntityCustomStateChangedFire(
172
+ gridEntity,
173
+ gridEntityTypeCustom,
174
+ oldState,
175
+ newState,
176
+ );
177
+ }
123
178
 
124
179
  if (isGridEntityBroken(gridEntity)) {
125
- postGridEntityBrokenFire(gridEntity);
180
+ if (gridEntityTypeCustom === undefined) {
181
+ postGridEntityBrokenFire(gridEntity);
182
+ } else {
183
+ postGridEntityCustomBrokenFire(gridEntity, gridEntityTypeCustom);
184
+ }
126
185
  }
127
186
  }
128
187
  }
@@ -133,7 +192,13 @@ function checkNewGridEntity(gridIndex: int, gridEntity: GridEntity) {
133
192
 
134
193
  if (gridEntityTuple === undefined || gridEntityTuple[0] !== gridEntityType) {
135
194
  updateTupleInMap(gridEntity);
136
- postGridEntityInitFire(gridEntity);
195
+
196
+ const gridEntityTypeCustom = getCustomGridEntityType(gridEntity);
197
+ if (gridEntityTypeCustom === undefined) {
198
+ postGridEntityInitFire(gridEntity);
199
+ } else {
200
+ postGridEntityCustomInitFire(gridEntity, gridEntityTypeCustom);
201
+ }
137
202
  }
138
203
  }
139
204
 
@@ -1,8 +1,7 @@
1
- import { TearFlag } from "isaac-typescript-definitions";
2
1
  import { DefaultMap } from "../classes/DefaultMap";
3
2
  import { ModUpgraded } from "../classes/ModUpgraded";
4
- import { StatType } from "../enums";
5
3
  import { ModCallbackCustom } from "../enums/ModCallbackCustom";
4
+ import { StatType } from "../enums/StatType";
6
5
  import { saveDataManager } from "../features/saveDataManager/exports";
7
6
  import { isBitSet128 } from "../functions/bitSet128";
8
7
  import { colorEquals, isColor } from "../functions/color";
@@ -10,14 +9,14 @@ import { getEnumValues } from "../functions/enums";
10
9
  import { getPlayerIndex } from "../functions/playerIndex";
11
10
  import { getPlayerStat } from "../functions/playerStats";
12
11
  import { isBoolean, isNumber } from "../functions/types";
12
+ import { isVector, vectorEquals } from "../functions/vector";
13
13
  import { PlayerIndex } from "../types/PlayerIndex";
14
+ import { PossibleStatType } from "../types/PossibleStatType";
14
15
  import {
15
16
  postPlayerChangeStatFire,
16
17
  postPlayerChangeStatHasSubscriptions,
17
18
  } from "./subscriptions/postPlayerChangeStat";
18
19
 
19
- type PossibleStatType = number | boolean | BitFlags<TearFlag> | Color;
20
-
21
20
  const v = {
22
21
  run: {
23
22
  playersStatMap: new DefaultMap<
@@ -100,6 +99,11 @@ function statEquals(
100
99
  return colorEquals(oldValue, newValue);
101
100
  }
102
101
 
102
+ const isVectorStat = isVector(oldValue) && isVector(newValue);
103
+ if (isVectorStat) {
104
+ return vectorEquals(oldValue, newValue);
105
+ }
106
+
103
107
  error(
104
108
  'Failed to determine the type of a stat in the "POST_PLAYER_CHANGE_STAT" callback.',
105
109
  );
@@ -10,6 +10,10 @@ export type PostGridEntityCustomBrokenRegisterParameters = [
10
10
 
11
11
  const subscriptions: PostGridEntityCustomBrokenRegisterParameters[] = [];
12
12
 
13
+ export function postGridEntityCustomBrokenHasSubscriptions(): boolean {
14
+ return subscriptions.length > 0;
15
+ }
16
+
13
17
  export function postGridEntityCustomBrokenRegister(
14
18
  ...args: PostGridEntityCustomBrokenRegisterParameters
15
19
  ): void {
@@ -0,0 +1,38 @@
1
+ import { GridEntityType } from "isaac-typescript-definitions";
2
+
3
+ export type PostGridEntityCustomInitRegisterParameters = [
4
+ callback: (
5
+ gridEntity: GridEntity,
6
+ gridEntityTypeCustom: GridEntityType,
7
+ ) => void,
8
+ gridEntityTypeCustom?: GridEntityType,
9
+ ];
10
+
11
+ const subscriptions: PostGridEntityCustomInitRegisterParameters[] = [];
12
+
13
+ export function postGridEntityCustomInitHasSubscriptions(): boolean {
14
+ return subscriptions.length > 0;
15
+ }
16
+
17
+ export function postGridEntityCustomInitRegister(
18
+ ...args: PostGridEntityCustomInitRegisterParameters
19
+ ): void {
20
+ subscriptions.push(args);
21
+ }
22
+
23
+ export function postGridEntityCustomInitFire(
24
+ gridEntity: GridEntity,
25
+ gridEntityTypeCustom: GridEntityType,
26
+ ): void {
27
+ for (const [callback, callbackGridEntityTypeCustom] of subscriptions) {
28
+ // Handle the optional 2nd callback argument.
29
+ if (
30
+ callbackGridEntityTypeCustom !== undefined &&
31
+ callbackGridEntityTypeCustom !== gridEntityTypeCustom
32
+ ) {
33
+ continue;
34
+ }
35
+
36
+ callback(gridEntity, gridEntityTypeCustom);
37
+ }
38
+ }
@@ -0,0 +1,35 @@
1
+ import { GridEntityType } from "isaac-typescript-definitions";
2
+
3
+ export type PostGridEntityCustomRemoveRegisterParameters = [
4
+ callback: (gridIndex: int, gridEntityTypeCustom: GridEntityType) => void,
5
+ gridEntityTypeCustom?: GridEntityType,
6
+ ];
7
+
8
+ const subscriptions: PostGridEntityCustomRemoveRegisterParameters[] = [];
9
+
10
+ export function postGridEntityCustomRemoveHasSubscriptions(): boolean {
11
+ return subscriptions.length > 0;
12
+ }
13
+
14
+ export function postGridEntityCustomRemoveRegister(
15
+ ...args: PostGridEntityCustomRemoveRegisterParameters
16
+ ): void {
17
+ subscriptions.push(args);
18
+ }
19
+
20
+ export function postGridEntityCustomRemoveFire(
21
+ gridIndex: int,
22
+ gridEntityTypeCustom: GridEntityType,
23
+ ): void {
24
+ for (const [callback, callbackGridEntityTypeCustom] of subscriptions) {
25
+ // Handle the optional 2nd callback argument.
26
+ if (
27
+ callbackGridEntityTypeCustom !== undefined &&
28
+ callbackGridEntityTypeCustom !== gridEntityTypeCustom
29
+ ) {
30
+ continue;
31
+ }
32
+
33
+ callback(gridIndex, gridEntityTypeCustom);
34
+ }
35
+ }
@@ -0,0 +1,42 @@
1
+ import { GridEntityType } from "isaac-typescript-definitions";
2
+
3
+ export type PostGridEntityCustomStateChangedRegisterParameters = [
4
+ callback: (
5
+ gridEntity: GridEntity,
6
+ gridEntityTypeCustom: GridEntityType,
7
+ oldState: int,
8
+ newState: int,
9
+ ) => void,
10
+ gridEntityTypeCustom?: GridEntityType,
11
+ ];
12
+
13
+ const subscriptions: PostGridEntityCustomStateChangedRegisterParameters[] = [];
14
+
15
+ export function postGridEntityCustomStateChangedHasSubscriptions(): boolean {
16
+ return subscriptions.length > 0;
17
+ }
18
+
19
+ export function postGridEntityCustomStateChangedRegister(
20
+ ...args: PostGridEntityCustomStateChangedRegisterParameters
21
+ ): void {
22
+ subscriptions.push(args);
23
+ }
24
+
25
+ export function postGridEntityCustomStateChangedFire(
26
+ gridEntity: GridEntity,
27
+ gridEntityTypeCustom: GridEntityType,
28
+ oldState: int,
29
+ newState: int,
30
+ ): void {
31
+ for (const [callback, callbackGridEntityTypeCustom] of subscriptions) {
32
+ // Handle the optional 2nd callback argument.
33
+ if (
34
+ callbackGridEntityTypeCustom !== undefined &&
35
+ callbackGridEntityTypeCustom !== gridEntityTypeCustom
36
+ ) {
37
+ continue;
38
+ }
39
+
40
+ callback(gridEntity, gridEntityTypeCustom, oldState, newState);
41
+ }
42
+ }
@@ -1,18 +1,15 @@
1
- import {
2
- PlayerType,
3
- PlayerVariant,
4
- TearFlag,
5
- } from "isaac-typescript-definitions";
1
+ import { PlayerType, PlayerVariant } from "isaac-typescript-definitions";
6
2
  import { StatType } from "../../enums/StatType";
7
3
  import { StatTypeType } from "../../interfaces/StatTypeType";
4
+ import { PossibleStatType } from "../../types/PossibleStatType";
8
5
 
9
6
  export type PostPlayerChangeStatRegisterParameters = [
10
7
  callback: (
11
8
  player: EntityPlayer,
12
9
  statType: StatType,
13
10
  difference: int,
14
- oldValue: number | boolean | BitFlags<TearFlag> | Color | Vector,
15
- newValue: number | boolean | BitFlags<TearFlag> | Color | Vector,
11
+ oldValue: PossibleStatType,
12
+ newValue: PossibleStatType,
16
13
  ) => void,
17
14
  playerVariant?: PlayerVariant,
18
15
  character?: PlayerType,
@@ -1,7 +1,8 @@
1
1
  import { isFunction, isPrimitive } from "../functions/types";
2
2
 
3
3
  /**
4
- * `DefaultMap` is a data structure that makes working with default values easier.
4
+ * `DefaultMap` is a data structure that makes working with default values easier. It extends a
5
+ * `Map` and adds additional methods.
5
6
  *
6
7
  * It is a common pattern to look up a value in a `Map`, and then, if the value does not exist, set
7
8
  * a default value for the key, and then return the default value. `DefaultMap` abstracts this
@@ -89,7 +90,7 @@ export class DefaultMap<Key, Value, Args extends unknown[] = []> extends Map<
89
90
 
90
91
  /**
91
92
  * See the main `DefaultMap` documentation:
92
- * https://isaacscript.github.io/isaacscript-common/classes/classes_DefaultMap.DefaultMap
93
+ * https://isaacscript.github.io/isaacscript-common/other/classes/DefaultMap
93
94
  */
94
95
  constructor(
95
96
  defaultValueOrFactoryFunction: Value | FactoryFunction<Value, Args>,
@@ -216,7 +216,7 @@ export enum ModCallbackCustom {
216
216
 
217
217
  /**
218
218
  * Fires from the `POST_EFFECT_UPDATE` callback when an effect's state has changed from what it
219
- * was on the previous frame.
219
+ * was on the previous frame. (In this context, "state" refers to the `EntityEffect.State` field.)
220
220
  *
221
221
  * When registering the callback, takes an optional second argument that will make the callback
222
222
  * only fire if it matches the `EffectVariant` provided.
@@ -258,7 +258,8 @@ export enum ModCallbackCustom {
258
258
 
259
259
  /**
260
260
  * Fires from the `POST_FAMILIAR_UPDATE` callback when a familiar's state has changed from what it
261
- * was on the previous frame.
261
+ * was on the previous frame. (In this context, "state" refers to the `EntityFamiliar.State`
262
+ * field.)
262
263
  *
263
264
  * When registering the callback, takes an optional second argument that will make the callback
264
265
  * only fire if it matches the `FamiliarVariant` provided.
@@ -337,7 +338,8 @@ export enum ModCallbackCustom {
337
338
 
338
339
  /**
339
340
  * Fires from the `POST_UPDATE` callback when a grid entity changes to a state that corresponds to
340
- * the broken state for the respective grid entity type.
341
+ * the broken state for the respective grid entity type. (For example, this will fire for a
342
+ * `GridEntityType.ROCK` (2) when its state changes to `RockState.BROKEN` (2).)
341
343
  *
342
344
  * When registering the callback, takes an optional second argument that will make the callback
343
345
  * only fire if it matches the `GridEntityType` provided.
@@ -364,12 +366,8 @@ export enum ModCallbackCustom {
364
366
  POST_GRID_ENTITY_COLLISION,
365
367
 
366
368
  /**
367
- * Fires from the `POST_UPDATE` callback when a grid entity created with the
368
- * `spawnCustomGridEntity` helper function is hit by an explosion.
369
- *
370
- * In most cases, you will want to remove the grid entity inside of this callback in order to
371
- * prevent further "broken" callbacks from firing. (This would not be the case if you were trying
372
- * to emulate a super tinted rock that takes multiple explosions to destroy, for example.)
369
+ * The same as the `POST_GRID_ENTITY_BROKEN` callback, but only fires for grid entities created
370
+ * with the `spawnCustomGridEntity` helper function.
373
371
  *
374
372
  * When registering the callback, takes an optional second argument that will make the callback
375
373
  * only fire if it matches the `GridEntityType` provided.
@@ -384,24 +382,57 @@ export enum ModCallbackCustom {
384
382
  POST_GRID_ENTITY_CUSTOM_BROKEN,
385
383
 
386
384
  /**
387
- * Fires from the `POST_UPDATE` callback a new entity collides with a grid entity created with the
388
- * `spawnCustomGridEntity` helper function.
385
+ * The same as the `POST_GRID_ENTITY_COLLISION` callback, but only fires for grid entities created
386
+ * with the `spawnCustomGridEntity` helper function.
389
387
  *
390
388
  * When registering the callback, takes an optional second argument that will make the callback
391
389
  * only fire if it matches the `GridEntityType` provided.
392
390
  *
393
391
  * ```ts
394
- * function postGridEntityCustomRender(
392
+ * function postGridEntityCustomCollision(
395
393
  * gridEntity: GridEntity,
396
394
  * gridEntityTypeCustom: GridEntityType,
395
+ * entity: Entity,
397
396
  * ): void {}
398
397
  * ```
399
398
  */
400
399
  POST_GRID_ENTITY_CUSTOM_COLLISION,
401
400
 
402
401
  /**
403
- * Fires from the `POST_RENDER` callback on every frame that a grid entity created with the
404
- * `spawnCustomGridEntity` helper function exists.
402
+ * The same as the `POST_GRID_ENTITY_INIT` callback, but only fires for grid entities created with
403
+ * the `spawnCustomGridEntity` helper function.
404
+ *
405
+ * When registering the callback, takes an optional second argument that will make the callback
406
+ * only fire if it matches the `GridEntityType` provided.
407
+ *
408
+ * ```ts
409
+ * function postGridEntityCustomInit(
410
+ * gridEntity: GridEntity,
411
+ * gridEntityTypeCustom: GridEntityType,
412
+ * ): void {}
413
+ * ```
414
+ */
415
+ POST_GRID_ENTITY_CUSTOM_INIT,
416
+
417
+ /**
418
+ * The same as the `POST_GRID_ENTITY_REMOVE` callback, but only fires for grid entities created
419
+ * with the `spawnCustomGridEntity` helper function.
420
+ *
421
+ * When registering the callback, takes an optional second argument that will make the callback
422
+ * only fire if it matches the `GridEntityType` provided.
423
+ *
424
+ * ```ts
425
+ * function postGridEntityCustomRemove(
426
+ * gridIndex: int,
427
+ * gridEntityTypeCustom: GridEntityType,
428
+ * ): void {}
429
+ * ```
430
+ */
431
+ POST_GRID_ENTITY_CUSTOM_REMOVE,
432
+
433
+ /**
434
+ * The same as the `POST_GRID_ENTITY_RENDER` callback, but only fires for grid entities created
435
+ * with the `spawnCustomGridEntity` helper function.
405
436
  *
406
437
  * When registering the callback, takes an optional second argument that will make the callback
407
438
  * only fire if it matches the `GridEntityType` provided.
@@ -416,8 +447,26 @@ export enum ModCallbackCustom {
416
447
  POST_GRID_ENTITY_CUSTOM_RENDER,
417
448
 
418
449
  /**
419
- * Fires from the `POST_UPDATE` callback on every frame that a grid entity created with the
420
- * `spawnCustomGridEntity` helper function exists.
450
+ * The same as the `POST_GRID_ENTITY_STATE_CHANGED` callback, but only fires for grid entities
451
+ * created with the `spawnCustomGridEntity` helper function.
452
+ *
453
+ * When registering the callback, takes an optional second argument that will make the callback
454
+ * only fire if it matches the `GridEntityType` provided.
455
+ *
456
+ * ```ts
457
+ * function postGridEntityCustomStateChanged(
458
+ * gridEntity: GridEntity,
459
+ * gridEntityTypeCustom: GridEntityType,
460
+ * oldState: int,
461
+ * newState: int,
462
+ * ): void {}
463
+ * ```
464
+ */
465
+ POST_GRID_ENTITY_CUSTOM_STATE_CHANGED,
466
+
467
+ /**
468
+ * The same as the `POST_GRID_ENTITY_UPDATE` callback, but only fires for grid entities created
469
+ * with the `spawnCustomGridEntity` helper function.
421
470
  *
422
471
  * When registering the callback, takes an optional second argument that will make the callback
423
472
  * only fire if it matches the `GridEntityType` provided.
@@ -452,6 +501,8 @@ export enum ModCallbackCustom {
452
501
  * Fires from the `POST_UPDATE` callback when a new grid entity is removed. Specifically, this on
453
502
  * the frame after it no longer exists (where it did exist a frame ago).
454
503
  *
504
+ * (Leaving a room with a grid entity does not count as "removing" it.)
505
+ *
455
506
  * When registering the callback, takes an optional second argument that will make the callback
456
507
  * only fire if it matches the `GridEntityType` provided.
457
508
  *
@@ -479,7 +530,8 @@ export enum ModCallbackCustom {
479
530
  POST_GRID_ENTITY_RENDER,
480
531
 
481
532
  /**
482
- * Fires from the `POST_UPDATE` callback when a grid entity changes its state.
533
+ * Fires from the `POST_UPDATE` callback when a grid entity changes its state. (In this context,
534
+ * "state" refers to the `GridEntity.State` field.)
483
535
  *
484
536
  * When registering the callback, takes an optional second argument that will make the callback
485
537
  * only fire if it matches the `GridEntityType` provided.
@@ -670,7 +722,7 @@ export enum ModCallbackCustom {
670
722
 
671
723
  /**
672
724
  * Fires from the `POST_NPC_UPDATE` callback when an NPC's state has changed from what it was on
673
- * the previous frame.
725
+ * the previous frame. (In this context, "state" refers to the `EntityNPC.State` field.)
674
726
  *
675
727
  * - When registering the callback, takes an optional second argument that will make the callback
676
728
  * only fire if it matches the `EntityType` provided.
@@ -758,7 +810,7 @@ export enum ModCallbackCustom {
758
810
 
759
811
  /**
760
812
  * Fires from the `POST_PICKUP_UPDATE` callback when a pickup's state has changed from what it was
761
- * on the previous frame.
813
+ * on the previous frame. (In this context, "state" refers to the `EntityPickup.State` field.)
762
814
  *
763
815
  * When registering the callback, takes an optional second argument that will make the callback
764
816
  * only fire if it matches the `PickupVariant` provided.
@@ -1110,7 +1162,8 @@ export enum ModCallbackCustom {
1110
1162
  POST_ROCK_UPDATE,
1111
1163
 
1112
1164
  /**
1113
- * Fires from the `POST_UPDATE` callback when the clear state of a room changes.
1165
+ * Fires from the `POST_UPDATE` callback when the clear state of a room changes (as according to
1166
+ * the `Room.IsClear` method).
1114
1167
  *
1115
1168
  * When registering the callback, takes an optional second argument that will make the callback
1116
1169
  * only fire if the room clear state matches the boolean provided.
@@ -39,9 +39,9 @@ export enum StatType {
39
39
  /** Corresponds to `CacheFlag.LUCK` (1 << 10) and `EntityPlayer.Luck`. */
40
40
  LUCK,
41
41
 
42
- // - `CacheFlag.SIZE` (1 << 12) does not have a corresponding `EntityPlayer` field. (After picking
43
- // up Magic Mushroom, the values of `EntityPlayer.Size` and `EntityPlayer.SizeMulti` do not
44
- // change.)
42
+ /** Corresponds to `CacheFlag.SIZE` (1 << 11) and `EntityPlayer.SpriteScale`. */
43
+ SIZE,
44
+
45
45
  // - `CacheFlag.COLOR` (1 << 12) does not have a corresponding `EntityPlayer` field.
46
46
  // - `CacheFlag.PICKUP_VISION` (1 << 13) does not have a corresponding `EntityPlayer` field.
47
47
  }