isaacscript-common 4.9.0 → 5.0.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.
@@ -38,6 +38,8 @@ local ____cards = require("functions.cards")
38
38
  local getCardName = ____cards.getCardName
39
39
  local ____character = require("functions.character")
40
40
  local getCharacterName = ____character.getCharacterName
41
+ local ____charge = require("functions.charge")
42
+ local addCharge = ____charge.addCharge
41
43
  local ____collectibles = require("functions.collectibles")
42
44
  local isValidCollectibleType = ____collectibles.isValidCollectibleType
43
45
  local ____entitySpecific = require("functions.entitySpecific")
@@ -199,7 +201,7 @@ function ____exports.addCharges(self, params)
199
201
  printConsole(nil, "That is an invalid amount of arguments.")
200
202
  return
201
203
  end
202
- local activeSlotString, chargeString = table.unpack(args)
204
+ local activeSlotString, numChargeString = table.unpack(args)
203
205
  local activeSlot = tonumber(activeSlotString)
204
206
  if activeSlot == nil then
205
207
  printConsole(
@@ -215,19 +217,17 @@ function ____exports.addCharges(self, params)
215
217
  )
216
218
  return
217
219
  end
218
- local chargeNum = 1
219
- if chargeString ~= nil then
220
- local chargeNumAttempt = tonumber(chargeString)
221
- if chargeNumAttempt == nil then
222
- printConsole(nil, "The provided charge amount is invalid: " .. chargeString)
220
+ local numCharges = 1
221
+ if numChargeString ~= nil then
222
+ local numChargesAttempt = tonumber(numChargeString)
223
+ if numChargesAttempt == nil then
224
+ printConsole(nil, "The provided charge amount is invalid: " .. numChargeString)
223
225
  return
224
226
  end
225
- chargeNum = chargeNumAttempt
227
+ numCharges = numChargesAttempt
226
228
  end
227
229
  local player = Isaac.GetPlayer()
228
- local currentCharge = player:GetActiveCharge(activeSlot)
229
- local newCharge = currentCharge + chargeNum
230
- player:SetActiveCharge(newCharge, activeSlot)
230
+ addCharge(nil, player, activeSlot, numCharges)
231
231
  end
232
232
  --- Warps to the Angel Room for the floor. If the Devil Room has already been visited or initialized,
233
233
  -- this will uninitialize it and make an Angel Room instead.
@@ -63,7 +63,6 @@ export declare function emptyArray<T>(array: T[]): void;
63
63
  * For example, if this function is provided an array containing 1, 2, and 3, then it will return an
64
64
  * array containing the following arrays:
65
65
  *
66
- * - []
67
66
  * - [1]
68
67
  * - [2]
69
68
  * - [3]
@@ -75,11 +74,12 @@ export declare function emptyArray<T>(array: T[]): void;
75
74
  * From: https://github.com/firstandthird/combinations/blob/master/index.js
76
75
  *
77
76
  * @param array The array to get the combinations of.
77
+ * @param includeEmptyArray Whether or not to include an empty array in the combinations.
78
78
  * @param min Optional. The minimum number of elements to include in each combination. Default is 1.
79
79
  * @param max Optional. The maximum number of elements to include in each combination. Default is
80
80
  * the length of the array.
81
81
  */
82
- export declare function getArrayCombinations<T>(array: T[] | readonly T[], min?: int, max?: int): ReadonlyArray<readonly T[]>;
82
+ export declare function getArrayCombinations<T>(array: T[] | readonly T[], includeEmptyArray: boolean, min?: int, max?: int): ReadonlyArray<readonly T[]>;
83
83
  /**
84
84
  * Helper function to get an array containing the indexes of an array.
85
85
  *
@@ -214,7 +214,6 @@ end
214
214
  -- For example, if this function is provided an array containing 1, 2, and 3, then it will return an
215
215
  -- array containing the following arrays:
216
216
  --
217
- -- - []
218
217
  -- - [1]
219
218
  -- - [2]
220
219
  -- - [3]
@@ -226,10 +225,11 @@ end
226
225
  -- From: https://github.com/firstandthird/combinations/blob/master/index.js
227
226
  --
228
227
  -- @param array The array to get the combinations of.
228
+ -- @param includeEmptyArray Whether or not to include an empty array in the combinations.
229
229
  -- @param min Optional. The minimum number of elements to include in each combination. Default is 1.
230
230
  -- @param max Optional. The maximum number of elements to include in each combination. Default is
231
231
  -- the length of the array.
232
- function ____exports.getArrayCombinations(self, array, min, max)
232
+ function ____exports.getArrayCombinations(self, array, includeEmptyArray, min, max)
233
233
  if min == nil or min <= 0 then
234
234
  min = 1
235
235
  end
@@ -276,7 +276,9 @@ function ____exports.getArrayCombinations(self, array, min, max)
276
276
  if #array == max then
277
277
  all[#all + 1] = array
278
278
  end
279
- __TS__ArrayUnshift(all, {})
279
+ if includeEmptyArray then
280
+ __TS__ArrayUnshift(all, {})
281
+ end
280
282
  return all
281
283
  end
282
284
  --- Helper function to get an array containing the indexes of an array.
@@ -1,19 +1,40 @@
1
1
  import { ActiveSlot } from "isaac-typescript-definitions";
2
2
  /**
3
- * Helper function to add a charge to a player's active item, emulating what happens when a room is
4
- * cleared.
3
+ * Helper function to add a charge to the player's active item. Will flash the HUD and play the
4
+ * appropriate sound effect, depending on whether the charge is partially full or completely full.
5
+ *
6
+ * If the player's active item is already fully charged, then this function will return 0 and not
7
+ * flash the HUD or play a sound effect.
5
8
  *
6
9
  * This function will take the following things into account:
7
- * - L rooms and 2x2 rooms granting a double charge
8
10
  * - The Battery
9
11
  * - AAA Battery
10
12
  *
11
13
  * @param player The player to grant the charges to.
12
- * @param ignoreBigRoomDoubleCharge Optional. If set to true, it will treat the current room as a
13
- * 1x1 room for the purposes of calculating how much charge to
14
- * grant. Default is false.
14
+ * @param activeSlot The slot to grant the charges to.
15
+ * @param numCharges Optional. The amount of charges to grant. Default is 1.
16
+ * @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
17
+ * @returns The amount of charges that were actually granted. For example, if the active item was
18
+ * only one away from a full charge, but the `numCharges` provided to this function was 2,
19
+ * then this function would return 1.
15
20
  */
16
- export declare function addRoomClearCharge(player: EntityPlayer, ignoreBigRoomDoubleCharge?: boolean): void;
21
+ export declare function addCharge(player: EntityPlayer, activeSlot: ActiveSlot, numCharges?: number, playSoundEffect?: boolean): int;
22
+ /**
23
+ * Helper function to add a charge to a player's active item(s), emulating what happens when a room
24
+ * is cleared.
25
+ *
26
+ * This function will take the following things into account:
27
+ * - 2x2 rooms and L rooms granting a double charge
28
+ * - The Battery
29
+ * - AAA Battery
30
+ *
31
+ * @param player The player to grant the charges to.
32
+ * @param bigRoomDoubleCharge Optional. If set to false, it will treat the current room as a 1x1
33
+ * room for the purposes of calculating how much charge to grant. Default
34
+ * is true.
35
+ * @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
36
+ */
37
+ export declare function addRoomClearCharge(player: EntityPlayer, bigRoomDoubleCharge?: boolean, playSoundEffect?: boolean): void;
17
38
  /**
18
39
  * Helper function to add a charge to one of a player's active items, emulating what happens when a
19
40
  * room is cleared.
@@ -25,11 +46,12 @@ export declare function addRoomClearCharge(player: EntityPlayer, ignoreBigRoomDo
25
46
  *
26
47
  * @param player The player to grant the charges to.
27
48
  * @param activeSlot The active item slot to grant the charges to.
28
- * @param ignoreBigRoomDoubleCharge Optional. If set to true, it will treat the current room as a
29
- * 1x1 room for the purposes of calculating how much charge to
30
- * grant. Default is false.
49
+ * @param bigRoomDoubleCharge Optional. If set to false, it will treat the current room as a 1x1
50
+ * room for the purposes of calculating how much charge to grant. Default
51
+ * is true.
52
+ * @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
31
53
  */
32
- export declare function addRoomClearChargeToSlot(player: EntityPlayer, activeSlot: ActiveSlot, ignoreBigRoomDoubleCharge?: boolean): void;
54
+ export declare function addRoomClearChargeToSlot(player: EntityPlayer, activeSlot: ActiveSlot, bigRoomDoubleCharge?: boolean, playSoundEffect?: boolean): void;
33
55
  /**
34
56
  * Helper function to add a charge to every player's active item, emulating what happens when a room
35
57
  * is cleared.
@@ -1,9 +1,8 @@
1
1
  local ____exports = {}
2
- local getNumChargesToAdd, getNumChargesWithAAAModifier, shouldPlayFullRechargeSound
2
+ local getClampedChargesToAdd, getNumChargesWithAAAModifier, shouldPlayFullRechargeSound
3
3
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
4
4
  local ActiveSlot = ____isaac_2Dtypescript_2Ddefinitions.ActiveSlot
5
5
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
6
- local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
7
6
  local SoundEffect = ____isaac_2Dtypescript_2Ddefinitions.SoundEffect
8
7
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
9
8
  local ____cachedClasses = require("cachedClasses")
@@ -13,41 +12,80 @@ local ____collectibles = require("functions.collectibles")
13
12
  local getCollectibleMaxCharges = ____collectibles.getCollectibleMaxCharges
14
13
  local ____playerIndex = require("functions.playerIndex")
15
14
  local getPlayers = ____playerIndex.getPlayers
16
- --- Helper function to add a charge to one of a player's active items, emulating what happens when a
17
- -- room is cleared.
15
+ local ____roomShape = require("functions.roomShape")
16
+ local getRoomShapeCharges = ____roomShape.getRoomShapeCharges
17
+ --- Helper function to add a charge to the player's active item. Will flash the HUD and play the
18
+ -- appropriate sound effect, depending on whether the charge is partially full or completely full.
19
+ --
20
+ -- If the player's active item is already fully charged, then this function will return 0 and not
21
+ -- flash the HUD or play a sound effect.
18
22
  --
19
23
  -- This function will take the following things into account:
20
- -- - L rooms and 2x2 rooms granting a double charge
21
24
  -- - The Battery
22
25
  -- - AAA Battery
23
26
  --
24
27
  -- @param player The player to grant the charges to.
25
- -- @param activeSlot The active item slot to grant the charges to.
26
- -- @param ignoreBigRoomDoubleCharge Optional. If set to true, it will treat the current room as a
27
- -- 1x1 room for the purposes of calculating how much charge to
28
- -- grant. Default is false.
29
- function ____exports.addRoomClearChargeToSlot(self, player, activeSlot, ignoreBigRoomDoubleCharge)
30
- if ignoreBigRoomDoubleCharge == nil then
31
- ignoreBigRoomDoubleCharge = false
32
- end
33
- if not player:NeedsCharge(activeSlot) then
34
- return
28
+ -- @param activeSlot The slot to grant the charges to.
29
+ -- @param numCharges Optional. The amount of charges to grant. Default is 1.
30
+ -- @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
31
+ -- @returns The amount of charges that were actually granted. For example, if the active item was
32
+ -- only one away from a full charge, but the `numCharges` provided to this function was 2,
33
+ -- then this function would return 1.
34
+ function ____exports.addCharge(self, player, activeSlot, numCharges, playSoundEffect)
35
+ if numCharges == nil then
36
+ numCharges = 1
37
+ end
38
+ if playSoundEffect == nil then
39
+ playSoundEffect = true
35
40
  end
36
41
  local hud = game:GetHUD()
37
- local totalCharge = ____exports.getTotalCharge(nil, player, activeSlot)
38
- local chargesToAdd = getNumChargesToAdd(nil, player, activeSlot, ignoreBigRoomDoubleCharge)
42
+ local chargesToAdd = getClampedChargesToAdd(nil, player, activeSlot, numCharges)
39
43
  local modifiedChargesToAdd = getNumChargesWithAAAModifier(nil, player, activeSlot, chargesToAdd)
44
+ local totalCharge = ____exports.getTotalCharge(nil, player, activeSlot)
40
45
  local newCharge = totalCharge + modifiedChargesToAdd
46
+ if newCharge == totalCharge then
47
+ return 0
48
+ end
41
49
  player:SetActiveCharge(newCharge, activeSlot)
42
50
  hud:FlashChargeBar(player, activeSlot)
43
- ____exports.playChargeSoundEffect(nil, player, activeSlot)
51
+ if playSoundEffect then
52
+ ____exports.playChargeSoundEffect(nil, player, activeSlot)
53
+ end
54
+ return modifiedChargesToAdd
44
55
  end
45
- function getNumChargesToAdd(self, player, activeSlot, ignoreBigRoomDoubleCharge)
46
- if ignoreBigRoomDoubleCharge == nil then
47
- ignoreBigRoomDoubleCharge = false
56
+ --- Helper function to add a charge to one of a player's active items, emulating what happens when a
57
+ -- room is cleared.
58
+ --
59
+ -- This function will take the following things into account:
60
+ -- - L rooms and 2x2 rooms granting a double charge
61
+ -- - The Battery
62
+ -- - AAA Battery
63
+ --
64
+ -- @param player The player to grant the charges to.
65
+ -- @param activeSlot The active item slot to grant the charges to.
66
+ -- @param bigRoomDoubleCharge Optional. If set to false, it will treat the current room as a 1x1
67
+ -- room for the purposes of calculating how much charge to grant. Default
68
+ -- is true.
69
+ -- @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
70
+ function ____exports.addRoomClearChargeToSlot(self, player, activeSlot, bigRoomDoubleCharge, playSoundEffect)
71
+ if bigRoomDoubleCharge == nil then
72
+ bigRoomDoubleCharge = true
73
+ end
74
+ if playSoundEffect == nil then
75
+ playSoundEffect = true
48
76
  end
49
77
  local room = game:GetRoom()
50
78
  local roomShape = room:GetRoomShape()
79
+ local numCharges = bigRoomDoubleCharge and getRoomShapeCharges(nil, roomShape) or 1
80
+ ____exports.addCharge(
81
+ nil,
82
+ player,
83
+ activeSlot,
84
+ numCharges,
85
+ playSoundEffect
86
+ )
87
+ end
88
+ function getClampedChargesToAdd(self, player, activeSlot, numCharges)
51
89
  local activeItem = player:GetActiveItem(activeSlot)
52
90
  local activeCharge = player:GetActiveCharge(activeSlot)
53
91
  local batteryCharge = player:GetBatteryCharge(activeSlot)
@@ -65,10 +103,7 @@ function getNumChargesToAdd(self, player, activeSlot, ignoreBigRoomDoubleCharge)
65
103
  if hasBattery and batteryCharge + 1 == maxCharges then
66
104
  return 1
67
105
  end
68
- if roomShape >= RoomShape.SHAPE_2x2 and not ignoreBigRoomDoubleCharge then
69
- return 2
70
- end
71
- return 1
106
+ return numCharges
72
107
  end
73
108
  function getNumChargesWithAAAModifier(self, player, activeSlot, chargesToAdd)
74
109
  local activeItem = player:GetActiveItem(activeSlot)
@@ -81,10 +116,10 @@ function getNumChargesWithAAAModifier(self, player, activeSlot, chargesToAdd)
81
116
  return chargesToAdd
82
117
  end
83
118
  if not hasBattery and activeCharge + chargesToAdd == maxCharges - 1 then
84
- return maxCharges + 1
119
+ return chargesToAdd + 1
85
120
  end
86
121
  if hasBattery and batteryCharge + chargesToAdd == maxCharges - 1 then
87
- return maxCharges + 1
122
+ return chargesToAdd + 1
88
123
  end
89
124
  return chargesToAdd
90
125
  end
@@ -114,24 +149,34 @@ function shouldPlayFullRechargeSound(self, player, activeSlot)
114
149
  end
115
150
  return not player:NeedsCharge(activeSlot) or activeCharge == maxCharges and batteryCharge == 0
116
151
  end
117
- --- Helper function to add a charge to a player's active item, emulating what happens when a room is
118
- -- cleared.
152
+ --- Helper function to add a charge to a player's active item(s), emulating what happens when a room
153
+ -- is cleared.
119
154
  --
120
155
  -- This function will take the following things into account:
121
- -- - L rooms and 2x2 rooms granting a double charge
156
+ -- - 2x2 rooms and L rooms granting a double charge
122
157
  -- - The Battery
123
158
  -- - AAA Battery
124
159
  --
125
160
  -- @param player The player to grant the charges to.
126
- -- @param ignoreBigRoomDoubleCharge Optional. If set to true, it will treat the current room as a
127
- -- 1x1 room for the purposes of calculating how much charge to
128
- -- grant. Default is false.
129
- function ____exports.addRoomClearCharge(self, player, ignoreBigRoomDoubleCharge)
130
- if ignoreBigRoomDoubleCharge == nil then
131
- ignoreBigRoomDoubleCharge = false
161
+ -- @param bigRoomDoubleCharge Optional. If set to false, it will treat the current room as a 1x1
162
+ -- room for the purposes of calculating how much charge to grant. Default
163
+ -- is true.
164
+ -- @param playSoundEffect Optional. Whether to play a charge-related sound effect. Default is true.
165
+ function ____exports.addRoomClearCharge(self, player, bigRoomDoubleCharge, playSoundEffect)
166
+ if bigRoomDoubleCharge == nil then
167
+ bigRoomDoubleCharge = true
168
+ end
169
+ if playSoundEffect == nil then
170
+ playSoundEffect = true
132
171
  end
133
172
  for ____, activeSlot in ipairs({ActiveSlot.PRIMARY, ActiveSlot.SECONDARY, ActiveSlot.POCKET}) do
134
- ____exports.addRoomClearChargeToSlot(nil, player, activeSlot, ignoreBigRoomDoubleCharge)
173
+ ____exports.addRoomClearChargeToSlot(
174
+ nil,
175
+ player,
176
+ activeSlot,
177
+ bigRoomDoubleCharge,
178
+ playSoundEffect
179
+ )
135
180
  end
136
181
  end
137
182
  --- Helper function to add a charge to every player's active item, emulating what happens when a room
@@ -6,18 +6,25 @@ import { DoorSlot, RoomShape } from "isaac-typescript-definitions";
6
6
  * started.
7
7
  */
8
8
  export declare function getGridIndexDelta(roomShape: RoomShape, doorSlot: DoorSlot): int | undefined;
9
+ /**
10
+ * Helper function to see if a given room shape will grant a single charge or a double charge to the
11
+ * player's active item(s).
12
+ *
13
+ * For example, `RoomShape.SHAPE_2x2` will return 2.
14
+ */
15
+ export declare function getRoomShapeBottomRightPosition(roomShape: RoomShape): Vector;
9
16
  /**
10
17
  * Helper function to get the grid position of the bottom-right tile of a given room shape.
11
18
  *
12
19
  * "Vector(0, 0)" corresponds to the top left tile of a room, not including the walls. (The top-left
13
20
  * wall would be at "Vector(-1, -1)".)
14
21
  */
15
- export declare function getRoomShapeBottomRightPosition(roomShape: RoomShape): Vector;
22
+ export declare function getRoomShapeBounds(roomShape: RoomShape): readonly [width: int, height: int];
16
23
  /**
17
24
  * Helper function to get the bounds of a room shape, which are a box representing its contents.
18
25
  * This does not include the tiles that the walls are on. L rooms use the same bounds as a 2x2 room.
19
26
  */
20
- export declare function getRoomShapeBounds(roomShape: RoomShape): readonly [width: int, height: int];
27
+ export declare function getRoomShapeCharges(roomShape: RoomShape): int;
21
28
  /**
22
29
  * Helper function to get the dimensions of a room shape's layout. This is NOT the size of the
23
30
  * room's actual contents! For that, use the `getRoomShapeBounds` function.
@@ -41,3 +48,10 @@ export declare function getRoomShapeTopLeftPosition(roomShape: RoomShape): Vecto
41
48
  export declare function getRoomShapeVolume(roomShape: RoomShape): int;
42
49
  export declare function getRoomShapeWidth(roomShape: RoomShape): int;
43
50
  export declare function isLRoom(roomShape: RoomShape): boolean;
51
+ /**
52
+ * Helper function to see if a given room shape will grant a single charge or a double charge to the
53
+ * player's active item(s).
54
+ *
55
+ * For example, `RoomShape.SHAPE_2x2` will return true.
56
+ */
57
+ export declare function isRoomShapeDoubleCharge(roomShape: RoomShape): boolean;
@@ -1,6 +1,8 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
3
  local ____exports = {}
4
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
5
+ local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
4
6
  local ____roomShapeBounds = require("objects.roomShapeBounds")
5
7
  local ROOM_SHAPE_BOUNDS = ____roomShapeBounds.ROOM_SHAPE_BOUNDS
6
8
  local ____roomShapeLayoutSizes = require("objects.roomShapeLayoutSizes")
@@ -17,6 +19,13 @@ local ____roomShapeVolumes = require("objects.roomShapeVolumes")
17
19
  local ROOM_SHAPE_VOLUMES = ____roomShapeVolumes.ROOM_SHAPE_VOLUMES
18
20
  local ____LRoomShapesSet = require("sets.LRoomShapesSet")
19
21
  local L_ROOM_SHAPES_SET = ____LRoomShapesSet.L_ROOM_SHAPES_SET
22
+ --- Helper function to see if a given room shape will grant a single charge or a double charge to the
23
+ -- player's active item(s).
24
+ --
25
+ -- For example, `RoomShape.SHAPE_2x2` will return true.
26
+ function ____exports.isRoomShapeDoubleCharge(self, roomShape)
27
+ return roomShape >= RoomShape.SHAPE_2x2
28
+ end
20
29
  --- Helper function to get the grid index delta that a door out of the given room shape would lead
21
30
  -- to. For example, if you went through the bottom door in a room of `RoomShape.SHAPE_1x2`, you
22
31
  -- would end up in a room with a grid index that is +26 units from the `SafeGridIndex` of where you
@@ -25,17 +34,24 @@ function ____exports.getGridIndexDelta(self, roomShape, doorSlot)
25
34
  local doorSlotToGridIndexMap = ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA[roomShape]
26
35
  return doorSlotToGridIndexMap:get(doorSlot)
27
36
  end
37
+ --- Helper function to see if a given room shape will grant a single charge or a double charge to the
38
+ -- player's active item(s).
39
+ --
40
+ -- For example, `RoomShape.SHAPE_2x2` will return 2.
41
+ function ____exports.getRoomShapeBottomRightPosition(self, roomShape)
42
+ return ROOM_SHAPE_TO_BOTTOM_RIGHT_POSITION[roomShape]
43
+ end
28
44
  --- Helper function to get the grid position of the bottom-right tile of a given room shape.
29
45
  --
30
46
  -- "Vector(0, 0)" corresponds to the top left tile of a room, not including the walls. (The top-left
31
47
  -- wall would be at "Vector(-1, -1)".)
32
- function ____exports.getRoomShapeBottomRightPosition(self, roomShape)
33
- return ROOM_SHAPE_TO_BOTTOM_RIGHT_POSITION[roomShape]
48
+ function ____exports.getRoomShapeBounds(self, roomShape)
49
+ return ROOM_SHAPE_BOUNDS[roomShape]
34
50
  end
35
51
  --- Helper function to get the bounds of a room shape, which are a box representing its contents.
36
52
  -- This does not include the tiles that the walls are on. L rooms use the same bounds as a 2x2 room.
37
- function ____exports.getRoomShapeBounds(self, roomShape)
38
- return ROOM_SHAPE_BOUNDS[roomShape]
53
+ function ____exports.getRoomShapeCharges(self, roomShape)
54
+ return ____exports.isRoomShapeDoubleCharge(nil, roomShape) and 2 or 1
39
55
  end
40
56
  --- Helper function to get the dimensions of a room shape's layout. This is NOT the size of the
41
57
  -- room's actual contents! For that, use the `getRoomShapeBounds` function.
@@ -46,8 +46,11 @@ export declare function getRandomSetElement<T>(set: Set<T> | ReadonlySet<T>, see
46
46
  * - [1, 3]
47
47
  * - [2, 3]
48
48
  * - [1, 2, 3]
49
+ *
50
+ * @param set The set to get the combinations of.
51
+ * @param includeEmptyArray Whether or not to include an empty array in the combinations.
49
52
  */
50
- export declare function getSetCombinations<T>(set: Set<T> | ReadonlySet<T>): ReadonlyArray<ReadonlySet<T>>;
53
+ export declare function getSetCombinations<T>(set: Set<T> | ReadonlySet<T>, includeEmptyArray: boolean): ReadonlyArray<ReadonlySet<T>>;
51
54
  /**
52
55
  * Helper function to get a sorted array based on the contents of a set.
53
56
  *
package/functions/set.lua CHANGED
@@ -96,9 +96,12 @@ end
96
96
  -- - [1, 3]
97
97
  -- - [2, 3]
98
98
  -- - [1, 2, 3]
99
- function ____exports.getSetCombinations(self, set)
99
+ --
100
+ -- @param set The set to get the combinations of.
101
+ -- @param includeEmptyArray Whether or not to include an empty array in the combinations.
102
+ function ____exports.getSetCombinations(self, set, includeEmptyArray)
100
103
  local values = ____exports.getSortedSetValues(nil, set)
101
- local combinations = getArrayCombinations(nil, values)
104
+ local combinations = getArrayCombinations(nil, values, includeEmptyArray)
102
105
  return __TS__ArrayMap(
103
106
  combinations,
104
107
  function(____, array) return __TS__New(Set, array) end
@@ -6,8 +6,8 @@ ____exports.OPPOSITE_DOOR_SLOTS = {
6
6
  [DoorSlot.LEFT_0] = DoorSlot.RIGHT_0,
7
7
  [DoorSlot.UP_0] = DoorSlot.DOWN_0,
8
8
  [DoorSlot.RIGHT_0] = DoorSlot.LEFT_0,
9
- [DoorSlot.LEFT_1] = DoorSlot.RIGHT_1,
10
9
  [DoorSlot.DOWN_0] = DoorSlot.UP_0,
10
+ [DoorSlot.LEFT_1] = DoorSlot.RIGHT_1,
11
11
  [DoorSlot.UP_1] = DoorSlot.DOWN_1,
12
12
  [DoorSlot.RIGHT_1] = DoorSlot.LEFT_1,
13
13
  [DoorSlot.DOWN_1] = DoorSlot.UP_1
@@ -0,0 +1,4 @@
1
+ import { DoorSlot, RoomShape } from "isaac-typescript-definitions";
2
+ export declare const ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES: {
3
+ readonly [key in RoomShape]: ReadonlySet<DoorSlot>;
4
+ };
@@ -0,0 +1,46 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
+ local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
7
+ local RoomShape = ____isaac_2Dtypescript_2Ddefinitions.RoomShape
8
+ local ALL_DOOR_SLOTS_SET = __TS__New(Set, {
9
+ DoorSlot.LEFT_0,
10
+ DoorSlot.UP_0,
11
+ DoorSlot.RIGHT_0,
12
+ DoorSlot.DOWN_0,
13
+ DoorSlot.LEFT_1,
14
+ DoorSlot.UP_1,
15
+ DoorSlot.RIGHT_1,
16
+ DoorSlot.DOWN_1
17
+ })
18
+ ____exports.ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES = {
19
+ [RoomShape.SHAPE_1x1] = __TS__New(Set, {DoorSlot.LEFT_0, DoorSlot.UP_0, DoorSlot.RIGHT_0, DoorSlot.DOWN_0}),
20
+ [RoomShape.IH] = __TS__New(Set, {DoorSlot.LEFT_0, DoorSlot.RIGHT_0}),
21
+ [RoomShape.IV] = __TS__New(Set, {DoorSlot.UP_0, DoorSlot.DOWN_0}),
22
+ [RoomShape.SHAPE_1x2] = __TS__New(Set, {
23
+ DoorSlot.LEFT_0,
24
+ DoorSlot.UP_0,
25
+ DoorSlot.RIGHT_0,
26
+ DoorSlot.DOWN_0,
27
+ DoorSlot.LEFT_1,
28
+ DoorSlot.RIGHT_1
29
+ }),
30
+ [RoomShape.IIV] = __TS__New(Set, {DoorSlot.UP_0, DoorSlot.DOWN_0}),
31
+ [RoomShape.SHAPE_2x1] = __TS__New(Set, {
32
+ DoorSlot.LEFT_0,
33
+ DoorSlot.UP_0,
34
+ DoorSlot.RIGHT_0,
35
+ DoorSlot.DOWN_0,
36
+ DoorSlot.UP_1,
37
+ DoorSlot.DOWN_1
38
+ }),
39
+ [RoomShape.IIH] = __TS__New(Set, {DoorSlot.LEFT_0, DoorSlot.RIGHT_0}),
40
+ [RoomShape.SHAPE_2x2] = ALL_DOOR_SLOTS_SET,
41
+ [RoomShape.LTL] = ALL_DOOR_SLOTS_SET,
42
+ [RoomShape.LTR] = ALL_DOOR_SLOTS_SET,
43
+ [RoomShape.LBL] = ALL_DOOR_SLOTS_SET,
44
+ [RoomShape.LBR] = ALL_DOOR_SLOTS_SET
45
+ }
46
+ return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "4.9.0",
3
+ "version": "5.0.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",