isaacscript-common 1.2.172 → 1.2.175

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.
Files changed (80) hide show
  1. package/dist/callbacks/postNewRoomEarly.lua +2 -2
  2. package/dist/classes/null.d.ts +6 -7
  3. package/dist/classes/null.lua +5 -5
  4. package/dist/constants.d.ts +10 -10
  5. package/dist/constants.lua +3 -3
  6. package/dist/features/collectiblesSeen.d.ts +6 -0
  7. package/dist/features/collectiblesSeen.lua +43 -0
  8. package/dist/features/deployJSONRoom.lua +2 -1
  9. package/dist/features/extraConsoleCommands/commands.d.ts +11 -11
  10. package/dist/features/extraConsoleCommands/commands.lua +23 -22
  11. package/dist/features/extraConsoleCommands/init.lua +6 -6
  12. package/dist/features/playerInventory.d.ts +10 -2
  13. package/dist/features/playerInventory.lua +60 -21
  14. package/dist/features/saveDataManager/constants.d.ts +1 -1
  15. package/dist/features/saveDataManager/constants.lua +1 -1
  16. package/dist/features/saveDataManager/exports.d.ts +6 -6
  17. package/dist/features/saveDataManager/exports.lua +4 -4
  18. package/dist/features/saveDataManager/merge.lua +9 -8
  19. package/dist/featuresInitialized.d.ts +1 -1
  20. package/dist/featuresInitialized.lua +3 -3
  21. package/dist/functions/array.d.ts +39 -39
  22. package/dist/functions/array.lua +79 -79
  23. package/dist/functions/cards.d.ts +3 -3
  24. package/dist/functions/cards.lua +7 -7
  25. package/dist/functions/charge.d.ts +11 -11
  26. package/dist/functions/charge.lua +13 -13
  27. package/dist/functions/collectibles.d.ts +53 -15
  28. package/dist/functions/collectibles.lua +44 -21
  29. package/dist/functions/color.d.ts +2 -2
  30. package/dist/functions/color.lua +6 -6
  31. package/dist/functions/deepCopy.d.ts +0 -3
  32. package/dist/functions/deepCopy.lua +5 -22
  33. package/dist/functions/doors.d.ts +8 -8
  34. package/dist/functions/doors.lua +16 -16
  35. package/dist/functions/entity.d.ts +13 -14
  36. package/dist/functions/entity.lua +27 -34
  37. package/dist/functions/gridEntity.d.ts +8 -1
  38. package/dist/functions/gridEntity.lua +7 -11
  39. package/dist/functions/jsonHelpers.d.ts +7 -7
  40. package/dist/functions/jsonHelpers.lua +10 -11
  41. package/dist/functions/log.d.ts +21 -21
  42. package/dist/functions/log.lua +75 -74
  43. package/dist/functions/math.d.ts +1 -1
  44. package/dist/functions/math.lua +3 -3
  45. package/dist/functions/mergeTests.lua +56 -1
  46. package/dist/functions/player.d.ts +8 -10
  47. package/dist/functions/player.lua +22 -29
  48. package/dist/functions/playerHealth.d.ts +1 -1
  49. package/dist/functions/playerHealth.lua +20 -20
  50. package/dist/functions/positionVelocity.d.ts +3 -0
  51. package/dist/functions/positionVelocity.lua +19 -5
  52. package/dist/functions/random.d.ts +7 -7
  53. package/dist/functions/revive.d.ts +5 -5
  54. package/dist/functions/revive.lua +8 -8
  55. package/dist/functions/roomData.d.ts +96 -0
  56. package/dist/functions/roomData.lua +57 -0
  57. package/dist/functions/rooms.d.ts +1 -96
  58. package/dist/functions/rooms.lua +30 -75
  59. package/dist/functions/set.d.ts +2 -2
  60. package/dist/functions/set.lua +7 -7
  61. package/dist/functions/trinketCacheFlag.d.ts +4 -4
  62. package/dist/functions/trinketCacheFlag.lua +3 -2
  63. package/dist/functions/trinketGive.d.ts +7 -7
  64. package/dist/functions/trinketGive.lua +27 -27
  65. package/dist/functions/trinkets.d.ts +2 -2
  66. package/dist/functions/trinkets.lua +6 -6
  67. package/dist/functions/ui.d.ts +13 -13
  68. package/dist/functions/ui.lua +28 -28
  69. package/dist/functions/utils.d.ts +6 -0
  70. package/dist/functions/utils.lua +7 -0
  71. package/dist/functions/vector.d.ts +2 -0
  72. package/dist/functions/vector.lua +13 -0
  73. package/dist/index.d.ts +2 -0
  74. package/dist/index.lua +8 -0
  75. package/dist/maps/roomShapeToTopLeftWallGridIndexMap.d.ts +1 -1
  76. package/dist/maps/roomShapeToTopLeftWallGridIndexMap.lua +1 -1
  77. package/dist/types/CollectibleIndex.d.ts +15 -0
  78. package/dist/types/CollectibleIndex.lua +3 -0
  79. package/dist/upgradeMod.lua +3 -0
  80. package/package.json +2 -2
@@ -1,8 +1,9 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { CollectiblePedestalType } from "../enums/CollectiblePedestalType";
3
- export declare function collectibleHasTag(collectibleType: CollectibleType | int, tag: ItemConfigTag): boolean;
3
+ import { CollectibleIndex } from "../types/CollectibleIndex";
4
4
  export declare function clearCollectibleSprite(collectible: EntityPickup): void;
5
5
  export declare function collectibleHasCacheFlag(collectibleType: CollectibleType | int, cacheFlag: CacheFlag): boolean;
6
+ export declare function collectibleHasTag(collectibleType: CollectibleType | int, tag: ItemConfigTag): boolean;
6
7
  /**
7
8
  * Helper function to get the in-game description for a collectible. Returns "Unknown" if the
8
9
  * provided collectible type was not valid.
@@ -18,16 +19,42 @@ export declare function getCollectibleDevilHeartPrice(collectibleType: Collectib
18
19
  * "gfx/items/collectibles/questionmark.png" if the provided collectible type was not valid.
19
20
  */
20
21
  export declare function getCollectibleGfxFilename(collectibleType: CollectibleType | int): string;
22
+ /**
23
+ * Mods often have to track variables relating to a collectible. Finding an index for these kinds of
24
+ * data structures is difficult, since collectibles are respawned every time a player re-enters a
25
+ * room, so the `PtrHash` will change. Instead, we use a 3-tuple of the room list index, the grid
26
+ * index of the collectible in the room, and the collectible's InitSeed.
27
+ *
28
+ * When collectibles are rolled (e.g. with a D6), their InitSeed changes. If you want to track
29
+ * collectibles independently of any rerolls, then use the `PtrHash` as an index instead. (The
30
+ * `PtrHash` will not persist between rooms, however.)
31
+ *
32
+ * Note that:
33
+ * - The grid index is a necessary part of the collectible index because Diplopia and Crooked Penny
34
+ * can cause two or more collectibles with the same sub-type and InitSeed to exist in the same room.
35
+ * - This index will fail in the case where the player uses Diplopia or a successful Crooked Penny
36
+ * seven or more times in the same room, since that will cause two or more collectibles with the
37
+ * same grid index and InitSeed to exist.
38
+ * - Using a collectible's position as part of the index is problematic, since players can push a
39
+ * pedestal. (Even using the grid index does not solve this problem, since it is possible in certain
40
+ * cases for collectibles to be spawned at a position that is not aligned with the grid, and the
41
+ * pedestal pushed to an adjacent tile, but this case should be extremely rare.)
42
+ * - Mega Chests spawn two collectibles on the exact same position. However, both of them will have
43
+ * different InitSeeds, so this is not a problem for this indexing scheme.
44
+ * - The indexing scheme used is different for collectibles that are inside of a Treasure Room, in
45
+ * order to handle the case of the player seeing the same collectible again in a post-Ascent
46
+ * Treasure Room. An 4-tuple of stage, stage type, grid index, and InitSeed is used in this case.
47
+ * (Using the room list index or the room grid index is not suitable for this purpose, since both
48
+ * of these values can change in the post-Ascent Treasure Room.) Even though there can be two
49
+ * Treasure Rooms on an XL floor, both Treasure Rooms should not have collectibles with the same
50
+ * InitSeed.
51
+ */
52
+ export declare function getCollectibleIndex(collectible: EntityPickup): CollectibleIndex;
21
53
  /**
22
54
  * Helper function to get the initial amount of charges that a collectible has. Returns 0 if the
23
55
  * provided collectible type was not valid.
24
56
  */
25
- export declare function getCollectibleInitCharges(collectibleType: CollectibleType | int): int;
26
- /**
27
- * Helper function to get the path to a collectible's quality. Returns 0 if the provided collectible
28
- * type was not valid.
29
- */
30
- export declare function getCollectibleQuality(collectibleType: CollectibleType | int): int;
57
+ export declare function getCollectibleInitCharge(collectibleType: CollectibleType | int): int;
31
58
  /**
32
59
  * Helper function to get the `ItemType` of a collectible. Returns `ItemType.ITEM_NULL` if the
33
60
  * provided collectible type was not valid.
@@ -50,6 +77,11 @@ export declare function getCollectibleMaxCharges(collectibleType: CollectibleTyp
50
77
  */
51
78
  export declare function getCollectibleName(collectibleType: CollectibleType | int): string;
52
79
  export declare function getCollectiblePedestalType(collectible: EntityPickup): CollectiblePedestalType;
80
+ /**
81
+ * Helper function to get the path to a collectible's quality. Returns 0 if the provided collectible
82
+ * type was not valid.
83
+ */
84
+ export declare function getCollectibleQuality(collectibleType: CollectibleType | int): int;
53
85
  /** Helper function to get all of the collectible entities in the room. */
54
86
  export declare function getCollectibles(matchingSubType?: number): EntityPickup[];
55
87
  /**
@@ -59,6 +91,8 @@ export declare function getCollectibles(matchingSubType?: number): EntityPickup[
59
91
  * collectibles.
60
92
  */
61
93
  export declare function getMaxCollectibleType(): int;
94
+ /** Returns true if the item type in the item config is equal to `ItemType.ITEM_ACTIVE`. */
95
+ export declare function isActiveCollectible(collectibleType: CollectibleType | int): boolean;
62
96
  /**
63
97
  * Returns whether or not the given collectible is a "glitched" item. All items are replaced by
64
98
  * glitched items once a player has TMTRAINER. However, glitched items can also "naturally" appear
@@ -86,11 +120,6 @@ export declare function isSingleUseCollectible(collectibleType: CollectibleType
86
120
  * @returns True if one or more collectibles was removed, false otherwise.
87
121
  */
88
122
  export declare function removeAllCollectibles(collectibleType?: CollectibleType | int, cap?: int): boolean;
89
- /**
90
- * Helper function to remove all pickup delay on a collectible. By default, collectibles have a 20
91
- * frame delay before they can be picked up by a player.
92
- */
93
- export declare function removeCollectiblePickupDelay(collectible: EntityPickup): void;
94
123
  /**
95
124
  * Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that it
96
125
  * should remove an item.
@@ -100,10 +129,14 @@ export declare function removeCollectiblePickupDelay(collectible: EntityPickup):
100
129
  */
101
130
  export declare function removeCollectibleFromItemTracker(collectibleType: CollectibleType | int): void;
102
131
  /**
103
- * Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that
104
- * the build has been rerolled.
132
+ * Helper function to remove all pickup delay on a collectible. By default, collectibles have a 20
133
+ * frame delay before they can be picked up by a player.
134
+ */
135
+ export declare function removeCollectiblePickupDelay(collectible: EntityPickup): void;
136
+ /**
137
+ * Helper function to set a collectible sprite to a question mark (i.e. how collectibles look when
138
+ * the player has Curse of the Blind).
105
139
  */
106
- export declare function setCollectiblesRerolledForItemTracker(): void;
107
140
  export declare function setCollectibleBlind(collectible: EntityPickup): void;
108
141
  /**
109
142
  * Helper function to remove the collectible from a collectible pedestal and make it appear as if a
@@ -130,3 +163,8 @@ export declare function setCollectibleSprite(collectible: EntityPickup, pngPath:
130
163
  * not sufficient because the sprite will not change.
131
164
  */
132
165
  export declare function setCollectibleSubType(collectible: EntityPickup, newCollectibleType: CollectibleType | int): void;
166
+ /**
167
+ * Helper function to put a message in the log.txt file to let the Rebirth Item Tracker know that
168
+ * the build has been rerolled.
169
+ */
170
+ export declare function setCollectiblesRerolledForItemTracker(): void;
@@ -2,6 +2,7 @@
2
2
  local ____exports = {}
3
3
  local COLLECTIBLE_SPRITE_LAYER, COLLECTIBLE_SHADOW_LAYER
4
4
  local ____cachedClasses = require("cachedClasses")
5
+ local game = ____cachedClasses.game
5
6
  local itemConfig = ____cachedClasses.itemConfig
6
7
  local ____constants = require("constants")
7
8
  local BLIND_ITEM_PNG_PATH = ____constants.BLIND_ITEM_PNG_PATH
@@ -17,6 +18,8 @@ local hasFlag = ____flag.hasFlag
17
18
  local ____pickups = require("functions.pickups")
18
19
  local getPickups = ____pickups.getPickups
19
20
  local removeAllPickups = ____pickups.removeAllPickups
21
+ local ____roomData = require("functions.roomData")
22
+ local getRoomListIndex = ____roomData.getRoomListIndex
20
23
  local ____sprite = require("functions.sprite")
21
24
  local clearSprite = ____sprite.clearSprite
22
25
  function ____exports.setCollectibleSprite(self, collectible, pngPath)
@@ -34,13 +37,6 @@ end
34
37
  COLLECTIBLE_SPRITE_LAYER = 1
35
38
  COLLECTIBLE_SHADOW_LAYER = 4
36
39
  local GLITCHED_ITEM_THRESHOLD = 4000000000
37
- function ____exports.collectibleHasTag(self, collectibleType, tag)
38
- local itemConfigItem = itemConfig:GetCollectible(collectibleType)
39
- if itemConfigItem == nil then
40
- return false
41
- end
42
- return itemConfigItem:HasTags(tag)
43
- end
44
40
  function ____exports.clearCollectibleSprite(self, collectible)
45
41
  ____exports.setCollectibleSprite(nil, collectible, nil)
46
42
  end
@@ -51,6 +47,13 @@ function ____exports.collectibleHasCacheFlag(self, collectibleType, cacheFlag)
51
47
  end
52
48
  return hasFlag(nil, itemConfigItem.CacheFlags, cacheFlag)
53
49
  end
50
+ function ____exports.collectibleHasTag(self, collectibleType, tag)
51
+ local itemConfigItem = itemConfig:GetCollectible(collectibleType)
52
+ if itemConfigItem == nil then
53
+ return false
54
+ end
55
+ return itemConfigItem:HasTags(tag)
56
+ end
54
57
  function ____exports.getCollectibleDescription(self, collectibleType)
55
58
  local collectibleDescription = COLLECTIBLE_DESCRIPTION_MAP:get(collectibleType)
56
59
  if collectibleDescription ~= nil then
@@ -85,19 +88,28 @@ function ____exports.getCollectibleGfxFilename(self, collectibleType)
85
88
  end
86
89
  return itemConfigItem.GfxFileName
87
90
  end
88
- function ____exports.getCollectibleInitCharges(self, collectibleType)
89
- local itemConfigItem = itemConfig:GetCollectible(collectibleType)
90
- if itemConfigItem == nil then
91
- return 0
91
+ function ____exports.getCollectibleIndex(self, collectible)
92
+ if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
93
+ error("You cannot get a collectible index for pickups of variant: " .. tostring(collectible.Variant))
92
94
  end
93
- return itemConfigItem.InitCharge
95
+ local level = game:GetLevel()
96
+ local stage = level:GetStage()
97
+ local stageType = level:GetStageType()
98
+ local room = game:GetRoom()
99
+ local roomType = room:GetType()
100
+ local gridIndex = room:GetGridIndex(collectible.Position)
101
+ local roomListIndex = getRoomListIndex(nil)
102
+ if roomType == RoomType.ROOM_TREASURE then
103
+ return (((((tostring(stage) .. ",") .. tostring(stageType)) .. ",") .. tostring(gridIndex)) .. ",") .. tostring(collectible.InitSeed)
104
+ end
105
+ return (((tostring(roomListIndex) .. ",") .. tostring(gridIndex)) .. ",") .. tostring(collectible.InitSeed)
94
106
  end
95
- function ____exports.getCollectibleQuality(self, collectibleType)
107
+ function ____exports.getCollectibleInitCharge(self, collectibleType)
96
108
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
97
109
  if itemConfigItem == nil then
98
110
  return 0
99
111
  end
100
- return itemConfigItem.Quality
112
+ return itemConfigItem.InitCharge
101
113
  end
102
114
  function ____exports.getCollectibleItemType(self, collectibleType)
103
115
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
@@ -131,6 +143,13 @@ function ____exports.getCollectiblePedestalType(self, collectible)
131
143
  local sprite = collectible:GetSprite()
132
144
  return sprite:GetOverlayFrame()
133
145
  end
146
+ function ____exports.getCollectibleQuality(self, collectibleType)
147
+ local itemConfigItem = itemConfig:GetCollectible(collectibleType)
148
+ if itemConfigItem == nil then
149
+ return 0
150
+ end
151
+ return itemConfigItem.Quality
152
+ end
134
153
  function ____exports.getCollectibles(self, matchingSubType)
135
154
  if matchingSubType == nil then
136
155
  matchingSubType = -1
@@ -140,6 +159,10 @@ end
140
159
  function ____exports.getMaxCollectibleType(self)
141
160
  return itemConfig:GetCollectibles().Size - 1
142
161
  end
162
+ function ____exports.isActiveCollectible(self, collectibleType)
163
+ local itemType = ____exports.getCollectibleItemType(nil, collectibleType)
164
+ return itemType == ItemType.ITEM_ACTIVE
165
+ end
143
166
  function ____exports.isGlitchedCollectible(self, pickup)
144
167
  return pickup.Variant == PickupVariant.PICKUP_COLLECTIBLE and pickup.SubType > GLITCHED_ITEM_THRESHOLD
145
168
  end
@@ -156,19 +179,16 @@ end
156
179
  function ____exports.removeAllCollectibles(self, collectibleType, cap)
157
180
  return removeAllPickups(nil, PickupVariant.PICKUP_COLLECTIBLE, collectibleType, cap)
158
181
  end
182
+ function ____exports.removeCollectibleFromItemTracker(self, collectibleType)
183
+ local collectibleName = ____exports.getCollectibleName(nil, collectibleType)
184
+ Isaac.DebugString(((("Removing collectible " .. tostring(collectibleType)) .. " (") .. collectibleName) .. ") on player 0 (Player)")
185
+ end
159
186
  function ____exports.removeCollectiblePickupDelay(self, collectible)
160
187
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
161
188
  error("You cannot remove pickup delay for pickups of variant: " .. tostring(collectible.Variant))
162
189
  end
163
190
  collectible.Wait = 0
164
191
  end
165
- function ____exports.removeCollectibleFromItemTracker(self, collectibleType)
166
- local collectibleName = ____exports.getCollectibleName(nil, collectibleType)
167
- Isaac.DebugString(((("Removing collectible " .. tostring(collectibleType)) .. " (") .. collectibleName) .. ") on player 0 (Player)")
168
- end
169
- function ____exports.setCollectiblesRerolledForItemTracker(self)
170
- Isaac.DebugString("Added 3 Collectibles")
171
- end
172
192
  function ____exports.setCollectibleBlind(self, collectible)
173
193
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
174
194
  error("You cannot set a collectible to be blind for pickups of variant: " .. tostring(collectible.Variant))
@@ -199,4 +219,7 @@ function ____exports.setCollectibleSubType(self, collectible, newCollectibleType
199
219
  true
200
220
  )
201
221
  end
222
+ function ____exports.setCollectiblesRerolledForItemTracker(self)
223
+ Isaac.DebugString("Added 3 Collectibles")
224
+ end
202
225
  return ____exports
@@ -1,5 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
- export declare function getDefaultColor(): Color;
3
- export declare function getDefaultKColor(): KColor;
4
2
  export declare function copyColor(color: Color): Color;
5
3
  export declare function copyKColor(kColor: KColor): KColor;
4
+ export declare function getDefaultColor(): Color;
5
+ export declare function getDefaultKColor(): KColor;
@@ -1,11 +1,5 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____exports = {}
3
- function ____exports.getDefaultColor(self)
4
- return Color(1, 1, 1)
5
- end
6
- function ____exports.getDefaultKColor(self)
7
- return KColor(1, 1, 1, 1)
8
- end
9
3
  function ____exports.copyColor(self, color)
10
4
  return Color(
11
5
  color.R,
@@ -20,4 +14,10 @@ end
20
14
  function ____exports.copyKColor(self, kColor)
21
15
  return KColor(kColor.Red, kColor.Green, kColor.Blue, kColor.Alpha)
22
16
  end
17
+ function ____exports.getDefaultColor(self)
18
+ return Color(1, 1, 1)
19
+ end
20
+ function ____exports.getDefaultKColor(self)
21
+ return KColor(1, 1, 1, 1)
22
+ end
23
23
  return ____exports
@@ -1,5 +1,4 @@
1
1
  /// <reference types="typescript-to-lua/language-extensions" />
2
- /// <reference types="isaac-typescript-definitions" />
3
2
  import { SerializationType } from "../enums/SerializationType";
4
3
  /**
5
4
  * deepCopy is a semi-generic deep cloner. It will recursively copy all of the values so that none
@@ -21,8 +20,6 @@ import { SerializationType } from "../enums/SerializationType";
21
20
  * @param traversalDescription Used to track the current key that we are operating on.
22
21
  */
23
22
  export declare function deepCopy(oldObject: LuaTable | Map<AnyNotNil, unknown> | Set<AnyNotNil>, serializationType?: SerializationType, traversalDescription?: string): LuaTable | Map<AnyNotNil, unknown> | Set<AnyNotNil>;
24
- export declare function deserializeVector(vectorTable: LuaTable): Vector;
25
- export declare function addTraversalDescription(key: AnyNotNil, traversalDescription: string): string;
26
23
  /**
27
24
  * Used to determine is the given table is a serialized Vector created by the save data manager
28
25
  * and/or the `deepCopy` function.
@@ -18,7 +18,10 @@ local ____constants = require("features.saveDataManager.constants")
18
18
  local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
19
19
  local ____log = require("functions.log")
20
20
  local log = ____log.log
21
+ local ____utils = require("functions.utils")
22
+ local getTraversalDescription = ____utils.getTraversalDescription
21
23
  local ____vector = require("functions.vector")
24
+ local deserializeVector = ____vector.deserializeVector
22
25
  local isVector = ____vector.isVector
23
26
  function ____exports.deepCopy(self, oldObject, serializationType, traversalDescription)
24
27
  if serializationType == nil then
@@ -205,10 +208,10 @@ function deepCopyValue(self, oldObject, newObject, key, value, traversalDescript
205
208
  newValue = copyVector(nil, vector, serializationType)
206
209
  elseif ____exports.isSerializedVector(nil, value) and serializationType == SerializationType.DESERIALIZE then
207
210
  local serializedVector = value
208
- newValue = ____exports.deserializeVector(nil, serializedVector)
211
+ newValue = deserializeVector(nil, serializedVector)
209
212
  elseif valueType == "table" then
210
213
  local ____table = value
211
- traversalDescription = ____exports.addTraversalDescription(nil, key, traversalDescription)
214
+ traversalDescription = getTraversalDescription(nil, key, traversalDescription)
212
215
  newValue = ____exports.deepCopy(nil, ____table, serializationType, traversalDescription)
213
216
  else
214
217
  newValue = value
@@ -233,19 +236,6 @@ function copyVector(self, vector, serializationType)
233
236
  local newVector = Vector(vector.X, vector.Y)
234
237
  return newVector
235
238
  end
236
- function ____exports.deserializeVector(self, vectorTable)
237
- local xString = vectorTable.X
238
- local x = tonumber(xString)
239
- if x == nil then
240
- error("Failed to read the X value of a serialized vector.")
241
- end
242
- local yString = vectorTable.Y
243
- local y = tonumber(yString)
244
- if y == nil then
245
- error("Failed to read the Y value of a serialized vector.")
246
- end
247
- return Vector(x, y)
248
- end
249
239
  function checkMetatable(self, ____table, traversalDescription)
250
240
  local metatable = getmetatable(____table)
251
241
  if metatable == nil then
@@ -262,13 +252,6 @@ function validateValue(self, value, valueType, traversalDescription)
262
252
  error(((("The deepCopy function detected that \"" .. traversalDescription) .. "\" is type ") .. valueType) .. ", which is not supported.")
263
253
  end
264
254
  end
265
- function ____exports.addTraversalDescription(self, key, traversalDescription)
266
- if traversalDescription ~= "" then
267
- traversalDescription = traversalDescription .. " --> "
268
- end
269
- traversalDescription = traversalDescription .. tostring(key)
270
- return traversalDescription
271
- end
272
255
  function ____exports.isSerializedVector(self, object)
273
256
  local objectType = type(object)
274
257
  if objectType ~= "table" then
@@ -6,6 +6,13 @@ export declare function closeAllDoors(): void;
6
6
  */
7
7
  export declare function closeDoorFast(door: GridEntityDoor): void;
8
8
  export declare function doorSlotToDirection(doorSlot: DoorSlot): Direction;
9
+ export declare function getAngelRoomDoor(): GridEntityDoor | undefined;
10
+ export declare function getDevilRoomDoor(): GridEntityDoor | undefined;
11
+ /**
12
+ * If there is both a Devil Room and an Angel Room door, this function will return door with the
13
+ * lowest slot number.
14
+ */
15
+ export declare function getDevilRoomOrAngelRoomDoor(): GridEntityDoor | undefined;
9
16
  /**
10
17
  * Helper function to get all of the doors in the room. By default, it will return every door. You
11
18
  * can optionally specify one or more room types to return only the doors that match the specified
@@ -19,17 +26,9 @@ export declare function getDoors(...roomTypes: RoomType[]): GridEntityDoor[];
19
26
  * that match any of the N room grid indexes.
20
27
  */
21
28
  export declare function getDoorsToRoomIndex(...roomGridIndex: int[]): GridEntityDoor[];
22
- export declare function getAngelRoomDoor(): GridEntityDoor | undefined;
23
- export declare function getDevilRoomDoor(): GridEntityDoor | undefined;
24
- /**
25
- * If there is both a Devil Room and an Angel Room door, this function will return door with the
26
- * lowest slot number.
27
- */
28
- export declare function getDevilRoomOrAngelRoomDoor(): GridEntityDoor | undefined;
29
29
  export declare function getRepentanceDoor(): GridEntityDoor | undefined;
30
30
  export declare function isAngelRoomDoor(door: GridEntityDoor): boolean;
31
31
  export declare function isDevilRoomDoor(door: GridEntityDoor): boolean;
32
- export declare function isHiddenSecretRoomDoor(door: GridEntityDoor): boolean;
33
32
  /**
34
33
  * This refers to the Repentance door that spawns in a boss room after defeating the boss.
35
34
  * You have to spend one key to open it.
@@ -60,6 +59,7 @@ export declare function isDoorToMines(door: GridEntityDoor): boolean;
60
59
  * It has a sprite filename of "gfx/grid/Door_MomsHeart.anm2".
61
60
  */
62
61
  export declare function isDoorToMomsHeart(door: GridEntityDoor): boolean;
62
+ export declare function isHiddenSecretRoomDoor(door: GridEntityDoor): boolean;
63
63
  export declare function isRepentanceDoor(door: GridEntityDoor): boolean;
64
64
  export declare function isSecretRoomDoor(door: GridEntityDoor): boolean;
65
65
  /**
@@ -23,13 +23,13 @@ function ____exports.getDoors(self, ...)
23
23
  do
24
24
  local door = room:GetDoor(i)
25
25
  if door == nil then
26
- goto __continue8
26
+ goto __continue11
27
27
  end
28
28
  if #roomTypes == 0 or roomTypesSet:has(door.TargetRoomType) then
29
29
  __TS__ArrayPush(doors, door)
30
30
  end
31
31
  end
32
- ::__continue8::
32
+ ::__continue11::
33
33
  i = i + 1
34
34
  end
35
35
  end
@@ -66,15 +66,6 @@ end
66
66
  function ____exports.doorSlotToDirection(self, doorSlot)
67
67
  return DOOR_SLOT_TO_DIRECTION[doorSlot]
68
68
  end
69
- function ____exports.getDoorsToRoomIndex(self, ...)
70
- local roomGridIndex = {...}
71
- local roomGridIndexesSet = __TS__New(Set, roomGridIndex)
72
- local doors = ____exports.getDoors(nil)
73
- return __TS__ArrayFilter(
74
- doors,
75
- function(____, door) return roomGridIndexesSet:has(door.TargetRoomIndex) end
76
- )
77
- end
78
69
  function ____exports.getAngelRoomDoor(self)
79
70
  local angelRoomDoors = ____exports.getDoors(nil, RoomType.ROOM_ANGEL)
80
71
  local ____temp_0
@@ -105,6 +96,15 @@ function ____exports.getDevilRoomOrAngelRoomDoor(self)
105
96
  end
106
97
  return ____temp_2
107
98
  end
99
+ function ____exports.getDoorsToRoomIndex(self, ...)
100
+ local roomGridIndex = {...}
101
+ local roomGridIndexesSet = __TS__New(Set, roomGridIndex)
102
+ local doors = ____exports.getDoors(nil)
103
+ return __TS__ArrayFilter(
104
+ doors,
105
+ function(____, door) return roomGridIndexesSet:has(door.TargetRoomIndex) end
106
+ )
107
+ end
108
108
  function ____exports.getRepentanceDoor(self)
109
109
  local doors = ____exports.getDoors(nil)
110
110
  return __TS__ArrayFind(
@@ -118,11 +118,6 @@ end
118
118
  function ____exports.isDevilRoomDoor(self, door)
119
119
  return door.TargetRoomType == RoomType.ROOM_DEVIL
120
120
  end
121
- function ____exports.isHiddenSecretRoomDoor(self, door)
122
- local sprite = door:GetSprite()
123
- local animation = sprite:GetAnimation()
124
- return ____exports.isSecretRoomDoor(nil, door) and animation == "Hidden"
125
- end
126
121
  function ____exports.isDoorToDownpour(self, door)
127
122
  if not ____exports.isRepentanceDoor(nil, door) then
128
123
  return false
@@ -163,6 +158,11 @@ function ____exports.isDoorToMomsHeart(self, door)
163
158
  local filename = sprite:GetFilename()
164
159
  return filename == "gfx/grid/Door_MomsHeart.anm2"
165
160
  end
161
+ function ____exports.isHiddenSecretRoomDoor(self, door)
162
+ local sprite = door:GetSprite()
163
+ local animation = sprite:GetAnimation()
164
+ return ____exports.isSecretRoomDoor(nil, door) and animation == "Hidden"
165
+ end
166
166
  function ____exports.lockDoor(self, door)
167
167
  local level = game:GetLevel()
168
168
  local roomDescriptor = level:GetRoomByIdx(door.TargetRoomIndex)
@@ -1,6 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  import { AnyEntity } from "../types/AnyEntity";
3
- export declare function anyEntityCloserThan(entities: Entity[], position: Vector, distance: int): boolean;
4
3
  /**
5
4
  * Helper function to count the number of entities in room. Use this over the vanilla
6
5
  * `Isaac.CountEntities` method to avoid having to specify a spawner and to handle ignoring charmed
@@ -24,11 +23,6 @@ export declare function countEntities(entityType?: EntityType | int, variant?: n
24
23
  * ```
25
24
  */
26
25
  export declare function getClosestEntityTo<T extends AnyEntity>(referenceEntity: Entity, entities: T[]): T;
27
- /**
28
- * Helper function to compare two different arrays of entities. Returns the entities that are in the
29
- * second array but not in the first array.
30
- */
31
- export declare function getFilteredNewEntities<T extends AnyEntity>(oldEntities: T[], newEntities: T[]): T[];
32
26
  /**
33
27
  * Helper function to get all of the entities in the room or all of the entities that match a
34
28
  * specific entity type / variant / sub-type.
@@ -55,6 +49,11 @@ export declare function getFilteredNewEntities<T extends AnyEntity>(oldEntities:
55
49
  export declare function getEntities(matchingEntityType?: EntityType | int, matchingVariant?: number, matchingSubType?: number, ignoreFriendly?: boolean): Entity[];
56
50
  /** Helper function to return a string containing an entity's type, variant, and sub-type. */
57
51
  export declare function getEntityID(entity: Entity): string;
52
+ /**
53
+ * Helper function to compare two different arrays of entities. Returns the entities that are in the
54
+ * second array but not in the first array.
55
+ */
56
+ export declare function getFilteredNewEntities<T extends AnyEntity>(oldEntities: T[], newEntities: T[]): T[];
58
57
  /**
59
58
  * Helper function to measure an entity's velocity to see if it is moving.
60
59
  *
@@ -68,14 +67,6 @@ export declare function isEntityMoving(entity: Entity, threshold?: number): bool
68
67
  * to non-story bosses, like Vanishing Twin. Also see the `STORY_BOSSES` constant.
69
68
  */
70
69
  export declare function isStoryBoss(entity: Entity): boolean;
71
- /**
72
- * Helper function to remove all of the entities in the supplied array.
73
- *
74
- * @param entities The array of entities to remove.
75
- * @param cap Optional. If specified, will only remove the given amount of entities.
76
- * @returns True if one or more entities was removed, false otherwise.
77
- */
78
- export declare function removeEntities(entities: Entity[], cap?: int): boolean;
79
70
  /**
80
71
  * Helper function to remove all of the matching entities in the room.
81
72
  *
@@ -88,6 +79,14 @@ export declare function removeEntities(entities: Entity[], cap?: int): boolean;
88
79
  * @returns True if one or more entities was removed, false otherwise.
89
80
  */
90
81
  export declare function removeAllMatchingEntities(entityType: int, entityVariant?: number, entitySubType?: number, cap?: int | undefined): boolean;
82
+ /**
83
+ * Helper function to remove all of the entities in the supplied array.
84
+ *
85
+ * @param entities The array of entities to remove.
86
+ * @param cap Optional. If specified, will only remove the given amount of entities.
87
+ * @returns True if one or more entities was removed, false otherwise.
88
+ */
89
+ export declare function removeEntities(entities: Entity[], cap?: int): boolean;
91
90
  /**
92
91
  * Helper function to reroll an enemy. Use this instead of the vanilla "Game.RerollEnemy" function
93
92
  * if you want the rerolled enemy to be returned.
@@ -1,6 +1,5 @@
1
1
  --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
2
  local ____lualib = require("lualib_bundle")
3
- local __TS__ArraySome = ____lualib.__TS__ArraySome
4
3
  local Set = ____lualib.Set
5
4
  local __TS__New = ____lualib.__TS__New
6
5
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
@@ -15,11 +14,19 @@ local getRandom = ____random.getRandom
15
14
  local nextSeed = ____random.nextSeed
16
15
  local ____utils = require("functions.utils")
17
16
  local ____repeat = ____utils["repeat"]
18
- function ____exports.anyEntityCloserThan(self, entities, position, distance)
19
- return __TS__ArraySome(
20
- entities,
21
- function(____, entity) return position:Distance(entity.Position) <= distance end
22
- )
17
+ function ____exports.removeEntities(self, entities, cap)
18
+ if #entities == 0 then
19
+ return false
20
+ end
21
+ local numEntitiesRemoved = 0
22
+ for ____, entity in ipairs(entities) do
23
+ entity:Remove()
24
+ numEntitiesRemoved = numEntitiesRemoved + 1
25
+ if cap ~= nil and numEntitiesRemoved >= cap then
26
+ return true
27
+ end
28
+ end
29
+ return true
23
30
  end
24
31
  function ____exports.countEntities(self, entityType, variant, subType, ignoreFriendly)
25
32
  if entityType == nil then
@@ -61,20 +68,6 @@ function ____exports.getClosestEntityTo(self, referenceEntity, entities)
61
68
  end
62
69
  return closestEntity
63
70
  end
64
- function ____exports.getFilteredNewEntities(self, oldEntities, newEntities)
65
- local oldEntitiesSet = __TS__New(Set)
66
- for ____, entity in ipairs(oldEntities) do
67
- local ptrHash = GetPtrHash(entity)
68
- oldEntitiesSet:add(ptrHash)
69
- end
70
- return __TS__ArrayFilter(
71
- newEntities,
72
- function(____, entity)
73
- local ptrHash = GetPtrHash(entity)
74
- return not oldEntitiesSet:has(ptrHash)
75
- end
76
- )
77
- end
78
71
  function ____exports.getEntities(self, matchingEntityType, matchingVariant, matchingSubType, ignoreFriendly)
79
72
  if matchingVariant == nil then
80
73
  matchingVariant = -1
@@ -93,6 +86,20 @@ end
93
86
  function ____exports.getEntityID(self, entity)
94
87
  return (((tostring(entity.Type) .. ".") .. tostring(entity.Variant)) .. ".") .. tostring(entity.SubType)
95
88
  end
89
+ function ____exports.getFilteredNewEntities(self, oldEntities, newEntities)
90
+ local oldEntitiesSet = __TS__New(Set)
91
+ for ____, entity in ipairs(oldEntities) do
92
+ local ptrHash = GetPtrHash(entity)
93
+ oldEntitiesSet:add(ptrHash)
94
+ end
95
+ return __TS__ArrayFilter(
96
+ newEntities,
97
+ function(____, entity)
98
+ local ptrHash = GetPtrHash(entity)
99
+ return not oldEntitiesSet:has(ptrHash)
100
+ end
101
+ )
102
+ end
96
103
  function ____exports.isEntityMoving(self, entity, threshold)
97
104
  if threshold == nil then
98
105
  threshold = 0.01
@@ -102,20 +109,6 @@ end
102
109
  function ____exports.isStoryBoss(self, entity)
103
110
  return STORY_BOSSES:has(entity.Type)
104
111
  end
105
- function ____exports.removeEntities(self, entities, cap)
106
- if #entities == 0 then
107
- return false
108
- end
109
- local numEntitiesRemoved = 0
110
- for ____, entity in ipairs(entities) do
111
- entity:Remove()
112
- numEntitiesRemoved = numEntitiesRemoved + 1
113
- if cap ~= nil and numEntitiesRemoved >= cap then
114
- return true
115
- end
116
- end
117
- return true
118
- end
119
112
  function ____exports.removeAllMatchingEntities(self, entityType, entityVariant, entitySubType, cap)
120
113
  if entityVariant == nil then
121
114
  entityVariant = -1
@@ -5,6 +5,13 @@
5
5
  * 1000.0 in a room XML file, but `GridEntityType.GRID_ROCK` is equal to 2.
6
6
  */
7
7
  export declare function convertXMLGridEntityType(gridEntityXMLType: int, gridEntityXMLVariant: int): [int, int] | undefined;
8
+ /**
9
+ * Gets the entities that have a hitbox that overlaps with any part of the square that the grid
10
+ * entity is on.
11
+ *
12
+ * Note that this function will not work properly in the PostNewRoom callback, since entities do not
13
+ * have collision yet in that callback.
14
+ */
8
15
  export declare function getCollidingEntitiesWithGridEntity(gridEntity: GridEntity): Entity[];
9
16
  /**
10
17
  * Helper function to get every grid entity in the current room.
@@ -37,13 +44,13 @@ export declare function getGridEntities(...gridEntityTypes: GridEntityType[]): G
37
44
  * arguments to match specific grid entity types.
38
45
  */
39
46
  export declare function getGridEntitiesMap(...gridEntityTypes: GridEntityType[]): Map<int, GridEntity>;
47
+ export declare function getSurroundingGridEntities(gridEntity: GridEntity): GridEntity[];
40
48
  export declare function getTopLeftWall(): GridEntity | undefined;
41
49
  /**
42
50
  * Helper function to get the grid index of the top left wall.
43
51
  * (This will depend on what the current room shape is.)
44
52
  */
45
53
  export declare function getTopLeftWallGridIndex(): int;
46
- export declare function getSurroundingGridEntities(gridEntity: GridEntity): GridEntity[];
47
54
  /**
48
55
  * Helper function to determine if all of the pressure plates in the current room are pushed.
49
56
  * Returns true if there are no pressure plates in the room.