isaacscript-common 21.2.1 → 21.4.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 (90) hide show
  1. package/dist/index.d.ts +177 -84
  2. package/dist/isaacscript-common.lua +527 -444
  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/PostKeyboardChanged.d.ts +16 -0
  15. package/dist/src/classes/callbacks/PostKeyboardChanged.d.ts.map +1 -0
  16. package/dist/src/classes/callbacks/PostKeyboardChanged.lua +50 -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/DebugDisplay.d.ts +91 -19
  25. package/dist/src/classes/features/other/DebugDisplay.d.ts.map +1 -1
  26. package/dist/src/classes/features/other/DebugDisplay.lua +42 -38
  27. package/dist/src/classes/features/other/DeployJSONRoom.d.ts.map +1 -1
  28. package/dist/src/classes/features/other/DeployJSONRoom.lua +3 -5
  29. package/dist/src/classes/features/other/ModdedElementSets.d.ts.map +1 -1
  30. package/dist/src/classes/features/other/ModdedElementSets.lua +9 -7
  31. package/dist/src/classes/features/other/customStages/streakText.d.ts.map +1 -1
  32. package/dist/src/classes/features/other/customStages/streakText.lua +3 -4
  33. package/dist/src/classes/features/other/extraConsoleCommands/commands.d.ts.map +1 -1
  34. package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +5 -7
  35. package/dist/src/enums/ModCallbackCustom.d.ts +81 -65
  36. package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
  37. package/dist/src/enums/ModCallbackCustom.lua +67 -65
  38. package/dist/src/functions/doors.d.ts.map +1 -1
  39. package/dist/src/functions/doors.lua +5 -6
  40. package/dist/src/functions/input.d.ts.map +1 -1
  41. package/dist/src/functions/input.lua +4 -6
  42. package/dist/src/functions/level.d.ts.map +1 -1
  43. package/dist/src/functions/level.lua +3 -5
  44. package/dist/src/functions/pills.d.ts.map +1 -1
  45. package/dist/src/functions/pills.lua +3 -5
  46. package/dist/src/functions/playerHealth.d.ts.map +1 -1
  47. package/dist/src/functions/playerHealth.lua +3 -4
  48. package/dist/src/functions/players.d.ts.map +1 -1
  49. package/dist/src/functions/players.lua +6 -7
  50. package/dist/src/functions/pocketItems.d.ts.map +1 -1
  51. package/dist/src/functions/pocketItems.lua +3 -5
  52. package/dist/src/functions/roomData.d.ts.map +1 -1
  53. package/dist/src/functions/roomData.lua +3 -6
  54. package/dist/src/functions/roomShapeWalls.lua +3 -3
  55. package/dist/src/functions/serialization.lua +3 -6
  56. package/dist/src/functions/sound.d.ts.map +1 -1
  57. package/dist/src/functions/sound.lua +3 -3
  58. package/dist/src/functions/transformations.d.ts.map +1 -1
  59. package/dist/src/functions/transformations.lua +4 -5
  60. package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts +6 -1
  61. package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts.map +1 -1
  62. package/package.json +1 -1
  63. package/src/arrays/cachedEnumValues.ts +75 -0
  64. package/src/callbackClasses.ts +1 -0
  65. package/src/callbacks.ts +1 -0
  66. package/src/classes/callbacks/PostItemDischarge.ts +2 -2
  67. package/src/classes/callbacks/PostKeyboardChanged.ts +62 -0
  68. package/src/classes/callbacks/PostPlayerChangeHealth.ts +2 -2
  69. package/src/classes/callbacks/PostPlayerChangeStat.ts +2 -2
  70. package/src/classes/callbacks/PostTransformation.ts +2 -2
  71. package/src/classes/features/callbackLogic/PlayerCollectibleDetection.ts +2 -2
  72. package/src/classes/features/other/DebugDisplay.ts +120 -39
  73. package/src/classes/features/other/DeployJSONRoom.ts +2 -3
  74. package/src/classes/features/other/ModdedElementSets.ts +10 -6
  75. package/src/classes/features/other/customStages/streakText.ts +2 -2
  76. package/src/classes/features/other/extraConsoleCommands/commands.ts +6 -7
  77. package/src/enums/ModCallbackCustom.ts +17 -0
  78. package/src/functions/doors.ts +7 -4
  79. package/src/functions/input.ts +3 -5
  80. package/src/functions/level.ts +2 -3
  81. package/src/functions/pills.ts +2 -4
  82. package/src/functions/playerHealth.ts +2 -2
  83. package/src/functions/players.ts +7 -6
  84. package/src/functions/pocketItems.ts +2 -3
  85. package/src/functions/roomData.ts +2 -4
  86. package/src/functions/roomShapeWalls.ts +2 -2
  87. package/src/functions/serialization.ts +4 -4
  88. package/src/functions/sound.ts +2 -1
  89. package/src/functions/transformations.ts +3 -4
  90. package/src/interfaces/private/AddCallbackParametersCustom.ts +7 -0
@@ -6,14 +6,16 @@ import {
6
6
  NullItemID,
7
7
  PlayerForm,
8
8
  PlayerType,
9
- TrinketSlot,
10
9
  TrinketType,
11
10
  } from "isaac-typescript-definitions";
11
+ import {
12
+ ACTIVE_SLOT_VALUES,
13
+ TRINKET_SLOT_VALUES,
14
+ } from "../arrays/cachedEnumValues";
12
15
  import { game, itemConfig } from "../core/cachedClasses";
13
16
  import { getLastElement, sumArray } from "./array";
14
17
  import { getCharacterName, isVanillaCharacter } from "./characters";
15
18
  import { getCollectibleMaxCharges } from "./collectibles";
16
- import { getEnumValues } from "./enums";
17
19
  import {
18
20
  getAllPlayers,
19
21
  getPlayerIndexVanilla,
@@ -119,8 +121,7 @@ export function getActiveItemSlot(
119
121
  player: EntityPlayer,
120
122
  collectibleType: CollectibleType,
121
123
  ): ActiveSlot | undefined {
122
- const activeSlots = getEnumValues(ActiveSlot);
123
- return activeSlots.find((activeSlot) => {
124
+ return ACTIVE_SLOT_VALUES.find((activeSlot) => {
124
125
  const activeItem = player.GetActiveItem(activeSlot);
125
126
  return activeItem === collectibleType;
126
127
  });
@@ -660,7 +661,7 @@ export function playerHasForm(
660
661
  * and any pocket actives.
661
662
  */
662
663
  export function removeAllActiveItems(player: EntityPlayer): void {
663
- for (const activeSlot of getEnumValues(ActiveSlot)) {
664
+ for (const activeSlot of ACTIVE_SLOT_VALUES) {
664
665
  const collectibleType = player.GetActiveItem(activeSlot);
665
666
  if (collectibleType === CollectibleType.NULL) {
666
667
  continue;
@@ -681,7 +682,7 @@ export function removeAllActiveItems(player: EntityPlayer): void {
681
682
  * they also have smelted. (In that case, both the held and the smelted trinket will be removed.)
682
683
  */
683
684
  export function removeAllPlayerTrinkets(player: EntityPlayer): void {
684
- for (const trinketSlot of getEnumValues(TrinketSlot)) {
685
+ for (const trinketSlot of TRINKET_SLOT_VALUES) {
685
686
  const trinketType = player.GetTrinket(trinketSlot);
686
687
  if (trinketType === TrinketType.NULL) {
687
688
  continue;
@@ -6,9 +6,9 @@ import {
6
6
  PlayerType,
7
7
  PocketItemSlot,
8
8
  } from "isaac-typescript-definitions";
9
+ import { POCKET_ITEM_SLOT_VALUES } from "../arrays/cachedEnumValues";
9
10
  import { PocketItemType } from "../enums/PocketItemType";
10
11
  import { PocketItemDescription } from "../interfaces/PocketItemDescription";
11
- import { getEnumValues } from "./enums";
12
12
  import { isCharacter } from "./players";
13
13
  import { asNumber } from "./types";
14
14
 
@@ -58,12 +58,11 @@ export function getPocketItems(player: EntityPlayer): PocketItemDescription[] {
58
58
  const hasPocketItem2 = pocketItem2 !== CollectibleType.NULL;
59
59
 
60
60
  const maxPocketItems = player.GetMaxPocketItems();
61
- const pocketItemSlots = getEnumValues(PocketItemSlot);
62
61
 
63
62
  const pocketItems: PocketItemDescription[] = [];
64
63
  let pocketItemIdentified = false;
65
64
  let pocketItem2Identified = false;
66
- for (const slot of pocketItemSlots) {
65
+ for (const slot of POCKET_ITEM_SLOT_VALUES) {
67
66
  const cardType = player.GetCard(slot);
68
67
  const pillColor = player.GetPill(slot);
69
68
 
@@ -1,13 +1,12 @@
1
1
  import {
2
2
  DoorSlot,
3
- DoorSlotFlag,
4
3
  RoomShape,
5
4
  RoomType,
6
5
  StageID,
7
6
  } from "isaac-typescript-definitions";
7
+ import { DOOR_SLOT_FLAG_VALUES } from "../arrays/cachedEnumValues";
8
8
  import { game } from "../core/cachedClasses";
9
9
  import { doorSlotFlagToDoorSlot } from "./doors";
10
- import { getEnumValues } from "./enums";
11
10
  import { hasFlag } from "./flag";
12
11
 
13
12
  /**
@@ -22,8 +21,7 @@ export function getRoomAllowedDoors(roomGridIndex?: int): Set<DoorSlot> {
22
21
  return allowedDoors;
23
22
  }
24
23
 
25
- const doorSlotFlags = getEnumValues(DoorSlotFlag);
26
- for (const doorSlotFlag of doorSlotFlags) {
24
+ for (const doorSlotFlag of DOOR_SLOT_FLAG_VALUES) {
27
25
  if (hasFlag(roomData.Doors, doorSlotFlag)) {
28
26
  const doorSlot = doorSlotFlagToDoorSlot(doorSlotFlag);
29
27
  allowedDoors.add(doorSlot);
@@ -1,8 +1,8 @@
1
1
  import { BossID, RoomShape } from "isaac-typescript-definitions";
2
+ import { ROOM_SHAPE_VALUES } from "../arrays/cachedEnumValues";
2
3
  import { game } from "../core/cachedClasses";
3
4
  import { CornerType } from "../enums/CornerType";
4
5
  import { Corner } from "../interfaces/Corner";
5
- import { getEnumValues } from "./enums";
6
6
  import { getGridIndexesBetween } from "./gridIndex";
7
7
  import { inBossRoomOf, inHomeCloset } from "./rooms";
8
8
  import { getRoomShapeCorners, isLRoom } from "./roomShape";
@@ -13,7 +13,7 @@ const ROOM_SHAPE_TO_WALL_GRID_INDEX_SET: ReadonlyMap<
13
13
  > = (() => {
14
14
  const roomShapeToWallGridIndexSet = new Map<RoomShape, ReadonlySet<int>>();
15
15
 
16
- for (const roomShape of getEnumValues(RoomShape)) {
16
+ for (const roomShape of ROOM_SHAPE_VALUES) {
17
17
  const gridIndexSet = getVanillaWallGridIndexSetForRoomShape(roomShape);
18
18
  roomShapeToWallGridIndexSet.set(roomShape, gridIndexSet);
19
19
  }
@@ -1,5 +1,5 @@
1
1
  import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
2
- import { SerializationBrand } from "../enums/SerializationBrand";
2
+ import { SERIALIZATION_BRAND_VALUES } from "../arrays/cachedEnumValues";
3
3
  import { ISAAC_API_CLASS_TYPE_TO_BRAND } from "../objects/isaacAPIClassTypeToBrand";
4
4
  import {
5
5
  CopyableIsaacAPIClass,
@@ -10,12 +10,12 @@ import {
10
10
  SerializedIsaacAPIClass,
11
11
  } from "../objects/isaacAPIClassTypeToFunctions";
12
12
  import { ReadonlySet } from "../types/ReadonlySet";
13
- import { getEnumValues } from "./enums";
14
13
  import { getIsaacAPIClassName } from "./isaacAPIClass";
15
14
  import { isString, isTable, isUserdata } from "./types";
16
15
 
17
- const SERIALIZATION_BRANDS = getEnumValues(SerializationBrand);
18
- const SERIALIZATION_BRAND_SET = new ReadonlySet<string>(SERIALIZATION_BRANDS);
16
+ const SERIALIZATION_BRAND_SET = new ReadonlySet<string>(
17
+ SERIALIZATION_BRAND_VALUES,
18
+ );
19
19
 
20
20
  /**
21
21
  * Helper function to generically copy an Isaac API class without knowing what specific type of
@@ -4,6 +4,7 @@ import {
4
4
  SoundEffect,
5
5
  StageType,
6
6
  } from "isaac-typescript-definitions";
7
+ import { SOUND_EFFECT_VALUES } from "../arrays/cachedEnumValues";
7
8
  import { game, sfxManager } from "../core/cachedClasses";
8
9
  import { STAGE_TO_MUSIC } from "../objects/stageToMusic";
9
10
  import { getEnumValues } from "./enums";
@@ -42,7 +43,7 @@ export function getMusicForStage(
42
43
  * your mod.
43
44
  */
44
45
  export function stopAllSoundEffects(soundEffectCustom?: unknown): void {
45
- for (const soundEffect of getEnumValues(SoundEffect)) {
46
+ for (const soundEffect of SOUND_EFFECT_VALUES) {
46
47
  sfxManager.Stop(soundEffect);
47
48
  }
48
49
 
@@ -3,11 +3,11 @@ import {
3
3
  ItemConfigTag,
4
4
  PlayerForm,
5
5
  } from "isaac-typescript-definitions";
6
+ import { PLAYER_FORM_VALUES } from "../arrays/cachedEnumValues";
6
7
  import { TRANSFORMATION_NAMES } from "../objects/transformationNames";
7
8
  import { ReadonlyMap } from "../types/ReadonlyMap";
8
9
  import { ReadonlySet } from "../types/ReadonlySet";
9
10
  import { getCollectibleTags } from "./collectibles";
10
- import { getEnumValues } from "./enums";
11
11
  import { hasFlag } from "./flag";
12
12
 
13
13
  const TRANSFORMATION_TO_TAG_MAP = new ReadonlyMap<PlayerForm, ItemConfigTag>([
@@ -39,7 +39,7 @@ export function getPlayerTransformations(
39
39
  player: EntityPlayer,
40
40
  ): Set<PlayerForm> {
41
41
  const transformations = new Set<PlayerForm>();
42
- for (const playerForm of getEnumValues(PlayerForm)) {
42
+ for (const playerForm of PLAYER_FORM_VALUES) {
43
43
  if (player.HasPlayerForm(playerForm)) {
44
44
  transformations.add(playerForm);
45
45
  }
@@ -71,9 +71,8 @@ export function getTransformationsForCollectibleType(
71
71
  ): Set<PlayerForm> {
72
72
  const itemConfigTags = getCollectibleTags(collectibleType);
73
73
 
74
- const playerForms = getEnumValues(PlayerForm);
75
74
  const transformationSet = new Set<PlayerForm>();
76
- for (const playerForm of playerForms) {
75
+ for (const playerForm of PLAYER_FORM_VALUES) {
77
76
  const itemConfigTag = TRANSFORMATION_TO_TAG_MAP.get(playerForm);
78
77
  if (itemConfigTag === undefined) {
79
78
  continue;
@@ -13,6 +13,7 @@ import {
13
13
  GridEntityXMLType,
14
14
  InputHook,
15
15
  ItemType,
16
+ Keyboard,
16
17
  KnifeVariant,
17
18
  LaserVariant,
18
19
  PickupVariant,
@@ -366,6 +367,12 @@ export interface AddCallbackParametersCustom {
366
367
  trinketType?: TrinketType,
367
368
  ];
368
369
 
370
+ [ModCallbackCustom.POST_KEYBOARD_CHANGED]: [
371
+ callback: (keyboard: Keyboard, pressed: boolean) => void,
372
+ keyboard?: Keyboard,
373
+ pressed?: boolean,
374
+ ];
375
+
369
376
  [ModCallbackCustom.POST_KNIFE_INIT_LATE]: [
370
377
  callback: (knife: EntityKnife) => void,
371
378
  knifeVariant?: KnifeVariant,