isaacscript-common 2.0.14 → 2.0.17

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,7 @@ local __TS__New = ____lualib.__TS__New
3
3
  local ____exports = {}
4
4
  local hasSubscriptions, postPEffectUpdateReordered, queueEmpty, queueNotEmpty, v
5
5
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
- local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
6
+ local ItemType = ____isaac_2Dtypescript_2Ddefinitions.ItemType
7
7
  local ____DefaultMap = require("classes.DefaultMap")
8
8
  local DefaultMap = ____DefaultMap.DefaultMap
9
9
  local ____ModCallbackCustom = require("enums.ModCallbackCustom")
@@ -36,7 +36,7 @@ function postPEffectUpdateReordered(self, player)
36
36
  end
37
37
  end
38
38
  function queueEmpty(self, player, pickingUpItem)
39
- if pickingUpItem.subType == CollectibleType.NULL then
39
+ if pickingUpItem.itemType == ItemType.NULL or pickingUpItem.subType == 0 then
40
40
  return
41
41
  end
42
42
  postItemPickupFire(nil, player, pickingUpItem)
@@ -44,7 +44,7 @@ function queueEmpty(self, player, pickingUpItem)
44
44
  end
45
45
  function queueNotEmpty(self, player, pickingUpItem)
46
46
  local queuedItem = player.QueuedItem.Item
47
- if queuedItem == nil then
47
+ if queuedItem == nil or queuedItem.Type == ItemType.NULL then
48
48
  return
49
49
  end
50
50
  if queuedItem.Type ~= pickingUpItem.itemType or queuedItem.ID ~= pickingUpItem.subType then
@@ -1,7 +1,11 @@
1
1
  import { CollectibleType, ItemType, TrinketType } from "isaac-typescript-definitions";
2
- import { PickingUpItem } from "../../types/PickingUpItem";
3
- export declare type PostItemPickupRegisterParameters = [
4
- callback: (player: EntityPlayer, pickingUpItem: PickingUpItem) => void,
5
- itemType?: ItemType,
6
- itemID?: CollectibleType | TrinketType
2
+ import { PickingUpItem, PickingUpItemCollectible, PickingUpItemTrinket } from "../../types/PickingUpItem";
3
+ export declare type PostItemPickupRegisterParameters = [callback: (player: EntityPlayer, pickingUpItem: PickingUpItem) => void] | [
4
+ callback: (player: EntityPlayer, pickingUpItem: PickingUpItemCollectible) => void,
5
+ itemType: ItemType.PASSIVE | ItemType.ACTIVE | ItemType.FAMILIAR,
6
+ collectibleType?: CollectibleType
7
+ ] | [
8
+ callback: (player: EntityPlayer, pickingUpItem: PickingUpItemTrinket) => void,
9
+ itemType: ItemType.TRINKET,
10
+ trinketType?: TrinketType
7
11
  ];
@@ -11,12 +11,12 @@ function ____exports.postItemPickupFire(self, player, pickingUpItem)
11
11
  for ____, ____value in ipairs(subscriptions) do
12
12
  local callback = ____value[1]
13
13
  local itemType = ____value[2]
14
- local itemID = ____value[3]
14
+ local subType = ____value[3]
15
15
  do
16
16
  if itemType ~= nil and itemType ~= pickingUpItem.itemType then
17
17
  goto __continue5
18
18
  end
19
- if itemID ~= nil and itemID ~= pickingUpItem.subType then
19
+ if subType ~= nil and subType ~= pickingUpItem.subType then
20
20
  goto __continue5
21
21
  end
22
22
  callback(nil, player, pickingUpItem)
@@ -1,7 +1,11 @@
1
1
  import { CollectibleType, ItemType, TrinketType } from "isaac-typescript-definitions";
2
- import { PickingUpItem } from "../../types/PickingUpItem";
3
- export declare type PreItemPickupRegisterParameters = [
4
- callback: (player: EntityPlayer, pickingUpItem: PickingUpItem) => void,
5
- itemType?: ItemType,
6
- itemID?: CollectibleType | TrinketType
2
+ import { PickingUpItem, PickingUpItemCollectible, PickingUpItemTrinket } from "../../types/PickingUpItem";
3
+ export declare type PreItemPickupRegisterParameters = [callback: (player: EntityPlayer, pickingUpItem: PickingUpItem) => void] | [
4
+ callback: (player: EntityPlayer, pickingUpItem: PickingUpItemCollectible) => void,
5
+ itemType: ItemType.PASSIVE | ItemType.ACTIVE | ItemType.FAMILIAR,
6
+ collectibleType?: CollectibleType
7
+ ] | [
8
+ callback: (player: EntityPlayer, pickingUpItem: PickingUpItemTrinket) => void,
9
+ itemType: ItemType.TRINKET,
10
+ trinketType?: TrinketType
7
11
  ];
@@ -11,12 +11,12 @@ function ____exports.preItemPickupFire(self, player, pickingUpItem)
11
11
  for ____, ____value in ipairs(subscriptions) do
12
12
  local callback = ____value[1]
13
13
  local itemType = ____value[2]
14
- local itemID = ____value[3]
14
+ local subType = ____value[3]
15
15
  do
16
16
  if itemType ~= nil and itemType ~= pickingUpItem.itemType then
17
17
  goto __continue5
18
18
  end
19
- if itemID ~= nil and itemID ~= pickingUpItem.subType then
19
+ if subType ~= nil and subType ~= pickingUpItem.subType then
20
20
  goto __continue5
21
21
  end
22
22
  callback(nil, player, pickingUpItem)
@@ -1,13 +1,12 @@
1
1
  local ____lualib = require("lualib_bundle")
2
- local Set = ____lualib.Set
3
2
  local __TS__New = ____lualib.__TS__New
3
+ local Set = ____lualib.Set
4
4
  local __TS__Iterator = ____lualib.__TS__Iterator
5
5
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
6
6
  local ____exports = {}
7
- local newPlayerInventory, useItemD4, postGameStarted, postItemPickup, addCollectibleToInventory, COLLECTIBLE_ITEM_TYPES, v
7
+ local newPlayerInventory, useItemD4, postGameStarted, postItemPickup, addCollectibleToInventory, v
8
8
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
9
9
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
10
- local ItemType = ____isaac_2Dtypescript_2Ddefinitions.ItemType
11
10
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
12
11
  local ____DefaultMap = require("classes.DefaultMap")
13
12
  local DefaultMap = ____DefaultMap.DefaultMap
@@ -27,6 +26,8 @@ local getAllPlayers = ____playerIndex.getAllPlayers
27
26
  local getPlayerIndex = ____playerIndex.getPlayerIndex
28
27
  local ____utils = require("functions.utils")
29
28
  local ____repeat = ____utils["repeat"]
29
+ local ____PickingUpItem = require("types.PickingUpItem")
30
+ local pickingUpItemIsCollectible = ____PickingUpItem.pickingUpItemIsCollectible
30
31
  local ____exports = require("features.saveDataManager.exports")
31
32
  local saveDataManager = ____exports.saveDataManager
32
33
  function newPlayerInventory(self, player)
@@ -59,7 +60,7 @@ function postGameStarted(self)
59
60
  end
60
61
  end
61
62
  function postItemPickup(self, player, pickingUpItem)
62
- if not COLLECTIBLE_ITEM_TYPES:has(pickingUpItem.itemType) then
63
+ if not pickingUpItemIsCollectible(nil, pickingUpItem) then
63
64
  return
64
65
  end
65
66
  addCollectibleToInventory(nil, player, pickingUpItem.subType)
@@ -83,7 +84,6 @@ function addCollectibleToInventory(self, player, collectibleType)
83
84
  end
84
85
  end
85
86
  local FEATURE_NAME = "player inventory tracker"
86
- COLLECTIBLE_ITEM_TYPES = __TS__New(Set, {ItemType.PASSIVE, ItemType.ACTIVE, ItemType.FAMILIAR})
87
87
  v = {run = {
88
88
  playersInventory = __TS__New(
89
89
  DefaultMap,
@@ -160,6 +160,13 @@ export declare function getPlayersOfType(...characters: PlayerType[]): EntityPla
160
160
  * check for. It only returns the players that have all of the collectibles.
161
161
  */
162
162
  export declare function getPlayersWithCollectible(...collectibleTypes: CollectibleType[]): EntityPlayer[];
163
+ /**
164
+ * Helper function to get only the players that have a certain trinket.
165
+ *
166
+ * This function is variadic, meaning that you can supply as many trinket types as you want to check
167
+ * for. It only returns the players that have all of the trinkets.
168
+ */
169
+ export declare function getPlayersWithTrinket(...trinketTypes: TrinketType[]): EntityPlayer[];
163
170
  /**
164
171
  * Helper function to determine how many heart containers that Tainted Magdalene has that will not
165
172
  * be automatically depleted over time. By default, this is 2, but this function will return 4 so
@@ -398,6 +398,17 @@ function ____exports.getPlayersWithCollectible(self, ...)
398
398
  ) end
399
399
  )
400
400
  end
401
+ function ____exports.getPlayersWithTrinket(self, ...)
402
+ local trinketTypes = {...}
403
+ local players = getPlayers(nil)
404
+ return __TS__ArrayFilter(
405
+ players,
406
+ function(____, player) return __TS__ArrayEvery(
407
+ trinketTypes,
408
+ function(____, trinketType) return player:HasTrinket(trinketType) end
409
+ ) end
410
+ )
411
+ end
401
412
  function ____exports.getTaintedMagdaleneNonTemporaryMaxHearts(self, player)
402
413
  local maxHearts = player:GetMaxHearts()
403
414
  local hasBirthright = player:HasCollectible(CollectibleType.BIRTHRIGHT)
@@ -516,9 +527,9 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
516
527
  itemPool:RemoveCollectible(collectibleType)
517
528
  end
518
529
  repeat
519
- local ____switch110 = activeSlot
520
- local ____cond110 = ____switch110 == ActiveSlot.PRIMARY
521
- if ____cond110 then
530
+ local ____switch113 = activeSlot
531
+ local ____cond113 = ____switch113 == ActiveSlot.PRIMARY
532
+ if ____cond113 then
522
533
  do
523
534
  if primaryCollectibleType ~= CollectibleType.NULL then
524
535
  player:RemoveCollectible(primaryCollectibleType)
@@ -527,8 +538,8 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
527
538
  break
528
539
  end
529
540
  end
530
- ____cond110 = ____cond110 or ____switch110 == ActiveSlot.SECONDARY
531
- if ____cond110 then
541
+ ____cond113 = ____cond113 or ____switch113 == ActiveSlot.SECONDARY
542
+ if ____cond113 then
532
543
  do
533
544
  if primaryCollectibleType ~= CollectibleType.NULL then
534
545
  player:RemoveCollectible(primaryCollectibleType)
@@ -543,16 +554,16 @@ function ____exports.setActiveItem(self, player, collectibleType, activeSlot, ch
543
554
  break
544
555
  end
545
556
  end
546
- ____cond110 = ____cond110 or ____switch110 == ActiveSlot.POCKET
547
- if ____cond110 then
557
+ ____cond113 = ____cond113 or ____switch113 == ActiveSlot.POCKET
558
+ if ____cond113 then
548
559
  do
549
560
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
550
561
  player:SetActiveCharge(charge, activeSlot)
551
562
  break
552
563
  end
553
564
  end
554
- ____cond110 = ____cond110 or ____switch110 == ActiveSlot.POCKET_SINGLE_USE
555
- if ____cond110 then
565
+ ____cond113 = ____cond113 or ____switch113 == ActiveSlot.POCKET_SINGLE_USE
566
+ if ____cond113 then
556
567
  do
557
568
  player:SetPocketActiveItem(collectibleType, activeSlot, keepInPools)
558
569
  break
@@ -1,9 +1,24 @@
1
1
  import { CollectibleType, ItemType, TrinketType } from "isaac-typescript-definitions";
2
- export interface PickingUpItem {
2
+ export declare type PickingUpItem = PickingUpItemNull | PickingUpItemCollectible | PickingUpItemTrinket;
3
+ export interface PickingUpItemNull {
3
4
  /** Needed so that we can distinguish between picking up a collectible and a trinket. */
4
- itemType: ItemType;
5
- /** Equal to either the collectible type or the trinket type. */
6
- subType: CollectibleType | TrinketType;
5
+ itemType: ItemType.NULL;
6
+ /** Equal to either the collectible type, the trinket type, or 0. */
7
+ subType: 0;
8
+ }
9
+ export interface PickingUpItemCollectible {
10
+ /** Needed so that we can distinguish between picking up a collectible and a trinket. */
11
+ itemType: ItemType.PASSIVE | ItemType.ACTIVE | ItemType.FAMILIAR;
12
+ /** Equal to either the collectible type, the trinket type, or 0. */
13
+ subType: CollectibleType;
14
+ }
15
+ export interface PickingUpItemTrinket {
16
+ /** Needed so that we can distinguish between picking up a collectible and a trinket. */
17
+ itemType: ItemType.TRINKET;
18
+ /** Equal to either the collectible type, the trinket type, or 0. */
19
+ subType: TrinketType;
7
20
  }
8
21
  export declare function newPickingUpItem(): PickingUpItem;
9
22
  export declare function resetPickingUpItem(pickingUpItem: PickingUpItem): void;
23
+ export declare function pickingUpItemIsCollectible(pickingUpItem: PickingUpItem): pickingUpItem is PickingUpItemCollectible;
24
+ export declare function pickingUpItemIsTrinket(pickingUpItem: PickingUpItem): pickingUpItem is PickingUpItemTrinket;
@@ -1,3 +1,6 @@
1
+ local ____lualib = require("lualib_bundle")
2
+ local Set = ____lualib.Set
3
+ local __TS__New = ____lualib.__TS__New
1
4
  local ____exports = {}
2
5
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
3
6
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
@@ -11,4 +14,11 @@ function ____exports.resetPickingUpItem(self, pickingUpItem)
11
14
  pickingUpItem.itemType = DEFAULT_ITEM_TYPE
12
15
  pickingUpItem.subType = DEFAULT_SUB_TYPE
13
16
  end
17
+ local COLLECTIBLE_ITEM_TYPES = __TS__New(Set, {ItemType.PASSIVE, ItemType.ACTIVE, ItemType.FAMILIAR})
18
+ function ____exports.pickingUpItemIsCollectible(self, pickingUpItem)
19
+ return COLLECTIBLE_ITEM_TYPES:has(pickingUpItem.itemType)
20
+ end
21
+ function ____exports.pickingUpItemIsTrinket(self, pickingUpItem)
22
+ return pickingUpItem.itemType == ItemType.TRINKET
23
+ end
14
24
  return ____exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "2.0.14",
3
+ "version": "2.0.17",
4
4
  "description": "Helper functions for IsaacScript mods",
5
5
  "keywords": [
6
6
  "isaac",
@@ -25,7 +25,7 @@
25
25
  "dist/**/*.d.ts"
26
26
  ],
27
27
  "dependencies": {
28
- "isaac-typescript-definitions": "^2.0.19"
28
+ "isaac-typescript-definitions": "^2.0.20"
29
29
  },
30
30
  "devDependencies": {
31
31
  "isaacscript-lint": "^1.0.150",