isaacscript-common 1.2.164 → 1.2.165

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.
@@ -3,7 +3,9 @@ local ____lualib = require("lualib_bundle")
3
3
  local Map = ____lualib.Map
4
4
  local __TS__New = ____lualib.__TS__New
5
5
  local ____exports = {}
6
- local useCardSoulOfIsaac, postPickupUpdateCollectible, v
6
+ local useCardSoulOfIsaac, postPickupUpdateCollectible, getMapIndex, v
7
+ local ____cachedClasses = require("cachedClasses")
8
+ local game = ____cachedClasses.game
7
9
  local ____featuresInitialized = require("featuresInitialized")
8
10
  local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNotInitialized
9
11
  local ____collectibles = require("functions.collectibles")
@@ -11,20 +13,25 @@ local setCollectibleSubType = ____collectibles.setCollectibleSubType
11
13
  local ____exports = require("features.saveDataManager.exports")
12
14
  local saveDataManager = ____exports.saveDataManager
13
15
  function useCardSoulOfIsaac(self)
14
- v.room.trackedItems:clear()
16
+ v.room.trackedCollectibles:clear()
15
17
  end
16
- function postPickupUpdateCollectible(self, pickup)
17
- if pickup.SubType == CollectibleType.COLLECTIBLE_NULL then
18
+ function postPickupUpdateCollectible(self, collectible)
19
+ if collectible.SubType == CollectibleType.COLLECTIBLE_NULL then
18
20
  return
19
21
  end
20
- local ptrHash = GetPtrHash(pickup)
21
- local trackedCollectibleType = v.room.trackedItems:get(ptrHash)
22
- if trackedCollectibleType ~= nil and pickup.SubType ~= trackedCollectibleType then
23
- setCollectibleSubType(nil, pickup, trackedCollectibleType)
22
+ local index = getMapIndex(nil, collectible)
23
+ local trackedCollectibleType = v.room.trackedCollectibles:get(index)
24
+ if trackedCollectibleType ~= nil and collectible.SubType ~= trackedCollectibleType then
25
+ setCollectibleSubType(nil, collectible, trackedCollectibleType)
24
26
  end
25
27
  end
28
+ function getMapIndex(self, collectible)
29
+ local room = game:GetRoom()
30
+ local gridIndex = room:GetGridIndex(collectible.Position)
31
+ return (tostring(gridIndex) .. ",") .. tostring(collectible.InitSeed)
32
+ end
26
33
  local FEATURE_NAME = "prevent collectible rotation"
27
- v = {room = {trackedItems = __TS__New(Map)}}
34
+ v = {room = {trackedCollectibles = __TS__New(Map)}}
28
35
  function ____exports.preventCollectibleRotateInit(self, mod)
29
36
  saveDataManager(nil, "preventCollectibleRotate", v)
30
37
  mod:AddCallback(ModCallbacks.MC_USE_CARD, useCardSoulOfIsaac, Card.CARD_SOUL_ISAAC)
@@ -35,8 +42,8 @@ function ____exports.preventCollectibleRotate(self, collectible, collectibleType
35
42
  if collectible.Variant ~= PickupVariant.PICKUP_COLLECTIBLE then
36
43
  error("You cannot prevent the rotation for pickups of variant: " .. tostring(collectible.Variant))
37
44
  end
38
- local ptrHash = GetPtrHash(collectible)
39
- v.room.trackedItems:set(ptrHash, collectibleType)
45
+ local index = getMapIndex(nil, collectible)
46
+ v.room.trackedCollectibles:set(index, collectibleType)
40
47
  postPickupUpdateCollectible(nil, collectible)
41
48
  end
42
49
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "1.2.164",
3
+ "version": "1.2.165",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "devDependencies": {
28
28
  "@zamiell/typescript-to-lua": "^1.4.2",
29
- "isaac-typescript-definitions": "^1.0.369",
29
+ "isaac-typescript-definitions": "^1.0.370",
30
30
  "isaacscript-lint": "^1.0.90",
31
31
  "isaacscript-tsconfig": "^1.1.8",
32
32
  "typedoc": "^0.22.13",