isaacscript-common 33.12.0 → 33.13.0

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.
@@ -3558,12 +3558,29 @@ export declare function deserializeVector(vector: SerializedVector): Vector;
3558
3558
  /** For `EntityType.EFFECT` (1000), `EffectVariant.DICE_FLOOR` (76). */
3559
3559
  export declare const DICE_FLOOR_TRIGGER_SQUARE_SIZE = 75;
3560
3560
 
3561
+ /**
3562
+ * Helper function to convert a direction to degrees. For example, `Direction.LEFT` (0) would return
3563
+ * 180 and `Direction.RIGHT` (2) would return 0. (This corresponds to how the
3564
+ * `Vector.GetAngleDegrees` method works.)
3565
+ */
3561
3566
  export declare function directionToDegrees(direction: Direction): int;
3562
3567
 
3568
+ /**
3569
+ * Helper function to convert a direction to a shoot `ButtonAction`. For example, `Direction.LEFT`
3570
+ * (0) would return `ButtonAction.LEFT` (0).
3571
+ */
3563
3572
  export declare function directionToMoveAction(direction: Direction): ButtonAction | undefined;
3564
3573
 
3574
+ /**
3575
+ * Helper function to convert a direction to a shoot `ButtonAction`. For example, `Direction.LEFT`
3576
+ * (0) would return `ButtonAction.SHOOT_LEFT` (4).
3577
+ */
3565
3578
  export declare function directionToShootAction(direction: Direction): ButtonAction | undefined;
3566
3579
 
3580
+ /**
3581
+ * Helper function to convert a direction to a `Vector`. For example, `Direction.LEFT` (0) would
3582
+ * convert to `Vector(-1, 0).
3583
+ */
3567
3584
  export declare function directionToVector(direction: Direction): Readonly<Vector>;
3568
3585
 
3569
3586
  declare class DisableAllSound extends Feature {
@@ -4275,7 +4292,7 @@ declare abstract class Feature {
4275
4292
  constructor();
4276
4293
  }
4277
4294
 
4278
- /** Helper function to fill every possible square with a red room. */
4295
+ /** Helper function to fill every possible level grid square with a red room. */
4279
4296
  export declare function fillLevelWithRedRooms(): void;
4280
4297
 
4281
4298
  /**
@@ -5105,6 +5122,10 @@ export declare function getDevilRoomOrAngelRoomDoor(): GridEntityDoor | undefine
5105
5122
  */
5106
5123
  export declare function getDimension(): Dimension;
5107
5124
 
5125
+ /**
5126
+ * Helper function to get the lowercase name of a direction. For example, `Direction.LEFT` (0) would
5127
+ * return "left".
5128
+ */
5108
5129
  export declare function getDirectionName(direction: Direction): string | undefined;
5109
5130
 
5110
5131
  /**
@@ -5703,6 +5724,15 @@ export declare function getLastElement<T>(array: T[]): T | undefined;
5703
5724
  */
5704
5725
  export declare function getLastFrameOfAnimation(sprite: Sprite, animation?: string): int;
5705
5726
 
5727
+ /**
5728
+ * Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
5729
+ * to the sub-type of the room data.)
5730
+ *
5731
+ * Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
5732
+ * rooms will not count.
5733
+ */
5734
+ export declare function getLevelBossIDs(): BossID[];
5735
+
5706
5736
  /**
5707
5737
  * Helper function to get the lowest value in an array. Returns undefined if there were no elements
5708
5738
  * in the array.
@@ -6651,7 +6681,7 @@ export declare function getRoomDescriptorReadOnly(): Readonly<RoomDescriptor>;
6651
6681
  * Helper function to get an array of all of the room descriptors for rooms that match the specified
6652
6682
  * room type.
6653
6683
  *
6654
- * This function only searches through rooms in the current dimension.
6684
+ * This function only searches through rooms in the current dimension and rooms inside the grid.
6655
6685
  *
6656
6686
  * This function is variadic, meaning that you can specify N arguments to get the combined room
6657
6687
  * descriptors for N room types.
@@ -9477,6 +9507,14 @@ export declare const LEVEL_GRID_COLUMN_HEIGHT = 13;
9477
9507
  */
9478
9508
  export declare const LEVEL_GRID_ROW_WIDTH = 13;
9479
9509
 
9510
+ /**
9511
+ * Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
9512
+ *
9513
+ * This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
9514
+ * It will return true if one or more of the boss IDs are matched.
9515
+ */
9516
+ export declare function levelHasBossID(...bossIDs: BossID[]): boolean;
9517
+
9480
9518
  /**
9481
9519
  * Helper function to check to see if the current floor has one or more of a specific room type in
9482
9520
  * it.
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 33.12.0
3
+ isaacscript-common 33.13.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -27737,8 +27737,8 @@ function ____exports.changeRoom(self, roomGridIndex)
27737
27737
  game:ChangeRoom(roomGridIndex)
27738
27738
  end
27739
27739
  function ____exports.getNumRooms(self)
27740
- local rooms = ____exports.getRoomsInsideGrid(nil)
27741
- return #rooms
27740
+ local roomsInsideGrid = ____exports.getRoomsInsideGrid(nil)
27741
+ return #roomsInsideGrid
27742
27742
  end
27743
27743
  function ____exports.getRoomDataForTypeVariant(self, roomType, roomVariant, cancelRoomTransition, useSpecialRoomsForRoomTypeDefault)
27744
27744
  if cancelRoomTransition == nil then
@@ -27879,14 +27879,14 @@ function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes, includeSecretAndS
27879
27879
  if includeUltraSecretRoom == nil then
27880
27880
  includeUltraSecretRoom = false
27881
27881
  end
27882
- local rooms = ____exports.getRoomsInsideGrid(nil)
27882
+ local roomsInsideGrid = ____exports.getRoomsInsideGrid(nil)
27883
27883
  local matchingRooms
27884
27884
  if onlyCheckRoomTypes == nil then
27885
- matchingRooms = rooms
27885
+ matchingRooms = roomsInsideGrid
27886
27886
  else
27887
27887
  local roomTypeWhitelist = __TS__New(ReadonlySet, onlyCheckRoomTypes)
27888
27888
  matchingRooms = __TS__ArrayFilter(
27889
- rooms,
27889
+ roomsInsideGrid,
27890
27890
  function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypeWhitelist:has(roomDescriptor.Data.Type) end
27891
27891
  )
27892
27892
  end
@@ -37332,7 +37332,7 @@ function ____exports.loadFromDisk(self, mod, oldSaveData, classConstructors)
37332
37332
  end,
37333
37333
  SAVE_DATA_MANAGER_DEBUG
37334
37334
  )
37335
- log("The save data manager loaded data from the \"save#.dat\" file.")
37335
+ log("The save data manager loaded data from the \"save#.dat\" file for mod: " .. mod.Name)
37336
37336
  end
37337
37337
  return ____exports
37338
37338
  end,
@@ -37452,7 +37452,7 @@ function ____exports.saveToDisk(self, mod, saveDataMap, saveDataConditionalFuncM
37452
37452
  local allSaveData = getAllSaveDataToWriteToDisk(nil, saveDataMap, saveDataConditionalFuncMap)
37453
37453
  local jsonString = jsonEncode(nil, allSaveData)
37454
37454
  mod:SaveData(jsonString)
37455
- log("The save data manager wrote data to the \"save#.dat\" file.")
37455
+ log("The save data manager wrote data to the \"save#.dat\" file for mod: " .. mod.Name)
37456
37456
  end
37457
37457
  return ____exports
37458
37458
  end,
@@ -48156,12 +48156,12 @@ function ____exports.getNewRoomCandidatesForLevel(self, ensureDeadEnd)
48156
48156
  if ensureDeadEnd == nil then
48157
48157
  ensureDeadEnd = true
48158
48158
  end
48159
- local rooms = getRoomsInsideGrid(nil)
48159
+ local roomsInsideGrid = getRoomsInsideGrid(nil)
48160
48160
  local normalRooms = __TS__ArrayFilter(
48161
- rooms,
48161
+ roomsInsideGrid,
48162
48162
  function(____, room) return room.Data ~= nil and room.Data.Type == RoomType.DEFAULT and not isMirrorRoom(nil, room.Data) and not isMineShaft(nil, room.Data) end
48163
48163
  )
48164
- local roomsToLookThrough = ensureDeadEnd and normalRooms or rooms
48164
+ local roomsToLookThrough = ensureDeadEnd and normalRooms or roomsInsideGrid
48165
48165
  local newRoomCandidates = {}
48166
48166
  for ____, room in ipairs(roomsToLookThrough) do
48167
48167
  local newRoomCandidatesBesideRoom = ____exports.getNewRoomCandidatesBesideRoom(nil, room.SafeGridIndex, ensureDeadEnd)
@@ -48279,9 +48279,9 @@ end
48279
48279
  function ____exports.getRoomDescriptorsForType(self, ...)
48280
48280
  local roomTypes = {...}
48281
48281
  local roomTypesSet = __TS__New(Set, roomTypes)
48282
- local rooms = getRoomsInsideGrid(nil)
48282
+ local roomsInsideGrid = getRoomsInsideGrid(nil)
48283
48283
  return __TS__ArrayFilter(
48284
- rooms,
48284
+ roomsInsideGrid,
48285
48285
  function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypesSet:has(roomDescriptor.Data.Type) end
48286
48286
  )
48287
48287
  end
@@ -53740,11 +53740,20 @@ end
53740
53740
  return ____exports
53741
53741
  end,
53742
53742
  ["src.functions.level"] = function(...)
53743
+ local ____lualib = require("lualib_bundle")
53744
+ local Set = ____lualib.Set
53745
+ local __TS__New = ____lualib.__TS__New
53746
+ local __TS__ArraySome = ____lualib.__TS__ArraySome
53743
53747
  local ____exports = {}
53748
+ local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
53749
+ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
53750
+ local StageID = ____isaac_2Dtypescript_2Ddefinitions.StageID
53744
53751
  local ____cachedEnumValues = require("src.arrays.cachedEnumValues")
53745
53752
  local DOOR_SLOT_VALUES = ____cachedEnumValues.DOOR_SLOT_VALUES
53746
53753
  local ____cachedClasses = require("src.core.cachedClasses")
53747
53754
  local game = ____cachedClasses.game
53755
+ local ____array = require("src.functions.array")
53756
+ local filterMap = ____array.filterMap
53748
53757
  local ____levelGrid = require("src.functions.levelGrid")
53749
53758
  local getRoomDescriptorsForType = ____levelGrid.getRoomDescriptorsForType
53750
53759
  local isDoorSlotValidAtGridIndexForRedRoom = ____levelGrid.isDoorSlotValidAtGridIndexForRedRoom
@@ -53768,6 +53777,23 @@ function ____exports.fillLevelWithRedRooms(self)
53768
53777
  end
53769
53778
  until not (numRoomsInGrid ~= getNumRooms(nil))
53770
53779
  end
53780
+ function ____exports.getLevelBossIDs(self)
53781
+ local roomsInsideGrid = getRoomsInsideGrid(nil)
53782
+ return filterMap(
53783
+ nil,
53784
+ roomsInsideGrid,
53785
+ function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomDescriptor.Data.Type == RoomType.BOSS and roomDescriptor.Data.StageID == StageID.SPECIAL_ROOMS and roomDescriptor.Data.Subtype or nil end
53786
+ )
53787
+ end
53788
+ function ____exports.levelHasBossID(self, ...)
53789
+ local bossIDs = {...}
53790
+ local levelBossIDs = ____exports.getLevelBossIDs(nil)
53791
+ local levelBossIDsSet = __TS__New(Set, levelBossIDs)
53792
+ return __TS__ArraySome(
53793
+ bossIDs,
53794
+ function(____, bossID) return levelBossIDsSet:has(bossID) end
53795
+ )
53796
+ end
53771
53797
  function ____exports.levelHasRoomType(self, ...)
53772
53798
  local roomDescriptors = getRoomDescriptorsForType(nil, ...)
53773
53799
  return #roomDescriptors > 0
@@ -1 +1 @@
1
- {"version":3,"file":"loadFromDisk.d.ts","sourceRoot":"","sources":["../../../../../../src/classes/features/other/saveDataManager/loadFromDisk.ts"],"names":[],"mappings":";;AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAK3D,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EACrC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAC1C,IAAI,CAsDN"}
1
+ {"version":3,"file":"loadFromDisk.d.ts","sourceRoot":"","sources":["../../../../../../src/classes/features/other/saveDataManager/loadFromDisk.ts"],"names":[],"mappings":";;AAMA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAK3D,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EACrC,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GAC1C,IAAI,CAwDN"}
@@ -73,6 +73,6 @@ function ____exports.loadFromDisk(self, mod, oldSaveData, classConstructors)
73
73
  end,
74
74
  SAVE_DATA_MANAGER_DEBUG
75
75
  )
76
- log("The save data manager loaded data from the \"save#.dat\" file.")
76
+ log("The save data manager loaded data from the \"save#.dat\" file for mod: " .. mod.Name)
77
77
  end
78
78
  return ____exports
@@ -1 +1 @@
1
- {"version":3,"file":"saveToDisk.d.ts","sourceRoot":"","sources":["../../../../../../src/classes/features/other/saveDataManager/saveToDisk.ts"],"names":[],"mappings":";;AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAGhE,wBAAgB,UAAU,CACxB,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EACrC,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,GACxD,IAAI,CAQN"}
1
+ {"version":3,"file":"saveToDisk.d.ts","sourceRoot":"","sources":["../../../../../../src/classes/features/other/saveDataManager/saveToDisk.ts"],"names":[],"mappings":";;AAKA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iCAAiC,CAAC;AAGhE,wBAAgB,UAAU,CACxB,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,EACrC,0BAA0B,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,OAAO,CAAC,GACxD,IAAI,CAUN"}
@@ -41,6 +41,6 @@ function ____exports.saveToDisk(self, mod, saveDataMap, saveDataConditionalFuncM
41
41
  local allSaveData = getAllSaveDataToWriteToDisk(nil, saveDataMap, saveDataConditionalFuncMap)
42
42
  local jsonString = jsonEncode(nil, allSaveData)
43
43
  mod:SaveData(jsonString)
44
- log("The save data manager wrote data to the \"save#.dat\" file.")
44
+ log("The save data manager wrote data to the \"save#.dat\" file for mod: " .. mod.Name)
45
45
  end
46
46
  return ____exports
@@ -8,9 +8,30 @@ import { Direction } from "isaac-typescript-definitions";
8
8
  * works.)
9
9
  */
10
10
  export declare function angleToDirection(angleDegrees: int): Direction;
11
+ /**
12
+ * Helper function to convert a direction to degrees. For example, `Direction.LEFT` (0) would return
13
+ * 180 and `Direction.RIGHT` (2) would return 0. (This corresponds to how the
14
+ * `Vector.GetAngleDegrees` method works.)
15
+ */
11
16
  export declare function directionToDegrees(direction: Direction): int;
17
+ /**
18
+ * Helper function to convert a direction to a shoot `ButtonAction`. For example, `Direction.LEFT`
19
+ * (0) would return `ButtonAction.LEFT` (0).
20
+ */
12
21
  export declare function directionToMoveAction(direction: Direction): ButtonAction | undefined;
22
+ /**
23
+ * Helper function to convert a direction to a shoot `ButtonAction`. For example, `Direction.LEFT`
24
+ * (0) would return `ButtonAction.SHOOT_LEFT` (4).
25
+ */
13
26
  export declare function directionToShootAction(direction: Direction): ButtonAction | undefined;
27
+ /**
28
+ * Helper function to convert a direction to a `Vector`. For example, `Direction.LEFT` (0) would
29
+ * convert to `Vector(-1, 0).
30
+ */
14
31
  export declare function directionToVector(direction: Direction): Readonly<Vector>;
32
+ /**
33
+ * Helper function to get the lowercase name of a direction. For example, `Direction.LEFT` (0) would
34
+ * return "left".
35
+ */
15
36
  export declare function getDirectionName(direction: Direction): string | undefined;
16
37
  //# sourceMappingURL=direction.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"direction.d.ts","sourceRoot":"","sources":["../../../src/functions/direction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAOzD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,GAAG,GAAG,SAAS,CAwB7D;AAED,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,GAAG,CAE5D;AAED,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,SAAS,GACnB,YAAY,GAAG,SAAS,CAE1B;AAED,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,SAAS,GACnB,YAAY,GAAG,SAAS,CAE1B;AAED,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,CAExE;AAED,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAEzE"}
1
+ {"version":3,"file":"direction.d.ts","sourceRoot":"","sources":["../../../src/functions/direction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAOzD;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,YAAY,EAAE,GAAG,GAAG,SAAS,CAwB7D;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,SAAS,GAAG,GAAG,CAE5D;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,SAAS,EAAE,SAAS,GACnB,YAAY,GAAG,SAAS,CAE1B;AAED;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,SAAS,EAAE,SAAS,GACnB,YAAY,GAAG,SAAS,CAE1B;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,SAAS,GAAG,QAAQ,CAAC,MAAM,CAAC,CAExE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,SAAS,EAAE,SAAS,GAAG,MAAM,GAAG,SAAS,CAEzE"}
@@ -36,18 +36,29 @@ function ____exports.angleToDirection(self, angleDegrees)
36
36
  end
37
37
  return Direction.RIGHT
38
38
  end
39
+ --- Helper function to convert a direction to degrees. For example, `Direction.LEFT` (0) would return
40
+ -- 180 and `Direction.RIGHT` (2) would return 0. (This corresponds to how the
41
+ -- `Vector.GetAngleDegrees` method works.)
39
42
  function ____exports.directionToDegrees(self, direction)
40
43
  return DIRECTION_TO_DEGREES[direction]
41
44
  end
45
+ --- Helper function to convert a direction to a shoot `ButtonAction`. For example, `Direction.LEFT`
46
+ -- (0) would return `ButtonAction.LEFT` (0).
42
47
  function ____exports.directionToMoveAction(self, direction)
43
48
  return DIRECTION_TO_MOVE_ACTION[direction]
44
49
  end
50
+ --- Helper function to convert a direction to a shoot `ButtonAction`. For example, `Direction.LEFT`
51
+ -- (0) would return `ButtonAction.SHOOT_LEFT` (4).
45
52
  function ____exports.directionToShootAction(self, direction)
46
53
  return DIRECTION_TO_SHOOT_ACTION[direction]
47
54
  end
55
+ --- Helper function to convert a direction to a `Vector`. For example, `Direction.LEFT` (0) would
56
+ -- convert to `Vector(-1, 0).
48
57
  function ____exports.directionToVector(self, direction)
49
58
  return DIRECTION_TO_VECTOR[direction]
50
59
  end
60
+ --- Helper function to get the lowercase name of a direction. For example, `Direction.LEFT` (0) would
61
+ -- return "left".
51
62
  function ____exports.getDirectionName(self, direction)
52
63
  return DIRECTION_NAMES[direction]
53
64
  end
@@ -1,6 +1,22 @@
1
- import type { RoomType } from "isaac-typescript-definitions";
2
- /** Helper function to fill every possible square with a red room. */
1
+ import type { BossID } from "isaac-typescript-definitions";
2
+ import { RoomType } from "isaac-typescript-definitions";
3
+ /** Helper function to fill every possible level grid square with a red room. */
3
4
  export declare function fillLevelWithRedRooms(): void;
5
+ /**
6
+ * Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
7
+ * to the sub-type of the room data.)
8
+ *
9
+ * Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
10
+ * rooms will not count.
11
+ */
12
+ export declare function getLevelBossIDs(): BossID[];
13
+ /**
14
+ * Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
15
+ *
16
+ * This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
17
+ * It will return true if one or more of the boss IDs are matched.
18
+ */
19
+ export declare function levelHasBossID(...bossIDs: BossID[]): boolean;
4
20
  /**
5
21
  * Helper function to check to see if the current floor has one or more of a specific room type in
6
22
  * it.
@@ -1 +1 @@
1
- {"version":3,"file":"level.d.ts","sourceRoot":"","sources":["../../../src/functions/level.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAS7D,qEAAqE;AACrE,wBAAgB,qBAAqB,IAAI,IAAI,CAqB5C;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAGlE"}
1
+ {"version":3,"file":"level.d.ts","sourceRoot":"","sources":["../../../src/functions/level.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,8BAA8B,CAAC;AAC3D,OAAO,EAAE,QAAQ,EAAW,MAAM,8BAA8B,CAAC;AAUjE,gFAAgF;AAChF,wBAAgB,qBAAqB,IAAI,IAAI,CAqB5C;AAED;;;;;;GAMG;AACH,wBAAgB,eAAe,IAAI,MAAM,EAAE,CAU1C;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,OAAO,CAK5D;AAED;;;;;;GAMG;AACH,wBAAgB,gBAAgB,CAAC,GAAG,SAAS,EAAE,QAAQ,EAAE,GAAG,OAAO,CAGlE"}
@@ -1,15 +1,24 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
4
+ local __TS__ArraySome = ____lualib.__TS__ArraySome
1
5
  local ____exports = {}
6
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
+ local RoomType = ____isaac_2Dtypescript_2Ddefinitions.RoomType
8
+ local StageID = ____isaac_2Dtypescript_2Ddefinitions.StageID
2
9
  local ____cachedEnumValues = require("src.arrays.cachedEnumValues")
3
10
  local DOOR_SLOT_VALUES = ____cachedEnumValues.DOOR_SLOT_VALUES
4
11
  local ____cachedClasses = require("src.core.cachedClasses")
5
12
  local game = ____cachedClasses.game
13
+ local ____array = require("src.functions.array")
14
+ local filterMap = ____array.filterMap
6
15
  local ____levelGrid = require("src.functions.levelGrid")
7
16
  local getRoomDescriptorsForType = ____levelGrid.getRoomDescriptorsForType
8
17
  local isDoorSlotValidAtGridIndexForRedRoom = ____levelGrid.isDoorSlotValidAtGridIndexForRedRoom
9
18
  local ____rooms = require("src.functions.rooms")
10
19
  local getNumRooms = ____rooms.getNumRooms
11
20
  local getRoomsInsideGrid = ____rooms.getRoomsInsideGrid
12
- --- Helper function to fill every possible square with a red room.
21
+ --- Helper function to fill every possible level grid square with a red room.
13
22
  function ____exports.fillLevelWithRedRooms(self)
14
23
  local level = game:GetLevel()
15
24
  local numRoomsInGrid
@@ -27,6 +36,32 @@ function ____exports.fillLevelWithRedRooms(self)
27
36
  end
28
37
  until not (numRoomsInGrid ~= getNumRooms(nil))
29
38
  end
39
+ --- Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
40
+ -- to the sub-type of the room data.)
41
+ --
42
+ -- Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
43
+ -- rooms will not count.
44
+ function ____exports.getLevelBossIDs(self)
45
+ local roomsInsideGrid = getRoomsInsideGrid(nil)
46
+ return filterMap(
47
+ nil,
48
+ roomsInsideGrid,
49
+ function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomDescriptor.Data.Type == RoomType.BOSS and roomDescriptor.Data.StageID == StageID.SPECIAL_ROOMS and roomDescriptor.Data.Subtype or nil end
50
+ )
51
+ end
52
+ --- Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
53
+ --
54
+ -- This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
55
+ -- It will return true if one or more of the boss IDs are matched.
56
+ function ____exports.levelHasBossID(self, ...)
57
+ local bossIDs = {...}
58
+ local levelBossIDs = ____exports.getLevelBossIDs(nil)
59
+ local levelBossIDsSet = __TS__New(Set, levelBossIDs)
60
+ return __TS__ArraySome(
61
+ bossIDs,
62
+ function(____, bossID) return levelBossIDsSet:has(bossID) end
63
+ )
64
+ end
30
65
  --- Helper function to check to see if the current floor has one or more of a specific room type in
31
66
  -- it.
32
67
  --
@@ -102,7 +102,7 @@ export declare function getRoomAdjacentGridIndexes(roomGridIndex?: int): Readonl
102
102
  * Helper function to get an array of all of the room descriptors for rooms that match the specified
103
103
  * room type.
104
104
  *
105
- * This function only searches through rooms in the current dimension.
105
+ * This function only searches through rooms in the current dimension and rooms inside the grid.
106
106
  *
107
107
  * This function is variadic, meaning that you can specify N arguments to get the combined room
108
108
  * descriptors for N room types.
@@ -136,12 +136,12 @@ function ____exports.getNewRoomCandidatesForLevel(self, ensureDeadEnd)
136
136
  if ensureDeadEnd == nil then
137
137
  ensureDeadEnd = true
138
138
  end
139
- local rooms = getRoomsInsideGrid(nil)
139
+ local roomsInsideGrid = getRoomsInsideGrid(nil)
140
140
  local normalRooms = __TS__ArrayFilter(
141
- rooms,
141
+ roomsInsideGrid,
142
142
  function(____, room) return room.Data ~= nil and room.Data.Type == RoomType.DEFAULT and not isMirrorRoom(nil, room.Data) and not isMineShaft(nil, room.Data) end
143
143
  )
144
- local roomsToLookThrough = ensureDeadEnd and normalRooms or rooms
144
+ local roomsToLookThrough = ensureDeadEnd and normalRooms or roomsInsideGrid
145
145
  local newRoomCandidates = {}
146
146
  for ____, room in ipairs(roomsToLookThrough) do
147
147
  local newRoomCandidatesBesideRoom = ____exports.getNewRoomCandidatesBesideRoom(nil, room.SafeGridIndex, ensureDeadEnd)
@@ -324,16 +324,16 @@ end
324
324
  --- Helper function to get an array of all of the room descriptors for rooms that match the specified
325
325
  -- room type.
326
326
  --
327
- -- This function only searches through rooms in the current dimension.
327
+ -- This function only searches through rooms in the current dimension and rooms inside the grid.
328
328
  --
329
329
  -- This function is variadic, meaning that you can specify N arguments to get the combined room
330
330
  -- descriptors for N room types.
331
331
  function ____exports.getRoomDescriptorsForType(self, ...)
332
332
  local roomTypes = {...}
333
333
  local roomTypesSet = __TS__New(Set, roomTypes)
334
- local rooms = getRoomsInsideGrid(nil)
334
+ local roomsInsideGrid = getRoomsInsideGrid(nil)
335
335
  return __TS__ArrayFilter(
336
- rooms,
336
+ roomsInsideGrid,
337
337
  function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypesSet:has(roomDescriptor.Data.Type) end
338
338
  )
339
339
  end
@@ -259,8 +259,8 @@ end
259
259
  --- Helper function to get the number of rooms that are currently on the floor layout. This does not
260
260
  -- include off-grid rooms, like the Devil Room.
261
261
  function ____exports.getNumRooms(self)
262
- local rooms = ____exports.getRoomsInsideGrid(nil)
263
- return #rooms
262
+ local roomsInsideGrid = ____exports.getRoomsInsideGrid(nil)
263
+ return #roomsInsideGrid
264
264
  end
265
265
  --- Helper function to get the room data for a specific room type and variant combination. This is
266
266
  -- accomplished by using the "goto" console command to load the specified room into the
@@ -507,14 +507,14 @@ function ____exports.isAllRoomsClear(self, onlyCheckRoomTypes, includeSecretAndS
507
507
  if includeUltraSecretRoom == nil then
508
508
  includeUltraSecretRoom = false
509
509
  end
510
- local rooms = ____exports.getRoomsInsideGrid(nil)
510
+ local roomsInsideGrid = ____exports.getRoomsInsideGrid(nil)
511
511
  local matchingRooms
512
512
  if onlyCheckRoomTypes == nil then
513
- matchingRooms = rooms
513
+ matchingRooms = roomsInsideGrid
514
514
  else
515
515
  local roomTypeWhitelist = __TS__New(ReadonlySet, onlyCheckRoomTypes)
516
516
  matchingRooms = __TS__ArrayFilter(
517
- rooms,
517
+ roomsInsideGrid,
518
518
  function(____, roomDescriptor) return roomDescriptor.Data ~= nil and roomTypeWhitelist:has(roomDescriptor.Data.Type) end
519
519
  )
520
520
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "33.12.0",
3
+ "version": "33.13.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -463,7 +463,7 @@ export class SaveDataManager extends Feature {
463
463
  for (const tstlClass of tstlClasses) {
464
464
  const { name } = tstlClass;
465
465
  assertDefined(
466
- // Since we are accepting untrusted user input, this might nto be a real TSTL class.
466
+ // Since we are accepting untrusted user input, this might not be a real TSTL class.
467
467
  name as string | undefined,
468
468
  "Failed to register a class with the save data manager due to not being able to derive the name of the class.",
469
469
  );
@@ -67,7 +67,9 @@ export function loadFromDisk(
67
67
  SAVE_DATA_MANAGER_DEBUG,
68
68
  );
69
69
 
70
- log('The save data manager loaded data from the "save#.dat" file.');
70
+ log(
71
+ `The save data manager loaded data from the "save#.dat" file for mod: ${mod.Name}`,
72
+ );
71
73
  }
72
74
 
73
75
  function readSaveDatFile(mod: Mod) {
@@ -17,7 +17,9 @@ export function saveToDisk(
17
17
  );
18
18
  const jsonString = jsonEncode(allSaveData);
19
19
  mod.SaveData(jsonString);
20
- log('The save data manager wrote data to the "save#.dat" file.');
20
+ log(
21
+ `The save data manager wrote data to the "save#.dat" file for mod: ${mod.Name}`,
22
+ );
21
23
  }
22
24
 
23
25
  function getAllSaveDataToWriteToDisk(
@@ -39,26 +39,47 @@ export function angleToDirection(angleDegrees: int): Direction {
39
39
  return Direction.RIGHT;
40
40
  }
41
41
 
42
+ /**
43
+ * Helper function to convert a direction to degrees. For example, `Direction.LEFT` (0) would return
44
+ * 180 and `Direction.RIGHT` (2) would return 0. (This corresponds to how the
45
+ * `Vector.GetAngleDegrees` method works.)
46
+ */
42
47
  export function directionToDegrees(direction: Direction): int {
43
48
  return DIRECTION_TO_DEGREES[direction];
44
49
  }
45
50
 
51
+ /**
52
+ * Helper function to convert a direction to a shoot `ButtonAction`. For example, `Direction.LEFT`
53
+ * (0) would return `ButtonAction.LEFT` (0).
54
+ */
46
55
  export function directionToMoveAction(
47
56
  direction: Direction,
48
57
  ): ButtonAction | undefined {
49
58
  return DIRECTION_TO_MOVE_ACTION[direction];
50
59
  }
51
60
 
61
+ /**
62
+ * Helper function to convert a direction to a shoot `ButtonAction`. For example, `Direction.LEFT`
63
+ * (0) would return `ButtonAction.SHOOT_LEFT` (4).
64
+ */
52
65
  export function directionToShootAction(
53
66
  direction: Direction,
54
67
  ): ButtonAction | undefined {
55
68
  return DIRECTION_TO_SHOOT_ACTION[direction];
56
69
  }
57
70
 
71
+ /**
72
+ * Helper function to convert a direction to a `Vector`. For example, `Direction.LEFT` (0) would
73
+ * convert to `Vector(-1, 0).
74
+ */
58
75
  export function directionToVector(direction: Direction): Readonly<Vector> {
59
76
  return DIRECTION_TO_VECTOR[direction];
60
77
  }
61
78
 
79
+ /**
80
+ * Helper function to get the lowercase name of a direction. For example, `Direction.LEFT` (0) would
81
+ * return "left".
82
+ */
62
83
  export function getDirectionName(direction: Direction): string | undefined {
63
84
  return DIRECTION_NAMES[direction];
64
85
  }
@@ -1,13 +1,15 @@
1
- import type { RoomType } from "isaac-typescript-definitions";
1
+ import type { BossID } from "isaac-typescript-definitions";
2
+ import { RoomType, StageID } from "isaac-typescript-definitions";
2
3
  import { DOOR_SLOT_VALUES } from "../arrays/cachedEnumValues";
3
4
  import { game } from "../core/cachedClasses";
5
+ import { filterMap } from "./array";
4
6
  import {
5
7
  getRoomDescriptorsForType,
6
8
  isDoorSlotValidAtGridIndexForRedRoom,
7
9
  } from "./levelGrid";
8
10
  import { getNumRooms, getRoomsInsideGrid } from "./rooms";
9
11
 
10
- /** Helper function to fill every possible square with a red room. */
12
+ /** Helper function to fill every possible level grid square with a red room. */
11
13
  export function fillLevelWithRedRooms(): void {
12
14
  const level = game.GetLevel();
13
15
 
@@ -31,6 +33,38 @@ export function fillLevelWithRedRooms(): void {
31
33
  } while (numRoomsInGrid !== getNumRooms());
32
34
  }
33
35
 
36
+ /**
37
+ * Helper function to get the boss IDs of all of the Boss Rooms on this floor. (This is equivalent
38
+ * to the sub-type of the room data.)
39
+ *
40
+ * Note that this will only look at Boss Rooms inside of the grid, so e.g. Reverse Emperor card
41
+ * rooms will not count.
42
+ */
43
+ export function getLevelBossIDs(): BossID[] {
44
+ const roomsInsideGrid = getRoomsInsideGrid();
45
+
46
+ return filterMap(roomsInsideGrid, (roomDescriptor) =>
47
+ roomDescriptor.Data !== undefined &&
48
+ roomDescriptor.Data.Type === RoomType.BOSS &&
49
+ roomDescriptor.Data.StageID === StageID.SPECIAL_ROOMS
50
+ ? roomDescriptor.Data.Subtype
51
+ : undefined,
52
+ );
53
+ }
54
+
55
+ /**
56
+ * Helper function to check if the current floor has a Boss Room that matches the boss ID provided.
57
+ *
58
+ * This function is variadic, meaning that you can pass as many boss IDs as you want to check for.
59
+ * It will return true if one or more of the boss IDs are matched.
60
+ */
61
+ export function levelHasBossID(...bossIDs: BossID[]): boolean {
62
+ const levelBossIDs = getLevelBossIDs();
63
+ const levelBossIDsSet = new Set(levelBossIDs);
64
+
65
+ return bossIDs.some((bossID) => levelBossIDsSet.has(bossID));
66
+ }
67
+
34
68
  /**
35
69
  * Helper function to check to see if the current floor has one or more of a specific room type in
36
70
  * it.
@@ -231,10 +231,10 @@ export function getNewRoomCandidatesForLevel(
231
231
  readonly newRoomGridIndex: int;
232
232
  }> {
233
233
  // We want to iterate over every room on the floor and search for potential new room spots.
234
- const rooms = getRoomsInsideGrid();
234
+ const roomsInsideGrid = getRoomsInsideGrid();
235
235
 
236
236
  // However, we want to filter out special rooms because they are supposed to be dead ends.
237
- const normalRooms = rooms.filter(
237
+ const normalRooms = roomsInsideGrid.filter(
238
238
  (room) =>
239
239
  room.Data !== undefined &&
240
240
  room.Data.Type === RoomType.DEFAULT &&
@@ -242,7 +242,7 @@ export function getNewRoomCandidatesForLevel(
242
242
  !isMineShaft(room.Data), // Mineshaft rooms do not count as special rooms.
243
243
  );
244
244
 
245
- const roomsToLookThrough = ensureDeadEnd ? normalRooms : rooms;
245
+ const roomsToLookThrough = ensureDeadEnd ? normalRooms : roomsInsideGrid;
246
246
 
247
247
  const newRoomCandidates: Array<{
248
248
  readonly adjacentRoomGridIndex: int;
@@ -301,7 +301,7 @@ export function getRoomAdjacentGridIndexes(
301
301
  * Helper function to get an array of all of the room descriptors for rooms that match the specified
302
302
  * room type.
303
303
  *
304
- * This function only searches through rooms in the current dimension.
304
+ * This function only searches through rooms in the current dimension and rooms inside the grid.
305
305
  *
306
306
  * This function is variadic, meaning that you can specify N arguments to get the combined room
307
307
  * descriptors for N room types.
@@ -311,8 +311,8 @@ export function getRoomDescriptorsForType(
311
311
  ): RoomDescriptor[] {
312
312
  const roomTypesSet = new Set<RoomType>(roomTypes);
313
313
 
314
- const rooms = getRoomsInsideGrid();
315
- return rooms.filter(
314
+ const roomsInsideGrid = getRoomsInsideGrid();
315
+ return roomsInsideGrid.filter(
316
316
  (roomDescriptor) =>
317
317
  roomDescriptor.Data !== undefined &&
318
318
  roomTypesSet.has(roomDescriptor.Data.Type),
@@ -82,8 +82,8 @@ export function changeRoom(roomGridIndex: int): void {
82
82
  * include off-grid rooms, like the Devil Room.
83
83
  */
84
84
  export function getNumRooms(): int {
85
- const rooms = getRoomsInsideGrid();
86
- return rooms.length;
85
+ const roomsInsideGrid = getRoomsInsideGrid();
86
+ return roomsInsideGrid.length;
87
87
  }
88
88
 
89
89
  /**
@@ -199,7 +199,7 @@ export function getRoomTypeName(roomType: RoomType): string {
199
199
  export function getRooms(
200
200
  includeExtraDimensionalRooms = false,
201
201
  ): RoomDescriptor[] {
202
- // The obvious way to get all of the rooms would be to iterate over the `RoomList` from the
202
+ // The naive way to get all of the rooms would be to iterate over the `RoomList` from the
203
203
  // `Level.GetRooms` method. However, this results in read-only data, and we want to return a
204
204
  // writable object. Instead, we let the heavy lifting be handled by other functions.
205
205
  const roomsInGrid = getRoomsInsideGrid(includeExtraDimensionalRooms);
@@ -497,14 +497,14 @@ export function isAllRoomsClear(
497
497
  includeSecretAndSuperSecretRoom = false,
498
498
  includeUltraSecretRoom = false,
499
499
  ): boolean {
500
- const rooms = getRoomsInsideGrid();
500
+ const roomsInsideGrid = getRoomsInsideGrid();
501
501
 
502
502
  let matchingRooms: RoomDescriptor[];
503
503
  if (onlyCheckRoomTypes === undefined) {
504
- matchingRooms = rooms;
504
+ matchingRooms = roomsInsideGrid;
505
505
  } else {
506
506
  const roomTypeWhitelist = new ReadonlySet(onlyCheckRoomTypes);
507
- matchingRooms = rooms.filter(
507
+ matchingRooms = roomsInsideGrid.filter(
508
508
  (roomDescriptor) =>
509
509
  roomDescriptor.Data !== undefined &&
510
510
  roomTypeWhitelist.has(roomDescriptor.Data.Type),