isaacscript-common 1.2.217 → 1.2.220

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 (42) hide show
  1. package/dist/callbacks/customRevive.lua +3 -2
  2. package/dist/enums/private/SerializableIsaacAPIClassType.d.ts +7 -0
  3. package/dist/enums/private/SerializableIsaacAPIClassType.lua +8 -0
  4. package/dist/enums/private/SerializationBrand.d.ts +1 -0
  5. package/dist/enums/private/SerializationBrand.lua +1 -0
  6. package/dist/features/extraConsoleCommands/commands.lua +3 -2
  7. package/dist/features/saveDataManager/merge.d.ts +1 -0
  8. package/dist/features/saveDataManager/merge.lua +7 -19
  9. package/dist/functions/collectibles.d.ts +4 -0
  10. package/dist/functions/collectibles.lua +40 -1
  11. package/dist/functions/color.d.ts +9 -3
  12. package/dist/functions/color.lua +26 -15
  13. package/dist/functions/deepCopy.d.ts +1 -0
  14. package/dist/functions/deepCopy.lua +35 -34
  15. package/dist/functions/isaacAPIClass.d.ts +25 -0
  16. package/dist/functions/isaacAPIClass.lua +52 -0
  17. package/dist/functions/kColor.d.ts +30 -0
  18. package/dist/functions/kColor.lua +90 -0
  19. package/dist/functions/log.lua +9 -7
  20. package/dist/functions/player.d.ts +7 -0
  21. package/dist/functions/player.lua +16 -11
  22. package/dist/functions/playerHealth.lua +3 -4
  23. package/dist/functions/pocketItems.lua +3 -2
  24. package/dist/functions/rng.d.ts +6 -3
  25. package/dist/functions/rng.lua +7 -3
  26. package/dist/functions/serialization.d.ts +5 -0
  27. package/dist/functions/serialization.lua +115 -0
  28. package/dist/functions/sprite.d.ts +10 -0
  29. package/dist/functions/sprite.lua +32 -0
  30. package/dist/functions/table.d.ts +4 -4
  31. package/dist/functions/trinkets.lua +2 -2
  32. package/dist/functions/vector.d.ts +6 -3
  33. package/dist/functions/vector.lua +7 -3
  34. package/dist/index.d.ts +3 -1
  35. package/dist/index.lua +24 -8
  36. package/dist/types/private/IsaacAPIClass.d.ts +4 -0
  37. package/dist/types/private/IsaacAPIClass.lua +3 -0
  38. package/dist/types/private/SerializableIsaacAPIClass.d.ts +4 -0
  39. package/dist/types/private/SerializableIsaacAPIClass.lua +3 -0
  40. package/dist/types/private/SerializedIsaacAPIClass.d.ts +4 -0
  41. package/dist/types/private/SerializedIsaacAPIClass.lua +3 -0
  42. package/package.json +2 -2
@@ -0,0 +1,90 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local OBJECT_NAME
4
+ local ____SerializationBrand = require("enums.private.SerializationBrand")
5
+ local SerializationBrand = ____SerializationBrand.SerializationBrand
6
+ local ____SerializationType = require("enums.SerializationType")
7
+ local SerializationType = ____SerializationType.SerializationType
8
+ local ____isaacAPIClass = require("functions.isaacAPIClass")
9
+ local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
10
+ local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
11
+ local ____table = require("functions.table")
12
+ local copyValuesToTable = ____table.copyValuesToTable
13
+ local getNumbersFromTable = ____table.getNumbersFromTable
14
+ local tableHasKeys = ____table.tableHasKeys
15
+ local ____utils = require("functions.utils")
16
+ local ensureAllCases = ____utils.ensureAllCases
17
+ function ____exports.isKColor(self, object)
18
+ return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
19
+ end
20
+ local KEYS = {"Red", "Green", "Blue", "Alpha"}
21
+ OBJECT_NAME = "KColor"
22
+ function ____exports.copyKColor(self, kColor, serializationType)
23
+ if serializationType == nil then
24
+ serializationType = SerializationType.NONE
25
+ end
26
+ repeat
27
+ local ____switch3 = serializationType
28
+ local ____cond3 = ____switch3 == SerializationType.NONE
29
+ if ____cond3 then
30
+ do
31
+ if not ____exports.isKColor(nil, kColor) then
32
+ error(((("Failed to copy a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
33
+ end
34
+ return KColor(kColor.Red, kColor.Green, kColor.Blue, kColor.Alpha)
35
+ end
36
+ end
37
+ ____cond3 = ____cond3 or ____switch3 == SerializationType.SERIALIZE
38
+ if ____cond3 then
39
+ do
40
+ if not ____exports.isKColor(nil, kColor) then
41
+ error(((("Failed to serialize a " .. OBJECT_NAME) .. " object since the provided object was not a userdata ") .. OBJECT_NAME) .. " class.")
42
+ end
43
+ local kColorTable = {}
44
+ copyValuesToTable(nil, kColor, KEYS, kColorTable)
45
+ kColorTable[SerializationBrand.KCOLOR] = ""
46
+ return kColorTable
47
+ end
48
+ end
49
+ ____cond3 = ____cond3 or ____switch3 == SerializationType.DESERIALIZE
50
+ if ____cond3 then
51
+ do
52
+ local kColorType = type(kColor)
53
+ if ____exports.isKColor(nil, kColor) or kColorType ~= "table" then
54
+ error(("Failed to deserialize a " .. OBJECT_NAME) .. " object since the provided object was not a Lua table.")
55
+ end
56
+ local r, g, b, a = table.unpack(getNumbersFromTable(
57
+ nil,
58
+ kColor,
59
+ OBJECT_NAME,
60
+ table.unpack(KEYS)
61
+ ))
62
+ return KColor(r, g, b, a)
63
+ end
64
+ end
65
+ do
66
+ do
67
+ return ensureAllCases(nil, serializationType)
68
+ end
69
+ end
70
+ until true
71
+ end
72
+ function ____exports.getDefaultKColor(self)
73
+ return KColor(1, 1, 1, 1)
74
+ end
75
+ function ____exports.isSerializedKColor(self, object)
76
+ local objectType = type(object)
77
+ if objectType ~= "table" then
78
+ return false
79
+ end
80
+ local ____table = object
81
+ return tableHasKeys(
82
+ nil,
83
+ ____table,
84
+ table.unpack(KEYS)
85
+ ) and ____table[SerializationBrand.KCOLOR] ~= nil
86
+ end
87
+ function ____exports.kColorEquals(self, kColor1, kColor2)
88
+ return isaacAPIClassEquals(nil, kColor1, kColor2, KEYS)
89
+ end
90
+ return ____exports
@@ -20,6 +20,8 @@ local ____flag = require("functions.flag")
20
20
  local hasFlag = ____flag.hasFlag
21
21
  local ____gridEntity = require("functions.gridEntity")
22
22
  local getGridEntities = ____gridEntity.getGridEntities
23
+ local ____isaacAPIClass = require("functions.isaacAPIClass")
24
+ local getIsaacAPIClassType = ____isaacAPIClass.getIsaacAPIClassType
23
25
  local ____math = require("functions.math")
24
26
  local range = ____math.range
25
27
  local ____player = require("functions.player")
@@ -35,8 +37,6 @@ local ____set = require("functions.set")
35
37
  local getSortedSetValues = ____set.getSortedSetValues
36
38
  local ____trinkets = require("functions.trinkets")
37
39
  local getTrinketName = ____trinkets.getTrinketName
38
- local ____userdata = require("functions.userdata")
39
- local getUserdataType = ____userdata.getUserdataType
40
40
  local ____utils = require("functions.utils")
41
41
  local printConsole = ____utils.printConsole
42
42
  function ____exports.getDebugPrependString(self, msg, numParentFunctions)
@@ -124,17 +124,19 @@ function ____exports.logEffects(player)
124
124
  __TS__ArrayForEach(
125
125
  effects,
126
126
  function(____, effect, i)
127
+ local effectDescription
127
128
  if effect.Item:IsCollectible() then
128
129
  local collectibleName = getCollectibleName(nil, effect.Item.ID)
129
- ____exports.log(((" " .. tostring(i + 1)) .. ") Collectible: ") .. collectibleName)
130
+ effectDescription = "Collectible: " .. collectibleName
130
131
  elseif effect.Item:IsTrinket() then
131
132
  local trinketName = getTrinketName(nil, effect.Item.ID)
132
- ____exports.log(((" " .. tostring(i + 1)) .. ") Trinket: ") .. trinketName)
133
+ effectDescription = "Trinket: " .. trinketName
133
134
  elseif effect.Item:IsNull() then
134
- ____exports.log(((" " .. tostring(i + 1)) .. ") Null item: ") .. tostring(effect.Item.ID))
135
+ effectDescription = "Null item: " .. tostring(effect.Item.ID)
135
136
  else
136
- ____exports.log(((" " .. tostring(i + 1)) .. ") Unknown type of effect: ") .. tostring(effect.Item.ID))
137
+ effectDescription = "Unknown type of effect: " .. tostring(effect.Item.ID)
137
138
  end
139
+ ____exports.log((((((" " .. tostring(i + 1)) .. ") ") .. effectDescription) .. " (x") .. tostring(effect.Count)) .. ")")
138
140
  end
139
141
  )
140
142
  end
@@ -432,7 +434,7 @@ function ____exports.logUserdata(userdata)
432
434
  ____exports.log("Userdata: [no metatable]")
433
435
  return
434
436
  end
435
- local classType = getUserdataType(nil, userdata)
437
+ local classType = getIsaacAPIClassType(nil, userdata)
436
438
  if classType == nil then
437
439
  ____exports.log("Userdata: [no class type]")
438
440
  else
@@ -186,6 +186,13 @@ export declare function isActiveSlotEmpty(player: EntityPlayer, activeSlot: Acti
186
186
  * charges.
187
187
  */
188
188
  export declare function isBethany(player: EntityPlayer): boolean;
189
+ /**
190
+ * Helper function to check if a player is a specific character (i.e. `PlayerType`).
191
+ *
192
+ * This function is variadic, meaning that you can supply as many characters as you want to check
193
+ * for. Returns true if the player is any of the supplied characters.
194
+ */
195
+ export declare function isCharacter(player: EntityPlayer, ...characters: Array<PlayerType | int>): boolean;
189
196
  /**
190
197
  * Helper function for detecting when a player is Eden or Tainted Eden. Useful for situations where
191
198
  * you want to know if the starting stats were randomized, for example.
@@ -64,6 +64,12 @@ function ____exports.getPlayerMaxHeartContainers(self, player)
64
64
  end
65
65
  return characterMaxHeartContainers
66
66
  end
67
+ function ____exports.isCharacter(self, player, ...)
68
+ local characters = {...}
69
+ local characterSet = __TS__New(Set, characters)
70
+ local character = player:GetPlayerType()
71
+ return characterSet:has(character)
72
+ end
67
73
  function ____exports.isKeeper(self, player)
68
74
  local character = player:GetPlayerType()
69
75
  return character == PlayerType.PLAYER_KEEPER or character == PlayerType.PLAYER_KEEPER_B
@@ -391,8 +397,7 @@ function ____exports.hasLostCurse(self, player)
391
397
  return effects:HasNullEffect(112)
392
398
  end
393
399
  function ____exports.hasOpenActiveItemSlot(self, player)
394
- local character = player:GetPlayerType()
395
- if character == PlayerType.PLAYER_THESOUL_B then
400
+ if ____exports.isCharacter(nil, player, PlayerType.PLAYER_THESOUL_B) then
396
401
  return false
397
402
  end
398
403
  local activeItemPrimary = player:GetActiveItem(ActiveSlot.SLOT_PRIMARY)
@@ -478,9 +483,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
478
483
  itemPool:RemoveCollectible(collectibleType)
479
484
  end
480
485
  repeat
481
- local ____switch100 = activeSlot
482
- local ____cond100 = ____switch100 == ActiveSlot.SLOT_PRIMARY
483
- if ____cond100 then
486
+ local ____switch101 = activeSlot
487
+ local ____cond101 = ____switch101 == ActiveSlot.SLOT_PRIMARY
488
+ if ____cond101 then
484
489
  do
485
490
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
486
491
  player:RemoveCollectible(primaryCollectibleType)
@@ -489,8 +494,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
489
494
  break
490
495
  end
491
496
  end
492
- ____cond100 = ____cond100 or ____switch100 == ActiveSlot.SLOT_SECONDARY
493
- if ____cond100 then
497
+ ____cond101 = ____cond101 or ____switch101 == ActiveSlot.SLOT_SECONDARY
498
+ if ____cond101 then
494
499
  do
495
500
  if primaryCollectibleType ~= CollectibleType.COLLECTIBLE_NULL then
496
501
  player:RemoveCollectible(primaryCollectibleType)
@@ -505,16 +510,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
505
510
  break
506
511
  end
507
512
  end
508
- ____cond100 = ____cond100 or ____switch100 == ActiveSlot.SLOT_POCKET
509
- if ____cond100 then
513
+ ____cond101 = ____cond101 or ____switch101 == ActiveSlot.SLOT_POCKET
514
+ if ____cond101 then
510
515
  do
511
516
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
512
517
  player:SetActiveCharge(charge, activeSlot)
513
518
  break
514
519
  end
515
520
  end
516
- ____cond100 = ____cond100 or ____switch100 == ActiveSlot.SLOT_POCKET2
517
- if ____cond100 then
521
+ ____cond101 = ____cond101 or ____switch101 == ActiveSlot.SLOT_POCKET2
522
+ if ____cond101 then
518
523
  do
519
524
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
520
525
  break
@@ -10,6 +10,7 @@ local ____player = require("functions.player")
10
10
  local getPlayerBlackHearts = ____player.getPlayerBlackHearts
11
11
  local getPlayerHearts = ____player.getPlayerHearts
12
12
  local getPlayerSoulHearts = ____player.getPlayerSoulHearts
13
+ local isCharacter = ____player.isCharacter
13
14
  local ____utils = require("functions.utils")
14
15
  local ensureAllCases = ____utils.ensureAllCases
15
16
  local ____repeat = ____utils["repeat"]
@@ -213,7 +214,6 @@ function ____exports.getPlayerHealthType(self, player, healthType)
213
214
  until true
214
215
  end
215
216
  function ____exports.removeAllPlayerHealth(self, player)
216
- local character = player:GetPlayerType()
217
217
  local goldenHearts = player:GetGoldenHearts()
218
218
  local eternalHearts = player:GetEternalHearts()
219
219
  local boneHearts = player:GetBoneHearts()
@@ -224,7 +224,7 @@ function ____exports.removeAllPlayerHealth(self, player)
224
224
  player:AddBrokenHearts(brokenHearts * -1)
225
225
  player:AddMaxHearts(MAX_PLAYER_HEART_CONTAINERS * -2, true)
226
226
  player:AddSoulHearts(MAX_PLAYER_HEART_CONTAINERS * -2)
227
- if character == PlayerType.PLAYER_THESOUL then
227
+ if isCharacter(nil, player, PlayerType.PLAYER_THESOUL) then
228
228
  local forgotten = player:GetSubPlayer()
229
229
  if forgotten ~= nil then
230
230
  local forgottenBoneHearts = forgotten:GetBoneHearts()
@@ -235,7 +235,6 @@ end
235
235
  function ____exports.setPlayerHealth(self, player, playerHealth)
236
236
  local character = player:GetPlayerType()
237
237
  local subPlayer = player:GetSubPlayer()
238
- local isTaintedMagdalene = character == PlayerType.PLAYER_MAGDALENE_B
239
238
  ____exports.removeAllPlayerHealth(nil, player)
240
239
  if character == PlayerType.PLAYER_THESOUL and subPlayer ~= nil then
241
240
  subPlayer:AddMaxHearts(playerHealth.maxHearts, false)
@@ -269,7 +268,7 @@ function ____exports.setPlayerHealth(self, player, playerHealth)
269
268
  playerHealth.hearts,
270
269
  function()
271
270
  player:AddHearts(1)
272
- if isTaintedMagdalene then
271
+ if character == PlayerType.PLAYER_MAGDALENE_B then
273
272
  player:AddHearts(-1)
274
273
  end
275
274
  end
@@ -9,6 +9,8 @@ local ____PocketItemType = require("enums.PocketItemType")
9
9
  local PocketItemType = ____PocketItemType.PocketItemType
10
10
  local ____math = require("functions.math")
11
11
  local range = ____math.range
12
+ local ____player = require("functions.player")
13
+ local isCharacter = ____player.isCharacter
12
14
  function ____exports.getPocketItems(self, player)
13
15
  local pocketItem = player:GetActiveItem(ActiveSlot.SLOT_POCKET)
14
16
  local hasPocketItem = pocketItem ~= CollectibleType.COLLECTIBLE_NULL
@@ -50,8 +52,7 @@ function ____exports.getFirstCardOrPill(self, player)
50
52
  )
51
53
  end
52
54
  function ____exports.hasOpenPocketItemSlot(self, player)
53
- local character = player:GetPlayerType()
54
- if character == PlayerType.PLAYER_THESOUL_B then
55
+ if isCharacter(nil, player, PlayerType.PLAYER_THESOUL_B) then
55
56
  return false
56
57
  end
57
58
  local pocketItems = ____exports.getPocketItems(nil, player)
@@ -1,7 +1,9 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
3
  import { SerializationType } from "../enums/SerializationType";
4
- declare type SerializedRNG = LuaTable<string, string | number>;
4
+ declare type SerializedRNG = LuaTable<string, unknown> & {
5
+ __serializedRNGBrand: unknown;
6
+ };
5
7
  interface CopyRNGReturn {
6
8
  [SerializationType.NONE]: RNG;
7
9
  [SerializationType.SERIALIZE]: SerializedRNG;
@@ -25,8 +27,8 @@ export declare function getRandomSeed(): Seed;
25
27
  /** Helper function to check if something is an instantiated RNG object. */
26
28
  export declare function isRNG(object: unknown): object is RNG;
27
29
  /**
28
- * Used to determine is the given table is a serialized Vector created by the save data manager
29
- * and/or the `deepCopy` function.
30
+ * Used to determine is the given table is a serialized `RNG` object created by the save data
31
+ * manager and/or the `deepCopy` function.
30
32
  */
31
33
  export declare function isSerializedRNG(object: unknown): object is SerializedRNG;
32
34
  /**
@@ -35,6 +37,7 @@ export declare function isSerializedRNG(object: unknown): object is SerializedRN
35
37
  * @param seed The seed to initialize it with. Default is `getRandomSeed()`.
36
38
  */
37
39
  export declare function newRNG(seed?: Seed): RNG;
40
+ export declare function rngEquals(rng1: RNG, rng2: RNG): boolean;
38
41
  /**
39
42
  * Helper function to iterate over the provided object and set the seed for all of the values that
40
43
  * are RNG objects equal to a particular seed.
@@ -8,11 +8,12 @@ local ____SerializationBrand = require("enums.private.SerializationBrand")
8
8
  local SerializationBrand = ____SerializationBrand.SerializationBrand
9
9
  local ____SerializationType = require("enums.SerializationType")
10
10
  local SerializationType = ____SerializationType.SerializationType
11
+ local ____isaacAPIClass = require("functions.isaacAPIClass")
12
+ local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
13
+ local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
11
14
  local ____table = require("functions.table")
12
15
  local getNumbersFromTable = ____table.getNumbersFromTable
13
16
  local tableHasKeys = ____table.tableHasKeys
14
- local ____userdata = require("functions.userdata")
15
- local isUserdataObject = ____userdata.isUserdataObject
16
17
  local ____utils = require("functions.utils")
17
18
  local ensureAllCases = ____utils.ensureAllCases
18
19
  function ____exports.getRandomSeed(self)
@@ -21,7 +22,7 @@ function ____exports.getRandomSeed(self)
21
22
  return safeRandomNumber
22
23
  end
23
24
  function ____exports.isRNG(self, object)
24
- return isUserdataObject(nil, object, OBJECT_NAME)
25
+ return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
25
26
  end
26
27
  function ____exports.newRNG(self, seed)
27
28
  if seed == nil then
@@ -105,6 +106,9 @@ function ____exports.isSerializedRNG(self, object)
105
106
  table.unpack(KEYS)
106
107
  ) and ____table[SerializationBrand.RNG] ~= nil
107
108
  end
109
+ function ____exports.rngEquals(self, rng1, rng2)
110
+ return isaacAPIClassEquals(nil, rng1, rng2, KEYS)
111
+ end
108
112
  function ____exports.setAllRNGToSeed(self, object, seed)
109
113
  local objectType = type(object)
110
114
  if objectType ~= "table" then
@@ -0,0 +1,5 @@
1
+ import { SerializationType } from "../enums/SerializationType";
2
+ import { SerializableIsaacAPIClass } from "../types/private/SerializableIsaacAPIClass";
3
+ import { SerializedIsaacAPIClass } from "../types/private/SerializedIsaacAPIClass";
4
+ export declare function copySerializableIsaacAPIClass(isaacAPIClassOrSerializedTable: SerializableIsaacAPIClass | SerializedIsaacAPIClass, serializationType: SerializationType): unknown;
5
+ export declare function isSerializedIsaacAPIClass(object: unknown): object is SerializedIsaacAPIClass;
@@ -0,0 +1,115 @@
1
+ --[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]]
2
+ local ____exports = {}
3
+ local ____SerializableIsaacAPIClassType = require("enums.private.SerializableIsaacAPIClassType")
4
+ local SerializableIsaacAPIClassType = ____SerializableIsaacAPIClassType.SerializableIsaacAPIClassType
5
+ local ____color = require("functions.color")
6
+ local copyColor = ____color.copyColor
7
+ local isSerializedColor = ____color.isSerializedColor
8
+ local ____isaacAPIClass = require("functions.isaacAPIClass")
9
+ local getIsaacAPIClassType = ____isaacAPIClass.getIsaacAPIClassType
10
+ local ____kColor = require("functions.kColor")
11
+ local copyKColor = ____kColor.copyKColor
12
+ local isSerializedKColor = ____kColor.isSerializedKColor
13
+ local ____rng = require("functions.rng")
14
+ local copyRNG = ____rng.copyRNG
15
+ local isSerializedRNG = ____rng.isSerializedRNG
16
+ local ____utils = require("functions.utils")
17
+ local ensureAllCases = ____utils.ensureAllCases
18
+ local getEnumValues = ____utils.getEnumValues
19
+ local ____vector = require("functions.vector")
20
+ local copyVector = ____vector.copyVector
21
+ local isSerializedVector = ____vector.isSerializedVector
22
+ function ____exports.copySerializableIsaacAPIClass(self, isaacAPIClassOrSerializedTable, serializationType)
23
+ local isaacAPIClassType = getIsaacAPIClassType(nil, isaacAPIClassOrSerializedTable)
24
+ repeat
25
+ local ____switch3 = isaacAPIClassType
26
+ local ____cond3 = ____switch3 == SerializableIsaacAPIClassType.COLOR
27
+ if ____cond3 then
28
+ do
29
+ local color = isaacAPIClassOrSerializedTable
30
+ return copyColor(nil, color, serializationType)
31
+ end
32
+ end
33
+ ____cond3 = ____cond3 or ____switch3 == SerializableIsaacAPIClassType.KCOLOR
34
+ if ____cond3 then
35
+ do
36
+ local kColor = isaacAPIClassOrSerializedTable
37
+ return copyKColor(nil, kColor, serializationType)
38
+ end
39
+ end
40
+ ____cond3 = ____cond3 or ____switch3 == SerializableIsaacAPIClassType.RNG
41
+ if ____cond3 then
42
+ do
43
+ local rng = isaacAPIClassOrSerializedTable
44
+ return copyRNG(nil, rng)
45
+ end
46
+ end
47
+ ____cond3 = ____cond3 or ____switch3 == SerializableIsaacAPIClassType.VECTOR
48
+ if ____cond3 then
49
+ do
50
+ local vector = isaacAPIClassOrSerializedTable
51
+ return copyVector(nil, vector)
52
+ end
53
+ end
54
+ do
55
+ do
56
+ return ensureAllCases(nil, isaacAPIClassType)
57
+ end
58
+ end
59
+ until true
60
+ end
61
+ function ____exports.isSerializedIsaacAPIClass(self, object)
62
+ local objectType = type(object)
63
+ if objectType ~= "table" then
64
+ return false
65
+ end
66
+ local serializableIsaacAPIClassTypes = getEnumValues(nil, SerializableIsaacAPIClassType)
67
+ for ____, serializableIsaacAPIClassType in ipairs(serializableIsaacAPIClassTypes) do
68
+ repeat
69
+ local ____switch12 = serializableIsaacAPIClassType
70
+ local ____cond12 = ____switch12 == SerializableIsaacAPIClassType.COLOR
71
+ if ____cond12 then
72
+ do
73
+ if isSerializedColor(nil, object) then
74
+ return true
75
+ end
76
+ break
77
+ end
78
+ end
79
+ ____cond12 = ____cond12 or ____switch12 == SerializableIsaacAPIClassType.KCOLOR
80
+ if ____cond12 then
81
+ do
82
+ if isSerializedKColor(nil, object) then
83
+ return true
84
+ end
85
+ break
86
+ end
87
+ end
88
+ ____cond12 = ____cond12 or ____switch12 == SerializableIsaacAPIClassType.RNG
89
+ if ____cond12 then
90
+ do
91
+ if isSerializedRNG(nil, object) then
92
+ return true
93
+ end
94
+ break
95
+ end
96
+ end
97
+ ____cond12 = ____cond12 or ____switch12 == SerializableIsaacAPIClassType.VECTOR
98
+ if ____cond12 then
99
+ do
100
+ if isSerializedVector(nil, object) then
101
+ return true
102
+ end
103
+ break
104
+ end
105
+ end
106
+ do
107
+ do
108
+ ensureAllCases(nil, serializableIsaacAPIClassType)
109
+ end
110
+ end
111
+ until true
112
+ end
113
+ return false
114
+ end
115
+ return ____exports
@@ -24,3 +24,13 @@ export declare function clearSprite(sprite: Sprite, ...layerIDs: int[]): void;
24
24
  * as player animations.
25
25
  */
26
26
  export declare function getFinalFrameOfAnimation(sprite: Sprite, animation?: string): int;
27
+ /**
28
+ * Helper function to check if two sprite layers have the same sprite sheet by using the
29
+ * `Sprite.GetTexel` method.
30
+ *
31
+ * Since checking every single texel in the entire sprite is very expensive, this function requires
32
+ * that you provide a range of specific texels to check.
33
+ */
34
+ export declare function spriteEquals(sprite1: Sprite, sprite2: Sprite, layerID: int, xStart: int, xFinish: int, xIncrement: int, yStart: int, yFinish: int, yIncrement: int): boolean;
35
+ /** Helper function to check if two texels on a sprite are equivalent to each other. */
36
+ export declare function texelEquals(sprite1: Sprite, sprite2: Sprite, position: Vector, layerID: int): boolean;
@@ -2,8 +2,15 @@
2
2
  local ____exports = {}
3
3
  local ____constants = require("constants")
4
4
  local EMPTY_PNG_PATH = ____constants.EMPTY_PNG_PATH
5
+ local ____kColor = require("functions.kColor")
6
+ local kColorEquals = ____kColor.kColorEquals
5
7
  local ____math = require("functions.math")
6
8
  local range = ____math.range
9
+ function ____exports.texelEquals(self, sprite1, sprite2, position, layerID)
10
+ local kColor1 = sprite1:GetTexel(position, Vector.Zero, 1, layerID)
11
+ local kColor2 = sprite2:GetTexel(position, Vector.Zero, 1, layerID)
12
+ return kColorEquals(nil, kColor1, kColor2)
13
+ end
7
14
  function ____exports.clearSprite(self, sprite, ...)
8
15
  local layerIDs = {...}
9
16
  if #layerIDs == 0 then
@@ -29,4 +36,29 @@ function ____exports.getFinalFrameOfAnimation(self, sprite, animation)
29
36
  sprite:SetFrame(currentFrame)
30
37
  return finalFrame
31
38
  end
39
+ function ____exports.spriteEquals(self, sprite1, sprite2, layerID, xStart, xFinish, xIncrement, yStart, yFinish, yIncrement)
40
+ do
41
+ local x = xStart
42
+ while x <= xFinish do
43
+ do
44
+ local y = yStart
45
+ while y <= yFinish do
46
+ local position = Vector(x, y)
47
+ if not ____exports.texelEquals(
48
+ nil,
49
+ sprite1,
50
+ sprite2,
51
+ position,
52
+ layerID
53
+ ) then
54
+ return false
55
+ end
56
+ y = y + yIncrement
57
+ end
58
+ end
59
+ x = x + xIncrement
60
+ end
61
+ end
62
+ return true
63
+ end
32
64
  return ____exports
@@ -5,28 +5,28 @@
5
5
  */
6
6
  export declare function clearTable(table: LuaTable): void;
7
7
  /** Helper function to copy specific values from a object to a table. */
8
- export declare function copyValuesToTable(object: unknown, keys: string[], table: LuaTable<string, string | number>): void;
8
+ export declare function copyValuesToTable(object: unknown, keys: string[], table: LuaTable<string, unknown>): void;
9
9
  /**
10
10
  * Helper function to safely get boolean values from a Lua table. Will throw an error if the
11
11
  * specific value does not exist on the table.
12
12
  *
13
13
  * This function is variadic, meaning that you can specify N arguments to get N values.
14
14
  */
15
- export declare function getBooleansFromTable(table: LuaTable<string, string | number>, objectName: string, ...keys: string[]): boolean[];
15
+ export declare function getBooleansFromTable(table: LuaTable<string, unknown>, objectName: string, ...keys: string[]): boolean[];
16
16
  /**
17
17
  * Helper function to safely get number values from a Lua table. Will throw an error if the specific
18
18
  * value does not exist on the table or if it cannot be converted to a number.
19
19
  *
20
20
  * This function is variadic, meaning that you can specify N arguments to get N values.
21
21
  */
22
- export declare function getNumbersFromTable(table: LuaTable<string, string | number>, objectName: string, ...keys: string[]): number[];
22
+ export declare function getNumbersFromTable(table: LuaTable<string, unknown>, objectName: string, ...keys: string[]): number[];
23
23
  /**
24
24
  * Helper function to safely get string values from a Lua table. Will throw an error if the specific
25
25
  * value does not exist on the table.
26
26
  *
27
27
  * This function is variadic, meaning that you can specify N arguments to get N values.
28
28
  */
29
- export declare function getStringsFromTable(table: LuaTable<string, string | number>, objectName: string, ...keys: string[]): string[];
29
+ export declare function getStringsFromTable(table: LuaTable<string, unknown>, objectName: string, ...keys: string[]): string[];
30
30
  /**
31
31
  * Helper function to check if a Lua table has all of the provided keys.
32
32
  *
@@ -15,6 +15,7 @@ local hasFlag = ____flag.hasFlag
15
15
  local ____pickups = require("functions.pickups")
16
16
  local getPickups = ____pickups.getPickups
17
17
  local ____player = require("functions.player")
18
+ local isCharacter = ____player.isCharacter
18
19
  local useActiveItemTemp = ____player.useActiveItemTemp
19
20
  local ____sprite = require("functions.sprite")
20
21
  local clearSprite = ____sprite.clearSprite
@@ -71,8 +72,7 @@ function ____exports.getTrinkets(self, matchingSubType)
71
72
  return getPickups(nil, 350, matchingSubType)
72
73
  end
73
74
  function ____exports.hasOpenTrinketSlot(self, player)
74
- local character = player:GetPlayerType()
75
- if character == PlayerType.PLAYER_THESOUL_B then
75
+ if isCharacter(nil, player, PlayerType.PLAYER_THESOUL_B) then
76
76
  return false
77
77
  end
78
78
  local openTrinketSlot = ____exports.getOpenTrinketSlot(nil, player)
@@ -1,7 +1,9 @@
1
1
  /// <reference types="isaac-typescript-definitions" />
2
2
  /// <reference types="typescript-to-lua/language-extensions" />
3
3
  import { SerializationType } from "../enums/SerializationType";
4
- declare type SerializedVector = LuaTable<string, string | number>;
4
+ declare type SerializedVector = LuaTable<string, unknown> & {
5
+ __serializedVectorBrand: unknown;
6
+ };
5
7
  interface CopyVectorReturn {
6
8
  [SerializationType.NONE]: Vector;
7
9
  [SerializationType.SERIALIZE]: SerializedVector;
@@ -28,12 +30,13 @@ export declare function getOneVector(): Vector;
28
30
  */
29
31
  export declare function getZeroVector(): Vector;
30
32
  /**
31
- * Used to determine is the given table is a serialized Vector created by the save data manager
32
- * and/or the `deepCopy` function.
33
+ * Used to determine is the given table is a serialized `Vector` object created by the save data
34
+ * manager and/or the `deepCopy` function.
33
35
  */
34
36
  export declare function isSerializedVector(object: unknown): object is SerializedVector;
35
37
  /** Helper function to check if something is an instantiated Vector object. */
36
38
  export declare function isVector(object: unknown): object is Vector;
39
+ export declare function vectorEquals(vector1: Vector, vector2: Vector): boolean;
37
40
  /** Helper function for finding out which way a vector is pointing. */
38
41
  export declare function vectorToDirection(vector: Vector): Direction;
39
42
  export {};
@@ -7,16 +7,17 @@ local ____SerializationType = require("enums.SerializationType")
7
7
  local SerializationType = ____SerializationType.SerializationType
8
8
  local ____directionToVector = require("objects.directionToVector")
9
9
  local DIRECTION_TO_VECTOR = ____directionToVector.DIRECTION_TO_VECTOR
10
+ local ____isaacAPIClass = require("functions.isaacAPIClass")
11
+ local isaacAPIClassEquals = ____isaacAPIClass.isaacAPIClassEquals
12
+ local isIsaacAPIClassOfType = ____isaacAPIClass.isIsaacAPIClassOfType
10
13
  local ____table = require("functions.table")
11
14
  local copyValuesToTable = ____table.copyValuesToTable
12
15
  local getNumbersFromTable = ____table.getNumbersFromTable
13
16
  local tableHasKeys = ____table.tableHasKeys
14
- local ____userdata = require("functions.userdata")
15
- local isUserdataObject = ____userdata.isUserdataObject
16
17
  local ____utils = require("functions.utils")
17
18
  local ensureAllCases = ____utils.ensureAllCases
18
19
  function ____exports.isVector(self, object)
19
- return isUserdataObject(nil, object, OBJECT_NAME)
20
+ return isIsaacAPIClassOfType(nil, object, OBJECT_NAME)
20
21
  end
21
22
  local KEYS = {"X", "Y"}
22
23
  OBJECT_NAME = "Vector"
@@ -91,6 +92,9 @@ function ____exports.isSerializedVector(self, object)
91
92
  table.unpack(KEYS)
92
93
  ) and ____table[SerializationBrand.VECTOR] ~= nil
93
94
  end
95
+ function ____exports.vectorEquals(self, vector1, vector2)
96
+ return isaacAPIClassEquals(nil, vector1, vector2, KEYS)
97
+ end
94
98
  function ____exports.vectorToDirection(self, vector)
95
99
  local degrees = vector:GetAngleDegrees()
96
100
  if degrees > -45 and degrees < 45 then