isaacscript-common 31.4.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 (196) hide show
  1. package/dist/index.rollup.d.ts +38 -4
  2. package/dist/isaacscript-common.lua +722 -684
  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/debugDisplay/DebugDisplayBomb.d.ts.map +1 -1
  27. package/dist/src/classes/features/other/debugDisplay/DebugDisplayBomb.lua +2 -1
  28. package/dist/src/classes/features/other/debugDisplay/DebugDisplayDoor.d.ts.map +1 -1
  29. package/dist/src/classes/features/other/debugDisplay/DebugDisplayDoor.lua +2 -1
  30. package/dist/src/classes/features/other/debugDisplay/DebugDisplayEffect.d.ts.map +1 -1
  31. package/dist/src/classes/features/other/debugDisplay/DebugDisplayEffect.lua +2 -1
  32. package/dist/src/classes/features/other/debugDisplay/DebugDisplayFamiliar.d.ts.map +1 -1
  33. package/dist/src/classes/features/other/debugDisplay/DebugDisplayFamiliar.lua +2 -1
  34. package/dist/src/classes/features/other/debugDisplay/DebugDisplayKnife.d.ts.map +1 -1
  35. package/dist/src/classes/features/other/debugDisplay/DebugDisplayKnife.lua +2 -1
  36. package/dist/src/classes/features/other/debugDisplay/DebugDisplayLaser.d.ts.map +1 -1
  37. package/dist/src/classes/features/other/debugDisplay/DebugDisplayLaser.lua +2 -1
  38. package/dist/src/classes/features/other/debugDisplay/DebugDisplayNPC.d.ts.map +1 -1
  39. package/dist/src/classes/features/other/debugDisplay/DebugDisplayNPC.lua +2 -1
  40. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPickup.d.ts.map +1 -1
  41. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPickup.lua +2 -1
  42. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPit.d.ts.map +1 -1
  43. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPit.lua +2 -1
  44. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPlayer.d.ts.map +1 -1
  45. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPlayer.lua +2 -1
  46. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPoop.d.ts.map +1 -1
  47. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPoop.lua +2 -1
  48. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPressurePlate.d.ts.map +1 -1
  49. package/dist/src/classes/features/other/debugDisplay/DebugDisplayPressurePlate.lua +2 -1
  50. package/dist/src/classes/features/other/debugDisplay/DebugDisplayProjectile.d.ts.map +1 -1
  51. package/dist/src/classes/features/other/debugDisplay/DebugDisplayProjectile.lua +2 -1
  52. package/dist/src/classes/features/other/debugDisplay/DebugDisplayRock.d.ts.map +1 -1
  53. package/dist/src/classes/features/other/debugDisplay/DebugDisplayRock.lua +2 -1
  54. package/dist/src/classes/features/other/debugDisplay/DebugDisplaySlot.d.ts.map +1 -1
  55. package/dist/src/classes/features/other/debugDisplay/DebugDisplaySlot.lua +2 -1
  56. package/dist/src/classes/features/other/debugDisplay/DebugDisplaySpikes.d.ts.map +1 -1
  57. package/dist/src/classes/features/other/debugDisplay/DebugDisplaySpikes.lua +2 -1
  58. package/dist/src/classes/features/other/debugDisplay/DebugDisplayTNT.d.ts.map +1 -1
  59. package/dist/src/classes/features/other/debugDisplay/DebugDisplayTNT.lua +2 -1
  60. package/dist/src/classes/features/other/debugDisplay/DebugDisplayTear.d.ts.map +1 -1
  61. package/dist/src/classes/features/other/debugDisplay/DebugDisplayTear.lua +2 -1
  62. package/dist/src/classes/features/other/debugDisplay/utils.d.ts +0 -1
  63. package/dist/src/classes/features/other/debugDisplay/utils.d.ts.map +1 -1
  64. package/dist/src/classes/features/other/debugDisplay/utils.lua +0 -17
  65. package/dist/src/classes/features/other/saveDataManager/restoreDefaults.lua +1 -1
  66. package/dist/src/functions/array.d.ts +3 -0
  67. package/dist/src/functions/array.d.ts.map +1 -1
  68. package/dist/src/functions/array.lua +9 -3
  69. package/dist/src/functions/bitSet128.d.ts.map +1 -1
  70. package/dist/src/functions/bitSet128.lua +4 -6
  71. package/dist/src/functions/bitwise.d.ts.map +1 -1
  72. package/dist/src/functions/bitwise.lua +7 -3
  73. package/dist/src/functions/color.d.ts.map +1 -1
  74. package/dist/src/functions/color.lua +5 -9
  75. package/dist/src/functions/deepCopy.lua +23 -31
  76. package/dist/src/functions/entities.d.ts.map +1 -1
  77. package/dist/src/functions/entities.lua +20 -18
  78. package/dist/src/functions/entitiesSpecific.d.ts.map +1 -1
  79. package/dist/src/functions/entitiesSpecific.lua +11 -27
  80. package/dist/src/functions/enums.d.ts +6 -4
  81. package/dist/src/functions/enums.d.ts.map +1 -1
  82. package/dist/src/functions/enums.lua +13 -9
  83. package/dist/src/functions/gridEntities.d.ts.map +1 -1
  84. package/dist/src/functions/gridEntities.lua +18 -11
  85. package/dist/src/functions/gridEntitiesSpecific.d.ts.map +1 -1
  86. package/dist/src/functions/gridEntitiesSpecific.lua +16 -28
  87. package/dist/src/functions/input.d.ts +3 -0
  88. package/dist/src/functions/input.d.ts.map +1 -1
  89. package/dist/src/functions/input.lua +14 -14
  90. package/dist/src/functions/jsonRoom.d.ts.map +1 -1
  91. package/dist/src/functions/jsonRoom.lua +35 -23
  92. package/dist/src/functions/kColor.d.ts.map +1 -1
  93. package/dist/src/functions/kColor.lua +6 -12
  94. package/dist/src/functions/map.d.ts.map +1 -1
  95. package/dist/src/functions/map.lua +3 -3
  96. package/dist/src/functions/minimap.d.ts.map +1 -1
  97. package/dist/src/functions/minimap.lua +17 -9
  98. package/dist/src/functions/players.d.ts.map +1 -1
  99. package/dist/src/functions/players.lua +17 -22
  100. package/dist/src/functions/render.d.ts +16 -0
  101. package/dist/src/functions/render.d.ts.map +1 -0
  102. package/dist/src/functions/render.lua +50 -0
  103. package/dist/src/functions/rng.d.ts.map +1 -1
  104. package/dist/src/functions/rng.lua +3 -3
  105. package/dist/src/functions/roomShapeWalls.d.ts.map +1 -1
  106. package/dist/src/functions/roomShapeWalls.lua +7 -3
  107. package/dist/src/functions/roomTransition.d.ts.map +1 -1
  108. package/dist/src/functions/roomTransition.lua +7 -3
  109. package/dist/src/functions/rooms.d.ts.map +1 -1
  110. package/dist/src/functions/rooms.lua +8 -5
  111. package/dist/src/functions/serialization.d.ts.map +1 -1
  112. package/dist/src/functions/serialization.lua +8 -18
  113. package/dist/src/functions/table.d.ts.map +1 -1
  114. package/dist/src/functions/table.lua +6 -12
  115. package/dist/src/functions/tstlClass.d.ts.map +1 -1
  116. package/dist/src/functions/tstlClass.lua +3 -3
  117. package/dist/src/functions/utils.d.ts +9 -10
  118. package/dist/src/functions/utils.d.ts.map +1 -1
  119. package/dist/src/functions/utils.lua +14 -22
  120. package/dist/src/functions/vector.d.ts.map +1 -1
  121. package/dist/src/functions/vector.lua +4 -6
  122. package/dist/src/functions/weighted.d.ts.map +1 -1
  123. package/dist/src/functions/weighted.lua +7 -3
  124. package/dist/src/index.d.ts +2 -0
  125. package/dist/src/index.d.ts.map +1 -1
  126. package/dist/src/index.lua +8 -0
  127. package/dist/src/sets/bossSets.d.ts.map +1 -1
  128. package/dist/src/sets/bossSets.lua +3 -3
  129. package/dist/src/types/Expand.d.ts +8 -0
  130. package/dist/src/types/Expand.d.ts.map +1 -0
  131. package/dist/src/types/Expand.lua +2 -0
  132. package/package.json +2 -2
  133. package/src/classes/ModFeature.ts +16 -12
  134. package/src/classes/ModUpgraded.ts +18 -16
  135. package/src/classes/callbacks/PostNewRoomEarly.ts +2 -2
  136. package/src/classes/features/callbackLogic/CustomGridEntities.ts +2 -3
  137. package/src/classes/features/other/CharacterHealthConversion.ts +1 -1
  138. package/src/classes/features/other/CustomItemPools.ts +9 -8
  139. package/src/classes/features/other/CustomStages.ts +9 -10
  140. package/src/classes/features/other/CustomTrapdoors.ts +9 -10
  141. package/src/classes/features/other/DeployJSONRoom.ts +21 -21
  142. package/src/classes/features/other/ModdedElementSets.ts +18 -21
  143. package/src/classes/features/other/Pause.ts +9 -6
  144. package/src/classes/features/other/SaveDataManager.ts +14 -16
  145. package/src/classes/features/other/customStages/backdrop.ts +5 -6
  146. package/src/classes/features/other/debugDisplay/DebugDisplayBomb.ts +2 -1
  147. package/src/classes/features/other/debugDisplay/DebugDisplayDoor.ts +2 -1
  148. package/src/classes/features/other/debugDisplay/DebugDisplayEffect.ts +2 -1
  149. package/src/classes/features/other/debugDisplay/DebugDisplayFamiliar.ts +2 -1
  150. package/src/classes/features/other/debugDisplay/DebugDisplayKnife.ts +2 -1
  151. package/src/classes/features/other/debugDisplay/DebugDisplayLaser.ts +2 -1
  152. package/src/classes/features/other/debugDisplay/DebugDisplayNPC.ts +2 -1
  153. package/src/classes/features/other/debugDisplay/DebugDisplayPickup.ts +2 -1
  154. package/src/classes/features/other/debugDisplay/DebugDisplayPit.ts +2 -1
  155. package/src/classes/features/other/debugDisplay/DebugDisplayPlayer.ts +2 -1
  156. package/src/classes/features/other/debugDisplay/DebugDisplayPoop.ts +2 -1
  157. package/src/classes/features/other/debugDisplay/DebugDisplayPressurePlate.ts +2 -1
  158. package/src/classes/features/other/debugDisplay/DebugDisplayProjectile.ts +2 -1
  159. package/src/classes/features/other/debugDisplay/DebugDisplayRock.ts +2 -1
  160. package/src/classes/features/other/debugDisplay/DebugDisplaySlot.ts +2 -1
  161. package/src/classes/features/other/debugDisplay/DebugDisplaySpikes.ts +2 -1
  162. package/src/classes/features/other/debugDisplay/DebugDisplayTNT.ts +2 -1
  163. package/src/classes/features/other/debugDisplay/DebugDisplayTear.ts +2 -1
  164. package/src/classes/features/other/debugDisplay/utils.ts +0 -13
  165. package/src/classes/features/other/saveDataManager/restoreDefaults.ts +1 -1
  166. package/src/functions/array.ts +8 -6
  167. package/src/functions/bitSet128.ts +9 -10
  168. package/src/functions/bitwise.ts +6 -3
  169. package/src/functions/color.ts +13 -15
  170. package/src/functions/deepCopy.ts +18 -24
  171. package/src/functions/deepCopyTests.ts +5 -6
  172. package/src/functions/entities.ts +22 -20
  173. package/src/functions/entitiesSpecific.ts +10 -27
  174. package/src/functions/enums.ts +29 -17
  175. package/src/functions/gridEntities.ts +14 -16
  176. package/src/functions/gridEntitiesSpecific.ts +15 -28
  177. package/src/functions/input.ts +3 -3
  178. package/src/functions/jsonRoom.ts +39 -27
  179. package/src/functions/kColor.ts +17 -20
  180. package/src/functions/map.ts +5 -5
  181. package/src/functions/minimap.ts +16 -15
  182. package/src/functions/players.ts +7 -10
  183. package/src/functions/render.ts +53 -0
  184. package/src/functions/rng.ts +5 -5
  185. package/src/functions/roomShapeWalls.ts +3 -4
  186. package/src/functions/roomTransition.ts +5 -5
  187. package/src/functions/rooms.ts +5 -6
  188. package/src/functions/serialization.ts +25 -30
  189. package/src/functions/table.ts +18 -20
  190. package/src/functions/tstlClass.ts +5 -5
  191. package/src/functions/utils.ts +27 -23
  192. package/src/functions/vector.ts +9 -10
  193. package/src/functions/weighted.ts +5 -5
  194. package/src/index.ts +2 -0
  195. package/src/sets/bossSets.ts +5 -5
  196. package/src/types/Expand.ts +5 -0
@@ -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. )
@@ -4118,6 +4128,14 @@ declare class EsauJrDetection extends Feature {
4118
4128
  */
4119
4129
  export declare function every<T>(array: T[], func: (value: T, index: number, array: T[]) => boolean): boolean;
4120
4130
 
4131
+ /**
4132
+ * From:
4133
+ * https://stackoverflow.com/questions/57683303/how-can-i-see-the-full-expanded-contract-of-a-typescript-type
4134
+ */
4135
+ export declare type Expand<T> = T extends infer O ? {
4136
+ [K in keyof O]: O[K];
4137
+ } : never;
4138
+
4121
4139
  declare class ExtraConsoleCommands extends Feature {
4122
4140
  private readonly commandFunctionMap;
4123
4141
  private readonly postUpdate;
@@ -5255,10 +5273,10 @@ export declare function getEnumEntries<T>(transpiledEnum: T): Array<[key: string
5255
5273
  * For a more in depth explanation, see:
5256
5274
  * https://isaacscript.github.io/main/gotchas#iterating-over-enums
5257
5275
  */
5258
- export declare function getEnumKeys<T>(transpiledEnum: T): string[];
5276
+ export declare function getEnumKeys(transpiledEnum: Record<string | number, string | number>): string[];
5259
5277
 
5260
5278
  /** Helper function to get the amount of entries inside of an enum. */
5261
- export declare function getEnumLength<T>(transpiledEnum: T): int;
5279
+ export declare function getEnumLength(transpiledEnum: Record<string | number, string | number>): int;
5262
5280
 
5263
5281
  /**
5264
5282
  * TypeScriptToLua will transpile TypeScript enums to Lua tables that have a double mapping. Thus,
@@ -5478,8 +5496,8 @@ export declare function getHeartsUIWidth(): int;
5478
5496
  /**
5479
5497
  * Helper function to get the enum value with the highest value.
5480
5498
  *
5481
- * Note that this is not necessarily the enum value that is declared last, since there is no way to
5482
- * 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.
5483
5501
  */
5484
5502
  export declare function getHighestEnumValue<T>(transpiledEnum: T): T[keyof T];
5485
5503
 
@@ -5620,6 +5638,9 @@ export declare function getLasers(laserVariant?: LaserVariant | -1, subType?: nu
5620
5638
  * Helper function to return the last element of an array.
5621
5639
  *
5622
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.)
5623
5644
  */
5624
5645
  export declare function getLastElement<T>(array: T[]): T | undefined;
5625
5646
 
@@ -8273,6 +8294,9 @@ export declare function isEntity(variable: unknown): variable is Entity;
8273
8294
  */
8274
8295
  export declare function isEntityMoving(entity: Entity, threshold?: number): boolean;
8275
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
+
8276
8300
  export declare function isEven(num: int): boolean;
8277
8301
 
8278
8302
  /** Helper function to detect if a variable is of type `EntityFamiliar`. */
@@ -13045,6 +13069,8 @@ export declare class ModFeature {
13045
13069
  uninit(): void;
13046
13070
  }
13047
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
+
13048
13074
  /**
13049
13075
  * `isaacscript-common` has many custom callbacks that you can use in your mods. Instead of
13050
13076
  * hijacking the vanilla `Mod` object, we provide a `ModUpgraded` object for you to use, which
@@ -13138,6 +13164,8 @@ export declare class ModUpgraded implements Mod {
13138
13164
  */
13139
13165
  declare type ModUpgradedWithFeatures<T extends readonly ISCFeature[] = []> = ModUpgraded & ISCFeaturesToKeys<T>;
13140
13166
 
13167
+ export declare const MOVEMENT_ACTIONS: readonly [ButtonAction.LEFT, ButtonAction.RIGHT, ButtonAction.UP, ButtonAction.DOWN];
13168
+
13141
13169
  export declare const MOVEMENT_ACTIONS_SET: ReadonlySet<ButtonAction>;
13142
13170
 
13143
13171
  /**
@@ -14879,6 +14907,10 @@ export declare const RENDER_FRAMES_PER_SECOND = 60;
14879
14907
  */
14880
14908
  export declare function renderChargeBar(sprites: ChargeBarSprites, position: Vector, normalCharges: int, batteryCharges: int): void;
14881
14909
 
14910
+ export declare function renderScaledTextOnEntity(entity: Entity | GridEntity, text: string, scaleX: float, scaleY: float): void;
14911
+
14912
+ export declare function renderTextOnEntity(entity: Entity | GridEntity, text: string): void;
14913
+
14882
14914
  /**
14883
14915
  * Helper function to repeat code N times. This is faster to type and cleaner than using a for loop.
14884
14916
  *
@@ -15992,6 +16024,8 @@ export declare function setUnseeded(): void;
15992
16024
  */
15993
16025
  export declare const sfxManager: SFXManager;
15994
16026
 
16027
+ export declare const SHOOTING_ACTIONS: readonly [ButtonAction.SHOOT_LEFT, ButtonAction.SHOOT_RIGHT, ButtonAction.SHOOT_UP, ButtonAction.SHOOT_DOWN];
16028
+
15995
16029
  export declare const SHOOTING_ACTIONS_SET: ReadonlySet<ButtonAction>;
15996
16030
 
15997
16031
  declare function shouldFireCollectibleType(fireArgs: [player: EntityPlayer, collectibleType: CollectibleType], optionalArgs: [collectibleType?: CollectibleType]): boolean;