isaacscript-common 1.2.65 → 1.2.68

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,7 +8,7 @@ local __TS__Iterator = ____lualib.__TS__Iterator
8
8
  local ____exports = {}
9
9
  local ____collectibles = require("functions.collectibles")
10
10
  local collectibleHasCacheFlag = ____collectibles.collectibleHasCacheFlag
11
- local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
11
+ local getMaxCollectibleType = ____collectibles.getMaxCollectibleType
12
12
  local ____math = require("functions.math")
13
13
  local range = ____math.range
14
14
  local ____set = require("functions.set")
@@ -17,10 +17,10 @@ local ____utils = require("functions.utils")
17
17
  local getEnumValues = ____utils.getEnumValues
18
18
  local CACHE_FLAG_TO_COLLECTIBLES_MAP = __TS__New(Map)
19
19
  local function initCacheFlagMap(self)
20
- local maxCollectibleID = getMaxCollectibleID(nil)
20
+ local maxCollectibleType = getMaxCollectibleType(nil)
21
21
  for ____, cacheFlag in ipairs(getEnumValues(nil, CacheFlag)) do
22
22
  local collectiblesSet = __TS__New(Set)
23
- for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleID)) do
23
+ for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleType)) do
24
24
  if collectibleHasCacheFlag(nil, collectibleType, cacheFlag) then
25
25
  collectiblesSet:add(collectibleType)
26
26
  end
@@ -4,7 +4,7 @@ local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
6
  local ____collectibles = require("functions.collectibles")
7
- local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
7
+ local getMaxCollectibleType = ____collectibles.getMaxCollectibleType
8
8
  local ____math = require("functions.math")
9
9
  local range = ____math.range
10
10
  local ____set = require("functions.set")
@@ -12,8 +12,8 @@ local copySet = ____set.copySet
12
12
  local COLLECTIBLE_SET = __TS__New(Set)
13
13
  local function initCollectibleSet(self)
14
14
  local itemConfig = Isaac.GetItemConfig()
15
- local maxCollectibleID = getMaxCollectibleID(nil)
16
- for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleID)) do
15
+ local maxCollectibleType = getMaxCollectibleType(nil)
16
+ for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleType)) do
17
17
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
18
18
  if itemConfigItem ~= nil then
19
19
  COLLECTIBLE_SET:add(collectibleType)
@@ -49,7 +49,7 @@ export declare function getCollectibleMaxCharges(collectibleType: CollectibleTyp
49
49
  export declare function getCollectibleName(collectibleType: CollectibleType | int): string;
50
50
  /** Helper function to get all of the collectible entities in the room. */
51
51
  export declare function getCollectibles(matchingSubType?: number): EntityPickup[];
52
- export declare function getMaxCollectibleID(): int;
52
+ export declare function getMaxCollectibleType(): int;
53
53
  /**
54
54
  * Returns whether or not the given collectible is a "glitched" item. All items are replaced by
55
55
  * glitched items once a player has TMTRAINER. However, glitched items can also "naturally" appear
@@ -141,7 +141,7 @@ function ____exports.getCollectibles(self, matchingSubType)
141
141
  end
142
142
  return getPickups(nil, PickupVariant.PICKUP_COLLECTIBLE, matchingSubType)
143
143
  end
144
- function ____exports.getMaxCollectibleID(self)
144
+ function ____exports.getMaxCollectibleType(self)
145
145
  local itemConfig = Isaac.GetItemConfig()
146
146
  return itemConfig:GetCollectibles().Size - 1
147
147
  end
@@ -11,6 +11,13 @@ export declare function closeDoorFast(door: GridEntityDoor): void;
11
11
  * room types.
12
12
  */
13
13
  export declare function getDoors(...roomTypes: RoomType[]): GridEntityDoor[];
14
+ /**
15
+ * Helper function to get all of the doors in the room that lead to the provided room index.
16
+ *
17
+ * This function is variadic, meaning that you can specify N arguments to return all of the doors
18
+ * that match any of the N room grid indexes.
19
+ */
20
+ export declare function getDoorsToRoomIndex(...roomGridIndex: int[]): GridEntityDoor[];
14
21
  export declare function getAngelRoomDoor(): GridEntityDoor | undefined;
15
22
  export declare function getDevilRoomDoor(): GridEntityDoor | undefined;
16
23
  /**
@@ -73,3 +80,17 @@ export declare function openAllDoors(): void;
73
80
  * an animation.
74
81
  */
75
82
  export declare function openDoorFast(door: GridEntityDoor): void;
83
+ /**
84
+ * Helper function to remove all of the doors in the room. By default, it will remove every door.
85
+ * You can optionally specify one or more room types to remove only the doors that match the
86
+ * specified room types.
87
+ *
88
+ * @returns The number of doors removed.
89
+ */
90
+ export declare function removeAllDoors(...roomTypes: RoomType[]): int;
91
+ /**
92
+ * Helper function to remove the door(s) provided.
93
+ *
94
+ * This function is variadic, meaning that you can specify as many doors as you want to remove.
95
+ */
96
+ export declare function removeDoors(...doors: GridEntityDoor[]): void;
@@ -3,6 +3,7 @@ local ____lualib = require("lualib_bundle")
3
3
  local Set = ____lualib.Set
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local __TS__ArrayPush = ____lualib.__TS__ArrayPush
6
+ local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
6
7
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
7
8
  local ____exports = {}
8
9
  local ____constants = require("constants")
@@ -21,9 +22,7 @@ function ____exports.getDoors(self, ...)
21
22
  if door == nil then
22
23
  goto __continue7
23
24
  end
24
- if #roomTypes == 0 then
25
- __TS__ArrayPush(doors, door)
26
- elseif roomTypesSet:has(door.TargetRoomType) then
25
+ if #roomTypes == 0 or roomTypesSet:has(door.TargetRoomType) then
27
26
  __TS__ArrayPush(doors, door)
28
27
  end
29
28
  end
@@ -51,6 +50,15 @@ function ____exports.closeDoorFast(self, door)
51
50
  local sprite = door:GetSprite()
52
51
  sprite:Play("Closed", true)
53
52
  end
53
+ function ____exports.getDoorsToRoomIndex(self, ...)
54
+ local roomGridIndex = {...}
55
+ local roomGridIndexesSet = __TS__New(Set, roomGridIndex)
56
+ local doors = ____exports.getDoors(nil)
57
+ return __TS__ArrayFilter(
58
+ doors,
59
+ function(____, door) return roomGridIndexesSet:has(door.TargetRoomIndex) end
60
+ )
61
+ end
54
62
  function ____exports.getAngelRoomDoor(self)
55
63
  local angelRoomDoors = ____exports.getDoors(nil, RoomType.ROOM_ANGEL)
56
64
  local ____temp_0
@@ -158,4 +166,37 @@ function ____exports.openDoorFast(self, door)
158
166
  local sprite = door:GetSprite()
159
167
  sprite:Play("Opened", true)
160
168
  end
169
+ function ____exports.removeAllDoors(self, ...)
170
+ local roomTypes = {...}
171
+ local game = Game()
172
+ local room = game:GetRoom()
173
+ local roomTypesSet = __TS__New(Set, roomTypes)
174
+ local numDoorsRemoved = 0
175
+ do
176
+ local i = 0
177
+ while i < MAX_NUM_DOORS do
178
+ do
179
+ local door = room:GetDoor(i)
180
+ if door == nil then
181
+ goto __continue38
182
+ end
183
+ if #roomTypes == 0 or roomTypesSet:has(door.TargetRoomType) then
184
+ room:RemoveDoor(i)
185
+ numDoorsRemoved = numDoorsRemoved + 1
186
+ end
187
+ end
188
+ ::__continue38::
189
+ i = i + 1
190
+ end
191
+ end
192
+ return numDoorsRemoved
193
+ end
194
+ function ____exports.removeDoors(self, ...)
195
+ local doors = {...}
196
+ local game = Game()
197
+ local room = game:GetRoom()
198
+ for ____, door in ipairs(doors) do
199
+ room:RemoveDoor(door.Slot)
200
+ end
201
+ end
161
202
  return ____exports
@@ -9,7 +9,7 @@ local ____transformationNameMap = require("maps.transformationNameMap")
9
9
  local TRANSFORMATION_NAME_MAP = ____transformationNameMap.TRANSFORMATION_NAME_MAP
10
10
  local ____collectibles = require("functions.collectibles")
11
11
  local collectibleHasTag = ____collectibles.collectibleHasTag
12
- local getMaxCollectibleID = ____collectibles.getMaxCollectibleID
12
+ local getMaxCollectibleType = ____collectibles.getMaxCollectibleType
13
13
  local ____math = require("functions.math")
14
14
  local range = ____math.range
15
15
  local ____set = require("functions.set")
@@ -33,14 +33,14 @@ local TRANSFORMATIONS_THAT_GRANT_FLYING = __TS__New(Set, {PlayerForm.PLAYERFORM_
33
33
  local TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP = __TS__New(Map)
34
34
  local COLLECTIBLE_TYPE_TO_TRANSFORMATION_MAP = __TS__New(Map)
35
35
  local function initMaps(self)
36
- local maxCollectibleID = getMaxCollectibleID(nil)
36
+ local maxCollectibleType = getMaxCollectibleType(nil)
37
37
  for ____, playerForm in __TS__Iterator(TRANSFORMATION_TO_TAG_MAP:keys()) do
38
38
  TRANSFORMATION_TO_COLLECTIBLE_TYPES_MAP:set(
39
39
  playerForm,
40
40
  __TS__New(Set)
41
41
  )
42
42
  end
43
- for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleID)) do
43
+ for ____, collectibleType in ipairs(range(nil, 1, maxCollectibleType)) do
44
44
  for ____, ____value in __TS__Iterator(TRANSFORMATION_TO_TAG_MAP:entries()) do
45
45
  local playerForm = ____value[1]
46
46
  local tag = ____value[2]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.65",
3
+ "version": "1.2.68",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",