isaacscript-common 1.2.65 → 1.2.66

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.
@@ -73,3 +73,11 @@ export declare function openAllDoors(): void;
73
73
  * an animation.
74
74
  */
75
75
  export declare function openDoorFast(door: GridEntityDoor): void;
76
+ /**
77
+ * Helper function to remove all of the doors in the room. By default, it will remove every door.
78
+ * You can optionally specify one or more room types to remove only the doors that match the
79
+ * specified room types.
80
+ *
81
+ * @returns The number of doors removed.
82
+ */
83
+ export declare function removeAllDoors(...roomTypes: RoomType[]): int;
@@ -21,9 +21,7 @@ function ____exports.getDoors(self, ...)
21
21
  if door == nil then
22
22
  goto __continue7
23
23
  end
24
- if #roomTypes == 0 then
25
- __TS__ArrayPush(doors, door)
26
- elseif roomTypesSet:has(door.TargetRoomType) then
24
+ if #roomTypes == 0 or roomTypesSet:has(door.TargetRoomType) then
27
25
  __TS__ArrayPush(doors, door)
28
26
  end
29
27
  end
@@ -158,4 +156,29 @@ function ____exports.openDoorFast(self, door)
158
156
  local sprite = door:GetSprite()
159
157
  sprite:Play("Opened", true)
160
158
  end
159
+ 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
183
+ end
161
184
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.65",
3
+ "version": "1.2.66",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",