isaacscript-common 1.2.66 → 1.2.69

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
  /**
@@ -81,3 +88,11 @@ export declare function openDoorFast(door: GridEntityDoor): void;
81
88
  * @returns The number of doors removed.
82
89
  */
83
90
  export declare function removeAllDoors(...roomTypes: RoomType[]): int;
91
+ /** Helper function to remove a single door. */
92
+ export declare function removeDoor(door: GridEntityDoor): void;
93
+ /**
94
+ * Helper function to remove the doors provided.
95
+ *
96
+ * This function is variadic, meaning that you can specify as many doors as you want to remove.
97
+ */
98
+ 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")
@@ -39,6 +40,17 @@ function ____exports.isSecretRoomDoor(self, door)
39
40
  local filename = sprite:GetFilename()
40
41
  return filename == "gfx/grid/Door_08_HoleInWall.anm2"
41
42
  end
43
+ function ____exports.removeDoor(self, door)
44
+ local game = Game()
45
+ local room = game:GetRoom()
46
+ room:RemoveDoor(door.Slot)
47
+ end
48
+ function ____exports.removeDoors(self, ...)
49
+ local doors = {...}
50
+ for ____, door in ipairs(doors) do
51
+ ____exports.removeDoor(nil, door)
52
+ end
53
+ end
42
54
  function ____exports.closeAllDoors(self)
43
55
  for ____, door in ipairs(____exports.getDoors(nil)) do
44
56
  door:Close(true)
@@ -49,6 +61,15 @@ function ____exports.closeDoorFast(self, door)
49
61
  local sprite = door:GetSprite()
50
62
  sprite:Play("Closed", true)
51
63
  end
64
+ function ____exports.getDoorsToRoomIndex(self, ...)
65
+ local roomGridIndex = {...}
66
+ local roomGridIndexesSet = __TS__New(Set, roomGridIndex)
67
+ local doors = ____exports.getDoors(nil)
68
+ return __TS__ArrayFilter(
69
+ doors,
70
+ function(____, door) return roomGridIndexesSet:has(door.TargetRoomIndex) end
71
+ )
72
+ end
52
73
  function ____exports.getAngelRoomDoor(self)
53
74
  local angelRoomDoors = ____exports.getDoors(nil, RoomType.ROOM_ANGEL)
54
75
  local ____temp_0
@@ -157,28 +178,11 @@ function ____exports.openDoorFast(self, door)
157
178
  sprite:Play("Opened", true)
158
179
  end
159
180
  function ____exports.removeAllDoors(self, ...)
160
- local roomTypes = {...}
161
- local game = Game()
162
- local room = game:GetRoom()
163
- local roomTypesSet = __TS__New(Set, roomTypes)
164
- local numDoorsRemoved = 0
165
- do
166
- local i = 0
167
- while i < MAX_NUM_DOORS do
168
- do
169
- local door = room:GetDoor(i)
170
- if door == nil then
171
- goto __continue36
172
- end
173
- if #roomTypes == 0 or roomTypesSet:has(door.TargetRoomType) then
174
- room:RemoveDoor(i)
175
- numDoorsRemoved = numDoorsRemoved + 1
176
- end
177
- end
178
- ::__continue36::
179
- i = i + 1
180
- end
181
- end
182
- return numDoorsRemoved
181
+ local doors = ____exports.getDoors(nil, ...)
182
+ ____exports.removeDoors(
183
+ nil,
184
+ table.unpack(doors)
185
+ )
186
+ return #doors
183
187
  end
184
188
  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.66",
3
+ "version": "1.2.69",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",