isaacscript-common 29.5.0 → 29.5.2

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 (70) hide show
  1. package/dist/index.rollup.d.ts +148 -228
  2. package/dist/isaacscript-common.lua +1682 -1711
  3. package/dist/src/callbackClasses.d.ts +0 -1
  4. package/dist/src/callbackClasses.d.ts.map +1 -1
  5. package/dist/src/callbackClasses.lua +0 -5
  6. package/dist/src/callbacks.d.ts +126 -127
  7. package/dist/src/callbacks.d.ts.map +1 -1
  8. package/dist/src/callbacks.lua +0 -1
  9. package/dist/src/classes/features/callbackLogic/EsauJrDetection.d.ts +1 -1
  10. package/dist/src/classes/features/callbackLogic/EsauJrDetection.d.ts.map +1 -1
  11. package/dist/src/classes/features/callbackLogic/EsauJrDetection.lua +2 -2
  12. package/dist/src/classes/features/callbackLogic/FlipDetection.d.ts +1 -1
  13. package/dist/src/classes/features/callbackLogic/FlipDetection.d.ts.map +1 -1
  14. package/dist/src/classes/features/callbackLogic/FlipDetection.lua +2 -2
  15. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.d.ts +1 -1
  16. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.d.ts.map +1 -1
  17. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.lua +2 -2
  18. package/dist/src/classes/features/callbackLogic/PlayerCollectibleDetection.d.ts +1 -1
  19. package/dist/src/classes/features/callbackLogic/PlayerCollectibleDetection.d.ts.map +1 -1
  20. package/dist/src/classes/features/callbackLogic/PlayerCollectibleDetection.lua +2 -2
  21. package/dist/src/classes/features/other/PickupIndexCreation.d.ts +4 -0
  22. package/dist/src/classes/features/other/PickupIndexCreation.d.ts.map +1 -1
  23. package/dist/src/classes/features/other/PreventCollectibleRotation.d.ts +9 -3
  24. package/dist/src/classes/features/other/PreventCollectibleRotation.d.ts.map +1 -1
  25. package/dist/src/classes/features/other/PreventCollectibleRotation.lua +66 -25
  26. package/dist/src/enums/ModCallbackCustom.d.ts +126 -144
  27. package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
  28. package/dist/src/enums/ModCallbackCustom.lua +126 -128
  29. package/dist/src/features.d.ts.map +1 -1
  30. package/dist/src/features.lua +2 -2
  31. package/dist/src/functions/collectibles.d.ts +0 -52
  32. package/dist/src/functions/collectibles.d.ts.map +1 -1
  33. package/dist/src/functions/collectibles.lua +0 -68
  34. package/dist/src/functions/playerIndex.d.ts +3 -3
  35. package/dist/src/functions/playerIndex.lua +3 -3
  36. package/dist/src/functions/utils.d.ts +2 -0
  37. package/dist/src/functions/utils.d.ts.map +1 -1
  38. package/dist/src/functions/utils.lua +2 -0
  39. package/dist/src/index.d.ts +0 -1
  40. package/dist/src/index.d.ts.map +1 -1
  41. package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts +0 -4
  42. package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts.map +1 -1
  43. package/dist/src/shouldFire.d.ts +0 -1
  44. package/dist/src/shouldFire.d.ts.map +1 -1
  45. package/dist/src/shouldFire.lua +0 -5
  46. package/package.json +2 -2
  47. package/src/callbackClasses.ts +0 -1
  48. package/src/callbacks.ts +0 -1
  49. package/src/classes/features/callbackLogic/EsauJrDetection.ts +2 -2
  50. package/src/classes/features/callbackLogic/FlipDetection.ts +2 -2
  51. package/src/classes/features/callbackLogic/GameReorderedCallbacks.ts +2 -2
  52. package/src/classes/features/callbackLogic/PlayerCollectibleDetection.ts +2 -2
  53. package/src/classes/features/other/PickupIndexCreation.ts +4 -0
  54. package/src/classes/features/other/PreventCollectibleRotation.ts +108 -49
  55. package/src/enums/ModCallbackCustom.ts +0 -19
  56. package/src/features.ts +7 -5
  57. package/src/functions/collectibles.ts +0 -79
  58. package/src/functions/playerIndex.ts +3 -3
  59. package/src/functions/utils.ts +2 -0
  60. package/src/index.ts +0 -1
  61. package/src/interfaces/private/AddCallbackParametersCustom.ts +0 -5
  62. package/src/shouldFire.ts +0 -13
  63. package/dist/src/classes/callbacks/PostCollectibleInitFirst.d.ts +0 -15
  64. package/dist/src/classes/callbacks/PostCollectibleInitFirst.d.ts.map +0 -1
  65. package/dist/src/classes/callbacks/PostCollectibleInitFirst.lua +0 -36
  66. package/dist/src/types/CollectibleIndex.d.ts +0 -18
  67. package/dist/src/types/CollectibleIndex.d.ts.map +0 -1
  68. package/dist/src/types/CollectibleIndex.lua +0 -2
  69. package/src/classes/callbacks/PostCollectibleInitFirst.ts +0 -44
  70. package/src/types/CollectibleIndex.ts +0 -17
@@ -1,68 +1,109 @@
1
1
  local ____lualib = require("lualib_bundle")
2
- local Map = ____lualib.Map
3
2
  local __TS__New = ____lualib.__TS__New
3
+ local Map = ____lualib.Map
4
4
  local __TS__Class = ____lualib.__TS__Class
5
5
  local __TS__ClassExtends = ____lualib.__TS__ClassExtends
6
6
  local __TS__Decorate = ____lualib.__TS__Decorate
7
7
  local ____exports = {}
8
- local getMapIndex
8
+ local markRollFrame, v
9
9
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
10
10
  local CardType = ____isaac_2Dtypescript_2Ddefinitions.CardType
11
11
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
12
+ local DiceFloorSubType = ____isaac_2Dtypescript_2Ddefinitions.DiceFloorSubType
12
13
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
13
14
  local PickupVariant = ____isaac_2Dtypescript_2Ddefinitions.PickupVariant
14
15
  local ____cachedClasses = require("src.core.cachedClasses")
15
16
  local game = ____cachedClasses.game
16
17
  local ____decorators = require("src.decorators")
17
18
  local Exported = ____decorators.Exported
19
+ local ____ISCFeature = require("src.enums.ISCFeature")
20
+ local ISCFeature = ____ISCFeature.ISCFeature
21
+ local ____ModCallbackCustom = require("src.enums.ModCallbackCustom")
22
+ local ModCallbackCustom = ____ModCallbackCustom.ModCallbackCustom
18
23
  local ____collectibles = require("src.functions.collectibles")
19
24
  local setCollectibleSubType = ____collectibles.setCollectibleSubType
20
25
  local ____entities = require("src.functions.entities")
21
26
  local getEntityID = ____entities.getEntityID
27
+ local ____pickupsSpecific = require("src.functions.pickupsSpecific")
28
+ local getCollectibles = ____pickupsSpecific.getCollectibles
22
29
  local ____pickupVariants = require("src.functions.pickupVariants")
23
30
  local isCollectible = ____pickupVariants.isCollectible
31
+ local ____types = require("src.functions.types")
32
+ local asCollectibleType = ____types.asCollectibleType
33
+ local ____ReadonlySet = require("src.types.ReadonlySet")
34
+ local ReadonlySet = ____ReadonlySet.ReadonlySet
24
35
  local ____Feature = require("src.classes.private.Feature")
25
36
  local Feature = ____Feature.Feature
26
- function getMapIndex(self, collectible)
27
- local room = game:GetRoom()
28
- local gridIndex = room:GetGridIndex(collectible.Position)
29
- return (tostring(gridIndex) .. ",") .. tostring(collectible.InitSeed)
37
+ function markRollFrame(self)
38
+ v.run.rollGameFrame = game:GetFrameCount()
30
39
  end
31
- local v = {room = {trackedCollectibles = __TS__New(Map)}}
40
+ local ROLL_COLLECTIBLE_TYPES = __TS__New(ReadonlySet, {CollectibleType.D6, CollectibleType.ETERNAL_D6, CollectibleType.SPINDOWN_DICE})
41
+ local ROLL_FLOOR_DICE_FLOOR_SUB_TYPES = __TS__New(ReadonlySet, {DiceFloorSubType.FOUR_PIP, DiceFloorSubType.SIX_PIP})
42
+ v = {run = {
43
+ trackedCollectibles = __TS__New(Map),
44
+ rollGameFrame = nil
45
+ }}
32
46
  ____exports.PreventCollectibleRotation = __TS__Class()
33
47
  local PreventCollectibleRotation = ____exports.PreventCollectibleRotation
34
48
  PreventCollectibleRotation.name = "PreventCollectibleRotation"
35
49
  __TS__ClassExtends(PreventCollectibleRotation, Feature)
36
- function PreventCollectibleRotation.prototype.____constructor(self)
50
+ function PreventCollectibleRotation.prototype.____constructor(self, pickupIndexCreation)
37
51
  Feature.prototype.____constructor(self)
38
52
  self.v = v
39
- self.useCardSoulOfIsaac = function()
40
- v.room.trackedCollectibles:clear()
53
+ self.preUseItem = function(____, collectibleType)
54
+ if ROLL_COLLECTIBLE_TYPES:has(collectibleType) then
55
+ markRollFrame(nil)
56
+ end
57
+ return nil
41
58
  end
42
- self.postPickupUpdateCollectible = function(____, pickup)
43
- local collectible = pickup
44
- self:checkCollectibleRotated(collectible)
59
+ self.postUseCardSoulOfIsaac = function()
60
+ local collectibles = getCollectibles(nil)
61
+ for ____, collectible in ipairs(collectibles) do
62
+ local pickupIndex = self.pickupIndexCreation:getPickupIndex(collectible)
63
+ v.run.trackedCollectibles:delete(pickupIndex)
64
+ end
45
65
  end
46
- self.callbacksUsed = {{ModCallback.POST_USE_CARD, self.useCardSoulOfIsaac, {CardType.SOUL_ISAAC}}, {ModCallback.POST_PICKUP_UPDATE, self.postPickupUpdateCollectible, {PickupVariant.COLLECTIBLE}}}
47
- end
48
- function PreventCollectibleRotation.prototype.checkCollectibleRotated(self, collectible)
49
- if collectible.SubType == CollectibleType.NULL then
50
- return
66
+ self.postDiceRoomActivated = function(____, _player, diceFloorSubType)
67
+ if ROLL_FLOOR_DICE_FLOOR_SUB_TYPES:has(diceFloorSubType) then
68
+ v.run.trackedCollectibles:clear()
69
+ end
51
70
  end
52
- local index = getMapIndex(nil, collectible)
53
- local trackedCollectibleType = v.room.trackedCollectibles:get(index)
54
- if trackedCollectibleType ~= nil and collectible.SubType ~= trackedCollectibleType then
55
- setCollectibleSubType(nil, collectible, trackedCollectibleType)
71
+ self.postPickupChanged = function(____, pickup, oldVariant, _oldSubType, newVariant, newSubType)
72
+ if oldVariant ~= PickupVariant.COLLECTIBLE or newVariant ~= PickupVariant.COLLECTIBLE then
73
+ return
74
+ end
75
+ if asCollectibleType(nil, newSubType) == CollectibleType.NULL then
76
+ return
77
+ end
78
+ local pickupIndex = self.pickupIndexCreation:getPickupIndex(pickup)
79
+ local trackedCollectibleType = v.run.trackedCollectibles:get(pickupIndex)
80
+ if trackedCollectibleType == nil then
81
+ return
82
+ end
83
+ local gameFrameCount = game:GetFrameCount()
84
+ if gameFrameCount == v.run.rollGameFrame then
85
+ v.run.trackedCollectibles:delete(pickupIndex)
86
+ return
87
+ end
88
+ if trackedCollectibleType ~= asCollectibleType(nil, newSubType) then
89
+ setCollectibleSubType(nil, pickup, trackedCollectibleType)
90
+ end
56
91
  end
92
+ self.featuresUsed = {ISCFeature.PICKUP_INDEX_CREATION}
93
+ self.callbacksUsed = {{ModCallback.POST_USE_CARD, self.postUseCardSoulOfIsaac, {CardType.SOUL_ISAAC}}, {ModCallback.PRE_USE_ITEM, self.preUseItem}}
94
+ self.customCallbacksUsed = {{ModCallbackCustom.POST_DICE_ROOM_ACTIVATED, self.postDiceRoomActivated}, {ModCallbackCustom.POST_PICKUP_CHANGED, self.postPickupChanged}}
95
+ self.pickupIndexCreation = pickupIndexCreation
57
96
  end
58
97
  function PreventCollectibleRotation.prototype.preventCollectibleRotation(self, collectible, collectibleType)
59
98
  if not isCollectible(nil, collectible) then
60
99
  local entityID = getEntityID(nil, collectible)
61
100
  error("The \"preventCollectibleRotate\" function was given a non-collectible: " .. entityID)
62
101
  end
63
- local index = getMapIndex(nil, collectible)
64
- v.room.trackedCollectibles:set(index, collectibleType)
65
- self:checkCollectibleRotated(collectible)
102
+ local pickupIndex = self.pickupIndexCreation:getPickupIndex(collectible)
103
+ v.run.trackedCollectibles:set(pickupIndex, collectibleType)
104
+ if collectible.SubType ~= collectibleType then
105
+ setCollectibleSubType(nil, collectible, collectibleType)
106
+ end
66
107
  end
67
108
  __TS__Decorate({Exported}, PreventCollectibleRotation.prototype, "preventCollectibleRotation", true)
68
109
  return ____exports