isaacscript-common 7.1.0 → 7.2.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 (255) hide show
  1. package/dist/callbacks/itemPickup.d.ts.map +1 -1
  2. package/dist/callbacks/itemPickup.lua +3 -1
  3. package/dist/callbacks/postCustomDoorEnter.d.ts.map +1 -1
  4. package/dist/callbacks/postCustomDoorEnter.lua +14 -11
  5. package/dist/callbacks/postDiceRoomActivated.d.ts.map +1 -1
  6. package/dist/callbacks/postDiceRoomActivated.lua +5 -4
  7. package/dist/callbacks/postItemDischarged.lua +2 -1
  8. package/dist/callbacks/postPlayerChangeStat.d.ts.map +1 -1
  9. package/dist/callbacks/postPlayerChangeStat.lua +44 -15
  10. package/dist/callbacks/postSlotDestroyed.lua +3 -3
  11. package/dist/classes/DefaultMap.d.ts +5 -5
  12. package/dist/classes/DefaultMap.d.ts.map +1 -1
  13. package/dist/core/constants.d.ts +2 -2
  14. package/dist/core/constants.d.ts.map +1 -1
  15. package/dist/core/constants.lua +3 -1
  16. package/dist/core/constantsFirstLast.d.ts +2 -0
  17. package/dist/core/constantsFirstLast.d.ts.map +1 -1
  18. package/dist/core/constantsFirstLast.lua +36 -9
  19. package/dist/enums/AmbushType.d.ts +1 -0
  20. package/dist/enums/AmbushType.d.ts.map +1 -1
  21. package/dist/enums/AmbushType.lua +1 -0
  22. package/dist/enums/CornerType.d.ts +1 -0
  23. package/dist/enums/CornerType.d.ts.map +1 -1
  24. package/dist/enums/CornerType.lua +1 -0
  25. package/dist/enums/PocketItemType.d.ts +1 -0
  26. package/dist/enums/PocketItemType.d.ts.map +1 -1
  27. package/dist/enums/PocketItemType.lua +1 -0
  28. package/dist/enums/RockAltType.d.ts +1 -0
  29. package/dist/enums/RockAltType.d.ts.map +1 -1
  30. package/dist/enums/RockAltType.lua +1 -0
  31. package/dist/enums/SaveDataKey.d.ts +11 -0
  32. package/dist/enums/SaveDataKey.d.ts.map +1 -0
  33. package/dist/enums/{private/SaveDataKey.lua → SaveDataKey.lua} +2 -0
  34. package/dist/enums/SerializationType.d.ts +1 -0
  35. package/dist/enums/SerializationType.d.ts.map +1 -1
  36. package/dist/enums/SerializationType.lua +1 -0
  37. package/dist/enums/SlotDestructionType.d.ts +1 -0
  38. package/dist/enums/SlotDestructionType.d.ts.map +1 -1
  39. package/dist/enums/SlotDestructionType.lua +1 -0
  40. package/dist/enums/StatType.d.ts +1 -3
  41. package/dist/enums/StatType.d.ts.map +1 -1
  42. package/dist/enums/StatType.lua +0 -2
  43. package/dist/enums/index.d.ts +1 -0
  44. package/dist/enums/index.d.ts.map +1 -1
  45. package/dist/enums/index.lua +8 -0
  46. package/dist/features/customGridEntity.d.ts.map +1 -1
  47. package/dist/features/customGridEntity.lua +3 -1
  48. package/dist/features/customStage/backdrop.d.ts +1 -1
  49. package/dist/features/customStage/backdrop.d.ts.map +1 -1
  50. package/dist/features/customStage/backdrop.lua +5 -3
  51. package/dist/features/customStage/customStageGridEntities.d.ts.map +1 -1
  52. package/dist/features/customStage/customStageGridEntities.lua +3 -1
  53. package/dist/features/customStage/exports.d.ts.map +1 -1
  54. package/dist/features/customStage/exports.lua +3 -1
  55. package/dist/features/customStage/init.lua +2 -2
  56. package/dist/features/customStage/shadows.d.ts.map +1 -1
  57. package/dist/features/customStage/shadows.lua +2 -1
  58. package/dist/features/deployJSONRoom.lua +13 -10
  59. package/dist/features/extraConsoleCommands/listCommands.d.ts.map +1 -1
  60. package/dist/features/extraConsoleCommands/listCommands.lua +8 -2
  61. package/dist/features/saveDataManager/exports.d.ts +2 -1
  62. package/dist/features/saveDataManager/exports.d.ts.map +1 -1
  63. package/dist/features/saveDataManager/main.d.ts +1 -1
  64. package/dist/features/saveDataManager/main.d.ts.map +1 -1
  65. package/dist/features/saveDataManager/main.lua +1 -1
  66. package/dist/functions/bitSet128.d.ts.map +1 -1
  67. package/dist/functions/bosses.d.ts.map +1 -1
  68. package/dist/functions/bosses.lua +3 -1
  69. package/dist/functions/cacheFlag.d.ts +23 -1
  70. package/dist/functions/cacheFlag.d.ts.map +1 -1
  71. package/dist/functions/cacheFlag.lua +78 -0
  72. package/dist/functions/collectibles.d.ts.map +1 -1
  73. package/dist/functions/deepCopy.lua +2 -1
  74. package/dist/functions/doors.d.ts.map +1 -1
  75. package/dist/functions/doors.lua +3 -1
  76. package/dist/functions/entities.lua +2 -1
  77. package/dist/functions/flying.lua +2 -2
  78. package/dist/functions/gridEntities.lua +2 -1
  79. package/dist/functions/gridEntitiesSpecific.d.ts.map +1 -1
  80. package/dist/functions/gridEntitiesSpecific.lua +5 -3
  81. package/dist/functions/index.d.ts +0 -1
  82. package/dist/functions/index.d.ts.map +1 -1
  83. package/dist/functions/index.lua +0 -8
  84. package/dist/functions/input.d.ts +5 -2
  85. package/dist/functions/input.d.ts.map +1 -1
  86. package/dist/functions/input.lua +11 -3
  87. package/dist/functions/kColor.d.ts.map +1 -1
  88. package/dist/functions/levelGrid.d.ts.map +1 -1
  89. package/dist/functions/levelGrid.lua +3 -1
  90. package/dist/functions/nextStage.d.ts.map +1 -1
  91. package/dist/functions/nextStage.lua +7 -5
  92. package/dist/functions/npcs.d.ts.map +1 -1
  93. package/dist/functions/npcs.lua +4 -2
  94. package/dist/functions/pills.d.ts.map +1 -1
  95. package/dist/functions/pills.lua +9 -3
  96. package/dist/functions/playerIndex.d.ts.map +1 -1
  97. package/dist/functions/playerIndex.lua +2 -1
  98. package/dist/functions/playerStats.d.ts.map +1 -1
  99. package/dist/functions/playerStats.lua +1 -2
  100. package/dist/functions/players.d.ts +1 -1
  101. package/dist/functions/players.d.ts.map +1 -1
  102. package/dist/functions/players.lua +13 -15
  103. package/dist/functions/pocketItems.d.ts.map +1 -1
  104. package/dist/functions/pocketItems.lua +3 -1
  105. package/dist/functions/rng.d.ts.map +1 -1
  106. package/dist/functions/rng.lua +3 -0
  107. package/dist/functions/rockAlt.d.ts.map +1 -1
  108. package/dist/functions/rockAlt.lua +11 -20
  109. package/dist/functions/rooms.d.ts +4 -4
  110. package/dist/functions/rooms.d.ts.map +1 -1
  111. package/dist/functions/rooms.lua +18 -16
  112. package/dist/functions/spawnCollectible.d.ts.map +1 -1
  113. package/dist/functions/stage.d.ts.map +1 -1
  114. package/dist/functions/stage.lua +8 -2
  115. package/dist/functions/trinkets.d.ts.map +1 -1
  116. package/dist/functions/trinkets.lua +4 -2
  117. package/dist/functions/types.d.ts +64 -0
  118. package/dist/functions/types.d.ts.map +1 -1
  119. package/dist/functions/types.lua +63 -0
  120. package/dist/functions/vector.d.ts.map +1 -1
  121. package/dist/interfaces/ChargeBarSprites.d.ts +1 -1
  122. package/dist/interfaces/Corner.d.ts +5 -0
  123. package/dist/interfaces/Corner.d.ts.map +1 -1
  124. package/dist/interfaces/CustomStageLua.d.ts +57 -0
  125. package/dist/interfaces/CustomStageLua.d.ts.map +1 -1
  126. package/dist/interfaces/GridEntityCustomData.d.ts +6 -0
  127. package/dist/interfaces/GridEntityCustomData.d.ts.map +1 -1
  128. package/dist/interfaces/JSONRoomsFile.d.ts +7 -3
  129. package/dist/interfaces/JSONRoomsFile.d.ts.map +1 -1
  130. package/dist/interfaces/PlayerHealth.d.ts +1 -1
  131. package/dist/interfaces/PlayerHealth.d.ts.map +1 -1
  132. package/dist/interfaces/PocketItemDescription.d.ts +1 -1
  133. package/dist/interfaces/PocketItemDescription.d.ts.map +1 -1
  134. package/dist/interfaces/RoomDescription.d.ts +1 -1
  135. package/dist/interfaces/RoomDescription.d.ts.map +1 -1
  136. package/dist/interfaces/StatTypeType.d.ts +4 -1
  137. package/dist/interfaces/StatTypeType.d.ts.map +1 -1
  138. package/dist/interfaces/TrinketSituation.d.ts +1 -1
  139. package/dist/interfaces/TrinketSituation.d.ts.map +1 -1
  140. package/dist/maps/keyboardToString.d.ts +4 -0
  141. package/dist/maps/keyboardToString.d.ts.map +1 -0
  142. package/dist/maps/keyboardToString.lua +73 -0
  143. package/dist/types/AnyEntity.d.ts +5 -0
  144. package/dist/types/AnyEntity.d.ts.map +1 -1
  145. package/dist/types/AnyGridEntity.d.ts +5 -0
  146. package/dist/types/AnyGridEntity.d.ts.map +1 -1
  147. package/dist/types/CollectibleIndex.d.ts +4 -3
  148. package/dist/types/CollectibleIndex.d.ts.map +1 -1
  149. package/dist/types/Immutable.d.ts +3 -1
  150. package/dist/types/Immutable.d.ts.map +1 -1
  151. package/dist/types/PickupIndex.d.ts +4 -2
  152. package/dist/types/PickupIndex.d.ts.map +1 -1
  153. package/dist/types/PlayerIndex.d.ts +3 -2
  154. package/dist/types/PlayerIndex.d.ts.map +1 -1
  155. package/dist/types/SerializedIsaacAPIClass.d.ts +6 -0
  156. package/dist/types/SerializedIsaacAPIClass.d.ts.map +1 -1
  157. package/dist/types/TSTLClass.d.ts +5 -0
  158. package/dist/types/TSTLClass.d.ts.map +1 -1
  159. package/dist/types/TrapdoorDestination.d.ts +3 -0
  160. package/dist/types/TrapdoorDestination.d.ts.map +1 -1
  161. package/package.json +2 -2
  162. package/src/callbacks/itemPickup.ts +5 -2
  163. package/src/callbacks/postCustomDoorEnter.ts +18 -11
  164. package/src/callbacks/postDiceRoomActivated.ts +7 -12
  165. package/src/callbacks/postItemDischarged.ts +3 -1
  166. package/src/callbacks/postPlayerChangeStat.ts +45 -3
  167. package/src/callbacks/postSlotDestroyed.ts +3 -2
  168. package/src/callbacks/reorderedCallbacks.ts +2 -2
  169. package/src/classes/DefaultMap.ts +8 -8
  170. package/src/core/constants.ts +3 -3
  171. package/src/core/constantsFirstLast.ts +29 -14
  172. package/src/enums/AmbushType.ts +1 -0
  173. package/src/enums/CornerType.ts +1 -0
  174. package/src/enums/PocketItemType.ts +1 -0
  175. package/src/enums/RockAltType.ts +1 -0
  176. package/src/enums/SaveDataKey.ts +10 -0
  177. package/src/enums/SerializationType.ts +1 -0
  178. package/src/enums/SlotDestructionType.ts +1 -0
  179. package/src/enums/StatType.ts +7 -7
  180. package/src/enums/index.ts +1 -0
  181. package/src/enums/indexTypeDoc.ts +1 -0
  182. package/src/features/customGridEntity.ts +2 -1
  183. package/src/features/customStage/backdrop.ts +5 -3
  184. package/src/features/customStage/customStageGridEntities.ts +2 -1
  185. package/src/features/customStage/exports.ts +5 -4
  186. package/src/features/customStage/init.ts +2 -2
  187. package/src/features/customStage/shadows.ts +2 -1
  188. package/src/features/deployJSONRoom.ts +14 -19
  189. package/src/features/extraConsoleCommands/listCommands.ts +3 -2
  190. package/src/features/fastReset.ts +1 -1
  191. package/src/features/indexTypeDoc.ts +2 -1
  192. package/src/features/saveDataManager/exports.ts +4 -4
  193. package/src/features/saveDataManager/main.ts +1 -1
  194. package/src/features/saveDataManager/save.ts +1 -1
  195. package/src/functions/bitSet128.ts +1 -5
  196. package/src/functions/bosses.ts +2 -1
  197. package/src/functions/cacheFlag.ts +90 -1
  198. package/src/functions/cards.ts +3 -3
  199. package/src/functions/collectibles.ts +2 -8
  200. package/src/functions/color.ts +1 -1
  201. package/src/functions/deepCopy.ts +2 -2
  202. package/src/functions/dimensions.ts +1 -1
  203. package/src/functions/doors.ts +2 -2
  204. package/src/functions/entities.ts +2 -2
  205. package/src/functions/flying.ts +1 -1
  206. package/src/functions/gridEntities.ts +2 -2
  207. package/src/functions/gridEntitiesSpecific.ts +4 -3
  208. package/src/functions/index.ts +0 -1
  209. package/src/functions/indexTypeDoc.ts +0 -1
  210. package/src/functions/input.ts +17 -4
  211. package/src/functions/jsonHelpers.ts +1 -1
  212. package/src/functions/kColor.ts +1 -5
  213. package/src/functions/levelGrid.ts +3 -2
  214. package/src/functions/nextStage.ts +6 -5
  215. package/src/functions/npcs.ts +3 -2
  216. package/src/functions/pills.ts +11 -9
  217. package/src/functions/playerIndex.ts +3 -1
  218. package/src/functions/playerStats.ts +0 -1
  219. package/src/functions/players.ts +5 -6
  220. package/src/functions/pocketItems.ts +4 -4
  221. package/src/functions/rng.ts +8 -5
  222. package/src/functions/rockAlt.ts +28 -13
  223. package/src/functions/rooms.ts +27 -26
  224. package/src/functions/spawnCollectible.ts +1 -2
  225. package/src/functions/stage.ts +3 -2
  226. package/src/functions/trinkets.ts +6 -5
  227. package/src/functions/types.ts +100 -0
  228. package/src/functions/vector.ts +1 -5
  229. package/src/interfaces/ChargeBarSprites.ts +1 -1
  230. package/src/interfaces/Corner.ts +5 -0
  231. package/src/interfaces/CustomStageLua.ts +66 -0
  232. package/src/interfaces/GridEntityCustomData.ts +6 -0
  233. package/src/interfaces/JSONRoomsFile.ts +7 -3
  234. package/src/interfaces/PlayerHealth.ts +1 -1
  235. package/src/interfaces/PocketItemDescription.ts +1 -1
  236. package/src/interfaces/RoomDescription.ts +1 -1
  237. package/src/interfaces/StatTypeType.ts +4 -1
  238. package/src/interfaces/TrinketSituation.ts +1 -1
  239. package/src/maps/keyboardToString.ts +77 -0
  240. package/src/types/AnyEntity.ts +5 -0
  241. package/src/types/AnyGridEntity.ts +5 -0
  242. package/src/types/CollectibleIndex.ts +4 -3
  243. package/src/types/Immutable.ts +3 -1
  244. package/src/types/PickupIndex.ts +4 -2
  245. package/src/types/PlayerIndex.ts +3 -2
  246. package/src/types/SerializedIsaacAPIClass.ts +6 -0
  247. package/src/types/TSTLClass.ts +5 -0
  248. package/src/types/TrapdoorDestination.ts +3 -0
  249. package/dist/enums/private/SaveDataKey.d.ts +0 -7
  250. package/dist/enums/private/SaveDataKey.d.ts.map +0 -1
  251. package/dist/functions/collectibleCacheFlag.d.ts +0 -24
  252. package/dist/functions/collectibleCacheFlag.d.ts.map +0 -1
  253. package/dist/functions/collectibleCacheFlag.lua +0 -80
  254. package/src/enums/private/SaveDataKey.ts +0 -6
  255. package/src/functions/collectibleCacheFlag.ts +0 -90
@@ -36,7 +36,7 @@ export function postSlotDestroyedInit(mod: ModUpgraded): void {
36
36
 
37
37
  mod.AddCallback(
38
38
  ModCallback.POST_ENTITY_REMOVE,
39
- postEntityRemove,
39
+ postEntityRemoveSlot,
40
40
  EntityType.SLOT,
41
41
  ); // 67
42
42
 
@@ -51,7 +51,8 @@ function hasSubscriptions() {
51
51
  }
52
52
 
53
53
  // ModCallback.POST_ENTITY_REMOVE (67)
54
- function postEntityRemove(entity: Entity) {
54
+ // EntityType.SLOT (6)
55
+ function postEntityRemoveSlot(entity: Entity) {
55
56
  const slot = entity as EntitySlot;
56
57
  const ptrHash = GetPtrHash(slot);
57
58
  const gameFrameCount = game.GetFrameCount();
@@ -31,8 +31,8 @@ import {
31
31
  postNewRoomReorderedHasSubscriptions,
32
32
  } from "./subscriptions/postNewRoomReordered";
33
33
 
34
- let currentStage = null as int | null;
35
- let currentStageType = null as int | null;
34
+ let currentStage: int | null = null;
35
+ let currentStageType: int | null = null;
36
36
  let usedGlowingHourGlass = false;
37
37
  let forceNewLevel = false;
38
38
  let forceNewRoom = false;
@@ -1,12 +1,5 @@
1
1
  import { isFunction, isPrimitive } from "../functions/types";
2
2
 
3
- // eslint-disable-next-line isaacscript/complete-sentences-jsdoc
4
- /**
5
- * A function that creates the default value for your `DefaultMap`. For example, if it was a
6
- * `DefaultMap` containing maps, the factory function would be: `() => new Map()`
7
- */
8
- export type FactoryFunction<V, Args extends unknown[]> = (...args: Args) => V;
9
-
10
3
  /**
11
4
  * `DefaultMap` is a data structure that makes working with default values easier.
12
5
  *
@@ -116,7 +109,7 @@ export class DefaultMap<Key, Value, Args extends unknown[] = []> extends Map<
116
109
  this.defaultValue = undefined;
117
110
  this.defaultValueFactory = defaultValueOrFactoryFunction;
118
111
  } else {
119
- this.defaultValue = defaultValueOrFactoryFunction as Value;
112
+ this.defaultValue = defaultValueOrFactoryFunction;
120
113
  this.defaultValueFactory = undefined;
121
114
  }
122
115
  }
@@ -169,6 +162,13 @@ export class DefaultMap<Key, Value, Args extends unknown[] = []> extends Map<
169
162
  }
170
163
  }
171
164
 
165
+ // eslint-disable-next-line isaacscript/complete-sentences-jsdoc
166
+ /**
167
+ * A function that creates the default value for your `DefaultMap`. For example, if it was a
168
+ * `DefaultMap` containing maps, the factory function would be: `() => new Map()`
169
+ */
170
+ export type FactoryFunction<V, Args extends unknown[]> = (...args: Args) => V;
171
+
172
172
  /* eslint-disable @typescript-eslint/no-unused-vars */
173
173
  function test() {
174
174
  // Boolean
@@ -1,5 +1,4 @@
1
1
  import {
2
- CollectibleType,
3
2
  Dimension,
4
3
  DisplayFlag,
5
4
  ItemPoolType,
@@ -7,6 +6,7 @@ import {
7
6
  } from "isaac-typescript-definitions";
8
7
  import { getEnumLength } from "../functions/enums";
9
8
  import { addFlag } from "../functions/flag";
9
+ import { asCollectibleType } from "../functions/types";
10
10
  import { NUM_NORMAL_PILL_COLORS } from "./constantsFirstLast";
11
11
 
12
12
  /**
@@ -64,8 +64,8 @@ export const EMPTY_PNG_PATH = "gfx/none.png";
64
64
  * encountered by the player. The first TMTRAINER item takes the final possible 32 bit number. The
65
65
  * second TMTRAINER item subtracts one from that, and so on.
66
66
  */
67
- export const FIRST_GLITCHED_COLLECTIBLE_TYPE = ((1 << 32) -
68
- 1) as CollectibleType;
67
+
68
+ export const FIRST_GLITCHED_COLLECTIBLE_TYPE = asCollectibleType((1 << 32) - 1);
69
69
 
70
70
  /** Game frames are what is returned by the `Game.GetFrameCount` method. */
71
71
  export const GAME_FRAMES_PER_SECOND = 30;
@@ -9,6 +9,14 @@ import {
9
9
  TrinketType,
10
10
  } from "isaac-typescript-definitions";
11
11
  import { getEnumLength, getLastEnumValue } from "../functions/enums";
12
+ import {
13
+ asCard,
14
+ asCollectibleType,
15
+ asNumber,
16
+ asPillEffect,
17
+ asPlayerType,
18
+ asTrinketType,
19
+ } from "../functions/types";
12
20
  import { itemConfig } from "./cachedClasses";
13
21
 
14
22
  // ------------
@@ -24,8 +32,9 @@ export const FIRST_COLLECTIBLE_TYPE = CollectibleType.SAD_ONION;
24
32
  * Equal to `itemConfig.GetCollectibles().Size - 1`. (`Size` includes invalid collectibles, like
25
33
  * 666. We subtract one to account for `CollectibleType.NULL`.)
26
34
  */
27
- export const LAST_COLLECTIBLE_TYPE = (itemConfig.GetCollectibles().Size -
28
- 1) as CollectibleType;
35
+ export const LAST_COLLECTIBLE_TYPE = asCollectibleType(
36
+ itemConfig.GetCollectibles().Size - 1,
37
+ );
29
38
 
30
39
  /**
31
40
  * Calculated from the `CollectibleType` enum.
@@ -39,8 +48,9 @@ export const LAST_VANILLA_COLLECTIBLE_TYPE = getLastEnumValue(CollectibleType);
39
48
  * If there are no modded collectibles, this constant will represent a collectible type that does
40
49
  * not exist.
41
50
  */
42
- export const FIRST_MODDED_COLLECTIBLE_TYPE =
43
- ((LAST_VANILLA_COLLECTIBLE_TYPE as int) + 1) as CollectibleType;
51
+ export const FIRST_MODDED_COLLECTIBLE_TYPE = asCollectibleType(
52
+ asNumber(LAST_VANILLA_COLLECTIBLE_TYPE) + 1,
53
+ );
44
54
 
45
55
  /** Calculated from the `CollectibleType` enum. `CollectibleType.NULL` is not included. */
46
56
  export const NUM_VANILLA_COLLECTIBLE_TYPES = getEnumLength(CollectibleType) - 1;
@@ -79,7 +89,7 @@ export const FIRST_TRINKET_TYPE = TrinketType.SWALLOWED_PENNY;
79
89
  * Equal to `itemConfig.GetTrinkets().Size - 1`. (We subtract one to account for
80
90
  * `TrinketType.NULL`.)
81
91
  */
82
- export const LAST_TRINKET_TYPE = NUM_TRINKET_TYPES as TrinketType;
92
+ export const LAST_TRINKET_TYPE = asTrinketType(NUM_TRINKET_TYPES);
83
93
 
84
94
  /** Calculated from the `TrinketType` enum. */
85
95
  export const LAST_VANILLA_TRINKET_TYPE = getLastEnumValue(TrinketType);
@@ -87,8 +97,9 @@ export const LAST_VANILLA_TRINKET_TYPE = getLastEnumValue(TrinketType);
87
97
  /**
88
98
  * If there are no modded trinkets, this constant will represent a trinket type that does not exist.
89
99
  */
90
- export const FIRST_MODDED_TRINKET_TYPE = ((LAST_VANILLA_TRINKET_TYPE as int) +
91
- 1) as TrinketType;
100
+ export const FIRST_MODDED_TRINKET_TYPE = asTrinketType(
101
+ asNumber(LAST_VANILLA_TRINKET_TYPE) + 1,
102
+ );
92
103
 
93
104
  // -----
94
105
  // Cards
@@ -114,13 +125,13 @@ export const FIRST_CARD = Card.FOOL;
114
125
  *
115
126
  * Equal to `itemConfig.GetCards().Size - 1`. (We subtract one to account for `Card.NULL`.)
116
127
  */
117
- export const LAST_CARD = NUM_CARDS as Card;
128
+ export const LAST_CARD = asCard(NUM_CARDS);
118
129
 
119
130
  /** Calculated from the `Card` enum. */
120
131
  export const MAX_VANILLA_CARD = getLastEnumValue(Card);
121
132
 
122
133
  /** If there are no modded cards, this constant will represent a card that does not exist. */
123
- export const FIRST_MODDED_CARD = ((MAX_VANILLA_CARD as int) + 1) as Card;
134
+ export const FIRST_MODDED_CARD = asCard(asNumber(MAX_VANILLA_CARD) + 1);
124
135
 
125
136
  // ------------
126
137
  // Pill Effects
@@ -153,7 +164,7 @@ export const FIRST_PILL_EFFECT = PillEffect.BAD_GAS;
153
164
  * Equal to `itemConfig.GetPillEffects().Size - 1`. (We subtract one to account for
154
165
  * `PillEffect.NULL`.)
155
166
  */
156
- export const LAST_PILL_EFFECT = NUM_PILL_EFFECTS as PillEffect;
167
+ export const LAST_PILL_EFFECT = asPillEffect(NUM_PILL_EFFECTS);
157
168
 
158
169
  /** Calculated from the `PillEffect` enum. */
159
170
  export const LAST_VANILLA_PILL_EFFECT = getLastEnumValue(PillEffect);
@@ -162,8 +173,9 @@ export const LAST_VANILLA_PILL_EFFECT = getLastEnumValue(PillEffect);
162
173
  * If there are no modded pill effects, this constant will represent a pill effect that does not
163
174
  * exist.
164
175
  */
165
- export const FIRST_MODDED_PILL_EFFECT = ((LAST_VANILLA_PILL_EFFECT as int) +
166
- 1) as PillEffect;
176
+ export const FIRST_MODDED_PILL_EFFECT = asPillEffect(
177
+ asNumber(LAST_VANILLA_PILL_EFFECT) + 1,
178
+ );
167
179
 
168
180
  // -----------
169
181
  // Pill Colors
@@ -207,9 +219,12 @@ export const LAST_VANILLA_CHARACTER = getLastEnumValue(PlayerType);
207
219
 
208
220
  /**
209
221
  * If there are no modded characters, this constant will represent a character that does not exist.
222
+ * (There is no way to determine the amount of modded characters at run-time, since there is no
223
+ * exposed player config.)
210
224
  */
211
- export const FIRST_MODDED_CHARACTER = ((LAST_VANILLA_CHARACTER as int) +
212
- 1) as PlayerType;
225
+ export const FIRST_MODDED_CHARACTER = asPlayerType(
226
+ asNumber(LAST_VANILLA_CHARACTER) + 1,
227
+ );
213
228
 
214
229
  // ----------
215
230
  // Room Types
@@ -1,3 +1,4 @@
1
+ /** This is used by the `POST_AMBUSH_STARTED` and `POST_AMBUSH_FINISHED` custom callbacks. */
1
2
  export enum AmbushType {
2
3
  CHALLENGE_ROOM,
3
4
  BOSS_RUSH,
@@ -1,3 +1,4 @@
1
+ /** This is used by the `getRoomShapeCorners` helper function. */
1
2
  export enum CornerType {
2
3
  TOP_LEFT,
3
4
  TOP_RIGHT,
@@ -1,3 +1,4 @@
1
+ /** This is used in the various pocket item helper functions. */
1
2
  export enum PocketItemType {
2
3
  EMPTY,
3
4
  CARD,
@@ -1,3 +1,4 @@
1
+ /** This is used in the various rock alt type helper functions. */
1
2
  export enum RockAltType {
2
3
  URN,
3
4
  MUSHROOM,
@@ -0,0 +1,10 @@
1
+ /**
2
+ * These are the types of keys that you can put on the local variables that you feed to the save
3
+ * data manager.
4
+ */
5
+ export enum SaveDataKey {
6
+ PERSISTENT = "persistent",
7
+ RUN = "run",
8
+ LEVEL = "level",
9
+ ROOM = "room",
10
+ }
@@ -1,3 +1,4 @@
1
+ /** This is used with the `deepCopy` and `merge` functions. */
1
2
  export enum SerializationType {
2
3
  NONE,
3
4
  SERIALIZE,
@@ -1,3 +1,4 @@
1
+ /** This is used in the `POST_SLOT_DESTROYED` custom callback. */
1
2
  export enum SlotDestructionType {
2
3
  NORMAL,
3
4
  COLLECTIBLE_PAYOUT,
@@ -33,15 +33,15 @@ export enum StatType {
33
33
  /** Corresponds to `CacheFlag.FLYING` (1 << 7) and `EntityPlayer.CanFly`. */
34
34
  FLYING,
35
35
 
36
- // `CacheFlag.WEAPON` (1 << 8) does not have a corresponding `EntityPlayer` field.
37
- // `CacheFlag.FAMILIARS` (1 << 9) does not have a corresponding `EntityPlayer` field.
36
+ // - `CacheFlag.WEAPON` (1 << 8) does not have a corresponding `EntityPlayer` field.
37
+ // - `CacheFlag.FAMILIARS` (1 << 9) does not have a corresponding `EntityPlayer` field.
38
38
 
39
39
  /** Corresponds to `CacheFlag.LUCK` (1 << 10) and `EntityPlayer.Luck`. */
40
40
  LUCK,
41
41
 
42
- /** Corresponds to `CacheFlag.SIZE` (1 << 11) and `EntityPlayer.SizeMulti`. */
43
- SIZE,
44
-
45
- // `CacheFlag.COLOR` (1 << 12) does not have a corresponding `EntityPlayer` field.
46
- // `CacheFlag.PICKUP_VISION` (1 << 13) does not have a corresponding `EntityPlayer` field.
42
+ // - `CacheFlag.SIZE` (1 << 12) does not have a corresponding `EntityPlayer` field. (After picking
43
+ // up Magic Mushroom, the values of `EntityPlayer.Size` and `EntityPlayer.SizeMulti` do not
44
+ // change.)
45
+ // - `CacheFlag.COLOR` (1 << 12) does not have a corresponding `EntityPlayer` field.
46
+ // - `CacheFlag.PICKUP_VISION` (1 << 13) does not have a corresponding `EntityPlayer` field.
47
47
  }
@@ -4,6 +4,7 @@ export * from "./HealthType";
4
4
  export * from "./ModCallbackCustom";
5
5
  export * from "./PocketItemType";
6
6
  export * from "./RockAltType";
7
+ export * from "./SaveDataKey";
7
8
  export * from "./SerializationType";
8
9
  export * from "./SlotDestructionType";
9
10
  export * from "./StatType";
@@ -4,6 +4,7 @@ export * as HealthType from "./HealthType";
4
4
  export * as ModCallbackCustom from "./ModCallbackCustom";
5
5
  export * as PocketItemType from "./PocketItemType";
6
6
  export * as RockAltType from "./RockAltType";
7
+ export * as SaveDataKey from "./SaveDataKey";
7
8
  export * as SerializationType from "./SerializationType";
8
9
  export * as SlotDestructionType from "./SlotDestructionType";
9
10
  export * as StatType from "./StatType";
@@ -23,6 +23,7 @@ import {
23
23
  spawnGridEntityWithVariant,
24
24
  } from "../functions/gridEntities";
25
25
  import { getRoomListIndex } from "../functions/roomData";
26
+ import { asNumber } from "../functions/types";
26
27
  import { isVector } from "../functions/vector";
27
28
  import { GridEntityCustomData } from "../interfaces/GridEntityCustomData";
28
29
  import { runNextGameFrame } from "./runInNFrames";
@@ -251,7 +252,7 @@ export function spawnCustomGridEntity(
251
252
  existingGridEntity !== undefined &&
252
253
  existingGridEntity.GetType() === GridEntityType.DECORATION &&
253
254
  existingGridEntity.GetVariant() ===
254
- (DecorationVariant.CUSTOM_GRID_ENTITY as int);
255
+ asNumber(DecorationVariant.CUSTOM_GRID_ENTITY);
255
256
  const decoration = isExistingDecoration
256
257
  ? existingGridEntity
257
258
  : spawnGridEntityWithVariant(
@@ -91,7 +91,7 @@ const BACKDROP_ROOM_TYPE_SET: ReadonlySet<RoomType> = new Set([
91
91
  RoomType.MINI_BOSS,
92
92
  ]);
93
93
 
94
- export function setBackdrop(customStage: CustomStage): void {
94
+ export function setCustomStageBackdrop(customStage: CustomStage): void {
95
95
  const room = game.GetRoom();
96
96
  const roomType = room.GetType();
97
97
  const decorationSeed = room.GetDecorationSeed();
@@ -131,11 +131,12 @@ function spawnWallEntity(
131
131
 
132
132
  // We spawn an effect instead of simply rendering a static sprite in order to emulate how vanilla
133
133
  // does this. (`EntityFlag.RENDER_WALL` is intended for this purpose.)
134
+ const seed = 1 as Seed;
134
135
  const wallEffect = spawnEffectWithSeed(
135
136
  BACKDROP_EFFECT_VARIANT,
136
137
  BACKDROP_EFFECT_SUBTYPE,
137
138
  VectorZero,
138
- 1 as Seed,
139
+ seed,
139
140
  );
140
141
  wallEffect.AddEntityFlags(EntityFlag.RENDER_WALL);
141
142
 
@@ -195,11 +196,12 @@ function spawnFloorEntity(customStage: CustomStage, rng: RNG) {
195
196
 
196
197
  // We spawn an effect instead of simply rendering a static sprite in order to emulate how vanilla
197
198
  // does this. (`EntityFlag.RENDER_FLOOR` is intended for this purpose.)
199
+ const seed = 1 as Seed;
198
200
  const floorEffect = spawnEffectWithSeed(
199
201
  BACKDROP_EFFECT_VARIANT,
200
202
  0,
201
203
  VectorZero,
202
- 1 as Seed,
204
+ seed,
203
205
  );
204
206
  floorEffect.AddEntityFlags(EntityFlag.RENDER_FLOOR);
205
207
 
@@ -15,6 +15,7 @@ import {
15
15
  getTrinkets,
16
16
  } from "../../functions/pickupsSpecific";
17
17
  import { calculateStageType } from "../../functions/stage";
18
+ import { asNumber } from "../../functions/types";
18
19
  import { vectorEquals } from "../../functions/vector";
19
20
  import { CustomStage } from "../../interfaces/private/CustomStage";
20
21
  import { TrapdoorDestination } from "../../types/TrapdoorDestination";
@@ -40,7 +41,7 @@ export function setCustomDecorationGraphics(
40
41
 
41
42
  // Ignore custom grid entities. (They are represented as decorations with a non-zero variant.)
42
43
  const variant = gridEntity.GetVariant();
43
- if (variant !== (DecorationVariant.VANILLA_DECORATION as int)) {
44
+ if (variant !== asNumber(DecorationVariant.VANILLA_DECORATION)) {
44
45
  return;
45
46
  }
46
47
 
@@ -24,6 +24,7 @@ import {
24
24
  getRoomsInsideGrid,
25
25
  } from "../../functions/rooms";
26
26
  import { setStage } from "../../functions/stage";
27
+ import { asNumber } from "../../functions/types";
27
28
  import { CustomStage } from "../../interfaces/private/CustomStage";
28
29
  import { getRandomCustomStageRoom } from "./customStageUtils";
29
30
  import v, {
@@ -77,7 +78,7 @@ export function setCustomStage(
77
78
  level.SetStage(LevelStage.BASEMENT_1, StageType.ORIGINAL);
78
79
  }
79
80
 
80
- let baseStage: int =
81
+ let baseStage =
81
82
  customStage.baseStage === undefined
82
83
  ? DEFAULT_BASE_STAGE
83
84
  : customStage.baseStage;
@@ -88,11 +89,11 @@ export function setCustomStage(
88
89
  const baseStageType =
89
90
  customStage.baseStageType === undefined
90
91
  ? DEFAULT_BASE_STAGE_TYPE
91
- : (customStage.baseStageType as StageType);
92
+ : customStage.baseStageType;
92
93
 
93
- const reseed = (stage as int) >= baseStage;
94
+ const reseed = asNumber(stage) >= baseStage;
94
95
 
95
- setStage(baseStage as LevelStage, baseStageType, reseed);
96
+ setStage(baseStage as LevelStage, baseStageType as StageType, reseed);
96
97
 
97
98
  setStageRoomsData(customStage, rng, verbose);
98
99
 
@@ -16,7 +16,7 @@ import {
16
16
  } from "../../interfaces/CustomStageLua";
17
17
  import { CustomStage, RoomTypeMap } from "../../interfaces/private/CustomStage";
18
18
  import { saveDataManager } from "../saveDataManager/exports";
19
- import { setBackdrop } from "./backdrop";
19
+ import { setCustomStageBackdrop } from "./backdrop";
20
20
  import {
21
21
  convertVanillaTrapdoors,
22
22
  removeUrnRewards,
@@ -196,7 +196,7 @@ function postNewRoomReordered() {
196
196
  return;
197
197
  }
198
198
 
199
- setBackdrop(customStage);
199
+ setCustomStageBackdrop(customStage);
200
200
  setShadows(customStage);
201
201
  playVersusScreenAnimation(customStage);
202
202
  }
@@ -56,11 +56,12 @@ export function setShadows(customStage: CustomStage): void {
56
56
  // We spawn an effect instead of simply rendering a static sprite so that the effect will properly
57
57
  // slide in during a room transition animation. (It looks stupid if the shadow stays statically
58
58
  // rendering throughout this animation.)
59
+ const seed = 1 as Seed;
59
60
  const shadowEffect = spawnEffectWithSeed(
60
61
  SHADOW_EFFECT_VARIANT,
61
62
  SHADOW_EFFECT_SUBTYPE,
62
63
  centerPos,
63
- 1 as Seed,
64
+ seed,
64
65
  );
65
66
 
66
67
  const sprite = shadowEffect.GetSprite();
@@ -40,7 +40,6 @@ import {
40
40
  convertXMLGridEntityType,
41
41
  getAllGridIndexes,
42
42
  getGridEntities,
43
- getGridEntityIDFromConstituents,
44
43
  removeAllGridExcept,
45
44
  removeGridEntity,
46
45
  setGridEntityInvisible,
@@ -53,6 +52,7 @@ import { getRoomListIndex } from "../functions/roomData";
53
52
  import { gridCoordinatesToWorldPosition } from "../functions/roomGrid";
54
53
  import { setRoomCleared, setRoomUncleared } from "../functions/rooms";
55
54
  import { spawnCollectible } from "../functions/spawnCollectible";
55
+ import { asCollectibleType, asNumber } from "../functions/types";
56
56
  import { JSONRoom } from "../interfaces/JSONRoomsFile";
57
57
  import { runNextGameFrame } from "./runInNFrames";
58
58
  import { saveDataManager } from "./saveDataManager/exports";
@@ -462,8 +462,8 @@ function spawnAllEntities(
462
462
  }
463
463
 
464
464
  const entityTypeString = firstXMLEntity.$.type;
465
- const entityType = tonumber(entityTypeString);
466
- if (entityType === undefined) {
465
+ const entityTypeNumber = tonumber(entityTypeString);
466
+ if (entityTypeNumber === undefined) {
467
467
  error(
468
468
  `Failed to convert the entity type to a number: ${entityTypeString}`,
469
469
  );
@@ -482,31 +482,26 @@ function spawnAllEntities(
482
482
  }
483
483
 
484
484
  // Note that XML entity type 1000 is a rock, not an effect.
485
- if (entityType >= 1000) {
485
+ if (entityTypeNumber >= 1000) {
486
+ const gridEntityXMLType = entityTypeNumber as GridEntityXMLType;
486
487
  if (verbose) {
487
- const gridEntityID = getGridEntityIDFromConstituents(
488
- entityType as GridEntityType,
489
- variant,
488
+ log(
489
+ `Spawning grid entity ${gridEntityXMLType}.${variant} at: (${x}, ${y})`,
490
490
  );
491
- log(`Spawning grid entity ${gridEntityID} at: (${x}, ${y})`);
492
491
  }
493
- spawnGridEntityForJSONRoom(
494
- entityType as GridEntityXMLType,
495
- variant,
496
- x,
497
- y,
498
- );
492
+ spawnGridEntityForJSONRoom(gridEntityXMLType, variant, x, y);
499
493
  } else {
494
+ const entityType = entityTypeNumber as EntityType;
500
495
  if (verbose) {
501
496
  const entityID = getEntityIDFromConstituents(
502
- entityType as EntityType,
497
+ entityType,
503
498
  variant,
504
499
  subType,
505
500
  );
506
501
  log(`Spawning normal entity ${entityID} at: (${x}, ${y})`);
507
502
  }
508
503
  const entity = spawnNormalEntityForJSONRoom(
509
- entityType as EntityType,
504
+ entityType,
510
505
  variant,
511
506
  subType,
512
507
  x,
@@ -589,11 +584,11 @@ function spawnNormalEntityForJSONRoom(
589
584
  let entity: Entity;
590
585
  if (
591
586
  entityType === EntityType.PICKUP &&
592
- (variant as PickupVariant) === PickupVariant.COLLECTIBLE
587
+ variant === asNumber(PickupVariant.COLLECTIBLE)
593
588
  ) {
594
589
  const options = roomType === RoomType.ANGEL;
595
590
  entity = spawnCollectible(
596
- subType as CollectibleType,
591
+ asCollectibleType(subType),
597
592
  position,
598
593
  seed,
599
594
  options,
@@ -605,7 +600,7 @@ function spawnNormalEntityForJSONRoom(
605
600
  // For some reason, Pitfalls do not spawn with the correct collision classes.
606
601
  if (
607
602
  entityType === EntityType.PITFALL &&
608
- (variant as PitfallVariant) === PitfallVariant.PITFALL
603
+ variant === asNumber(PitfallVariant.PITFALL)
609
604
  ) {
610
605
  entity.EntityCollisionClass = EntityCollisionClass.ENEMIES;
611
606
  entity.GridCollisionClass = EntityGridCollisionClass.WALLS;
@@ -89,6 +89,7 @@ import { gridCoordinatesToWorldPosition } from "../../functions/roomGrid";
89
89
  import { changeRoom } from "../../functions/rooms";
90
90
  import { onSetSeed, restart, setUnseeded } from "../../functions/run";
91
91
  import { getGoldenTrinketType } from "../../functions/trinkets";
92
+ import { asCard } from "../../functions/types";
92
93
  import { irange, printConsole, printEnabled } from "../../functions/utils";
93
94
  import { CARD_MAP } from "../../maps/cardMap";
94
95
  import { CHARACTER_MAP } from "../../maps/characterMap";
@@ -343,12 +344,12 @@ export function cards(): void {
343
344
  let cardType = 1;
344
345
  for (let y = 0; y <= 6; y++) {
345
346
  for (let x = 0; x <= 12; x++) {
346
- if ((cardType as Card) === LAST_CARD) {
347
+ if (asCard(cardType) === LAST_CARD) {
347
348
  return;
348
349
  }
349
350
 
350
351
  const position = gridCoordinatesToWorldPosition(x, y);
351
- spawnCard(cardType as Card, position);
352
+ spawnCard(asCard(cardType), position);
352
353
  cardType++;
353
354
  }
354
355
  }
@@ -34,7 +34,7 @@ function checkResetInput() {
34
34
  return;
35
35
  }
36
36
 
37
- // Disable the fast-reset feature if the custom console is open.
37
+ // Disable the fast-reset feature if any custom consoles are open.
38
38
  if (AwaitingTextInput) {
39
39
  return;
40
40
  }
@@ -9,7 +9,8 @@ export * as DebugDisplay from "./debugDisplay/exports";
9
9
  export * as DeployJSONRoom from "./deployJSONRoom";
10
10
  export * as DisableAllSound from "./disableAllSound";
11
11
  export * as DisableInputs from "./disableInputs";
12
- export * as ExtraConsoleCommands from "./extraConsoleCommands/exports";
12
+ export * as ExtraConsoleCommandsInit from "./extraConsoleCommands/exports";
13
+ export * as ExtraConsoleCommandsList from "./extraConsoleCommands/listCommands";
13
14
  export * as FadeInRemover from "./fadeInRemover";
14
15
  export * as FastReset from "./fastReset";
15
16
  export * as ForgottenSwitch from "./forgottenSwitch";
@@ -1,4 +1,4 @@
1
- import { SaveDataKey } from "../../enums/private/SaveDataKey";
1
+ import { SaveDataKey } from "../../enums/SaveDataKey";
2
2
  import { SerializationType } from "../../enums/SerializationType";
3
3
  import { errorIfFeaturesNotInitialized } from "../../featuresInitialized";
4
4
  import { deepCopy } from "../../functions/deepCopy";
@@ -227,7 +227,7 @@ export function saveDataManagerSetGlobal(): void {
227
227
  */
228
228
  export function saveDataManagerReset(
229
229
  key: string,
230
- childObjectKey: string,
230
+ childObjectKey: SaveDataKey,
231
231
  ): void {
232
232
  errorIfFeaturesNotInitialized(SAVE_DATA_MANAGER_FEATURE_NAME);
233
233
 
@@ -237,12 +237,12 @@ export function saveDataManagerReset(
237
237
  );
238
238
  }
239
239
 
240
- const saveData = saveDataMap.get(key) as Record<string, unknown> | undefined;
240
+ const saveData = saveDataMap.get(key);
241
241
  if (saveData === undefined) {
242
242
  error(
243
243
  `The ${SAVE_DATA_MANAGER_FEATURE_NAME} is not managing save data for a key of: ${key}`,
244
244
  );
245
245
  }
246
246
 
247
- restoreDefaultSaveData(key, saveData, childObjectKey as SaveDataKey);
247
+ restoreDefaultSaveData(key, saveData, childObjectKey);
248
248
  }
@@ -2,7 +2,7 @@ import { ModCallback } from "isaac-typescript-definitions";
2
2
  import { ModUpgraded } from "../../classes/ModUpgraded";
3
3
  import { game } from "../../core/cachedClasses";
4
4
  import { ModCallbackCustom } from "../../enums/ModCallbackCustom";
5
- import { SaveDataKey } from "../../enums/private/SaveDataKey";
5
+ import { SaveDataKey } from "../../enums/SaveDataKey";
6
6
  import { SerializationType } from "../../enums/SerializationType";
7
7
  import { deepCopy } from "../../functions/deepCopy";
8
8
  import { logError } from "../../functions/log";
@@ -61,7 +61,7 @@ function getAllSaveDataToWriteToDisk(
61
61
  // that is unnecessary. Make a copy of the data and recursively convert all TypeScriptToLua
62
62
  // Maps into Lua tables.
63
63
  const saveDataCopy = deepCopy(
64
- saveDataWithoutRoom as LuaMap,
64
+ saveDataWithoutRoom,
65
65
  SerializationType.SERIALIZE,
66
66
  subscriberName,
67
67
  );
@@ -37,11 +37,7 @@ export function deserializeBitSet128(
37
37
  );
38
38
  }
39
39
 
40
- const [l, h] = getNumbersFromTable(
41
- bitSet128 as LuaMap<string, unknown>,
42
- OBJECT_NAME,
43
- ...KEYS,
44
- );
40
+ const [l, h] = getNumbersFromTable(bitSet128, OBJECT_NAME, ...KEYS);
45
41
 
46
42
  if (l === undefined) {
47
43
  error(
@@ -14,6 +14,7 @@ import { getNPCs, spawnNPC } from "./entitiesSpecific";
14
14
  import { getAliveNPCs } from "./npcs";
15
15
  import { isRNG } from "./rng";
16
16
  import { copySet } from "./set";
17
+ import { asNumber } from "./types";
17
18
  import { repeat } from "./utils";
18
19
 
19
20
  const BOSSES_THAT_REQUIRE_MULTIPLE_SPAWNS: ReadonlySet<EntityType> = new Set([
@@ -194,7 +195,7 @@ function getNumBossSegments(
194
195
 
195
196
  // 69
196
197
  case EntityType.LOKI: {
197
- return (variant as LokiVariant) === LokiVariant.LOKII ? 2 : 1;
198
+ return variant === asNumber(LokiVariant.LOKII) ? 2 : 1;
198
199
  }
199
200
 
200
201
  // 237