isaacscript-common 3.0.0 → 3.2.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.
Files changed (95) hide show
  1. package/cachedClasses.d.ts +6 -4
  2. package/cachedClasses.lua +4 -4
  3. package/callbacks/postPickupInitFirst.d.ts +1 -0
  4. package/callbacks/postPickupInitFirst.lua +55 -0
  5. package/callbacks/postSlotDestroyed.d.ts +1 -0
  6. package/callbacks/postSlotDestroyed.lua +66 -0
  7. package/callbacks/postSlotRender.lua +3 -21
  8. package/callbacks/subscriptions/postCustomRevive.d.ts +1 -0
  9. package/callbacks/subscriptions/postDoorRender.d.ts +1 -0
  10. package/callbacks/subscriptions/postDoorUpdate.d.ts +1 -0
  11. package/callbacks/subscriptions/postPickupCollect.d.ts +1 -0
  12. package/callbacks/subscriptions/postPickupInitFirst.d.ts +3 -0
  13. package/callbacks/subscriptions/postPickupInitFirst.lua +29 -0
  14. package/callbacks/subscriptions/postPickupStateChanged.d.ts +1 -0
  15. package/callbacks/subscriptions/postPitRender.d.ts +1 -0
  16. package/callbacks/subscriptions/postPitUpdate.d.ts +1 -0
  17. package/callbacks/subscriptions/postPoopRender.d.ts +1 -0
  18. package/callbacks/subscriptions/postPoopUpdate.d.ts +1 -0
  19. package/callbacks/subscriptions/postPressurePlateRender.d.ts +1 -0
  20. package/callbacks/subscriptions/postPressurePlateUpdate.d.ts +1 -0
  21. package/callbacks/subscriptions/postRockRender.d.ts +1 -0
  22. package/callbacks/subscriptions/postRockUpdate.d.ts +1 -0
  23. package/callbacks/subscriptions/postSpikesRender.d.ts +1 -0
  24. package/callbacks/subscriptions/postSpikesUpdate.d.ts +1 -0
  25. package/callbacks/subscriptions/postTNTRender.d.ts +1 -0
  26. package/callbacks/subscriptions/postTNTUpdate.d.ts +1 -0
  27. package/classes/DefaultMap.d.ts +1 -2
  28. package/classes/DefaultMap.lua +1 -4
  29. package/enums/ModCallbackCustom.d.ts +61 -39
  30. package/enums/ModCallbackCustom.lua +40 -38
  31. package/features/debugDisplay/exports.d.ts +17 -0
  32. package/features/debugDisplay/v.d.ts +17 -0
  33. package/features/deployJSONRoom.d.ts +1 -0
  34. package/features/saveDataManager/load.lua +12 -8
  35. package/features/saveDataManager/main.lua +10 -3
  36. package/features/saveDataManager/merge.lua +33 -21
  37. package/features/saveDataManager/save.lua +12 -7
  38. package/functions/array.d.ts +2 -0
  39. package/functions/bombs.d.ts +3 -0
  40. package/functions/bombs.lua +12 -0
  41. package/functions/chargeBar.d.ts +1 -0
  42. package/functions/collectibles.d.ts +13 -8
  43. package/functions/collectibles.lua +24 -11
  44. package/functions/deepCopy.lua +35 -26
  45. package/functions/deepCopyTests.lua +8 -5
  46. package/functions/direction.d.ts +8 -0
  47. package/functions/direction.lua +27 -0
  48. package/functions/doors.d.ts +1 -0
  49. package/functions/doors.lua +5 -0
  50. package/functions/entity.d.ts +4 -4
  51. package/functions/entity.lua +8 -8
  52. package/functions/entitySpecific.d.ts +20 -20
  53. package/functions/entitySpecific.lua +10 -10
  54. package/functions/enums.d.ts +2 -0
  55. package/functions/globals.lua +2 -10
  56. package/functions/gridEntitySpecific.d.ts +5 -0
  57. package/functions/isaacAPIClass.d.ts +4 -4
  58. package/functions/isaacAPIClass.lua +6 -6
  59. package/functions/jsonRoom.d.ts +2 -0
  60. package/functions/log.lua +3 -3
  61. package/functions/pickups.d.ts +9 -9
  62. package/functions/player.d.ts +7 -0
  63. package/functions/player.lua +44 -9
  64. package/functions/playerHealth.d.ts +3 -0
  65. package/functions/playerHealth.lua +87 -68
  66. package/functions/playerIndex.d.ts +2 -0
  67. package/functions/positionVelocity.d.ts +3 -0
  68. package/functions/random.d.ts +2 -0
  69. package/functions/revive.d.ts +2 -0
  70. package/functions/rng.d.ts +1 -0
  71. package/functions/saveFile.d.ts +15 -0
  72. package/functions/saveFile.lua +106 -0
  73. package/functions/serialization.lua +2 -2
  74. package/functions/set.d.ts +1 -0
  75. package/functions/sprite.d.ts +2 -0
  76. package/functions/table.d.ts +12 -0
  77. package/functions/table.lua +34 -0
  78. package/functions/tears.d.ts +1 -0
  79. package/functions/tstlClass.d.ts +34 -0
  80. package/functions/tstlClass.lua +54 -9
  81. package/functions/ui.d.ts +2 -0
  82. package/functions/utils.d.ts +15 -0
  83. package/functions/utils.lua +20 -0
  84. package/functions/vector.lua +4 -16
  85. package/index.d.ts +2 -0
  86. package/index.lua +16 -0
  87. package/initCustomCallbacks.lua +6 -0
  88. package/interfaces/AddCallbackParameterCustom.d.ts +2 -0
  89. package/interfaces/ChargeBarSprites.d.ts +1 -0
  90. package/interfaces/private/TSTLClassMetatable.d.ts +2 -0
  91. package/objects/callbackRegisterFunctions.lua +3 -0
  92. package/objects/oppositeDoorSlots.d.ts +4 -0
  93. package/objects/oppositeDoorSlots.lua +15 -0
  94. package/package.json +1 -1
  95. package/types/AnyEntity.d.ts +10 -0
@@ -11,28 +11,33 @@ local ____jsonHelpers = require("functions.jsonHelpers")
11
11
  local jsonEncode = ____jsonHelpers.jsonEncode
12
12
  local ____log = require("functions.log")
13
13
  local log = ____log.log
14
+ local ____table = require("functions.table")
15
+ local iterateTableDeterministically = ____table.iterateTableDeterministically
14
16
  local ____constants = require("features.saveDataManager.constants")
17
+ local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
15
18
  local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
16
19
  function getAllSaveDataToWriteToDisk(self, saveDataMap, saveDataConditionalFuncMap)
17
20
  local allSaveData = {}
18
- for subscriberName, saveData in pairs(saveDataMap) do
19
- do
21
+ iterateTableDeterministically(
22
+ nil,
23
+ saveDataMap,
24
+ function(____, subscriberName, saveData)
20
25
  local conditionalFunc = saveDataConditionalFuncMap:get(subscriberName)
21
26
  if conditionalFunc ~= nil then
22
27
  local shouldSave = conditionalFunc(nil)
23
28
  if not shouldSave then
24
- goto __continue4
29
+ return
25
30
  end
26
31
  end
27
32
  local saveDataWithoutRoom = {persistent = saveData.persistent, run = saveData.run, level = saveData.level}
28
33
  if #__TS__ObjectKeys(saveDataWithoutRoom) == 0 then
29
- goto __continue4
34
+ return
30
35
  end
31
36
  local saveDataCopy = deepCopy(nil, saveDataWithoutRoom, SerializationType.SERIALIZE, subscriberName)
32
37
  allSaveData[subscriberName] = saveDataCopy
33
- end
34
- ::__continue4::
35
- end
38
+ end,
39
+ SAVE_DATA_MANAGER_DEBUG
40
+ )
36
41
  return allSaveData
37
42
  end
38
43
  function ____exports.saveToDisk(self, mod, saveDataMap, saveDataConditionalFuncMap)
@@ -1,4 +1,6 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
3
+ /// <reference types="isaac-typescript-definitions" />
2
4
  /**
3
5
  * Helper function for determining if two arrays contain the exact same elements. Note that this
4
6
  * only performs a shallow comparison.
@@ -0,0 +1,3 @@
1
+ /// <reference types="isaac-typescript-definitions" />
2
+ /** Helper function to find out how large a bomb explosion is based on the damage inflicted. */
3
+ export declare function getBombRadiusFromDamage(damage: float): float;
@@ -0,0 +1,12 @@
1
+ local ____exports = {}
2
+ --- Helper function to find out how large a bomb explosion is based on the damage inflicted.
3
+ function ____exports.getBombRadiusFromDamage(self, damage)
4
+ if damage > 175 then
5
+ return 105
6
+ end
7
+ if damage <= 140 then
8
+ return 75
9
+ end
10
+ return 90
11
+ end
12
+ return ____exports
@@ -1,4 +1,5 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
+ /// <reference types="isaac-typescript-definitions" />
2
3
  import { ChargeBarSprites } from "../interfaces/ChargeBarSprites";
3
4
  /**
4
5
  * Constructor for a `ChargeBarSprites` object. For more information, see the `renderChargeBar`
@@ -8,9 +8,14 @@ export declare function collectibleSpriteEquals(sprite1: Sprite, sprite2: Sprite
8
8
  * provided collectible type was not valid.
9
9
  */
10
10
  export declare function getCollectibleDescription(collectibleType: CollectibleType): string;
11
+ /**
12
+ * Helper function to get the coin cost that a collectible item would be if it were being offered in
13
+ * a Devil Room deal. Returns 0 if passed `CollectibleType.NULL`.
14
+ */
15
+ export declare function getCollectibleDevilCoinPrice(collectibleType: CollectibleType): int;
11
16
  /**
12
17
  * Helper function to get the heart cost that a collectible item would be if it were being offered
13
- * in a Devil Room deal. Returns 0 if passed CollectibleType.NULL.
18
+ * in a Devil Room deal. Returns 0 if passed `CollectibleType.NULL`.
14
19
  */
15
20
  export declare function getCollectibleDevilHeartPrice(collectibleType: CollectibleType, player: EntityPlayer): PickupPrice;
16
21
  /**
@@ -47,13 +52,13 @@ export declare function getCollectibleGfxFilename(collectibleType: CollectibleTy
47
52
  * and the pedestal pushed to an adjacent tile, but this case should be extremely rare.)
48
53
  * - Mega Chests spawn two collectibles on the exact same position. However, both of them will have
49
54
  * different InitSeeds, so this is not a problem for this indexing scheme.
50
- * - The indexing scheme used is different for collectibles that are inside of a Treasure Room, in
51
- * order to handle the case of the player seeing the same collectible again in a post-Ascent
52
- * Treasure Room. A 5-tuple of stage, stage type, grid index, SubType, and InitSeed is used in
53
- * this case. (Using the room list index or the room grid index is not suitable for this purpose,
54
- * since both of these values can change in the post-Ascent Treasure Room.) Even though there can
55
- * be two Treasure Rooms on an XL floor, both Treasure Rooms should not have collectibles with the
56
- * same grid index, Subtype, and InitSeed.
55
+ * - The indexing scheme used is different for collectibles that are inside of a Treasure Room or
56
+ * Boss Room, in order to handle the case of the player seeing the same collectible again in a
57
+ * post-Ascent Treasure Room or Boss Room. A 5-tuple of stage, stage type, grid index, SubType,
58
+ * and InitSeed is used in this case. (Using the room list index or the room grid index is not
59
+ * suitable for this purpose, since both of these values can change in the post-Ascent rooms.)
60
+ * Even though Treasure Rooms and Boss Rooms are grouped together in this scheme, there probably
61
+ * will not be collectibles with the same grid index, SubType, and InitSeed.
57
62
  */
58
63
  export declare function getCollectibleIndex(collectible: EntityPickup): CollectibleIndex;
59
64
  /**
@@ -108,8 +108,21 @@ function ____exports.getCollectibleDescription(self, collectibleType)
108
108
  end
109
109
  return DEFAULT_COLLECTIBLE_DESCRIPTION
110
110
  end
111
+ --- Helper function to get the coin cost that a collectible item would be if it were being offered in
112
+ -- a Devil Room deal. Returns 0 if passed `CollectibleType.NULL`.
113
+ function ____exports.getCollectibleDevilCoinPrice(self, collectibleType)
114
+ if collectibleType == CollectibleType.NULL then
115
+ return 0
116
+ end
117
+ local defaultCollectiblePrice = 15
118
+ local itemConfigItem = itemConfig:GetCollectible(collectibleType)
119
+ if itemConfigItem == nil then
120
+ return defaultCollectiblePrice
121
+ end
122
+ return itemConfigItem.DevilPrice * defaultCollectiblePrice
123
+ end
111
124
  --- Helper function to get the heart cost that a collectible item would be if it were being offered
112
- -- in a Devil Room deal. Returns 0 if passed CollectibleType.NULL.
125
+ -- in a Devil Room deal. Returns 0 if passed `CollectibleType.NULL`.
113
126
  function ____exports.getCollectibleDevilHeartPrice(self, collectibleType, player)
114
127
  local maxHearts = player:GetMaxHearts()
115
128
  if collectibleType == CollectibleType.NULL then
@@ -118,10 +131,10 @@ function ____exports.getCollectibleDevilHeartPrice(self, collectibleType, player
118
131
  if maxHearts == 0 then
119
132
  return PickupPrice.THREE_SOUL_HEARTS
120
133
  end
121
- local defaultPickupPrice = PickupPrice.ONE_HEART
134
+ local defaultCollectiblePrice = PickupPrice.ONE_HEART
122
135
  local itemConfigItem = itemConfig:GetCollectible(collectibleType)
123
136
  if itemConfigItem == nil then
124
- return defaultPickupPrice
137
+ return defaultCollectiblePrice
125
138
  end
126
139
  local twoHeartPrice = maxHearts == 2 and PickupPrice.ONE_HEART_AND_TWO_SOUL_HEARTS or PickupPrice.TWO_HEARTS
127
140
  return itemConfigItem.DevilPrice == 2 and twoHeartPrice or PickupPrice.ONE_HEART
@@ -163,13 +176,13 @@ end
163
176
  -- and the pedestal pushed to an adjacent tile, but this case should be extremely rare.)
164
177
  -- - Mega Chests spawn two collectibles on the exact same position. However, both of them will have
165
178
  -- different InitSeeds, so this is not a problem for this indexing scheme.
166
- -- - The indexing scheme used is different for collectibles that are inside of a Treasure Room, in
167
- -- order to handle the case of the player seeing the same collectible again in a post-Ascent
168
- -- Treasure Room. A 5-tuple of stage, stage type, grid index, SubType, and InitSeed is used in
169
- -- this case. (Using the room list index or the room grid index is not suitable for this purpose,
170
- -- since both of these values can change in the post-Ascent Treasure Room.) Even though there can
171
- -- be two Treasure Rooms on an XL floor, both Treasure Rooms should not have collectibles with the
172
- -- same grid index, Subtype, and InitSeed.
179
+ -- - The indexing scheme used is different for collectibles that are inside of a Treasure Room or
180
+ -- Boss Room, in order to handle the case of the player seeing the same collectible again in a
181
+ -- post-Ascent Treasure Room or Boss Room. A 5-tuple of stage, stage type, grid index, SubType,
182
+ -- and InitSeed is used in this case. (Using the room list index or the room grid index is not
183
+ -- suitable for this purpose, since both of these values can change in the post-Ascent rooms.)
184
+ -- Even though Treasure Rooms and Boss Rooms are grouped together in this scheme, there probably
185
+ -- will not be collectibles with the same grid index, SubType, and InitSeed.
173
186
  function ____exports.getCollectibleIndex(self, collectible)
174
187
  if not isCollectible(nil, collectible) then
175
188
  local entityID = getEntityID(nil, collectible)
@@ -182,7 +195,7 @@ function ____exports.getCollectibleIndex(self, collectible)
182
195
  local roomType = room:GetType()
183
196
  local gridIndex = room:GetGridIndex(collectible.Position)
184
197
  local roomListIndex = getRoomListIndex(nil)
185
- if roomType == RoomType.TREASURE then
198
+ if roomType == RoomType.TREASURE or roomType == RoomType.BOSS then
186
199
  return (((((((tostring(stage) .. ",") .. tostring(stageType)) .. ",") .. tostring(gridIndex)) .. ",") .. tostring(collectible.SubType)) .. ",") .. tostring(collectible.InitSeed)
187
200
  end
188
201
  return (((((tostring(roomListIndex) .. ",") .. tostring(gridIndex)) .. ",") .. tostring(collectible.SubType)) .. ",") .. tostring(collectible.InitSeed)
@@ -1,11 +1,9 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Set = ____lualib.Set
3
3
  local __TS__New = ____lualib.__TS__New
4
- local __TS__InstanceOf = ____lualib.__TS__InstanceOf
5
4
  local Map = ____lualib.Map
6
- local WeakMap = ____lualib.WeakMap
7
- local WeakSet = ____lualib.WeakSet
8
5
  local __TS__Iterator = ____lualib.__TS__Iterator
6
+ local __TS__ArraySort = ____lualib.__TS__ArraySort
9
7
  local __TS__ArraySome = ____lualib.__TS__ArraySome
10
8
  local ____exports = {}
11
9
  local deepCopyTable, deepCopyDefaultMap, deepCopyMap, deepCopySet, deepCopyTSTLClass, deepCopyArray, deepCopyNormalLuaTable, getCopiedEntries, checkMetatable, deepCopyUserdata, COPYABLE_ISAAC_API_CLASS_TYPES_SET
@@ -26,19 +24,25 @@ local isArray = ____array.isArray
26
24
  local ____enums = require("functions.enums")
27
25
  local getEnumValues = ____enums.getEnumValues
28
26
  local ____isaacAPIClass = require("functions.isaacAPIClass")
29
- local getIsaacAPIClassType = ____isaacAPIClass.getIsaacAPIClassType
27
+ local getIsaacAPIClassName = ____isaacAPIClass.getIsaacAPIClassName
30
28
  local ____log = require("functions.log")
31
29
  local log = ____log.log
30
+ local logTable = ____log.logTable
32
31
  local ____serialization = require("functions.serialization")
33
32
  local copyIsaacAPIClass = ____serialization.copyIsaacAPIClass
34
33
  local deserializeIsaacAPIClass = ____serialization.deserializeIsaacAPIClass
35
34
  local isSerializedIsaacAPIClass = ____serialization.isSerializedIsaacAPIClass
36
35
  local ____tstlClass = require("functions.tstlClass")
36
+ local getTSTLClassName = ____tstlClass.getTSTLClassName
37
+ local isDefaultMap = ____tstlClass.isDefaultMap
38
+ local isTSTLMap = ____tstlClass.isTSTLMap
39
+ local isTSTLSet = ____tstlClass.isTSTLSet
37
40
  local isUserDefinedTSTLClass = ____tstlClass.isUserDefinedTSTLClass
38
41
  local newTSTLClass = ____tstlClass.newTSTLClass
39
42
  local ____utils = require("functions.utils")
40
43
  local ensureAllCases = ____utils.ensureAllCases
41
44
  local getTraversalDescription = ____utils.getTraversalDescription
45
+ local twoDimensionalSort = ____utils.twoDimensionalSort
42
46
  --- `deepCopy` is a semi-generic deep cloner. It will recursively copy all of the values so that none
43
47
  -- of the nested references remain.
44
48
  --
@@ -120,19 +124,20 @@ function ____exports.deepCopy(self, value, serializationType, traversalDescripti
120
124
  until true
121
125
  end
122
126
  function deepCopyTable(self, ____table, serializationType, traversalDescription)
123
- if __TS__InstanceOf(____table, DefaultMap) or ____table[SerializationBrand.DEFAULT_MAP] ~= nil then
127
+ if isDefaultMap(nil, ____table) or ____table[SerializationBrand.DEFAULT_MAP] ~= nil then
124
128
  return deepCopyDefaultMap(nil, ____table, serializationType, traversalDescription)
125
129
  end
126
- if __TS__InstanceOf(____table, Map) or ____table[SerializationBrand.MAP] ~= nil then
130
+ if isTSTLMap(nil, ____table) or ____table[SerializationBrand.MAP] ~= nil then
127
131
  return deepCopyMap(nil, ____table, serializationType, traversalDescription)
128
132
  end
129
- if __TS__InstanceOf(____table, Set) or ____table[SerializationBrand.SET] ~= nil then
133
+ if isTSTLSet(nil, ____table) or ____table[SerializationBrand.SET] ~= nil then
130
134
  return deepCopySet(nil, ____table, serializationType, traversalDescription)
131
135
  end
132
- if __TS__InstanceOf(____table, WeakMap) then
136
+ local className = getTSTLClassName(nil, ____table)
137
+ if className == "WeakMap" then
133
138
  error("The deep copy function does not support copying the \"WeakMap\" class for: " .. traversalDescription)
134
139
  end
135
- if __TS__InstanceOf(____table, WeakSet) then
140
+ if className == "WeakSet" then
136
141
  error("The deep copy function does not support copying the \"WeakSet\" class for: " .. traversalDescription)
137
142
  end
138
143
  if isUserDefinedTSTLClass(nil, ____table) then
@@ -148,13 +153,13 @@ function deepCopyTable(self, ____table, serializationType, traversalDescription)
148
153
  return deepCopyNormalLuaTable(nil, ____table, serializationType, traversalDescription)
149
154
  end
150
155
  function deepCopyDefaultMap(self, defaultMap, serializationType, traversalDescription)
151
- local ____temp_0
152
- if __TS__InstanceOf(defaultMap, DefaultMap) then
153
- ____temp_0 = defaultMap:getConstructorArg()
156
+ local ____isDefaultMap_result_0
157
+ if isDefaultMap(nil, defaultMap) then
158
+ ____isDefaultMap_result_0 = defaultMap:getConstructorArg()
154
159
  else
155
- ____temp_0 = nil
160
+ ____isDefaultMap_result_0 = nil
156
161
  end
157
- local constructorArg = ____temp_0
162
+ local constructorArg = ____isDefaultMap_result_0
158
163
  local newDefaultMap
159
164
  repeat
160
165
  local ____switch23 = serializationType
@@ -180,7 +185,7 @@ function deepCopyDefaultMap(self, defaultMap, serializationType, traversalDescri
180
185
  ____cond23 = ____cond23 or ____switch23 == SerializationType.DESERIALIZE
181
186
  if ____cond23 then
182
187
  do
183
- if __TS__InstanceOf(defaultMap, DefaultMap) then
188
+ if isDefaultMap(nil, defaultMap) then
184
189
  error(("The deep copy function failed to deserialize a default map of \"" .. traversalDescription) .. "\", since it was not a Lua table.")
185
190
  end
186
191
  local defaultMapValue = defaultMap[SerializationBrand.DEFAULT_MAP_VALUE]
@@ -201,7 +206,7 @@ function deepCopyDefaultMap(self, defaultMap, serializationType, traversalDescri
201
206
  local entries = ____getCopiedEntries_result_1.entries
202
207
  local convertedNumberKeysToStrings = ____getCopiedEntries_result_1.convertedNumberKeysToStrings
203
208
  if convertedNumberKeysToStrings then
204
- if __TS__InstanceOf(newDefaultMap, DefaultMap) then
209
+ if isDefaultMap(nil, newDefaultMap) then
205
210
  newDefaultMap:set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "")
206
211
  else
207
212
  newDefaultMap[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
@@ -210,7 +215,7 @@ function deepCopyDefaultMap(self, defaultMap, serializationType, traversalDescri
210
215
  for ____, ____value in ipairs(entries) do
211
216
  local key = ____value[1]
212
217
  local value = ____value[2]
213
- if __TS__InstanceOf(newDefaultMap, DefaultMap) then
218
+ if isDefaultMap(nil, newDefaultMap) then
214
219
  newDefaultMap:set(key, value)
215
220
  else
216
221
  newDefaultMap[key] = value
@@ -230,7 +235,7 @@ function deepCopyMap(self, map, serializationType, traversalDescription)
230
235
  local entries = ____getCopiedEntries_result_2.entries
231
236
  local convertedNumberKeysToStrings = ____getCopiedEntries_result_2.convertedNumberKeysToStrings
232
237
  if convertedNumberKeysToStrings then
233
- if __TS__InstanceOf(newMap, Map) then
238
+ if isTSTLMap(nil, newMap) then
234
239
  newMap:set(SerializationBrand.OBJECT_WITH_NUMBER_KEYS, "")
235
240
  else
236
241
  newMap[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
@@ -239,7 +244,7 @@ function deepCopyMap(self, map, serializationType, traversalDescription)
239
244
  for ____, ____value in ipairs(entries) do
240
245
  local key = ____value[1]
241
246
  local value = ____value[2]
242
- if __TS__InstanceOf(newMap, Map) then
247
+ if isTSTLMap(nil, newMap) then
243
248
  newMap:set(key, value)
244
249
  else
245
250
  newMap[key] = value
@@ -259,7 +264,7 @@ function deepCopySet(self, set, serializationType, traversalDescription)
259
264
  local entries = ____getCopiedEntries_result_3.entries
260
265
  local convertedNumberKeysToStrings = ____getCopiedEntries_result_3.convertedNumberKeysToStrings
261
266
  if convertedNumberKeysToStrings then
262
- if __TS__InstanceOf(newSet, Set) then
267
+ if isTSTLSet(nil, newSet) then
263
268
  error("The deep copy function cannot convert number keys to strings for a Set.")
264
269
  else
265
270
  newSet[SerializationBrand.OBJECT_WITH_NUMBER_KEYS] = ""
@@ -267,7 +272,7 @@ function deepCopySet(self, set, serializationType, traversalDescription)
267
272
  end
268
273
  for ____, ____value in ipairs(entries) do
269
274
  local key = ____value[1]
270
- if __TS__InstanceOf(newSet, Set) then
275
+ if isTSTLSet(nil, newSet) then
271
276
  newSet:add(key)
272
277
  else
273
278
  newSet[key] = ""
@@ -320,7 +325,7 @@ function deepCopyNormalLuaTable(self, ____table, serializationType, traversalDes
320
325
  end
321
326
  function getCopiedEntries(self, object, serializationType, traversalDescription)
322
327
  local entries = {}
323
- if __TS__InstanceOf(object, Map) or __TS__InstanceOf(object, Set) then
328
+ if isTSTLMap(nil, object) or isTSTLSet(nil, object) or isDefaultMap(nil, object) then
324
329
  for ____, ____value in __TS__Iterator(object:entries()) do
325
330
  local key = ____value[1]
326
331
  local value = ____value[2]
@@ -331,6 +336,10 @@ function getCopiedEntries(self, object, serializationType, traversalDescription)
331
336
  entries[#entries + 1] = {key, value}
332
337
  end
333
338
  end
339
+ if SAVE_DATA_MANAGER_DEBUG then
340
+ logTable(entries)
341
+ __TS__ArraySort(entries, twoDimensionalSort)
342
+ end
334
343
  local hasNumberKeys = __TS__ArraySome(
335
344
  entries,
336
345
  function(____, ____bindingPattern0)
@@ -346,14 +355,14 @@ function getCopiedEntries(self, object, serializationType, traversalDescription)
346
355
  local value = ____value[2]
347
356
  do
348
357
  if isSerializationBrand(nil, key) then
349
- goto __continue78
358
+ goto __continue79
350
359
  end
351
360
  traversalDescription = getTraversalDescription(nil, key, traversalDescription)
352
361
  local newValue = ____exports.deepCopy(nil, value, serializationType, traversalDescription)
353
362
  local keyToUse = convertNumberKeysToStrings and tostring(key) or key
354
363
  copiedEntries[#copiedEntries + 1] = {keyToUse, newValue}
355
364
  end
356
- ::__continue78::
365
+ ::__continue79::
357
366
  end
358
367
  return {entries = copiedEntries, convertedNumberKeysToStrings = convertNumberKeysToStrings}
359
368
  end
@@ -363,10 +372,10 @@ function checkMetatable(self, ____table, traversalDescription)
363
372
  return
364
373
  end
365
374
  local tableDescription = traversalDescription == "" and "the table to copy" or ("\"" .. traversalDescription) .. "\""
366
- error(("The deepCopy function detected that \"" .. tableDescription) .. "\" has a metatable. Copying tables with metatables is not supported, unless they are explicitly handled by the save data manager. (e.g. TypeScriptToLua Maps, TypeScriptToLua Sets, etc.)")
375
+ error(("The deepCopy function detected that " .. tableDescription) .. " has a metatable. Copying tables with metatables is not supported, unless they are explicitly handled by the save data manager. (e.g. TypeScriptToLua Maps, TypeScriptToLua Sets, etc.)")
367
376
  end
368
377
  function deepCopyUserdata(self, value, serializationType, traversalDescription)
369
- local classType = getIsaacAPIClassType(nil, value)
378
+ local classType = getIsaacAPIClassName(nil, value)
370
379
  if classType == nil then
371
380
  error("The deep copy function was not able to derive the Isaac API class type for: " .. traversalDescription)
372
381
  end
@@ -1,7 +1,6 @@
1
1
  local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
3
  local __TS__New = ____lualib.__TS__New
4
- local __TS__InstanceOf = ____lualib.__TS__InstanceOf
5
4
  local Set = ____lualib.Set
6
5
  local ____exports = {}
7
6
  local copiedObjectIsTable, copiedObjectHasKeyAndValueString, copiedTableHasKeyAndValueNumber, copiedTableDoesNotCoerceTypes, copiedObjectHasNoReferencesForPrimitivesForward, copiedObjectHasNoReferencesForPrimitivesBackward, copiedObjectHasNoReferencesForArray, copiedObjectHasChildObject, copiedMapIsMap, copiedMapHasValue, copiedSetIsSet, copiedSetHasValue, copiedMapHasChildMap, copiedDefaultMapHasChildDefaultMap, copiedDefaultMapHasBrand
@@ -17,6 +16,10 @@ local ____deepCopy = require("functions.deepCopy")
17
16
  local deepCopy = ____deepCopy.deepCopy
18
17
  local ____log = require("functions.log")
19
18
  local log = ____log.log
19
+ local ____tstlClass = require("functions.tstlClass")
20
+ local isDefaultMap = ____tstlClass.isDefaultMap
21
+ local isTSTLMap = ____tstlClass.isTSTLMap
22
+ local isTSTLSet = ____tstlClass.isTSTLSet
20
23
  function copiedObjectIsTable(self)
21
24
  local oldObject = {abc = "def"}
22
25
  local newObject = deepCopy(nil, oldObject)
@@ -173,7 +176,7 @@ function copiedMapIsMap(self)
173
176
  if newMapType ~= "table" then
174
177
  error("The copied Map was not a table.")
175
178
  end
176
- if not __TS__InstanceOf(newMap, Map) then
179
+ if not isTSTLMap(nil, newMap) then
177
180
  error("The copied Map was not a Map.")
178
181
  end
179
182
  end
@@ -202,7 +205,7 @@ function copiedSetIsSet(self)
202
205
  if newSetType ~= "table" then
203
206
  error("The copied Set was not a table.")
204
207
  end
205
- if not __TS__InstanceOf(newSet, Set) then
208
+ if not isTSTLSet(nil, newSet) then
206
209
  error("The copied Set was not a Map.")
207
210
  end
208
211
  end
@@ -235,7 +238,7 @@ function copiedMapHasChildMap(self)
235
238
  if newChildMapType ~= "table" then
236
239
  error("The copied child Map had a type of: " .. newChildMapType)
237
240
  end
238
- if not __TS__InstanceOf(newChildMap, Map) then
241
+ if not isTSTLMap(nil, newChildMap) then
239
242
  error("The copied child Map was not a Map.")
240
243
  end
241
244
  local value = newChildMap:get(childMapKey)
@@ -269,7 +272,7 @@ function copiedDefaultMapHasChildDefaultMap(self)
269
272
  if newChildMapType ~= "table" then
270
273
  error("The copied child DefaultMap had a type of: " .. newChildMapType)
271
274
  end
272
- if not __TS__InstanceOf(newChildMap, DefaultMap) then
275
+ if not isDefaultMap(nil, newChildMap) then
273
276
  error("The copied child DefaultMap was not a DefaultMap.")
274
277
  end
275
278
  local newChildMapValue1 = newChildMap:get(childMapKey1)
@@ -1,4 +1,12 @@
1
1
  import { Direction } from "isaac-typescript-definitions";
2
+ /**
3
+ * Helper function to convert the degrees of an angle to the `Direction` enum.
4
+ *
5
+ * Note that this function considers 0 degrees to be pointing to the right, which is unusual because
6
+ * 0 normally corresponds to up. (This corresponds to how the `Vector.GetAngleDegrees` method
7
+ * works.)
8
+ */
9
+ export declare function angleToDirection(angleDegrees: int): Direction;
2
10
  export declare function directionToDegrees(direction: Direction): int;
3
11
  export declare function directionToVector(direction: Direction): Vector;
4
12
  export declare function getDirectionName(direction: Direction): string | undefined;
@@ -1,10 +1,37 @@
1
1
  local ____exports = {}
2
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
+ local Direction = ____isaac_2Dtypescript_2Ddefinitions.Direction
2
4
  local ____directionNames = require("objects.directionNames")
3
5
  local DIRECTION_NAMES = ____directionNames.DIRECTION_NAMES
4
6
  local ____directionToDegrees = require("objects.directionToDegrees")
5
7
  local DIRECTION_TO_DEGREES = ____directionToDegrees.DIRECTION_TO_DEGREES
6
8
  local ____directionToVector = require("objects.directionToVector")
7
9
  local DIRECTION_TO_VECTOR = ____directionToVector.DIRECTION_TO_VECTOR
10
+ --- Helper function to convert the degrees of an angle to the `Direction` enum.
11
+ --
12
+ -- Note that this function considers 0 degrees to be pointing to the right, which is unusual because
13
+ -- 0 normally corresponds to up. (This corresponds to how the `Vector.GetAngleDegrees` method
14
+ -- works.)
15
+ function ____exports.angleToDirection(self, angleDegrees)
16
+ local positiveDegrees = angleDegrees
17
+ while positiveDegrees < 0 do
18
+ positiveDegrees = positiveDegrees + 360
19
+ end
20
+ local normalizedDegrees = positiveDegrees % 360
21
+ if normalizedDegrees < 45 then
22
+ return Direction.RIGHT
23
+ end
24
+ if normalizedDegrees < 135 then
25
+ return Direction.DOWN
26
+ end
27
+ if normalizedDegrees < 225 then
28
+ return Direction.LEFT
29
+ end
30
+ if normalizedDegrees < 315 then
31
+ return Direction.UP
32
+ end
33
+ return Direction.RIGHT
34
+ end
8
35
  function ____exports.directionToDegrees(self, direction)
9
36
  return DIRECTION_TO_DEGREES[direction]
10
37
  end
@@ -45,6 +45,7 @@ export declare function getDoors(...roomTypes: RoomType[]): GridEntityDoor[];
45
45
  * that match any of the N room grid indexes.
46
46
  */
47
47
  export declare function getDoorsToRoomIndex(...roomGridIndex: int[]): GridEntityDoor[];
48
+ export declare function getOppositeDoorSlot(doorSlot: DoorSlot): DoorSlot | undefined;
48
49
  export declare function getRepentanceDoor(): GridEntityDoor | undefined;
49
50
  /** Helper function to find unused door slots in the room that can be used to make custom doors. */
50
51
  export declare function getUnusedDoorSlots(): DoorSlot[];
@@ -18,6 +18,8 @@ local DEFAULT_DOOR_SLOT = ____doorSlotFlagToDoorSlot.DEFAULT_DOOR_SLOT
18
18
  local DOOR_SLOT_FLAG_TO_DOOR_SLOT = ____doorSlotFlagToDoorSlot.DOOR_SLOT_FLAG_TO_DOOR_SLOT
19
19
  local ____doorSlotToDirection = require("objects.doorSlotToDirection")
20
20
  local DOOR_SLOT_TO_DIRECTION = ____doorSlotToDirection.DOOR_SLOT_TO_DIRECTION
21
+ local ____oppositeDoorSlots = require("objects.oppositeDoorSlots")
22
+ local OPPOSITE_DOOR_SLOTS = ____oppositeDoorSlots.OPPOSITE_DOOR_SLOTS
21
23
  local ____roomShapeToDoorSlots = require("objects.roomShapeToDoorSlots")
22
24
  local ROOM_SHAPE_TO_DOOR_SLOTS = ____roomShapeToDoorSlots.ROOM_SHAPE_TO_DOOR_SLOTS
23
25
  local ____direction = require("functions.direction")
@@ -158,6 +160,9 @@ function ____exports.getDoorsToRoomIndex(self, ...)
158
160
  function(____, door) return roomGridIndexesSet:has(door.TargetRoomIndex) end
159
161
  )
160
162
  end
163
+ function ____exports.getOppositeDoorSlot(self, doorSlot)
164
+ return OPPOSITE_DOOR_SLOTS[doorSlot]
165
+ end
161
166
  function ____exports.getRepentanceDoor(self)
162
167
  local doors = ____exports.getDoors(nil)
163
168
  return __TS__ArrayFind(
@@ -96,17 +96,17 @@ export declare function parseEntityTypeVariantString(entityTypeVariantString: st
96
96
  * @param entityVariant Optional. The variant to match. Default is -1. -1 matches every variant.
97
97
  * @param entitySubType Optional. The sub-type to match. Default is -1. -1 matches every sub-type.
98
98
  * @param cap Optional. If specified, will only remove the given amount of collectibles.
99
- * @returns True if one or more entities were removed, false otherwise.
99
+ * @returns An array of the entities that were removed.
100
100
  */
101
- export declare function removeAllMatchingEntities(entityType: EntityType, entityVariant?: number, entitySubType?: number, cap?: int | undefined): boolean;
101
+ export declare function removeAllMatchingEntities(entityType: EntityType, entityVariant?: number, entitySubType?: number, cap?: int | undefined): Entity[];
102
102
  /**
103
103
  * Helper function to remove all of the entities in the supplied array.
104
104
  *
105
105
  * @param entities The array of entities to remove.
106
106
  * @param cap Optional. If specified, will only remove the given amount of entities.
107
- * @returns True if one or more entities were removed, false otherwise.
107
+ * @returns An array of the entities that were removed.
108
108
  */
109
- export declare function removeEntities(entities: Entity[], cap?: int): boolean;
109
+ export declare function removeEntities<T extends AnyEntity>(entities: T[], cap?: int): T[];
110
110
  /**
111
111
  * Helper function to reroll an enemy. Use this instead of the vanilla "Game.RerollEnemy" function
112
112
  * if you want the rerolled enemy to be returned.
@@ -18,20 +18,20 @@ local newRNG = ____rng.newRNG
18
18
  --
19
19
  -- @param entities The array of entities to remove.
20
20
  -- @param cap Optional. If specified, will only remove the given amount of entities.
21
- -- @returns True if one or more entities were removed, false otherwise.
21
+ -- @returns An array of the entities that were removed.
22
22
  function ____exports.removeEntities(self, entities, cap)
23
23
  if #entities == 0 then
24
- return false
24
+ return {}
25
25
  end
26
- local numEntitiesRemoved = 0
26
+ local entitiesRemoved = {}
27
27
  for ____, entity in ipairs(entities) do
28
28
  entity:Remove()
29
- numEntitiesRemoved = numEntitiesRemoved + 1
30
- if cap ~= nil and numEntitiesRemoved >= cap then
31
- return true
29
+ entitiesRemoved[#entitiesRemoved + 1] = entity
30
+ if cap ~= nil and #entitiesRemoved >= cap then
31
+ return entitiesRemoved
32
32
  end
33
33
  end
34
- return true
34
+ return entitiesRemoved
35
35
  end
36
36
  --- Helper function to count the number of entities in room. Use this over the vanilla
37
37
  -- `Isaac.CountEntities` method to avoid having to specify a spawner and to handle ignoring charmed
@@ -217,7 +217,7 @@ end
217
217
  -- @param entityVariant Optional. The variant to match. Default is -1. -1 matches every variant.
218
218
  -- @param entitySubType Optional. The sub-type to match. Default is -1. -1 matches every sub-type.
219
219
  -- @param cap Optional. If specified, will only remove the given amount of collectibles.
220
- -- @returns True if one or more entities were removed, false otherwise.
220
+ -- @returns An array of the entities that were removed.
221
221
  function ____exports.removeAllMatchingEntities(self, entityType, entityVariant, entitySubType, cap)
222
222
  if entityVariant == nil then
223
223
  entityVariant = -1