isaacscript-common 31.5.0 → 31.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 (126) hide show
  1. package/dist/index.rollup.d.ts +26 -4
  2. package/dist/isaacscript-common.lua +626 -645
  3. package/dist/src/classes/ModFeature.d.ts.map +1 -1
  4. package/dist/src/classes/ModFeature.lua +5 -9
  5. package/dist/src/classes/ModUpgraded.d.ts.map +1 -1
  6. package/dist/src/classes/ModUpgraded.lua +8 -14
  7. package/dist/src/classes/callbacks/PostNewRoomEarly.lua +2 -2
  8. package/dist/src/classes/features/callbackLogic/CustomGridEntities.d.ts.map +1 -1
  9. package/dist/src/classes/features/callbackLogic/CustomGridEntities.lua +3 -3
  10. package/dist/src/classes/features/other/CharacterHealthConversion.lua +1 -1
  11. package/dist/src/classes/features/other/CustomItemPools.d.ts.map +1 -1
  12. package/dist/src/classes/features/other/CustomItemPools.lua +12 -6
  13. package/dist/src/classes/features/other/CustomStages.d.ts.map +1 -1
  14. package/dist/src/classes/features/other/CustomStages.lua +12 -14
  15. package/dist/src/classes/features/other/CustomTrapdoors.d.ts.map +1 -1
  16. package/dist/src/classes/features/other/CustomTrapdoors.lua +6 -8
  17. package/dist/src/classes/features/other/DeployJSONRoom.d.ts.map +1 -1
  18. package/dist/src/classes/features/other/DeployJSONRoom.lua +15 -15
  19. package/dist/src/classes/features/other/ModdedElementSets.d.ts.map +1 -1
  20. package/dist/src/classes/features/other/ModdedElementSets.lua +21 -12
  21. package/dist/src/classes/features/other/Pause.d.ts.map +1 -1
  22. package/dist/src/classes/features/other/Pause.lua +4 -6
  23. package/dist/src/classes/features/other/SaveDataManager.d.ts.map +1 -1
  24. package/dist/src/classes/features/other/SaveDataManager.lua +5 -9
  25. package/dist/src/classes/features/other/customStages/backdrop.lua +9 -10
  26. package/dist/src/classes/features/other/saveDataManager/restoreDefaults.lua +1 -1
  27. package/dist/src/functions/array.d.ts +3 -0
  28. package/dist/src/functions/array.d.ts.map +1 -1
  29. package/dist/src/functions/array.lua +9 -3
  30. package/dist/src/functions/bitSet128.d.ts.map +1 -1
  31. package/dist/src/functions/bitSet128.lua +4 -6
  32. package/dist/src/functions/bitwise.d.ts.map +1 -1
  33. package/dist/src/functions/bitwise.lua +7 -3
  34. package/dist/src/functions/color.d.ts.map +1 -1
  35. package/dist/src/functions/color.lua +5 -9
  36. package/dist/src/functions/deepCopy.lua +23 -31
  37. package/dist/src/functions/entities.d.ts.map +1 -1
  38. package/dist/src/functions/entities.lua +20 -18
  39. package/dist/src/functions/entitiesSpecific.d.ts.map +1 -1
  40. package/dist/src/functions/entitiesSpecific.lua +11 -27
  41. package/dist/src/functions/enums.d.ts +6 -4
  42. package/dist/src/functions/enums.d.ts.map +1 -1
  43. package/dist/src/functions/enums.lua +13 -9
  44. package/dist/src/functions/gridEntities.d.ts.map +1 -1
  45. package/dist/src/functions/gridEntities.lua +18 -11
  46. package/dist/src/functions/gridEntitiesSpecific.d.ts.map +1 -1
  47. package/dist/src/functions/gridEntitiesSpecific.lua +16 -28
  48. package/dist/src/functions/input.d.ts +3 -0
  49. package/dist/src/functions/input.d.ts.map +1 -1
  50. package/dist/src/functions/input.lua +14 -14
  51. package/dist/src/functions/jsonRoom.d.ts.map +1 -1
  52. package/dist/src/functions/jsonRoom.lua +35 -23
  53. package/dist/src/functions/kColor.d.ts.map +1 -1
  54. package/dist/src/functions/kColor.lua +6 -12
  55. package/dist/src/functions/map.d.ts.map +1 -1
  56. package/dist/src/functions/map.lua +3 -3
  57. package/dist/src/functions/minimap.d.ts.map +1 -1
  58. package/dist/src/functions/minimap.lua +17 -9
  59. package/dist/src/functions/players.d.ts.map +1 -1
  60. package/dist/src/functions/players.lua +17 -22
  61. package/dist/src/functions/rng.d.ts.map +1 -1
  62. package/dist/src/functions/rng.lua +3 -3
  63. package/dist/src/functions/roomShapeWalls.d.ts.map +1 -1
  64. package/dist/src/functions/roomShapeWalls.lua +7 -3
  65. package/dist/src/functions/roomTransition.d.ts.map +1 -1
  66. package/dist/src/functions/roomTransition.lua +7 -3
  67. package/dist/src/functions/rooms.d.ts.map +1 -1
  68. package/dist/src/functions/rooms.lua +8 -5
  69. package/dist/src/functions/serialization.d.ts.map +1 -1
  70. package/dist/src/functions/serialization.lua +8 -18
  71. package/dist/src/functions/table.d.ts.map +1 -1
  72. package/dist/src/functions/table.lua +6 -12
  73. package/dist/src/functions/tstlClass.d.ts.map +1 -1
  74. package/dist/src/functions/tstlClass.lua +3 -3
  75. package/dist/src/functions/utils.d.ts +9 -0
  76. package/dist/src/functions/utils.d.ts.map +1 -1
  77. package/dist/src/functions/utils.lua +14 -6
  78. package/dist/src/functions/vector.d.ts.map +1 -1
  79. package/dist/src/functions/vector.lua +4 -6
  80. package/dist/src/functions/weighted.d.ts.map +1 -1
  81. package/dist/src/functions/weighted.lua +7 -3
  82. package/dist/src/sets/bossSets.d.ts.map +1 -1
  83. package/dist/src/sets/bossSets.lua +3 -3
  84. package/package.json +2 -2
  85. package/src/classes/ModFeature.ts +16 -12
  86. package/src/classes/ModUpgraded.ts +18 -16
  87. package/src/classes/callbacks/PostNewRoomEarly.ts +2 -2
  88. package/src/classes/features/callbackLogic/CustomGridEntities.ts +2 -3
  89. package/src/classes/features/other/CharacterHealthConversion.ts +1 -1
  90. package/src/classes/features/other/CustomItemPools.ts +9 -8
  91. package/src/classes/features/other/CustomStages.ts +9 -10
  92. package/src/classes/features/other/CustomTrapdoors.ts +9 -10
  93. package/src/classes/features/other/DeployJSONRoom.ts +21 -21
  94. package/src/classes/features/other/ModdedElementSets.ts +18 -21
  95. package/src/classes/features/other/Pause.ts +9 -6
  96. package/src/classes/features/other/SaveDataManager.ts +14 -16
  97. package/src/classes/features/other/customStages/backdrop.ts +5 -6
  98. package/src/classes/features/other/saveDataManager/restoreDefaults.ts +1 -1
  99. package/src/functions/array.ts +8 -6
  100. package/src/functions/bitSet128.ts +9 -10
  101. package/src/functions/bitwise.ts +6 -3
  102. package/src/functions/color.ts +13 -15
  103. package/src/functions/deepCopy.ts +18 -24
  104. package/src/functions/deepCopyTests.ts +5 -6
  105. package/src/functions/entities.ts +22 -20
  106. package/src/functions/entitiesSpecific.ts +10 -27
  107. package/src/functions/enums.ts +29 -17
  108. package/src/functions/gridEntities.ts +14 -16
  109. package/src/functions/gridEntitiesSpecific.ts +15 -28
  110. package/src/functions/input.ts +3 -3
  111. package/src/functions/jsonRoom.ts +39 -27
  112. package/src/functions/kColor.ts +17 -20
  113. package/src/functions/map.ts +5 -5
  114. package/src/functions/minimap.ts +16 -15
  115. package/src/functions/players.ts +7 -10
  116. package/src/functions/rng.ts +5 -5
  117. package/src/functions/roomShapeWalls.ts +3 -4
  118. package/src/functions/roomTransition.ts +5 -5
  119. package/src/functions/rooms.ts +5 -6
  120. package/src/functions/serialization.ts +25 -30
  121. package/src/functions/table.ts +18 -20
  122. package/src/functions/tstlClass.ts +5 -5
  123. package/src/functions/utils.ts +27 -6
  124. package/src/functions/vector.ts +9 -10
  125. package/src/functions/weighted.ts +5 -5
  126. package/src/sets/bossSets.ts +5 -5
@@ -1194,6 +1194,16 @@ export declare function asPillEffect(num: number): PillEffect;
1194
1194
  */
1195
1195
  export declare function asPlayerType(num: number): PlayerType;
1196
1196
 
1197
+ /**
1198
+ * Helper function to throw an error (using the `error` Lua function) if the provided value is equal
1199
+ * to `undefined`.
1200
+ *
1201
+ * This is useful to have TypeScript narrow a `T | undefined` value to `T` in a concise way.
1202
+ */
1203
+ export declare function assertDefined<T>(value: T, ...[msg]: [undefined] extends [T] ? [string] : [
1204
+ "The assertion is useless because the provided value does not contain undefined."
1205
+ ]): asserts value is Exclude<T, undefined>;
1206
+
1197
1207
  /**
1198
1208
  * Helper function to safely cast an enum to a `string`. (This is better than using the `as`
1199
1209
  * TypeScript keyword to do a type assertion, since that can obfuscate compiler errors. )
@@ -5263,10 +5273,10 @@ export declare function getEnumEntries<T>(transpiledEnum: T): Array<[key: string
5263
5273
  * For a more in depth explanation, see:
5264
5274
  * https://isaacscript.github.io/main/gotchas#iterating-over-enums
5265
5275
  */
5266
- export declare function getEnumKeys<T>(transpiledEnum: T): string[];
5276
+ export declare function getEnumKeys(transpiledEnum: Record<string | number, string | number>): string[];
5267
5277
 
5268
5278
  /** Helper function to get the amount of entries inside of an enum. */
5269
- export declare function getEnumLength<T>(transpiledEnum: T): int;
5279
+ export declare function getEnumLength(transpiledEnum: Record<string | number, string | number>): int;
5270
5280
 
5271
5281
  /**
5272
5282
  * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
@@ -5486,8 +5496,8 @@ export declare function getHeartsUIWidth(): int;
5486
5496
  /**
5487
5497
  * Helper function to get the enum value with the highest value.
5488
5498
  *
5489
- * Note that this is not necessarily the enum value that is declared last, since there is no way to
5490
- * infer that at run-time.
5499
+ * Note that this is not necessarily the enum value that is declared last in the code, since there
5500
+ * is no way to infer that at run-time.
5491
5501
  */
5492
5502
  export declare function getHighestEnumValue<T>(transpiledEnum: T): T[keyof T];
5493
5503
 
@@ -5628,6 +5638,9 @@ export declare function getLasers(laserVariant?: LaserVariant | -1, subType?: nu
5628
5638
  * Helper function to return the last element of an array.
5629
5639
  *
5630
5640
  * If the array is empty, this will return undefined.
5641
+ *
5642
+ * (Note that TSTL does not support `Array.at(-1)`, which would make this helper function largely
5643
+ * unnecessary.)
5631
5644
  */
5632
5645
  export declare function getLastElement<T>(array: T[]): T | undefined;
5633
5646
 
@@ -8281,6 +8294,9 @@ export declare function isEntity(variable: unknown): variable is Entity;
8281
8294
  */
8282
8295
  export declare function isEntityMoving(entity: Entity, threshold?: number): boolean;
8283
8296
 
8297
+ /** Helper function to validate that a particular value exists inside of an enum. */
8298
+ export declare function isEnumValue(value: number | string, transpiledEnum: Record<string | number, string | number>): boolean;
8299
+
8284
8300
  export declare function isEven(num: int): boolean;
8285
8301
 
8286
8302
  /** Helper function to detect if a variable is of type `EntityFamiliar`. */
@@ -13053,6 +13069,8 @@ export declare class ModFeature {
13053
13069
  uninit(): void;
13054
13070
  }
13055
13071
 
13072
+ export declare const MODIFIER_KEYS: readonly [Keyboard.LEFT_SHIFT, Keyboard.LEFT_CONTROL, Keyboard.LEFT_ALT, Keyboard.LEFT_SUPER, Keyboard.RIGHT_SHIFT, Keyboard.RIGHT_CONTROL, Keyboard.RIGHT_ALT, Keyboard.RIGHT_SUPER];
13073
+
13056
13074
  /**
13057
13075
  * `isaacscript-common` has many custom callbacks that you can use in your mods. Instead of
13058
13076
  * hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to use, which
@@ -13146,6 +13164,8 @@ export declare class ModUpgraded implements Mod {
13146
13164
  */
13147
13165
  declare type ModUpgradedWithFeatures<T extends readonly ISCFeature[] = []> = ModUpgraded & ISCFeaturesToKeys<T>;
13148
13166
 
13167
+ export declare const MOVEMENT_ACTIONS: readonly [ButtonAction.LEFT, ButtonAction.RIGHT, ButtonAction.UP, ButtonAction.DOWN];
13168
+
13149
13169
  export declare const MOVEMENT_ACTIONS_SET: ReadonlySet<ButtonAction>;
13150
13170
 
13151
13171
  /**
@@ -16004,6 +16024,8 @@ export declare function setUnseeded(): void;
16004
16024
  */
16005
16025
  export declare const sfxManager: SFXManager;
16006
16026
 
16027
+ export declare const SHOOTING_ACTIONS: readonly [ButtonAction.SHOOT_LEFT, ButtonAction.SHOOT_RIGHT, ButtonAction.SHOOT_UP, ButtonAction.SHOOT_DOWN];
16028
+
16007
16029
  export declare const SHOOTING_ACTIONS_SET: ReadonlySet<ButtonAction>;
16008
16030
 
16009
16031
  declare function shouldFireCollectibleType(fireArgs: [player: EntityPlayer, collectibleType: CollectibleType], optionalArgs: [collectibleType?: CollectibleType]): boolean;