isaacscript-common 6.6.5 → 6.8.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.
Files changed (234) hide show
  1. package/dist/callbacks/customRevive.lua +4 -4
  2. package/dist/callbacks/postCursedTeleport.lua +2 -2
  3. package/dist/callbacks/postCustomDoorEnter.lua +5 -5
  4. package/dist/callbacks/postDiceRoomActivated.lua +2 -2
  5. package/dist/callbacks/postFlip.lua +3 -3
  6. package/dist/callbacks/postGridEntity.lua +3 -3
  7. package/dist/callbacks/postGridEntityCollision.lua +3 -3
  8. package/dist/callbacks/postGridEntityRender.lua +2 -2
  9. package/dist/callbacks/postNewRoomEarly.lua +5 -5
  10. package/dist/callbacks/postPickupCollect.lua +2 -2
  11. package/dist/callbacks/postPitRender.lua +2 -2
  12. package/dist/callbacks/postPitUpdate.lua +2 -2
  13. package/dist/callbacks/postPlayerCollectible.lua +2 -2
  14. package/dist/callbacks/postPoopRender.lua +2 -2
  15. package/dist/callbacks/postPoopUpdate.lua +2 -2
  16. package/dist/callbacks/postPressurePlateRender.lua +2 -2
  17. package/dist/callbacks/postPressurePlateUpdate.lua +2 -2
  18. package/dist/callbacks/postPurchase.lua +2 -2
  19. package/dist/callbacks/postRockRender.lua +2 -2
  20. package/dist/callbacks/postRockUpdate.lua +2 -2
  21. package/dist/callbacks/postSlotInitUpdate.lua +2 -2
  22. package/dist/callbacks/postSlotRender.lua +2 -2
  23. package/dist/callbacks/postSpikesRender.lua +2 -2
  24. package/dist/callbacks/postSpikesUpdate.lua +2 -2
  25. package/dist/callbacks/postTNTRender.lua +2 -2
  26. package/dist/callbacks/postTNTUpdate.lua +2 -2
  27. package/dist/callbacks/preBerserkDeath.lua +2 -2
  28. package/dist/callbacks/preNewLevel.lua +2 -2
  29. package/dist/callbacks/subscriptions/postDoorRender.d.ts +2 -3
  30. package/dist/callbacks/subscriptions/postDoorRender.d.ts.map +1 -1
  31. package/dist/callbacks/subscriptions/postDoorRender.lua +3 -3
  32. package/dist/callbacks/subscriptions/postDoorUpdate.d.ts +2 -3
  33. package/dist/callbacks/subscriptions/postDoorUpdate.d.ts.map +1 -1
  34. package/dist/callbacks/subscriptions/postDoorUpdate.lua +3 -3
  35. package/dist/callbacks/subscriptions/postPitRender.d.ts +2 -3
  36. package/dist/callbacks/subscriptions/postPitRender.d.ts.map +1 -1
  37. package/dist/callbacks/subscriptions/postPitRender.lua +3 -3
  38. package/dist/callbacks/subscriptions/postPitUpdate.d.ts +2 -3
  39. package/dist/callbacks/subscriptions/postPitUpdate.d.ts.map +1 -1
  40. package/dist/callbacks/subscriptions/postPitUpdate.lua +3 -3
  41. package/dist/callbacks/subscriptions/postPoopRender.d.ts +2 -3
  42. package/dist/callbacks/subscriptions/postPoopRender.d.ts.map +1 -1
  43. package/dist/callbacks/subscriptions/postPoopRender.lua +3 -3
  44. package/dist/callbacks/subscriptions/postPoopUpdate.d.ts +2 -3
  45. package/dist/callbacks/subscriptions/postPoopUpdate.d.ts.map +1 -1
  46. package/dist/callbacks/subscriptions/postPoopUpdate.lua +3 -3
  47. package/dist/callbacks/subscriptions/postPressurePlateRender.d.ts +2 -3
  48. package/dist/callbacks/subscriptions/postPressurePlateRender.d.ts.map +1 -1
  49. package/dist/callbacks/subscriptions/postPressurePlateRender.lua +3 -3
  50. package/dist/callbacks/subscriptions/postPressurePlateUpdate.d.ts +2 -3
  51. package/dist/callbacks/subscriptions/postPressurePlateUpdate.d.ts.map +1 -1
  52. package/dist/callbacks/subscriptions/postPressurePlateUpdate.lua +3 -3
  53. package/dist/features/characterStats.lua +2 -2
  54. package/dist/features/collectibleItemPoolType.lua +2 -2
  55. package/dist/features/customGridEntity.d.ts.map +1 -1
  56. package/dist/features/customGridEntity.lua +5 -5
  57. package/dist/features/customStage/backdrop.lua +2 -2
  58. package/dist/features/customStage/{gridEntities.d.ts → customStageGridEntities.d.ts} +1 -1
  59. package/dist/features/customStage/customStageGridEntities.d.ts.map +1 -0
  60. package/dist/features/customStage/{gridEntities.lua → customStageGridEntities.lua} +8 -8
  61. package/dist/features/customStage/{util.d.ts → customStageUtils.d.ts} +1 -1
  62. package/dist/features/customStage/customStageUtils.d.ts.map +1 -0
  63. package/dist/features/customStage/{util.lua → customStageUtils.lua} +0 -0
  64. package/dist/features/customStage/exports.lua +4 -4
  65. package/dist/features/customStage/init.lua +6 -6
  66. package/dist/features/customStage/shadows.lua +2 -2
  67. package/dist/features/customStage/versusScreen.lua +4 -4
  68. package/dist/features/debugDisplay/v.lua +4 -4
  69. package/dist/features/deployJSONRoom.lua +20 -20
  70. package/dist/features/extraConsoleCommands/commandsSubroutines.lua +7 -7
  71. package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
  72. package/dist/features/extraConsoleCommands/listCommands.lua +14 -14
  73. package/dist/features/pause.lua +2 -2
  74. package/dist/features/persistentEntities.lua +2 -2
  75. package/dist/features/preventCollectibleRotation.lua +2 -2
  76. package/dist/features/saveDataManager/exports.d.ts.map +1 -1
  77. package/dist/features/sirenHelpers.lua +2 -2
  78. package/dist/functions/ambush.lua +5 -5
  79. package/dist/functions/{boss.d.ts → bosses.d.ts} +22 -4
  80. package/dist/functions/bosses.d.ts.map +1 -0
  81. package/dist/functions/{boss.lua → bosses.lua} +38 -13
  82. package/dist/functions/collectibleTag.lua +2 -2
  83. package/dist/functions/collectibles.lua +5 -5
  84. package/dist/functions/{entity.d.ts → entities.d.ts} +21 -19
  85. package/dist/functions/entities.d.ts.map +1 -0
  86. package/dist/functions/{entity.lua → entities.lua} +25 -20
  87. package/dist/functions/{entitySpecific.d.ts → entitiesSpecific.d.ts} +145 -68
  88. package/dist/functions/entitiesSpecific.d.ts.map +1 -0
  89. package/dist/functions/{entitySpecific.lua → entitiesSpecific.lua} +203 -65
  90. package/dist/functions/familiars.lua +2 -2
  91. package/dist/functions/{gridEntity.d.ts → gridEntities.d.ts} +48 -17
  92. package/dist/functions/gridEntities.d.ts.map +1 -0
  93. package/dist/functions/{gridEntity.lua → gridEntities.lua} +140 -90
  94. package/dist/functions/gridEntitiesSpecific.d.ts +141 -0
  95. package/dist/functions/gridEntitiesSpecific.d.ts.map +1 -0
  96. package/dist/functions/gridEntitiesSpecific.lua +366 -0
  97. package/dist/functions/log.d.ts +14 -6
  98. package/dist/functions/log.d.ts.map +1 -1
  99. package/dist/functions/log.lua +201 -163
  100. package/dist/functions/{npc.d.ts → npcs.d.ts} +24 -2
  101. package/dist/functions/npcs.d.ts.map +1 -0
  102. package/dist/functions/{npc.lua → npcs.lua} +44 -9
  103. package/dist/functions/pickups.d.ts +4 -119
  104. package/dist/functions/pickups.d.ts.map +1 -1
  105. package/dist/functions/pickups.lua +10 -439
  106. package/dist/functions/pickupsSpecific.d.ts +229 -0
  107. package/dist/functions/pickupsSpecific.d.ts.map +1 -0
  108. package/dist/functions/pickupsSpecific.lua +560 -0
  109. package/dist/functions/playerHealth.lua +6 -6
  110. package/dist/functions/{player.d.ts → players.d.ts} +1 -1
  111. package/dist/functions/players.d.ts.map +1 -0
  112. package/dist/functions/{player.lua → players.lua} +0 -0
  113. package/dist/functions/pocketItems.lua +2 -2
  114. package/dist/functions/positionVelocity.lua +6 -6
  115. package/dist/functions/pressurePlate.d.ts +10 -0
  116. package/dist/functions/pressurePlate.d.ts.map +1 -0
  117. package/dist/functions/pressurePlate.lua +29 -0
  118. package/dist/functions/revive.lua +7 -7
  119. package/dist/functions/rooms.lua +2 -2
  120. package/dist/functions/saveFile.lua +3 -3
  121. package/dist/functions/spawnCollectible.lua +4 -4
  122. package/dist/functions/{sprite.d.ts → sprites.d.ts} +1 -1
  123. package/dist/functions/sprites.d.ts.map +1 -0
  124. package/dist/functions/{sprite.lua → sprites.lua} +0 -0
  125. package/dist/functions/transformations.lua +2 -2
  126. package/dist/functions/trinketGive.lua +2 -2
  127. package/dist/functions/trinkets.lua +6 -6
  128. package/dist/functions/utils.d.ts +7 -0
  129. package/dist/functions/utils.d.ts.map +1 -1
  130. package/dist/functions/utils.lua +35 -22
  131. package/dist/index.d.ts +10 -8
  132. package/dist/index.d.ts.map +1 -1
  133. package/dist/index.lua +26 -10
  134. package/dist/types/AnyGridEntity.d.ts +10 -0
  135. package/dist/types/AnyGridEntity.d.ts.map +1 -0
  136. package/dist/types/AnyGridEntity.lua +2 -0
  137. package/package.json +2 -2
  138. package/src/callbacks/customRevive.ts +2 -2
  139. package/src/callbacks/postCursedTeleport.ts +1 -1
  140. package/src/callbacks/postCustomDoorEnter.ts +2 -2
  141. package/src/callbacks/postDiceRoomActivated.ts +1 -1
  142. package/src/callbacks/postFlip.ts +1 -1
  143. package/src/callbacks/postGridEntity.ts +1 -1
  144. package/src/callbacks/postGridEntityCollision.ts +1 -1
  145. package/src/callbacks/postGridEntityRender.ts +1 -1
  146. package/src/callbacks/postNewRoomEarly.ts +9 -3
  147. package/src/callbacks/postPickupCollect.ts +1 -1
  148. package/src/callbacks/postPitRender.ts +1 -1
  149. package/src/callbacks/postPitUpdate.ts +1 -1
  150. package/src/callbacks/postPlayerCollectible.ts +1 -1
  151. package/src/callbacks/postPoopRender.ts +1 -1
  152. package/src/callbacks/postPoopUpdate.ts +1 -1
  153. package/src/callbacks/postPressurePlateRender.ts +1 -1
  154. package/src/callbacks/postPressurePlateUpdate.ts +1 -1
  155. package/src/callbacks/postPurchase.ts +1 -1
  156. package/src/callbacks/postRockRender.ts +1 -1
  157. package/src/callbacks/postRockUpdate.ts +1 -1
  158. package/src/callbacks/postSlotInitUpdate.ts +1 -1
  159. package/src/callbacks/postSlotRender.ts +1 -1
  160. package/src/callbacks/postSpikesRender.ts +1 -1
  161. package/src/callbacks/postSpikesUpdate.ts +1 -1
  162. package/src/callbacks/postTNTRender.ts +1 -1
  163. package/src/callbacks/postTNTUpdate.ts +1 -1
  164. package/src/callbacks/preBerserkDeath.ts +1 -1
  165. package/src/callbacks/preNewLevel.ts +1 -1
  166. package/src/callbacks/subscriptions/postDoorRender.ts +7 -5
  167. package/src/callbacks/subscriptions/postDoorUpdate.ts +7 -5
  168. package/src/callbacks/subscriptions/postPitRender.ts +6 -7
  169. package/src/callbacks/subscriptions/postPitUpdate.ts +6 -7
  170. package/src/callbacks/subscriptions/postPoopRender.ts +7 -5
  171. package/src/callbacks/subscriptions/postPoopUpdate.ts +7 -5
  172. package/src/callbacks/subscriptions/postPressurePlateRender.ts +7 -5
  173. package/src/callbacks/subscriptions/postPressurePlateUpdate.ts +7 -5
  174. package/src/features/characterStats.ts +1 -1
  175. package/src/features/collectibleItemPoolType.ts +1 -1
  176. package/src/features/customGridEntity.ts +6 -3
  177. package/src/features/customStage/backdrop.ts +1 -1
  178. package/src/features/customStage/{gridEntities.ts → customStageGridEntities.ts} +3 -3
  179. package/src/features/customStage/{util.ts → customStageUtils.ts} +0 -0
  180. package/src/features/customStage/exports.ts +2 -2
  181. package/src/features/customStage/init.ts +1 -1
  182. package/src/features/customStage/shadows.ts +1 -1
  183. package/src/features/customStage/versusScreen.ts +2 -2
  184. package/src/features/debugDisplay/v.ts +2 -2
  185. package/src/features/deployJSONRoom.ts +11 -7
  186. package/src/features/extraConsoleCommands/commandsSubroutines.ts +5 -5
  187. package/src/features/extraConsoleCommands/listCommands.ts +10 -6
  188. package/src/features/pause.ts +1 -1
  189. package/src/features/persistentEntities.ts +1 -1
  190. package/src/features/preventCollectibleRotation.ts +1 -1
  191. package/src/features/saveDataManager/exports.ts +7 -4
  192. package/src/features/sirenHelpers.ts +1 -1
  193. package/src/functions/ambush.ts +2 -2
  194. package/src/functions/{boss.ts → bosses.ts} +29 -21
  195. package/src/functions/collectibleTag.ts +1 -1
  196. package/src/functions/collectibles.ts +2 -2
  197. package/src/functions/{entity.ts → entities.ts} +23 -21
  198. package/src/functions/{entitySpecific.ts → entitiesSpecific.ts} +170 -99
  199. package/src/functions/familiars.ts +1 -1
  200. package/src/functions/{gridEntity.ts → gridEntities.ts} +110 -34
  201. package/src/functions/gridEntitiesSpecific.ts +490 -0
  202. package/src/functions/log.ts +227 -181
  203. package/src/functions/{npc.ts → npcs.ts} +42 -11
  204. package/src/functions/pickups.ts +8 -475
  205. package/src/functions/pickupsSpecific.ts +613 -0
  206. package/src/functions/playerHealth.ts +1 -1
  207. package/src/functions/{player.ts → players.ts} +0 -0
  208. package/src/functions/pocketItems.ts +1 -1
  209. package/src/functions/positionVelocity.ts +3 -3
  210. package/src/functions/pressurePlate.ts +29 -0
  211. package/src/functions/revive.ts +2 -2
  212. package/src/functions/rooms.ts +1 -1
  213. package/src/functions/saveFile.ts +1 -1
  214. package/src/functions/spawnCollectible.ts +2 -2
  215. package/src/functions/{sprite.ts → sprites.ts} +0 -0
  216. package/src/functions/transformations.ts +1 -1
  217. package/src/functions/trinketGive.ts +1 -1
  218. package/src/functions/trinkets.ts +3 -3
  219. package/src/functions/utils.ts +32 -13
  220. package/src/index.ts +10 -8
  221. package/src/types/AnyGridEntity.ts +9 -0
  222. package/dist/features/customStage/gridEntities.d.ts.map +0 -1
  223. package/dist/features/customStage/util.d.ts.map +0 -1
  224. package/dist/functions/boss.d.ts.map +0 -1
  225. package/dist/functions/entity.d.ts.map +0 -1
  226. package/dist/functions/entitySpecific.d.ts.map +0 -1
  227. package/dist/functions/gridEntity.d.ts.map +0 -1
  228. package/dist/functions/gridEntitySpecific.d.ts +0 -29
  229. package/dist/functions/gridEntitySpecific.d.ts.map +0 -1
  230. package/dist/functions/gridEntitySpecific.lua +0 -114
  231. package/dist/functions/npc.d.ts.map +0 -1
  232. package/dist/functions/player.d.ts.map +0 -1
  233. package/dist/functions/sprite.d.ts.map +0 -1
  234. package/src/functions/gridEntitySpecific.ts +0 -143
@@ -16,13 +16,13 @@ import {
16
16
  import { game, sfxManager } from "../cachedClasses";
17
17
  import { arrayToString } from "./array";
18
18
  import { getCollectibleName } from "./collectibles";
19
- import { getEntities, getEntityID } from "./entity";
19
+ import { getEntities, getEntityID } from "./entities";
20
20
  import { getEnumEntries } from "./enums";
21
21
  import { hasFlag } from "./flag";
22
- import { getGridEntities } from "./gridEntity";
22
+ import { getGridEntities, getGridEntityID } from "./gridEntities";
23
23
  import { getIsaacAPIClassName } from "./isaacAPIClass";
24
- import { getEffectsList, getPlayerName } from "./player";
25
24
  import { getPlayerHealth } from "./playerHealth";
25
+ import { getEffectsList, getPlayerName } from "./players";
26
26
  import { getRoomData, getRoomGridIndex, getRoomListIndex } from "./roomData";
27
27
  import { combineSets, getSortedSetValues } from "./set";
28
28
  import { iterateTableInOrder } from "./table";
@@ -83,6 +83,106 @@ export function log(this: void, msg: string): void {
83
83
  Isaac.DebugString(debugMsg);
84
84
  }
85
85
 
86
+ /** Helper function for printing out every entity (or filtered entity) in the current room. */
87
+ export function logAllEntities(
88
+ this: void,
89
+ includeBackgroundEffects: boolean,
90
+ entityTypeFilter?: EntityType,
91
+ ): void {
92
+ let msg = "Entities in the room";
93
+ if (entityTypeFilter !== undefined) {
94
+ msg += ` (filtered to entity type ${entityTypeFilter})`;
95
+ } else if (!includeBackgroundEffects) {
96
+ msg += " (not including background effects)";
97
+ }
98
+ msg += ":\n";
99
+
100
+ const entities = getEntities();
101
+ let numMatchedEntities = 0;
102
+ entities.forEach((entity, i) => {
103
+ // If a filter was specified, exclude all entities outside of the filter.
104
+ if (entityTypeFilter !== undefined && entity.Type !== entityTypeFilter) {
105
+ return;
106
+ }
107
+
108
+ const effect = entity.ToEffect();
109
+ if (
110
+ !includeBackgroundEffects &&
111
+ effect !== undefined &&
112
+ IGNORE_EFFECT_VARIANTS.has(effect.Variant)
113
+ ) {
114
+ return;
115
+ }
116
+
117
+ msg += getEntityLogLine(entity, i + 1);
118
+ numMatchedEntities++;
119
+ });
120
+
121
+ if (numMatchedEntities === 0) {
122
+ msg += "(no entities matched)\n";
123
+ } else {
124
+ msg += `(${numMatchedEntities} total ${
125
+ numMatchedEntities === 1 ? "entity" : "entities"
126
+ })\n`;
127
+ }
128
+
129
+ log(msg);
130
+ }
131
+
132
+ /**
133
+ * Helper function for printing out every grid entity (or filtered grid entity) in the current room.
134
+ */
135
+ export function logAllGridEntities(
136
+ this: void,
137
+ includeWalls: boolean,
138
+ gridEntityTypeFilter?: GridEntityType,
139
+ ): void {
140
+ let msg = "Grid entities in the room";
141
+ if (gridEntityTypeFilter !== undefined) {
142
+ msg += ` (filtered to grid entity type ${gridEntityTypeFilter})`;
143
+ } else if (!includeWalls) {
144
+ msg += " (not including walls)";
145
+ }
146
+ msg += ":\n";
147
+
148
+ const gridEntities = getGridEntities();
149
+ let numMatchedEntities = 0;
150
+ gridEntities.forEach((gridEntity) => {
151
+ const gridEntityIndex = gridEntity.GetGridIndex();
152
+ const gridEntityType = gridEntity.GetType();
153
+
154
+ // If a filter was specified, exclude all entities outside of the filter.
155
+ if (
156
+ gridEntityTypeFilter !== undefined &&
157
+ gridEntityType !== gridEntityTypeFilter
158
+ ) {
159
+ return;
160
+ }
161
+
162
+ if (
163
+ !includeWalls &&
164
+ gridEntityType === GridEntityType.WALL &&
165
+ gridEntityTypeFilter !== GridEntityType.WALL
166
+ ) {
167
+ return;
168
+ }
169
+
170
+ msg += getGridEntityLogLine(gridEntity, gridEntityIndex);
171
+
172
+ numMatchedEntities++;
173
+ });
174
+
175
+ if (numMatchedEntities === 0) {
176
+ msg += "(no grid entities matched)\n";
177
+ } else {
178
+ msg += `(${numMatchedEntities} total grid ${
179
+ numMatchedEntities === 1 ? "entity" : "entities"
180
+ })\n`;
181
+ }
182
+
183
+ log(msg);
184
+ }
185
+
86
186
  export function logArray<T>(this: void, array: T[] | readonly T[]): void {
87
187
  const arrayString = arrayToString(array);
88
188
  log(`Array: ${arrayString}`);
@@ -130,116 +230,90 @@ export function logEffects(this: void, player: EntityPlayer): void {
130
230
  });
131
231
  }
132
232
 
133
- /** Helper function for printing out every entity (or filtered entity) in the current room. */
134
- export function logEntities(
135
- this: void,
136
- includeBackgroundEffects: boolean,
137
- entityTypeFilter?: EntityType,
138
- ): void {
139
- let msg = "Entities in the room";
140
- if (entityTypeFilter !== undefined) {
141
- msg += ` (filtered to entity type ${entityTypeFilter})`;
142
- } else if (!includeBackgroundEffects) {
143
- msg += " (not including background effects)";
233
+ /** Helper function for logging an array of specific entities. */
234
+ export function logEntities(this: void, entities: Entity[]): void {
235
+ for (const entity of entities) {
236
+ logEntity(entity);
144
237
  }
145
- msg += ":\n";
146
-
147
- const entities = getEntities();
148
- let numMatchedEntities = 0;
149
- entities.forEach((entity, i) => {
150
- // If a filter was specified, exclude all entities outside of the filter.
151
- if (entityTypeFilter !== undefined && entity.Type !== entityTypeFilter) {
152
- return;
153
- }
154
-
155
- const effect = entity.ToEffect();
156
- if (
157
- !includeBackgroundEffects &&
158
- effect !== undefined &&
159
- IGNORE_EFFECT_VARIANTS.has(effect.Variant)
160
- ) {
161
- return;
162
- }
238
+ }
163
239
 
164
- const entityID = getEntityID(entity);
165
- msg += `${i + 1}) ${entityID}`;
240
+ /** Helper function to log information about a specific entity. */
241
+ export function logEntity(this: void, entity: Entity): void {
242
+ const msg = getEntityLogLine(entity);
243
+ log(msg);
244
+ }
166
245
 
167
- const bomb = entity.ToBomb();
168
- if (bomb !== undefined) {
169
- msg += " (bomb)";
170
- }
246
+ function getEntityLogLine(entity: Entity, num?: int): string {
247
+ let msg = num === undefined ? "" : `${num}) `;
171
248
 
172
- if (effect !== undefined) {
173
- msg += ` (effect) (State: ${effect.State})`;
174
- }
249
+ msg += getEntityID(entity);
175
250
 
176
- const familiar = entity.ToFamiliar();
177
- if (familiar !== undefined) {
178
- msg += ` (familiar) (State: ${familiar.State})`;
179
- }
251
+ const bomb = entity.ToBomb();
252
+ if (bomb !== undefined) {
253
+ msg += " (bomb)";
254
+ }
180
255
 
181
- const knife = entity.ToKnife();
182
- if (knife !== undefined) {
183
- msg += " (knife)";
184
- }
256
+ const effect = entity.ToEffect();
257
+ if (effect !== undefined) {
258
+ msg += ` (effect) (State: ${effect.State})`;
259
+ }
185
260
 
186
- const laser = entity.ToLaser();
187
- if (laser !== undefined) {
188
- msg += " (laser)";
189
- }
261
+ const familiar = entity.ToFamiliar();
262
+ if (familiar !== undefined) {
263
+ msg += ` (familiar) (State: ${familiar.State})`;
264
+ }
190
265
 
191
- const npc = entity.ToNPC();
192
- if (npc !== undefined) {
193
- msg += ` (NPC) (State: ${npc.State})`;
194
- }
266
+ const knife = entity.ToKnife();
267
+ if (knife !== undefined) {
268
+ msg += " (knife)";
269
+ }
195
270
 
196
- const pickup = entity.ToPickup();
197
- if (pickup !== undefined) {
198
- msg += ` (pickup) (State: ${pickup.State})`;
199
- }
271
+ const laser = entity.ToLaser();
272
+ if (laser !== undefined) {
273
+ msg += " (laser)";
274
+ }
200
275
 
201
- const player = entity.ToPlayer();
202
- if (player !== undefined) {
203
- msg += " (player)";
204
- }
276
+ const npc = entity.ToNPC();
277
+ if (npc !== undefined) {
278
+ msg += ` (NPC) (State: ${npc.State})`;
279
+ }
205
280
 
206
- const projectile = entity.ToProjectile();
207
- if (projectile !== undefined) {
208
- msg += " (projectile)";
209
- }
281
+ const pickup = entity.ToPickup();
282
+ if (pickup !== undefined) {
283
+ msg += ` (pickup) (State: ${pickup.State})`;
284
+ }
210
285
 
211
- const tear = entity.ToTear();
212
- if (tear !== undefined) {
213
- msg += " (tear)";
214
- }
286
+ const player = entity.ToPlayer();
287
+ if (player !== undefined) {
288
+ msg += " (player)";
289
+ }
215
290
 
216
- msg += "\n";
217
- msg += ` - Index: ${entity.Index}\n`;
218
- msg += ` - InitSeed: ${entity.InitSeed}\n`;
219
- msg += ` - DropSeed: ${entity.DropSeed}\n`;
220
- msg += ` - Position: (${entity.Position.X}, ${entity.Position.Y})\n`;
221
- msg += ` - Velocity: (${entity.Velocity.X}, ${entity.Velocity.Y})\n`;
222
- msg += ` - HP: ${entity.HitPoints} / ${entity.MaxHitPoints}\n`;
223
- msg += ` - Parent: ${entity.Parent}\n`;
224
- msg += ` - Child: ${entity.Child}\n`;
225
- msg += ` - SpawnerEntity: ${entity.SpawnerEntity}\n`;
226
- msg += ` - SpawnerType / SpawnerVariant: ${entity.SpawnerType}.${entity.SpawnerVariant}\n`;
227
- if (npc !== undefined) {
228
- msg += ` - CanShutDoors: ${npc.CanShutDoors}\n`;
229
- }
291
+ const projectile = entity.ToProjectile();
292
+ if (projectile !== undefined) {
293
+ msg += " (projectile)";
294
+ }
230
295
 
231
- numMatchedEntities++;
232
- });
296
+ const tear = entity.ToTear();
297
+ if (tear !== undefined) {
298
+ msg += " (tear)";
299
+ }
233
300
 
234
- if (numMatchedEntities === 0) {
235
- msg += "(no entities matched)\n";
236
- } else {
237
- msg += `(${numMatchedEntities} total ${
238
- numMatchedEntities === 1 ? "entity" : "entities"
239
- })\n`;
301
+ msg += "\n";
302
+ msg += ` - Index: ${entity.Index}\n`;
303
+ msg += ` - InitSeed: ${entity.InitSeed}\n`;
304
+ msg += ` - DropSeed: ${entity.DropSeed}\n`;
305
+ msg += ` - Position: (${entity.Position.X}, ${entity.Position.Y})\n`;
306
+ msg += ` - Velocity: (${entity.Velocity.X}, ${entity.Velocity.Y})\n`;
307
+ msg += ` - HP: ${entity.HitPoints} / ${entity.MaxHitPoints}\n`;
308
+ msg += ` - Parent: ${entity.Parent}\n`;
309
+ msg += ` - Child: ${entity.Child}\n`;
310
+ msg += ` - SpawnerEntity: ${entity.SpawnerEntity}\n`;
311
+ msg += ` - SpawnerType / SpawnerVariant: ${entity.SpawnerType}.${entity.SpawnerVariant}\n`;
312
+ if (npc !== undefined) {
313
+ msg += ` - CanShutDoors: ${npc.CanShutDoors}\n`;
240
314
  }
241
315
 
242
- log(msg);
316
+ return msg;
243
317
  }
244
318
 
245
319
  /** Helper function for printing out every entity flag that is turned on. Useful when debugging. */
@@ -316,106 +390,74 @@ export function logGameStateFlags(this: void): void {
316
390
  }
317
391
  }
318
392
 
319
- /**
320
- * Helper function for printing out every grid entity (or filtered grid entity) in the current room.
321
- */
322
- export function logGridEntities(
323
- this: void,
324
- includeWalls: boolean,
325
- gridEntityTypeFilter?: GridEntityType,
326
- ): void {
327
- let msg = "Grid entities in the room";
328
- if (gridEntityTypeFilter !== undefined) {
329
- msg += ` (filtered to grid entity type ${gridEntityTypeFilter})`;
330
- } else if (!includeWalls) {
331
- msg += " (not including walls)";
393
+ /** Helper function for logging an array of specific grid entities. */
394
+ export function logGridEntities(this: void, gridEntities: GridEntity[]): void {
395
+ for (const gridEntity of gridEntities) {
396
+ logGridEntity(gridEntity);
332
397
  }
333
- msg += ":\n";
334
-
335
- const gridEntities = getGridEntities();
336
- let numMatchedEntities = 0;
337
- gridEntities.forEach((gridEntity) => {
338
- const gridEntityIndex = gridEntity.GetGridIndex();
339
- const gridEntityType = gridEntity.GetType();
340
- const gridEntityVariant = gridEntity.GetVariant();
341
- const gridEntityDesc = gridEntity.GetSaveState();
342
-
343
- // If a filter was specified, exclude all entities outside of the filter.
344
- if (
345
- gridEntityTypeFilter !== undefined &&
346
- gridEntityType !== gridEntityTypeFilter
347
- ) {
348
- return;
349
- }
398
+ }
350
399
 
351
- if (
352
- !includeWalls &&
353
- gridEntityType === GridEntityType.WALL &&
354
- gridEntityTypeFilter !== GridEntityType.WALL
355
- ) {
356
- return;
357
- }
400
+ /** Helper function for log information about a specific grid entity. */
401
+ export function logGridEntity(this: void, gridEntity: GridEntity): void {
402
+ const msg = getGridEntityLogLine(gridEntity);
403
+ log(msg);
404
+ }
358
405
 
359
- msg += `${gridEntityIndex}) ${gridEntityType}.${gridEntityVariant}.${gridEntity.State}`;
406
+ function getGridEntityLogLine(gridEntity: GridEntity, num?: int): string {
407
+ const gridEntityDesc = gridEntity.GetSaveState();
360
408
 
361
- const door = gridEntity.ToDoor();
362
- if (door !== undefined) {
363
- msg += " (door)";
364
- }
409
+ let msg = num === undefined ? "" : `${num}) `;
365
410
 
366
- const pit = gridEntity.ToPit();
367
- if (pit !== undefined) {
368
- msg += " (pit)";
369
- }
411
+ msg += getGridEntityID(gridEntity);
370
412
 
371
- const poop = gridEntity.ToPoop();
372
- if (poop !== undefined) {
373
- msg += " (poop)";
374
- }
413
+ const door = gridEntity.ToDoor();
414
+ if (door !== undefined) {
415
+ msg += " (door)";
416
+ }
375
417
 
376
- const pressurePlate = gridEntity.ToPressurePlate();
377
- if (pressurePlate !== undefined) {
378
- msg += " (pressurePlate)";
379
- }
418
+ const pit = gridEntity.ToPit();
419
+ if (pit !== undefined) {
420
+ msg += " (pit)";
421
+ }
380
422
 
381
- const rock = gridEntity.ToRock();
382
- if (rock !== undefined) {
383
- msg += " (rock)";
384
- }
423
+ const poop = gridEntity.ToPoop();
424
+ if (poop !== undefined) {
425
+ msg += " (poop)";
426
+ }
385
427
 
386
- const spikes = gridEntity.ToSpikes();
387
- if (spikes !== undefined) {
388
- msg += " (spikes)";
389
- }
428
+ const pressurePlate = gridEntity.ToPressurePlate();
429
+ if (pressurePlate !== undefined) {
430
+ msg += " (pressurePlate)";
431
+ }
390
432
 
391
- const tnt = gridEntity.ToTNT();
392
- if (tnt !== undefined) {
393
- msg += " (TNT)";
394
- }
433
+ const rock = gridEntity.ToRock();
434
+ if (rock !== undefined) {
435
+ msg += " (rock)";
436
+ }
395
437
 
396
- msg += ` - VarData: ${gridEntity.VarData}\n`;
397
- msg += ` - Position: (${gridEntity.Position.X}, ${gridEntity.Position.Y})\n`;
398
- msg += ` - SpawnSeed: ${gridEntityDesc.SpawnSeed}\n`;
399
- msg += ` - VariableSeed: ${gridEntityDesc.VariableSeed})\n`;
400
- if (door !== undefined) {
401
- msg += ` - Slot: ${door.Slot}\n`;
402
- msg += ` - Direction: ${door.Direction}\n`;
403
- msg += ` - TargetRoomIndex: ${door.TargetRoomIndex}\n`;
404
- msg += ` - TargetRoomType: ${door.TargetRoomType}\n`;
405
- }
438
+ const spikes = gridEntity.ToSpikes();
439
+ if (spikes !== undefined) {
440
+ msg += " (spikes)";
441
+ }
406
442
 
407
- numMatchedEntities++;
408
- });
443
+ const tnt = gridEntity.ToTNT();
444
+ if (tnt !== undefined) {
445
+ msg += " (TNT)";
446
+ }
409
447
 
410
- if (numMatchedEntities === 0) {
411
- msg += "(no grid entities matched)\n";
412
- } else {
413
- msg += `(${numMatchedEntities} total grid ${
414
- numMatchedEntities === 1 ? "entity" : "entities"
415
- })\n`;
448
+ msg += ` - State: ${gridEntity.State}\n`;
449
+ msg += ` - VarData: ${gridEntity.VarData}\n`;
450
+ msg += ` - Position: (${gridEntity.Position.X}, ${gridEntity.Position.Y})\n`;
451
+ msg += ` - SpawnSeed: ${gridEntityDesc.SpawnSeed}\n`;
452
+ msg += ` - VariableSeed: ${gridEntityDesc.VariableSeed})\n`;
453
+ if (door !== undefined) {
454
+ msg += ` - Slot: ${door.Slot}\n`;
455
+ msg += ` - Direction: ${door.Direction}\n`;
456
+ msg += ` - TargetRoomIndex: ${door.TargetRoomIndex}\n`;
457
+ msg += ` - TargetRoomType: ${door.TargetRoomType}\n`;
416
458
  }
417
459
 
418
- log(msg);
460
+ return msg;
419
461
  }
420
462
 
421
463
  export function logKColor(this: void, kColor: KColor): void {
@@ -714,17 +756,21 @@ export function setLogFunctionsGlobal(): void {
714
756
  const globals = _G as Record<string, unknown>;
715
757
 
716
758
  globals["log"] = log;
759
+ globals["logAllEntities"] = logAllEntities;
760
+ globals["logAllGridEntities"] = logAllGridEntities;
717
761
  globals["logArray"] = logArray;
718
762
  globals["logColor"] = logColor;
719
763
  globals["logDamageFlags"] = logDamageFlags;
720
764
  globals["logEffects"] = logEffects;
721
765
  globals["logEntities"] = logEntities;
766
+ globals["logEntity"] = logEntity;
722
767
  globals["logEntityID"] = logEntityID;
723
768
  globals["logEntityFlags"] = logEntityFlags;
724
769
  globals["logError"] = logError;
725
770
  globals["logFlags"] = logFlags;
726
771
  globals["logGameStateFlags"] = logGameStateFlags;
727
772
  globals["logGridEntities"] = logGridEntities;
773
+ globals["logGridEntity"] = logGridEntity;
728
774
  globals["logKColor"] = logKColor;
729
775
  globals["logLevelStateFlags"] = logLevelStateFlags;
730
776
  globals["logMap"] = logMap;
@@ -16,8 +16,8 @@ import {
16
16
  VisVariant,
17
17
  } from "isaac-typescript-definitions";
18
18
  import { EGGY_STATE_FRAME_OF_FINAL_SPIDER } from "../constants";
19
- import { getFilteredNewEntities } from "./entity";
20
- import { getNPCs, getProjectiles } from "./entitySpecific";
19
+ import { getFilteredNewEntities } from "./entities";
20
+ import { getNPCs, getProjectiles } from "./entitiesSpecific";
21
21
 
22
22
  /**
23
23
  * Used to filter out certain NPCs when determining of an NPC is "alive" and/or should keep the
@@ -78,19 +78,22 @@ export function fireProjectiles(
78
78
  *
79
79
  * This function will not include NPCs on an internal blacklist, such as Death's scythes or Big Horn
80
80
  * holes.
81
+ *
82
+ * @param entityType Optional. If specified, will only get the NPCs that match the type. Default is
83
+ * -1, which matches every type.
84
+ * @param variant Optional. If specified, will only get the NPCs that match the variant. Default is
85
+ * -1, which matches every variant.
86
+ * @param subType Optional. If specified, will only get the NPCs that match the sub-type. Default is
87
+ * -1, which matches every sub-type.
88
+ * @param ignoreFriendly Optional. Default is false.
81
89
  */
82
90
  export function getAliveNPCs(
83
- matchingEntityType?: EntityType,
84
- matchingVariant?: int,
85
- matchingSubType?: int,
91
+ entityType: EntityType = -1,
92
+ variant = -1,
93
+ subType = -1,
86
94
  ignoreFriendly = false,
87
95
  ): EntityNPC[] {
88
- const npcs = getNPCs(
89
- matchingEntityType,
90
- matchingVariant,
91
- matchingSubType,
92
- ignoreFriendly,
93
- );
96
+ const npcs = getNPCs(entityType, variant, subType, ignoreFriendly);
94
97
  return npcs.filter((npc) => !npc.IsDead() && !isAliveExceptionNPC(npc));
95
98
  }
96
99
 
@@ -146,3 +149,31 @@ export function isRaglingDeathPatch(npc: EntityNPC): boolean {
146
149
  npc.State === NpcState.SPECIAL
147
150
  );
148
151
  }
152
+
153
+ /**
154
+ * The base game `EntityNPC.FireProjectiles` method does not return anything, which is a problem in
155
+ * situations where you need to work with the fired projectiles. This function invokes that method,
156
+ * and then returns the projectiles that were spawned.
157
+ *
158
+ * @param npc The EntityNPC firing projectiles.
159
+ * @param position The starting position of the projectiles.
160
+ * @param velocity The starting velocity of the projectiles.
161
+ * @param projectilesMode A ProjectilesMode enum value defining how to fire the projectiles.
162
+ * @param projectileParams A ProjectileParams object containing various parameters for the
163
+ * projectiles.
164
+ * @returns An array of EntityProjectiles containing all fired projectiles.
165
+ */
166
+ export function npcFireProjectiles(
167
+ npc: EntityNPC,
168
+ position: Vector,
169
+ velocity: Vector,
170
+ projectilesMode: ProjectilesMode,
171
+ projectileParams: ProjectileParams,
172
+ ): EntityProjectile[] {
173
+ const oldEntities = getProjectiles();
174
+ npc.FireProjectiles(position, velocity, projectilesMode, projectileParams);
175
+ const newEntities = getProjectiles();
176
+ const filteredNewEntities = getFilteredNewEntities(oldEntities, newEntities);
177
+
178
+ return filteredNewEntities;
179
+ }