isaacscript-common 20.2.0 → 20.3.1

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 (103) hide show
  1. package/dist/index.d.ts +54 -21
  2. package/dist/isaacscript-common.lua +10293 -10005
  3. package/dist/src/callbackClasses.d.ts +1 -0
  4. package/dist/src/callbackClasses.d.ts.map +1 -1
  5. package/dist/src/callbackClasses.lua +5 -0
  6. package/dist/src/callbacks.d.ts +1 -0
  7. package/dist/src/callbacks.d.ts.map +1 -1
  8. package/dist/src/callbacks.lua +2 -1
  9. package/dist/src/classes/ModUpgradedBase.d.ts +1 -1
  10. package/dist/src/classes/callbacks/PreRoomEntitySpawnFilter.d.ts +11 -0
  11. package/dist/src/classes/callbacks/PreRoomEntitySpawnFilter.d.ts.map +1 -0
  12. package/dist/src/classes/callbacks/PreRoomEntitySpawnFilter.lua +29 -0
  13. package/dist/src/classes/features/callbackLogic/CustomGridEntities.lua +3 -3
  14. package/dist/src/classes/features/callbackLogic/GridEntityCollisionDetection.lua +1 -1
  15. package/dist/src/classes/features/callbackLogic/GridEntityUpdateDetection.d.ts.map +1 -1
  16. package/dist/src/classes/features/callbackLogic/GridEntityUpdateDetection.lua +3 -3
  17. package/dist/src/classes/features/callbackLogic/PlayerCollectibleDetection.lua +1 -1
  18. package/dist/src/classes/features/other/CustomHotkeys.d.ts.map +1 -1
  19. package/dist/src/classes/features/other/CustomHotkeys.lua +2 -2
  20. package/dist/src/classes/features/other/DeployJSONRoom.lua +1 -1
  21. package/dist/src/classes/features/other/ItemPoolDetection.d.ts.map +1 -1
  22. package/dist/src/classes/features/other/ModdedElementSets.lua +3 -3
  23. package/dist/src/classes/features/other/PersistentEntities.d.ts.map +1 -1
  24. package/dist/src/classes/features/other/PersistentEntities.lua +1 -1
  25. package/dist/src/classes/features/other/PickupIndexCreation.lua +1 -1
  26. package/dist/src/classes/features/other/customStages/streakText.d.ts.map +1 -1
  27. package/dist/src/classes/features/other/extraConsoleCommands/commands.lua +0 -1
  28. package/dist/src/core/constants.d.ts +1 -1
  29. package/dist/src/core/constants.d.ts.map +1 -1
  30. package/dist/src/enums/ModCallbackCustom.d.ts +32 -7
  31. package/dist/src/enums/ModCallbackCustom.d.ts.map +1 -1
  32. package/dist/src/enums/ModCallbackCustom.lua +2 -0
  33. package/dist/src/functions/cards.lua +0 -2
  34. package/dist/src/functions/entities.lua +1 -1
  35. package/dist/src/functions/hex.d.ts +4 -3
  36. package/dist/src/functions/hex.d.ts.map +1 -1
  37. package/dist/src/functions/hex.lua +8 -0
  38. package/dist/src/functions/isaacAPIClass.d.ts +1 -1
  39. package/dist/src/functions/isaacAPIClass.d.ts.map +1 -1
  40. package/dist/src/functions/levelGrid.d.ts.map +1 -1
  41. package/dist/src/functions/levelGrid.lua +2 -2
  42. package/dist/src/functions/map.d.ts +2 -2
  43. package/dist/src/functions/map.lua +1 -1
  44. package/dist/src/functions/minimap.lua +1 -1
  45. package/dist/src/functions/table.d.ts +1 -1
  46. package/dist/src/functions/table.d.ts.map +1 -1
  47. package/dist/src/functions/utils.d.ts +5 -5
  48. package/dist/src/functions/utils.d.ts.map +1 -1
  49. package/dist/src/functions/utils.lua +9 -18
  50. package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts +7 -1
  51. package/dist/src/interfaces/private/AddCallbackParametersCustom.d.ts.map +1 -1
  52. package/dist/src/maps/characterNameToTypeMap.d.ts +1 -1
  53. package/dist/src/maps/characterNameToTypeMap.d.ts.map +1 -1
  54. package/dist/src/objects/roomShapeToDoorSlotCoordinates.d.ts +1 -1
  55. package/dist/src/objects/roomShapeToDoorSlotCoordinates.d.ts.map +1 -1
  56. package/dist/src/sets/bossSets.lua +5 -5
  57. package/dist/src/sets/entitiesWithArmorSet.d.ts +1 -1
  58. package/dist/src/sets/entitiesWithArmorSet.d.ts.map +1 -1
  59. package/package.json +2 -2
  60. package/src/callbackClasses.ts +1 -0
  61. package/src/callbacks.ts +1 -0
  62. package/src/classes/ModUpgradedBase.ts +1 -1
  63. package/src/classes/callbacks/PostTrinketBreak.ts +2 -2
  64. package/src/classes/callbacks/PreRoomEntitySpawnFilter.ts +55 -0
  65. package/src/classes/features/callbackLogic/CustomGridEntities.ts +3 -3
  66. package/src/classes/features/callbackLogic/GridEntityCollisionDetection.ts +1 -1
  67. package/src/classes/features/callbackLogic/GridEntityUpdateDetection.ts +4 -6
  68. package/src/classes/features/callbackLogic/PlayerCollectibleDetection.ts +1 -1
  69. package/src/classes/features/other/CustomHotkeys.ts +2 -8
  70. package/src/classes/features/other/DeployJSONRoom.ts +1 -1
  71. package/src/classes/features/other/FlyingDetection.ts +2 -2
  72. package/src/classes/features/other/ItemPoolDetection.ts +3 -5
  73. package/src/classes/features/other/ModdedElementSets.ts +4 -4
  74. package/src/classes/features/other/PersistentEntities.ts +1 -4
  75. package/src/classes/features/other/PickupIndexCreation.ts +1 -1
  76. package/src/classes/features/other/PonyDetection.ts +2 -2
  77. package/src/classes/features/other/customStages/backdrop.ts +2 -2
  78. package/src/classes/features/other/customStages/streakText.ts +6 -4
  79. package/src/classes/features/other/saveDataManager/glowingHourGlass.ts +2 -2
  80. package/src/core/constants.ts +7 -6
  81. package/src/enums/ModCallbackCustom.ts +32 -6
  82. package/src/functions/bitSet128.ts +1 -1
  83. package/src/functions/color.ts +1 -1
  84. package/src/functions/hex.ts +4 -2
  85. package/src/functions/input.ts +6 -6
  86. package/src/functions/isaacAPIClass.ts +1 -1
  87. package/src/functions/kColor.ts +1 -1
  88. package/src/functions/levelGrid.ts +3 -9
  89. package/src/functions/map.ts +2 -2
  90. package/src/functions/merge.ts +1 -1
  91. package/src/functions/minimap.ts +1 -1
  92. package/src/functions/rng.ts +1 -1
  93. package/src/functions/table.ts +1 -1
  94. package/src/functions/utils.ts +9 -15
  95. package/src/functions/vector.ts +1 -1
  96. package/src/interfaces/private/AddCallbackParametersCustom.ts +14 -0
  97. package/src/maps/characterNameToTypeMap.ts +86 -85
  98. package/src/objects/roomShapeBounds.ts +2 -2
  99. package/src/objects/roomShapeLayoutSizes.ts +4 -4
  100. package/src/objects/roomShapeToDoorSlotCoordinates.ts +1 -1
  101. package/src/patchErrorFunctions.ts +2 -2
  102. package/src/sets/bossSets.ts +5 -5
  103. package/src/sets/entitiesWithArmorSet.ts +1 -1
package/dist/index.d.ts CHANGED
@@ -579,6 +579,12 @@ declare interface AddCallbackParametersCustom {
579
579
  variant?: int,
580
580
  subType?: int
581
581
  ];
582
+ [ModCallbackCustom.PRE_ROOM_ENTITY_SPAWN_FILTER]: [
583
+ callback: (entityTypeOrGridEntityXMLType: EntityType | GridEntityXMLType, variant: int, subType: int, gridIndex: int, seed: Seed) => [EntityType | GridEntityXMLType, int, int] | undefined,
584
+ entityTypeOrGridEntityXMLType?: EntityType | GridEntityXMLType,
585
+ variant?: int,
586
+ subType?: int
587
+ ];
582
588
  }
583
589
 
584
590
  /**
@@ -1102,7 +1108,7 @@ export declare const CARD_NAME_TO_TYPE_MAP: ReadonlyMap<string, CardType>;
1102
1108
  export declare function changeRoom(roomGridIndex: int): void;
1103
1109
 
1104
1110
  /** Maps character names to the values of the `PlayerType` enum. */
1105
- export declare const CHARACTER_NAME_TO_TYPE_MAP: Map<string, PlayerType>;
1111
+ export declare const CHARACTER_NAME_TO_TYPE_MAP: ReadonlyMap<string, PlayerType>;
1106
1112
 
1107
1113
  /**
1108
1114
  * Helper function to determine if the given character can have red heart containers. Returns true
@@ -1477,7 +1483,7 @@ export declare function copyRNG(rng: RNG): RNG;
1477
1483
  export declare function copySet<T>(oldSet: Set<T> | ReadonlySet<T>): Set<T>;
1478
1484
 
1479
1485
  /** Helper function to copy specific values from a userdata object (e.g. `Vector`) to a table. */
1480
- export declare function copyUserdataValuesToTable(object: unknown, keys: string[], luaMap: LuaMap<string, unknown>): void;
1486
+ export declare function copyUserdataValuesToTable(object: unknown, keys: string[] | readonly string[], luaMap: LuaMap<string, unknown>): void;
1481
1487
 
1482
1488
  /** Helper function to copy a `Vector` Isaac API class. */
1483
1489
  export declare function copyVector(vector: Vector): Vector;
@@ -3565,8 +3571,8 @@ export declare type EntityID = string & {
3565
3571
  * - For example, `eRange(1, 3)` will return `[1, 2]`.
3566
3572
  * - For example, `eRange(2)` will return `[0, 1]`.
3567
3573
  *
3568
- * @param start The number to start at.
3569
- * @param end Optional. The number to end at. If not specified, then the start will be 0 and the
3574
+ * @param start The integer to start at.
3575
+ * @param end Optional. The integer to end at. If not specified, then the start will be 0 and the
3570
3576
  * first argument will be the end.
3571
3577
  * @param increment Optional. The increment to use. Default is 1.
3572
3578
  */
@@ -5120,10 +5126,10 @@ export declare function getLastFrameOfAnimation(sprite: Sprite, animation?: stri
5120
5126
  * ]);
5121
5127
  * const searchText = "f";
5122
5128
  * const match = getMapPartialMatch(map, searchText); // match is now equal to ["foo", 123]
5129
+ * ```
5123
5130
  *
5124
5131
  * @returns If a match was found, returns a tuple of the map key and value. If a match was not
5125
- * found, returns undefined.
5126
- * ```
5132
+ * found, returns undefined.
5127
5133
  */
5128
5134
  export declare function getMapPartialMatch<T>(searchText: string, map: ReadonlyMap<string, T>): [string, T] | undefined;
5129
5135
 
@@ -6813,15 +6819,17 @@ export declare enum HealthType {
6813
6819
  * Converts a hex string like "#33aa33" to a KColor object.
6814
6820
  *
6815
6821
  * @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
6822
+ * @param alpha Optional. Range is from 0 to 1. Default is 1. (The same as the `Color` constructor.)
6816
6823
  */
6817
- export declare function hexToColor(hexString: string, alpha: float): Color;
6824
+ export declare function hexToColor(hexString: string, alpha?: number): Color;
6818
6825
 
6819
6826
  /**
6820
6827
  * Converts a hex string like "#33aa33" to a Color object.
6821
6828
  *
6822
6829
  * @param hexString A hex string like "#ffffff" or "ffffff". (The "#" character is optional.)
6830
+ * @param alpha Range is from 0 to 1. Default is 1.
6823
6831
  */
6824
- export declare function hexToKColor(hexString: string, alpha: float): KColor;
6832
+ export declare function hexToKColor(hexString: string, alpha?: number): KColor;
6825
6833
 
6826
6834
  /**
6827
6835
  * Helper type to make the given array/map/set/object recursively read-only.
@@ -7002,8 +7010,8 @@ export declare function inStartingRoom(): boolean;
7002
7010
  * - For example, `iRange(1, 3)` will return `[1, 2, 3]`.
7003
7011
  * - For example, `iRange(2)` will return `[0, 1, 2]`.
7004
7012
  *
7005
- * @param start The number to start at.
7006
- * @param end Optional. The number to end at. If not specified, then the start will be 0 and the
7013
+ * @param start The integer to start at.
7014
+ * @param end Optional. The integer to end at. If not specified, then the start will be 0 and the
7007
7015
  * first argument will be the end.
7008
7016
  * @param increment Optional. The increment to use. Default is 1.
7009
7017
  */
@@ -7013,7 +7021,7 @@ export declare function iRange(start: int, end?: int, increment?: number): int[]
7013
7021
  * Helper function to check if an instantiated Isaac API class is equal to another one of the same
7014
7022
  * type. You must provide the list of keys to check for.
7015
7023
  */
7016
- export declare function isaacAPIClassEquals(object1: unknown, object2: unknown, keys: string[]): boolean;
7024
+ export declare function isaacAPIClassEquals(object1: unknown, object2: unknown, keys: string[] | readonly string[]): boolean;
7017
7025
 
7018
7026
  declare interface IsaacAPIClassTypeToSerializedType {
7019
7027
  [CopyableIsaacAPIClassType.BIT_SET_128]: SerializedBitSet128;
@@ -8015,7 +8023,7 @@ export declare function isVanillaWallGridIndex(gridIndex: int): boolean;
8015
8023
  export declare function isVector(object: unknown): object is Vector;
8016
8024
 
8017
8025
  /** The set of all `ItemConfigCardType` values that are not a rune or special object. */
8018
- export declare const ITEM_CONFIG_CARD_TYPES_FOR_CARDS: Set<ItemConfigCardType>;
8026
+ export declare const ITEM_CONFIG_CARD_TYPES_FOR_CARDS: ReadonlySet<ItemConfigCardType>;
8019
8027
 
8020
8028
  /**
8021
8029
  * A cached version of the class returned from the `Isaac.GetItemConfig()` constructor.
@@ -10409,12 +10417,14 @@ export declare enum ModCallbackCustom {
10409
10417
  *
10410
10418
  * ```ts
10411
10419
  * function preEntitySpawnFilter(
10412
- * entity: Entity,
10413
- * amount: float,
10414
- * damageFlags: BitFlags<DamageFlag>,
10415
- * source: EntityRef,
10416
- * countdownFrames: int,
10417
- * ): boolean | undefined {}
10420
+ * entityType: EntityType,
10421
+ * variant: int,
10422
+ * subType: int,
10423
+ * position: Vector,
10424
+ * velocity: Vector,
10425
+ * spawner: Entity | undefined,
10426
+ * initSeed: Seed,
10427
+ * ): [EntityType, int, int, int] | undefined {}
10418
10428
  * ```
10419
10429
  */
10420
10430
  PRE_ENTITY_SPAWN_FILTER = 102,
@@ -10509,7 +10519,30 @@ export declare enum ModCallbackCustom {
10509
10519
  * function preNPCUpdateFilter(entity: Entity): boolean | undefined {}
10510
10520
  * ```
10511
10521
  */
10512
- PRE_NPC_UPDATE_FILTER = 107
10522
+ PRE_NPC_UPDATE_FILTER = 107,
10523
+ /**
10524
+ * The exact same thing as the vanilla `PRE_ROOM_ENTITY_SPAWN` callback, except this callback
10525
+ * allows you to specify extra arguments for additional filtration.
10526
+ *
10527
+ * When registering the callback with the `ModUpgraded.AddCallbackCustom` method:
10528
+ * - You can provide an optional third argument that will make the callback only fire if it
10529
+ * matches the `EntityType` or `GridEntityXMLType` provided.
10530
+ * - You can provide an optional fourth argument that will make the callback only fire if it
10531
+ * matches the variant provided.
10532
+ * - You can provide an optional fifth argument that will make the callback only fire if it
10533
+ * matches the sub-type provided.
10534
+ *
10535
+ * ```ts
10536
+ * function preRoomEntitySpawnFilter(
10537
+ * entityTypeOrGridEntityXMLType: EntityType | GridEntityXMLType,
10538
+ * variant: int,
10539
+ * subType: int,
10540
+ * gridIndex: int,
10541
+ * seed: Seed,
10542
+ * ): [EntityType | GridEntityXMLType, int, int] | undefined {}
10543
+ * ```
10544
+ */
10545
+ PRE_ROOM_ENTITY_SPAWN_FILTER = 108
10513
10546
  }
10514
10547
 
10515
10548
  /**
@@ -11476,7 +11509,7 @@ export declare class ModUpgradedBase implements Mod {
11476
11509
  /**
11477
11510
  * Returns the names of the exported class methods from the features that were added. This is
11478
11511
  * called from the "upgradeMod" function, but we want to mark it as private so that end-users
11479
- * don't have access to it..
11512
+ * don't have access to it.
11480
11513
  */
11481
11514
  private initOptionalFeature;
11482
11515
  /**
@@ -15064,7 +15097,7 @@ export declare function validateEnumContiguous<T>(transpiledEnumName: string, tr
15064
15097
  *
15065
15098
  * This function is only meant to be used with interfaces (i.e. types that will not exist at
15066
15099
  * run-time). If you are generating an object that will contain all of the keys of an enum, use the
15067
- * `newObjectWithEnumKeys` helper function instead.
15100
+ * `satisfies` operator with the `HasAllEnumValues` helper type instead.
15068
15101
  */
15069
15102
  export declare function validateInterfaceMatchesEnum<T extends Record<Enum, unknown>, Enum extends string | number>(): void;
15070
15103