isaacscript-common 1.0.545 → 1.0.549

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.
@@ -90,7 +90,7 @@ export declare function removeGridEntity(gridEntity: GridEntity, updateRoom?: bo
90
90
  * Helper function to make a grid entity invisible. This is accomplished by setting its sprite to
91
91
  * an empty/missing PNG file.
92
92
  *
93
- * For more information, see the documentation for the "EMPTY_PNG_FILENAME" constant.
93
+ * For more information, see the documentation for the `clearSprite()` helper function.
94
94
  */
95
95
  export declare function setGridEntityInvisible(gridEntity: GridEntity): void;
96
96
  export declare function spawnGiantPoop(topLeftGridIndex: int): void;
@@ -1,8 +1,6 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  require("lualib_bundle");
3
3
  local ____exports = {}
4
- local ____constants = require("constants")
5
- local EMPTY_PNG_PATH = ____constants.EMPTY_PNG_PATH
6
4
  local ____gridEntityXMLMap = require("maps.gridEntityXMLMap")
7
5
  local GRID_ENTITY_XML_MAP = ____gridEntityXMLMap.GRID_ENTITY_XML_MAP
8
6
  local ____roomShapeToTopLeftWallGridIndexMap = require("maps.roomShapeToTopLeftWallGridIndexMap")
@@ -10,6 +8,8 @@ local DEFAULT_TOP_LEFT_WALL_GRID_INDEX = ____roomShapeToTopLeftWallGridIndexMap.
10
8
  local ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP = ____roomShapeToTopLeftWallGridIndexMap.ROOM_SHAPE_TO_TOP_LEFT_WALL_GRID_INDEX_MAP
11
9
  local ____rooms = require("functions.rooms")
12
10
  local roomUpdateSafe = ____rooms.roomUpdateSafe
11
+ local ____sprite = require("functions.sprite")
12
+ local clearSprite = ____sprite.clearSprite
13
13
  function ____exports.getTopLeftWallGridIndex(self)
14
14
  local game = Game()
15
15
  local room = game:GetRoom()
@@ -161,8 +161,7 @@ function ____exports.removeAllMatchingGridEntities(self, ...)
161
161
  end
162
162
  function ____exports.setGridEntityInvisible(self, gridEntity)
163
163
  local sprite = gridEntity:GetSprite()
164
- sprite:ReplaceSpritesheet(0, EMPTY_PNG_PATH)
165
- sprite:LoadGraphics()
164
+ clearSprite(nil, sprite)
166
165
  end
167
166
  function ____exports.spawnGiantPoop(self, topLeftGridIndex)
168
167
  local game = Game()
@@ -7,6 +7,8 @@
7
7
  export declare function changeRoom(roomGridIndex: int): void;
8
8
  export declare function getAllRoomGridIndexes(): int[];
9
9
  export declare function getCurrentDimension(): Dimension;
10
+ /** An alias to the `Level.GetCurrentRoomDesc()` method. */
11
+ export declare function getCurrentRoomDescReadOnly(): RoomDescriptorReadOnly;
10
12
  export declare function getRoomData(): RoomConfig | undefined;
11
13
  /**
12
14
  * Helper function to get the type for the room from the XML/STB data. The room data type will
@@ -126,6 +128,11 @@ export declare function inCrawlspace(): boolean;
126
128
  * with the Death Certificate area.
127
129
  */
128
130
  export declare function inDeathCertificateArea(): boolean;
131
+ /**
132
+ * Helper function to detect if the current room is a Treasure Room created when entering with a
133
+ * Devil's Crown trinket. Under the hood, this checks for the `RoomDescriptorFlag.DEVIL_TREASURE`
134
+ * flag.
135
+ */
129
136
  export declare function inDevilsCrownTreasureRoom(): boolean;
130
137
  export declare function inDimension(dimension: Dimension): boolean;
131
138
  /** Helper function to determine if the current room shape is one of the four L room shapes. */
@@ -152,6 +159,11 @@ export declare function inStartingRoom(): boolean;
152
159
  * default.
153
160
  */
154
161
  export declare function isAllRoomsClear(onlyCheckRoomTypes?: RoomType[]): boolean;
162
+ /**
163
+ * Helper function to detect if the current room was created by the Red Key item. Under the hood,
164
+ * this checks for the `RoomDescriptorFlag.FLAG_RED_ROOM` flag.
165
+ */
166
+ export declare function isRedKeyRoom(): boolean;
155
167
  /**
156
168
  * Helper function to determine whether or not the current room is part of the floor layout. For
157
169
  * example, Devil Rooms and the Mega Satan room are not considered to be inside the map.
@@ -17,6 +17,11 @@ local setEntityPositions = ____entity.setEntityPositions
17
17
  local setEntityVelocities = ____entity.setEntityVelocities
18
18
  local ____flag = require("functions.flag")
19
19
  local hasFlag = ____flag.hasFlag
20
+ function ____exports.getCurrentRoomDescReadOnly(self)
21
+ local game = Game()
22
+ local level = game:GetLevel()
23
+ return level:GetCurrentRoomDesc()
24
+ end
20
25
  function ____exports.getRoomData(self)
21
26
  local game = Game()
22
27
  local level = game:GetLevel()
@@ -25,9 +30,7 @@ function ____exports.getRoomData(self)
25
30
  return roomDesc.Data
26
31
  end
27
32
  function ____exports.getRoomSafeGridIndex(self)
28
- local game = Game()
29
- local level = game:GetLevel()
30
- local roomDesc = level:GetCurrentRoomDesc()
33
+ local roomDesc = ____exports.getCurrentRoomDescReadOnly(nil)
31
34
  return roomDesc.SafeGridIndex
32
35
  end
33
36
  function ____exports.getRoomStageID(self)
@@ -130,9 +133,7 @@ function ____exports.getRoomDataType(self)
130
133
  return roomData.Type
131
134
  end
132
135
  function ____exports.getRoomListIndex(self)
133
- local game = Game()
134
- local level = game:GetLevel()
135
- local roomDesc = level:GetCurrentRoomDesc()
136
+ local roomDesc = ____exports.getCurrentRoomDescReadOnly(nil)
136
137
  return roomDesc.ListIndex
137
138
  end
138
139
  function ____exports.getRoomGridIndexesForType(self, roomType)
@@ -169,9 +170,7 @@ function ____exports.getRoomVariant(self)
169
170
  return roomData.Variant
170
171
  end
171
172
  function ____exports.getRoomVisitedCount(self)
172
- local game = Game()
173
- local level = game:GetLevel()
174
- local roomDesc = level:GetCurrentRoomDesc()
173
+ local roomDesc = ____exports.getCurrentRoomDescReadOnly(nil)
175
174
  return roomDesc.VisitedCount
176
175
  end
177
176
  function ____exports.gridToPos(self, x, y)
@@ -214,9 +213,7 @@ function ____exports.inCrawlspace(self)
214
213
  return (roomSafeGridIndex == GridRooms.ROOM_DUNGEON_IDX) and (roomSubType ~= 4)
215
214
  end
216
215
  function ____exports.inDevilsCrownTreasureRoom(self)
217
- local game = Game()
218
- local level = game:GetLevel()
219
- local roomDesc = level:GetCurrentRoomDesc()
216
+ local roomDesc = ____exports.getCurrentRoomDescReadOnly(nil)
220
217
  return hasFlag(nil, roomDesc.Flags, 2048)
221
218
  end
222
219
  function ____exports.inDimension(self, dimension)
@@ -259,20 +256,24 @@ function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes)
259
256
  do
260
257
  local roomData = roomDesc.Data
261
258
  if roomData == nil then
262
- goto __continue48
259
+ goto __continue49
263
260
  end
264
261
  local roomType = roomData.Type
265
262
  if (roomTypeWhitelist ~= nil) and (not roomTypeWhitelist:has(roomType)) then
266
- goto __continue48
263
+ goto __continue49
267
264
  end
268
265
  if not roomDesc.Clear then
269
266
  return false
270
267
  end
271
268
  end
272
- ::__continue48::
269
+ ::__continue49::
273
270
  end
274
271
  return true
275
272
  end
273
+ function ____exports.isRedKeyRoom(self)
274
+ local roomDesc = ____exports.getCurrentRoomDescReadOnly(nil)
275
+ return hasFlag(nil, roomDesc.Flags, 1024)
276
+ end
276
277
  function ____exports.isRoomInsideMap(self)
277
278
  local roomSafeGridIndex = ____exports.getRoomSafeGridIndex(nil)
278
279
  return roomSafeGridIndex >= 0
@@ -301,14 +302,14 @@ function ____exports.setRoomCleared(self)
301
302
  ) do
302
303
  do
303
304
  if isHiddenSecretRoomDoor(nil, door) then
304
- goto __continue56
305
+ goto __continue58
305
306
  end
306
307
  door.State = DoorState.STATE_OPEN
307
308
  local sprite = door:GetSprite()
308
309
  sprite:Play("Opened", true)
309
310
  door.ExtraVisible = false
310
311
  end
311
- ::__continue56::
312
+ ::__continue58::
312
313
  end
313
314
  sfx:Stop(SoundEffect.SOUND_DOOR_HEAVY_OPEN)
314
315
  game:ShakeScreen(0)
@@ -1,2 +1,2 @@
1
- /** Helper function to get the seed of the current run. */
1
+ /** Alias for the `Seeds.GetStartSeedString` method. */
2
2
  export declare function getStartSeedString(): string;
@@ -1,7 +1,7 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /**
3
3
  * Helper function to clear a specific layer from a sprite. This function is variadic, so pass as
4
- * many layer IDs as you want to clear.
4
+ * many layer IDs as you want to clear. If no specific layers are passed, it will clear every layer.
5
5
  *
6
6
  * Since there is no official API method to "clear" a sprite, we can work around it by setting the
7
7
  * spritesheet to a non-existent or completely transparent file. If the path to the spritesheet does
@@ -1,9 +1,21 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ require("lualib_bundle");
2
3
  local ____exports = {}
3
4
  local ____constants = require("constants")
4
5
  local EMPTY_PNG_PATH = ____constants.EMPTY_PNG_PATH
5
6
  function ____exports.clearSprite(self, sprite, ...)
6
7
  local layerIDs = {...}
8
+ local numLayers = sprite:GetLayerCount()
9
+ if #layerIDs == 0 then
10
+ layerIDs = {}
11
+ do
12
+ local i = 0
13
+ while i < numLayers do
14
+ __TS__ArrayPush(layerIDs, i)
15
+ i = i + 1
16
+ end
17
+ end
18
+ end
7
19
  for ____, layerID in ipairs(layerIDs) do
8
20
  sprite:ReplaceSpritesheet(layerID, EMPTY_PNG_PATH)
9
21
  end
@@ -5,9 +5,9 @@
5
5
  * consider Downpour 2 to have a stage of 3.
6
6
  */
7
7
  export declare function getEffectiveStage(): int;
8
- /** Helper function to get the current stage. */
8
+ /** Alias for the `Level.GetStage` method. */
9
9
  export declare function getStage(): LevelStage;
10
- /** Helper function to get the current stage type. */
10
+ /** Alias for the `Level.GetStageType` method. */
11
11
  export declare function getStageType(): StageType;
12
12
  /** Helper function to directly warp to a specific stage using the "stage" console command. */
13
13
  export declare function goToStage(stage: LevelStage, stageType: StageType): void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.0.545",
3
+ "version": "1.0.549",
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.306",
28
+ "isaac-typescript-definitions": "^1.0.307",
29
29
  "isaacscript-lint": "^1.0.73",
30
30
  "typedoc": "^0.22.10",
31
31
  "typescript": "4.4.4",