isaacscript-common 59.4.1 → 59.6.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.
Files changed (51) hide show
  1. package/dist/index.rollup.d.ts +110 -1
  2. package/dist/isaacscript-common.lua +182 -58
  3. package/dist/src/classes/ModUpgraded.d.ts.map +1 -1
  4. package/dist/src/classes/ModUpgraded.lua +2 -2
  5. package/dist/src/classes/callbacks/PostCursedTeleport.d.ts.map +1 -1
  6. package/dist/src/classes/callbacks/PostCursedTeleport.lua +3 -2
  7. package/dist/src/classes/callbacks/PostItemDischarge.d.ts.map +1 -1
  8. package/dist/src/classes/callbacks/PostPickupInitFirst.d.ts.map +1 -1
  9. package/dist/src/classes/callbacks/PostPickupInitFirst.lua +3 -5
  10. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.d.ts.map +1 -1
  11. package/dist/src/classes/features/callbackLogic/GameReorderedCallbacks.lua +5 -5
  12. package/dist/src/classes/features/other/CustomTrapdoors.d.ts.map +1 -1
  13. package/dist/src/classes/features/other/CustomTrapdoors.lua +10 -12
  14. package/dist/src/classes/features/other/PickupIndexCreation.d.ts.map +1 -1
  15. package/dist/src/classes/features/other/PickupIndexCreation.lua +3 -2
  16. package/dist/src/classes/features/other/PreventCollectibleRotation.d.ts.map +1 -1
  17. package/dist/src/classes/features/other/PreventCollectibleRotation.lua +3 -2
  18. package/dist/src/classes/features/other/SaveDataManager.d.ts.map +1 -1
  19. package/dist/src/classes/features/other/SaveDataManager.lua +3 -4
  20. package/dist/src/classes/features/other/customStages/streakText.d.ts.map +1 -1
  21. package/dist/src/classes/features/other/customStages/streakText.lua +6 -5
  22. package/dist/src/functions/debugFunctions.d.ts +7 -1
  23. package/dist/src/functions/debugFunctions.d.ts.map +1 -1
  24. package/dist/src/functions/debugFunctions.lua +22 -16
  25. package/dist/src/functions/frames.d.ts +68 -0
  26. package/dist/src/functions/frames.d.ts.map +1 -0
  27. package/dist/src/functions/frames.lua +119 -0
  28. package/dist/src/functions/gridEntities.d.ts +22 -0
  29. package/dist/src/functions/gridEntities.d.ts.map +1 -1
  30. package/dist/src/functions/gridEntities.lua +40 -11
  31. package/dist/src/functions/revive.d.ts.map +1 -1
  32. package/dist/src/functions/revive.lua +3 -4
  33. package/dist/src/index.d.ts +1 -0
  34. package/dist/src/index.d.ts.map +1 -1
  35. package/dist/src/index.lua +8 -0
  36. package/package.json +1 -1
  37. package/src/classes/ModUpgraded.ts +2 -3
  38. package/src/classes/callbacks/PostCursedTeleport.ts +2 -2
  39. package/src/classes/callbacks/PostItemDischarge.ts +2 -0
  40. package/src/classes/callbacks/PostPickupInitFirst.ts +2 -4
  41. package/src/classes/features/callbackLogic/GameReorderedCallbacks.ts +4 -6
  42. package/src/classes/features/other/CustomTrapdoors.ts +11 -14
  43. package/src/classes/features/other/PickupIndexCreation.ts +2 -2
  44. package/src/classes/features/other/PreventCollectibleRotation.ts +2 -3
  45. package/src/classes/features/other/SaveDataManager.ts +2 -3
  46. package/src/classes/features/other/customStages/streakText.ts +10 -6
  47. package/src/functions/debugFunctions.ts +10 -1
  48. package/src/functions/frames.ts +172 -0
  49. package/src/functions/gridEntities.ts +59 -13
  50. package/src/functions/revive.ts +2 -3
  51. package/src/index.ts +1 -0
@@ -340,6 +340,25 @@ function getRockPNGName(self)
340
340
  end
341
341
  until true
342
342
  end
343
+ --- Helper function to get the grid indexes on the surrounding tiles from the provided grid index.
344
+ --
345
+ -- There are always 8 grid indexes returned (e.g. top-left + top + top-right + left + right +
346
+ -- bottom-left + bottom + right), even if the computed values would be negative or otherwise
347
+ -- invalid.
348
+ function ____exports.getSurroundingGridIndexes(self, gridIndex)
349
+ local room = game:GetRoom()
350
+ local gridWidth = room:GetGridWidth()
351
+ return {
352
+ gridIndex - gridWidth - 1,
353
+ gridIndex - gridWidth,
354
+ gridIndex - gridWidth + 1,
355
+ gridIndex - 1,
356
+ gridIndex + 1,
357
+ gridIndex + gridWidth - 1,
358
+ gridIndex + gridWidth,
359
+ gridIndex + gridWidth + 1
360
+ }
361
+ end
343
362
  --- Helper function to get the grid index of the top left wall. (This will depend on what the current
344
363
  -- room shape is.)
345
364
  --
@@ -683,18 +702,8 @@ end
683
702
  -- rocks (e.g. top-left + top + top-right + left + right + bottom-left + bottom + right).
684
703
  function ____exports.getSurroundingGridEntities(self, gridEntity)
685
704
  local room = game:GetRoom()
686
- local gridWidth = room:GetGridWidth()
687
705
  local gridIndex = gridEntity:GetGridIndex()
688
- local surroundingGridIndexes = {
689
- gridIndex - 1,
690
- gridIndex + 1,
691
- gridIndex - gridWidth - 1,
692
- gridIndex - gridWidth,
693
- gridIndex - gridWidth + 1,
694
- gridIndex + gridWidth - 1,
695
- gridIndex + gridWidth,
696
- gridIndex + gridWidth + 1
697
- }
706
+ local surroundingGridIndexes = ____exports.getSurroundingGridIndexes(nil, gridIndex)
698
707
  local surroundingGridEntities = {}
699
708
  for ____, surroundingGridIndex in ipairs(surroundingGridIndexes) do
700
709
  local surroundingGridEntity = room:GetGridEntity(surroundingGridIndex)
@@ -737,6 +746,26 @@ end
737
746
  function ____exports.isGridEntityXMLType(self, num)
738
747
  return GRID_ENTITY_XML_TYPES_SET:has(num)
739
748
  end
749
+ --- Helper function to check if the provided grid index has a door on it or if the surrounding 8 grid
750
+ -- indexes have a door on it.
751
+ function ____exports.isGridIndexAdjacentToDoor(self, gridIndex)
752
+ local room = game:GetRoom()
753
+ local surroundingGridIndexes = ____exports.getSurroundingGridIndexes(nil, gridIndex)
754
+ local gridIndexes = {
755
+ gridIndex,
756
+ table.unpack(surroundingGridIndexes)
757
+ }
758
+ for ____, gridIndexToInspect in ipairs(gridIndexes) do
759
+ local gridEntity = room:GetGridEntity(gridIndexToInspect)
760
+ if gridEntity ~= nil then
761
+ local door = gridEntity:ToDoor()
762
+ if door ~= nil then
763
+ return true
764
+ end
765
+ end
766
+ end
767
+ return false
768
+ end
740
769
  --- Helper function to see if a `GridEntityXMLType` is some kind of poop.
741
770
  function ____exports.isPoopGridEntityXMLType(self, gridEntityXMLType)
742
771
  return POOP_GRID_ENTITY_XML_TYPES_SET:has(gridEntityXMLType)
@@ -1 +1 @@
1
- {"version":3,"file":"revive.d.ts","sourceRoot":"","sources":["../../../src/functions/revive.ts"],"names":[],"mappings":";;;AAoBA;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,SAAS,EACjB,mBAAmB,EAAE,GAAG,GAAG,SAAS,GACnC,OAAO,CAuFT;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAmBvE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAa9D;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAYtE;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAe1E"}
1
+ {"version":3,"file":"revive.d.ts","sourceRoot":"","sources":["../../../src/functions/revive.ts"],"names":[],"mappings":";;;AAoBA;;;GAGG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,MAAM,EAAE,GAAG,EACX,MAAM,EAAE,SAAS,EACjB,mBAAmB,EAAE,GAAG,GAAG,SAAS,GACnC,OAAO,CAsFT;AAED;;;;;;;GAOG;AACH,wBAAgB,yBAAyB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAmBvE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAa9D;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAYtE;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAe1E"}
@@ -5,8 +5,6 @@ local EntityType = ____isaac_2Dtypescript_2Ddefinitions.EntityType
5
5
  local NullItemID = ____isaac_2Dtypescript_2Ddefinitions.NullItemID
6
6
  local PlayerType = ____isaac_2Dtypescript_2Ddefinitions.PlayerType
7
7
  local TrinketType = ____isaac_2Dtypescript_2Ddefinitions.TrinketType
8
- local ____cachedClasses = require("src.core.cachedClasses")
9
- local game = ____cachedClasses.game
10
8
  local ____constants = require("src.core.constants")
11
9
  local MAX_TAINTED_SAMSON_BERSERK_CHARGE = ____constants.MAX_TAINTED_SAMSON_BERSERK_CHARGE
12
10
  local TAINTED_SAMSON_BERSERK_CHARGE_FROM_TAKING_DAMAGE = ____constants.TAINTED_SAMSON_BERSERK_CHARGE_FROM_TAKING_DAMAGE
@@ -14,6 +12,8 @@ local ____MysteriousPaperEffect = require("src.enums.MysteriousPaperEffect")
14
12
  local MysteriousPaperEffect = ____MysteriousPaperEffect.MysteriousPaperEffect
15
13
  local ____characters = require("src.functions.characters")
16
14
  local getCharacterDeathAnimationName = ____characters.getCharacterDeathAnimationName
15
+ local ____frames = require("src.functions.frames")
16
+ local onGameFrame = ____frames.onGameFrame
17
17
  local ____playerHealth = require("src.functions.playerHealth")
18
18
  local getPlayerMaxHeartContainers = ____playerHealth.getPlayerMaxHeartContainers
19
19
  local ____players = require("src.functions.players")
@@ -54,7 +54,6 @@ end
54
54
  --- Uses the player's current health and other miscellaneous things to determine if incoming damage
55
55
  -- will be fatal.
56
56
  function ____exports.isDamageToPlayerFatal(self, player, amount, source, lastDamageGameFrame)
57
- local gameFrameCount = game:GetFrameCount()
58
57
  local character = player:GetPlayerType()
59
58
  local effects = player:GetEffects()
60
59
  local isBerserk = effects:HasCollectibleEffect(CollectibleType.BERSERK)
@@ -84,7 +83,7 @@ function ____exports.isDamageToPlayerFatal(self, player, amount, source, lastDam
84
83
  if ____exports.willReviveFromHeartbreak(nil, player) then
85
84
  return false
86
85
  end
87
- if player:HasCollectible(CollectibleType.BROKEN_GLASS_CANNON) and gameFrameCount == lastDamageGameFrame then
86
+ if player:HasCollectible(CollectibleType.BROKEN_GLASS_CANNON) and onGameFrame(nil, lastDamageGameFrame) then
88
87
  return false
89
88
  end
90
89
  local hearts = player:GetHearts()
@@ -54,6 +54,7 @@ export * from "./functions/enums";
54
54
  export * from "./functions/external";
55
55
  export * from "./functions/familiars";
56
56
  export * from "./functions/flag";
57
+ export * from "./functions/frames";
57
58
  export * from "./functions/globals";
58
59
  export * from "./functions/gridEntities";
59
60
  export * from "./functions/gridEntitiesSpecific";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,sBAAsB,CAAC;AACrC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC;AACjC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,yBAAyB,CAAC;AACxC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,oBAAoB,CAAC;AACnC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC;AAC1C,cAAc,+BAA+B,CAAC;AAC9C,cAAc,oBAAoB,CAAC;AACnC,cAAc,wBAAwB,CAAC;AACvC,cAAc,qBAAqB,CAAC;AACpC,cAAc,qBAAqB,CAAC;AACpC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,sBAAsB,CAAC;AACrC,cAAc,uBAAuB,CAAC;AACtC,cAAc,uBAAuB,CAAC;AACtC,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,wBAAwB,C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;AACtC,cAAc,sBAAsB,CAAC;AACrC,cAAc,kBAAkB,CAAC"}
@@ -447,6 +447,14 @@ do
447
447
  end
448
448
  end
449
449
  end
450
+ do
451
+ local ____export = require("src.functions.frames")
452
+ for ____exportKey, ____exportValue in pairs(____export) do
453
+ if ____exportKey ~= "default" then
454
+ ____exports[____exportKey] = ____exportValue
455
+ end
456
+ end
457
+ end
450
458
  do
451
459
  local ____export = require("src.functions.globals")
452
460
  for ____exportKey, ____exportValue in pairs(____export) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "59.4.1",
3
+ "version": "59.6.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -5,7 +5,7 @@ import { EXPORTED_METHOD_NAMES_KEY } from "../decorators";
5
5
  import { ISCFeature } from "../enums/ISCFeature";
6
6
  import { ModCallbackCustom } from "../enums/ModCallbackCustom";
7
7
  import { getFeatures } from "../features";
8
- import { getTime } from "../functions/debugFunctions";
8
+ import { getElapsedTimeSince, getTime } from "../functions/debugFunctions";
9
9
  import { getParentFunctionDescription, log } from "../functions/log";
10
10
  import {
11
11
  getTSTLClassConstructor,
@@ -116,8 +116,7 @@ export class ModUpgraded implements Mod {
116
116
  // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, n/no-callback-literal
117
117
  const returnValue = callback(...callbackArgs);
118
118
 
119
- const endTime = getTime();
120
- const elapsedTime = endTime - startTime;
119
+ const elapsedTime = getElapsedTimeSince(startTime);
121
120
  if (
122
121
  this.timeThreshold === undefined ||
123
122
  this.timeThreshold <= elapsedTime
@@ -8,6 +8,7 @@ import {
8
8
  import { game } from "../../core/cachedClasses";
9
9
  import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
10
10
  import { hasFlag } from "../../functions/flag";
11
+ import { onGameFrame } from "../../functions/frames";
11
12
  import {
12
13
  mapGetPlayer,
13
14
  mapSetPlayer,
@@ -146,8 +147,7 @@ export class PostCursedTeleport extends CustomCallback<ModCallbackCustom.POST_CU
146
147
  lastDamageFrame: int,
147
148
  ) {
148
149
  // Check to see if this is the frame that we last took damage.
149
- const gameFrameCount = game.GetFrameCount();
150
- if (gameFrameCount !== lastDamageFrame) {
150
+ if (!onGameFrame(lastDamageFrame)) {
151
151
  return false;
152
152
  }
153
153
 
@@ -172,8 +172,10 @@ export class PostItemDischarge extends CustomCallback<T> {
172
172
  v.room.playersBulbLastCollisionFrame,
173
173
  player,
174
174
  );
175
+
175
176
  const collidedOnThisFrame = gameFrameCount === bulbLastCollisionFrame;
176
177
  const collidedOnLastFrame = gameFrameCount - 1 === bulbLastCollisionFrame;
178
+
177
179
  return collidedOnThisFrame || collidedOnLastFrame;
178
180
  }
179
181
  }
@@ -1,6 +1,6 @@
1
1
  import { ModCallback } from "isaac-typescript-definitions";
2
- import { game } from "../../core/cachedClasses";
3
2
  import type { ModCallbackCustom } from "../../enums/ModCallbackCustom";
3
+ import { isPastRoomFrame } from "../../functions/frames";
4
4
  import { getRoomVisitedCount } from "../../functions/roomData";
5
5
  import { shouldFirePickup } from "../../shouldFire";
6
6
  import { CustomCallback } from "../private/CustomCallback";
@@ -25,13 +25,11 @@ export class PostPickupInitFirst extends CustomCallback<ModCallbackCustom.POST_P
25
25
 
26
26
  // ModCallback.POST_PICKUP_INIT (34)
27
27
  private readonly postPickupInit = (pickup: EntityPickup) => {
28
- const room = game.GetRoom();
29
- const roomFrameCount = room.GetFrameCount();
30
28
  const roomVisitedCount = getRoomVisitedCount();
31
29
 
32
30
  // The room visited count is not reset when re-entering a Treasure Room or Boss room in the
33
31
  // Ascent.
34
- if (roomFrameCount > 0 || roomVisitedCount === 0) {
32
+ if (isPastRoomFrame(0) || roomVisitedCount === 0) {
35
33
  this.fire(pickup);
36
34
  }
37
35
  };
@@ -2,6 +2,7 @@ import type { LevelStage, StageType } from "isaac-typescript-definitions";
2
2
  import { CollectibleType, ModCallback } from "isaac-typescript-definitions";
3
3
  import { game } from "../../../core/cachedClasses";
4
4
  import { Exported } from "../../../decorators";
5
+ import { onGameFrame, onRenderFrame } from "../../../functions/frames";
5
6
  import type { PostGameStartedReordered } from "../../callbacks/PostGameStartedReordered";
6
7
  import type { PostGameStartedReorderedLast } from "../../callbacks/PostGameStartedReorderedLast";
7
8
  import type { PostNewLevelReordered } from "../../callbacks/PostNewLevelReordered";
@@ -123,14 +124,13 @@ export class GameReorderedCallbacks extends Feature {
123
124
 
124
125
  // ModCallback.POST_NEW_LEVEL (18)
125
126
  private readonly postNewLevel = (): void => {
126
- const gameFrameCount = game.GetFrameCount();
127
127
  const level = game.GetLevel();
128
128
  const stage = level.GetStage();
129
129
  const stageType = level.GetStageType();
130
130
  const room = game.GetRoom();
131
131
  const roomType = room.GetType();
132
132
 
133
- if (gameFrameCount === 0 && !this.forceNewLevel) {
133
+ if (onGameFrame(0) && !this.forceNewLevel) {
134
134
  // Wait for the `POST_GAME_STARTED` callback to fire.
135
135
  return;
136
136
  }
@@ -143,13 +143,11 @@ export class GameReorderedCallbacks extends Feature {
143
143
 
144
144
  // ModCallback.POST_NEW_ROOM (19)
145
145
  private readonly postNewRoom = (): void => {
146
- const gameFrameCount = game.GetFrameCount();
147
146
  const level = game.GetLevel();
148
147
  const stage = level.GetStage();
149
148
  const stageType = level.GetStageType();
150
149
  const room = game.GetRoom();
151
150
  const roomType = room.GetType();
152
- const renderFrameCount = Isaac.GetFrameCount();
153
151
 
154
152
  if (this.usedGlowingHourGlass) {
155
153
  this.usedGlowingHourGlass = false;
@@ -166,8 +164,8 @@ export class GameReorderedCallbacks extends Feature {
166
164
  }
167
165
 
168
166
  if (
169
- (gameFrameCount === 0 ||
170
- renderFrameCount === this.renderFrameRunStarted ||
167
+ (onGameFrame(0) ||
168
+ onRenderFrame(this.renderFrameRunStarted) ||
171
169
  this.currentStage !== stage ||
172
170
  this.currentStageType !== stageType) &&
173
171
  !this.forceNewRoom
@@ -21,6 +21,10 @@ import { GridEntityTypeCustom } from "../../../enums/private/GridEntityTypeCusto
21
21
  import { StageTravelState } from "../../../enums/private/StageTravelState";
22
22
  import { TrapdoorAnimation } from "../../../enums/private/TrapdoorAnimation";
23
23
  import { easeOutSine } from "../../../functions/easing";
24
+ import {
25
+ isPastRoomFrame,
26
+ onOrPastRenderFrame,
27
+ } from "../../../functions/frames";
24
28
  import { log } from "../../../functions/log";
25
29
  import { movePlayersToCenter } from "../../../functions/playerCenter";
26
30
  import {
@@ -218,12 +222,9 @@ export class CustomTrapdoors extends Feature {
218
222
  return;
219
223
  }
220
224
 
221
- const hud = game.GetHUD();
222
- const renderFrameCount = Isaac.GetFrameCount();
223
-
224
225
  const renderFrameScreenBlack =
225
226
  v.run.stateRenderFrame + PIXELATION_TO_BLACK_FRAMES;
226
- if (renderFrameCount < renderFrameScreenBlack) {
227
+ if (!onOrPastRenderFrame(renderFrameScreenBlack)) {
227
228
  return;
228
229
  }
229
230
 
@@ -232,6 +233,7 @@ export class CustomTrapdoors extends Feature {
232
233
 
233
234
  // Now, we display a black sprite on top of the pixelation effect, to prevent showing the rest
234
235
  // of the animation.
236
+ const hud = game.GetHUD();
235
237
  hud.SetVisible(false);
236
238
 
237
239
  // If the pixelation effect is not fully allowed to complete, the game's internal buffer will
@@ -313,18 +315,16 @@ export class CustomTrapdoors extends Feature {
313
315
  return;
314
316
  }
315
317
 
316
- const hud = game.GetHUD();
317
- const renderFrameCount = Isaac.GetFrameCount();
318
-
319
318
  const renderFrameScreenBlack =
320
319
  v.run.stateRenderFrame + PIXELATION_TO_BLACK_FRAMES;
321
- if (renderFrameCount < renderFrameScreenBlack) {
320
+ if (!onOrPastRenderFrame(renderFrameScreenBlack)) {
322
321
  return;
323
322
  }
324
323
 
325
324
  v.run.state = StageTravelState.PIXELATION_TO_ROOM;
326
325
  this.logStateChanged();
327
326
 
327
+ const hud = game.GetHUD();
328
328
  hud.SetVisible(true);
329
329
 
330
330
  this.runNextRoom.runNextRoom(() => {
@@ -439,7 +439,6 @@ export class CustomTrapdoors extends Feature {
439
439
  }
440
440
 
441
441
  private isPlayerCloseAfterBoss(position: Vector) {
442
- const gameFrameCount = game.GetFrameCount();
443
442
  const room = game.GetRoom();
444
443
  const roomType = room.GetType();
445
444
  const roomClearGameFrame = this.roomClearFrame.getRoomClearGameFrame();
@@ -449,7 +448,7 @@ export class CustomTrapdoors extends Feature {
449
448
  if (
450
449
  roomType !== RoomType.BOSS ||
451
450
  roomClearGameFrame === undefined ||
452
- gameFrameCount >= roomClearGameFrame + TRAPDOOR_BOSS_REACTION_FRAMES
451
+ onOrPastRenderFrame(roomClearGameFrame + TRAPDOOR_BOSS_REACTION_FRAMES)
453
452
  ) {
454
453
  return false;
455
454
  }
@@ -627,7 +626,6 @@ export class CustomTrapdoors extends Feature {
627
626
  firstSpawn: boolean,
628
627
  ): boolean {
629
628
  const room = game.GetRoom();
630
- const roomFrameCount = room.GetFrameCount();
631
629
  const roomClear = room.IsClear();
632
630
 
633
631
  // Trapdoors created after a room has already initialized should spawn closed by default:
@@ -635,7 +633,7 @@ export class CustomTrapdoors extends Feature {
635
633
  // into them.
636
634
  // - Trapdoors created by We Need to Go Deeper should spawn closed because the player will be
637
635
  // standing on top of them.
638
- if (roomFrameCount > 0) {
636
+ if (isPastRoomFrame(0)) {
639
637
  return false;
640
638
  }
641
639
 
@@ -762,7 +760,6 @@ export class CustomTrapdoors extends Feature {
762
760
  }
763
761
 
764
762
  const room = game.GetRoom();
765
- const roomFrameCount = room.GetFrameCount();
766
763
  const roomListIndex = getRoomListIndex();
767
764
  const gridIndex = isVector(gridIndexOrPosition)
768
765
  ? room.GetGridIndex(gridIndexOrPosition)
@@ -776,7 +773,7 @@ export class CustomTrapdoors extends Feature {
776
773
  TrapdoorAnimation.OPENED,
777
774
  );
778
775
 
779
- const firstSpawn = roomFrameCount !== 0;
776
+ const firstSpawn = isPastRoomFrame(0);
780
777
  const open =
781
778
  spawnOpen ?? this.shouldTrapdoorSpawnOpen(gridEntity, firstSpawn);
782
779
 
@@ -7,6 +7,7 @@ import { game } from "../../../core/cachedClasses";
7
7
  import { Exported } from "../../../decorators";
8
8
  import { ISCFeature } from "../../../enums/ISCFeature";
9
9
  import { getEntityID } from "../../../functions/entities";
10
+ import { isPastRoomFrame } from "../../../functions/frames";
10
11
  import { getRoomListIndex } from "../../../functions/roomData";
11
12
  import { onAscent } from "../../../functions/stage";
12
13
  import { vectorEquals } from "../../../functions/vector";
@@ -93,11 +94,10 @@ export class PickupIndexCreation extends Feature {
93
94
  this.getPickupIndexFromPreviousData(pickup);
94
95
  const room = game.GetRoom();
95
96
  const isFirstVisit = room.IsFirstVisit();
96
- const roomFrameCount = room.GetFrameCount();
97
97
  if (
98
98
  pickupIndexFromLevelData !== undefined &&
99
99
  !isFirstVisit &&
100
- roomFrameCount <= 0
100
+ !isPastRoomFrame(0)
101
101
  ) {
102
102
  v.room.pickupIndexes.set(ptrHash, pickupIndexFromLevelData);
103
103
  return;
@@ -11,6 +11,7 @@ import { ISCFeature } from "../../../enums/ISCFeature";
11
11
  import { ModCallbackCustom } from "../../../enums/ModCallbackCustom";
12
12
  import { setCollectibleSubType } from "../../../functions/collectibles";
13
13
  import { getEntityID } from "../../../functions/entities";
14
+ import { onGameFrame } from "../../../functions/frames";
14
15
  import { isCollectible } from "../../../functions/pickupVariants";
15
16
  import { getCollectibles } from "../../../functions/pickupsSpecific";
16
17
  import { asCollectibleType } from "../../../functions/types";
@@ -142,11 +143,9 @@ export class PreventCollectibleRotation extends Feature {
142
143
  }
143
144
 
144
145
  // It can take a frame after the activation of the D6 for the sub-type to change.
145
- const gameFrameCount = game.GetFrameCount();
146
146
  if (
147
147
  v.run.rollGameFrame !== null &&
148
- (gameFrameCount === v.run.rollGameFrame ||
149
- gameFrameCount === v.run.rollGameFrame + 1)
148
+ (onGameFrame(v.run.rollGameFrame) || onGameFrame(v.run.rollGameFrame + 1))
150
149
  ) {
151
150
  v.run.trackedCollectibles.delete(pickupIndex);
152
151
  return;
@@ -1,11 +1,11 @@
1
1
  import type { ActiveSlot, UseFlag } from "isaac-typescript-definitions";
2
2
  import { CollectibleType, ModCallback } from "isaac-typescript-definitions";
3
- import { game } from "../../../core/cachedClasses";
4
3
  import { Exported } from "../../../decorators";
5
4
  import { ModCallbackCustom } from "../../../enums/ModCallbackCustom";
6
5
  import { SaveDataKey } from "../../../enums/SaveDataKey";
7
6
  import { SerializationType } from "../../../enums/SerializationType";
8
7
  import { deepCopy } from "../../../functions/deepCopy";
8
+ import { isPastGameFrame } from "../../../functions/frames";
9
9
  import { log } from "../../../functions/log";
10
10
  import { onFirstFloor } from "../../../functions/stage";
11
11
  import { getTSTLClassName, isTSTLClass } from "../../../functions/tstlClass";
@@ -145,8 +145,7 @@ export class SaveDataManager extends Feature {
145
145
  // data that is not tied to an individual run.
146
146
  loadFromDisk(this.mod, this.saveDataMap, this.classConstructors);
147
147
 
148
- const gameFrameCount = game.GetFrameCount();
149
- const isContinued = gameFrameCount !== 0;
148
+ const isContinued = isPastGameFrame(0);
150
149
  if (!isContinued) {
151
150
  restoreDefaultsForAllFeaturesAndKeys(
152
151
  this.saveDataMap,
@@ -3,6 +3,10 @@ import { CONTROLLER_INDEX_VALUES } from "../../../../arrays/cachedEnumValues";
3
3
  import { fonts, game } from "../../../../core/cachedClasses";
4
4
  import { KColorDefault, VectorOne } from "../../../../core/constants";
5
5
  import { UIStreakAnimation } from "../../../../enums/private/UIStreakAnimation";
6
+ import {
7
+ getElapsedGameFramesSince,
8
+ getElapsedRenderFramesSince,
9
+ } from "../../../../functions/frames";
6
10
  import {
7
11
  getScreenBottomCenterPos,
8
12
  getScreenTopCenterPos,
@@ -102,9 +106,9 @@ function checkEndTopStreakText() {
102
106
  return;
103
107
  }
104
108
 
105
- const renderFrameCount = Isaac.GetFrameCount();
106
- const elapsedFrames =
107
- renderFrameCount - v.run.topStreakTextStartedRenderFrame;
109
+ const elapsedFrames = getElapsedRenderFramesSince(
110
+ v.run.topStreakTextStartedRenderFrame,
111
+ );
108
112
  if (elapsedFrames >= 115) {
109
113
  v.run.topStreakText.animation = UIStreakAnimation.TEXT;
110
114
  // We adjust by the frame backwards by an arbitrary amount to roughly align with the speed of
@@ -114,8 +118,9 @@ function checkEndTopStreakText() {
114
118
  }
115
119
 
116
120
  function trackMapInputPressed() {
121
+ const gameFrameCount = game.GetFrameCount();
122
+
117
123
  for (const controllerIndex of CONTROLLER_INDEX_VALUES) {
118
- const gameFrameCount = game.GetFrameCount();
119
124
  const oldPushedMapFrame =
120
125
  v.run.controllerIndexPushingMapRenderFrame.get(controllerIndex);
121
126
  const isPushingMap = Input.IsActionPressed(
@@ -153,8 +158,7 @@ function checkStartBottomStreakText() {
153
158
  }
154
159
 
155
160
  const earliestFrame = Math.min(...pushedMapFrames);
156
- const gameFrameCount = game.GetFrameCount();
157
- const elapsedFrames = gameFrameCount - earliestFrame;
161
+ const elapsedFrames = getElapsedGameFramesSince(earliestFrame);
158
162
  if (elapsedFrames >= NUM_RENDER_FRAMES_MAP_HELD_BEFORE_STREAK_TEXT) {
159
163
  v.run.bottomStreakText.animation = UIStreakAnimation.TEXT;
160
164
  v.run.bottomStreakText.frame = 0;
@@ -1,5 +1,14 @@
1
1
  import { log } from "./log";
2
2
 
3
+ /**
4
+ * Helper function to get the amount of elapsed time for benchmarking / profiling purposes.
5
+ *
6
+ * For more information, see the documentation for the `getTime` helper function.
7
+ */
8
+ export function getElapsedTimeSince(time: int | float): int {
9
+ return getTime() - time;
10
+ }
11
+
3
12
  /**
4
13
  * Helper function to get the current time for benchmarking / profiling purposes.
5
14
  *
@@ -18,7 +27,7 @@ import { log } from "./log";
18
27
  * Default is true. If set to false, the `Isaac.GetTime()` method will
19
28
  * always be used.
20
29
  */
21
- export function getTime(useSocketIfAvailable = true): float {
30
+ export function getTime(useSocketIfAvailable = true): int | float {
22
31
  if (useSocketIfAvailable) {
23
32
  if (SandboxGetTime !== undefined) {
24
33
  return SandboxGetTime();