isaacscript-common 33.12.1 → 33.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.rollup.d.ts +19 -2
- package/dist/isaacscript-common.lua +37 -11
- package/dist/src/functions/level.d.ts +18 -2
- package/dist/src/functions/level.d.ts.map +1 -1
- package/dist/src/functions/level.lua +36 -1
- package/dist/src/functions/levelGrid.d.ts +1 -1
- package/dist/src/functions/levelGrid.lua +6 -6
- package/dist/src/functions/rooms.lua +5 -5
- package/package.json +1 -1
- package/src/functions/level.ts +36 -2
- package/src/functions/levelGrid.ts +6 -6
- package/src/functions/rooms.ts +6 -6
package/dist/index.rollup.d.ts
CHANGED
|
@@ -4292,7 +4292,7 @@ declare abstract class Feature {
|
|
|
4292
4292
|
constructor();
|
|
4293
4293
|
}
|
|
4294
4294
|
|
|
4295
|
-
/** Helper function to fill every possible square with a red room. */
|
|
4295
|
+
/** Helper function to fill every possible level grid square with a red room. */
|
|
4296
4296
|
export declare function fillLevelWithRedRooms(): void;
|
|
4297
4297
|
|
|
4298
4298
|
/**
|
|
@@ -5724,6 +5724,15 @@ export declare function getLastElement<T>(array: T[]): T | undefined;
|
|
|
5724
5724
|
*/
|
|
5725
5725
|
export declare function getLastFrameOfAnimation(sprite: Sprite, animation?: string): int;
|
|
5726
5726
|
|
|
5727
|
+
/**
|
|
5728
|
+
* Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
|
|
5729
|
+
* to the sub-type of the room data.)
|
|
5730
|
+
*
|
|
5731
|
+
* Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
|
|
5732
|
+
* rooms will not count.
|
|
5733
|
+
*/
|
|
5734
|
+
export declare function getLevelBossIDs(): BossID[];
|
|
5735
|
+
|
|
5727
5736
|
/**
|
|
5728
5737
|
* Helper function to get the lowest value in an array. Returns undefined if there were no elements
|
|
5729
5738
|
* in the array.
|
|
@@ -6672,7 +6681,7 @@ export declare function getRoomDescriptorReadOnly(): Readonly<RoomDescriptor>;
|
|
|
6672
6681
|
* Helper function to get an array of all of the room descriptors for rooms that match the specified
|
|
6673
6682
|
* room type.
|
|
6674
6683
|
*
|
|
6675
|
-
* This function only searches through rooms in the current dimension.
|
|
6684
|
+
* This function only searches through rooms in the current dimension and rooms inside the grid.
|
|
6676
6685
|
*
|
|
6677
6686
|
* This function is variadic, meaning that you can specify N arguments to get the combined room
|
|
6678
6687
|
* descriptors for N room types.
|
|
@@ -9498,6 +9507,14 @@ export declare const LEVEL_GRID_COLUMN_HEIGHT = 13;
|
|
|
9498
9507
|
*/
|
|
9499
9508
|
export declare const LEVEL_GRID_ROW_WIDTH = 13;
|
|
9500
9509
|
|
|
9510
|
+
/**
|
|
9511
|
+
* Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
|
|
9512
|
+
*
|
|
9513
|
+
* This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
|
|
9514
|
+
* It will return true if one or more of the boss IDs are matched.
|
|
9515
|
+
*/
|
|
9516
|
+
export declare function levelHasBossID(...bossIDs: BossID[]): boolean;
|
|
9517
|
+
|
|
9501
9518
|
/**
|
|
9502
9519
|
* Helper function to check to see if the current floor has one or more of a specific room type in
|
|
9503
9520
|
* it.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
--[[
|
|
2
2
|
|
|
3
|
-
isaacscript-common 33.
|
|
3
|
+
isaacscript-common 33.13.0
|
|
4
4
|
|
|
5
5
|
This is the "isaacscript-common" library, which was created with the IsaacScript tool.
|
|
6
6
|
|
|
@@ -27737,8 +27737,8 @@ function ____exports.changeRoom(self, roomGridIndex)
|
|
|
27737
27737
|
game:ChangeRoom(roomGridIndex)
|
|
27738
27738
|
end
|
|
27739
27739
|
function ____exports.getNumRooms(self)
|
|
27740
|
-
local
|
|
27741
|
-
return #
|
|
27740
|
+
local roomsInsideGrid = ____exports.getRoomsInsideGrid(nil)
|
|
27741
|
+
return #roomsInsideGrid
|
|
27742
27742
|
end
|
|
27743
27743
|
function ____exports.getRoomDataForTypeVariant(self, roomType, roomVariant, cancelRoomTransition, useSpecialRoomsForRoomTypeDefault)
|
|
27744
27744
|
if cancelRoomTransition == nil then
|
|
@@ -27879,14 +27879,14 @@ function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes, includeSecretAndS
|
|
|
27879
27879
|
if includeUltraSecretRoom == nil then
|
|
27880
27880
|
includeUltraSecretRoom = false
|
|
27881
27881
|
end
|
|
27882
|
-
local
|
|
27882
|
+
local roomsInsideGrid = ____exports.getRoomsInsideGrid(nil)
|
|
27883
27883
|
local matchingRooms
|
|
27884
27884
|
if onlyCheckRoomTypes == nil then
|
|
27885
|
-
matchingRooms =
|
|
27885
|
+
matchingRooms = roomsInsideGrid
|
|
27886
27886
|
else
|
|
27887
27887
|
local roomTypeWhitelist = __TS__New(ReadonlySet, onlyCheckRoomTypes)
|
|
27888
27888
|
matchingRooms = __TS__ArrayFilter(
|
|
27889
|
-
|
|
27889
|
+
roomsInsideGrid,
|
|
27890
27890
|
function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypeWhitelist:has(roomDescriptor.Data.Type) end
|
|
27891
27891
|
)
|
|
27892
27892
|
end
|
|
@@ -48156,12 +48156,12 @@ function ____exports.getNewRoomCandidatesForLevel(self, ensureDeadEnd)
|
|
|
48156
48156
|
if ensureDeadEnd == nil then
|
|
48157
48157
|
ensureDeadEnd = true
|
|
48158
48158
|
end
|
|
48159
|
-
local
|
|
48159
|
+
local roomsInsideGrid = getRoomsInsideGrid(nil)
|
|
48160
48160
|
local normalRooms = __TS__ArrayFilter(
|
|
48161
|
-
|
|
48161
|
+
roomsInsideGrid,
|
|
48162
48162
|
function(____, room) return room.Data ~= nil and room.Data.Type == RoomType.DEFAULT and not isMirrorRoom(nil, room.Data) and not isMineShaft(nil, room.Data) end
|
|
48163
48163
|
)
|
|
48164
|
-
local roomsToLookThrough = ensureDeadEnd and normalRooms or
|
|
48164
|
+
local roomsToLookThrough = ensureDeadEnd and normalRooms or roomsInsideGrid
|
|
48165
48165
|
local newRoomCandidates = {}
|
|
48166
48166
|
for ____, room in ipairs(roomsToLookThrough) do
|
|
48167
48167
|
local newRoomCandidatesBesideRoom = ____exports.getNewRoomCandidatesBesideRoom(nil, room.SafeGridIndex, ensureDeadEnd)
|
|
@@ -48279,9 +48279,9 @@ end
|
|
|
48279
48279
|
function ____exports.getRoomDescriptorsForType(self, ...)
|
|
48280
48280
|
local roomTypes = {...}
|
|
48281
48281
|
local roomTypesSet = __TS__New(Set, roomTypes)
|
|
48282
|
-
local
|
|
48282
|
+
local roomsInsideGrid = getRoomsInsideGrid(nil)
|
|
48283
48283
|
return __TS__ArrayFilter(
|
|
48284
|
-
|
|
48284
|
+
roomsInsideGrid,
|
|
48285
48285
|
function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypesSet:has(roomDescriptor.Data.Type) end
|
|
48286
48286
|
)
|
|
48287
48287
|
end
|
|
@@ -53740,11 +53740,20 @@ end
|
|
|
53740
53740
|
return ____exports
|
|
53741
53741
|
end,
|
|
53742
53742
|
["src.functions.level"] = function(...)
|
|
53743
|
+
local ____lualib = require("lualib_bundle")
|
|
53744
|
+
local Set = ____lualib.Set
|
|
53745
|
+
local __TS__New = ____lualib.__TS__New
|
|
53746
|
+
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
53743
53747
|
local ____exports = {}
|
|
53748
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
|
|
53749
|
+
local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
|
|
53750
|
+
local StageID = ____isaac_2Dtypescript_2Ddefinitions.StageID
|
|
53744
53751
|
local ____cachedEnumValues = require("src.arrays.cachedEnumValues")
|
|
53745
53752
|
local DOOR_SLOT_VALUES = ____cachedEnumValues.DOOR_SLOT_VALUES
|
|
53746
53753
|
local ____cachedClasses = require("src.core.cachedClasses")
|
|
53747
53754
|
local game = ____cachedClasses.game
|
|
53755
|
+
local ____array = require("src.functions.array")
|
|
53756
|
+
local filterMap = ____array.filterMap
|
|
53748
53757
|
local ____levelGrid = require("src.functions.levelGrid")
|
|
53749
53758
|
local getRoomDescriptorsForType = ____levelGrid.getRoomDescriptorsForType
|
|
53750
53759
|
local isDoorSlotValidAtGridIndexForRedRoom = ____levelGrid.isDoorSlotValidAtGridIndexForRedRoom
|
|
@@ -53768,6 +53777,23 @@ function ____exports.fillLevelWithRedRooms(self)
|
|
|
53768
53777
|
end
|
|
53769
53778
|
until not (numRoomsInGrid ~= getNumRooms(nil))
|
|
53770
53779
|
end
|
|
53780
|
+
function ____exports.getLevelBossIDs(self)
|
|
53781
|
+
local roomsInsideGrid = getRoomsInsideGrid(nil)
|
|
53782
|
+
return filterMap(
|
|
53783
|
+
nil,
|
|
53784
|
+
roomsInsideGrid,
|
|
53785
|
+
function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomDescriptor.Data.Type == RoomType.BOSS and roomDescriptor.Data.StageID == StageID.SPECIAL_ROOMS and roomDescriptor.Data.Subtype or nil end
|
|
53786
|
+
)
|
|
53787
|
+
end
|
|
53788
|
+
function ____exports.levelHasBossID(self, ...)
|
|
53789
|
+
local bossIDs = {...}
|
|
53790
|
+
local levelBossIDs = ____exports.getLevelBossIDs(nil)
|
|
53791
|
+
local levelBossIDsSet = __TS__New(Set, levelBossIDs)
|
|
53792
|
+
return __TS__ArraySome(
|
|
53793
|
+
bossIDs,
|
|
53794
|
+
function(____, bossID) return levelBossIDsSet:has(bossID) end
|
|
53795
|
+
)
|
|
53796
|
+
end
|
|
53771
53797
|
function ____exports.levelHasRoomType(self, ...)
|
|
53772
53798
|
local roomDescriptors = getRoomDescriptorsForType(nil, ...)
|
|
53773
53799
|
return #roomDescriptors > 0
|
|
@@ -1,6 +1,22 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
1
|
+
import type { BossID } from "isaac-typescript-definitions";
|
|
2
|
+
import { RoomType } from "isaac-typescript-definitions";
|
|
3
|
+
/** Helper function to fill every possible level grid square with a red room. */
|
|
3
4
|
export declare function fillLevelWithRedRooms(): void;
|
|
5
|
+
/**
|
|
6
|
+
* Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
|
|
7
|
+
* to the sub-type of the room data.)
|
|
8
|
+
*
|
|
9
|
+
* Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
|
|
10
|
+
* rooms will not count.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getLevelBossIDs(): BossID[];
|
|
13
|
+
/**
|
|
14
|
+
* Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
|
|
15
|
+
*
|
|
16
|
+
* This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
|
|
17
|
+
* It will return true if one or more of the boss IDs are matched.
|
|
18
|
+
*/
|
|
19
|
+
export declare function levelHasBossID(...bossIDs: BossID[]): boolean;
|
|
4
20
|
/**
|
|
5
21
|
* Helper function to check to see if the current floor has one or more of a specific room type in
|
|
6
22
|
* it.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"level.d.ts","sourceRoot":"","sources":["../../../src/functions/level.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"level.d.ts","sourceRoot":"","sources":["../../../src/functions/level.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAW,MAAM,8BAA8B,CAAC;AAUjE,gFAAgF;AAChF,wBAAgB,qBAAqB,IAAI,IAAI,CAqB5C;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAU1C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAK5D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAGlE"}
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
+
local ____lualib = require("lualib_bundle")
|
|
2
|
+
local Set = ____lualib.Set
|
|
3
|
+
local __TS__New = ____lualib.__TS__New
|
|
4
|
+
local __TS__ArraySome = ____lualib.__TS__ArraySome
|
|
1
5
|
local ____exports = {}
|
|
6
|
+
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
7
|
+
local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
|
|
8
|
+
local StageID = ____isaac_2Dtypescript_2Ddefinitions.StageID
|
|
2
9
|
local ____cachedEnumValues = require("src.arrays.cachedEnumValues")
|
|
3
10
|
local DOOR_SLOT_VALUES = ____cachedEnumValues.DOOR_SLOT_VALUES
|
|
4
11
|
local ____cachedClasses = require("src.core.cachedClasses")
|
|
5
12
|
local game = ____cachedClasses.game
|
|
13
|
+
local ____array = require("src.functions.array")
|
|
14
|
+
local filterMap = ____array.filterMap
|
|
6
15
|
local ____levelGrid = require("src.functions.levelGrid")
|
|
7
16
|
local getRoomDescriptorsForType = ____levelGrid.getRoomDescriptorsForType
|
|
8
17
|
local isDoorSlotValidAtGridIndexForRedRoom = ____levelGrid.isDoorSlotValidAtGridIndexForRedRoom
|
|
9
18
|
local ____rooms = require("src.functions.rooms")
|
|
10
19
|
local getNumRooms = ____rooms.getNumRooms
|
|
11
20
|
local getRoomsInsideGrid = ____rooms.getRoomsInsideGrid
|
|
12
|
-
--- Helper function to fill every possible square with a red room.
|
|
21
|
+
--- Helper function to fill every possible level grid square with a red room.
|
|
13
22
|
function ____exports.fillLevelWithRedRooms(self)
|
|
14
23
|
local level = game:GetLevel()
|
|
15
24
|
local numRoomsInGrid
|
|
@@ -27,6 +36,32 @@ function ____exports.fillLevelWithRedRooms(self)
|
|
|
27
36
|
end
|
|
28
37
|
until not (numRoomsInGrid ~= getNumRooms(nil))
|
|
29
38
|
end
|
|
39
|
+
--- Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
|
|
40
|
+
-- to the sub-type of the room data.)
|
|
41
|
+
--
|
|
42
|
+
-- Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
|
|
43
|
+
-- rooms will not count.
|
|
44
|
+
function ____exports.getLevelBossIDs(self)
|
|
45
|
+
local roomsInsideGrid = getRoomsInsideGrid(nil)
|
|
46
|
+
return filterMap(
|
|
47
|
+
nil,
|
|
48
|
+
roomsInsideGrid,
|
|
49
|
+
function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomDescriptor.Data.Type == RoomType.BOSS and roomDescriptor.Data.StageID == StageID.SPECIAL_ROOMS and roomDescriptor.Data.Subtype or nil end
|
|
50
|
+
)
|
|
51
|
+
end
|
|
52
|
+
--- Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
|
|
53
|
+
--
|
|
54
|
+
-- This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
|
|
55
|
+
-- It will return true if one or more of the boss IDs are matched.
|
|
56
|
+
function ____exports.levelHasBossID(self, ...)
|
|
57
|
+
local bossIDs = {...}
|
|
58
|
+
local levelBossIDs = ____exports.getLevelBossIDs(nil)
|
|
59
|
+
local levelBossIDsSet = __TS__New(Set, levelBossIDs)
|
|
60
|
+
return __TS__ArraySome(
|
|
61
|
+
bossIDs,
|
|
62
|
+
function(____, bossID) return levelBossIDsSet:has(bossID) end
|
|
63
|
+
)
|
|
64
|
+
end
|
|
30
65
|
--- Helper function to check to see if the current floor has one or more of a specific room type in
|
|
31
66
|
-- it.
|
|
32
67
|
--
|
|
@@ -102,7 +102,7 @@ export declare function getRoomAdjacentGridIndexes(roomGridIndex?: int): Readonl
|
|
|
102
102
|
* Helper function to get an array of all of the room descriptors for rooms that match the specified
|
|
103
103
|
* room type.
|
|
104
104
|
*
|
|
105
|
-
* This function only searches through rooms in the current dimension.
|
|
105
|
+
* This function only searches through rooms in the current dimension and rooms inside the grid.
|
|
106
106
|
*
|
|
107
107
|
* This function is variadic, meaning that you can specify N arguments to get the combined room
|
|
108
108
|
* descriptors for N room types.
|
|
@@ -136,12 +136,12 @@ function ____exports.getNewRoomCandidatesForLevel(self, ensureDeadEnd)
|
|
|
136
136
|
if ensureDeadEnd == nil then
|
|
137
137
|
ensureDeadEnd = true
|
|
138
138
|
end
|
|
139
|
-
local
|
|
139
|
+
local roomsInsideGrid = getRoomsInsideGrid(nil)
|
|
140
140
|
local normalRooms = __TS__ArrayFilter(
|
|
141
|
-
|
|
141
|
+
roomsInsideGrid,
|
|
142
142
|
function(____, room) return room.Data ~= nil and room.Data.Type == RoomType.DEFAULT and not isMirrorRoom(nil, room.Data) and not isMineShaft(nil, room.Data) end
|
|
143
143
|
)
|
|
144
|
-
local roomsToLookThrough = ensureDeadEnd and normalRooms or
|
|
144
|
+
local roomsToLookThrough = ensureDeadEnd and normalRooms or roomsInsideGrid
|
|
145
145
|
local newRoomCandidates = {}
|
|
146
146
|
for ____, room in ipairs(roomsToLookThrough) do
|
|
147
147
|
local newRoomCandidatesBesideRoom = ____exports.getNewRoomCandidatesBesideRoom(nil, room.SafeGridIndex, ensureDeadEnd)
|
|
@@ -324,16 +324,16 @@ end
|
|
|
324
324
|
--- Helper function to get an array of all of the room descriptors for rooms that match the specified
|
|
325
325
|
-- room type.
|
|
326
326
|
--
|
|
327
|
-
-- This function only searches through rooms in the current dimension.
|
|
327
|
+
-- This function only searches through rooms in the current dimension and rooms inside the grid.
|
|
328
328
|
--
|
|
329
329
|
-- This function is variadic, meaning that you can specify N arguments to get the combined room
|
|
330
330
|
-- descriptors for N room types.
|
|
331
331
|
function ____exports.getRoomDescriptorsForType(self, ...)
|
|
332
332
|
local roomTypes = {...}
|
|
333
333
|
local roomTypesSet = __TS__New(Set, roomTypes)
|
|
334
|
-
local
|
|
334
|
+
local roomsInsideGrid = getRoomsInsideGrid(nil)
|
|
335
335
|
return __TS__ArrayFilter(
|
|
336
|
-
|
|
336
|
+
roomsInsideGrid,
|
|
337
337
|
function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypesSet:has(roomDescriptor.Data.Type) end
|
|
338
338
|
)
|
|
339
339
|
end
|
|
@@ -259,8 +259,8 @@ end
|
|
|
259
259
|
--- Helper function to get the number of rooms that are currently on the floor layout. This does not
|
|
260
260
|
-- include off-grid rooms, like the Devil Room.
|
|
261
261
|
function ____exports.getNumRooms(self)
|
|
262
|
-
local
|
|
263
|
-
return #
|
|
262
|
+
local roomsInsideGrid = ____exports.getRoomsInsideGrid(nil)
|
|
263
|
+
return #roomsInsideGrid
|
|
264
264
|
end
|
|
265
265
|
--- Helper function to get the room data for a specific room type and variant combination. This is
|
|
266
266
|
-- accomplished by using the "goto" console command to load the specified room into the
|
|
@@ -507,14 +507,14 @@ function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes, includeSecretAndS
|
|
|
507
507
|
if includeUltraSecretRoom == nil then
|
|
508
508
|
includeUltraSecretRoom = false
|
|
509
509
|
end
|
|
510
|
-
local
|
|
510
|
+
local roomsInsideGrid = ____exports.getRoomsInsideGrid(nil)
|
|
511
511
|
local matchingRooms
|
|
512
512
|
if onlyCheckRoomTypes == nil then
|
|
513
|
-
matchingRooms =
|
|
513
|
+
matchingRooms = roomsInsideGrid
|
|
514
514
|
else
|
|
515
515
|
local roomTypeWhitelist = __TS__New(ReadonlySet, onlyCheckRoomTypes)
|
|
516
516
|
matchingRooms = __TS__ArrayFilter(
|
|
517
|
-
|
|
517
|
+
roomsInsideGrid,
|
|
518
518
|
function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypeWhitelist:has(roomDescriptor.Data.Type) end
|
|
519
519
|
)
|
|
520
520
|
end
|
package/package.json
CHANGED
package/src/functions/level.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { BossID } from "isaac-typescript-definitions";
|
|
2
|
+
import { RoomType, StageID } from "isaac-typescript-definitions";
|
|
2
3
|
import { DOOR_SLOT_VALUES } from "../arrays/cachedEnumValues";
|
|
3
4
|
import { game } from "../core/cachedClasses";
|
|
5
|
+
import { filterMap } from "./array";
|
|
4
6
|
import {
|
|
5
7
|
getRoomDescriptorsForType,
|
|
6
8
|
isDoorSlotValidAtGridIndexForRedRoom,
|
|
7
9
|
} from "./levelGrid";
|
|
8
10
|
import { getNumRooms, getRoomsInsideGrid } from "./rooms";
|
|
9
11
|
|
|
10
|
-
/** Helper function to fill every possible square with a red room. */
|
|
12
|
+
/** Helper function to fill every possible level grid square with a red room. */
|
|
11
13
|
export function fillLevelWithRedRooms(): void {
|
|
12
14
|
const level = game.GetLevel();
|
|
13
15
|
|
|
@@ -31,6 +33,38 @@ export function fillLevelWithRedRooms(): void {
|
|
|
31
33
|
} while (numRoomsInGrid !== getNumRooms());
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
/**
|
|
37
|
+
* Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
|
|
38
|
+
* to the sub-type of the room data.)
|
|
39
|
+
*
|
|
40
|
+
* Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
|
|
41
|
+
* rooms will not count.
|
|
42
|
+
*/
|
|
43
|
+
export function getLevelBossIDs(): BossID[] {
|
|
44
|
+
const roomsInsideGrid = getRoomsInsideGrid();
|
|
45
|
+
|
|
46
|
+
return filterMap(roomsInsideGrid, (roomDescriptor) =>
|
|
47
|
+
roomDescriptor.Data !== undefined &&
|
|
48
|
+
roomDescriptor.Data.Type === RoomType.BOSS &&
|
|
49
|
+
roomDescriptor.Data.StageID === StageID.SPECIAL_ROOMS
|
|
50
|
+
? roomDescriptor.Data.Subtype
|
|
51
|
+
: undefined,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
|
|
57
|
+
*
|
|
58
|
+
* This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
|
|
59
|
+
* It will return true if one or more of the boss IDs are matched.
|
|
60
|
+
*/
|
|
61
|
+
export function levelHasBossID(...bossIDs: BossID[]): boolean {
|
|
62
|
+
const levelBossIDs = getLevelBossIDs();
|
|
63
|
+
const levelBossIDsSet = new Set(levelBossIDs);
|
|
64
|
+
|
|
65
|
+
return bossIDs.some((bossID) => levelBossIDsSet.has(bossID));
|
|
66
|
+
}
|
|
67
|
+
|
|
34
68
|
/**
|
|
35
69
|
* Helper function to check to see if the current floor has one or more of a specific room type in
|
|
36
70
|
* it.
|
|
@@ -231,10 +231,10 @@ export function getNewRoomCandidatesForLevel(
|
|
|
231
231
|
readonly newRoomGridIndex: int;
|
|
232
232
|
}> {
|
|
233
233
|
// We want to iterate over every room on the floor and search for potential new room spots.
|
|
234
|
-
const
|
|
234
|
+
const roomsInsideGrid = getRoomsInsideGrid();
|
|
235
235
|
|
|
236
236
|
// However, we want to filter out special rooms because they are supposed to be dead ends.
|
|
237
|
-
const normalRooms =
|
|
237
|
+
const normalRooms = roomsInsideGrid.filter(
|
|
238
238
|
(room) =>
|
|
239
239
|
room.Data !== undefined &&
|
|
240
240
|
room.Data.Type === RoomType.DEFAULT &&
|
|
@@ -242,7 +242,7 @@ export function getNewRoomCandidatesForLevel(
|
|
|
242
242
|
!isMineShaft(room.Data), // Mineshaft rooms do not count as special rooms.
|
|
243
243
|
);
|
|
244
244
|
|
|
245
|
-
const roomsToLookThrough = ensureDeadEnd ? normalRooms :
|
|
245
|
+
const roomsToLookThrough = ensureDeadEnd ? normalRooms : roomsInsideGrid;
|
|
246
246
|
|
|
247
247
|
const newRoomCandidates: Array<{
|
|
248
248
|
readonly adjacentRoomGridIndex: int;
|
|
@@ -301,7 +301,7 @@ export function getRoomAdjacentGridIndexes(
|
|
|
301
301
|
* Helper function to get an array of all of the room descriptors for rooms that match the specified
|
|
302
302
|
* room type.
|
|
303
303
|
*
|
|
304
|
-
* This function only searches through rooms in the current dimension.
|
|
304
|
+
* This function only searches through rooms in the current dimension and rooms inside the grid.
|
|
305
305
|
*
|
|
306
306
|
* This function is variadic, meaning that you can specify N arguments to get the combined room
|
|
307
307
|
* descriptors for N room types.
|
|
@@ -311,8 +311,8 @@ export function getRoomDescriptorsForType(
|
|
|
311
311
|
): RoomDescriptor[] {
|
|
312
312
|
const roomTypesSet = new Set<RoomType>(roomTypes);
|
|
313
313
|
|
|
314
|
-
const
|
|
315
|
-
return
|
|
314
|
+
const roomsInsideGrid = getRoomsInsideGrid();
|
|
315
|
+
return roomsInsideGrid.filter(
|
|
316
316
|
(roomDescriptor) =>
|
|
317
317
|
roomDescriptor.Data !== undefined &&
|
|
318
318
|
roomTypesSet.has(roomDescriptor.Data.Type),
|
package/src/functions/rooms.ts
CHANGED
|
@@ -82,8 +82,8 @@ export function changeRoom(roomGridIndex: int): void {
|
|
|
82
82
|
* include off-grid rooms, like the Devil Room.
|
|
83
83
|
*/
|
|
84
84
|
export function getNumRooms(): int {
|
|
85
|
-
const
|
|
86
|
-
return
|
|
85
|
+
const roomsInsideGrid = getRoomsInsideGrid();
|
|
86
|
+
return roomsInsideGrid.length;
|
|
87
87
|
}
|
|
88
88
|
|
|
89
89
|
/**
|
|
@@ -199,7 +199,7 @@ export function getRoomTypeName(roomType: RoomType): string {
|
|
|
199
199
|
export function getRooms(
|
|
200
200
|
includeExtraDimensionalRooms = false,
|
|
201
201
|
): RoomDescriptor[] {
|
|
202
|
-
// The
|
|
202
|
+
// The naive way to get all of the rooms would be to iterate over the `RoomList` from the
|
|
203
203
|
// `Level.GetRooms` method. However, this results in read-only data, and we want to return a
|
|
204
204
|
// writable object. Instead, we let the heavy lifting be handled by other functions.
|
|
205
205
|
const roomsInGrid = getRoomsInsideGrid(includeExtraDimensionalRooms);
|
|
@@ -497,14 +497,14 @@ export function isAllRoomsClear(
|
|
|
497
497
|
includeSecretAndSuperSecretRoom = false,
|
|
498
498
|
includeUltraSecretRoom = false,
|
|
499
499
|
): boolean {
|
|
500
|
-
const
|
|
500
|
+
const roomsInsideGrid = getRoomsInsideGrid();
|
|
501
501
|
|
|
502
502
|
let matchingRooms: RoomDescriptor[];
|
|
503
503
|
if (onlyCheckRoomTypes === undefined) {
|
|
504
|
-
matchingRooms =
|
|
504
|
+
matchingRooms = roomsInsideGrid;
|
|
505
505
|
} else {
|
|
506
506
|
const roomTypeWhitelist = new ReadonlySet(onlyCheckRoomTypes);
|
|
507
|
-
matchingRooms =
|
|
507
|
+
matchingRooms = roomsInsideGrid.filter(
|
|
508
508
|
(roomDescriptor) =>
|
|
509
509
|
roomDescriptor.Data !== undefined &&
|
|
510
510
|
roomTypeWhitelist.has(roomDescriptor.Data.Type),
|