isaacscript-common 3.0.0 → 3.1.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 (76) hide show
  1. package/cachedClasses.d.ts +6 -4
  2. package/cachedClasses.lua +4 -4
  3. package/callbacks/postSlotDestroyed.d.ts +1 -0
  4. package/callbacks/postSlotDestroyed.lua +66 -0
  5. package/callbacks/postSlotRender.lua +3 -21
  6. package/callbacks/subscriptions/postCustomRevive.d.ts +1 -0
  7. package/callbacks/subscriptions/postDoorRender.d.ts +1 -0
  8. package/callbacks/subscriptions/postDoorUpdate.d.ts +1 -0
  9. package/callbacks/subscriptions/postPickupCollect.d.ts +1 -0
  10. package/callbacks/subscriptions/postPickupStateChanged.d.ts +1 -0
  11. package/callbacks/subscriptions/postPitRender.d.ts +1 -0
  12. package/callbacks/subscriptions/postPitUpdate.d.ts +1 -0
  13. package/callbacks/subscriptions/postPoopRender.d.ts +1 -0
  14. package/callbacks/subscriptions/postPoopUpdate.d.ts +1 -0
  15. package/callbacks/subscriptions/postPressurePlateRender.d.ts +1 -0
  16. package/callbacks/subscriptions/postPressurePlateUpdate.d.ts +1 -0
  17. package/callbacks/subscriptions/postRockRender.d.ts +1 -0
  18. package/callbacks/subscriptions/postRockUpdate.d.ts +1 -0
  19. package/callbacks/subscriptions/postSpikesRender.d.ts +1 -0
  20. package/callbacks/subscriptions/postSpikesUpdate.d.ts +1 -0
  21. package/callbacks/subscriptions/postTNTRender.d.ts +1 -0
  22. package/callbacks/subscriptions/postTNTUpdate.d.ts +1 -0
  23. package/features/debugDisplay/exports.d.ts +17 -0
  24. package/features/debugDisplay/v.d.ts +17 -0
  25. package/features/deployJSONRoom.d.ts +1 -0
  26. package/features/saveDataManager/load.lua +12 -8
  27. package/features/saveDataManager/main.lua +10 -3
  28. package/features/saveDataManager/merge.lua +33 -21
  29. package/features/saveDataManager/save.lua +12 -7
  30. package/functions/array.d.ts +2 -0
  31. package/functions/chargeBar.d.ts +1 -0
  32. package/functions/collectibles.d.ts +6 -1
  33. package/functions/collectibles.lua +16 -3
  34. package/functions/deepCopy.lua +35 -26
  35. package/functions/deepCopyTests.lua +8 -5
  36. package/functions/direction.d.ts +1 -0
  37. package/functions/direction.lua +22 -0
  38. package/functions/doors.d.ts +1 -0
  39. package/functions/doors.lua +5 -0
  40. package/functions/entity.d.ts +4 -4
  41. package/functions/entity.lua +8 -8
  42. package/functions/entitySpecific.d.ts +20 -20
  43. package/functions/entitySpecific.lua +10 -10
  44. package/functions/enums.d.ts +2 -0
  45. package/functions/globals.lua +2 -10
  46. package/functions/gridEntitySpecific.d.ts +5 -0
  47. package/functions/isaacAPIClass.d.ts +4 -4
  48. package/functions/isaacAPIClass.lua +6 -6
  49. package/functions/jsonRoom.d.ts +2 -0
  50. package/functions/log.lua +3 -3
  51. package/functions/pickups.d.ts +9 -9
  52. package/functions/playerHealth.d.ts +1 -0
  53. package/functions/playerIndex.d.ts +2 -0
  54. package/functions/positionVelocity.d.ts +3 -0
  55. package/functions/random.d.ts +2 -0
  56. package/functions/revive.d.ts +2 -0
  57. package/functions/rng.d.ts +1 -0
  58. package/functions/serialization.lua +2 -2
  59. package/functions/set.d.ts +1 -0
  60. package/functions/sprite.d.ts +2 -0
  61. package/functions/table.d.ts +12 -0
  62. package/functions/table.lua +34 -0
  63. package/functions/tears.d.ts +1 -0
  64. package/functions/tstlClass.d.ts +34 -0
  65. package/functions/tstlClass.lua +54 -9
  66. package/functions/ui.d.ts +2 -0
  67. package/functions/utils.d.ts +15 -0
  68. package/functions/utils.lua +20 -0
  69. package/functions/vector.lua +4 -16
  70. package/initCustomCallbacks.lua +3 -0
  71. package/interfaces/ChargeBarSprites.d.ts +1 -0
  72. package/interfaces/private/TSTLClassMetatable.d.ts +2 -0
  73. package/objects/oppositeDoorSlots.d.ts +4 -0
  74. package/objects/oppositeDoorSlots.lua +15 -0
  75. package/package.json +1 -1
  76. package/types/AnyEntity.d.ts +10 -0
@@ -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
  /**
@@ -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
@@ -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,5 @@
1
1
  import { Direction } from "isaac-typescript-definitions";
2
+ export declare function angleToDirection(angleDegrees: int): Direction;
2
3
  export declare function directionToDegrees(direction: Direction): int;
3
4
  export declare function directionToVector(direction: Direction): Vector;
4
5
  export declare function getDirectionName(direction: Direction): string | undefined;
@@ -1,10 +1,32 @@
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
+ function ____exports.angleToDirection(self, angleDegrees)
11
+ local positiveDegrees = angleDegrees
12
+ while positiveDegrees < 0 do
13
+ positiveDegrees = positiveDegrees + 360
14
+ end
15
+ local normalizedDegrees = positiveDegrees % 360
16
+ if normalizedDegrees < 45 then
17
+ return Direction.UP
18
+ end
19
+ if normalizedDegrees < 135 then
20
+ return Direction.RIGHT
21
+ end
22
+ if normalizedDegrees < 225 then
23
+ return Direction.DOWN
24
+ end
25
+ if normalizedDegrees < 315 then
26
+ return Direction.RIGHT
27
+ end
28
+ return Direction.UP
29
+ end
8
30
  function ____exports.directionToDegrees(self, direction)
9
31
  return DIRECTION_TO_DEGREES[direction]
10
32
  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
@@ -138,18 +138,18 @@ export declare function npcFireProjectiles(npc: EntityNPC, position: Vector, vel
138
138
  * @param bombVariant Optional. If specified, will only remove bombs that match this variant.
139
139
  * @param subType Optional. If specified, will only remove bombs that match this sub-type.
140
140
  * @param cap Optional. If specified, will only remove the given amount of bombs.
141
- * @returns True if one or more bombs were removed, false otherwise.
141
+ * @returns An array of the bombs that were removed.
142
142
  */
143
- export declare function removeAllBombs(bombVariant?: BombVariant, subType?: int, cap?: int): boolean;
143
+ export declare function removeAllBombs(bombVariant?: BombVariant, subType?: int, cap?: int): EntityBomb[];
144
144
  /**
145
145
  * Helper function to remove all of the effects in the room.
146
146
  *
147
147
  * @param effectVariant Optional. If specified, will only remove effects that match this variant.
148
148
  * @param subType Optional. If specified, will only remove effects that match this sub-type.
149
149
  * @param cap Optional. If specified, will only remove the given amount of effects.
150
- * @returns True if one or more effects were removed, false otherwise.
150
+ * @returns An array of the effects that were removed.
151
151
  */
152
- export declare function removeAllEffects(effectVariant?: EffectVariant, subType?: int, cap?: int): boolean;
152
+ export declare function removeAllEffects(effectVariant?: EffectVariant, subType?: int, cap?: int): EntityEffect[];
153
153
  /**
154
154
  * Helper function to remove all of the familiars in the room.
155
155
  *
@@ -157,43 +157,43 @@ export declare function removeAllEffects(effectVariant?: EffectVariant, subType?
157
157
  * variant.
158
158
  * @param subType Optional. If specified, will only remove familiars that match this sub-type.
159
159
  * @param cap Optional. If specified, will only remove the given amount of familiars.
160
- * @returns True if one or more familiars were removed, false otherwise.
160
+ * @returns An array of the familiars that were removed.
161
161
  */
162
- export declare function removeAllFamiliars(familiarVariant?: FamiliarVariant, subType?: int, cap?: int): boolean;
162
+ export declare function removeAllFamiliars(familiarVariant?: FamiliarVariant, subType?: int, cap?: int): EntityFamiliar[];
163
163
  /**
164
164
  * Helper function to remove all of the `EntityType.KNIFE` in the room.
165
165
  *
166
166
  * @param knifeVariant Optional. If specified, will only remove knives that match this variant.
167
167
  * @param subType Optional. If specified, will only remove knives that match this sub-type.
168
168
  * @param cap Optional. If specified, will only remove the given amount of knives.
169
- * @returns True if one or more knives were removed, false otherwise.
169
+ * @returns An array of the knives that were removed.
170
170
  */
171
- export declare function removeAllKnives(knifeVariant?: KnifeVariant, subType?: int, cap?: int): boolean;
171
+ export declare function removeAllKnives(knifeVariant?: KnifeVariant, subType?: int, cap?: int): EntityKnife[];
172
172
  /**
173
173
  * Helper function to remove all of the `EntityType.LASER` in the room.
174
174
  *
175
175
  * @param laserVariant Optional. If specified, will only remove lasers that match this variant.
176
176
  * @param subType Optional. If specified, will only remove lasers that match this sub-type.
177
177
  * @param cap Optional. If specified, will only remove the given amount of lasers.
178
- * @returns True if one or more lasers were removed, false otherwise.
178
+ * @returns An array of the lasers that were removed.
179
179
  */
180
- export declare function removeAllLasers(laserVariant?: LaserVariant, subType?: int, cap?: int): boolean;
180
+ export declare function removeAllLasers(laserVariant?: LaserVariant, subType?: int, cap?: int): EntityLaser[];
181
181
  /**
182
182
  * Helper function to remove all NPCs in the room.
183
183
  *
184
184
  * @param cap Optional. If specified, will only remove the given amount of NPCs.
185
- * @returns True if one or more NPCs were removed, false otherwise.
185
+ * @returns An array of the NPCs that were removed.
186
186
  */
187
- export declare function removeAllNPCs(cap?: int): boolean;
187
+ export declare function removeAllNPCs(cap?: int): EntityNPC[];
188
188
  /**
189
189
  * Helper function to remove all of the pickups in the room.
190
190
  *
191
191
  * @param pickupVariant Optional. If specified, will only remove pickups that match this variant.
192
192
  * @param subType Optional. If specified, will only remove pickups that match this sub-type.
193
193
  * @param cap Optional. If specified, will only remove the given amount of pickups.
194
- * @returns True if one or more pickups were removed, false otherwise.
194
+ * @returns An array of the pickups that were removed.
195
195
  */
196
- export declare function removeAllPickups(pickupVariant?: PickupVariant, subType?: int, cap?: int): boolean;
196
+ export declare function removeAllPickups(pickupVariant?: PickupVariant, subType?: int, cap?: int): EntityPickup[];
197
197
  /**
198
198
  * Helper function to remove all of the `EntityType.PROJECTILE` in the room.
199
199
  *
@@ -201,27 +201,27 @@ export declare function removeAllPickups(pickupVariant?: PickupVariant, subType?
201
201
  * variant.
202
202
  * @param subType Optional. If specified, will only remove projectiles that match this sub-type.
203
203
  * @param cap Optional. If specified, will only remove the given amount of projectiles.
204
- * @returns True if one or more projectiles were removed, false otherwise.
204
+ * @returns An array of the projectiles that were removed.
205
205
  */
206
- export declare function removeAllProjectiles(projectileVariant?: ProjectileVariant, subType?: int, cap?: int): boolean;
206
+ export declare function removeAllProjectiles(projectileVariant?: ProjectileVariant, subType?: int, cap?: int): EntityProjectile[];
207
207
  /**
208
208
  * Helper function to remove all of the `EntityType.SLOT` in the room.
209
209
  *
210
210
  * @param slotVariant Optional. If specified, will only remove slots that match this variant.
211
211
  * @param subType Optional. If specified, will only remove slots that match this sub-type.
212
212
  * @param cap Optional. If specified, will only remove the given amount of slots.
213
- * @returns True if one or more slots were removed, false otherwise.
213
+ * @returns An array of the slots that were removed.
214
214
  */
215
- export declare function removeAllSlots(slotVariant?: SlotVariant, subType?: int, cap?: int): boolean;
215
+ export declare function removeAllSlots(slotVariant?: SlotVariant, subType?: int, cap?: int): Entity[];
216
216
  /**
217
217
  * Helper function to remove all of the `EntityType.TEAR` in the room.
218
218
  *
219
219
  * @param tearVariant Optional. If specified, will only remove tears that match this variant.
220
220
  * @param subType Optional. If specified, will only remove tears that match this sub-type.
221
221
  * @param cap Optional. If specified, will only remove the given amount of tears.
222
- * @returns True if one or more tears were removed, false otherwise.
222
+ * @returns An array of the tears that were removed.
223
223
  */
224
- export declare function removeAllTears(tearVariant?: TearVariant, subType?: int, cap?: int): boolean;
224
+ export declare function removeAllTears(tearVariant?: TearVariant, subType?: int, cap?: int): EntityTear[];
225
225
  /** Helper function to spawn a `EntityType.BOMB` (4). */
226
226
  export declare function spawnBomb(bombVariant: BombVariant, subType: int, position: Vector, velocity?: Readonly<Vector>, spawner?: Entity | undefined, seed?: Seed | undefined): EntityBomb;
227
227
  /** Helper function to spawn a `EntityType.BOMB` (4) with a specific seed. */
@@ -288,7 +288,7 @@ end
288
288
  -- @param bombVariant Optional. If specified, will only remove bombs that match this variant.
289
289
  -- @param subType Optional. If specified, will only remove bombs that match this sub-type.
290
290
  -- @param cap Optional. If specified, will only remove the given amount of bombs.
291
- -- @returns True if one or more bombs were removed, false otherwise.
291
+ -- @returns An array of the bombs that were removed.
292
292
  function ____exports.removeAllBombs(self, bombVariant, subType, cap)
293
293
  local bombs = ____exports.getBombs(nil, bombVariant, subType)
294
294
  return removeEntities(nil, bombs, cap)
@@ -298,7 +298,7 @@ end
298
298
  -- @param effectVariant Optional. If specified, will only remove effects that match this variant.
299
299
  -- @param subType Optional. If specified, will only remove effects that match this sub-type.
300
300
  -- @param cap Optional. If specified, will only remove the given amount of effects.
301
- -- @returns True if one or more effects were removed, false otherwise.
301
+ -- @returns An array of the effects that were removed.
302
302
  function ____exports.removeAllEffects(self, effectVariant, subType, cap)
303
303
  local effects = ____exports.getEffects(nil, effectVariant, subType)
304
304
  return removeEntities(nil, effects, cap)
@@ -309,7 +309,7 @@ end
309
309
  -- variant.
310
310
  -- @param subType Optional. If specified, will only remove familiars that match this sub-type.
311
311
  -- @param cap Optional. If specified, will only remove the given amount of familiars.
312
- -- @returns True if one or more familiars were removed, false otherwise.
312
+ -- @returns An array of the familiars that were removed.
313
313
  function ____exports.removeAllFamiliars(self, familiarVariant, subType, cap)
314
314
  local familiars = ____exports.getFamiliars(nil, familiarVariant, subType)
315
315
  return removeEntities(nil, familiars, cap)
@@ -319,7 +319,7 @@ end
319
319
  -- @param knifeVariant Optional. If specified, will only remove knives that match this variant.
320
320
  -- @param subType Optional. If specified, will only remove knives that match this sub-type.
321
321
  -- @param cap Optional. If specified, will only remove the given amount of knives.
322
- -- @returns True if one or more knives were removed, false otherwise.
322
+ -- @returns An array of the knives that were removed.
323
323
  function ____exports.removeAllKnives(self, knifeVariant, subType, cap)
324
324
  local knives = ____exports.getKnives(nil, knifeVariant, subType)
325
325
  return removeEntities(nil, knives, cap)
@@ -329,7 +329,7 @@ end
329
329
  -- @param laserVariant Optional. If specified, will only remove lasers that match this variant.
330
330
  -- @param subType Optional. If specified, will only remove lasers that match this sub-type.
331
331
  -- @param cap Optional. If specified, will only remove the given amount of lasers.
332
- -- @returns True if one or more lasers were removed, false otherwise.
332
+ -- @returns An array of the lasers that were removed.
333
333
  function ____exports.removeAllLasers(self, laserVariant, subType, cap)
334
334
  local lasers = ____exports.getLasers(nil, laserVariant, subType)
335
335
  return removeEntities(nil, lasers, cap)
@@ -337,7 +337,7 @@ end
337
337
  --- Helper function to remove all NPCs in the room.
338
338
  --
339
339
  -- @param cap Optional. If specified, will only remove the given amount of NPCs.
340
- -- @returns True if one or more NPCs were removed, false otherwise.
340
+ -- @returns An array of the NPCs that were removed.
341
341
  function ____exports.removeAllNPCs(self, cap)
342
342
  local npcs = ____exports.getNPCs(nil)
343
343
  return removeEntities(nil, npcs, cap)
@@ -347,7 +347,7 @@ end
347
347
  -- @param pickupVariant Optional. If specified, will only remove pickups that match this variant.
348
348
  -- @param subType Optional. If specified, will only remove pickups that match this sub-type.
349
349
  -- @param cap Optional. If specified, will only remove the given amount of pickups.
350
- -- @returns True if one or more pickups were removed, false otherwise.
350
+ -- @returns An array of the pickups that were removed.
351
351
  function ____exports.removeAllPickups(self, pickupVariant, subType, cap)
352
352
  local pickups = ____exports.getPickups(nil, pickupVariant, subType)
353
353
  return removeEntities(nil, pickups, cap)
@@ -358,7 +358,7 @@ end
358
358
  -- variant.
359
359
  -- @param subType Optional. If specified, will only remove projectiles that match this sub-type.
360
360
  -- @param cap Optional. If specified, will only remove the given amount of projectiles.
361
- -- @returns True if one or more projectiles were removed, false otherwise.
361
+ -- @returns An array of the projectiles that were removed.
362
362
  function ____exports.removeAllProjectiles(self, projectileVariant, subType, cap)
363
363
  local projectiles = ____exports.getProjectiles(nil, projectileVariant, subType)
364
364
  return removeEntities(nil, projectiles, cap)
@@ -368,7 +368,7 @@ end
368
368
  -- @param slotVariant Optional. If specified, will only remove slots that match this variant.
369
369
  -- @param subType Optional. If specified, will only remove slots that match this sub-type.
370
370
  -- @param cap Optional. If specified, will only remove the given amount of slots.
371
- -- @returns True if one or more slots were removed, false otherwise.
371
+ -- @returns An array of the slots that were removed.
372
372
  function ____exports.removeAllSlots(self, slotVariant, subType, cap)
373
373
  local slots = ____exports.getSlots(nil, slotVariant, subType)
374
374
  return removeEntities(nil, slots, cap)
@@ -378,7 +378,7 @@ end
378
378
  -- @param tearVariant Optional. If specified, will only remove tears that match this variant.
379
379
  -- @param subType Optional. If specified, will only remove tears that match this sub-type.
380
380
  -- @param cap Optional. If specified, will only remove the given amount of tears.
381
- -- @returns True if one or more tears were removed, false otherwise.
381
+ -- @returns An array of the tears that were removed.
382
382
  function ____exports.removeAllTears(self, tearVariant, subType, cap)
383
383
  local tears = ____exports.getTears(nil, tearVariant, subType)
384
384
  return removeEntities(nil, tears, cap)
@@ -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
  * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
4
6
  * when you iterate over them, you will get both the names of the enums and the values of the enums,