isaacscript-common 1.2.221 → 1.2.222

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.
@@ -40,6 +40,7 @@ local ____playerIndex = require("functions.playerIndex")
40
40
  local getPlayers = ____playerIndex.getPlayers
41
41
  local ____roomData = require("functions.roomData")
42
42
  local getRoomData = ____roomData.getRoomData
43
+ local getRoomDescriptor = ____roomData.getRoomDescriptor
43
44
  local ____rooms = require("functions.rooms")
44
45
  local changeRoom = ____rooms.changeRoom
45
46
  local getRoomGridIndexesForType = ____rooms.getRoomGridIndexesForType
@@ -129,8 +130,8 @@ function devilAngel(self, useDevil)
129
130
  local roomType = devilAngelRoomData.Type
130
131
  local conflictingType = useDevil and RoomType.ROOM_ANGEL or RoomType.ROOM_DEVIL
131
132
  if roomType == conflictingType then
132
- local roomDesc = level:GetRoomByIdx(GridRooms.ROOM_DEVIL_IDX)
133
- roomDesc.Data = nil
133
+ local roomDescriptor = getRoomDescriptor(nil, GridRooms.ROOM_DEVIL_IDX)
134
+ roomDescriptor.Data = nil
134
135
  end
135
136
  end
136
137
  if useDevil then
@@ -56,6 +56,13 @@ export declare function getRoomListIndex(roomGridIndex?: int): int;
56
56
  * @returns The room name. Returns "Unknown" if the type was not found.
57
57
  */
58
58
  export declare function getRoomName(roomGridIndex?: int): string;
59
+ /**
60
+ * Helper function to get the name of the room as it appears in the STB/XML data.
61
+ *
62
+ * @param roomGridIndex Optional. Default is the current room index.
63
+ * @returns The room name. Returns "Unknown" if the type was not found.
64
+ */
65
+ export declare function getRoomShape(roomGridIndex?: int): RoomShape | undefined;
59
66
  /**
60
67
  * Helper function to get the stage ID for a room from the XML/STB data. The room stage ID will
61
68
  * correspond to the first number in the filename of the XML/STB file. For example, a Depths room
@@ -61,6 +61,16 @@ function ____exports.getRoomName(self, roomGridIndex)
61
61
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
62
62
  return roomData == nil and "Unknown" or roomData.Name
63
63
  end
64
+ function ____exports.getRoomShape(self, roomGridIndex)
65
+ local roomData = ____exports.getRoomData(nil, roomGridIndex)
66
+ local ____temp_0
67
+ if roomData == nil then
68
+ ____temp_0 = nil
69
+ else
70
+ ____temp_0 = roomData.Shape
71
+ end
72
+ return ____temp_0
73
+ end
64
74
  function ____exports.getRoomStageID(self, roomGridIndex)
65
75
  local roomData = ____exports.getRoomData(nil, roomGridIndex)
66
76
  return roomData == nil and -1 or roomData.StageID
@@ -114,6 +114,8 @@ export declare function inStartingRoom(): boolean;
114
114
  * default.
115
115
  */
116
116
  export declare function isAllRoomsClear(onlyCheckRoomTypes?: RoomType[]): boolean;
117
+ export declare function isDoorSlotValidAtGridIndex(doorSlot: DoorSlot, roomGridIndex: int): boolean;
118
+ export declare function isDoorSlotValidAtGridIndexForRedRoom(doorSlot: DoorSlot, roomGridIndex: int): boolean;
117
119
  /**
118
120
  * Helper function to detect if the provided room was created by the Red Key item. Under the hood,
119
121
  * this checks for the `RoomDescriptorFlag.FLAG_RED_ROOM` flag.
@@ -128,6 +130,8 @@ export declare function isRedKeyRoom(roomGridIndex?: int): boolean;
128
130
  * @param roomGridIndex Optional. Default is the current room index.
129
131
  */
130
132
  export declare function isRoomInsideMap(roomGridIndex?: int): boolean;
133
+ /** Helper function to check if a room exists at the given room grid index. */
134
+ export declare function roomExists(roomGridIndex: int): boolean;
131
135
  /**
132
136
  * If the `Room.Update` method is called in a PostNewRoom callback, then some entities will slide
133
137
  * around (such as the player). Since those entity velocities are already at zero, setting them to
@@ -33,9 +33,11 @@ local setEntityPositions = ____positionVelocity.setEntityPositions
33
33
  local setEntityVelocities = ____positionVelocity.setEntityVelocities
34
34
  local ____roomData = require("functions.roomData")
35
35
  local getCurrentRoomDescriptorReadOnly = ____roomData.getCurrentRoomDescriptorReadOnly
36
+ local getRoomAllowedDoors = ____roomData.getRoomAllowedDoors
36
37
  local getRoomData = ____roomData.getRoomData
37
38
  local getRoomDescriptor = ____roomData.getRoomDescriptor
38
39
  local getRoomGridIndex = ____roomData.getRoomGridIndex
40
+ local getRoomShape = ____roomData.getRoomShape
39
41
  local getRoomStageID = ____roomData.getRoomStageID
40
42
  local getRoomSubType = ____roomData.getRoomSubType
41
43
  function ____exports.getRooms(self, includeExtraDimensionalRooms)
@@ -75,6 +77,10 @@ function ____exports.inDeathCertificateArea(self)
75
77
  local roomSubType = getRoomSubType(nil)
76
78
  return roomStageID == 35 and (roomSubType == 33 or roomSubType == 34)
77
79
  end
80
+ function ____exports.roomExists(self, roomGridIndex)
81
+ local roomData = getRoomData(nil, roomGridIndex)
82
+ return roomData ~= nil
83
+ end
78
84
  function ____exports.changeRoom(self, roomGridIndex)
79
85
  local level = game:GetLevel()
80
86
  local roomData = getRoomData(nil, roomGridIndex)
@@ -97,11 +103,11 @@ function ____exports.getCurrentDimension(self)
97
103
  return 2
98
104
  end
99
105
  local startingRoomGridIndex = level:GetStartingRoomIndex()
100
- local startingRoomDesc = level:GetRoomByIdx(startingRoomGridIndex, -1)
101
- local startingRoomHash = GetPtrHash(startingRoomDesc)
106
+ local startingRoomDescription = level:GetRoomByIdx(startingRoomGridIndex, -1)
107
+ local startingRoomHash = GetPtrHash(startingRoomDescription)
102
108
  for ____, dimension in ipairs(range(nil, 0, NUM_DIMENSIONS - 1)) do
103
- local dimensionRoomDesc = level:GetRoomByIdx(startingRoomGridIndex, dimension)
104
- local dimensionRoomHash = GetPtrHash(dimensionRoomDesc)
109
+ local dimensionRoomDescription = level:GetRoomByIdx(startingRoomGridIndex, dimension)
110
+ local dimensionRoomHash = GetPtrHash(dimensionRoomDescription)
105
111
  if dimensionRoomHash == startingRoomHash then
106
112
  return dimension
107
113
  end
@@ -226,6 +232,26 @@ function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes)
226
232
  function(____, roomDescriptor) return roomDescriptor.Clear end
227
233
  )
228
234
  end
235
+ function ____exports.isDoorSlotValidAtGridIndex(self, doorSlot, roomGridIndex)
236
+ local allowedDoors = getRoomAllowedDoors(nil, roomGridIndex)
237
+ return allowedDoors:has(doorSlot)
238
+ end
239
+ function ____exports.isDoorSlotValidAtGridIndexForRedRoom(self, doorSlot, roomGridIndex)
240
+ local doorSlotValidAtGridIndex = ____exports.isDoorSlotValidAtGridIndex(nil, doorSlot, roomGridIndex)
241
+ if not doorSlotValidAtGridIndex then
242
+ return false
243
+ end
244
+ local roomShape = getRoomShape(nil, roomGridIndex)
245
+ if roomShape == nil then
246
+ return false
247
+ end
248
+ local delta = ____exports.getGridIndexDelta(nil, roomShape, doorSlot)
249
+ if delta == nil then
250
+ return false
251
+ end
252
+ local redRoomGridIndex = roomGridIndex + delta
253
+ return not ____exports.roomExists(nil, redRoomGridIndex)
254
+ end
229
255
  function ____exports.isRedKeyRoom(self, roomGridIndex)
230
256
  local roomDescriptor = getRoomDescriptor(nil, roomGridIndex)
231
257
  return hasFlag(nil, roomDescriptor.Flags, 1024)
@@ -255,12 +281,12 @@ function ____exports.setRoomCleared(self)
255
281
  for ____, door in ipairs(getDoors(nil)) do
256
282
  do
257
283
  if isHiddenSecretRoomDoor(nil, door) then
258
- goto __continue48
284
+ goto __continue54
259
285
  end
260
286
  openDoorFast(nil, door)
261
287
  door.ExtraVisible = false
262
288
  end
263
- ::__continue48::
289
+ ::__continue54::
264
290
  end
265
291
  sfxManager:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
266
292
  game:ShakeScreen(0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.221",
3
+ "version": "1.2.222",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",