isaacscript-common 6.6.4 → 6.7.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 (250) hide show
  1. package/dist/callbacks/customRevive.lua +4 -4
  2. package/dist/callbacks/postCursedTeleport.lua +2 -2
  3. package/dist/callbacks/postCustomDoorEnter.d.ts +1 -1
  4. package/dist/callbacks/postCustomDoorEnter.lua +6 -6
  5. package/dist/callbacks/postDiceRoomActivated.lua +2 -2
  6. package/dist/callbacks/postFlip.lua +3 -3
  7. package/dist/callbacks/postGridEntity.lua +3 -3
  8. package/dist/callbacks/postGridEntityCollision.lua +3 -3
  9. package/dist/callbacks/postGridEntityRender.lua +2 -2
  10. package/dist/callbacks/postNewRoomEarly.lua +5 -5
  11. package/dist/callbacks/postPickupCollect.lua +2 -2
  12. package/dist/callbacks/postPitRender.lua +2 -2
  13. package/dist/callbacks/postPitUpdate.lua +2 -2
  14. package/dist/callbacks/postPlayerCollectible.lua +2 -2
  15. package/dist/callbacks/postPoopRender.lua +2 -2
  16. package/dist/callbacks/postPoopUpdate.lua +2 -2
  17. package/dist/callbacks/postPressurePlateRender.lua +2 -2
  18. package/dist/callbacks/postPressurePlateUpdate.lua +2 -2
  19. package/dist/callbacks/postPurchase.lua +2 -2
  20. package/dist/callbacks/postRockRender.lua +2 -2
  21. package/dist/callbacks/postRockUpdate.lua +2 -2
  22. package/dist/callbacks/postSlotInitUpdate.lua +2 -2
  23. package/dist/callbacks/postSlotRender.lua +2 -2
  24. package/dist/callbacks/postSpikesRender.lua +2 -2
  25. package/dist/callbacks/postSpikesUpdate.lua +2 -2
  26. package/dist/callbacks/postTNTRender.lua +2 -2
  27. package/dist/callbacks/postTNTUpdate.lua +2 -2
  28. package/dist/callbacks/preBerserkDeath.lua +2 -2
  29. package/dist/callbacks/preNewLevel.lua +2 -2
  30. package/dist/callbacks/subscriptions/postDoorRender.d.ts +2 -3
  31. package/dist/callbacks/subscriptions/postDoorRender.d.ts.map +1 -1
  32. package/dist/callbacks/subscriptions/postDoorRender.lua +3 -3
  33. package/dist/callbacks/subscriptions/postDoorUpdate.d.ts +2 -3
  34. package/dist/callbacks/subscriptions/postDoorUpdate.d.ts.map +1 -1
  35. package/dist/callbacks/subscriptions/postDoorUpdate.lua +3 -3
  36. package/dist/callbacks/subscriptions/postPitRender.d.ts +2 -3
  37. package/dist/callbacks/subscriptions/postPitRender.d.ts.map +1 -1
  38. package/dist/callbacks/subscriptions/postPitRender.lua +3 -3
  39. package/dist/callbacks/subscriptions/postPitUpdate.d.ts +2 -3
  40. package/dist/callbacks/subscriptions/postPitUpdate.d.ts.map +1 -1
  41. package/dist/callbacks/subscriptions/postPitUpdate.lua +3 -3
  42. package/dist/callbacks/subscriptions/postPoopRender.d.ts +2 -3
  43. package/dist/callbacks/subscriptions/postPoopRender.d.ts.map +1 -1
  44. package/dist/callbacks/subscriptions/postPoopRender.lua +3 -3
  45. package/dist/callbacks/subscriptions/postPoopUpdate.d.ts +2 -3
  46. package/dist/callbacks/subscriptions/postPoopUpdate.d.ts.map +1 -1
  47. package/dist/callbacks/subscriptions/postPoopUpdate.lua +3 -3
  48. package/dist/callbacks/subscriptions/postPressurePlateRender.d.ts +2 -3
  49. package/dist/callbacks/subscriptions/postPressurePlateRender.d.ts.map +1 -1
  50. package/dist/callbacks/subscriptions/postPressurePlateRender.lua +3 -3
  51. package/dist/callbacks/subscriptions/postPressurePlateUpdate.d.ts +2 -3
  52. package/dist/callbacks/subscriptions/postPressurePlateUpdate.d.ts.map +1 -1
  53. package/dist/callbacks/subscriptions/postPressurePlateUpdate.lua +3 -3
  54. package/dist/enums/private/SerializationBrand.d.ts +0 -4
  55. package/dist/enums/private/SerializationBrand.d.ts.map +1 -1
  56. package/dist/features/characterStats.lua +2 -2
  57. package/dist/features/collectibleItemPoolType.lua +2 -2
  58. package/dist/features/customGridEntity.d.ts.map +1 -1
  59. package/dist/features/customGridEntity.lua +5 -5
  60. package/dist/features/customStage/backdrop.lua +2 -2
  61. package/dist/features/customStage/{gridEntities.d.ts → customStageGridEntities.d.ts} +1 -1
  62. package/dist/features/customStage/customStageGridEntities.d.ts.map +1 -0
  63. package/dist/features/customStage/{gridEntities.lua → customStageGridEntities.lua} +8 -8
  64. package/dist/features/customStage/{util.d.ts → customStageUtils.d.ts} +1 -1
  65. package/dist/features/customStage/customStageUtils.d.ts.map +1 -0
  66. package/dist/features/customStage/{util.lua → customStageUtils.lua} +0 -0
  67. package/dist/features/customStage/exports.lua +4 -4
  68. package/dist/features/customStage/init.lua +6 -6
  69. package/dist/features/customStage/shadows.lua +2 -2
  70. package/dist/features/customStage/versusScreen.lua +4 -4
  71. package/dist/features/debugDisplay/v.lua +4 -4
  72. package/dist/features/deployJSONRoom.lua +20 -20
  73. package/dist/features/extraConsoleCommands/commandsSubroutines.lua +3 -3
  74. package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
  75. package/dist/features/extraConsoleCommands/listCommands.lua +14 -14
  76. package/dist/features/pause.lua +2 -2
  77. package/dist/features/persistentEntities.lua +2 -2
  78. package/dist/features/preventCollectibleRotation.lua +2 -2
  79. package/dist/features/saveDataManager/exports.d.ts.map +1 -1
  80. package/dist/features/sirenHelpers.lua +2 -2
  81. package/dist/functions/ambush.lua +5 -5
  82. package/dist/functions/{boss.d.ts → bosses.d.ts} +22 -4
  83. package/dist/functions/bosses.d.ts.map +1 -0
  84. package/dist/functions/{boss.lua → bosses.lua} +38 -13
  85. package/dist/functions/collectibleTag.lua +2 -2
  86. package/dist/functions/collectibles.lua +5 -5
  87. package/dist/functions/deepCopy.d.ts +8 -5
  88. package/dist/functions/deepCopy.d.ts.map +1 -1
  89. package/dist/functions/deepCopy.lua +142 -38
  90. package/dist/functions/{entity.d.ts → entities.d.ts} +21 -19
  91. package/dist/functions/entities.d.ts.map +1 -0
  92. package/dist/functions/{entity.lua → entities.lua} +25 -20
  93. package/dist/functions/{entitySpecific.d.ts → entitiesSpecific.d.ts} +145 -68
  94. package/dist/functions/entitiesSpecific.d.ts.map +1 -0
  95. package/dist/functions/{entitySpecific.lua → entitiesSpecific.lua} +203 -65
  96. package/dist/functions/familiars.lua +2 -2
  97. package/dist/functions/{gridEntity.d.ts → gridEntities.d.ts} +48 -17
  98. package/dist/functions/gridEntities.d.ts.map +1 -0
  99. package/dist/functions/{gridEntity.lua → gridEntities.lua} +140 -90
  100. package/dist/functions/gridEntitiesSpecific.d.ts +141 -0
  101. package/dist/functions/gridEntitiesSpecific.d.ts.map +1 -0
  102. package/dist/functions/gridEntitiesSpecific.lua +366 -0
  103. package/dist/functions/log.d.ts +1 -1
  104. package/dist/functions/log.lua +9 -9
  105. package/dist/functions/{npc.d.ts → npcs.d.ts} +24 -2
  106. package/dist/functions/npcs.d.ts.map +1 -0
  107. package/dist/functions/{npc.lua → npcs.lua} +44 -9
  108. package/dist/functions/pickups.d.ts +4 -119
  109. package/dist/functions/pickups.d.ts.map +1 -1
  110. package/dist/functions/pickups.lua +10 -439
  111. package/dist/functions/pickupsSpecific.d.ts +229 -0
  112. package/dist/functions/pickupsSpecific.d.ts.map +1 -0
  113. package/dist/functions/pickupsSpecific.lua +560 -0
  114. package/dist/functions/playerHealth.lua +6 -6
  115. package/dist/functions/{player.d.ts → players.d.ts} +1 -1
  116. package/dist/functions/players.d.ts.map +1 -0
  117. package/dist/functions/{player.lua → players.lua} +0 -0
  118. package/dist/functions/pocketItems.lua +2 -2
  119. package/dist/functions/positionVelocity.lua +6 -6
  120. package/dist/functions/pressurePlate.d.ts +10 -0
  121. package/dist/functions/pressurePlate.d.ts.map +1 -0
  122. package/dist/functions/pressurePlate.lua +29 -0
  123. package/dist/functions/revive.lua +7 -7
  124. package/dist/functions/rooms.lua +2 -2
  125. package/dist/functions/saveFile.lua +3 -3
  126. package/dist/functions/spawnCollectible.lua +4 -4
  127. package/dist/functions/{sprite.d.ts → sprites.d.ts} +1 -1
  128. package/dist/functions/sprites.d.ts.map +1 -0
  129. package/dist/functions/{sprite.lua → sprites.lua} +0 -0
  130. package/dist/functions/table.d.ts +1 -1
  131. package/dist/functions/table.lua +1 -1
  132. package/dist/functions/transformations.lua +2 -2
  133. package/dist/functions/trinketGive.lua +2 -2
  134. package/dist/functions/trinkets.lua +6 -6
  135. package/dist/functions/utils.d.ts +7 -0
  136. package/dist/functions/utils.d.ts.map +1 -1
  137. package/dist/functions/utils.lua +35 -22
  138. package/dist/index.d.ts +10 -8
  139. package/dist/index.d.ts.map +1 -1
  140. package/dist/index.lua +26 -10
  141. package/dist/types/AnyGridEntity.d.ts +10 -0
  142. package/dist/types/AnyGridEntity.d.ts.map +1 -0
  143. package/dist/types/AnyGridEntity.lua +2 -0
  144. package/package.json +2 -2
  145. package/src/callbacks/customRevive.ts +2 -2
  146. package/src/callbacks/postCursedTeleport.ts +2 -2
  147. package/src/callbacks/postCustomDoorEnter.ts +3 -3
  148. package/src/callbacks/postDiceRoomActivated.ts +1 -1
  149. package/src/callbacks/postFlip.ts +1 -1
  150. package/src/callbacks/postGridEntity.ts +1 -1
  151. package/src/callbacks/postGridEntityCollision.ts +1 -1
  152. package/src/callbacks/postGridEntityRender.ts +1 -1
  153. package/src/callbacks/postNewRoomEarly.ts +9 -3
  154. package/src/callbacks/postPickupCollect.ts +1 -1
  155. package/src/callbacks/postPitRender.ts +1 -1
  156. package/src/callbacks/postPitUpdate.ts +1 -1
  157. package/src/callbacks/postPlayerCollectible.ts +2 -2
  158. package/src/callbacks/postPoopRender.ts +1 -1
  159. package/src/callbacks/postPoopUpdate.ts +1 -1
  160. package/src/callbacks/postPressurePlateRender.ts +1 -1
  161. package/src/callbacks/postPressurePlateUpdate.ts +1 -1
  162. package/src/callbacks/postPurchase.ts +1 -1
  163. package/src/callbacks/postRockRender.ts +1 -1
  164. package/src/callbacks/postRockUpdate.ts +1 -1
  165. package/src/callbacks/postSacrifice.ts +1 -1
  166. package/src/callbacks/postSlotInitUpdate.ts +1 -1
  167. package/src/callbacks/postSlotRender.ts +1 -1
  168. package/src/callbacks/postSpikesRender.ts +1 -1
  169. package/src/callbacks/postSpikesUpdate.ts +1 -1
  170. package/src/callbacks/postTNTRender.ts +1 -1
  171. package/src/callbacks/postTNTUpdate.ts +1 -1
  172. package/src/callbacks/preBerserkDeath.ts +1 -1
  173. package/src/callbacks/preNewLevel.ts +1 -1
  174. package/src/callbacks/subscriptions/postDoorRender.ts +7 -5
  175. package/src/callbacks/subscriptions/postDoorUpdate.ts +7 -5
  176. package/src/callbacks/subscriptions/postPitRender.ts +6 -7
  177. package/src/callbacks/subscriptions/postPitUpdate.ts +6 -7
  178. package/src/callbacks/subscriptions/postPoopRender.ts +7 -5
  179. package/src/callbacks/subscriptions/postPoopUpdate.ts +7 -5
  180. package/src/callbacks/subscriptions/postPressurePlateRender.ts +7 -5
  181. package/src/callbacks/subscriptions/postPressurePlateUpdate.ts +7 -5
  182. package/src/enums/private/SerializationBrand.ts +0 -4
  183. package/src/features/characterStats.ts +1 -1
  184. package/src/features/collectibleItemPoolType.ts +1 -1
  185. package/src/features/customGridEntity.ts +6 -3
  186. package/src/features/customStage/backdrop.ts +1 -1
  187. package/src/features/customStage/{gridEntities.ts → customStageGridEntities.ts} +3 -3
  188. package/src/features/customStage/{util.ts → customStageUtils.ts} +0 -0
  189. package/src/features/customStage/exports.ts +2 -2
  190. package/src/features/customStage/init.ts +1 -1
  191. package/src/features/customStage/shadows.ts +1 -1
  192. package/src/features/customStage/versusScreen.ts +2 -2
  193. package/src/features/debugDisplay/v.ts +2 -2
  194. package/src/features/deployJSONRoom.ts +11 -7
  195. package/src/features/extraConsoleCommands/commandsSubroutines.ts +2 -2
  196. package/src/features/extraConsoleCommands/listCommands.ts +13 -9
  197. package/src/features/pause.ts +1 -1
  198. package/src/features/persistentEntities.ts +2 -2
  199. package/src/features/preventCollectibleRotation.ts +1 -1
  200. package/src/features/saveDataManager/exports.ts +7 -4
  201. package/src/features/sirenHelpers.ts +1 -1
  202. package/src/functions/ambush.ts +2 -2
  203. package/src/functions/array.ts +1 -1
  204. package/src/functions/bitwise.ts +2 -2
  205. package/src/functions/{boss.ts → bosses.ts} +29 -21
  206. package/src/functions/collectibleTag.ts +1 -1
  207. package/src/functions/collectibles.ts +2 -2
  208. package/src/functions/deepCopy.ts +98 -19
  209. package/src/functions/deepCopyTests.ts +6 -4
  210. package/src/functions/{entity.ts → entities.ts} +23 -21
  211. package/src/functions/{entitySpecific.ts → entitiesSpecific.ts} +170 -99
  212. package/src/functions/familiars.ts +1 -1
  213. package/src/functions/{gridEntity.ts → gridEntities.ts} +110 -34
  214. package/src/functions/gridEntitiesSpecific.ts +490 -0
  215. package/src/functions/log.ts +6 -6
  216. package/src/functions/{npc.ts → npcs.ts} +42 -11
  217. package/src/functions/pickups.ts +8 -475
  218. package/src/functions/pickupsSpecific.ts +613 -0
  219. package/src/functions/playerHealth.ts +1 -1
  220. package/src/functions/{player.ts → players.ts} +0 -0
  221. package/src/functions/pocketItems.ts +1 -1
  222. package/src/functions/positionVelocity.ts +3 -3
  223. package/src/functions/pressurePlate.ts +29 -0
  224. package/src/functions/revive.ts +2 -2
  225. package/src/functions/rooms.ts +1 -1
  226. package/src/functions/saveFile.ts +1 -1
  227. package/src/functions/spawnCollectible.ts +2 -2
  228. package/src/functions/{sprite.ts → sprites.ts} +0 -0
  229. package/src/functions/table.ts +1 -1
  230. package/src/functions/transformations.ts +1 -1
  231. package/src/functions/trinketGive.ts +4 -4
  232. package/src/functions/trinkets.ts +3 -3
  233. package/src/functions/tstlClass.ts +1 -1
  234. package/src/functions/ui.ts +3 -3
  235. package/src/functions/utils.ts +32 -13
  236. package/src/index.ts +10 -8
  237. package/src/types/AnyGridEntity.ts +9 -0
  238. package/dist/features/customStage/gridEntities.d.ts.map +0 -1
  239. package/dist/features/customStage/util.d.ts.map +0 -1
  240. package/dist/functions/boss.d.ts.map +0 -1
  241. package/dist/functions/entity.d.ts.map +0 -1
  242. package/dist/functions/entitySpecific.d.ts.map +0 -1
  243. package/dist/functions/gridEntity.d.ts.map +0 -1
  244. package/dist/functions/gridEntitySpecific.d.ts +0 -29
  245. package/dist/functions/gridEntitySpecific.d.ts.map +0 -1
  246. package/dist/functions/gridEntitySpecific.lua +0 -114
  247. package/dist/functions/npc.d.ts.map +0 -1
  248. package/dist/functions/player.d.ts.map +0 -1
  249. package/dist/functions/sprite.d.ts.map +0 -1
  250. package/src/functions/gridEntitySpecific.ts +0 -143
@@ -0,0 +1,490 @@
1
+ import {
2
+ DoorVariant,
3
+ GridEntityType,
4
+ PitVariant,
5
+ PoopGridEntityVariant,
6
+ PressurePlateVariant,
7
+ RockVariant,
8
+ } from "isaac-typescript-definitions";
9
+ import {
10
+ getGridEntities,
11
+ removeGridEntities,
12
+ spawnGridEntityWithVariant,
13
+ } from "./gridEntities";
14
+
15
+ // The `getDoors` function is not located here because doors are collected via the `Room.GetDoor`
16
+ // method instead, which is faster.
17
+
18
+ /**
19
+ * Helper function to get all of the `GridEntityPit` in the room.
20
+ *
21
+ * @param pitVariant Optional. If specified, will only get the pits that match the variant. Default
22
+ * is -1, which matches every variant.
23
+ */
24
+ export function getPits(pitVariant: PitVariant = -1): GridEntityPit[] {
25
+ const gridEntities = getGridEntities();
26
+
27
+ const pits: GridEntityPit[] = [];
28
+ for (const gridEntity of gridEntities) {
29
+ const pit = gridEntity.ToPit();
30
+ if (pit !== undefined) {
31
+ const gridEntityVariant = pit.GetVariant();
32
+ if ((pitVariant as int) === -1 || pitVariant === gridEntityVariant) {
33
+ pits.push(pit);
34
+ }
35
+ }
36
+ }
37
+
38
+ return pits;
39
+ }
40
+
41
+ /**
42
+ * Helper function to get all of the `GridEntityPoop` in the room.
43
+ *
44
+ * @param poopVariant Optional. If specified, will only get the poops that match the variant.
45
+ * Default is -1, which matches every variant.
46
+ */
47
+ export function getPoops(
48
+ poopVariant: PoopGridEntityVariant = -1,
49
+ ): GridEntityPoop[] {
50
+ const gridEntities = getGridEntities();
51
+
52
+ const poops: GridEntityPoop[] = [];
53
+ for (const gridEntity of gridEntities) {
54
+ const poop = gridEntity.ToPoop();
55
+ if (poop !== undefined) {
56
+ const gridEntityVariant = poop.GetVariant();
57
+ if ((poopVariant as int) === -1 || poopVariant === gridEntityVariant) {
58
+ poops.push(poop);
59
+ }
60
+ }
61
+ }
62
+
63
+ return poops;
64
+ }
65
+
66
+ /**
67
+ * Helper function to get all of the `GridEntityPressurePlate` in the room.
68
+ *
69
+ * @param pressurePlateVariant Optional. If specified, will only get the pressure plates that match
70
+ * the variant. Default is -1, which matches every variant.
71
+ */
72
+ export function getPressurePlates(
73
+ pressurePlateVariant: PressurePlateVariant = -1,
74
+ ): GridEntityPressurePlate[] {
75
+ const gridEntities = getGridEntities();
76
+
77
+ const pressurePlates: GridEntityPressurePlate[] = [];
78
+ for (const gridEntity of gridEntities) {
79
+ const pressurePlate = gridEntity.ToPressurePlate();
80
+ if (pressurePlate !== undefined) {
81
+ const gridEntityVariant = pressurePlate.GetVariant();
82
+ if (
83
+ (pressurePlateVariant as int) === -1 ||
84
+ pressurePlateVariant === gridEntityVariant
85
+ ) {
86
+ pressurePlates.push(pressurePlate);
87
+ }
88
+ }
89
+ }
90
+
91
+ return pressurePlates;
92
+ }
93
+
94
+ /**
95
+ * Helper function to get all of the `GridEntityRock` in the room.
96
+ *
97
+ * @param variant Optional. If specified, will only get the rocks that match the variant. Default is
98
+ * -1, which matches every variant. Note that this is not the same thing as the
99
+ * `RockVariant` enum, since that only applies to `GridEntityType.ROCK`, and other
100
+ * types of grid entities can be the `GridEntityRock` class.
101
+ */
102
+ export function getRocks(variant = -1): GridEntityRock[] {
103
+ const gridEntities = getGridEntities();
104
+
105
+ const rocks: GridEntityRock[] = [];
106
+ for (const gridEntity of gridEntities) {
107
+ const rock = gridEntity.ToRock();
108
+ if (rock !== undefined) {
109
+ const gridEntityVariant = rock.GetVariant();
110
+ if (variant === -1 || variant === gridEntityVariant) {
111
+ rocks.push(rock);
112
+ }
113
+ }
114
+ }
115
+
116
+ return rocks;
117
+ }
118
+
119
+ /** Helper function to get all of the `GridEntitySpikes` in the room. */
120
+ export function getSpikes(variant = -1): GridEntitySpikes[] {
121
+ const gridEntities = getGridEntities();
122
+
123
+ const spikes: GridEntitySpikes[] = [];
124
+ for (const gridEntity of gridEntities) {
125
+ const spike = gridEntity.ToSpikes();
126
+ if (spike !== undefined) {
127
+ const gridEntityVariant = spike.GetVariant();
128
+ if (variant === -1 || variant === gridEntityVariant) {
129
+ spikes.push(spike);
130
+ }
131
+ }
132
+ }
133
+
134
+ return spikes;
135
+ }
136
+
137
+ /** Helper function to get all of the `GridEntityTNT` in the room. */
138
+ export function getTNT(variant = -1): GridEntityTNT[] {
139
+ const gridEntities = getGridEntities();
140
+
141
+ const tntArray: GridEntityTNT[] = [];
142
+ for (const gridEntity of gridEntities) {
143
+ const tnt = gridEntity.ToTNT();
144
+ if (tnt !== undefined) {
145
+ const gridEntityVariant = tnt.GetVariant();
146
+ if (variant === -1 || variant === gridEntityVariant) {
147
+ tntArray.push(tnt);
148
+ }
149
+ }
150
+ }
151
+
152
+ return tntArray;
153
+ }
154
+
155
+ // The `removeAllDoors` function is not located here because doors are removed via the
156
+ // `Room.RemoveDoor` method instead.
157
+
158
+ /**
159
+ * Helper function to remove all of the `GridEntityPit` in the room.
160
+ *
161
+ * @param pitVariant Optional. If specified, will only remove the pits that match this variant.
162
+ * Default is -1, which matches every variant.
163
+ * @param updateRoom Optional. Whether or not to update the room after the pits are removed. Default
164
+ * is false. For more information, see the description of the `removeGridEntities`
165
+ * helper function.
166
+ * @param cap Optional. If specified, will only remove the given amount of pits.
167
+ * @returns The pits that were removed.
168
+ */
169
+ export function removeAllPits(
170
+ pitVariant: PitVariant = -1,
171
+ updateRoom = false,
172
+ cap?: int,
173
+ ): GridEntityPit[] {
174
+ const pits = getPits(pitVariant);
175
+ return removeGridEntities(pits, updateRoom, cap);
176
+ }
177
+
178
+ /**
179
+ * Helper function to remove all of the `GridEntityPoop` in the room.
180
+ *
181
+ * Note that poops can either be an entity or a grid entity, depending on the situation. This
182
+ * function will only remove the grid entity poops.
183
+ *
184
+ * @param poopVariant Optional. If specified, will only remove the poops that match this variant.
185
+ * Default is -1, which matches every variant.
186
+ * @param updateRoom Optional. Whether or not to update the room after the poops are removed.
187
+ * Default is false. For more information, see the description of the
188
+ * `removeGridEntities` helper function.
189
+ * @param cap Optional. If specified, will only remove the given amount of poops.
190
+ * @returns The poops that were removed.
191
+ */
192
+ export function removeAllPoops(
193
+ poopVariant: PoopGridEntityVariant = -1,
194
+ updateRoom = false,
195
+ cap?: int,
196
+ ): GridEntityPoop[] {
197
+ const poops = getPoops(poopVariant);
198
+ return removeGridEntities(poops, updateRoom, cap);
199
+ }
200
+
201
+ /**
202
+ * Helper function to remove all of the `GridEntityPressurePlate` in the room.
203
+ *
204
+ * @param pressurePlateVariant Optional. If specified, will only remove the pressure plates that
205
+ * match this variant. Default is -1, which matches every variant.
206
+ * @param updateRoom Optional. Whether or not to update the room after the pressure plates are
207
+ * removed. Default is false. For more information, see the description of the
208
+ * `removeGridEntities` helper function.
209
+ * @param cap Optional. If specified, will only remove the given amount of pressure plates.
210
+ * @returns The pressure plates that were removed.
211
+ */
212
+ export function removeAllPressurePlates(
213
+ pressurePlateVariant: PressurePlateVariant = -1,
214
+ updateRoom = false,
215
+ cap?: int,
216
+ ): GridEntityPressurePlate[] {
217
+ const pressurePlates = getPressurePlates(pressurePlateVariant);
218
+ return removeGridEntities(pressurePlates, updateRoom, cap);
219
+ }
220
+
221
+ /**
222
+ * Helper function to remove all of the `GridEntityRock` in the room.
223
+ *
224
+ * @param variant Optional. If specified, will only remove the rocks that match this variant.
225
+ * Default is -1, which matches every variant. Note that this is not the same thing
226
+ * as the `RockVariant` enum, since that only applies to `GridEntityType.ROCK`, and
227
+ * other types of grid entities can be the `GridEntityRock` class.
228
+ * @param updateRoom Optional. Whether or not to update the room after the rocks are removed.
229
+ * Default is false. For more information, see the description of the
230
+ * `removeGridEntities` helper function.
231
+ * @param cap Optional. If specified, will only remove the given amount of rocks.
232
+ * @returns The rocks that were removed.
233
+ */
234
+ export function removeAllRocks(
235
+ variant = -1,
236
+ updateRoom = false,
237
+ cap?: int,
238
+ ): GridEntityRock[] {
239
+ const rocks = getRocks(variant);
240
+ return removeGridEntities(rocks, updateRoom, cap);
241
+ }
242
+
243
+ /**
244
+ * Helper function to remove all of the `GridEntitySpikes` in the room.
245
+ *
246
+ * @param variant Optional. If specified, will only remove the spikes that match this variant.
247
+ * Default is -1, which matches every variant.
248
+ * @param updateRoom Optional. Whether or not to update the room after the spikes are removed.
249
+ * Default is false. For more information, see the description of the
250
+ * `removeGridEntities` helper function.
251
+ * @param cap Optional. If specified, will only remove the given amount of spikes.
252
+ * @returns The spikes that were removed.
253
+ */
254
+ export function removeAllSpikes(
255
+ variant = -1,
256
+ updateRoom = false,
257
+ cap?: int,
258
+ ): GridEntitySpikes[] {
259
+ const spikes = getSpikes(variant);
260
+ return removeGridEntities(spikes, updateRoom, cap);
261
+ }
262
+
263
+ /**
264
+ * Helper function to remove all of the `GridEntityTNT` in the room.
265
+ *
266
+ * @param variant Optional. If specified, will only remove the TNTs that match this variant. Default
267
+ * is -1, which matches every variant.
268
+ * @param updateRoom Optional. Whether or not to update the room after the TNTs are removed. Default
269
+ * is false. For more information, see the description of the `removeGridEntities`
270
+ * helper function.
271
+ * @param cap Optional. If specified, will only remove the given amount of TNTs.
272
+ * @returns The TNTs that were removed.
273
+ */
274
+ export function removeAllTNT(
275
+ variant = -1,
276
+ updateRoom = false,
277
+ cap?: int,
278
+ ): GridEntityTNT[] {
279
+ const tnt = getTNT(variant);
280
+ return removeGridEntities(tnt, updateRoom, cap);
281
+ }
282
+
283
+ /** Helper function to spawn a `GridEntityType.DOOR` (16). */
284
+ export function spawnDoor(
285
+ gridIndexOrPosition: int | Vector,
286
+ ): GridEntityDoor | undefined {
287
+ return spawnDoorWithVariant(DoorVariant.UNSPECIFIED, gridIndexOrPosition);
288
+ }
289
+
290
+ /** Helper function to spawn a `GridEntityType.DOOR` (16) with a specific variant. */
291
+ export function spawnDoorWithVariant(
292
+ doorVariant: DoorVariant,
293
+ gridIndexOrPosition: int | Vector,
294
+ ): GridEntityDoor | undefined {
295
+ const gridEntity = spawnGridEntityWithVariant(
296
+ GridEntityType.DOOR,
297
+ doorVariant,
298
+ gridIndexOrPosition,
299
+ );
300
+ if (gridEntity === undefined) {
301
+ return gridEntity;
302
+ }
303
+
304
+ const door = gridEntity.ToDoor();
305
+ if (door === undefined) {
306
+ error("Failed to spawn a door.");
307
+ }
308
+
309
+ return door;
310
+ }
311
+
312
+ /** Helper function to spawn a `GridEntityType.PIT` (7). */
313
+ export function spawnPit(
314
+ gridIndexOrPosition: int | Vector,
315
+ ): GridEntityPit | undefined {
316
+ return spawnPitWithVariant(PitVariant.NORMAL, gridIndexOrPosition);
317
+ }
318
+
319
+ /** Helper function to spawn a `GridEntityType.PIT` (7) with a specific variant. */
320
+ export function spawnPitWithVariant(
321
+ pitVariant: PitVariant,
322
+ gridIndexOrPosition: int | Vector,
323
+ ): GridEntityPit | undefined {
324
+ const gridEntity = spawnGridEntityWithVariant(
325
+ GridEntityType.PIT,
326
+ pitVariant,
327
+ gridIndexOrPosition,
328
+ );
329
+ if (gridEntity === undefined) {
330
+ return gridEntity;
331
+ }
332
+
333
+ const pit = gridEntity.ToPit();
334
+ if (pit === undefined) {
335
+ error("Failed to spawn a pit.");
336
+ }
337
+
338
+ return pit;
339
+ }
340
+
341
+ /** Helper function to spawn a `GridEntityType.POOP` (14). */
342
+ export function spawnPoop(
343
+ gridIndexOrPosition: int | Vector,
344
+ ): GridEntityPoop | undefined {
345
+ return spawnPoopWithVariant(
346
+ PoopGridEntityVariant.NORMAL,
347
+ gridIndexOrPosition,
348
+ );
349
+ }
350
+
351
+ /** Helper function to spawn a `GridEntityType.POOP` (14) with a specific variant. */
352
+ export function spawnPoopWithVariant(
353
+ poopVariant: PoopGridEntityVariant,
354
+ gridIndexOrPosition: int | Vector,
355
+ ): GridEntityPoop | undefined {
356
+ const gridEntity = spawnGridEntityWithVariant(
357
+ GridEntityType.POOP,
358
+ poopVariant,
359
+ gridIndexOrPosition,
360
+ );
361
+ if (gridEntity === undefined) {
362
+ return gridEntity;
363
+ }
364
+
365
+ const poop = gridEntity.ToPoop();
366
+ if (poop === undefined) {
367
+ error("Failed to spawn a poop.");
368
+ }
369
+
370
+ return poop;
371
+ }
372
+
373
+ /** Helper function to spawn a `GridEntityType.PRESSURE_PLATE` (20). */
374
+ export function spawnPressurePlate(
375
+ gridIndexOrPosition: int | Vector,
376
+ ): GridEntityPressurePlate | undefined {
377
+ return spawnPressurePlateWithVariant(
378
+ PressurePlateVariant.PRESSURE_PLATE,
379
+ gridIndexOrPosition,
380
+ );
381
+ }
382
+
383
+ /** Helper function to spawn a `GridEntityType.PRESSURE_PLATE` (20) with a specific variant. */
384
+ export function spawnPressurePlateWithVariant(
385
+ pressurePlateVariant: PressurePlateVariant,
386
+ gridIndexOrPosition: int | Vector,
387
+ ): GridEntityPressurePlate | undefined {
388
+ const gridEntity = spawnGridEntityWithVariant(
389
+ GridEntityType.PRESSURE_PLATE,
390
+ pressurePlateVariant,
391
+ gridIndexOrPosition,
392
+ );
393
+ if (gridEntity === undefined) {
394
+ return gridEntity;
395
+ }
396
+
397
+ const pressurePlate = gridEntity.ToPressurePlate();
398
+ if (pressurePlate === undefined) {
399
+ error("Failed to spawn a pressure plate.");
400
+ }
401
+
402
+ return pressurePlate;
403
+ }
404
+
405
+ /** Helper function to spawn a `GridEntityType.ROCK` (2). */
406
+ export function spawnRock(
407
+ gridIndexOrPosition: int | Vector,
408
+ ): GridEntityRock | undefined {
409
+ return spawnRockWithVariant(RockVariant.NORMAL, gridIndexOrPosition);
410
+ }
411
+
412
+ /** Helper function to spawn a `GridEntityType.ROCK` (2) with a specific variant. */
413
+ export function spawnRockWithVariant(
414
+ rockVariant: RockVariant,
415
+ gridIndexOrPosition: int | Vector,
416
+ ): GridEntityRock | undefined {
417
+ const gridEntity = spawnGridEntityWithVariant(
418
+ GridEntityType.ROCK,
419
+ rockVariant,
420
+ gridIndexOrPosition,
421
+ );
422
+ if (gridEntity === undefined) {
423
+ return gridEntity;
424
+ }
425
+
426
+ const rock = gridEntity.ToRock();
427
+ if (rock === undefined) {
428
+ error("Failed to spawn a rock.");
429
+ }
430
+
431
+ return rock;
432
+ }
433
+
434
+ /** Helper function to spawn a `GridEntityType.SPIKES` (8). */
435
+ export function spawnSpikes(
436
+ gridIndexOrPosition: int | Vector,
437
+ ): GridEntitySpikes | undefined {
438
+ return spawnSpikesWithVariant(0, gridIndexOrPosition);
439
+ }
440
+
441
+ /** Helper function to spawn a `GridEntityType.SPIKES` (8) with a specific variant. */
442
+ export function spawnSpikesWithVariant(
443
+ variant: int,
444
+ gridIndexOrPosition: int | Vector,
445
+ ): GridEntitySpikes | undefined {
446
+ const gridEntity = spawnGridEntityWithVariant(
447
+ GridEntityType.SPIKES,
448
+ variant,
449
+ gridIndexOrPosition,
450
+ );
451
+ if (gridEntity === undefined) {
452
+ return gridEntity;
453
+ }
454
+
455
+ const spikes = gridEntity.ToSpikes();
456
+ if (spikes === undefined) {
457
+ error("Failed to spawn spikes.");
458
+ }
459
+
460
+ return spikes;
461
+ }
462
+
463
+ /** Helper function to spawn a `GridEntityType.TNT` (12). */
464
+ export function spawnTNT(
465
+ gridIndexOrPosition: int | Vector,
466
+ ): GridEntityTNT | undefined {
467
+ return spawnTNTWithVariant(0, gridIndexOrPosition);
468
+ }
469
+
470
+ /** Helper function to spawn a `GridEntityType.TNT` (12) with a specific variant. */
471
+ export function spawnTNTWithVariant(
472
+ variant: int,
473
+ gridIndexOrPosition: int | Vector,
474
+ ): GridEntityTNT | undefined {
475
+ const gridEntity = spawnGridEntityWithVariant(
476
+ GridEntityType.TNT,
477
+ variant,
478
+ gridIndexOrPosition,
479
+ );
480
+ if (gridEntity === undefined) {
481
+ return gridEntity;
482
+ }
483
+
484
+ const tnt = gridEntity.ToTNT();
485
+ if (tnt === undefined) {
486
+ error("Failed to spawn TNT.");
487
+ }
488
+
489
+ return tnt;
490
+ }
@@ -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 } 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";
@@ -228,7 +228,7 @@ export function logEntities(
228
228
  msg += ` - CanShutDoors: ${npc.CanShutDoors}\n`;
229
229
  }
230
230
 
231
- numMatchedEntities += 1;
231
+ numMatchedEntities++;
232
232
  });
233
233
 
234
234
  if (numMatchedEntities === 0) {
@@ -404,7 +404,7 @@ export function logGridEntities(
404
404
  msg += ` - TargetRoomType: ${door.TargetRoomType}\n`;
405
405
  }
406
406
 
407
- numMatchedEntities += 1;
407
+ numMatchedEntities++;
408
408
  });
409
409
 
410
410
  if (numMatchedEntities === 0) {
@@ -572,7 +572,7 @@ export function logSounds(this: void): void {
572
572
  * recursively call itself if it counters a table within a table.
573
573
  *
574
574
  * This function will only work on tables that have string keys (because it logs the keys in order,
575
- * instead of randomly). It will throw a runtime error if it encounters a non-string key.
575
+ * instead of randomly). It will throw a run-time error if it encounters a non-string key.
576
576
  */
577
577
  export function logTable(
578
578
  this: void,
@@ -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
+ }