isaacscript-common 35.0.0 → 35.0.1

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.
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 35.0.0
3
+ isaacscript-common 35.0.1
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -30382,8 +30382,6 @@ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
30382
30382
  local ____exports = {}
30383
30383
  local ____isaac_2Dtypescript_2Ddefinitions = require("lua_modules.isaac-typescript-definitions.dist.src.index")
30384
30384
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
30385
- local ____shouldFire = require("src.shouldFire")
30386
- local shouldFirePickup = ____shouldFire.shouldFirePickup
30387
30385
  local ____CustomCallback = require("src.classes.private.CustomCallback")
30388
30386
  local CustomCallback = ____CustomCallback.CustomCallback
30389
30387
  ____exports.PostPickupSelectionFilter = __TS__Class()
@@ -30392,7 +30390,11 @@ PostPickupSelectionFilter.name = "PostPickupSelectionFilter"
30392
30390
  __TS__ClassExtends(PostPickupSelectionFilter, CustomCallback)
30393
30391
  function PostPickupSelectionFilter.prototype.____constructor(self)
30394
30392
  CustomCallback.prototype.____constructor(self)
30395
- self.shouldFire = shouldFirePickup
30393
+ self.shouldFire = function(____, fireArgs, optionalArgs)
30394
+ local _pickup, pickupVariant, subType = table.unpack(fireArgs)
30395
+ local callbackPickupVariant, callbackPickupSubType = table.unpack(optionalArgs)
30396
+ return (callbackPickupVariant == nil or callbackPickupVariant == pickupVariant) and (callbackPickupSubType == nil or callbackPickupSubType == subType)
30397
+ end
30396
30398
  self.postPickupSelection = function(____, pickup, variant, subType) return self:fire(pickup, variant, subType) end
30397
30399
  self.callbacksUsed = {{ModCallback.POST_PICKUP_SELECTION, self.postPickupSelection}}
30398
30400
  end
@@ -1,9 +1,16 @@
1
+ import type { PickupVariant } from "isaac-typescript-definitions";
1
2
  import type { ModCallbackCustom } from "../../enums/ModCallbackCustom";
2
- import { shouldFirePickup } from "../../shouldFire";
3
3
  import { CustomCallback } from "../private/CustomCallback";
4
- export declare class PostPickupSelectionFilter extends CustomCallback<ModCallbackCustom.POST_PICKUP_SELECTION_FILTER> {
4
+ type T = ModCallbackCustom.POST_PICKUP_SELECTION_FILTER;
5
+ export declare class PostPickupSelectionFilter extends CustomCallback<T> {
5
6
  constructor();
6
- protected shouldFire: typeof shouldFirePickup;
7
+ /**
8
+ * We cannot use the `shouldFirePickup` helper function because in the case of non-collectibles,
9
+ * `EntityPickup.Type` and `EntityPickup.Variant` and `EntityPickup.SubType` will all be set to 0
10
+ * in this callback.
11
+ */
12
+ protected shouldFire: (fireArgs: [pickup: EntityPickup, variant: PickupVariant, subType: int], optionalArgs: [pickupVariant?: PickupVariant | undefined, subType?: int | undefined]) => boolean;
7
13
  private readonly postPickupSelection;
8
14
  }
15
+ export {};
9
16
  //# sourceMappingURL=PostPickupSelectionFilter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"PostPickupSelectionFilter.d.ts","sourceRoot":"","sources":["../../../../src/classes/callbacks/PostPickupSelectionFilter.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,qBAAa,yBAA0B,SAAQ,cAAc,CAAC,iBAAiB,CAAC,4BAA4B,CAAC;;IAU3G,UAAmB,UAAU,0BAAoB;IAGjD,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAIuC;CAC5E"}
1
+ {"version":3,"file":"PostPickupSelectionFilter.d.ts","sourceRoot":"","sources":["../../../../src/classes/callbacks/PostPickupSelectionFilter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAElE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,+BAA+B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAE3D,KAAK,CAAC,GAAG,iBAAiB,CAAC,4BAA4B,CAAC;AAExD,qBAAa,yBAA0B,SAAQ,cAAc,CAAC,CAAC,CAAC;;IAU9D;;;;OAIG;IACH,UAAmB,UAAU,oKAG1B,OAAO,CASR;IAGF,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAIuC;CAC5E"}
@@ -4,8 +4,6 @@ local __TS__ClassExtends = ____lualib.__TS__ClassExtends
4
4
  local ____exports = {}
5
5
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
6
6
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
7
- local ____shouldFire = require("src.shouldFire")
8
- local shouldFirePickup = ____shouldFire.shouldFirePickup
9
7
  local ____CustomCallback = require("src.classes.private.CustomCallback")
10
8
  local CustomCallback = ____CustomCallback.CustomCallback
11
9
  ____exports.PostPickupSelectionFilter = __TS__Class()
@@ -14,7 +12,11 @@ PostPickupSelectionFilter.name = "PostPickupSelectionFilter"
14
12
  __TS__ClassExtends(PostPickupSelectionFilter, CustomCallback)
15
13
  function PostPickupSelectionFilter.prototype.____constructor(self)
16
14
  CustomCallback.prototype.____constructor(self)
17
- self.shouldFire = shouldFirePickup
15
+ self.shouldFire = function(____, fireArgs, optionalArgs)
16
+ local _pickup, pickupVariant, subType = table.unpack(fireArgs)
17
+ local callbackPickupVariant, callbackPickupSubType = table.unpack(optionalArgs)
18
+ return (callbackPickupVariant == nil or callbackPickupVariant == pickupVariant) and (callbackPickupSubType == nil or callbackPickupSubType == subType)
19
+ end
18
20
  self.postPickupSelection = function(____, pickup, variant, subType) return self:fire(pickup, variant, subType) end
19
21
  self.callbacksUsed = {{ModCallback.POST_PICKUP_SELECTION, self.postPickupSelection}}
20
22
  end
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "35.0.0",
3
+ "version": "35.0.1",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -1,10 +1,12 @@
1
1
  import type { PickupVariant } from "isaac-typescript-definitions";
2
2
  import { ModCallback } from "isaac-typescript-definitions";
3
3
  import type { ModCallbackCustom } from "../../enums/ModCallbackCustom";
4
- import { shouldFirePickup } from "../../shouldFire";
4
+ import type { FireArgs, OptionalArgs } from "../private/CustomCallback";
5
5
  import { CustomCallback } from "../private/CustomCallback";
6
6
 
7
- export class PostPickupSelectionFilter extends CustomCallback<ModCallbackCustom.POST_PICKUP_SELECTION_FILTER> {
7
+ type T = ModCallbackCustom.POST_PICKUP_SELECTION_FILTER;
8
+
9
+ export class PostPickupSelectionFilter extends CustomCallback<T> {
8
10
  constructor() {
9
11
  super();
10
12
 
@@ -14,7 +16,24 @@ export class PostPickupSelectionFilter extends CustomCallback<ModCallbackCustom.
14
16
  ];
15
17
  }
16
18
 
17
- protected override shouldFire = shouldFirePickup;
19
+ /**
20
+ * We cannot use the `shouldFirePickup` helper function because in the case of non-collectibles,
21
+ * `EntityPickup.Type` and `EntityPickup.Variant` and `EntityPickup.SubType` will all be set to 0
22
+ * in this callback.
23
+ */
24
+ protected override shouldFire = (
25
+ fireArgs: FireArgs<T>,
26
+ optionalArgs: OptionalArgs<T>,
27
+ ): boolean => {
28
+ const [_pickup, pickupVariant, subType] = fireArgs;
29
+ const [callbackPickupVariant, callbackPickupSubType] = optionalArgs;
30
+
31
+ return (
32
+ (callbackPickupVariant === undefined ||
33
+ callbackPickupVariant === pickupVariant) &&
34
+ (callbackPickupSubType === undefined || callbackPickupSubType === subType)
35
+ );
36
+ };
18
37
 
19
38
  // ModCallback.POST_PICKUP_SELECTION (37)
20
39
  private readonly postPickupSelection = (