isaacscript-common 8.8.1 → 8.9.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.
@@ -8,7 +8,17 @@
8
8
  import { LevelStage, StageType } from "isaac-typescript-definitions";
9
9
  export declare const DEFAULT_BASE_STAGE = LevelStage.BASEMENT_2;
10
10
  export declare const DEFAULT_BASE_STAGE_TYPE = StageType.ORIGINAL;
11
- export declare const INVALID_STAGE_VALUE: LevelStage;
11
+ /**
12
+ * Equal to -1. Setting the stage to an invalid stage value is useful in that it prevents backdrops
13
+ * and shadows from loading.
14
+ */
15
+ export declare const CUSTOM_FLOOR_STAGE: LevelStage;
16
+ /**
17
+ * We must use `StageType.WRATH_OF_THE_LAMB` instead of `StageType.ORIGINAL` or else the walls will
18
+ * not render properly. DeadInfinity suspects that this might be because it is trying to use the
19
+ * Dark Room's backdrop (instead of The Chest).
20
+ */
21
+ export declare const CUSTOM_FLOOR_STAGE_TYPE = StageType.WRATH_OF_THE_LAMB;
12
22
  /**
13
23
  * Helper function to warp to a custom stage/level.
14
24
  *
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/exports.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,OAAO,EAEL,UAAU,EAGV,SAAS,EACV,MAAM,8BAA8B,CAAC;AAoBtC,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AACxD,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAE1D,eAAO,MAAM,mBAAmB,YAAmB,CAAC;AAEpD;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,UAAU,UAAO,EACjB,OAAO,UAAQ,GACd,IAAI,CAwDN;AAkGD;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
1
+ {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/exports.ts"],"names":[],"mappings":"AACA;;;;;;GAMG;AAEH,OAAO,EAEL,UAAU,EAGV,SAAS,EACV,MAAM,8BAA8B,CAAC;AAoBtC,eAAO,MAAM,kBAAkB,wBAAwB,CAAC;AACxD,eAAO,MAAM,uBAAuB,qBAAqB,CAAC;AAE1D;;;GAGG;AACH,eAAO,MAAM,kBAAkB,YAAmB,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,8BAA8B,CAAC;AAEnE;;;;;;;;;;;;GAYG;AACH,wBAAgB,cAAc,CAC5B,IAAI,EAAE,MAAM,EACZ,UAAU,UAAO,EACjB,OAAO,UAAQ,GACd,IAAI,CAqDN;AAkGD;;;GAGG;AACH,wBAAgB,kBAAkB,IAAI,IAAI,CAEzC"}
@@ -103,7 +103,13 @@ function setStageRoomsData(self, customStage, rng, verbose)
103
103
  end
104
104
  ____exports.DEFAULT_BASE_STAGE = LevelStage.BASEMENT_2
105
105
  ____exports.DEFAULT_BASE_STAGE_TYPE = StageType.ORIGINAL
106
- ____exports.INVALID_STAGE_VALUE = -1
106
+ --- Equal to -1. Setting the stage to an invalid stage value is useful in that it prevents backdrops
107
+ -- and shadows from loading.
108
+ ____exports.CUSTOM_FLOOR_STAGE = -1
109
+ --- We must use `StageType.WRATH_OF_THE_LAMB` instead of `StageType.ORIGINAL` or else the walls will
110
+ -- not render properly. DeadInfinity suspects that this might be because it is trying to use the
111
+ -- Dark Room's backdrop (instead of The Chest).
112
+ ____exports.CUSTOM_FLOOR_STAGE_TYPE = StageType.WRATH_OF_THE_LAMB
107
113
  --- Helper function to warp to a custom stage/level.
108
114
  --
109
115
  -- Custom stages/levels must first be defined in the "tsconfig.json" file. See the documentation for
@@ -133,7 +139,7 @@ function ____exports.setCustomStage(self, name, firstFloor, verbose)
133
139
  local rng = newRNG(nil, startSeed)
134
140
  v.run.currentCustomStage = customStage
135
141
  v.run.firstFloor = firstFloor
136
- if stage == ____exports.INVALID_STAGE_VALUE then
142
+ if stage == ____exports.CUSTOM_FLOOR_STAGE then
137
143
  level:SetStage(LevelStage.BASEMENT_1, StageType.ORIGINAL)
138
144
  end
139
145
  local baseStage = customStage.baseStage == nil and ____exports.DEFAULT_BASE_STAGE or customStage.baseStage
@@ -144,8 +150,8 @@ function ____exports.setCustomStage(self, name, firstFloor, verbose)
144
150
  local reseed = asNumber(nil, stage) >= baseStage
145
151
  setStage(nil, baseStage, baseStageType, reseed)
146
152
  setStageRoomsData(nil, customStage, rng, verbose)
147
- local targetStage = ____exports.INVALID_STAGE_VALUE
148
- local targetStageType = StageType.WRATH_OF_THE_LAMB
153
+ local targetStage = ____exports.CUSTOM_FLOOR_STAGE
154
+ local targetStageType = ____exports.CUSTOM_FLOOR_STAGE_TYPE
149
155
  level:SetStage(targetStage, targetStageType)
150
156
  reorderedCallbacksSetStageInternal(nil, targetStage, targetStageType)
151
157
  end
@@ -1 +1 @@
1
- {"version":3,"file":"versusScreen.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/versusScreen.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AA+EnE;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAavC;AAED,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAoFxE;AAmGD,wBAAgB,sBAAsB,IAAI,IAAI,CAkC7C"}
1
+ {"version":3,"file":"versusScreen.d.ts","sourceRoot":"","sources":["../../../src/features/customStage/versusScreen.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,WAAW,EAAE,MAAM,sCAAsC,CAAC;AAgFnE;;;;GAIG;AACH,wBAAgB,gBAAgB,IAAI,IAAI,CAavC;AAED,wBAAgB,yBAAyB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAoFxE;AAmGD,wBAAgB,sBAAsB,IAAI,IAAI,CAkC7C"}
@@ -9,7 +9,6 @@ local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
9
9
  local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
10
10
  local SoundEffect = ____isaac_2Dtypescript_2Ddefinitions.SoundEffect
11
11
  local StageID = ____isaac_2Dtypescript_2Ddefinitions.StageID
12
- local StageType = ____isaac_2Dtypescript_2Ddefinitions.StageType
13
12
  local ____cachedClasses = require("core.cachedClasses")
14
13
  local game = ____cachedClasses.game
15
14
  local sfxManager = ____cachedClasses.sfxManager
@@ -47,9 +46,10 @@ local ____customStageConstants = require("features.customStage.customStageConsta
47
46
  local CUSTOM_STAGE_FEATURE_NAME = ____customStageConstants.CUSTOM_STAGE_FEATURE_NAME
48
47
  local ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH = ____customStageConstants.ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH
49
48
  local ____exports = require("features.customStage.exports")
49
+ local CUSTOM_FLOOR_STAGE = ____exports.CUSTOM_FLOOR_STAGE
50
+ local CUSTOM_FLOOR_STAGE_TYPE = ____exports.CUSTOM_FLOOR_STAGE_TYPE
50
51
  local DEFAULT_BASE_STAGE = ____exports.DEFAULT_BASE_STAGE
51
52
  local DEFAULT_BASE_STAGE_TYPE = ____exports.DEFAULT_BASE_STAGE_TYPE
52
- local INVALID_STAGE_VALUE = ____exports.INVALID_STAGE_VALUE
53
53
  local ____v = require("features.customStage.v")
54
54
  local v = ____v.default
55
55
  function willVanillaVersusScreenPlay(self)
@@ -172,7 +172,7 @@ function ____exports.playVersusScreenAnimation(self, customStage)
172
172
  nil,
173
173
  function()
174
174
  local futureLevel = game:GetLevel()
175
- futureLevel:SetStage(INVALID_STAGE_VALUE, StageType.ORIGINAL)
175
+ futureLevel:SetStage(CUSTOM_FLOOR_STAGE, CUSTOM_FLOOR_STAGE_TYPE)
176
176
  end
177
177
  )
178
178
  return
@@ -1,4 +1,4 @@
1
- import { CrawlSpaceVariant, GridEntityType, GridEntityXMLType, TrapdoorVariant } from "isaac-typescript-definitions";
1
+ import { GridEntityType, GridEntityXMLType } from "isaac-typescript-definitions";
2
2
  import { AnyGridEntity } from "../types/AnyGridEntity";
3
3
  /**
4
4
  * Helper function to convert the grid entity type found in a room XML file to the corresponding
@@ -20,13 +20,6 @@ export declare function getAllGridIndexes(): int[];
20
20
  * not have collision yet in that callback.
21
21
  */
22
22
  export declare function getCollidingEntitiesWithGridEntity(gridEntity: GridEntity): Entity[];
23
- /**
24
- * Helper function to get all of the crawl spaces in the room.
25
- *
26
- * @param crawlSpaceVariant Optional. If specified, will only get the crawl spaces that match the
27
- * variant. Default is -1, which matches every variant.
28
- */
29
- export declare function getCrawlSpaces(crawlSpaceVariant?: CrawlSpaceVariant): GridEntity[];
30
23
  /**
31
24
  * Helper function to get every grid entity in the current room.
32
25
  *
@@ -88,11 +81,6 @@ export declare function getTopLeftWall(): GridEntity | undefined;
88
81
  * room shape is.)
89
82
  */
90
83
  export declare function getTopLeftWallGridIndex(): int;
91
- /**
92
- * Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` in the room.
93
- * Specify a specific trapdoor variant to select only trapdoors of that variant.
94
- */
95
- export declare function getTrapdoors(trapdoorVariant?: TrapdoorVariant): GridEntity[];
96
84
  /**
97
85
  * Helper function to see if the provided gridEntity is in its respective broken state. See the
98
86
  * `GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP` constant for more details.
@@ -1 +1 @@
1
- {"version":3,"file":"gridEntities.d.ts","sourceRoot":"","sources":["../../src/functions/gridEntities.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EAGjB,cAAc,EACd,iBAAiB,EAGjB,eAAe,EAChB,MAAM,8BAA8B,CAAC;AAStC,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAgCvD;;;;GAIG;AACH,wBAAgB,wBAAwB,CACtC,iBAAiB,EAAE,iBAAiB,EACpC,oBAAoB,EAAE,GAAG,GACxB,CAAC,cAAc,EAAE,GAAG,CAAC,GAAG,SAAS,CAqBnC;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,IAAI,GAAG,EAAE,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,CAgCxB;AAED;;;GAGG;AACH,wBAAgB,eAAe,CAAC,SAAS,EAAE,GAAG,GAAG,UAAU,GAAG,SAAS,CAkBtE"}
@@ -49,43 +49,6 @@ function ____exports.getAllGridIndexes(self)
49
49
  local gridSize = room:GetGridSize()
50
50
  return erange(nil, gridSize)
51
51
  end
52
- --- Helper function to get every grid entity in the current room.
53
- --
54
- -- Use this function with no arguments to get every grid entity, or specify a variadic amount of
55
- -- arguments to match specific grid entity types.
56
- --
57
- -- For example:
58
- --
59
- -- ```ts
60
- -- for (const gridEntity of getGridEntities()) {
61
- -- print(gridEntity.GetType())
62
- -- }
63
- -- ```
64
- --
65
- -- For example:
66
- --
67
- -- ```ts
68
- -- const rocks = getGridEntities(
69
- -- GridEntityType.ROCK,
70
- -- GridEntityType.BLOCK,
71
- -- GridEntityType.ROCK_TINTED,
72
- -- );
73
- -- ```
74
- function ____exports.getGridEntities(self, ...)
75
- local gridEntityTypes = {...}
76
- local gridEntities = getAllGridEntities(nil)
77
- if #gridEntityTypes == 0 then
78
- return gridEntities
79
- end
80
- local gridEntityTypesSet = __TS__New(Set, gridEntityTypes)
81
- return __TS__ArrayFilter(
82
- gridEntities,
83
- function(____, gridEntity)
84
- local gridEntityType = gridEntity:GetType()
85
- return gridEntityTypesSet:has(gridEntityType)
86
- end
87
- )
88
- end
89
52
  function getAllGridEntities(self)
90
53
  local room = game:GetRoom()
91
54
  local gridEntities = {}
@@ -97,17 +60,6 @@ function getAllGridEntities(self)
97
60
  end
98
61
  return gridEntities
99
62
  end
100
- --- Helper function to get all of the grid entities in the room that specifically match the type and
101
- -- variant provided.
102
- --
103
- -- If you want to match every variant, use the `getGridEntities` function instead.
104
- function ____exports.getMatchingGridEntities(self, gridEntityType, variant)
105
- local gridEntities = ____exports.getGridEntities(nil, gridEntityType)
106
- return __TS__ArrayFilter(
107
- gridEntities,
108
- function(____, gridEntity) return gridEntity:GetVariant() == variant end
109
- )
110
- end
111
63
  --- Helper function to get the grid index of the top left wall. (This will depend on what the current
112
64
  -- room shape is.)
113
65
  function ____exports.getTopLeftWallGridIndex(self)
@@ -243,18 +195,42 @@ function ____exports.getCollidingEntitiesWithGridEntity(self, gridEntity)
243
195
  ) end
244
196
  )
245
197
  end
246
- --- Helper function to get all of the crawl spaces in the room.
198
+ --- Helper function to get every grid entity in the current room.
247
199
  --
248
- -- @param crawlSpaceVariant Optional. If specified, will only get the crawl spaces that match the
249
- -- variant. Default is -1, which matches every variant.
250
- function ____exports.getCrawlSpaces(self, crawlSpaceVariant)
251
- if crawlSpaceVariant == nil then
252
- crawlSpaceVariant = -1
253
- end
254
- if asNumber(nil, crawlSpaceVariant) == -1 then
255
- return ____exports.getGridEntities(nil, GridEntityType.CRAWL_SPACE)
200
+ -- Use this function with no arguments to get every grid entity, or specify a variadic amount of
201
+ -- arguments to match specific grid entity types.
202
+ --
203
+ -- For example:
204
+ --
205
+ -- ```ts
206
+ -- for (const gridEntity of getGridEntities()) {
207
+ -- print(gridEntity.GetType())
208
+ -- }
209
+ -- ```
210
+ --
211
+ -- For example:
212
+ --
213
+ -- ```ts
214
+ -- const rocks = getGridEntities(
215
+ -- GridEntityType.ROCK,
216
+ -- GridEntityType.BLOCK,
217
+ -- GridEntityType.ROCK_TINTED,
218
+ -- );
219
+ -- ```
220
+ function ____exports.getGridEntities(self, ...)
221
+ local gridEntityTypes = {...}
222
+ local gridEntities = getAllGridEntities(nil)
223
+ if #gridEntityTypes == 0 then
224
+ return gridEntities
256
225
  end
257
- return ____exports.getMatchingGridEntities(nil, GridEntityType.CRAWL_SPACE, crawlSpaceVariant)
226
+ local gridEntityTypesSet = __TS__New(Set, gridEntityTypes)
227
+ return __TS__ArrayFilter(
228
+ gridEntities,
229
+ function(____, gridEntity)
230
+ local gridEntityType = gridEntity:GetType()
231
+ return gridEntityTypesSet:has(gridEntityType)
232
+ end
233
+ )
258
234
  end
259
235
  --- Helper function to get every grid entity in the current room except for certain specific types.
260
236
  --
@@ -300,6 +276,17 @@ end
300
276
  function ____exports.getGridEntityIDFromConstituents(self, gridEntityType, variant)
301
277
  return (tostring(gridEntityType) .. ".") .. tostring(variant)
302
278
  end
279
+ --- Helper function to get all of the grid entities in the room that specifically match the type and
280
+ -- variant provided.
281
+ --
282
+ -- If you want to match every variant, use the `getGridEntities` function instead.
283
+ function ____exports.getMatchingGridEntities(self, gridEntityType, variant)
284
+ local gridEntities = ____exports.getGridEntities(nil, gridEntityType)
285
+ return __TS__ArrayFilter(
286
+ gridEntities,
287
+ function(____, gridEntity) return gridEntity:GetVariant() == variant end
288
+ )
289
+ end
303
290
  function ____exports.getSurroundingGridEntities(self, gridEntity)
304
291
  local room = game:GetRoom()
305
292
  local gridWidth = room:GetGridWidth()
@@ -328,14 +315,6 @@ function ____exports.getTopLeftWall(self)
328
315
  local topLeftWallGridIndex = ____exports.getTopLeftWallGridIndex(nil)
329
316
  return room:GetGridEntity(topLeftWallGridIndex)
330
317
  end
331
- --- Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` in the room.
332
- -- Specify a specific trapdoor variant to select only trapdoors of that variant.
333
- function ____exports.getTrapdoors(self, trapdoorVariant)
334
- if trapdoorVariant == nil then
335
- return ____exports.getGridEntities(nil, GridEntityType.TRAPDOOR)
336
- end
337
- return ____exports.getMatchingGridEntities(nil, GridEntityType.TRAPDOOR, trapdoorVariant)
338
- end
339
318
  --- Helper function to see if the provided gridEntity is in its respective broken state. See the
340
319
  -- `GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP` constant for more details.
341
320
  --
@@ -1,4 +1,12 @@
1
- import { DoorVariant, PitVariant, PoopGridEntityVariant, PressurePlateVariant, RockVariant } from "isaac-typescript-definitions";
1
+ import { CrawlSpaceVariant, DoorVariant, PitVariant, PoopGridEntityVariant, PressurePlateVariant, RockVariant, TrapdoorVariant } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function to get all of the grid entities of type `GridEntityType.CRAWL_SPACE` (18) in the
4
+ * room.
5
+ *
6
+ * @param crawlSpaceVariant Optional. If specified, will only get the crawl spaces that match the
7
+ * variant. Default is -1, which matches every variant.
8
+ */
9
+ export declare function getCrawlSpaces(crawlSpaceVariant?: CrawlSpaceVariant): GridEntity[];
2
10
  /**
3
11
  * Helper function to get all of the `GridEntityPit` in the room.
4
12
  *
@@ -33,6 +41,23 @@ export declare function getRocks(variant?: number): GridEntityRock[];
33
41
  export declare function getSpikes(variant?: number): GridEntitySpikes[];
34
42
  /** Helper function to get all of the `GridEntityTNT` in the room. */
35
43
  export declare function getTNT(variant?: number): GridEntityTNT[];
44
+ /**
45
+ * Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` (17) in the
46
+ * room. Specify a specific trapdoor variant to select only trapdoors of that variant.
47
+ */
48
+ export declare function getTrapdoors(trapdoorVariant?: TrapdoorVariant): GridEntity[];
49
+ /**
50
+ * Helper function to remove all of the `GridEntityType.CRAWL_SPACE` (18) in the room.
51
+ *
52
+ * @param crawlSpaceVariant Optional. If specified, will only remove the crawl spaces that match
53
+ * this variant. Default is -1, which matches every variant.
54
+ * @param updateRoom Optional. Whether or not to update the room after the crawl spaces are removed.
55
+ * Default is false. For more information, see the description of the
56
+ * `removeGridEntities` helper function.
57
+ * @param cap Optional. If specified, will only remove the given amount of crawl spaces.
58
+ * @returns The crawl spaces that were removed.
59
+ */
60
+ export declare function removeAllCrawlSpaces(crawlSpaceVariant?: CrawlSpaceVariant, updateRoom?: boolean, cap?: int): GridEntity[];
36
61
  /**
37
62
  * Helper function to remove all of the `GridEntityPit` in the room.
38
63
  *
@@ -110,11 +135,27 @@ export declare function removeAllSpikes(variant?: number, updateRoom?: boolean,
110
135
  * @returns The TNTs that were removed.
111
136
  */
112
137
  export declare function removeAllTNT(variant?: number, updateRoom?: boolean, cap?: int): GridEntityTNT[];
113
- /** Helper function to spawn a `GridEntityType.DOOR` (16). */
138
+ /**
139
+ * Helper function to remove all of the `GridEntityType.TRAPDOOR` (17) in the room.
140
+ *
141
+ * @param trapdoorVariant Optional. If specified, will only remove the trapdoors that match this
142
+ * variant. Default is -1, which matches every variant.
143
+ * @param updateRoom Optional. Whether or not to update the room after the trapdoors are removed.
144
+ * Default is false. For more information, see the description of the
145
+ * `removeGridEntities` helper function.
146
+ * @param cap Optional. If specified, will only remove the given amount of trapdoors.
147
+ * @returns The trapdoors that were removed.
148
+ */
149
+ export declare function removeAllTrapdoors(trapdoorVariant?: TrapdoorVariant, updateRoom?: boolean, cap?: int): GridEntity[];
150
+ /** Helper function to spawn a `GridEntityType.CRAWL_SPACE` (18). */
151
+ export declare function spawnCrawlSpace(gridIndexOrPosition: int | Vector): GridEntity | undefined;
152
+ /** Helper function to spawn a `GridEntityType.CRAWL_SPACE` (18) with a specific variant. */
153
+ export declare function spawnCrawlSpaceWithVariant(crawlSpaceVariant: CrawlSpaceVariant, gridIndexOrPosition: int | Vector): GridEntity | undefined;
154
+ /** Helper function to spawn a `GridEntityType.PIT` (7) with a specific variant. */
114
155
  export declare function spawnDoor(gridIndexOrPosition: int | Vector): GridEntityDoor | undefined;
115
- /** Helper function to spawn a `GridEntityType.DOOR` (16) with a specific variant. */
156
+ /** Helper function to spawn a `GridEntityType.DOOR` (16). */
116
157
  export declare function spawnDoorWithVariant(doorVariant: DoorVariant, gridIndexOrPosition: int | Vector): GridEntityDoor | undefined;
117
- /** Helper function to spawn a `GridEntityType.PIT` (7). */
158
+ /** Helper function to spawn a `GridEntityType.DOOR` (16) with a specific variant. */
118
159
  export declare function spawnPit(gridIndexOrPosition: int | Vector): GridEntityPit | undefined;
119
160
  /** Helper function to spawn a `GridEntityType.PIT` (7) with a specific variant. */
120
161
  export declare function spawnPitWithVariant(pitVariant: PitVariant, gridIndexOrPosition: int | Vector): GridEntityPit | undefined;
@@ -138,4 +179,8 @@ export declare function spawnSpikesWithVariant(variant: int, gridIndexOrPosition
138
179
  export declare function spawnTNT(gridIndexOrPosition: int | Vector): GridEntityTNT | undefined;
139
180
  /** Helper function to spawn a `GridEntityType.TNT` (12) with a specific variant. */
140
181
  export declare function spawnTNTWithVariant(variant: int, gridIndexOrPosition: int | Vector): GridEntityTNT | undefined;
182
+ /** Helper function to spawn a `GridEntityType.TRAPDOOR` (17). */
183
+ export declare function spawnTrapdoor(gridIndexOrPosition: int | Vector): GridEntity | undefined;
184
+ /** Helper function to spawn a `GridEntityType.TRAPDOOR` (17) with a specific variant. */
185
+ export declare function spawnTrapdoorWithVariant(trapdoorVariant: TrapdoorVariant, gridIndexOrPosition: int | Vector): GridEntity | undefined;
141
186
  //# sourceMappingURL=gridEntitiesSpecific.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"gridEntitiesSpecific.d.ts","sourceRoot":"","sources":["../../src/functions/gridEntitiesSpecific.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EAEX,UAAU,EACV,qBAAqB,EACrB,oBAAoB,EACpB,WAAW,EACZ,MAAM,8BAA8B,CAAC;AAWtC;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,UAAU,GAAE,UAAe,GAAG,aAAa,EAAE,CAepE;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CACtB,WAAW,GAAE,qBAA0B,GACtC,cAAc,EAAE,CAelB;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,oBAAoB,GAAE,oBAAyB,GAC9C,uBAAuB,EAAE,CAkB3B;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,OAAO,SAAK,GAAG,cAAc,EAAE,CAevD;AAED,wEAAwE;AACxE,wBAAgB,SAAS,CAAC,OAAO,SAAK,GAAG,gBAAgB,EAAE,CAe1D;AAED,qEAAqE;AACrE,wBAAgB,MAAM,CAAC,OAAO,SAAK,GAAG,aAAa,EAAE,CAepD;AAKD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,UAAU,GAAE,UAAe,EAC3B,UAAU,UAAQ,EAClB,GAAG,CAAC,EAAE,GAAG,GACR,aAAa,EAAE,CAGjB;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,cA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K5B;AAED,qFAAqF;AACrF,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,qBAAqB,EAClC,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,cAAc,GAAG,SAAS,CAgB5B;AAED,uEAAuE;AACvE,wBAAgB,kBAAkB,CAChC,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,uBAAuB,GAAG,SAAS,CAKrC;AAED,+FAA+F;AAC/F,wBAAgB,6BAA6B,CAC3C,oBAAoB,EAAE,oBAAoB,EAC1C,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,uBAAuB,GAAG,SAAS,CAgBrC;AAED,4DAA4D;AAC5D,wBAAgB,SAAS,CACvB,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,cAAc,GAAG,SAAS,CAE5B;AAED,oFAAoF;AACpF,wBAAgB,oBAAoB,CAClC,WAAW,EAAE,WAAW,EACxB,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,cAAc,GAAG,SAAS,CAgB5B;AAED,8DAA8D;AAC9D,wBAAgB,WAAW,CACzB,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,gBAAgB,GAAG,SAAS,CAE9B;AAED,sFAAsF;AACtF,wBAAgB,sBAAsB,CACpC,OAAO,EAAE,GAAG,EACZ,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,gBAAgB,GAAG,SAAS,CAgB9B;AAED,4DAA4D;AAC5D,wBAAgB,QAAQ,CACtB,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,aAAa,GAAG,SAAS,CAE3B;AAED,oFAAoF;AACpF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,GAAG,EACZ,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,aAAa,GAAG,SAAS,CAgB3B"}
1
+ {"version":3,"file":"gridEntitiesSpecific.d.ts","sourceRoot":"","sources":["../../src/functions/gridEntitiesSpecific.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,WA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oF;AACpF,wBAAgB,mBAAmB,CACjC,OAAO,EAAE,GAAG,EACZ,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,aAAa,GAAG,SAAS,CAgB3B;AAED,iEAAiE;AACjE,wBAAgB,aAAa,CAC3B,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,UAAU,GAAG,SAAS,CAKxB;AAED,yFAAyF;AACzF,wBAAgB,wBAAwB,CACtC,eAAe,EAAE,eAAe,EAChC,mBAAmB,EAAE,GAAG,GAAG,MAAM,GAChC,UAAU,GAAG,SAAS,CAMxB"}
@@ -1,5 +1,6 @@
1
1
  local ____exports = {}
2
2
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
+ local CrawlSpaceVariant = ____isaac_2Dtypescript_2Ddefinitions.CrawlSpaceVariant
3
4
  local DoorVariant = ____isaac_2Dtypescript_2Ddefinitions.DoorVariant
4
5
  local GridEntityType = ____isaac_2Dtypescript_2Ddefinitions.GridEntityType
5
6
  local PitVariant = ____isaac_2Dtypescript_2Ddefinitions.PitVariant
@@ -8,11 +9,16 @@ local PressurePlateVariant = ____isaac_2Dtypescript_2Ddefinitions.PressurePlateV
8
9
  local RockVariant = ____isaac_2Dtypescript_2Ddefinitions.RockVariant
9
10
  local ____gridEntities = require("functions.gridEntities")
10
11
  local getGridEntities = ____gridEntities.getGridEntities
12
+ local getMatchingGridEntities = ____gridEntities.getMatchingGridEntities
11
13
  local removeGridEntities = ____gridEntities.removeGridEntities
12
14
  local spawnGridEntityWithVariant = ____gridEntities.spawnGridEntityWithVariant
13
15
  local ____types = require("functions.types")
14
16
  local asNumber = ____types.asNumber
15
- --- Helper function to spawn a `GridEntityType.DOOR` (16) with a specific variant.
17
+ --- Helper function to spawn a `GridEntityType.CRAWL_SPACE` (18) with a specific variant.
18
+ function ____exports.spawnCrawlSpaceWithVariant(self, crawlSpaceVariant, gridIndexOrPosition)
19
+ return spawnGridEntityWithVariant(nil, GridEntityType.CRAWL_SPACE, crawlSpaceVariant, gridIndexOrPosition)
20
+ end
21
+ --- Helper function to spawn a `GridEntityType.DOOR` (16).
16
22
  function ____exports.spawnDoorWithVariant(self, doorVariant, gridIndexOrPosition)
17
23
  local gridEntity = spawnGridEntityWithVariant(nil, GridEntityType.DOOR, doorVariant, gridIndexOrPosition)
18
24
  if gridEntity == nil then
@@ -96,6 +102,20 @@ function ____exports.spawnTNTWithVariant(self, variant, gridIndexOrPosition)
96
102
  end
97
103
  return tnt
98
104
  end
105
+ --- Helper function to get all of the grid entities of type `GridEntityType.CRAWL_SPACE` (18) in the
106
+ -- room.
107
+ --
108
+ -- @param crawlSpaceVariant Optional. If specified, will only get the crawl spaces that match the
109
+ -- variant. Default is -1, which matches every variant.
110
+ function ____exports.getCrawlSpaces(self, crawlSpaceVariant)
111
+ if crawlSpaceVariant == nil then
112
+ crawlSpaceVariant = -1
113
+ end
114
+ if asNumber(nil, crawlSpaceVariant) == -1 then
115
+ return getGridEntities(nil, GridEntityType.CRAWL_SPACE)
116
+ end
117
+ return getMatchingGridEntities(nil, GridEntityType.CRAWL_SPACE, crawlSpaceVariant)
118
+ end
99
119
  --- Helper function to get all of the `GridEntityPit` in the room.
100
120
  --
101
121
  -- @param pitVariant Optional. If specified, will only get the pits that match the variant. Default
@@ -218,6 +238,33 @@ function ____exports.getTNT(self, variant)
218
238
  end
219
239
  return tntArray
220
240
  end
241
+ --- Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` (17) in the
242
+ -- room. Specify a specific trapdoor variant to select only trapdoors of that variant.
243
+ function ____exports.getTrapdoors(self, trapdoorVariant)
244
+ if trapdoorVariant == nil then
245
+ return getGridEntities(nil, GridEntityType.TRAPDOOR)
246
+ end
247
+ return getMatchingGridEntities(nil, GridEntityType.TRAPDOOR, trapdoorVariant)
248
+ end
249
+ --- Helper function to remove all of the `GridEntityType.CRAWL_SPACE` (18) in the room.
250
+ --
251
+ -- @param crawlSpaceVariant Optional. If specified, will only remove the crawl spaces that match
252
+ -- this variant. Default is -1, which matches every variant.
253
+ -- @param updateRoom Optional. Whether or not to update the room after the crawl spaces are removed.
254
+ -- Default is false. For more information, see the description of the
255
+ -- `removeGridEntities` helper function.
256
+ -- @param cap Optional. If specified, will only remove the given amount of crawl spaces.
257
+ -- @returns The crawl spaces that were removed.
258
+ function ____exports.removeAllCrawlSpaces(self, crawlSpaceVariant, updateRoom, cap)
259
+ if crawlSpaceVariant == nil then
260
+ crawlSpaceVariant = -1
261
+ end
262
+ if updateRoom == nil then
263
+ updateRoom = false
264
+ end
265
+ local crawlSpaces = ____exports.getCrawlSpaces(nil, crawlSpaceVariant)
266
+ return removeGridEntities(nil, crawlSpaces, updateRoom, cap)
267
+ end
221
268
  --- Helper function to remove all of the `GridEntityPit` in the room.
222
269
  --
223
270
  -- @param pitVariant Optional. If specified, will only remove the pits that match this variant.
@@ -337,11 +384,34 @@ function ____exports.removeAllTNT(self, variant, updateRoom, cap)
337
384
  local tnt = ____exports.getTNT(nil, variant)
338
385
  return removeGridEntities(nil, tnt, updateRoom, cap)
339
386
  end
340
- --- Helper function to spawn a `GridEntityType.DOOR` (16).
387
+ --- Helper function to remove all of the `GridEntityType.TRAPDOOR` (17) in the room.
388
+ --
389
+ -- @param trapdoorVariant Optional. If specified, will only remove the trapdoors that match this
390
+ -- variant. Default is -1, which matches every variant.
391
+ -- @param updateRoom Optional. Whether or not to update the room after the trapdoors are removed.
392
+ -- Default is false. For more information, see the description of the
393
+ -- `removeGridEntities` helper function.
394
+ -- @param cap Optional. If specified, will only remove the given amount of trapdoors.
395
+ -- @returns The trapdoors that were removed.
396
+ function ____exports.removeAllTrapdoors(self, trapdoorVariant, updateRoom, cap)
397
+ if trapdoorVariant == nil then
398
+ trapdoorVariant = -1
399
+ end
400
+ if updateRoom == nil then
401
+ updateRoom = false
402
+ end
403
+ local trapdoors = ____exports.getTrapdoors(nil, trapdoorVariant)
404
+ return removeGridEntities(nil, trapdoors, updateRoom, cap)
405
+ end
406
+ --- Helper function to spawn a `GridEntityType.CRAWL_SPACE` (18).
407
+ function ____exports.spawnCrawlSpace(self, gridIndexOrPosition)
408
+ return ____exports.spawnCrawlSpaceWithVariant(nil, CrawlSpaceVariant.NORMAL, gridIndexOrPosition)
409
+ end
410
+ --- Helper function to spawn a `GridEntityType.PIT` (7) with a specific variant.
341
411
  function ____exports.spawnDoor(self, gridIndexOrPosition)
342
412
  return ____exports.spawnDoorWithVariant(nil, DoorVariant.UNSPECIFIED, gridIndexOrPosition)
343
413
  end
344
- --- Helper function to spawn a `GridEntityType.PIT` (7).
414
+ --- Helper function to spawn a `GridEntityType.DOOR` (16) with a specific variant.
345
415
  function ____exports.spawnPit(self, gridIndexOrPosition)
346
416
  return ____exports.spawnPitWithVariant(nil, PitVariant.NORMAL, gridIndexOrPosition)
347
417
  end
@@ -365,4 +435,12 @@ end
365
435
  function ____exports.spawnTNT(self, gridIndexOrPosition)
366
436
  return ____exports.spawnTNTWithVariant(nil, 0, gridIndexOrPosition)
367
437
  end
438
+ --- Helper function to spawn a `GridEntityType.TRAPDOOR` (17).
439
+ function ____exports.spawnTrapdoor(self, gridIndexOrPosition)
440
+ return ____exports.spawnCrawlSpaceWithVariant(nil, CrawlSpaceVariant.NORMAL, gridIndexOrPosition)
441
+ end
442
+ --- Helper function to spawn a `GridEntityType.TRAPDOOR` (17) with a specific variant.
443
+ function ____exports.spawnTrapdoorWithVariant(self, trapdoorVariant, gridIndexOrPosition)
444
+ return spawnGridEntityWithVariant(nil, GridEntityType.TRAPDOOR, trapdoorVariant, gridIndexOrPosition)
445
+ end
368
446
  return ____exports
package/dist/index.d.ts CHANGED
@@ -954,6 +954,19 @@ export declare function countEntities(entityType?: EntityType, variant?: number,
954
954
  */
955
955
  export declare function countSetBits(n: int): int;
956
956
 
957
+ /**
958
+ * Equal to -1. Setting the stage to an invalid stage value is useful in that it prevents backdrops
959
+ * and shadows from loading.
960
+ */
961
+ export declare const CUSTOM_FLOOR_STAGE: LevelStage;
962
+
963
+ /**
964
+ * We must use `StageType.WRATH_OF_THE_LAMB` instead of `StageType.ORIGINAL` or else the walls will
965
+ * not render properly. DeadInfinity suspects that this might be because it is trying to use the
966
+ * Dark Room's backdrop (instead of The Chest).
967
+ */
968
+ export declare const CUSTOM_FLOOR_STAGE_TYPE = StageType.WRATH_OF_THE_LAMB;
969
+
957
970
  /**
958
971
  * An object that represents a possible boss for a custom stage. This can be for a vanilla boss or a
959
972
  * custom boss.
@@ -2798,7 +2811,8 @@ export declare function getCollidingEntitiesWithGridEntity(gridEntity: GridEntit
2798
2811
  export declare function getCombinedBossSet(stage: int): ReadonlySet<string> | undefined;
2799
2812
 
2800
2813
  /**
2801
- * Helper function to get all of the crawl spaces in the room.
2814
+ * Helper function to get all of the grid entities of type `GridEntityType.CRAWL_SPACE` (18) in the
2815
+ * room.
2802
2816
  *
2803
2817
  * @param crawlSpaceVariant Optional. If specified, will only get the crawl spaces that match the
2804
2818
  * variant. Default is -1, which matches every variant.
@@ -5014,8 +5028,8 @@ export declare function getTransformationName(playerForm: PlayerForm): string;
5014
5028
  export declare function getTransformationsForCollectibleType(collectibleType: CollectibleType): Set<PlayerForm>;
5015
5029
 
5016
5030
  /**
5017
- * Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` in the room.
5018
- * Specify a specific trapdoor variant to select only trapdoors of that variant.
5031
+ * Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` (17) in the
5032
+ * room. Specify a specific trapdoor variant to select only trapdoors of that variant.
5019
5033
  */
5020
5034
  export declare function getTrapdoors(trapdoorVariant?: TrapdoorVariant): GridEntity[];
5021
5035
 
@@ -5478,8 +5492,6 @@ export declare function inSecretShop(): boolean;
5478
5492
  */
5479
5493
  export declare function inStartingRoom(): boolean;
5480
5494
 
5481
- export declare const INVALID_STAGE_VALUE: LevelStage;
5482
-
5483
5495
  /**
5484
5496
  * Helper function to return an array with the elements from start to end, inclusive. (The "i"
5485
5497
  * stands for inclusive.)
@@ -9099,6 +9111,19 @@ export declare function removeAllCoins(coinSubType?: CoinSubType, cap?: int): En
9099
9111
  */
9100
9112
  export declare function removeAllCollectibles(collectibleType?: CollectibleType, cap?: int): EntityPickupCollectible[];
9101
9113
 
9114
+ /**
9115
+ * Helper function to remove all of the `GridEntityType.CRAWL_SPACE` (18) in the room.
9116
+ *
9117
+ * @param crawlSpaceVariant Optional. If specified, will only remove the crawl spaces that match
9118
+ * this variant. Default is -1, which matches every variant.
9119
+ * @param updateRoom Optional. Whether or not to update the room after the crawl spaces are removed.
9120
+ * Default is false. For more information, see the description of the
9121
+ * `removeGridEntities` helper function.
9122
+ * @param cap Optional. If specified, will only remove the given amount of crawl spaces.
9123
+ * @returns The crawl spaces that were removed.
9124
+ */
9125
+ export declare function removeAllCrawlSpaces(crawlSpaceVariant?: CrawlSpaceVariant, updateRoom?: boolean, cap?: int): GridEntity[];
9126
+
9102
9127
  /**
9103
9128
  * Helper function to remove all of the doors in the room. By default, it will remove every door.
9104
9129
  * You can optionally specify one or more room types to remove only the doors that match the
@@ -9412,6 +9437,19 @@ export declare function removeAllTears(tearVariant?: TearVariant, subType?: numb
9412
9437
  */
9413
9438
  export declare function removeAllTNT(variant?: number, updateRoom?: boolean, cap?: int): GridEntityTNT[];
9414
9439
 
9440
+ /**
9441
+ * Helper function to remove all of the `GridEntityType.TRAPDOOR` (17) in the room.
9442
+ *
9443
+ * @param trapdoorVariant Optional. If specified, will only remove the trapdoors that match this
9444
+ * variant. Default is -1, which matches every variant.
9445
+ * @param updateRoom Optional. Whether or not to update the room after the trapdoors are removed.
9446
+ * Default is false. For more information, see the description of the
9447
+ * `removeGridEntities` helper function.
9448
+ * @param cap Optional. If specified, will only remove the given amount of trapdoors.
9449
+ * @returns The trapdoors that were removed.
9450
+ */
9451
+ export declare function removeAllTrapdoors(trapdoorVariant?: TrapdoorVariant, updateRoom?: boolean, cap?: int): GridEntity[];
9452
+
9415
9453
  /**
9416
9454
  * Helper function to remove all of the trinkets in the room.
9417
9455
  *
@@ -10761,6 +10799,12 @@ export declare function spawnCoinWithSeed(coinSubType: CoinSubType, position: Ve
10761
10799
  */
10762
10800
  export declare function spawnCollectible(collectibleType: CollectibleType, position: Vector, seedOrRNG?: Seed | RNG, options?: boolean, forceFreeItem?: boolean, spawner?: Entity): EntityPickupCollectible;
10763
10801
 
10802
+ /** Helper function to spawn a `GridEntityType.CRAWL_SPACE` (18). */
10803
+ export declare function spawnCrawlSpace(gridIndexOrPosition: int | Vector): GridEntity | undefined;
10804
+
10805
+ /** Helper function to spawn a `GridEntityType.CRAWL_SPACE` (18) with a specific variant. */
10806
+ export declare function spawnCrawlSpaceWithVariant(crawlSpaceVariant: CrawlSpaceVariant, gridIndexOrPosition: int | Vector): GridEntity | undefined;
10807
+
10764
10808
  /**
10765
10809
  * Helper function to spawn a custom door. This is intended to be called from the `POST_NEW_ROOM`
10766
10810
  * callback when the player enters a room that should have a custom door. (You could also call it
@@ -10870,10 +10914,10 @@ export declare function spawnCustomTrapdoor(gridIndexOrPosition: int | Vector, c
10870
10914
  */
10871
10915
  export declare function spawnCustomTrapdoorToVanilla(gridIndexOrPosition: int | Vector, stage?: LevelStage, stageType?: StageType, anm2Path?: string, spawnOpen?: boolean): GridEntity;
10872
10916
 
10873
- /** Helper function to spawn a `GridEntityType.DOOR` (16). */
10917
+ /** Helper function to spawn a `GridEntityType.PIT` (7) with a specific variant. */
10874
10918
  export declare function spawnDoor(gridIndexOrPosition: int | Vector): GridEntityDoor | undefined;
10875
10919
 
10876
- /** Helper function to spawn a `GridEntityType.DOOR` (16) with a specific variant. */
10920
+ /** Helper function to spawn a `GridEntityType.DOOR` (16). */
10877
10921
  export declare function spawnDoorWithVariant(doorVariant: DoorVariant, gridIndexOrPosition: int | Vector): GridEntityDoor | undefined;
10878
10922
 
10879
10923
  /** Helper function to spawn a `EntityType.EFFECT` (1000). */
@@ -11006,7 +11050,7 @@ export declare function spawnPill(pillColor: PillColor, position: Vector, veloci
11006
11050
  */
11007
11051
  export declare function spawnPillWithSeed(pillColor: PillColor, position: Vector, seedOrRNG: Seed | RNG, velocity?: Vector, spawner?: Entity | undefined): EntityPickupPill;
11008
11052
 
11009
- /** Helper function to spawn a `GridEntityType.PIT` (7). */
11053
+ /** Helper function to spawn a `GridEntityType.DOOR` (16) with a specific variant. */
11010
11054
  export declare function spawnPit(gridIndexOrPosition: int | Vector): GridEntityPit | undefined;
11011
11055
 
11012
11056
  /** Helper function to spawn a `GridEntityType.PIT` (7) with a specific variant. */
@@ -11099,6 +11143,12 @@ export declare function spawnTNT(gridIndexOrPosition: int | Vector): GridEntityT
11099
11143
  /** Helper function to spawn a `GridEntityType.TNT` (12) with a specific variant. */
11100
11144
  export declare function spawnTNTWithVariant(variant: int, gridIndexOrPosition: int | Vector): GridEntityTNT | undefined;
11101
11145
 
11146
+ /** Helper function to spawn a `GridEntityType.TRAPDOOR` (17). */
11147
+ export declare function spawnTrapdoor(gridIndexOrPosition: int | Vector): GridEntity | undefined;
11148
+
11149
+ /** Helper function to spawn a `GridEntityType.TRAPDOOR` (17) with a specific variant. */
11150
+ export declare function spawnTrapdoorWithVariant(trapdoorVariant: TrapdoorVariant, gridIndexOrPosition: int | Vector): GridEntity | undefined;
11151
+
11102
11152
  /**
11103
11153
  * Helper function to spawn a `EntityType.PICKUP` (5) with variant `PickupVariant.TRINKET` (350).
11104
11154
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "8.8.1",
3
+ "version": "8.9.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "dist/index",
23
23
  "types": "dist/index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^3.6.1"
25
+ "isaac-typescript-definitions": "^3.6.3"
26
26
  }
27
27
  }
@@ -36,7 +36,18 @@ import v, { customStageCachedRoomData, customStagesMap } from "./v";
36
36
  export const DEFAULT_BASE_STAGE = LevelStage.BASEMENT_2;
37
37
  export const DEFAULT_BASE_STAGE_TYPE = StageType.ORIGINAL;
38
38
 
39
- export const INVALID_STAGE_VALUE = -1 as LevelStage;
39
+ /**
40
+ * Equal to -1. Setting the stage to an invalid stage value is useful in that it prevents backdrops
41
+ * and shadows from loading.
42
+ */
43
+ export const CUSTOM_FLOOR_STAGE = -1 as LevelStage;
44
+
45
+ /**
46
+ * We must use `StageType.WRATH_OF_THE_LAMB` instead of `StageType.ORIGINAL` or else the walls will
47
+ * not render properly. DeadInfinity suspects that this might be because it is trying to use the
48
+ * Dark Room's backdrop (instead of The Chest).
49
+ */
50
+ export const CUSTOM_FLOOR_STAGE_TYPE = StageType.WRATH_OF_THE_LAMB;
40
51
 
41
52
  /**
42
53
  * Helper function to warp to a custom stage/level.
@@ -74,7 +85,7 @@ export function setCustomStage(
74
85
 
75
86
  // Before changing the stage, we have to revert the bugged stage, if necessary. This prevents the
76
87
  // bug where the backdrop will not spawn.
77
- if (stage === INVALID_STAGE_VALUE) {
88
+ if (stage === CUSTOM_FLOOR_STAGE) {
78
89
  level.SetStage(LevelStage.BASEMENT_1, StageType.ORIGINAL);
79
90
  }
80
91
 
@@ -98,11 +109,8 @@ export function setCustomStage(
98
109
  setStageRoomsData(customStage, rng, verbose);
99
110
 
100
111
  // Set the stage to an invalid value, which will prevent the walls and floors from loading.
101
- // Furthermore, we must use `StageType.WRATH_OF_THE_LAMB` instead of `StageType.ORIGINAL` or else
102
- // the walls will not render properly. DeadInfinity suspects that this might be because it is
103
- // trying to use the Dark Room's backdrop (instead of The Chest).
104
- const targetStage = INVALID_STAGE_VALUE;
105
- const targetStageType = StageType.WRATH_OF_THE_LAMB;
112
+ const targetStage = CUSTOM_FLOOR_STAGE;
113
+ const targetStageType = CUSTOM_FLOOR_STAGE_TYPE;
106
114
  level.SetStage(targetStage, targetStageType);
107
115
  reorderedCallbacksSetStageInternal(targetStage, targetStageType);
108
116
 
@@ -4,7 +4,6 @@ import {
4
4
  RoomType,
5
5
  SoundEffect,
6
6
  StageID,
7
- StageType,
8
7
  } from "isaac-typescript-definitions";
9
8
  import { game, sfxManager } from "../../core/cachedClasses";
10
9
  import { arrayRemove } from "../../functions/array";
@@ -27,9 +26,10 @@ import {
27
26
  ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH,
28
27
  } from "./customStageConstants";
29
28
  import {
29
+ CUSTOM_FLOOR_STAGE,
30
+ CUSTOM_FLOOR_STAGE_TYPE,
30
31
  DEFAULT_BASE_STAGE,
31
32
  DEFAULT_BASE_STAGE_TYPE,
32
- INVALID_STAGE_VALUE,
33
33
  } from "./exports";
34
34
  import v from "./v";
35
35
 
@@ -132,7 +132,7 @@ export function playVersusScreenAnimation(customStage: CustomStage): void {
132
132
  level.SetStage(DEFAULT_BASE_STAGE, DEFAULT_BASE_STAGE_TYPE);
133
133
  runNextGameFrame(() => {
134
134
  const futureLevel = game.GetLevel();
135
- futureLevel.SetStage(INVALID_STAGE_VALUE, StageType.ORIGINAL);
135
+ futureLevel.SetStage(CUSTOM_FLOOR_STAGE, CUSTOM_FLOOR_STAGE_TYPE);
136
136
  });
137
137
  return;
138
138
  }
@@ -1,5 +1,4 @@
1
1
  import {
2
- CrawlSpaceVariant,
3
2
  EffectVariant,
4
3
  GridCollisionClass,
5
4
  GridEntityType,
@@ -130,22 +129,6 @@ export function getCollidingEntitiesWithGridEntity(
130
129
  );
131
130
  }
132
131
 
133
- /**
134
- * Helper function to get all of the crawl spaces in the room.
135
- *
136
- * @param crawlSpaceVariant Optional. If specified, will only get the crawl spaces that match the
137
- * variant. Default is -1, which matches every variant.
138
- */
139
- export function getCrawlSpaces(
140
- crawlSpaceVariant: CrawlSpaceVariant = -1,
141
- ): GridEntity[] {
142
- if (asNumber(crawlSpaceVariant) === -1) {
143
- return getGridEntities(GridEntityType.CRAWL_SPACE);
144
- }
145
-
146
- return getMatchingGridEntities(GridEntityType.CRAWL_SPACE, crawlSpaceVariant);
147
- }
148
-
149
132
  /**
150
133
  * Helper function to get every grid entity in the current room.
151
134
  *
@@ -329,18 +312,6 @@ export function getTopLeftWallGridIndex(): int {
329
312
  : topLeftWallGridIndex;
330
313
  }
331
314
 
332
- /**
333
- * Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` in the room.
334
- * Specify a specific trapdoor variant to select only trapdoors of that variant.
335
- */
336
- export function getTrapdoors(trapdoorVariant?: TrapdoorVariant): GridEntity[] {
337
- if (trapdoorVariant === undefined) {
338
- return getGridEntities(GridEntityType.TRAPDOOR);
339
- }
340
-
341
- return getMatchingGridEntities(GridEntityType.TRAPDOOR, trapdoorVariant);
342
- }
343
-
344
315
  /**
345
316
  * Helper function to see if the provided gridEntity is in its respective broken state. See the
346
317
  * `GRID_ENTITY_TYPE_TO_BROKEN_STATE_MAP` constant for more details.
@@ -1,18 +1,38 @@
1
1
  import {
2
+ CrawlSpaceVariant,
2
3
  DoorVariant,
3
4
  GridEntityType,
4
5
  PitVariant,
5
6
  PoopGridEntityVariant,
6
7
  PressurePlateVariant,
7
8
  RockVariant,
9
+ TrapdoorVariant,
8
10
  } from "isaac-typescript-definitions";
9
11
  import {
10
12
  getGridEntities,
13
+ getMatchingGridEntities,
11
14
  removeGridEntities,
12
15
  spawnGridEntityWithVariant,
13
16
  } from "./gridEntities";
14
17
  import { asNumber } from "./types";
15
18
 
19
+ /**
20
+ * Helper function to get all of the grid entities of type `GridEntityType.CRAWL_SPACE` (18) in the
21
+ * room.
22
+ *
23
+ * @param crawlSpaceVariant Optional. If specified, will only get the crawl spaces that match the
24
+ * variant. Default is -1, which matches every variant.
25
+ */
26
+ export function getCrawlSpaces(
27
+ crawlSpaceVariant: CrawlSpaceVariant = -1,
28
+ ): GridEntity[] {
29
+ if (asNumber(crawlSpaceVariant) === -1) {
30
+ return getGridEntities(GridEntityType.CRAWL_SPACE);
31
+ }
32
+
33
+ return getMatchingGridEntities(GridEntityType.CRAWL_SPACE, crawlSpaceVariant);
34
+ }
35
+
16
36
  // The `getDoors` function is not located here because doors are collected via the `Room.GetDoor`
17
37
  // method instead, which is faster.
18
38
 
@@ -153,6 +173,38 @@ export function getTNT(variant = -1): GridEntityTNT[] {
153
173
  return tntArray;
154
174
  }
155
175
 
176
+ /**
177
+ * Helper function to get all of the grid entities of type `GridEntityType.TRAPDOOR` (17) in the
178
+ * room. Specify a specific trapdoor variant to select only trapdoors of that variant.
179
+ */
180
+ export function getTrapdoors(trapdoorVariant?: TrapdoorVariant): GridEntity[] {
181
+ if (trapdoorVariant === undefined) {
182
+ return getGridEntities(GridEntityType.TRAPDOOR);
183
+ }
184
+
185
+ return getMatchingGridEntities(GridEntityType.TRAPDOOR, trapdoorVariant);
186
+ }
187
+
188
+ /**
189
+ * Helper function to remove all of the `GridEntityType.CRAWL_SPACE` (18) in the room.
190
+ *
191
+ * @param crawlSpaceVariant Optional. If specified, will only remove the crawl spaces that match
192
+ * this variant. Default is -1, which matches every variant.
193
+ * @param updateRoom Optional. Whether or not to update the room after the crawl spaces are removed.
194
+ * Default is false. For more information, see the description of the
195
+ * `removeGridEntities` helper function.
196
+ * @param cap Optional. If specified, will only remove the given amount of crawl spaces.
197
+ * @returns The crawl spaces that were removed.
198
+ */
199
+ export function removeAllCrawlSpaces(
200
+ crawlSpaceVariant: CrawlSpaceVariant = -1,
201
+ updateRoom = false,
202
+ cap?: int,
203
+ ): GridEntity[] {
204
+ const crawlSpaces = getCrawlSpaces(crawlSpaceVariant);
205
+ return removeGridEntities(crawlSpaces, updateRoom, cap);
206
+ }
207
+
156
208
  // The `removeAllDoors` function is not located here because doors are removed via the
157
209
  // `Room.RemoveDoor` method instead.
158
210
 
@@ -281,14 +333,56 @@ export function removeAllTNT(
281
333
  return removeGridEntities(tnt, updateRoom, cap);
282
334
  }
283
335
 
284
- /** Helper function to spawn a `GridEntityType.DOOR` (16). */
336
+ /**
337
+ * Helper function to remove all of the `GridEntityType.TRAPDOOR` (17) in the room.
338
+ *
339
+ * @param trapdoorVariant Optional. If specified, will only remove the trapdoors that match this
340
+ * variant. Default is -1, which matches every variant.
341
+ * @param updateRoom Optional. Whether or not to update the room after the trapdoors are removed.
342
+ * Default is false. For more information, see the description of the
343
+ * `removeGridEntities` helper function.
344
+ * @param cap Optional. If specified, will only remove the given amount of trapdoors.
345
+ * @returns The trapdoors that were removed.
346
+ */
347
+ export function removeAllTrapdoors(
348
+ trapdoorVariant: TrapdoorVariant = -1,
349
+ updateRoom = false,
350
+ cap?: int,
351
+ ): GridEntity[] {
352
+ const trapdoors = getTrapdoors(trapdoorVariant);
353
+ return removeGridEntities(trapdoors, updateRoom, cap);
354
+ }
355
+
356
+ /** Helper function to spawn a `GridEntityType.CRAWL_SPACE` (18). */
357
+ export function spawnCrawlSpace(
358
+ gridIndexOrPosition: int | Vector,
359
+ ): GridEntity | undefined {
360
+ return spawnCrawlSpaceWithVariant(
361
+ CrawlSpaceVariant.NORMAL,
362
+ gridIndexOrPosition,
363
+ );
364
+ }
365
+
366
+ /** Helper function to spawn a `GridEntityType.CRAWL_SPACE` (18) with a specific variant. */
367
+ export function spawnCrawlSpaceWithVariant(
368
+ crawlSpaceVariant: CrawlSpaceVariant,
369
+ gridIndexOrPosition: int | Vector,
370
+ ): GridEntity | undefined {
371
+ return spawnGridEntityWithVariant(
372
+ GridEntityType.CRAWL_SPACE,
373
+ crawlSpaceVariant,
374
+ gridIndexOrPosition,
375
+ );
376
+ }
377
+
378
+ /** Helper function to spawn a `GridEntityType.PIT` (7) with a specific variant. */
285
379
  export function spawnDoor(
286
380
  gridIndexOrPosition: int | Vector,
287
381
  ): GridEntityDoor | undefined {
288
382
  return spawnDoorWithVariant(DoorVariant.UNSPECIFIED, gridIndexOrPosition);
289
383
  }
290
384
 
291
- /** Helper function to spawn a `GridEntityType.DOOR` (16) with a specific variant. */
385
+ /** Helper function to spawn a `GridEntityType.DOOR` (16). */
292
386
  export function spawnDoorWithVariant(
293
387
  doorVariant: DoorVariant,
294
388
  gridIndexOrPosition: int | Vector,
@@ -310,7 +404,7 @@ export function spawnDoorWithVariant(
310
404
  return door;
311
405
  }
312
406
 
313
- /** Helper function to spawn a `GridEntityType.PIT` (7). */
407
+ /** Helper function to spawn a `GridEntityType.DOOR` (16) with a specific variant. */
314
408
  export function spawnPit(
315
409
  gridIndexOrPosition: int | Vector,
316
410
  ): GridEntityPit | undefined {
@@ -489,3 +583,25 @@ export function spawnTNTWithVariant(
489
583
 
490
584
  return tnt;
491
585
  }
586
+
587
+ /** Helper function to spawn a `GridEntityType.TRAPDOOR` (17). */
588
+ export function spawnTrapdoor(
589
+ gridIndexOrPosition: int | Vector,
590
+ ): GridEntity | undefined {
591
+ return spawnCrawlSpaceWithVariant(
592
+ CrawlSpaceVariant.NORMAL,
593
+ gridIndexOrPosition,
594
+ );
595
+ }
596
+
597
+ /** Helper function to spawn a `GridEntityType.TRAPDOOR` (17) with a specific variant. */
598
+ export function spawnTrapdoorWithVariant(
599
+ trapdoorVariant: TrapdoorVariant,
600
+ gridIndexOrPosition: int | Vector,
601
+ ): GridEntity | undefined {
602
+ return spawnGridEntityWithVariant(
603
+ GridEntityType.TRAPDOOR,
604
+ trapdoorVariant,
605
+ gridIndexOrPosition,
606
+ );
607
+ }