isaacscript-common 1.2.228 → 1.2.231

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,8 +38,9 @@ local isRNG = ____rng.isRNG
38
38
  local newRNG = ____rng.newRNG
39
39
  local ____roomData = require("functions.roomData")
40
40
  local getRoomListIndex = ____roomData.getRoomListIndex
41
+ local ____roomGrid = require("functions.roomGrid")
42
+ local gridCoordinatesToWorldPosition = ____roomGrid.gridCoordinatesToWorldPosition
41
43
  local ____rooms = require("functions.rooms")
42
- local gridToPos = ____rooms.gridToPos
43
44
  local setRoomCleared = ____rooms.setRoomCleared
44
45
  local setRoomUncleared = ____rooms.setRoomUncleared
45
46
  local ____spawnCollectible = require("functions.spawnCollectible")
@@ -122,7 +123,7 @@ function fillRoomWithDecorations(self)
122
123
  local gridSize = room:GetGridSize()
123
124
  local roomListIndex = getRoomListIndex(nil)
124
125
  local decorationGridIndexes = v.level.roomToDecorationGridIndexesMap:getAndSetDefault(roomListIndex)
125
- for ____, gridIndex in ipairs(range(nil, 0, gridSize - 1)) do
126
+ for ____, gridIndex in ipairs(range(nil, gridSize - 1)) do
126
127
  do
127
128
  local existingGridEntity = room:GetGridEntity(gridIndex)
128
129
  if existingGridEntity ~= nil then
@@ -219,7 +220,7 @@ function spawnGridEntityForJSONRoom(self, xmlEntityType, xmlEntityVariant, x, y)
219
220
  return nil
220
221
  end
221
222
  local gridEntityType, variant = table.unpack(gridEntityTuple)
222
- local position = gridToPos(nil, x, y)
223
+ local position = gridCoordinatesToWorldPosition(nil, x, y)
223
224
  local gridIndex = room:GetGridIndex(position)
224
225
  local gridEntity = spawnGridEntityWithVariant(nil, gridEntityType, variant, gridIndex)
225
226
  if gridEntity == nil then
@@ -235,7 +236,7 @@ end
235
236
  function spawnNormalEntityForJSONRoom(self, entityType, variant, subType, x, y, rng)
236
237
  local room = game:GetRoom()
237
238
  local roomType = room:GetType()
238
- local position = gridToPos(nil, x, y)
239
+ local position = gridCoordinatesToWorldPosition(nil, x, y)
239
240
  local seed = rng:Next()
240
241
  local entity
241
242
  if entityType == EntityType.ENTITY_PICKUP and variant == 100 then
@@ -41,10 +41,11 @@ local getPlayers = ____playerIndex.getPlayers
41
41
  local ____roomData = require("functions.roomData")
42
42
  local getRoomData = ____roomData.getRoomData
43
43
  local getRoomDescriptor = ____roomData.getRoomDescriptor
44
+ local ____roomGrid = require("functions.roomGrid")
45
+ local gridCoordinatesToWorldPosition = ____roomGrid.gridCoordinatesToWorldPosition
44
46
  local ____rooms = require("functions.rooms")
45
47
  local changeRoom = ____rooms.changeRoom
46
48
  local getRoomGridIndexesForType = ____rooms.getRoomGridIndexesForType
47
- local gridToPos = ____rooms.gridToPos
48
49
  local ____run = require("functions.run")
49
50
  local restart = ____run.restart
50
51
  local ____utils = require("functions.utils")
@@ -373,7 +374,7 @@ function ____exports.cards(self)
373
374
  if cardType == Card.NUM_CARDS then
374
375
  return
375
376
  end
376
- local position = gridToPos(nil, x, y)
377
+ local position = gridCoordinatesToWorldPosition(nil, x, y)
377
378
  Isaac.Spawn(
378
379
  EntityType.ENTITY_PICKUP,
379
380
  300,
@@ -655,7 +656,7 @@ function ____exports.pills(self)
655
656
  end
656
657
  local horsePillColor = pillColor + PILL_GIANT_FLAG
657
658
  local subType = horse and horsePillColor or pillColor
658
- local position = gridToPos(nil, x, y)
659
+ local position = gridCoordinatesToWorldPosition(nil, x, y)
659
660
  Isaac.Spawn(
660
661
  EntityType.ENTITY_PICKUP,
661
662
  70,
@@ -0,0 +1,8 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to benchmark the performance of a function.
4
+ *
5
+ * - If one function is supplied, it will simply report the average run time of the function.
6
+ * - If two functions are supplied, it will compare the average run times of the functions.
7
+ */
8
+ export declare function benchmark(numTrials: int, function1: () => void, function2?: () => void): int[];
@@ -0,0 +1,38 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local __TS__ArrayPush = ____lualib.__TS__ArrayPush
3
+ local ____exports = {}
4
+ local ____log = require("functions.log")
5
+ local log = ____log.log
6
+ function ____exports.benchmark(self, numTrials, function1, function2)
7
+ local numFunctions = function2 == nil and 1 or 2
8
+ local functionsText = numFunctions == 1 and "1 function" or "2 functions"
9
+ log(((("Benchmarking " .. functionsText) .. " with ") .. tostring(numTrials)) .. " trials.")
10
+ local averages = {}
11
+ do
12
+ local i = 1
13
+ while i <= numFunctions do
14
+ local functionToUse = i == 1 and function1 or function2
15
+ if functionToUse == nil then
16
+ error("Failed to find the benchmarking function to use.")
17
+ end
18
+ local totalTimeMilliseconds = 0
19
+ do
20
+ local j = 0
21
+ while j < numTrials do
22
+ local startTimeMilliseconds = Isaac.GetTime()
23
+ functionToUse(nil)
24
+ local endTimeMilliseconds = Isaac.GetTime()
25
+ local elapsedTimeMilliseconds = endTimeMilliseconds - startTimeMilliseconds
26
+ totalTimeMilliseconds = totalTimeMilliseconds + elapsedTimeMilliseconds
27
+ j = j + 1
28
+ end
29
+ end
30
+ local averageTimeMilliseconds = totalTimeMilliseconds / numTrials
31
+ log(((("The average time of function " .. tostring(i)) .. " is: ") .. tostring(averageTimeMilliseconds)) .. " milliseconds")
32
+ __TS__ArrayPush(averages, averageTimeMilliseconds)
33
+ i = i + 1
34
+ end
35
+ end
36
+ return averages
37
+ end
38
+ return ____exports
@@ -0,0 +1,19 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /** A collection of the four sprites necessary in order to render a charge bar. */
3
+ export interface ChargeBarSprites {
4
+ back: Sprite;
5
+ meter: Sprite;
6
+ meterBattery: Sprite;
7
+ lines: Sprite;
8
+ maxCharges: int;
9
+ }
10
+ /**
11
+ * Constructor for a `ChargeBarSprites` object. For more information, see the `renderChargeBar`
12
+ * helper function.
13
+ */
14
+ export declare function newChargeBarSprites(maxCharges: int): ChargeBarSprites;
15
+ /**
16
+ * Helper function to render a charge bar on the screen. First, call the `newChargeBarSprites`
17
+ * function to initialize the sprites, and then call this function on every render frame.
18
+ */
19
+ export declare function renderChargeBar(sprites: ChargeBarSprites, position: Vector, normalCharges: int, batteryCharges: int): void;
@@ -0,0 +1,42 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local getChargeBarClamp
4
+ function getChargeBarClamp(self, charges, maxCharges)
5
+ local meterMultiplier = 24 / maxCharges
6
+ local meterClip = 26 - charges * meterMultiplier
7
+ return Vector(0, meterClip)
8
+ end
9
+ local CHARGE_BAR_ANM2 = "gfx/ui/ui_chargebar.anm2"
10
+ function ____exports.newChargeBarSprites(self, maxCharges)
11
+ local back = Sprite()
12
+ back:Load(CHARGE_BAR_ANM2, true)
13
+ back:Play("BarEmpty", true)
14
+ local meter = Sprite()
15
+ meter:Load(CHARGE_BAR_ANM2, true)
16
+ meter:Play("BarFull", true)
17
+ local meterBattery = Sprite()
18
+ meterBattery:Load(CHARGE_BAR_ANM2, true)
19
+ meterBattery:Play("BarFull", true)
20
+ local lines = Sprite()
21
+ lines:Load(CHARGE_BAR_ANM2, true)
22
+ lines:Play(
23
+ "BarOverlay" .. tostring(maxCharges),
24
+ true
25
+ )
26
+ return {
27
+ back = back,
28
+ meter = meter,
29
+ meterBattery = meterBattery,
30
+ lines = lines,
31
+ maxCharges = maxCharges
32
+ }
33
+ end
34
+ function ____exports.renderChargeBar(self, sprites, position, normalCharges, batteryCharges)
35
+ sprites.back:Render(position, Vector.Zero, Vector.Zero)
36
+ local normalChargesClamp = getChargeBarClamp(nil, normalCharges, sprites.maxCharges)
37
+ sprites.meter:Render(position, normalChargesClamp, Vector.Zero)
38
+ local batteryChargesClamp = getChargeBarClamp(nil, batteryCharges, sprites.maxCharges)
39
+ sprites.meterBattery:Render(position, batteryChargesClamp, Vector.Zero)
40
+ sprites.lines:Render(position, Vector.Zero, Vector.Zero)
41
+ end
42
+ return ____exports
@@ -29,7 +29,7 @@ function getAllGridEntities(self)
29
29
  local room = game:GetRoom()
30
30
  local gridSize = room:GetGridSize()
31
31
  local gridEntities = {}
32
- for ____, gridIndex in ipairs(range(nil, 0, gridSize - 1)) do
32
+ for ____, gridIndex in ipairs(range(nil, gridSize - 1)) do
33
33
  local gridEntity = room:GetGridEntity(gridIndex)
34
34
  if gridEntity ~= nil then
35
35
  __TS__ArrayPush(gridEntities, gridEntity)
@@ -84,14 +84,14 @@ function ____exports.getShootActions(self)
84
84
  return copySet(nil, SHOOTING_ACTIONS_SET)
85
85
  end
86
86
  function ____exports.isActionPressedOnAnyInput(self, buttonAction)
87
- local validInputs = range(nil, 0, MAX_NUM_INPUTS - 1)
87
+ local validInputs = range(nil, MAX_NUM_INPUTS - 1)
88
88
  return __TS__ArraySome(
89
89
  validInputs,
90
90
  function(____, input) return Input.IsActionPressed(buttonAction, input) end
91
91
  )
92
92
  end
93
93
  function ____exports.isActionTriggeredOnAnyInput(self, buttonAction)
94
- local validInputs = range(nil, 0, MAX_NUM_INPUTS - 1)
94
+ local validInputs = range(nil, MAX_NUM_INPUTS - 1)
95
95
  return __TS__ArraySome(
96
96
  validInputs,
97
97
  function(____, input) return Input.IsActionTriggered(buttonAction, input) end
@@ -380,7 +380,7 @@ function ____exports.logSet(set)
380
380
  ____exports.log("The size of the set was: " .. tostring(set.size))
381
381
  end
382
382
  function ____exports.logSounds()
383
- for ____, soundEffect in ipairs(range(nil, 0, SoundEffect.NUM_SOUND_EFFECTS - 1)) do
383
+ for ____, soundEffect in ipairs(range(nil, SoundEffect.NUM_SOUND_EFFECTS - 1)) do
384
384
  if sfxManager:IsPlaying(soundEffect) then
385
385
  ____exports.log("Currently playing sound effect: " .. tostring(soundEffect))
386
386
  end
@@ -15,8 +15,10 @@ export declare function getAngleDifference(angle1: float, angle2: float): float;
15
15
  */
16
16
  export declare function getCircleDiscretizedPoints(centerPos: Vector, radius: float, numPoints: int, xMultiplier?: number, yMultiplier?: number, initialDirection?: Direction): Vector[];
17
17
  /**
18
- * Helper function to check if a given position is within a given rectangle. This is an inclusive
19
- * check, meaning that it will return true if the position is on the border of the rectangle.
18
+ * Helper function to check if a given position is within a given rectangle.
19
+ *
20
+ * This is an inclusive check, meaning that it will return true if the position is on the border of
21
+ * the rectangle.
20
22
  */
21
23
  export declare function inRectangle(position: Vector, topLeft: Vector, bottomRight: Vector): boolean;
22
24
  /**
@@ -27,8 +29,12 @@ export declare function isEven(num: int): boolean;
27
29
  export declare function isOdd(num: int): boolean;
28
30
  export declare function lerp(a: number, b: number, pos: float): number;
29
31
  export declare function lerpAngleDegrees(aStart: number, aEnd: number, percent: float): number;
30
- /** Helper function to return an array with the elements from start to end, inclusive. */
31
- export declare function range(start: int, end: int): int[];
32
+ /**
33
+ * Helper function to return an array with the elements from start to end, inclusive.
34
+ *
35
+ * If only one argument is specified, then it will assume that the start is 0.
36
+ */
37
+ export declare function range(start: int, end?: int): int[];
32
38
  /**
33
39
  * If rounding fails, this function returns 0.
34
40
  * From: http://lua-users.org/wiki/SimpleRound
@@ -67,6 +67,10 @@ function ____exports.lerpAngleDegrees(self, aStart, aEnd, percent)
67
67
  return aStart + ____exports.getAngleDifference(nil, aStart, aEnd) * percent
68
68
  end
69
69
  function ____exports.range(self, start, ____end)
70
+ if ____end == nil then
71
+ ____end = start
72
+ start = 0
73
+ end
70
74
  local array = {}
71
75
  do
72
76
  local i = start
@@ -20,7 +20,7 @@ function ____exports.getPocketItems(self, player)
20
20
  local pocketItems = {}
21
21
  local pocketItemIdentified = false
22
22
  local pocketItem2Identified = false
23
- for ____, slot in ipairs(range(nil, 0, MAX_PLAYER_POCKET_ITEM_SLOTS - 1)) do
23
+ for ____, slot in ipairs(range(nil, MAX_PLAYER_POCKET_ITEM_SLOTS - 1)) do
24
24
  local card = player:GetCard(slot)
25
25
  local pillColor = player:GetPill(slot)
26
26
  if card ~= Card.CARD_NULL then
@@ -0,0 +1,40 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Helper function to convert grid coordinates to a world position `Vector`.
4
+ *
5
+ * For example, the coordinates of (0, 0) are equal to `Vector(80, 160)`.
6
+ */
7
+ export declare function gridCoordinatesToWorldPosition(x: int, y: int): Vector;
8
+ /**
9
+ * Helper function to convert a grid index to a grid position.
10
+ *
11
+ * For example, in a 1x1 room, grid index 0 is equal to "Vector(-1, -1) and grid index 16 is equal
12
+ * to "Vector(0, 0)".
13
+ */
14
+ export declare function gridIndexToGridPosition(gridIndex: int, roomShape: RoomShape): Vector;
15
+ /**
16
+ * Helper function to convert a grid position `Vector` to a world position `Vector`.
17
+ *
18
+ * For example, the coordinates of (0, 0) are equal to `Vector(80, 160)`.
19
+ */
20
+ export declare function gridPositionToWorldPosition(gridPosition: Vector): Vector;
21
+ /**
22
+ * Test if a grid position is actually in the given `RoomShape`
23
+ *
24
+ * In this context, the grid position of the top-left wall is "Vector(-1, -1)".
25
+ */
26
+ export declare function isValidGridPosition(gridPosition: Vector, roomShape: RoomShape): boolean;
27
+ /**
28
+ * Helper function to convert a world position `Vector` to a grid position `Vector`.
29
+ *
30
+ * In this context, the grid position of the top-left wall is "Vector(-1, -1)".
31
+ */
32
+ export declare function worldPositionToGridPosition(worldPos: Vector): Vector;
33
+ /**
34
+ * Helper function to convert a world position `Vector` to a grid position `Vector`.
35
+ *
36
+ * In this context, the grid position of the top-left wall is "Vector(-1, -1)".
37
+ *
38
+ * This is similar to the `worldPositionToGridPosition` function, but the values are not rounded.
39
+ */
40
+ export declare function worldPositionToGridPositionFast(worldPos: Vector): Vector;
@@ -0,0 +1,59 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local isValidGridPositionNormal, isValidGridPositionLRoom
4
+ local ____LRoomShapeToRectangles = require("objects.LRoomShapeToRectangles")
5
+ local L_ROOM_SHAPE_TO_RECTANGLES = ____LRoomShapeToRectangles.L_ROOM_SHAPE_TO_RECTANGLES
6
+ local ____math = require("functions.math")
7
+ local inRectangle = ____math.inRectangle
8
+ local ____roomShape = require("functions.roomShape")
9
+ local getRoomShapeTopLeftPosition = ____roomShape.getRoomShapeTopLeftPosition
10
+ local getRoomShapeWidth = ____roomShape.getRoomShapeWidth
11
+ local isLRoom = ____roomShape.isLRoom
12
+ function ____exports.gridPositionToWorldPosition(self, gridPosition)
13
+ local x = (gridPosition.X + 2) * 40
14
+ local y = (gridPosition.Y + 4) * 40
15
+ return Vector(x, y)
16
+ end
17
+ function isValidGridPositionNormal(self, gridPosition, roomShape)
18
+ local topLeft = getRoomShapeTopLeftPosition(nil, roomShape)
19
+ local bottomRight = getRoomShapeTopLeftPosition(nil, roomShape)
20
+ return inRectangle(nil, gridPosition, topLeft, bottomRight)
21
+ end
22
+ function isValidGridPositionLRoom(self, gridPosition, roomShape)
23
+ local rectangles = L_ROOM_SHAPE_TO_RECTANGLES[roomShape]
24
+ if rectangles == nil then
25
+ return false
26
+ end
27
+ local verticalTopLeft, verticalBottomRight, horizontalTopLeft, horizontalBottomRight = table.unpack(rectangles)
28
+ return inRectangle(nil, gridPosition, verticalTopLeft, verticalBottomRight) and inRectangle(nil, gridPosition, horizontalTopLeft, horizontalBottomRight)
29
+ end
30
+ function ____exports.gridCoordinatesToWorldPosition(self, x, y)
31
+ local gridPosition = Vector(x, y)
32
+ return ____exports.gridPositionToWorldPosition(nil, gridPosition)
33
+ end
34
+ function ____exports.gridIndexToGridPosition(self, gridIndex, roomShape)
35
+ local gridWidth = getRoomShapeWidth(nil, roomShape)
36
+ local x = gridIndex % gridWidth - 1
37
+ local y = math.floor(gridIndex / gridWidth) - 1
38
+ return Vector(x, y)
39
+ end
40
+ function ____exports.isValidGridPosition(self, gridPosition, roomShape)
41
+ local ____isLRoom_result_0
42
+ if isLRoom(nil, roomShape) then
43
+ ____isLRoom_result_0 = isValidGridPositionLRoom(nil, gridPosition, roomShape)
44
+ else
45
+ ____isLRoom_result_0 = isValidGridPositionNormal(nil, gridPosition, roomShape)
46
+ end
47
+ return ____isLRoom_result_0
48
+ end
49
+ function ____exports.worldPositionToGridPosition(self, worldPos)
50
+ local x = math.floor(worldPos.X / 40 - 2 + 0.5)
51
+ local y = math.floor(worldPos.Y / 40 - 4 + 0.5)
52
+ return Vector(x, y)
53
+ end
54
+ function ____exports.worldPositionToGridPositionFast(self, worldPos)
55
+ local x = worldPos.X / 40 - 2
56
+ local y = worldPos.Y / 40 - 4
57
+ return Vector(x, y)
58
+ end
59
+ return ____exports
@@ -39,3 +39,5 @@ export declare function getRoomShapeTopLeftPosition(roomShape: RoomShape): Vecto
39
39
  * (This cannot be directly calculated from the bounds since L rooms are a special case.)
40
40
  */
41
41
  export declare function getRoomShapeVolume(roomShape: RoomShape): int;
42
+ export declare function getRoomShapeWidth(roomShape: RoomShape): int;
43
+ export declare function isLRoom(roomShape: RoomShape): boolean;
@@ -7,17 +7,18 @@ local ____roomShapeLayoutSizes = require("objects.roomShapeLayoutSizes")
7
7
  local ROOM_SHAPE_LAYOUT_SIZES = ____roomShapeLayoutSizes.ROOM_SHAPE_LAYOUT_SIZES
8
8
  local ____roomShapeToBottomRightPosition = require("objects.roomShapeToBottomRightPosition")
9
9
  local ROOM_SHAPE_TO_BOTTOM_RIGHT_POSITION = ____roomShapeToBottomRightPosition.ROOM_SHAPE_TO_BOTTOM_RIGHT_POSITION
10
- local ____roomShapeToGridIndexDelta = require("objects.roomShapeToGridIndexDelta")
11
- local ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA = ____roomShapeToGridIndexDelta.ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA
10
+ local ____roomShapeToDoorSlotsToGridIndexDelta = require("objects.roomShapeToDoorSlotsToGridIndexDelta")
11
+ local ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA = ____roomShapeToDoorSlotsToGridIndexDelta.ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA
12
+ local ____roomShapeToGridWidth = require("objects.roomShapeToGridWidth")
13
+ local ROOM_SHAPE_TO_GRID_WIDTH = ____roomShapeToGridWidth.ROOM_SHAPE_TO_GRID_WIDTH
12
14
  local ____roomShapeToTopLeftPosition = require("objects.roomShapeToTopLeftPosition")
13
15
  local ROOM_SHAPE_TO_TOP_LEFT_POSITION = ____roomShapeToTopLeftPosition.ROOM_SHAPE_TO_TOP_LEFT_POSITION
14
16
  local ____roomShapeVolumes = require("objects.roomShapeVolumes")
15
17
  local ROOM_SHAPE_VOLUMES = ____roomShapeVolumes.ROOM_SHAPE_VOLUMES
18
+ local ____LRoomShapesSet = require("sets.LRoomShapesSet")
19
+ local L_ROOM_SHAPES_SET = ____LRoomShapesSet.L_ROOM_SHAPES_SET
16
20
  function ____exports.getGridIndexDelta(self, roomShape, doorSlot)
17
21
  local doorSlotToGridIndexMap = ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA[roomShape]
18
- if doorSlotToGridIndexMap == nil then
19
- return nil
20
- end
21
22
  return doorSlotToGridIndexMap:get(doorSlot)
22
23
  end
23
24
  function ____exports.getRoomShapeBottomRightPosition(self, roomShape)
@@ -35,4 +36,10 @@ end
35
36
  function ____exports.getRoomShapeVolume(self, roomShape)
36
37
  return ROOM_SHAPE_VOLUMES[roomShape]
37
38
  end
39
+ function ____exports.getRoomShapeWidth(self, roomShape)
40
+ return ROOM_SHAPE_TO_GRID_WIDTH[roomShape]
41
+ end
42
+ function ____exports.isLRoom(self, roomShape)
43
+ return L_ROOM_SHAPES_SET:has(roomShape)
44
+ end
38
45
  return ____exports
@@ -39,11 +39,6 @@ export declare function getRoomItemPoolType(): ItemPoolType;
39
39
  * `RoomList`. Default is false.
40
40
  */
41
41
  export declare function getRooms(includeExtraDimensionalRooms?: boolean): RoomDescriptor[];
42
- /**
43
- * Converts a room X and Y coordinate to a position. For example, the coordinates of 0, 0 are
44
- * equal to `Vector(80, 160)`.
45
- */
46
- export declare function gridToPos(x: int, y: int): Vector;
47
42
  /**
48
43
  * Helper function to determine if the current room shape is equal to `RoomShape.ROOMSHAPE_1x2` or
49
44
  * `RoomShape.ROOMSHAPE_2x1`.
@@ -105,7 +105,7 @@ function ____exports.getCurrentDimension(self)
105
105
  local startingRoomGridIndex = level:GetStartingRoomIndex()
106
106
  local startingRoomDescription = level:GetRoomByIdx(startingRoomGridIndex, -1)
107
107
  local startingRoomHash = GetPtrHash(startingRoomDescription)
108
- for ____, dimension in ipairs(range(nil, 0, NUM_DIMENSIONS - 1)) do
108
+ for ____, dimension in ipairs(range(nil, NUM_DIMENSIONS - 1)) do
109
109
  local dimensionRoomDescription = level:GetRoomByIdx(startingRoomGridIndex, dimension)
110
110
  local dimensionRoomHash = GetPtrHash(dimensionRoomDescription)
111
111
  if dimensionRoomHash == startingRoomHash then
@@ -133,13 +133,6 @@ function ____exports.getRoomItemPoolType(self)
133
133
  local roomSeed = room:GetSpawnSeed()
134
134
  return itemPool:GetPoolForRoom(roomType, roomSeed)
135
135
  end
136
- function ____exports.gridToPos(self, x, y)
137
- local room = game:GetRoom()
138
- x = x + 1
139
- y = y + 1
140
- local gridIndex = y * room:GetGridWidth() + x
141
- return room:GetGridPosition(gridIndex)
142
- end
143
136
  function ____exports.in2x1Room(self)
144
137
  local room = game:GetRoom()
145
138
  local roomShape = room:GetRoomShape()
@@ -274,12 +267,12 @@ function ____exports.setRoomCleared(self)
274
267
  for ____, door in ipairs(getDoors(nil)) do
275
268
  do
276
269
  if isHiddenSecretRoomDoor(nil, door) then
277
- goto __continue52
270
+ goto __continue51
278
271
  end
279
272
  openDoorFast(nil, door)
280
273
  door.ExtraVisible = false
281
274
  end
282
- ::__continue52::
275
+ ::__continue51::
283
276
  end
284
277
  sfxManager:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
285
278
  game:ShakeScreen(0)
@@ -15,7 +15,7 @@ function ____exports.clearSprite(self, sprite, ...)
15
15
  local layerIDs = {...}
16
16
  if #layerIDs == 0 then
17
17
  local numLayers = sprite:GetLayerCount()
18
- layerIDs = range(nil, 0, numLayers - 1)
18
+ layerIDs = range(nil, numLayers - 1)
19
19
  end
20
20
  for ____, layerID in ipairs(layerIDs) do
21
21
  sprite:ReplaceSpritesheet(layerID, EMPTY_PNG_PATH)
package/dist/index.d.ts CHANGED
@@ -29,12 +29,14 @@ export * from "./features/saveDataManager/exports";
29
29
  export { hasSirenStolenFamiliar, setFamiliarNoSirenSteal, } from "./features/sirenHelpers";
30
30
  export { getTaintedLazarusSubPlayer } from "./features/taintedLazarusPlayers";
31
31
  export * from "./functions/array";
32
+ export * from "./functions/benchmark";
32
33
  export * from "./functions/bitwise";
33
34
  export * from "./functions/cacheFlag";
34
35
  export * from "./functions/cards";
35
36
  export * from "./functions/challenges";
36
37
  export * from "./functions/character";
37
38
  export * from "./functions/charge";
39
+ export * from "./functions/chargeBar";
38
40
  export * from "./functions/collectibleCacheFlag";
39
41
  export * from "./functions/collectibles";
40
42
  export * from "./functions/collectibleSet";
@@ -73,6 +75,7 @@ export * from "./functions/random";
73
75
  export * from "./functions/revive";
74
76
  export * from "./functions/rng";
75
77
  export * from "./functions/roomData";
78
+ export * from "./functions/roomGrid";
76
79
  export * from "./functions/rooms";
77
80
  export * from "./functions/roomShape";
78
81
  export * from "./functions/run";
package/dist/index.lua CHANGED
@@ -241,6 +241,14 @@ do
241
241
  end
242
242
  end
243
243
  end
244
+ do
245
+ local ____export = require("functions.benchmark")
246
+ for ____exportKey, ____exportValue in pairs(____export) do
247
+ if ____exportKey ~= "default" then
248
+ ____exports[____exportKey] = ____exportValue
249
+ end
250
+ end
251
+ end
244
252
  do
245
253
  local ____export = require("functions.bitwise")
246
254
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -289,6 +297,14 @@ do
289
297
  end
290
298
  end
291
299
  end
300
+ do
301
+ local ____export = require("functions.chargeBar")
302
+ for ____exportKey, ____exportValue in pairs(____export) do
303
+ if ____exportKey ~= "default" then
304
+ ____exports[____exportKey] = ____exportValue
305
+ end
306
+ end
307
+ end
292
308
  do
293
309
  local ____export = require("functions.collectibleCacheFlag")
294
310
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -584,6 +600,14 @@ do
584
600
  end
585
601
  end
586
602
  end
603
+ do
604
+ local ____export = require("functions.roomGrid")
605
+ for ____exportKey, ____exportValue in pairs(____export) do
606
+ if ____exportKey ~= "default" then
607
+ ____exports[____exportKey] = ____exportValue
608
+ end
609
+ end
610
+ end
587
611
  do
588
612
  local ____export = require("functions.rooms")
589
613
  for ____exportKey, ____exportValue in pairs(____export) do
@@ -0,0 +1,13 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * "Vector(0, 0)" corresponds to the top left tile of a room, not including the walls. (The top-left
4
+ * wall would be at "Vector(-1, -1)".)
5
+ */
6
+ export declare const L_ROOM_SHAPE_TO_RECTANGLES: {
7
+ [key in RoomShape]?: [
8
+ verticalTopLeft: Vector,
9
+ verticalBottomRight: Vector,
10
+ horizontalTopLeft: Vector,
11
+ horizontalBottomRight: Vector
12
+ ];
13
+ };
@@ -0,0 +1,30 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local TWO_BY_TWO_BOTTOM_RIGHT = Vector(25, 13)
4
+ ____exports.L_ROOM_SHAPE_TO_RECTANGLES = {
5
+ [RoomShape.ROOMSHAPE_LTL] = {
6
+ Vector(13, 0),
7
+ Vector(25, 13),
8
+ Vector(0, 7),
9
+ TWO_BY_TWO_BOTTOM_RIGHT
10
+ },
11
+ [RoomShape.ROOMSHAPE_LTR] = {
12
+ Vector.Zero,
13
+ Vector(12, 13),
14
+ Vector(0, 7),
15
+ TWO_BY_TWO_BOTTOM_RIGHT
16
+ },
17
+ [RoomShape.ROOMSHAPE_LBL] = {
18
+ Vector.Zero,
19
+ Vector(25, 6),
20
+ Vector(13, 0),
21
+ TWO_BY_TWO_BOTTOM_RIGHT
22
+ },
23
+ [RoomShape.ROOMSHAPE_LBR] = {
24
+ Vector.Zero,
25
+ Vector(25, 6),
26
+ Vector.Zero,
27
+ Vector(12, 13)
28
+ }
29
+ }
30
+ return ____exports
@@ -0,0 +1,8 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /**
3
+ * Deltas are considered to be from the safe grid index of the room (i.e. the top left corner, or
4
+ * top right corner in the case of `RoomShape.ROOMSHAPE_LTL`).
5
+ */
6
+ export declare const ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA: {
7
+ readonly [key in RoomShape]: Map<DoorSlot, int>;
8
+ };
@@ -0,0 +1,85 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Map = ____lualib.Map
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ local ____constants = require("constants")
6
+ local LEVEL_GRID_ROW_LENGTH = ____constants.LEVEL_GRID_ROW_LENGTH
7
+ local LEFT = -1
8
+ local UP = -LEVEL_GRID_ROW_LENGTH
9
+ local RIGHT = 1
10
+ local DOWN = LEVEL_GRID_ROW_LENGTH
11
+ ____exports.ROOM_SHAPE_TO_DOOR_SLOTS_TO_GRID_INDEX_DELTA = {
12
+ [RoomShape.ROOMSHAPE_1x1] = __TS__New(Map, {{DoorSlot.LEFT0, LEFT}, {DoorSlot.UP0, UP}, {DoorSlot.RIGHT0, RIGHT}, {DoorSlot.DOWN0, DOWN}}),
13
+ [RoomShape.ROOMSHAPE_IH] = __TS__New(Map, {{DoorSlot.LEFT0, LEFT}, {DoorSlot.RIGHT0, RIGHT}}),
14
+ [RoomShape.ROOMSHAPE_IV] = __TS__New(Map, {{DoorSlot.UP0, UP}, {DoorSlot.DOWN0, DOWN}}),
15
+ [RoomShape.ROOMSHAPE_1x2] = __TS__New(Map, {
16
+ {DoorSlot.LEFT0, LEFT},
17
+ {DoorSlot.UP0, UP},
18
+ {DoorSlot.RIGHT0, RIGHT},
19
+ {DoorSlot.DOWN0, DOWN + DOWN},
20
+ {DoorSlot.LEFT1, DOWN + LEFT},
21
+ {DoorSlot.RIGHT1, DOWN + RIGHT}
22
+ }),
23
+ [RoomShape.ROOMSHAPE_IIV] = __TS__New(Map, {{DoorSlot.UP0, UP}, {DoorSlot.DOWN0, DOWN + DOWN}}),
24
+ [RoomShape.ROOMSHAPE_2x1] = __TS__New(Map, {
25
+ {DoorSlot.LEFT0, LEFT},
26
+ {DoorSlot.UP0, UP},
27
+ {DoorSlot.RIGHT0, RIGHT + RIGHT},
28
+ {DoorSlot.DOWN0, DOWN},
29
+ {DoorSlot.UP1, RIGHT + UP},
30
+ {DoorSlot.DOWN1, RIGHT + DOWN}
31
+ }),
32
+ [RoomShape.ROOMSHAPE_IIH] = __TS__New(Map, {{DoorSlot.LEFT0, LEFT}, {DoorSlot.RIGHT0, RIGHT + RIGHT}}),
33
+ [RoomShape.ROOMSHAPE_2x2] = __TS__New(Map, {
34
+ {DoorSlot.LEFT0, LEFT},
35
+ {DoorSlot.UP0, UP},
36
+ {DoorSlot.RIGHT0, RIGHT + RIGHT},
37
+ {DoorSlot.DOWN0, DOWN + DOWN},
38
+ {DoorSlot.LEFT1, DOWN + LEFT},
39
+ {DoorSlot.UP1, RIGHT + UP},
40
+ {DoorSlot.RIGHT1, RIGHT + DOWN + RIGHT},
41
+ {DoorSlot.DOWN1, RIGHT + DOWN + DOWN}
42
+ }),
43
+ [RoomShape.ROOMSHAPE_LTL] = __TS__New(Map, {
44
+ {DoorSlot.LEFT0, LEFT},
45
+ {DoorSlot.UP0, DOWN + LEFT + UP},
46
+ {DoorSlot.RIGHT0, RIGHT},
47
+ {DoorSlot.DOWN0, DOWN + LEFT + DOWN},
48
+ {DoorSlot.LEFT1, DOWN + LEFT + LEFT},
49
+ {DoorSlot.UP1, UP},
50
+ {DoorSlot.RIGHT1, DOWN + RIGHT},
51
+ {DoorSlot.DOWN1, DOWN + DOWN}
52
+ }),
53
+ [RoomShape.ROOMSHAPE_LTR] = __TS__New(Map, {
54
+ {DoorSlot.LEFT0, LEFT},
55
+ {DoorSlot.UP0, UP},
56
+ {DoorSlot.RIGHT0, RIGHT},
57
+ {DoorSlot.DOWN0, DOWN + DOWN},
58
+ {DoorSlot.LEFT1, DOWN + LEFT},
59
+ {DoorSlot.UP1, DOWN + RIGHT + UP},
60
+ {DoorSlot.RIGHT1, DOWN + RIGHT + RIGHT},
61
+ {DoorSlot.DOWN1, DOWN + RIGHT + DOWN}
62
+ }),
63
+ [RoomShape.ROOMSHAPE_LBL] = __TS__New(Map, {
64
+ {DoorSlot.LEFT0, LEFT},
65
+ {DoorSlot.UP0, UP},
66
+ {DoorSlot.RIGHT0, RIGHT + RIGHT},
67
+ {DoorSlot.DOWN0, DOWN},
68
+ {DoorSlot.LEFT1, RIGHT + DOWN + LEFT},
69
+ {DoorSlot.UP1, RIGHT + UP},
70
+ {DoorSlot.RIGHT1, RIGHT + DOWN + RIGHT},
71
+ {DoorSlot.DOWN1, RIGHT + DOWN + DOWN}
72
+ }),
73
+ [RoomShape.ROOMSHAPE_LBR] = __TS__New(Map, {
74
+ {DoorSlot.LEFT0, LEFT},
75
+ {DoorSlot.UP0, UP},
76
+ {DoorSlot.RIGHT0, RIGHT + RIGHT},
77
+ {DoorSlot.DOWN0, DOWN + DOWN},
78
+ {DoorSlot.LEFT1, DOWN + LEFT},
79
+ {DoorSlot.UP1, RIGHT + UP},
80
+ {DoorSlot.RIGHT1, DOWN + RIGHT},
81
+ {DoorSlot.DOWN1, RIGHT + DOWN}
82
+ }),
83
+ [RoomShape.NUM_ROOMSHAPES] = __TS__New(Map)
84
+ }
85
+ return ____exports
@@ -0,0 +1,4 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export declare const ROOM_SHAPE_TO_GRID_WIDTH: {
3
+ readonly [key in RoomShape]: int;
4
+ };
@@ -0,0 +1,20 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local ONE_BY_ONE_WIDTH = 15
4
+ local TWO_BY_ONE_WIDTH = 28
5
+ ____exports.ROOM_SHAPE_TO_GRID_WIDTH = {
6
+ [RoomShape.ROOMSHAPE_1x1] = ONE_BY_ONE_WIDTH,
7
+ [RoomShape.ROOMSHAPE_IH] = ONE_BY_ONE_WIDTH,
8
+ [RoomShape.ROOMSHAPE_IV] = ONE_BY_ONE_WIDTH,
9
+ [RoomShape.ROOMSHAPE_1x2] = ONE_BY_ONE_WIDTH,
10
+ [RoomShape.ROOMSHAPE_IIV] = ONE_BY_ONE_WIDTH,
11
+ [RoomShape.ROOMSHAPE_2x1] = TWO_BY_ONE_WIDTH,
12
+ [RoomShape.ROOMSHAPE_IIH] = TWO_BY_ONE_WIDTH,
13
+ [RoomShape.ROOMSHAPE_2x2] = TWO_BY_ONE_WIDTH,
14
+ [RoomShape.ROOMSHAPE_LTL] = TWO_BY_ONE_WIDTH,
15
+ [RoomShape.ROOMSHAPE_LTR] = TWO_BY_ONE_WIDTH,
16
+ [RoomShape.ROOMSHAPE_LBL] = TWO_BY_ONE_WIDTH,
17
+ [RoomShape.ROOMSHAPE_LBR] = TWO_BY_ONE_WIDTH,
18
+ [RoomShape.NUM_ROOMSHAPES] = 0
19
+ }
20
+ return ____exports
@@ -0,0 +1,2 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ export declare const L_ROOM_SHAPES_SET: ReadonlySet<RoomShape>;
@@ -0,0 +1,6 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
4
+ local ____exports = {}
5
+ ____exports.L_ROOM_SHAPES_SET = __TS__New(Set, {RoomShape.ROOMSHAPE_LTL, RoomShape.ROOMSHAPE_LTR, RoomShape.ROOMSHAPE_LBL, RoomShape.ROOMSHAPE_LBR})
6
+ return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.228",
3
+ "version": "1.2.231",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,7 +25,7 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "devDependencies": {
28
- "isaac-typescript-definitions": "^1.0.384",
28
+ "isaac-typescript-definitions": "^1.0.385",
29
29
  "isaacscript-lint": "^1.0.95",
30
30
  "isaacscript-tsconfig": "^1.1.8",
31
31
  "typedoc": "^0.22.13",