isaacscript-common 6.18.0 → 6.20.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.
- package/dist/constants.d.ts +5 -0
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.lua +4 -0
- package/dist/features/customStage/exports.d.ts.map +1 -1
- package/dist/features/customStage/exports.lua +2 -7
- package/dist/features/customTrapdoor/init.d.ts.map +1 -1
- package/dist/features/customTrapdoor/init.lua +10 -2
- package/dist/features/extraConsoleCommands/commandsSubroutines.d.ts.map +1 -1
- package/dist/features/extraConsoleCommands/commandsSubroutines.lua +2 -1
- package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
- package/dist/features/extraConsoleCommands/listCommands.lua +2 -1
- package/dist/features/playerInventory.d.ts.map +1 -1
- package/dist/features/playerInventory.lua +2 -4
- package/dist/functions/curses.d.ts +3 -0
- package/dist/functions/curses.d.ts.map +1 -0
- package/dist/functions/curses.lua +11 -0
- package/dist/functions/dimensions.d.ts +12 -0
- package/dist/functions/dimensions.d.ts.map +1 -0
- package/dist/functions/dimensions.lua +35 -0
- package/dist/functions/eden.d.ts.map +1 -1
- package/dist/functions/eden.lua +2 -4
- package/dist/functions/itemPool.d.ts +18 -0
- package/dist/functions/itemPool.d.ts.map +1 -0
- package/dist/functions/itemPool.lua +133 -0
- package/dist/functions/level.d.ts.map +1 -1
- package/dist/functions/level.lua +8 -7
- package/dist/functions/levelGrid.d.ts +155 -0
- package/dist/functions/levelGrid.d.ts.map +1 -0
- package/dist/functions/levelGrid.lua +349 -0
- package/dist/functions/rockAlt.d.ts +4 -4
- package/dist/functions/rockAlt.d.ts.map +1 -1
- package/dist/functions/rockAlt.lua +69 -20
- package/dist/functions/roomData.d.ts +5 -0
- package/dist/functions/roomData.d.ts.map +1 -1
- package/dist/functions/roomData.lua +6 -0
- package/dist/functions/roomGrid.d.ts +8 -0
- package/dist/functions/roomGrid.d.ts.map +1 -1
- package/dist/functions/rooms.d.ts +42 -61
- package/dist/functions/rooms.d.ts.map +1 -1
- package/dist/functions/rooms.lua +129 -200
- package/dist/functions/saveFile.d.ts +1 -6
- package/dist/functions/saveFile.d.ts.map +1 -1
- package/dist/functions/saveFile.lua +4 -113
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +32 -0
- package/package.json +2 -2
- package/src/constants.ts +8 -0
- package/src/features/customStage/exports.ts +10 -11
- package/src/features/customTrapdoor/init.ts +7 -3
- package/src/features/extraConsoleCommands/commandsSubroutines.ts +2 -1
- package/src/features/extraConsoleCommands/listCommands.ts +2 -1
- package/src/features/playerInventory.ts +2 -3
- package/src/functions/curses.ts +9 -0
- package/src/functions/dimensions.ts +41 -0
- package/src/functions/eden.ts +2 -4
- package/src/functions/itemPool.ts +178 -0
- package/src/functions/level.ts +7 -10
- package/src/functions/levelGrid.ts +468 -0
- package/src/functions/rockAlt.ts +111 -29
- package/src/functions/roomData.ts +12 -0
- package/src/functions/roomGrid.ts +9 -0
- package/src/functions/rooms.ts +93 -206
- package/src/functions/saveFile.ts +5 -147
- package/src/index.ts +4 -0
package/dist/functions/rooms.lua
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local
|
|
3
|
-
local Set = ____lualib.Set
|
|
2
|
+
local Map = ____lualib.Map
|
|
4
3
|
local __TS__New = ____lualib.__TS__New
|
|
5
|
-
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
6
4
|
local __TS__Spread = ____lualib.__TS__Spread
|
|
7
|
-
local
|
|
5
|
+
local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
|
|
8
6
|
local __TS__StringIncludes = ____lualib.__TS__StringIncludes
|
|
7
|
+
local Set = ____lualib.Set
|
|
9
8
|
local __TS__ArrayEvery = ____lualib.__TS__ArrayEvery
|
|
10
9
|
local ____exports = {}
|
|
11
10
|
local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
|
|
@@ -16,6 +15,7 @@ local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
|
|
|
16
15
|
local DungeonSubType = ____isaac_2Dtypescript_2Ddefinitions.DungeonSubType
|
|
17
16
|
local GridRoom = ____isaac_2Dtypescript_2Ddefinitions.GridRoom
|
|
18
17
|
local HomeRoomSubType = ____isaac_2Dtypescript_2Ddefinitions.HomeRoomSubType
|
|
18
|
+
local LevelCurse = ____isaac_2Dtypescript_2Ddefinitions.LevelCurse
|
|
19
19
|
local RoomDescriptorFlag = ____isaac_2Dtypescript_2Ddefinitions.RoomDescriptorFlag
|
|
20
20
|
local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
|
|
21
21
|
local RoomTransitionAnim = ____isaac_2Dtypescript_2Ddefinitions.RoomTransitionAnim
|
|
@@ -26,15 +26,15 @@ local ____cachedClasses = require("cachedClasses")
|
|
|
26
26
|
local game = ____cachedClasses.game
|
|
27
27
|
local sfxManager = ____cachedClasses.sfxManager
|
|
28
28
|
local ____constants = require("constants")
|
|
29
|
-
local LEVEL_GRID_ROW_WIDTH = ____constants.LEVEL_GRID_ROW_WIDTH
|
|
30
29
|
local MAX_LEVEL_GRID_INDEX = ____constants.MAX_LEVEL_GRID_INDEX
|
|
31
|
-
local NUM_DIMENSIONS = ____constants.NUM_DIMENSIONS
|
|
32
|
-
local ____roomShapeToDoorSlotsToGridIndexDelta = require("objects.roomShapeToDoorSlotsToGridIndexDelta")
|
|
33
|
-
local ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA = ____roomShapeToDoorSlotsToGridIndexDelta.ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA
|
|
34
30
|
local ____roomTypeNames = require("objects.roomTypeNames")
|
|
35
31
|
local ROOM_TYPE_NAMES = ____roomTypeNames.ROOM_TYPE_NAMES
|
|
36
32
|
local ____mineShaftRoomSubTypesSet = require("sets.mineShaftRoomSubTypesSet")
|
|
37
33
|
local MINE_SHAFT_ROOM_SUB_TYPE_SET = ____mineShaftRoomSubTypesSet.MINE_SHAFT_ROOM_SUB_TYPE_SET
|
|
34
|
+
local ____curses = require("functions.curses")
|
|
35
|
+
local hasCurse = ____curses.hasCurse
|
|
36
|
+
local ____dimensions = require("functions.dimensions")
|
|
37
|
+
local inDimension = ____dimensions.inDimension
|
|
38
38
|
local ____doors = require("functions.doors")
|
|
39
39
|
local closeAllDoors = ____doors.closeAllDoors
|
|
40
40
|
local getDoors = ____doors.getDoors
|
|
@@ -50,26 +50,22 @@ local getEntityVelocities = ____positionVelocity.getEntityVelocities
|
|
|
50
50
|
local setEntityPositions = ____positionVelocity.setEntityPositions
|
|
51
51
|
local setEntityVelocities = ____positionVelocity.setEntityVelocities
|
|
52
52
|
local ____roomData = require("functions.roomData")
|
|
53
|
-
local getRoomAllowedDoors = ____roomData.getRoomAllowedDoors
|
|
54
53
|
local getRoomData = ____roomData.getRoomData
|
|
55
|
-
local getRoomDescriptor = ____roomData.getRoomDescriptor
|
|
56
54
|
local getRoomDescriptorReadOnly = ____roomData.getRoomDescriptorReadOnly
|
|
57
55
|
local getRoomGridIndex = ____roomData.getRoomGridIndex
|
|
58
56
|
local getRoomName = ____roomData.getRoomName
|
|
59
|
-
local getRoomShape = ____roomData.getRoomShape
|
|
60
57
|
local getRoomStageID = ____roomData.getRoomStageID
|
|
61
58
|
local getRoomSubType = ____roomData.getRoomSubType
|
|
62
|
-
local
|
|
63
|
-
local
|
|
59
|
+
local ____stage = require("functions.stage")
|
|
60
|
+
local getGotoCommand = ____stage.getGotoCommand
|
|
64
61
|
local ____utils = require("functions.utils")
|
|
65
|
-
local erange = ____utils.erange
|
|
66
62
|
local irange = ____utils.irange
|
|
67
|
-
function
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
--
|
|
72
|
-
-- non-existent and are not added to the list.
|
|
63
|
+
--- Helper function to get the room descriptor for every room on the level. This includes off-grid
|
|
64
|
+
-- rooms, such as the Devil Room. (Off-grid rooms will only be included if they the data exists,
|
|
65
|
+
-- which only usually happens once they have been visited at least once.)
|
|
66
|
+
--
|
|
67
|
+
-- Under the hood, this function uses the `Level.GetRooms` method to accomplish this. Rooms without
|
|
68
|
+
-- data are assumed to be non-existent and are not added to the list.
|
|
73
69
|
--
|
|
74
70
|
-- @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
|
|
75
71
|
-- extra-dimensional rooms are automatically generated and can be
|
|
@@ -80,32 +76,84 @@ function ____exports.getRooms(self, includeExtraDimensionalRooms)
|
|
|
80
76
|
end
|
|
81
77
|
local level = game:GetLevel()
|
|
82
78
|
local roomList = level:GetRooms()
|
|
79
|
+
--- Indexed by room safe grid index. We use a map to avoid adding extra dimensional rooms.
|
|
83
80
|
local roomsMap = __TS__New(Map)
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
do
|
|
82
|
+
local i = 0
|
|
83
|
+
while i < roomList.Size do
|
|
84
|
+
do
|
|
88
85
|
local roomDescriptor = roomList:Get(i)
|
|
89
|
-
if roomDescriptor
|
|
90
|
-
|
|
86
|
+
if roomDescriptor == nil or roomDescriptor.Data == nil then
|
|
87
|
+
goto __continue10
|
|
91
88
|
end
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
for ____, roomGridIndex in ipairs(irange(nil, MAX_LEVEL_GRID_INDEX)) do
|
|
97
|
-
local roomDescriptor = level:GetRoomByIdx(roomGridIndex)
|
|
98
|
-
if roomDescriptor.Data ~= nil then
|
|
99
|
-
roomsMap:set(roomDescriptor.ListIndex, roomDescriptor)
|
|
89
|
+
if not includeExtraDimensionalRooms and roomsMap:has(roomDescriptor.SafeGridIndex) then
|
|
90
|
+
goto __continue10
|
|
91
|
+
end
|
|
92
|
+
roomsMap:set(roomDescriptor.SafeGridIndex, roomDescriptor)
|
|
100
93
|
end
|
|
94
|
+
::__continue10::
|
|
95
|
+
i = i + 1
|
|
101
96
|
end
|
|
102
97
|
end
|
|
103
98
|
return {__TS__Spread(roomsMap:values())}
|
|
104
99
|
end
|
|
105
|
-
--- Helper function to
|
|
106
|
-
|
|
100
|
+
--- Helper function to get the room descriptor for every room on the level except for rooms that are
|
|
101
|
+
-- not on the grid.
|
|
102
|
+
--
|
|
103
|
+
-- Under the hood, this function uses the `Level.GetRooms` method to accomplish this. Rooms without
|
|
104
|
+
-- data are assumed to be non-existent and are not added to the list.
|
|
105
|
+
--
|
|
106
|
+
-- @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
|
|
107
|
+
-- extra-dimensional rooms are automatically be generated and can be
|
|
108
|
+
-- seen when you iterate over the `RoomList`. Default is false.
|
|
109
|
+
function ____exports.getRoomsInGrid(self, includeExtraDimensionalRooms)
|
|
110
|
+
if includeExtraDimensionalRooms == nil then
|
|
111
|
+
includeExtraDimensionalRooms = false
|
|
112
|
+
end
|
|
113
|
+
local rooms = ____exports.getRooms(nil, includeExtraDimensionalRooms)
|
|
114
|
+
return __TS__ArrayFilter(
|
|
115
|
+
rooms,
|
|
116
|
+
function(____, roomDescriptor) return roomDescriptor.SafeGridIndex >= 0 end
|
|
117
|
+
)
|
|
118
|
+
end
|
|
119
|
+
--- Helper function to change the current room. It can be used for both teleportation and "normal"
|
|
120
|
+
-- room transitions, depending on what is passed for the `direction` and `roomTransitionAnim`
|
|
121
|
+
-- arguments.
|
|
122
|
+
--
|
|
123
|
+
-- Use this function instead of invoking the `Game.StartRoomTransition` method directly so that:
|
|
124
|
+
-- - you do not forget to set `Level.LeaveDoor` property
|
|
125
|
+
-- - to prevent crashing on invalid room grid indexes
|
|
126
|
+
-- - to automatically handle Curse of the Maze
|
|
127
|
+
--
|
|
128
|
+
-- @param roomGridIndex The room grid index of the destination room.
|
|
129
|
+
-- @param direction Optional. Default is `Direction.NO_DIRECTION`.
|
|
130
|
+
-- @param roomTransitionAnim Optional. Default is `RoomTransitionAnim.TELEPORT`.
|
|
131
|
+
-- @param force Optional. Whether to temporarily disable Curse of the Maze. Default is false. If set
|
|
132
|
+
-- to false, then this function may not go to the provided room grid index.
|
|
133
|
+
function ____exports.teleport(self, roomGridIndex, direction, roomTransitionAnim, force)
|
|
134
|
+
if direction == nil then
|
|
135
|
+
direction = Direction.NO_DIRECTION
|
|
136
|
+
end
|
|
137
|
+
if roomTransitionAnim == nil then
|
|
138
|
+
roomTransitionAnim = RoomTransitionAnim.TELEPORT
|
|
139
|
+
end
|
|
140
|
+
if force == nil then
|
|
141
|
+
force = false
|
|
142
|
+
end
|
|
143
|
+
local level = game:GetLevel()
|
|
144
|
+
local shouldTempDisableCurse = force and hasCurse(nil, LevelCurse.MAZE)
|
|
145
|
+
if shouldTempDisableCurse then
|
|
146
|
+
level:RemoveCurses(LevelCurse.MAZE)
|
|
147
|
+
end
|
|
107
148
|
local roomData = getRoomData(nil, roomGridIndex)
|
|
108
|
-
|
|
149
|
+
if roomData == nil then
|
|
150
|
+
error(("Failed to change the room to grid index " .. tostring(roomGridIndex)) .. " because that room does not exist.")
|
|
151
|
+
end
|
|
152
|
+
level.LeaveDoor = DoorSlot.NO_DOOR_SLOT
|
|
153
|
+
game:StartRoomTransition(roomGridIndex, direction, roomTransitionAnim)
|
|
154
|
+
if shouldTempDisableCurse then
|
|
155
|
+
level:AddCurse(LevelCurse.MAZE, false)
|
|
156
|
+
end
|
|
109
157
|
end
|
|
110
158
|
--- Helper function for quickly switching to a new room without playing a particular animation. Use
|
|
111
159
|
-- this helper function over invoking the `Game.ChangeRoom` method directly to ensure that you do
|
|
@@ -119,58 +167,49 @@ function ____exports.changeRoom(self, roomGridIndex)
|
|
|
119
167
|
level.LeaveDoor = DoorSlot.NO_DOOR_SLOT
|
|
120
168
|
game:ChangeRoom(roomGridIndex)
|
|
121
169
|
end
|
|
122
|
-
--- Helper function to get an array with every valid `Dimension` (not including `Dimension.CURRENT`).
|
|
123
|
-
function ____exports.getAllDimensions(self)
|
|
124
|
-
return erange(nil, NUM_DIMENSIONS)
|
|
125
|
-
end
|
|
126
|
-
--- Helper function to get the grid index for every room on the entire floor.
|
|
127
|
-
function ____exports.getAllRoomGridIndexes(self)
|
|
128
|
-
local rooms = ____exports.getRooms(nil)
|
|
129
|
-
return __TS__ArrayMap(
|
|
130
|
-
rooms,
|
|
131
|
-
function(____, roomDescriptor) return roomDescriptor.SafeGridIndex end
|
|
132
|
-
)
|
|
133
|
-
end
|
|
134
|
-
--- Helper function to get the current dimension. Most of the time, this will be `Dimension.MAIN`,
|
|
135
|
-
-- but it can change if e.g. the player is in the mirror world of Downpour/Dross.
|
|
136
|
-
function ____exports.getDimension(self)
|
|
137
|
-
local level = game:GetLevel()
|
|
138
|
-
local roomGridIndex = getRoomGridIndex(nil)
|
|
139
|
-
local roomDescription = level:GetRoomByIdx(roomGridIndex, Dimension.CURRENT)
|
|
140
|
-
local currentRoomHash = GetPtrHash(roomDescription)
|
|
141
|
-
for ____, dimension in ipairs(____exports.getAllDimensions(nil)) do
|
|
142
|
-
local dimensionRoomDescription = level:GetRoomByIdx(roomGridIndex, dimension)
|
|
143
|
-
local dimensionRoomHash = GetPtrHash(dimensionRoomDescription)
|
|
144
|
-
if dimensionRoomHash == currentRoomHash then
|
|
145
|
-
return dimension
|
|
146
|
-
end
|
|
147
|
-
end
|
|
148
|
-
error("Failed to get the current dimension.")
|
|
149
|
-
end
|
|
150
170
|
--- Helper function to get the number of rooms that are currently on the floor layout. This does not
|
|
151
171
|
-- include off-grid rooms, like the Devil Room.
|
|
152
172
|
function ____exports.getNumRooms(self)
|
|
153
|
-
local rooms = ____exports.
|
|
173
|
+
local rooms = ____exports.getRoomsInGrid(nil)
|
|
154
174
|
return #rooms
|
|
155
175
|
end
|
|
156
|
-
--- Helper function to get
|
|
157
|
-
-- specified room
|
|
176
|
+
--- Helper function to get the room data for a specific room type and variant combination. This is
|
|
177
|
+
-- accomplished by using the "goto" console command to load the specified room into the
|
|
178
|
+
-- `GridRoom.DEBUG` slot.
|
|
158
179
|
--
|
|
159
|
-
--
|
|
180
|
+
-- Returns undefined if the provided room type and variant combination were not found. (A warning
|
|
181
|
+
-- message will also appear on the console, since the "goto" command will fail.)
|
|
160
182
|
--
|
|
161
|
-
--
|
|
162
|
-
--
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
183
|
+
-- Note that the side effect of using the "goto" console command is that it will trigger a room
|
|
184
|
+
-- transition after a short delay. By default, this function cancels the incoming room transition by
|
|
185
|
+
-- using the `Game.StartRoomTransition` method to travel to the same room.
|
|
186
|
+
--
|
|
187
|
+
-- @param roomType The type of room to retrieve.
|
|
188
|
+
-- @param roomVariant The room variant to retrieve. (The room variant is the "ID" of the room in
|
|
189
|
+
-- Basement Renovator.)
|
|
190
|
+
-- @param cancelRoomTransition Optional. Whether to cancel the room transition by using the
|
|
191
|
+
-- `Game.StartRoomTransition` method to travel to the same room. Default
|
|
192
|
+
-- is true. Set this to false if you are getting the data for many rooms
|
|
193
|
+
-- at the same time, and then use the `teleport` helper function when
|
|
194
|
+
-- you are finished.
|
|
195
|
+
function ____exports.getRoomDataForTypeVariant(self, roomType, roomVariant, cancelRoomTransition)
|
|
196
|
+
if cancelRoomTransition == nil then
|
|
197
|
+
cancelRoomTransition = true
|
|
198
|
+
end
|
|
199
|
+
local command = getGotoCommand(nil, roomType, roomVariant)
|
|
200
|
+
Isaac.ExecuteCommand(command)
|
|
201
|
+
local newRoomData = getRoomData(nil, GridRoom.DEBUG)
|
|
202
|
+
if cancelRoomTransition then
|
|
203
|
+
local roomGridIndex = getRoomGridIndex(nil)
|
|
204
|
+
____exports.teleport(
|
|
205
|
+
nil,
|
|
206
|
+
roomGridIndex,
|
|
207
|
+
Direction.NO_DIRECTION,
|
|
208
|
+
RoomTransitionAnim.FADE,
|
|
209
|
+
true
|
|
210
|
+
)
|
|
211
|
+
end
|
|
212
|
+
return newRoomData
|
|
174
213
|
end
|
|
175
214
|
--- Helper function to get the item pool type for the current room. For example, this returns
|
|
176
215
|
-- `ItemPoolType.ItemPoolType.POOL_ANGEL` if you are in an Angel Room.
|
|
@@ -181,59 +220,22 @@ function ____exports.getRoomItemPoolType(self)
|
|
|
181
220
|
local roomSeed = room:GetSpawnSeed()
|
|
182
221
|
return itemPool:GetPoolForRoom(roomType, roomSeed)
|
|
183
222
|
end
|
|
184
|
-
--- Helper function to get the grid indexes of all the rooms connected to the given room index.
|
|
185
|
-
--
|
|
186
|
-
-- @param roomGridIndex Optional. Default is the current room index.
|
|
187
|
-
function ____exports.getRoomNeighbors(self, roomGridIndex)
|
|
188
|
-
local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
|
|
189
|
-
if roomDescriptor.SafeGridIndex < 0 or roomDescriptor.SafeGridIndex > MAX_LEVEL_GRID_INDEX then
|
|
190
|
-
return {}
|
|
191
|
-
end
|
|
192
|
-
local roomData = roomDescriptor.Data
|
|
193
|
-
if roomData == nil then
|
|
194
|
-
return {}
|
|
195
|
-
end
|
|
196
|
-
local roomShape = roomData.Shape
|
|
197
|
-
local gridIndexDeltas = ____exports.getRoomShapeNeighborGridIndexDeltas(nil, roomShape)
|
|
198
|
-
local gridIndexes = __TS__ArrayMap(
|
|
199
|
-
gridIndexDeltas,
|
|
200
|
-
function(____, gridIndexDelta) return roomDescriptor.SafeGridIndex + gridIndexDelta end
|
|
201
|
-
)
|
|
202
|
-
return __TS__ArrayFilter(
|
|
203
|
-
gridIndexes,
|
|
204
|
-
function(____, gridIndex) return ____exports.roomExists(nil, gridIndex) end
|
|
205
|
-
)
|
|
206
|
-
end
|
|
207
223
|
--- Helper function to get the proper name of a room type.
|
|
208
224
|
--
|
|
209
225
|
-- For example, `RoomType.TREASURE` will return "Treasure Room".
|
|
210
226
|
function ____exports.getRoomTypeName(self, roomType)
|
|
211
227
|
return ROOM_TYPE_NAMES[roomType]
|
|
212
228
|
end
|
|
213
|
-
--- Helper function to get the room descriptor for every room on the level except for rooms that are
|
|
214
|
-
-- not on the grid. Uses the `Level.GetRooms` method to accomplish this. Rooms without data are
|
|
215
|
-
-- assumed to be non-existent and are not added to the list.
|
|
216
|
-
--
|
|
217
|
-
-- @param includeExtraDimensionalRooms Optional. On some floors (e.g. Downpour 2, Mines 2),
|
|
218
|
-
-- extra-dimensional rooms are automatically be generated and can be
|
|
219
|
-
-- seen when you iterate over the `RoomList`. Default is false.
|
|
220
|
-
function ____exports.getRoomsInGrid(self, includeExtraDimensionalRooms)
|
|
221
|
-
if includeExtraDimensionalRooms == nil then
|
|
222
|
-
includeExtraDimensionalRooms = false
|
|
223
|
-
end
|
|
224
|
-
local rooms = ____exports.getRooms(nil, includeExtraDimensionalRooms)
|
|
225
|
-
return __TS__ArrayFilter(
|
|
226
|
-
rooms,
|
|
227
|
-
function(____, roomDescriptor) return roomDescriptor.SafeGridIndex >= 0 end
|
|
228
|
-
)
|
|
229
|
-
end
|
|
230
229
|
--- Helper function to get the room descriptor for every room on the level in a specific dimension.
|
|
231
|
-
--
|
|
232
|
-
--
|
|
230
|
+
-- This will not include any off-grid rooms, such as the Devil Room.
|
|
231
|
+
--
|
|
232
|
+
-- Under the hood, this function uses the `Level.GetRooms` method to accomplish this. Rooms without
|
|
233
|
+
-- data are assumed to be non-existent and are not added to the list.
|
|
233
234
|
--
|
|
234
235
|
-- @returns A map of room ListIndex to RoomDescriptor.
|
|
235
236
|
function ____exports.getRoomsOfDimension(self, dimension)
|
|
236
237
|
local level = game:GetLevel()
|
|
238
|
+
--- We use a map instead of an array because room shapes occupy more than one room grid index.
|
|
237
239
|
local roomsMap = __TS__New(Map)
|
|
238
240
|
for ____, roomGridIndex in ipairs(irange(nil, MAX_LEVEL_GRID_INDEX)) do
|
|
239
241
|
local roomDescriptor = level:GetRoomByIdx(roomGridIndex, dimension)
|
|
@@ -294,9 +296,6 @@ function ____exports.inDevilsCrownTreasureRoom(self)
|
|
|
294
296
|
local roomDescriptor = getRoomDescriptorReadOnly(nil)
|
|
295
297
|
return hasFlag(nil, roomDescriptor.Flags, RoomDescriptorFlag.DEVIL_TREASURE)
|
|
296
298
|
end
|
|
297
|
-
function ____exports.inDimension(self, dimension)
|
|
298
|
-
return dimension == ____exports.getDimension(nil)
|
|
299
|
-
end
|
|
300
299
|
function ____exports.inDoubleTrouble(self)
|
|
301
300
|
local room = game:GetRoom()
|
|
302
301
|
local roomType = room:GetType()
|
|
@@ -349,7 +348,7 @@ function ____exports.inStartingRoom(self)
|
|
|
349
348
|
local level = game:GetLevel()
|
|
350
349
|
local startingRoomGridIndex = level:GetStartingRoomIndex()
|
|
351
350
|
local roomGridIndex = getRoomGridIndex(nil)
|
|
352
|
-
return roomGridIndex == startingRoomGridIndex and
|
|
351
|
+
return roomGridIndex == startingRoomGridIndex and inDimension(nil, Dimension.MAIN)
|
|
353
352
|
end
|
|
354
353
|
--- Helper function to loop through every room on the floor and see if it has been cleared.
|
|
355
354
|
--
|
|
@@ -376,52 +375,6 @@ function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes)
|
|
|
376
375
|
function(____, roomDescriptor) return roomDescriptor.Clear end
|
|
377
376
|
)
|
|
378
377
|
end
|
|
379
|
-
function ____exports.isDoorSlotValidAtGridIndex(self, doorSlot, roomGridIndex)
|
|
380
|
-
local allowedDoors = getRoomAllowedDoors(nil, roomGridIndex)
|
|
381
|
-
return allowedDoors:has(doorSlot)
|
|
382
|
-
end
|
|
383
|
-
function ____exports.isDoorSlotValidAtGridIndexForRedRoom(self, doorSlot, roomGridIndex)
|
|
384
|
-
local doorSlotValidAtGridIndex = ____exports.isDoorSlotValidAtGridIndex(nil, doorSlot, roomGridIndex)
|
|
385
|
-
if not doorSlotValidAtGridIndex then
|
|
386
|
-
return false
|
|
387
|
-
end
|
|
388
|
-
local roomShape = getRoomShape(nil, roomGridIndex)
|
|
389
|
-
if roomShape == nil then
|
|
390
|
-
return false
|
|
391
|
-
end
|
|
392
|
-
local delta = getGridIndexDelta(nil, roomShape, doorSlot)
|
|
393
|
-
if delta == nil then
|
|
394
|
-
return false
|
|
395
|
-
end
|
|
396
|
-
local redRoomGridIndex = roomGridIndex + delta
|
|
397
|
-
return not ____exports.roomExists(nil, redRoomGridIndex) and redRoomGridIndex >= 0 and redRoomGridIndex <= MAX_LEVEL_GRID_INDEX
|
|
398
|
-
end
|
|
399
|
-
--- Helper function to detect if the provided room was created by the Red Key item. Under the hood,
|
|
400
|
-
-- this checks for the `RoomDescriptorFlag.FLAG_RED_ROOM` flag.
|
|
401
|
-
--
|
|
402
|
-
-- @param roomGridIndex Optional. Default is the current room index.
|
|
403
|
-
function ____exports.isRedKeyRoom(self, roomGridIndex)
|
|
404
|
-
local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
|
|
405
|
-
return hasFlag(nil, roomDescriptor.Flags, RoomDescriptorFlag.RED_ROOM)
|
|
406
|
-
end
|
|
407
|
-
--- Helper function to determine if the provided room is part of the floor layout. For example, Devil
|
|
408
|
-
-- Rooms and the Mega Satan room are not considered to be inside the map.
|
|
409
|
-
--
|
|
410
|
-
-- @param roomGridIndex Optional. Default is the current room index.
|
|
411
|
-
function ____exports.isRoomInsideMap(self, roomGridIndex)
|
|
412
|
-
if roomGridIndex == nil then
|
|
413
|
-
roomGridIndex = getRoomGridIndex(nil)
|
|
414
|
-
end
|
|
415
|
-
return roomGridIndex >= 0
|
|
416
|
-
end
|
|
417
|
-
--- Helper function to get the coordinates of a given grid index. The floor is represented by a 13x13
|
|
418
|
-
-- grid. For example, since the starting room is in the center, the starting room grid index of 84
|
|
419
|
-
-- be equal to coordinates of (?, ?).
|
|
420
|
-
function ____exports.roomGridIndexToXY(self, roomGridIndex)
|
|
421
|
-
local x = roomGridIndex % LEVEL_GRID_ROW_WIDTH
|
|
422
|
-
local y = math.floor(roomGridIndex / LEVEL_GRID_ROW_WIDTH)
|
|
423
|
-
return {x, y}
|
|
424
|
-
end
|
|
425
378
|
--- If the `Room.Update` method is called in a `POST_NEW_ROOM` callback, then some entities will
|
|
426
379
|
-- slide around (such as the player). Since those entity velocities are already at zero, setting
|
|
427
380
|
-- them to zero will have no effect. Thus, a generic solution is to record all of the entity
|
|
@@ -448,12 +401,12 @@ function ____exports.setRoomCleared(self)
|
|
|
448
401
|
for ____, door in ipairs(getDoors(nil)) do
|
|
449
402
|
do
|
|
450
403
|
if isHiddenSecretRoomDoor(nil, door) then
|
|
451
|
-
goto
|
|
404
|
+
goto __continue40
|
|
452
405
|
end
|
|
453
406
|
openDoorFast(nil, door)
|
|
454
407
|
door.ExtraVisible = false
|
|
455
408
|
end
|
|
456
|
-
::
|
|
409
|
+
::__continue40::
|
|
457
410
|
end
|
|
458
411
|
sfxManager:Stop(SoundEffect.DOOR_HEAVY_OPEN)
|
|
459
412
|
game:ShakeScreen(0)
|
|
@@ -465,28 +418,4 @@ function ____exports.setRoomUncleared(self)
|
|
|
465
418
|
room:SetClear(false)
|
|
466
419
|
closeAllDoors(nil)
|
|
467
420
|
end
|
|
468
|
-
--- Helper function to change the current room. It can be used for both teleportation and "normal"
|
|
469
|
-
-- room transitions, depending on what is passed for the `direction` and `roomTransitionAnim`
|
|
470
|
-
-- arguments. Use this function instead of invoking the `Game.StartRoomTransition` method directly
|
|
471
|
-
-- so that you do not forget to set `Level.LeaveDoor` property and to prevent crashing on invalid
|
|
472
|
-
-- room grid indexes.
|
|
473
|
-
--
|
|
474
|
-
-- @param roomGridIndex The room grid index of the destination room.
|
|
475
|
-
-- @param direction Optional. Default is `Direction.NO_DIRECTION`.
|
|
476
|
-
-- @param roomTransitionAnim Optional. Default is `RoomTransitionAnim.TELEPORT`.
|
|
477
|
-
function ____exports.teleport(self, roomGridIndex, direction, roomTransitionAnim)
|
|
478
|
-
if direction == nil then
|
|
479
|
-
direction = Direction.NO_DIRECTION
|
|
480
|
-
end
|
|
481
|
-
if roomTransitionAnim == nil then
|
|
482
|
-
roomTransitionAnim = RoomTransitionAnim.TELEPORT
|
|
483
|
-
end
|
|
484
|
-
local level = game:GetLevel()
|
|
485
|
-
local roomData = getRoomData(nil, roomGridIndex)
|
|
486
|
-
if roomData == nil then
|
|
487
|
-
error(("Failed to change the room to grid index " .. tostring(roomGridIndex)) .. " because that room does not exist.")
|
|
488
|
-
end
|
|
489
|
-
level.LeaveDoor = DoorSlot.NO_DOOR_SLOT
|
|
490
|
-
game:StartRoomTransition(roomGridIndex, direction, roomTransitionAnim)
|
|
491
|
-
end
|
|
492
421
|
return ____exports
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CollectibleType, ItemPoolType } from "isaac-typescript-definitions";
|
|
2
2
|
/**
|
|
3
3
|
* Helper function to see if the given collectible is unlocked on the current save file. This
|
|
4
|
-
* requires providing the corresponding item pool that the collectible is located in.
|
|
4
|
+
* requires providing the corresponding item pool that the collectible is normally located in.
|
|
5
5
|
*
|
|
6
6
|
* - If any player currently has the collectible, then it is assumed to be unlocked. (This is
|
|
7
7
|
* because in almost all cases, when a collectible is added to a player's inventory, it is
|
|
@@ -12,11 +12,6 @@ import { CollectibleType, ItemPoolType } from "isaac-typescript-definitions";
|
|
|
12
12
|
* - If the collectible is non-offensive, any Tainted Losts will be temporarily changed to Isaac and
|
|
13
13
|
* then changed back. (This is because Tainted Lost is not able to retrieve non-offensive
|
|
14
14
|
* collectibles from item pools).
|
|
15
|
-
*
|
|
16
|
-
* Under the hood, this function works by using the `ItemPool.AddRoomBlacklist` method to blacklist
|
|
17
|
-
* every collectible except for the one provided. Unfortunately, this is not a general-purpose
|
|
18
|
-
* "isCollectibleInItemPool" algorithm, because when a pool is depleted, it will automatically pull
|
|
19
|
-
* items from the Treasure Room pool, and there is no way to distinguish when this happens.
|
|
20
15
|
*/
|
|
21
16
|
export declare function isCollectibleUnlocked(collectibleType: CollectibleType, itemPoolType: ItemPoolType): boolean;
|
|
22
17
|
//# sourceMappingURL=saveFile.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"saveFile.d.ts","sourceRoot":"","sources":["../../src/functions/saveFile.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"saveFile.d.ts","sourceRoot":"","sources":["../../src/functions/saveFile.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAI7E;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB,CACnC,eAAe,EAAE,eAAe,EAChC,YAAY,EAAE,YAAY,GACzB,OAAO,CAMT"}
|
|
@@ -1,87 +1,10 @@
|
|
|
1
|
-
local ____lualib = require("lualib_bundle")
|
|
2
|
-
local Map = ____lualib.Map
|
|
3
|
-
local __TS__Iterator = ____lualib.__TS__Iterator
|
|
4
|
-
local __TS__New = ____lualib.__TS__New
|
|
5
1
|
local ____exports = {}
|
|
6
|
-
local
|
|
7
|
-
local
|
|
8
|
-
local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
|
|
9
|
-
local ItemConfigTag = ____isaac_2Dtypescript_2Ddefinitions.ItemConfigTag
|
|
10
|
-
local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
|
|
11
|
-
local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
|
|
12
|
-
local ____cachedClasses = require("cachedClasses")
|
|
13
|
-
local game = ____cachedClasses.game
|
|
14
|
-
local ____collectibleSet = require("functions.collectibleSet")
|
|
15
|
-
local getCollectibleSet = ____collectibleSet.getCollectibleSet
|
|
16
|
-
local ____collectibleTag = require("functions.collectibleTag")
|
|
17
|
-
local collectibleHasTag = ____collectibleTag.collectibleHasTag
|
|
18
|
-
local ____playerDataStructures = require("functions.playerDataStructures")
|
|
19
|
-
local mapGetPlayer = ____playerDataStructures.mapGetPlayer
|
|
20
|
-
local mapSetPlayer = ____playerDataStructures.mapSetPlayer
|
|
21
|
-
local ____playerIndex = require("functions.playerIndex")
|
|
22
|
-
local getPlayers = ____playerIndex.getPlayers
|
|
2
|
+
local ____itemPool = require("functions.itemPool")
|
|
3
|
+
local isCollectibleInItemPool = ____itemPool.isCollectibleInItemPool
|
|
23
4
|
local ____players = require("functions.players")
|
|
24
5
|
local anyPlayerHasCollectible = ____players.anyPlayerHasCollectible
|
|
25
|
-
local getPlayersOfType = ____players.getPlayersOfType
|
|
26
|
-
local ____utils = require("functions.utils")
|
|
27
|
-
local ____repeat = ____utils["repeat"]
|
|
28
|
-
function removeItemsAndTrinketsThatAffectItemPools(self)
|
|
29
|
-
local removedItemsMap = __TS__New(Map)
|
|
30
|
-
local removedTrinketsMap = __TS__New(Map)
|
|
31
|
-
for ____, player in ipairs(getPlayers(nil)) do
|
|
32
|
-
local removedItems = {}
|
|
33
|
-
for ____, itemToRemove in ipairs(COLLECTIBLES_THAT_AFFECT_ITEM_POOLS) do
|
|
34
|
-
if player:HasCollectible(itemToRemove) then
|
|
35
|
-
local numCollectibles = player:GetCollectibleNum(itemToRemove)
|
|
36
|
-
____repeat(
|
|
37
|
-
nil,
|
|
38
|
-
numCollectibles,
|
|
39
|
-
function()
|
|
40
|
-
player:RemoveCollectible(itemToRemove)
|
|
41
|
-
removedItems[#removedItems + 1] = itemToRemove
|
|
42
|
-
end
|
|
43
|
-
)
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
mapSetPlayer(nil, removedItemsMap, player, removedItems)
|
|
47
|
-
local removedTrinkets = {}
|
|
48
|
-
for ____, trinketToRemove in ipairs(TRINKETS_THAT_AFFECT_ITEM_POOLS) do
|
|
49
|
-
if player:HasTrinket(trinketToRemove) then
|
|
50
|
-
local numTrinkets = player:GetTrinketMultiplier(trinketToRemove)
|
|
51
|
-
____repeat(
|
|
52
|
-
nil,
|
|
53
|
-
numTrinkets,
|
|
54
|
-
function()
|
|
55
|
-
player:TryRemoveTrinket(trinketToRemove)
|
|
56
|
-
removedTrinkets[#removedTrinkets + 1] = trinketToRemove
|
|
57
|
-
end
|
|
58
|
-
)
|
|
59
|
-
end
|
|
60
|
-
end
|
|
61
|
-
mapSetPlayer(nil, removedTrinketsMap, player, removedTrinkets)
|
|
62
|
-
end
|
|
63
|
-
return {removedItemsMap, removedTrinketsMap}
|
|
64
|
-
end
|
|
65
|
-
function restoreItemsAndTrinketsThatAffectItemPools(self, removedItemsMap, removedTrinketsMap)
|
|
66
|
-
for ____, player in ipairs(getPlayers(nil)) do
|
|
67
|
-
local removedItems = mapGetPlayer(nil, removedItemsMap, player)
|
|
68
|
-
if removedItems ~= nil then
|
|
69
|
-
for ____, collectibleType in ipairs(removedItems) do
|
|
70
|
-
player:AddCollectible(collectibleType, 0, false)
|
|
71
|
-
end
|
|
72
|
-
end
|
|
73
|
-
local removedTrinkets = mapGetPlayer(nil, removedTrinketsMap, player)
|
|
74
|
-
if removedTrinkets ~= nil then
|
|
75
|
-
for ____, trinketType in ipairs(removedTrinkets) do
|
|
76
|
-
player:AddTrinket(trinketType, false)
|
|
77
|
-
end
|
|
78
|
-
end
|
|
79
|
-
end
|
|
80
|
-
end
|
|
81
|
-
COLLECTIBLES_THAT_AFFECT_ITEM_POOLS = {CollectibleType.CHAOS, CollectibleType.SACRED_ORB, CollectibleType.TMTRAINER}
|
|
82
|
-
TRINKETS_THAT_AFFECT_ITEM_POOLS = {TrinketType.NO}
|
|
83
6
|
--- Helper function to see if the given collectible is unlocked on the current save file. This
|
|
84
|
-
-- requires providing the corresponding item pool that the collectible is located in.
|
|
7
|
+
-- requires providing the corresponding item pool that the collectible is normally located in.
|
|
85
8
|
--
|
|
86
9
|
-- - If any player currently has the collectible, then it is assumed to be unlocked. (This is
|
|
87
10
|
-- because in almost all cases, when a collectible is added to a player's inventory, it is
|
|
@@ -92,42 +15,10 @@ TRINKETS_THAT_AFFECT_ITEM_POOLS = {TrinketType.NO}
|
|
|
92
15
|
-- - If the collectible is non-offensive, any Tainted Losts will be temporarily changed to Isaac and
|
|
93
16
|
-- then changed back. (This is because Tainted Lost is not able to retrieve non-offensive
|
|
94
17
|
-- collectibles from item pools).
|
|
95
|
-
--
|
|
96
|
-
-- Under the hood, this function works by using the `ItemPool.AddRoomBlacklist` method to blacklist
|
|
97
|
-
-- every collectible except for the one provided. Unfortunately, this is not a general-purpose
|
|
98
|
-
-- "isCollectibleInItemPool" algorithm, because when a pool is depleted, it will automatically pull
|
|
99
|
-
-- items from the Treasure Room pool, and there is no way to distinguish when this happens.
|
|
100
18
|
function ____exports.isCollectibleUnlocked(self, collectibleType, itemPoolType)
|
|
101
19
|
if anyPlayerHasCollectible(nil, collectibleType) then
|
|
102
20
|
return true
|
|
103
21
|
end
|
|
104
|
-
|
|
105
|
-
local isOffensive = collectibleHasTag(nil, collectibleType, ItemConfigTag.OFFENSIVE)
|
|
106
|
-
local changedPlayerTypes = false
|
|
107
|
-
if not isOffensive then
|
|
108
|
-
changedPlayerTypes = true
|
|
109
|
-
for ____, player in ipairs(taintedLosts) do
|
|
110
|
-
player:ChangePlayerType(PlayerType.ISAAC)
|
|
111
|
-
end
|
|
112
|
-
end
|
|
113
|
-
local removedItemsMap, removedTrinketsMap = table.unpack(removeItemsAndTrinketsThatAffectItemPools(nil))
|
|
114
|
-
local itemPool = game:GetItemPool()
|
|
115
|
-
local collectibleSet = getCollectibleSet(nil)
|
|
116
|
-
for ____, collectibleTypeInSet in __TS__Iterator(collectibleSet:values()) do
|
|
117
|
-
if collectibleTypeInSet ~= collectibleType then
|
|
118
|
-
itemPool:AddRoomBlacklist(collectibleTypeInSet)
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
local seed = 1
|
|
122
|
-
local retrievedCollectibleType = itemPool:GetCollectible(itemPoolType, false, seed)
|
|
123
|
-
local collectibleUnlocked = retrievedCollectibleType == collectibleType
|
|
124
|
-
itemPool:ResetRoomBlacklist()
|
|
125
|
-
restoreItemsAndTrinketsThatAffectItemPools(nil, removedItemsMap, removedTrinketsMap)
|
|
126
|
-
if changedPlayerTypes then
|
|
127
|
-
for ____, player in ipairs(taintedLosts) do
|
|
128
|
-
player:ChangePlayerType(PlayerType.THE_LOST_B)
|
|
129
|
-
end
|
|
130
|
-
end
|
|
131
|
-
return collectibleUnlocked
|
|
22
|
+
return isCollectibleInItemPool(nil, collectibleType, itemPoolType)
|
|
132
23
|
end
|
|
133
24
|
return ____exports
|
package/dist/index.d.ts
CHANGED
|
@@ -54,9 +54,11 @@ export * from "./functions/collectibles";
|
|
|
54
54
|
export * from "./functions/collectibleSet";
|
|
55
55
|
export * from "./functions/collectibleTag";
|
|
56
56
|
export * from "./functions/color";
|
|
57
|
+
export * from "./functions/curses";
|
|
57
58
|
export * from "./functions/debug";
|
|
58
59
|
export * from "./functions/deepCopy";
|
|
59
60
|
export * from "./functions/deepCopyTests";
|
|
61
|
+
export * from "./functions/dimensions";
|
|
60
62
|
export * from "./functions/direction";
|
|
61
63
|
export * from "./functions/doors";
|
|
62
64
|
export * from "./functions/easing";
|
|
@@ -74,11 +76,13 @@ export * from "./functions/gridEntities";
|
|
|
74
76
|
export * from "./functions/gridEntitiesSpecific";
|
|
75
77
|
export * from "./functions/input";
|
|
76
78
|
export * from "./functions/isaacAPIClass";
|
|
79
|
+
export * from "./functions/itemPool";
|
|
77
80
|
export * from "./functions/jsonHelpers";
|
|
78
81
|
export * from "./functions/jsonRoom";
|
|
79
82
|
export * from "./functions/kColor";
|
|
80
83
|
export * from "./functions/language";
|
|
81
84
|
export * from "./functions/level";
|
|
85
|
+
export * from "./functions/levelGrid";
|
|
82
86
|
export * from "./functions/log";
|
|
83
87
|
export * from "./functions/map";
|
|
84
88
|
export * from "./functions/math";
|