isaacscript-common 2.0.31 → 2.0.32

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.
@@ -15,8 +15,11 @@ local VANILLA_COLLECTIBLES_SET = __TS__New(Set)
15
15
  local MODDED_COLLECTIBLES_SET = __TS__New(Set)
16
16
  local function initCollectibleSets(self)
17
17
  for ____, collectibleType in ipairs(getCollectibleTypeRange(nil)) do
18
- local itemConfigItem = itemConfig:GetCollectible(collectibleType)
19
- if itemConfigItem ~= nil then
18
+ do
19
+ local itemConfigItem = itemConfig:GetCollectible(collectibleType)
20
+ if itemConfigItem == nil then
21
+ goto __continue3
22
+ end
20
23
  ALL_COLLECTIBLES_SET:add(collectibleType)
21
24
  if collectibleType <= LAST_VANILLA_COLLECTIBLE_TYPE then
22
25
  VANILLA_COLLECTIBLES_SET:add(collectibleType)
@@ -24,6 +27,7 @@ local function initCollectibleSets(self)
24
27
  MODDED_COLLECTIBLES_SET:add(collectibleType)
25
28
  end
26
29
  end
30
+ ::__continue3::
27
31
  end
28
32
  end
29
33
  function ____exports.getCollectibleSet(self)
@@ -142,6 +142,12 @@ export declare function isBlindCollectible(collectible: EntityPickup): boolean;
142
142
  * in secret rooms and I AM ERROR rooms if the "Corrupted Data" achievement is unlocked.
143
143
  */
144
144
  export declare function isGlitchedCollectible(pickup: EntityPickup): boolean;
145
+ /**
146
+ * Returns true if the collectible has the "Hidden" attribute in the item config.
147
+ *
148
+ * Hidden collectibles will not show up in any pools and Eden will not start with them.
149
+ */
150
+ export declare function isHiddenCollectible(collectibleType: CollectibleType): boolean;
145
151
  /**
146
152
  * Returns true if the item type in the item config is equal to `ItemType.ITEM_PASSIVE` or
147
153
  * `ItemType.ITEM_FAMILIAR`.
@@ -216,6 +216,10 @@ end
216
216
  function ____exports.isGlitchedCollectible(self, pickup)
217
217
  return pickup.Variant == PickupVariant.COLLECTIBLE and pickup.SubType > GLITCHED_ITEM_THRESHOLD
218
218
  end
219
+ function ____exports.isHiddenCollectible(self, collectibleType)
220
+ local itemConfigItem = itemConfig:GetCollectible(collectibleType)
221
+ return itemConfigItem ~= nil and itemConfigItem.Hidden
222
+ end
219
223
  function ____exports.isPassiveCollectible(self, collectibleType)
220
224
  local itemType = ____exports.getCollectibleItemType(nil, collectibleType)
221
225
  return itemType == ItemType.PASSIVE or itemType == ItemType.FAMILIAR
@@ -0,0 +1,3 @@
1
+ import { CollectibleType } from "isaac-typescript-definitions";
2
+ export declare function getEdenPassives(): Set<CollectibleType>;
3
+ export declare function getRandomEdenPassive(seedOrRNG?: Seed | RNG, exceptions?: CollectibleType[] | readonly CollectibleType[]): CollectibleType;
@@ -0,0 +1,47 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
4
+ local __TS__Iterator = ____lualib.__TS__Iterator
5
+ local ____exports = {}
6
+ local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
+ local ItemConfigTag = ____isaac_2Dtypescript_2Ddefinitions.ItemConfigTag
8
+ local ____collectibles = require("functions.collectibles")
9
+ local isHiddenCollectible = ____collectibles.isHiddenCollectible
10
+ local isPassiveCollectible = ____collectibles.isPassiveCollectible
11
+ local ____collectibleSet = require("functions.collectibleSet")
12
+ local getCollectibleSet = ____collectibleSet.getCollectibleSet
13
+ local ____collectibleTag = require("functions.collectibleTag")
14
+ local collectibleHasTag = ____collectibleTag.collectibleHasTag
15
+ local ____rng = require("functions.rng")
16
+ local getRandomSeed = ____rng.getRandomSeed
17
+ local ____set = require("functions.set")
18
+ local copySet = ____set.copySet
19
+ local getRandomSetElement = ____set.getRandomSetElement
20
+ local EDEN_PASSIVE_COLLECTIBLES_SET = __TS__New(Set)
21
+ local function initCollectibleSet(self)
22
+ local collectibleSet = getCollectibleSet(nil)
23
+ for ____, collectibleType in __TS__Iterator(collectibleSet:values()) do
24
+ if isPassiveCollectible(nil, collectibleType) and not isHiddenCollectible(nil, collectibleType) and not collectibleHasTag(nil, collectibleType, ItemConfigTag.NO_EDEN) then
25
+ EDEN_PASSIVE_COLLECTIBLES_SET:add(collectibleType)
26
+ end
27
+ end
28
+ end
29
+ function ____exports.getEdenPassives(self)
30
+ if EDEN_PASSIVE_COLLECTIBLES_SET.size == 0 then
31
+ initCollectibleSet(nil)
32
+ end
33
+ return copySet(nil, EDEN_PASSIVE_COLLECTIBLES_SET)
34
+ end
35
+ function ____exports.getRandomEdenPassive(self, seedOrRNG, exceptions)
36
+ if seedOrRNG == nil then
37
+ seedOrRNG = getRandomSeed(nil)
38
+ end
39
+ if exceptions == nil then
40
+ exceptions = {}
41
+ end
42
+ if EDEN_PASSIVE_COLLECTIBLES_SET.size == 0 then
43
+ initCollectibleSet(nil)
44
+ end
45
+ return getRandomSetElement(nil, EDEN_PASSIVE_COLLECTIBLES_SET, seedOrRNG, exceptions)
46
+ end
47
+ return ____exports
@@ -25,11 +25,8 @@ local DEFAULT_PILL_EFFECT_TYPE = ____pillEffectTypes.DEFAULT_PILL_EFFECT_TYPE
25
25
  local PILL_EFFECT_TYPES = ____pillEffectTypes.PILL_EFFECT_TYPES
26
26
  local ____enums = require("functions.enums")
27
27
  local getEnumValues = ____enums.getEnumValues
28
- local ____flag = require("functions.flag")
29
- local hasFlag = ____flag.hasFlag
30
28
  local ____utils = require("functions.utils")
31
29
  local irange = ____utils.irange
32
- local HORSE_PILL_FLAG = 2047
33
30
  local HORSE_PILL_ADJUSTMENT = 2048
34
31
  function ____exports.getAllPillColors(self)
35
32
  local pillColors = getEnumValues(nil, PillColor)
@@ -81,6 +78,6 @@ function ____exports.getVanillaPillEffects(self)
81
78
  return irange(nil, FIRST_PILL_EFFECT, LAST_VANILLA_PILL_EFFECT)
82
79
  end
83
80
  function ____exports.isHorsePill(self, pillColor)
84
- return hasFlag(nil, pillColor, HORSE_PILL_FLAG)
81
+ return pillColor > HORSE_PILL_ADJUSTMENT
85
82
  end
86
83
  return ____exports
@@ -28,7 +28,6 @@ local ____sprite = require("functions.sprite")
28
28
  local clearSprite = ____sprite.clearSprite
29
29
  local ____utils = require("functions.utils")
30
30
  local irange = ____utils.irange
31
- local GOLDEN_TRINKET_FLAG = 32767
32
31
  local GOLDEN_TRINKET_ADJUSTMENT = 32768
33
32
  local TRINKET_SPRITE_LAYER = 0
34
33
  function ____exports.getGoldenTrinketType(self, trinketType)
@@ -91,7 +90,7 @@ function ____exports.hasOpenTrinketSlot(self, player)
91
90
  return openTrinketSlot ~= nil
92
91
  end
93
92
  function ____exports.isGoldenTrinket(self, trinketType)
94
- return hasFlag(nil, trinketType, GOLDEN_TRINKET_FLAG)
93
+ return trinketType > GOLDEN_TRINKET_ADJUSTMENT
95
94
  end
96
95
  function ____exports.setTrinketSprite(self, trinket, pngPath)
97
96
  if not isTrinket(nil, trinket) then
package/dist/index.d.ts CHANGED
@@ -48,6 +48,7 @@ export { deepCopyTests } from "./functions/deepCopyTests";
48
48
  export * from "./functions/direction";
49
49
  export * from "./functions/doors";
50
50
  export * from "./functions/easing";
51
+ export * from "./functions/eden";
51
52
  export * from "./functions/entity";
52
53
  export * from "./functions/entitySpecific";
53
54
  export * from "./functions/entityTypes";
package/dist/index.lua CHANGED
@@ -397,6 +397,14 @@ do
397
397
  end
398
398
  end
399
399
  end
400
+ do
401
+ local ____export = require("functions.eden")
402
+ for ____exportKey, ____exportValue in pairs(____export) do
403
+ if ____exportKey ~= "default" then
404
+ ____exports[____exportKey] = ____exportValue
405
+ end
406
+ end
407
+ end
400
408
  do
401
409
  local ____export = require("functions.entity")
402
410
  for ____exportKey, ____exportValue in pairs(____export) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "2.0.31",
3
+ "version": "2.0.32",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",