isaacscript-common 16.1.3 → 16.1.4

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.
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 16.1.3
3
+ isaacscript-common 16.1.4
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -1443,10 +1443,6 @@ local function __TS__MathSign(val)
1443
1443
  return 0
1444
1444
  end
1445
1445
 
1446
- local function __TS__Modulo50(a, b)
1447
- return a - math.floor(a / b) * b
1448
- end
1449
-
1450
1446
  local function __TS__Number(value)
1451
1447
  local valueType = type(value)
1452
1448
  if valueType == "number" then
@@ -2535,7 +2531,6 @@ return {
2535
2531
  __TS__MathAtan2 = __TS__MathAtan2,
2536
2532
  __TS__MathModf = __TS__MathModf,
2537
2533
  __TS__MathSign = __TS__MathSign,
2538
- __TS__Modulo50 = __TS__Modulo50,
2539
2534
  __TS__New = __TS__New,
2540
2535
  __TS__Number = __TS__Number,
2541
2536
  __TS__NumberIsFinite = __TS__NumberIsFinite,
@@ -20046,9 +20041,10 @@ local Set = ____lualib.Set
20046
20041
  local __TS__Spread = ____lualib.__TS__Spread
20047
20042
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
20048
20043
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
20044
+ local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
20045
+ local __TS__Iterator = ____lualib.__TS__Iterator
20049
20046
  local __TS__New = ____lualib.__TS__New
20050
20047
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
20051
- local __TS__Iterator = ____lualib.__TS__Iterator
20052
20048
  local ____exports = {}
20053
20049
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
20054
20050
  local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
@@ -20096,13 +20092,16 @@ function ____exports.getDoorSlotEnterPositionOffset(self, doorSlot)
20096
20092
  local oppositeVector = vector * -1
20097
20093
  return oppositeVector * DISTANCE_OF_GRID_TILE
20098
20094
  end
20095
+ function ____exports.getDoorSlotsForRoomShape(self, roomShape)
20096
+ return ROOM_SHAPE_TO_DOOR_SLOTS[roomShape]
20097
+ end
20099
20098
  function ____exports.getDoors(self, ...)
20100
20099
  local roomTypes = {...}
20101
20100
  local room = game:GetRoom()
20102
- local roomTypesSet = __TS__New(Set, roomTypes)
20103
- local doorSlots = getEnumValues(nil, DoorSlot)
20101
+ local roomShape = room:GetRoomShape()
20102
+ local possibleDoorSlots = ____exports.getDoorSlotsForRoomShape(nil, roomShape)
20104
20103
  local doors = {}
20105
- for ____, doorSlot in ipairs(doorSlots) do
20104
+ for ____, doorSlot in __TS__Iterator(possibleDoorSlots) do
20106
20105
  do
20107
20106
  local door = room:GetDoor(doorSlot)
20108
20107
  if door == nil then
@@ -20112,7 +20111,7 @@ function ____exports.getDoors(self, ...)
20112
20111
  if gridEntityType ~= GridEntityType.DOOR then
20113
20112
  goto __continue25
20114
20113
  end
20115
- if roomTypesSet.size == 0 or roomTypesSet:has(door.TargetRoomType) then
20114
+ if #roomTypes == 0 or __TS__ArrayIncludes(roomTypes, door.TargetRoomType) then
20116
20115
  doors[#doors + 1] = door
20117
20116
  end
20118
20117
  end
@@ -20223,9 +20222,6 @@ function ____exports.getDoorSlotEnterPosition(self, doorSlot)
20223
20222
  local offset = ____exports.getDoorSlotEnterPositionOffset(nil, doorSlot)
20224
20223
  return position + offset
20225
20224
  end
20226
- function ____exports.getDoorSlotsForRoomShape(self, roomShape)
20227
- return ROOM_SHAPE_TO_DOOR_SLOTS[roomShape]
20228
- end
20229
20225
  function ____exports.getDoorsToRoomIndex(self, ...)
20230
20226
  local roomGridIndex = {...}
20231
20227
  local roomGridIndexesSet = __TS__New(Set, roomGridIndex)
@@ -1384,10 +1384,6 @@ local function __TS__MathSign(val)
1384
1384
  return 0
1385
1385
  end
1386
1386
 
1387
- local function __TS__Modulo50(a, b)
1388
- return a - math.floor(a / b) * b
1389
- end
1390
-
1391
1387
  local function __TS__Number(value)
1392
1388
  local valueType = type(value)
1393
1389
  if valueType == "number" then
@@ -2476,7 +2472,6 @@ return {
2476
2472
  __TS__MathAtan2 = __TS__MathAtan2,
2477
2473
  __TS__MathModf = __TS__MathModf,
2478
2474
  __TS__MathSign = __TS__MathSign,
2479
- __TS__Modulo50 = __TS__Modulo50,
2480
2475
  __TS__New = __TS__New,
2481
2476
  __TS__Number = __TS__Number,
2482
2477
  __TS__NumberIsFinite = __TS__NumberIsFinite,
@@ -3,9 +3,10 @@ local Set = ____lualib.Set
3
3
  local __TS__Spread = ____lualib.__TS__Spread
4
4
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
5
5
  local __TS__ArrayFind = ____lualib.__TS__ArrayFind
6
+ local __TS__ArrayIncludes = ____lualib.__TS__ArrayIncludes
7
+ local __TS__Iterator = ____lualib.__TS__Iterator
6
8
  local __TS__New = ____lualib.__TS__New
7
9
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
8
- local __TS__Iterator = ____lualib.__TS__Iterator
9
10
  local ____exports = {}
10
11
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
11
12
  local DoorSlot = ____isaac_2Dtypescript_2Ddefinitions.DoorSlot
@@ -58,16 +59,20 @@ function ____exports.getDoorSlotEnterPositionOffset(self, doorSlot)
58
59
  local oppositeVector = vector * -1
59
60
  return oppositeVector * DISTANCE_OF_GRID_TILE
60
61
  end
62
+ --- Helper function to get the possible door slots that can exist for a given room shape.
63
+ function ____exports.getDoorSlotsForRoomShape(self, roomShape)
64
+ return ROOM_SHAPE_TO_DOOR_SLOTS[roomShape]
65
+ end
61
66
  --- Helper function to get all of the doors in the room. By default, it will return every door. You
62
67
  -- can optionally specify one or more room types to return only the doors that match the specified
63
68
  -- room types.
64
69
  function ____exports.getDoors(self, ...)
65
70
  local roomTypes = {...}
66
71
  local room = game:GetRoom()
67
- local roomTypesSet = __TS__New(Set, roomTypes)
68
- local doorSlots = getEnumValues(nil, DoorSlot)
72
+ local roomShape = room:GetRoomShape()
73
+ local possibleDoorSlots = ____exports.getDoorSlotsForRoomShape(nil, roomShape)
69
74
  local doors = {}
70
- for ____, doorSlot in ipairs(doorSlots) do
75
+ for ____, doorSlot in __TS__Iterator(possibleDoorSlots) do
71
76
  do
72
77
  local door = room:GetDoor(doorSlot)
73
78
  if door == nil then
@@ -77,7 +82,7 @@ function ____exports.getDoors(self, ...)
77
82
  if gridEntityType ~= GridEntityType.DOOR then
78
83
  goto __continue25
79
84
  end
80
- if roomTypesSet.size == 0 or roomTypesSet:has(door.TargetRoomType) then
85
+ if #roomTypes == 0 or __TS__ArrayIncludes(roomTypes, door.TargetRoomType) then
81
86
  doors[#doors + 1] = door
82
87
  end
83
88
  end
@@ -218,10 +223,6 @@ function ____exports.getDoorSlotEnterPosition(self, doorSlot)
218
223
  local offset = ____exports.getDoorSlotEnterPositionOffset(nil, doorSlot)
219
224
  return position + offset
220
225
  end
221
- --- Helper function to get the possible door slots that can exist for a given room shape.
222
- function ____exports.getDoorSlotsForRoomShape(self, roomShape)
223
- return ROOM_SHAPE_TO_DOOR_SLOTS[roomShape]
224
- end
225
226
  --- Helper function to get all of the doors in the room that lead to the provided room index.
226
227
  --
227
228
  -- This function is variadic, meaning that you can specify N arguments to return all of the doors
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "16.1.3",
3
+ "version": "16.1.4",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -185,11 +185,11 @@ export function getDoorSlotsForRoomShape(
185
185
  */
186
186
  export function getDoors(...roomTypes: RoomType[]): GridEntityDoor[] {
187
187
  const room = game.GetRoom();
188
- const roomTypesSet = new Set(roomTypes);
188
+ const roomShape = room.GetRoomShape();
189
+ const possibleDoorSlots = getDoorSlotsForRoomShape(roomShape);
189
190
 
190
- const doorSlots = getEnumValues(DoorSlot);
191
191
  const doors: GridEntityDoor[] = [];
192
- for (const doorSlot of doorSlots) {
192
+ for (const doorSlot of possibleDoorSlots) {
193
193
  const door = room.GetDoor(doorSlot);
194
194
  if (door === undefined) {
195
195
  continue;
@@ -201,7 +201,7 @@ export function getDoors(...roomTypes: RoomType[]): GridEntityDoor[] {
201
201
  continue;
202
202
  }
203
203
 
204
- if (roomTypesSet.size === 0 || roomTypesSet.has(door.TargetRoomType)) {
204
+ if (roomTypes.length === 0 || roomTypes.includes(door.TargetRoomType)) {
205
205
  doors.push(door);
206
206
  }
207
207
  }