isaacscript-common 20.14.4 → 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.4
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
@@ -42257,6 +42260,7 @@ function getRoomTypeMap(self, customStageLua)
42257
42260
  end
42258
42261
  return roomTypeMap
42259
42262
  end
42263
+ local MUSIC_DELAY_RENDER_FRAMES = 70
42260
42264
  ____exports.CustomStages = __TS__Class()
42261
42265
  local CustomStages = ____exports.CustomStages
42262
42266
  CustomStages.name = "CustomStages"
@@ -42497,10 +42501,13 @@ function CustomStages.prototype.setCustomStage(self, name, firstFloor, streakTex
42497
42501
  end)
42498
42502
  end
42499
42503
  local music = customStage.music == nil and getMusicForStage(nil, baseStage, baseStageType) or Isaac.GetMusicIdByName(customStage.music)
42500
- self.runInNFrames:runNextRenderFrame(function()
42501
- musicManager:Enable()
42502
- musicManager:Crossfade(music)
42503
- end)
42504
+ self.runInNFrames:runInNRenderFrames(
42505
+ function()
42506
+ musicManager:Enable()
42507
+ musicManager:Crossfade(music)
42508
+ end,
42509
+ MUSIC_DELAY_RENDER_FRAMES
42510
+ )
42504
42511
  end
42505
42512
  function CustomStages.prototype.disableCustomStage(self)
42506
42513
  self.v.run.currentCustomStage = nil
@@ -1 +1 @@
1
- {"version":3,"file":"CustomStages.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/CustomStages.ts"],"names":[],"mappings":"AAyCA,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAoChD,qBAAa,YAAa,SAAQ,OAAO;IA8BvC,oCAAoC;IACpC,OAAO,CAAC,eAAe,CAAkC;IAEzD,+BAA+B;IAC/B,OAAO,CAAC,yBAAyB,CAAwC;IAEzE,OAAO,CAAC,kBAAkB,CAAqB;IAC/C,OAAO,CAAC,eAAe,CAA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C,eAAe,CAarB;IAGF,OAAO,CAAC,UAAU,CAQhB;IAGF,OAAO,CAAC,aAAa,CAcnB;IAGF,OAAO,CAAC,eAAe,CAUrB;IAIF,OAAO,CAAC,2BAA2B,CAejC;IAGF,OAAO,CAAC,kBAAkB,CAqBxB;IAGF,OAAO,CAAC,oBAAoB,CAe1B;IAEF,gDAAgD;IAChD,OAAO,CAAC,iBAAiB;IA+FzB;;;;;;;;;;;;;;;;OAgBG;IAEI,cAAc,CACnB,IAAI,EAAE,MAAM,EACZ,UAAU,UAAO,EACjB,UAAU,UAAO,EACjB,OAAO,UAAQ,GACd,IAAI;IAuFP;;;;;OAKG;IAEI,kBAAkB,IAAI,IAAI;CAGlC"}
@@ -102,6 +102,9 @@ function getRoomTypeMap(self, customStageLua)
102
102
  end
103
103
  return roomTypeMap
104
104
  end
105
+ --- 60 does not work correctly (the music kicking in from stage -1 will mute it), so we use 70 to be
106
+ -- safe.
107
+ local MUSIC_DELAY_RENDER_FRAMES = 70
105
108
  ____exports.CustomStages = __TS__Class()
106
109
  local CustomStages = ____exports.CustomStages
107
110
  CustomStages.name = "CustomStages"
@@ -342,10 +345,13 @@ function CustomStages.prototype.setCustomStage(self, name, firstFloor, streakTex
342
345
  end)
343
346
  end
344
347
  local music = customStage.music == nil and getMusicForStage(nil, baseStage, baseStageType) or Isaac.GetMusicIdByName(customStage.music)
345
- self.runInNFrames:runNextRenderFrame(function()
346
- musicManager:Enable()
347
- musicManager:Crossfade(music)
348
- end)
348
+ self.runInNFrames:runInNRenderFrames(
349
+ function()
350
+ musicManager:Enable()
351
+ musicManager:Crossfade(music)
352
+ end,
353
+ MUSIC_DELAY_RENDER_FRAMES
354
+ )
349
355
  end
350
356
  function CustomStages.prototype.disableCustomStage(self)
351
357
  self.v.run.currentCustomStage = nil
@@ -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.4",
3
+ "version": "20.15.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -22,6 +22,6 @@
22
22
  "main": "dist/src/index",
23
23
  "types": "dist/src/index.d.ts",
24
24
  "dependencies": {
25
- "isaac-typescript-definitions": "^11.0.2"
25
+ "isaac-typescript-definitions": "^11.0.3"
26
26
  }
27
27
  }
@@ -75,6 +75,12 @@ import { DisableAllSound } from "./DisableAllSound";
75
75
  import { Pause } from "./Pause";
76
76
  import { RunInNFrames } from "./RunInNFrames";
77
77
 
78
+ /**
79
+ * 60 does not work correctly (the music kicking in from stage -1 will mute it), so we use 70 to be
80
+ * safe.
81
+ */
82
+ const MUSIC_DELAY_RENDER_FRAMES = 70;
83
+
78
84
  export class CustomStages extends Feature {
79
85
  /** @internal */
80
86
  public override v = {
@@ -507,12 +513,13 @@ export class CustomStages extends Feature {
507
513
  customStage.music === undefined
508
514
  ? getMusicForStage(baseStage, baseStageType)
509
515
  : Isaac.GetMusicIdByName(customStage.music);
510
- this.runInNFrames.runNextRenderFrame(() => {
516
+
517
+ this.runInNFrames.runInNRenderFrames(() => {
511
518
  // By default, the `MusicManager.Play` method will play the music at max volume (1.0), which
512
519
  // is around twice as loud as the vanilla music plays.
513
520
  musicManager.Enable();
514
521
  musicManager.Crossfade(music);
515
- });
522
+ }, MUSIC_DELAY_RENDER_FRAMES);
516
523
 
517
524
  // We must reload the current room in order for the `Level.SetStage` method to take effect.
518
525
  // Furthermore, we need to cancel the queued warp to the `GridRoom.DEBUG` room. We can
@@ -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
  /**