isaacscript-common 20.14.5 → 20.15.0

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.
package/dist/index.d.ts CHANGED
@@ -8025,8 +8025,14 @@ export declare function isTear(variable: unknown): variable is EntityTear;
8025
8025
  *
8026
8026
  * Note that this function does not work properly when the tear is from a Lead Pencil barrage. In
8027
8027
  * this case, it will always appear as if the tear is coming from a player.
8028
+ *
8029
+ * @param tear The tear to inspect.
8030
+ * @param familiarVariant Optional. Specify this to check if the tear came from a specific familiar
8031
+ * variant. Default is undefined, which checks for any familiar.
8032
+ * @param subType Optional. Specify this to check if the tear came from a specific familiar
8033
+ * sub-type. Default is undefined, which checks for any familiar.
8028
8034
  */
8029
- export declare function isTearFromFamiliar(tear: EntityTear): boolean;
8035
+ export declare function isTearFromFamiliar(tear: EntityTear, familiarVariant?: FamiliarVariant, subType?: int): boolean;
8030
8036
 
8031
8037
  /**
8032
8038
  * Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 20.14.5
3
+ isaacscript-common 20.15.0
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -35007,7 +35007,7 @@ function ____exports.addTearsStat(self, player, tearsStat)
35007
35007
  local newMaxFireDelay = ____exports.getFireDelay(nil, newTearsStat)
35008
35008
  player.MaxFireDelay = newMaxFireDelay
35009
35009
  end
35010
- function ____exports.isTearFromFamiliar(self, tear)
35010
+ function ____exports.isTearFromFamiliar(self, tear, familiarVariant, subType)
35011
35011
  if tear.FrameCount == 0 then
35012
35012
  error("Failed to check if the given tear was from a player since the tear's frame count was equal to 0. (The \"isTearFromFamiliar\" function must only be used in the \"POST_TEAR_INIT_VERY_LATE\" callback or on frame 1 and onwards.)")
35013
35013
  end
@@ -35015,7 +35015,10 @@ function ____exports.isTearFromFamiliar(self, tear)
35015
35015
  return false
35016
35016
  end
35017
35017
  local familiar = tear.SpawnerEntity:ToFamiliar()
35018
- return familiar ~= nil
35018
+ if familiar == nil then
35019
+ return false
35020
+ end
35021
+ return (familiarVariant == nil or familiarVariant == familiar.Variant) and (subType == nil or subType == familiar.SubType)
35019
35022
  end
35020
35023
  function ____exports.isTearFromPlayer(self, tear)
35021
35024
  if tear.FrameCount == 0 then
@@ -1,6 +1,4 @@
1
- /// <reference types="isaac-typescript-definitions" />
2
- /// <reference types="isaac-typescript-definitions" />
3
- /// <reference types="isaac-typescript-definitions" />
1
+ import { FamiliarVariant } from "isaac-typescript-definitions";
4
2
  /**
5
3
  * - Converts the specified amount of tears stat into the format of `EntityPlayer.MaxFireDelay` and
6
4
  * adds it to the player.
@@ -46,8 +44,14 @@ export declare function getTearsStat(fireDelay: float): float;
46
44
  *
47
45
  * Note that this function does not work properly when the tear is from a Lead Pencil barrage. In
48
46
  * this case, it will always appear as if the tear is coming from a player.
47
+ *
48
+ * @param tear The tear to inspect.
49
+ * @param familiarVariant Optional. Specify this to check if the tear came from a specific familiar
50
+ * variant. Default is undefined, which checks for any familiar.
51
+ * @param subType Optional. Specify this to check if the tear came from a specific familiar
52
+ * sub-type. Default is undefined, which checks for any familiar.
49
53
  */
50
- export declare function isTearFromFamiliar(tear: EntityTear): boolean;
54
+ export declare function isTearFromFamiliar(tear: EntityTear, familiarVariant?: FamiliarVariant, subType?: int): boolean;
51
55
  /**
52
56
  * Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
53
57
  * is determined by looking at the parent.
@@ -1 +1 @@
1
- {"version":3,"file":"tears.d.ts","sourceRoot":"","sources":["../../../src/functions/tears.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,CAKzE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,KAAK,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,KAAK,CAEpD;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kBAAkB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAgB5D;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAgB1D"}
1
+ {"version":3,"file":"tears.d.ts","sourceRoot":"","sources":["../../../src/functions/tears.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAE/D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,YAAY,EAAE,SAAS,EAAE,KAAK,GAAG,IAAI,CAKzE;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,KAAK,CAEpD;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,SAAS,EAAE,KAAK,GAAG,KAAK,CAEpD;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,kBAAkB,CAChC,IAAI,EAAE,UAAU,EAChB,eAAe,CAAC,EAAE,eAAe,EACjC,OAAO,CAAC,EAAE,GAAG,GACZ,OAAO,CAuBT;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,UAAU,GAAG,OAAO,CAgB1D"}
@@ -46,7 +46,13 @@ end
46
46
  --
47
47
  -- Note that this function does not work properly when the tear is from a Lead Pencil barrage. In
48
48
  -- this case, it will always appear as if the tear is coming from a player.
49
- function ____exports.isTearFromFamiliar(self, tear)
49
+ --
50
+ -- @param tear The tear to inspect.
51
+ -- @param familiarVariant Optional. Specify this to check if the tear came from a specific familiar
52
+ -- variant. Default is undefined, which checks for any familiar.
53
+ -- @param subType Optional. Specify this to check if the tear came from a specific familiar
54
+ -- sub-type. Default is undefined, which checks for any familiar.
55
+ function ____exports.isTearFromFamiliar(self, tear, familiarVariant, subType)
50
56
  if tear.FrameCount == 0 then
51
57
  error("Failed to check if the given tear was from a player since the tear's frame count was equal to 0. (The \"isTearFromFamiliar\" function must only be used in the \"POST_TEAR_INIT_VERY_LATE\" callback or on frame 1 and onwards.)")
52
58
  end
@@ -54,7 +60,10 @@ function ____exports.isTearFromFamiliar(self, tear)
54
60
  return false
55
61
  end
56
62
  local familiar = tear.SpawnerEntity:ToFamiliar()
57
- return familiar ~= nil
63
+ if familiar == nil then
64
+ return false
65
+ end
66
+ return (familiarVariant == nil or familiarVariant == familiar.Variant) and (subType == nil or subType == familiar.SubType)
58
67
  end
59
68
  --- Helper function to check if a given tear is from a player (as opposed to e.g. a familiar). This
60
69
  -- is determined by looking at the parent.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "20.14.5",
3
+ "version": "20.15.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -1,3 +1,5 @@
1
+ import { FamiliarVariant } from "isaac-typescript-definitions";
2
+
1
3
  /**
2
4
  * - Converts the specified amount of tears stat into the format of `EntityPlayer.MaxFireDelay` and
3
5
  * adds it to the player.
@@ -55,8 +57,18 @@ export function getTearsStat(fireDelay: float): float {
55
57
  *
56
58
  * Note that this function does not work properly when the tear is from a Lead Pencil barrage. In
57
59
  * this case, it will always appear as if the tear is coming from a player.
60
+ *
61
+ * @param tear The tear to inspect.
62
+ * @param familiarVariant Optional. Specify this to check if the tear came from a specific familiar
63
+ * variant. Default is undefined, which checks for any familiar.
64
+ * @param subType Optional. Specify this to check if the tear came from a specific familiar
65
+ * sub-type. Default is undefined, which checks for any familiar.
58
66
  */
59
- export function isTearFromFamiliar(tear: EntityTear): boolean {
67
+ export function isTearFromFamiliar(
68
+ tear: EntityTear,
69
+ familiarVariant?: FamiliarVariant,
70
+ subType?: int,
71
+ ): boolean {
60
72
  if (tear.FrameCount === 0) {
61
73
  error(
62
74
  'Failed to check if the given tear was from a player since the tear\'s frame count was equal to 0. (The "isTearFromFamiliar" function must only be used in the "POST_TEAR_INIT_VERY_LATE" callback or on frame 1 and onwards.)',
@@ -71,7 +83,14 @@ export function isTearFromFamiliar(tear: EntityTear): boolean {
71
83
  // We cannot use `tear.SpawnerType` to determine this, since it is baked in to be equal to
72
84
  // `EntityType.PLAYER` regardless of whether the tear is from a player or familiar.
73
85
  const familiar = tear.SpawnerEntity.ToFamiliar();
74
- return familiar !== undefined;
86
+ if (familiar === undefined) {
87
+ return false;
88
+ }
89
+
90
+ return (
91
+ (familiarVariant === undefined || familiarVariant === familiar.Variant) &&
92
+ (subType === undefined || subType === familiar.SubType)
93
+ );
75
94
  }
76
95
 
77
96
  /**