isaacscript-common 21.2.0 → 21.3.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 (105) hide show
  1. package/dist/index.d.ts +174 -88
  2. package/dist/isaacscript-common.lua +529 -448
  3. package/dist/src/arrays/cachedEnumValues.d.ts +24 -0
  4. package/dist/src/arrays/cachedEnumValues.d.ts.map +1 -0
  5. package/dist/src/arrays/cachedEnumValues.lua +46 -0
  6. package/dist/src/callbackClasses.d.ts +1 -0
  7. package/dist/src/callbackClasses.d.ts.map +1 -1
  8. package/dist/src/callbackClasses.lua +5 -0
  9. package/dist/src/callbacks.d.ts +66 -65
  10. package/dist/src/callbacks.d.ts.map +1 -1
  11. package/dist/src/callbacks.lua +1 -0
  12. package/dist/src/classes/callbacks/PostItemDischarge.d.ts.map +1 -1
  13. package/dist/src/classes/callbacks/PostItemDischarge.lua +3 -4
  14. package/dist/src/classes/callbacks/PostKeyboardPressed.d.ts +14 -0
  15. package/dist/src/classes/callbacks/PostKeyboardPressed.d.ts.map +1 -0
  16. package/dist/src/classes/callbacks/PostKeyboardPressed.lua +49 -0
  17. package/dist/src/classes/callbacks/PostPlayerChangeHealth.d.ts.map +1 -1
  18. package/dist/src/classes/callbacks/PostPlayerChangeHealth.lua +3 -5
  19. package/dist/src/classes/callbacks/PostPlayerChangeStat.d.ts.map +1 -1
  20. package/dist/src/classes/callbacks/PostPlayerChangeStat.lua +3 -5
  21. package/dist/src/classes/callbacks/PostTransformation.d.ts.map +1 -1
  22. package/dist/src/classes/callbacks/PostTransformation.lua +3 -5
  23. package/dist/src/classes/features/callbackLogic/PlayerCollectibleDetection.lua +3 -4
  24. package/dist/src/classes/features/other/CustomStages.d.ts.map +1 -1
  25. package/dist/src/classes/features/other/DebugDisplay.d.ts +91 -19
  26. package/dist/src/classes/features/other/DebugDisplay.d.ts.map +1 -1
  27. package/dist/src/classes/features/other/DebugDisplay.lua +42 -38
  28. package/dist/src/classes/features/other/DeployJSONRoom.d.ts.map +1 -1
  29. package/dist/src/classes/features/other/DeployJSONRoom.lua +3 -5
  30. package/dist/src/classes/features/other/ExtraConsoleCommands.d.ts.map +1 -1
  31. package/dist/src/classes/features/other/ExtraConsoleCommands.lua +0 -1
  32. package/dist/src/classes/features/other/ModdedElementSets.d.ts.map +1 -1
  33. package/dist/src/classes/features/other/ModdedElementSets.lua +9 -7
  34. package/dist/src/classes/features/other/customStages/streakText.d.ts.map +1 -1
  35. package/dist/src/classes/features/other/customStages/streakText.lua +3 -4
  36. package/dist/src/classes/features/other/extraConsoleCommands/commands.d.ts.map +1 -1
  37. package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +5 -7
  38. package/dist/src/enums/ModCallbackCustom.d.ts +74 -65
  39. package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
  40. package/dist/src/enums/ModCallbackCustom.lua +67 -65
  41. package/dist/src/functions/doors.d.ts.map +1 -1
  42. package/dist/src/functions/doors.lua +5 -6
  43. package/dist/src/functions/input.d.ts.map +1 -1
  44. package/dist/src/functions/input.lua +4 -6
  45. package/dist/src/functions/level.d.ts.map +1 -1
  46. package/dist/src/functions/level.lua +3 -5
  47. package/dist/src/functions/pills.d.ts.map +1 -1
  48. package/dist/src/functions/pills.lua +3 -5
  49. package/dist/src/functions/playerHealth.d.ts.map +1 -1
  50. package/dist/src/functions/playerHealth.lua +3 -4
  51. package/dist/src/functions/players.d.ts.map +1 -1
  52. package/dist/src/functions/players.lua +6 -7
  53. package/dist/src/functions/pocketItems.d.ts.map +1 -1
  54. package/dist/src/functions/pocketItems.lua +3 -5
  55. package/dist/src/functions/roomData.d.ts +1 -1
  56. package/dist/src/functions/roomData.d.ts.map +1 -1
  57. package/dist/src/functions/roomData.lua +3 -6
  58. package/dist/src/functions/roomShapeWalls.lua +3 -3
  59. package/dist/src/functions/serialization.lua +3 -6
  60. package/dist/src/functions/sound.d.ts.map +1 -1
  61. package/dist/src/functions/sound.lua +3 -3
  62. package/dist/src/functions/transformations.d.ts.map +1 -1
  63. package/dist/src/functions/transformations.lua +4 -5
  64. package/dist/src/index.d.ts +1 -0
  65. package/dist/src/index.d.ts.map +1 -1
  66. package/dist/src/interfaces/CustomStageTSConfig.d.ts +8 -7
  67. package/dist/src/interfaces/CustomStageTSConfig.d.ts.map +1 -1
  68. package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts +5 -1
  69. package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts.map +1 -1
  70. package/dist/src/patchErrorFunctions.lua +3 -3
  71. package/package.json +2 -2
  72. package/src/arrays/cachedEnumValues.ts +75 -0
  73. package/src/callbackClasses.ts +1 -0
  74. package/src/callbacks.ts +1 -0
  75. package/src/classes/ModFeature.ts +4 -1
  76. package/src/classes/callbacks/PostItemDischarge.ts +2 -2
  77. package/src/classes/callbacks/PostKeyboardPressed.ts +52 -0
  78. package/src/classes/callbacks/PostPlayerChangeHealth.ts +2 -2
  79. package/src/classes/callbacks/PostPlayerChangeStat.ts +2 -2
  80. package/src/classes/callbacks/PostTransformation.ts +2 -2
  81. package/src/classes/features/callbackLogic/PlayerCollectibleDetection.ts +2 -2
  82. package/src/classes/features/other/CustomStages.ts +1 -1
  83. package/src/classes/features/other/DebugDisplay.ts +120 -39
  84. package/src/classes/features/other/DeployJSONRoom.ts +2 -3
  85. package/src/classes/features/other/ExtraConsoleCommands.ts +2 -1
  86. package/src/classes/features/other/ModdedElementSets.ts +10 -6
  87. package/src/classes/features/other/customStages/streakText.ts +2 -2
  88. package/src/classes/features/other/extraConsoleCommands/commands.ts +6 -7
  89. package/src/enums/ModCallbackCustom.ts +10 -0
  90. package/src/functions/doors.ts +7 -4
  91. package/src/functions/input.ts +3 -5
  92. package/src/functions/level.ts +2 -3
  93. package/src/functions/pills.ts +2 -4
  94. package/src/functions/playerHealth.ts +2 -2
  95. package/src/functions/players.ts +7 -6
  96. package/src/functions/pocketItems.ts +2 -3
  97. package/src/functions/roomData.ts +3 -8
  98. package/src/functions/roomShapeWalls.ts +2 -2
  99. package/src/functions/serialization.ts +4 -4
  100. package/src/functions/sound.ts +2 -1
  101. package/src/functions/transformations.ts +3 -4
  102. package/src/index.ts +1 -0
  103. package/src/interfaces/CustomStageTSConfig.ts +8 -7
  104. package/src/interfaces/private/AddCallbackParametersCustom.ts +6 -0
  105. package/src/patchErrorFunctions.ts +1 -9
@@ -289,8 +289,17 @@ export class DebugDisplay extends Feature {
289
289
  // Toggle Functions
290
290
  // ----------------
291
291
 
292
- private toggleFeature(feature: Feature, featureName: string) {
293
- if (feature.initialized) {
292
+ private toggleFeature(
293
+ feature: Feature,
294
+ featureName: string,
295
+ force: boolean | undefined,
296
+ ) {
297
+ let shouldInit = !feature.initialized;
298
+ if (force !== undefined) {
299
+ shouldInit = force;
300
+ }
301
+
302
+ if (shouldInit) {
294
303
  this.mod.uninitFeature(feature);
295
304
  } else {
296
305
  this.mod.initFeature(feature);
@@ -303,20 +312,28 @@ export class DebugDisplay extends Feature {
303
312
  * Toggles the debug display for players, which will draw text on the screen next to each player.
304
313
  *
305
314
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
315
+ *
316
+ * @param force Optional. A boolean that represents the value to force the display to. For
317
+ * example, you can specify true to always make the display turn on, regardless of
318
+ * whether or not it is already on.
306
319
  */
307
320
  @Exported
308
- public togglePlayerDisplay(): void {
309
- this.toggleFeature(this.player, "player");
321
+ public togglePlayerDisplay(force?: boolean): void {
322
+ this.toggleFeature(this.player, "player", force);
310
323
  }
311
324
 
312
325
  /**
313
326
  * Toggles the debug display for tears, which will draw text on the screen next to each tear.
314
327
  *
315
- * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
328
+ * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`. *
329
+ *
330
+ * @param force Optional. A boolean that represents the value to force the display to. For
331
+ * example, you can specify true to always make the display turn on, regardless of
332
+ * whether or not it is already on.
316
333
  */
317
334
  @Exported
318
- public toggleTearDisplay(): void {
319
- this.toggleFeature(this.tear, "tear");
335
+ public toggleTearDisplay(force?: boolean): void {
336
+ this.toggleFeature(this.tear, "tear", force);
320
337
  }
321
338
 
322
339
  /**
@@ -324,60 +341,84 @@ export class DebugDisplay extends Feature {
324
341
  * familiar.
325
342
  *
326
343
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
344
+ *
345
+ * @param force Optional. A boolean that represents the value to force the display to. For
346
+ * example, you can specify true to always make the display turn on, regardless of
347
+ * whether or not it is already on.
327
348
  */
328
349
  @Exported
329
- public toggleFamiliarDisplay(): void {
330
- this.toggleFeature(this.familiar, "familiar");
350
+ public toggleFamiliarDisplay(force?: boolean): void {
351
+ this.toggleFeature(this.familiar, "familiar", force);
331
352
  }
332
353
 
333
354
  /**
334
355
  * Toggles the debug display for bombs, which will draw text on the screen next to each bomb.
335
356
  *
336
357
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
358
+ *
359
+ * @param force Optional. A boolean that represents the value to force the display to. For
360
+ * example, you can specify true to always make the display turn on, regardless of
361
+ * whether or not it is already on.
337
362
  */
338
363
  @Exported
339
- public toggleBombDisplay(): void {
340
- this.toggleFeature(this.bomb, "bomb");
364
+ public toggleBombDisplay(force?: boolean): void {
365
+ this.toggleFeature(this.bomb, "bomb", force);
341
366
  }
342
367
 
343
368
  /**
344
369
  * Toggles the debug display for pickups, which will draw text on the screen next to each pickup.
345
370
  *
346
371
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
372
+ *
373
+ * @param force Optional. A boolean that represents the value to force the display to. For
374
+ * example, you can specify true to always make the display turn on, regardless of
375
+ * whether or not it is already on.
347
376
  */
348
377
  @Exported
349
- public togglePickupDisplay(): void {
350
- this.toggleFeature(this.pickup, "pickup");
378
+ public togglePickupDisplay(force?: boolean): void {
379
+ this.toggleFeature(this.pickup, "pickup", force);
351
380
  }
352
381
 
353
382
  /**
354
383
  * Toggles the debug display for slots, which will draw text on the screen next to each slot.
355
384
  *
356
385
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
386
+ *
387
+ * @param force Optional. A boolean that represents the value to force the display to. For
388
+ * example, you can specify true to always make the display turn on, regardless of
389
+ * whether or not it is already on.
357
390
  */
358
391
  @Exported
359
- public toggleSlotDisplay(): void {
360
- this.toggleFeature(this.slot, "slot");
392
+ public toggleSlotDisplay(force?: boolean): void {
393
+ this.toggleFeature(this.slot, "slot", force);
361
394
  }
362
395
 
363
396
  /**
364
397
  * Toggles the debug display for lasers, which will draw text on the screen next to each laser.
365
398
  *
366
399
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
400
+ *
401
+ * @param force Optional. A boolean that represents the value to force the display to. For
402
+ * example, you can specify true to always make the display turn on, regardless of
403
+ * whether or not it is already on.
367
404
  */
368
405
  @Exported
369
- public toggleLaserDisplay(): void {
370
- this.toggleFeature(this.laser, "laser");
406
+ public toggleLaserDisplay(force?: boolean): void {
407
+ this.toggleFeature(this.laser, "laser", force);
371
408
  }
372
409
 
373
410
  /**
374
411
  * Toggles the debug display for knives, which will draw text on the screen next to each knife.
375
412
  *
376
413
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
414
+ *
415
+ * @param force Optional. A boolean that represents the value to force the display to. For
416
+ * example, you can specify true to always make the display turn on, regardless of
417
+ * whether or not it is already on.
377
418
  */
378
419
  @Exported
379
- public toggleKnifeDisplay(): void {
380
- this.toggleFeature(this.knife, "knife");
420
+ public toggleKnifeDisplay(force?: boolean): void {
421
+ this.toggleFeature(this.knife, "knife", force);
381
422
  }
382
423
 
383
424
  /**
@@ -385,90 +426,126 @@ export class DebugDisplay extends Feature {
385
426
  * projectile.
386
427
  *
387
428
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
429
+ *
430
+ * @param force Optional. A boolean that represents the value to force the display to. For
431
+ * example, you can specify true to always make the display turn on, regardless of
432
+ * whether or not it is already on.
388
433
  */
389
434
  @Exported
390
- public toggleProjectileDisplay(): void {
391
- this.toggleFeature(this.projectile, "projectile");
435
+ public toggleProjectileDisplay(force?: boolean): void {
436
+ this.toggleFeature(this.projectile, "projectile", force);
392
437
  }
393
438
 
394
439
  /**
395
440
  * Toggles the debug display for effects, which will draw text on the screen next to each effect.
396
441
  *
397
442
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
443
+ *
444
+ * @param force Optional. A boolean that represents the value to force the display to. For
445
+ * example, you can specify true to always make the display turn on, regardless of
446
+ * whether or not it is already on.
398
447
  */
399
448
  @Exported
400
- public toggleEffectDisplay(): void {
401
- this.toggleFeature(this.effect, "effect");
449
+ public toggleEffectDisplay(force?: boolean): void {
450
+ this.toggleFeature(this.effect, "effect", force);
402
451
  }
403
452
 
404
453
  /**
405
454
  * Toggles the debug display for NPCs, which will draw text on the screen next to each NPC.
406
455
  *
407
456
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
457
+ *
458
+ * @param force Optional. A boolean that represents the value to force the display to. For
459
+ * example, you can specify true to always make the display turn on, regardless of
460
+ * whether or not it is already on.
408
461
  */
409
462
  @Exported
410
- public toggleNPCDisplay(): void {
411
- this.toggleFeature(this.npc, "NPC");
463
+ public toggleNPCDisplay(force?: boolean): void {
464
+ this.toggleFeature(this.npc, "NPC", force);
412
465
  }
413
466
 
414
467
  /**
415
468
  * Toggles the debug display for rocks, which will draw text on the screen next to each rock.
416
469
  *
417
470
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
471
+ *
472
+ * @param force Optional. A boolean that represents the value to force the display to. For
473
+ * example, you can specify true to always make the display turn on, regardless of
474
+ * whether or not it is already on.
418
475
  */
419
476
  @Exported
420
- public toggleRockDisplay(): void {
421
- this.toggleFeature(this.rock, "rock");
477
+ public toggleRockDisplay(force?: boolean): void {
478
+ this.toggleFeature(this.rock, "rock", force);
422
479
  }
423
480
 
424
481
  /**
425
482
  * Toggles the debug display for pits, which will draw text on the screen next to each pit.
426
483
  *
427
484
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
485
+ *
486
+ * @param force Optional. A boolean that represents the value to force the display to. For
487
+ * example, you can specify true to always make the display turn on, regardless of
488
+ * whether or not it is already on.
428
489
  */
429
490
  @Exported
430
- public togglePitDisplay(): void {
431
- this.toggleFeature(this.pit, "pit");
491
+ public togglePitDisplay(force?: boolean): void {
492
+ this.toggleFeature(this.pit, "pit", force);
432
493
  }
433
494
 
434
495
  /**
435
496
  * Toggles the debug display for spikes, which will draw text on the screen next to each spike.
436
497
  *
437
498
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
499
+ *
500
+ * @param force Optional. A boolean that represents the value to force the display to. For
501
+ * example, you can specify true to always make the display turn on, regardless of
502
+ * whether or not it is already on.
438
503
  */
439
504
  @Exported
440
- public toggleSpikesDisplay(): void {
441
- this.toggleFeature(this.spikes, "spikes");
505
+ public toggleSpikesDisplay(force?: boolean): void {
506
+ this.toggleFeature(this.spikes, "spikes", force);
442
507
  }
443
508
 
444
509
  /**
445
510
  * Toggles the debug display for TNT, which will draw text on the screen next to each TNT.
446
511
  *
447
512
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
513
+ *
514
+ * @param force Optional. A boolean that represents the value to force the display to. For
515
+ * example, you can specify true to always make the display turn on, regardless of
516
+ * whether or not it is already on.
448
517
  */
449
518
  @Exported
450
- public toggleTNTDisplay(): void {
451
- this.toggleFeature(this.tnt, "tnt");
519
+ public toggleTNTDisplay(force?: boolean): void {
520
+ this.toggleFeature(this.tnt, "tnt", force);
452
521
  }
453
522
 
454
523
  /**
455
524
  * Toggles the debug display for poops, which will draw text on the screen next to each poop.
456
525
  *
457
526
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
527
+ *
528
+ * @param force Optional. A boolean that represents the value to force the display to. For
529
+ * example, you can specify true to always make the display turn on, regardless of
530
+ * whether or not it is already on.
458
531
  */
459
532
  @Exported
460
- public togglePoopDisplay(): void {
461
- this.toggleFeature(this.poop, "poop");
533
+ public togglePoopDisplay(force?: boolean): void {
534
+ this.toggleFeature(this.poop, "poop", force);
462
535
  }
463
536
 
464
537
  /**
465
538
  * Toggles the debug display for doors, which will draw text on the screen next to each door.
466
539
  *
467
540
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
541
+ *
542
+ * @param force Optional. A boolean that represents the value to force the display to. For
543
+ * example, you can specify true to always make the display turn on, regardless of
544
+ * whether or not it is already on.
468
545
  */
469
546
  @Exported
470
- public toggleDoorDisplay(): void {
471
- this.toggleFeature(this.door, "door");
547
+ public toggleDoorDisplay(force?: boolean): void {
548
+ this.toggleFeature(this.door, "door", force);
472
549
  }
473
550
 
474
551
  /**
@@ -476,9 +553,13 @@ export class DebugDisplay extends Feature {
476
553
  * pressure plate.
477
554
  *
478
555
  * In order to use this function, you must upgrade your mod with `ISCFeature.DEBUG_DISPLAY`.
556
+ *
557
+ * @param force Optional. A boolean that represents the value to force the display to. For
558
+ * example, you can specify true to always make the display turn on, regardless of
559
+ * whether or not it is already on.
479
560
  */
480
561
  @Exported
481
- public togglePressurePlateDisplay(): void {
482
- this.toggleFeature(this.pressurePlate, "pressure plate");
562
+ public togglePressurePlateDisplay(force?: boolean): void {
563
+ this.toggleFeature(this.pressurePlate, "pressure plate", force);
483
564
  }
484
565
  }
@@ -8,6 +8,7 @@ import {
8
8
  PitfallVariant,
9
9
  RoomType,
10
10
  } from "isaac-typescript-definitions";
11
+ import { GRID_ENTITY_XML_TYPE_VALUES } from "../../../arrays/cachedEnumValues";
11
12
  import { game } from "../../../core/cachedClasses";
12
13
  import { Exported } from "../../../decorators";
13
14
  import { ISCFeature } from "../../../enums/ISCFeature";
@@ -16,7 +17,6 @@ import {
16
17
  getEntityIDFromConstituents,
17
18
  spawnWithSeed,
18
19
  } from "../../../functions/entities";
19
- import { getEnumValues } from "../../../functions/enums";
20
20
  import {
21
21
  convertXMLGridEntityType,
22
22
  getGridEntities,
@@ -34,9 +34,8 @@ import { Feature } from "../../private/Feature";
34
34
  import { PreventGridEntityRespawn } from "./PreventGridEntityRespawn";
35
35
  import { SpawnCollectible } from "./SpawnCollectible";
36
36
 
37
- const gridEntityXMLTypes = getEnumValues(GridEntityXMLType);
38
37
  const GRID_ENTITY_XML_TYPE_SET = new ReadonlySet<GridEntityXMLType>(
39
- gridEntityXMLTypes,
38
+ GRID_ENTITY_XML_TYPE_VALUES,
40
39
  );
41
40
 
42
41
  export class DeployJSONRoom extends Feature {
@@ -173,7 +173,8 @@ export class ExtraConsoleCommands extends Feature {
173
173
  private executeCmd = (command: string, params: string) => {
174
174
  const resultTuple = getMapPartialMatch(command, this.commandFunctionMap);
175
175
  if (resultTuple === undefined) {
176
- print("That is an invalid console command.");
176
+ // We cannot print an error message, because if multiple mods have this feature enabled, then
177
+ // multiple error messages would appear.
177
178
  return;
178
179
  }
179
180
 
@@ -7,6 +7,11 @@ import {
7
7
  PlayerForm,
8
8
  TrinketType,
9
9
  } from "isaac-typescript-definitions";
10
+ import {
11
+ CACHE_FLAG_VALUES,
12
+ ITEM_CONFIG_CARD_TYPE_VALUES,
13
+ ITEM_CONFIG_TAG_VALUES,
14
+ } from "../../../arrays/cachedEnumValues";
10
15
  import { itemConfig } from "../../../core/cachedClasses";
11
16
  import { FIRST_GLITCHED_COLLECTIBLE_TYPE } from "../../../core/constants";
12
17
  import { Exported } from "../../../decorators";
@@ -23,7 +28,6 @@ import {
23
28
  isPassiveCollectible,
24
29
  } from "../../../functions/collectibles";
25
30
  import { collectibleHasTag } from "../../../functions/collectibleTag";
26
- import { getEnumValues } from "../../../functions/enums";
27
31
  import { getFlagName } from "../../../functions/flag";
28
32
  import { getRandomSeed } from "../../../functions/rng";
29
33
  import {
@@ -275,12 +279,12 @@ export class ModdedElementSets extends Feature {
275
279
 
276
280
  // The tag to collectible types map should be valid for every tag, so we initialize it with
277
281
  // empty sets.
278
- for (const itemConfigTag of getEnumValues(ItemConfigTag)) {
282
+ for (const itemConfigTag of ITEM_CONFIG_TAG_VALUES) {
279
283
  this.tagToCollectibleTypesMap.set(itemConfigTag, new Set());
280
284
  }
281
285
 
282
286
  for (const collectibleType of this.getCollectibleArray()) {
283
- for (const itemConfigTag of getEnumValues(ItemConfigTag)) {
287
+ for (const itemConfigTag of ITEM_CONFIG_TAG_VALUES) {
284
288
  if (!collectibleHasTag(collectibleType, itemConfigTag)) {
285
289
  continue;
286
290
  }
@@ -303,7 +307,7 @@ export class ModdedElementSets extends Feature {
303
307
  return;
304
308
  }
305
309
 
306
- for (const cacheFlag of getEnumValues(CacheFlag)) {
310
+ for (const cacheFlag of CACHE_FLAG_VALUES) {
307
311
  const collectiblesSet = new Set<CollectibleType>();
308
312
 
309
313
  for (const collectibleType of this.getCollectibleArray()) {
@@ -321,7 +325,7 @@ export class ModdedElementSets extends Feature {
321
325
  return;
322
326
  }
323
327
 
324
- for (const cacheFlag of getEnumValues(CacheFlag)) {
328
+ for (const cacheFlag of CACHE_FLAG_VALUES) {
325
329
  const trinketsSet = new Set<TrinketType>();
326
330
 
327
331
  for (const trinketType of this.moddedElementDetection.getTrinketTypes()) {
@@ -419,7 +423,7 @@ export class ModdedElementSets extends Feature {
419
423
 
420
424
  // The card type to cards map should be valid for every card type, so we initialize it with
421
425
  // empty sets.
422
- for (const itemConfigCardType of getEnumValues(ItemConfigCardType)) {
426
+ for (const itemConfigCardType of ITEM_CONFIG_CARD_TYPE_VALUES) {
423
427
  this.itemConfigCardTypeToCardTypeMap.set(
424
428
  itemConfigCardType,
425
429
  new Set<CardType>(),
@@ -1,8 +1,8 @@
1
1
  import { ButtonAction, ControllerIndex } from "isaac-typescript-definitions";
2
+ import { CONTROLLER_INDEX_VALUES } from "../../../../arrays/cachedEnumValues";
2
3
  import { fonts, game } from "../../../../core/cachedClasses";
3
4
  import { KColorDefault, VectorOne } from "../../../../core/constants";
4
5
  import { UIStreakAnimation } from "../../../../enums/private/UIStreakAnimation";
5
- import { getEnumValues } from "../../../../functions/enums";
6
6
  import {
7
7
  getScreenBottomCenterPos,
8
8
  getScreenTopCenterPos,
@@ -137,7 +137,7 @@ function checkEndTopStreakText(v: StreakTextVars) {
137
137
  }
138
138
 
139
139
  function trackMapInputPressed(v: StreakTextVars) {
140
- for (const controllerIndex of getEnumValues(ControllerIndex)) {
140
+ for (const controllerIndex of CONTROLLER_INDEX_VALUES) {
141
141
  const gameFrameCount = game.GetFrameCount();
142
142
  const oldPushedMapFrame =
143
143
  v.run.controllerIndexPushingMapRenderFrame.get(controllerIndex);
@@ -38,7 +38,6 @@ import {
38
38
  Direction,
39
39
  DisplayFlag,
40
40
  GameStateFlag,
41
- GridEntityType,
42
41
  GridRoom,
43
42
  LevelStage,
44
43
  PillColor,
@@ -49,6 +48,10 @@ import {
49
48
  StageType,
50
49
  TrinketType,
51
50
  } from "isaac-typescript-definitions";
51
+ import {
52
+ ACTIVE_SLOT_VALUES,
53
+ GRID_ENTITY_TYPE_VALUES,
54
+ } from "../../../../arrays/cachedEnumValues";
52
55
  import { game, sfxManager } from "../../../../core/cachedClasses";
53
56
  import {
54
57
  DOGMA_ROOM_GRID_INDEX,
@@ -74,7 +77,6 @@ import { addCharge, getTotalCharge } from "../../../../functions/charge";
74
77
  import { isValidCollectibleType } from "../../../../functions/collectibles";
75
78
  import { runDeepCopyTests } from "../../../../functions/deepCopyTests";
76
79
  import { getNPCs } from "../../../../functions/entitiesSpecific";
77
- import { getEnumValues } from "../../../../functions/enums";
78
80
  import { addFlag } from "../../../../functions/flag";
79
81
  import { spawnGridEntity } from "../../../../functions/gridEntities";
80
82
  import { getRoomGridIndexesForType } from "../../../../functions/levelGrid";
@@ -768,13 +770,11 @@ export function gridCosts(): void {
768
770
 
769
771
  /** Spawns every grid entity, starting at the top-left-most tile. */
770
772
  export function gridEntities(): void {
771
- const gridEntityTypes = getEnumValues(GridEntityType);
772
-
773
773
  let gridEntityTypeIndex = -1;
774
774
  for (let y = 0; y <= 6; y++) {
775
775
  for (let x = 0; x <= 12; x++) {
776
776
  gridEntityTypeIndex++;
777
- const gridEntityType = gridEntityTypes[gridEntityTypeIndex];
777
+ const gridEntityType = GRID_ENTITY_TYPE_VALUES[gridEntityTypeIndex];
778
778
  if (gridEntityType === undefined) {
779
779
  return;
780
780
  }
@@ -1242,8 +1242,7 @@ export function setCharges(params: string): void {
1242
1242
  return;
1243
1243
  }
1244
1244
 
1245
- const activeSlots = getEnumValues(ActiveSlot);
1246
- if (!activeSlots.includes(activeSlot)) {
1245
+ if (!ACTIVE_SLOT_VALUES.includes(activeSlot)) {
1247
1246
  print(`The provided slot number is invalid: ${activeSlot}`);
1248
1247
  return;
1249
1248
  }
@@ -817,6 +817,16 @@ export enum ModCallbackCustom {
817
817
  */
818
818
  POST_ITEM_PICKUP,
819
819
 
820
+ /**
821
+ * Fires on the first `POST_RENDER` frame after a keyboard has been pressed (when it was not
822
+ * pressed on the previous frame).
823
+ *
824
+ * When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
825
+ * - You can provide an optional third argument that will make the callback only fire if it
826
+ * matches the `Keyboard` provided.
827
+ */
828
+ POST_KEYBOARD_PRESSED,
829
+
820
830
  /**
821
831
  * Fires on the first `POST_KNIFE_UPDATE` frame for each knife.
822
832
  *
@@ -9,6 +9,10 @@ import {
9
9
  RoomShape,
10
10
  RoomType,
11
11
  } from "isaac-typescript-definitions";
12
+ import {
13
+ DOOR_SLOT_FLAG_VALUES,
14
+ DOOR_SLOT_VALUES,
15
+ } from "../arrays/cachedEnumValues";
12
16
  import { game } from "../core/cachedClasses";
13
17
  import { DISTANCE_OF_GRID_TILE } from "../core/constants";
14
18
  import {
@@ -22,7 +26,6 @@ import { ROOM_SHAPE_TO_DOOR_SLOT_COORDINATES } from "../objects/roomShapeToDoorS
22
26
  import { ROOM_SHAPE_TO_DOOR_SLOTS } from "../objects/roomShapeToDoorSlots";
23
27
  import { arrayToBitFlags } from "./bitwise";
24
28
  import { directionToVector } from "./direction";
25
- import { getEnumValues } from "./enums";
26
29
  import { hasFlag } from "./flag";
27
30
  import { isTSTLSet } from "./tstlClass";
28
31
  import { asNumber } from "./types";
@@ -54,7 +57,7 @@ export function doorSlotFlagsToDoorSlots(
54
57
  ): DoorSlot[] {
55
58
  const doorSlots: DoorSlot[] = [];
56
59
 
57
- for (const doorSlotFlag of getEnumValues(DoorSlotFlag)) {
60
+ for (const doorSlotFlag of DOOR_SLOT_FLAG_VALUES) {
58
61
  if (hasFlag(doorSlotFlags, doorSlotFlag)) {
59
62
  const doorSlot = doorSlotFlagToDoorSlot(doorSlotFlag);
60
63
  doorSlots.push(doorSlot);
@@ -287,8 +290,8 @@ export function getRoomShapeDoorSlotCoordinates(
287
290
  */
288
291
  export function getUnusedDoorSlots(): DoorSlot[] {
289
292
  const room = game.GetRoom();
290
- const doorSlots = getEnumValues(DoorSlot);
291
- return doorSlots.filter(
293
+
294
+ return DOOR_SLOT_VALUES.filter(
292
295
  (doorSlot) =>
293
296
  // We need to filter out the -1 value to prevent crashes.
294
297
  doorSlot !== DoorSlot.NO_DOOR_SLOT &&
@@ -4,9 +4,9 @@ import {
4
4
  ControllerIndex,
5
5
  Keyboard,
6
6
  } from "isaac-typescript-definitions";
7
+ import { CONTROLLER_INDEX_VALUES } from "../arrays/cachedEnumValues";
7
8
  import { KEYBOARD_TO_STRING } from "../maps/keyboardToString";
8
9
  import { ReadonlySet } from "../types/ReadonlySet";
9
- import { getEnumValues } from "./enums";
10
10
  import { trimPrefix } from "./string";
11
11
 
12
12
  const MODIFIER_KEYS = [
@@ -91,8 +91,7 @@ export function isActionPressed(
91
91
  export function isActionPressedOnAnyInput(
92
92
  ...buttonActions: ButtonAction[]
93
93
  ): boolean {
94
- const controllerIndexes = getEnumValues(ControllerIndex);
95
- return controllerIndexes.some((controllerIndex) =>
94
+ return CONTROLLER_INDEX_VALUES.some((controllerIndex) =>
96
95
  isActionPressed(controllerIndex, ...buttonActions),
97
96
  );
98
97
  }
@@ -124,8 +123,7 @@ export function isActionTriggered(
124
123
  export function isActionTriggeredOnAnyInput(
125
124
  ...buttonActions: ButtonAction[]
126
125
  ): boolean {
127
- const controllerIndexes = getEnumValues(ControllerIndex);
128
- return controllerIndexes.some((controllerIndex) =>
126
+ return CONTROLLER_INDEX_VALUES.some((controllerIndex) =>
129
127
  isActionTriggered(controllerIndex, ...buttonActions),
130
128
  );
131
129
  }
@@ -1,6 +1,5 @@
1
- import { DoorSlot } from "isaac-typescript-definitions";
1
+ import { DOOR_SLOT_VALUES } from "../arrays/cachedEnumValues";
2
2
  import { game } from "../core/cachedClasses";
3
- import { getEnumValues } from "./enums";
4
3
  import { isDoorSlotValidAtGridIndexForRedRoom } from "./levelGrid";
5
4
  import { getNumRooms, getRoomsInsideGrid } from "./rooms";
6
5
 
@@ -13,7 +12,7 @@ export function fillLevelWithRedRooms(): void {
13
12
  numRoomsInGrid = roomsInGrid.length;
14
13
 
15
14
  for (const roomDescriptor of roomsInGrid) {
16
- for (const doorSlot of getEnumValues(DoorSlot)) {
15
+ for (const doorSlot of DOOR_SLOT_VALUES) {
17
16
  if (
18
17
  isDoorSlotValidAtGridIndexForRedRoom(
19
18
  doorSlot,
@@ -4,6 +4,7 @@ import {
4
4
  PillColor,
5
5
  PillEffect,
6
6
  } from "isaac-typescript-definitions";
7
+ import { PILL_COLOR_VALUES } from "../arrays/cachedEnumValues";
7
8
  import { itemConfig } from "../core/cachedClasses";
8
9
  import {
9
10
  FIRST_HORSE_PILL_COLOR,
@@ -27,7 +28,6 @@ import {
27
28
  DEFAULT_PILL_EFFECT_TYPE,
28
29
  PILL_EFFECT_TYPES,
29
30
  } from "../objects/pillEffectTypes";
30
- import { getEnumValues } from "./enums";
31
31
  import { asNumber, asPillColor } from "./types";
32
32
  import { iRange } from "./utils";
33
33
 
@@ -45,9 +45,7 @@ const HORSE_PILL_ADJUSTMENT = 2048;
45
45
  * all horse colors.
46
46
  */
47
47
  export function getAllPillColors(): PillColor[] {
48
- const pillColors = getEnumValues(PillColor);
49
- pillColors.slice(); // Remove `PillColor.NULL`
50
- return pillColors;
48
+ return PILL_COLOR_VALUES.slice(1); // Remove `PillColor.NULL`
51
49
  }
52
50
 
53
51
  /**
@@ -5,13 +5,13 @@ import {
5
5
  PlayerType,
6
6
  TrinketType,
7
7
  } from "isaac-typescript-definitions";
8
+ import { ACTIVE_SLOT_VALUES } from "../arrays/cachedEnumValues";
8
9
  import { MAX_PLAYER_HEART_CONTAINERS } from "../core/constants";
9
10
  import { HealthType } from "../enums/HealthType";
10
11
  import { PlayerHealth, SoulHeartType } from "../interfaces/PlayerHealth";
11
12
  import { countSetBits, getKBitOfN, getNumBitsOfN } from "./bitwise";
12
13
  import { getCharacterMaxHeartContainers } from "./characters";
13
14
  import { getTotalCharge } from "./charge";
14
- import { getEnumValues } from "./enums";
15
15
  import { isCharacter, isKeeper, setActiveItem } from "./players";
16
16
  import { repeat } from "./utils";
17
17
 
@@ -548,7 +548,7 @@ export function setPlayerHealth(
548
548
  // Before we add any health, we have to take away Alabaster Box, if present.
549
549
  const alabasterBoxes: Array<[slot: ActiveSlot, totalCharge: int]> = [];
550
550
  if (player.HasCollectible(CollectibleType.ALABASTER_BOX)) {
551
- for (const activeSlot of getEnumValues(ActiveSlot)) {
551
+ for (const activeSlot of ACTIVE_SLOT_VALUES) {
552
552
  const activeItem = player.GetActiveItem();
553
553
  if (activeItem === CollectibleType.ALABASTER_BOX) {
554
554
  const totalCharge = getTotalCharge(player, activeSlot);