isaacscript-common 11.2.3 → 12.0.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 (71) hide show
  1. package/dist/index.d.ts +18 -3
  2. package/dist/isaacscript-common.lua +161 -96
  3. package/dist/package.lua +1 -1
  4. package/dist/src/features/customStage/backdrop.lua +2 -2
  5. package/dist/src/features/customStage/{customStageConstants.d.ts → constants.d.ts} +1 -1
  6. package/dist/src/features/customStage/constants.d.ts.map +1 -0
  7. package/dist/src/features/customStage/{customStageConstants.lua → constants.lua} +0 -0
  8. package/dist/src/features/customStage/init.lua +2 -2
  9. package/dist/src/features/customStage/shadows.lua +2 -2
  10. package/dist/src/features/customStage/streakText.d.ts.map +1 -1
  11. package/dist/src/features/customStage/streakText.lua +3 -3
  12. package/dist/src/features/customStage/v.d.ts +1 -1
  13. package/dist/src/features/customStage/v.d.ts.map +1 -1
  14. package/dist/src/features/customStage/v.lua +2 -2
  15. package/dist/src/features/customStage/versusScreen.lua +3 -3
  16. package/dist/src/features/customTrapdoor/{customTrapdoorConstants.d.ts → constants.d.ts} +1 -1
  17. package/dist/src/features/customTrapdoor/constants.d.ts.map +1 -0
  18. package/dist/src/features/customTrapdoor/{customTrapdoorConstants.lua → constants.lua} +0 -0
  19. package/dist/src/features/customTrapdoor/exports.lua +2 -2
  20. package/dist/src/features/customTrapdoor/init.lua +4 -4
  21. package/dist/src/features/customTrapdoor/openClose.lua +4 -4
  22. package/dist/src/features/customTrapdoor/spawn.lua +2 -2
  23. package/dist/src/features/customTrapdoor/touched.lua +6 -6
  24. package/dist/src/features/saveDataManager/constants.d.ts +10 -0
  25. package/dist/src/features/saveDataManager/constants.d.ts.map +1 -0
  26. package/dist/src/features/saveDataManager/constants.lua +10 -0
  27. package/dist/src/features/saveDataManager/exports.d.ts +8 -3
  28. package/dist/src/features/saveDataManager/exports.d.ts.map +1 -1
  29. package/dist/src/features/saveDataManager/exports.lua +10 -5
  30. package/dist/src/features/saveDataManager/load.d.ts.map +1 -1
  31. package/dist/src/features/saveDataManager/load.lua +9 -9
  32. package/dist/src/features/saveDataManager/main.d.ts.map +1 -1
  33. package/dist/src/features/saveDataManager/main.lua +67 -4
  34. package/dist/src/features/saveDataManager/maps.d.ts +5 -0
  35. package/dist/src/features/saveDataManager/maps.d.ts.map +1 -1
  36. package/dist/src/features/saveDataManager/maps.lua +3 -0
  37. package/dist/src/features/saveDataManager/merge.lua +2 -2
  38. package/dist/src/features/saveDataManager/save.lua +3 -3
  39. package/dist/src/functions/charge.d.ts +9 -0
  40. package/dist/src/functions/charge.d.ts.map +1 -1
  41. package/dist/src/functions/charge.lua +23 -34
  42. package/dist/src/functions/deepCopy.lua +2 -2
  43. package/package.json +1 -1
  44. package/src/features/customStage/backdrop.ts +1 -1
  45. package/src/features/customStage/{customStageConstants.ts → constants.ts} +0 -0
  46. package/src/features/customStage/init.ts +1 -1
  47. package/src/features/customStage/shadows.ts +1 -1
  48. package/src/features/customStage/streakText.ts +1 -4
  49. package/src/features/customStage/v.ts +1 -1
  50. package/src/features/customStage/versusScreen.ts +1 -1
  51. package/src/features/customTrapdoor/{customTrapdoorConstants.ts → constants.ts} +0 -0
  52. package/src/features/customTrapdoor/exports.ts +1 -1
  53. package/src/features/customTrapdoor/init.ts +1 -1
  54. package/src/features/customTrapdoor/openClose.ts +1 -1
  55. package/src/features/customTrapdoor/spawn.ts +1 -1
  56. package/src/features/customTrapdoor/touched.ts +1 -1
  57. package/src/features/saveDataManager/constants.ts +15 -0
  58. package/src/features/saveDataManager/exports.ts +9 -4
  59. package/src/features/saveDataManager/load.ts +13 -9
  60. package/src/features/saveDataManager/main.ts +78 -4
  61. package/src/features/saveDataManager/maps.ts +6 -0
  62. package/src/features/saveDataManager/merge.ts +1 -1
  63. package/src/features/saveDataManager/save.ts +1 -1
  64. package/src/functions/charge.ts +39 -54
  65. package/src/functions/deepCopy.ts +1 -1
  66. package/dist/src/features/customStage/customStageConstants.d.ts.map +0 -1
  67. package/dist/src/features/customTrapdoor/customTrapdoorConstants.d.ts.map +0 -1
  68. package/dist/src/features/saveDataManager/saveDataManagerConstants.d.ts +0 -4
  69. package/dist/src/features/saveDataManager/saveDataManagerConstants.d.ts.map +0 -1
  70. package/dist/src/features/saveDataManager/saveDataManagerConstants.lua +0 -5
  71. package/src/features/saveDataManager/saveDataManagerConstants.ts +0 -4
@@ -2,8 +2,8 @@ local ____lualib = require("lualib_bundle")
2
2
  local Map = ____lualib.Map
3
3
  local __TS__New = ____lualib.__TS__New
4
4
  local ____exports = {}
5
- local ____customStageConstants = require("src.features.customStage.customStageConstants")
6
- local UIStreakAnimation = ____customStageConstants.UIStreakAnimation
5
+ local ____constants = require("src.features.customStage.constants")
6
+ local UIStreakAnimation = ____constants.UIStreakAnimation
7
7
  local v = {
8
8
  run = {
9
9
  currentCustomStage = nil,
@@ -42,9 +42,9 @@ local pause = ____pause.pause
42
42
  local unpause = ____pause.unpause
43
43
  local ____runInNFrames = require("src.features.runInNFrames")
44
44
  local runNextGameFrame = ____runInNFrames.runNextGameFrame
45
- local ____customStageConstants = require("src.features.customStage.customStageConstants")
46
- local CUSTOM_STAGE_FEATURE_NAME = ____customStageConstants.CUSTOM_STAGE_FEATURE_NAME
47
- local ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH = ____customStageConstants.ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH
45
+ local ____constants = require("src.features.customStage.constants")
46
+ local CUSTOM_STAGE_FEATURE_NAME = ____constants.CUSTOM_STAGE_FEATURE_NAME
47
+ local ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH = ____constants.ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH
48
48
  local ____exports = require("src.features.customStage.exports")
49
49
  local CUSTOM_FLOOR_STAGE = ____exports.CUSTOM_FLOOR_STAGE
50
50
  local CUSTOM_FLOOR_STAGE_TYPE = ____exports.CUSTOM_FLOOR_STAGE_TYPE
@@ -16,4 +16,4 @@ export declare const ANIMATIONS_THAT_PREVENT_STAGE_TRAVEL: ReadonlySet<string>;
16
16
  export declare const PIXELATION_TO_BLACK_FRAMES = 52;
17
17
  export declare const OTHER_PLAYER_TRAPDOOR_JUMP_DELAY_GAME_FRAMES = 6;
18
18
  export declare const OTHER_PLAYER_TRAPDOOR_JUMP_DURATION_GAME_FRAMES = 5;
19
- //# sourceMappingURL=customTrapdoorConstants.d.ts.map
19
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/features/customTrapdoor/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,eAAO,MAAM,4BAA4B,mBAAmB,CAAC;AAE7D,eAAO,MAAM,oBAAoB;IAC/B;;;OAGG;;CAEK,CAAC;AAEX,2FAA2F;AAC3F,eAAO,MAAM,sBAAsB,KAAK,CAAC;AAEzC,eAAO,MAAM,iCAAiC,QAA+B,CAAC;AAC9E,eAAO,MAAM,6BAA6B,KAAK,CAAC;AAEhD,eAAO,MAAM,uBAAuB,OAAO,CAAC;AAE5C,eAAO,MAAM,oCAAoC,EAAE,WAAW,CAAC,MAAM,CAClC,CAAC;AAEpC,eAAO,MAAM,0BAA0B,KAAK,CAAC;AAE7C,eAAO,MAAM,4CAA4C,IAAI,CAAC;AAC9D,eAAO,MAAM,+CAA+C,IAAI,CAAC"}
@@ -4,8 +4,8 @@ local errorIfFeaturesNotInitialized = ____featuresInitialized.errorIfFeaturesNot
4
4
  local ____nextStage = require("src.functions.nextStage")
5
5
  local getNextStage = ____nextStage.getNextStage
6
6
  local getNextStageType = ____nextStage.getNextStageType
7
- local ____customTrapdoorConstants = require("src.features.customTrapdoor.customTrapdoorConstants")
8
- local CUSTOM_TRAPDOOR_FEATURE_NAME = ____customTrapdoorConstants.CUSTOM_TRAPDOOR_FEATURE_NAME
7
+ local ____constants = require("src.features.customTrapdoor.constants")
8
+ local CUSTOM_TRAPDOOR_FEATURE_NAME = ____constants.CUSTOM_TRAPDOOR_FEATURE_NAME
9
9
  local ____spawn = require("src.features.customTrapdoor.spawn")
10
10
  local spawnCustomTrapdoorToDestination = ____spawn.spawnCustomTrapdoorToDestination
11
11
  --- Helper function to spawn a trapdoor grid entity that will take a player to a custom stage. If you
@@ -41,10 +41,10 @@ local ____exports = require("src.features.saveDataManager.exports")
41
41
  local saveDataManager = ____exports.saveDataManager
42
42
  local ____blackSprite = require("src.features.customTrapdoor.blackSprite")
43
43
  local drawBlackSprite = ____blackSprite.drawBlackSprite
44
- local ____customTrapdoorConstants = require("src.features.customTrapdoor.customTrapdoorConstants")
45
- local CUSTOM_TRAPDOOR_FEATURE_NAME = ____customTrapdoorConstants.CUSTOM_TRAPDOOR_FEATURE_NAME
46
- local GridEntityTypeCustom = ____customTrapdoorConstants.GridEntityTypeCustom
47
- local PIXELATION_TO_BLACK_FRAMES = ____customTrapdoorConstants.PIXELATION_TO_BLACK_FRAMES
44
+ local ____constants = require("src.features.customTrapdoor.constants")
45
+ local CUSTOM_TRAPDOOR_FEATURE_NAME = ____constants.CUSTOM_TRAPDOOR_FEATURE_NAME
46
+ local GridEntityTypeCustom = ____constants.GridEntityTypeCustom
47
+ local PIXELATION_TO_BLACK_FRAMES = ____constants.PIXELATION_TO_BLACK_FRAMES
48
48
  local ____openClose = require("src.features.customTrapdoor.openClose")
49
49
  local checkCustomTrapdoorOpenClose = ____openClose.checkCustomTrapdoorOpenClose
50
50
  local ____touched = require("src.features.customTrapdoor.touched")
@@ -10,10 +10,10 @@ local ____positionVelocity = require("src.functions.positionVelocity")
10
10
  local anyPlayerCloserThan = ____positionVelocity.anyPlayerCloserThan
11
11
  local ____roomClearFrame = require("src.features.roomClearFrame")
12
12
  local getRoomClearGameFrame = ____roomClearFrame.getRoomClearGameFrame
13
- local ____customTrapdoorConstants = require("src.features.customTrapdoor.customTrapdoorConstants")
14
- local TRAPDOOR_BOSS_REACTION_FRAMES = ____customTrapdoorConstants.TRAPDOOR_BOSS_REACTION_FRAMES
15
- local TRAPDOOR_OPEN_DISTANCE = ____customTrapdoorConstants.TRAPDOOR_OPEN_DISTANCE
16
- local TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS = ____customTrapdoorConstants.TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS
13
+ local ____constants = require("src.features.customTrapdoor.constants")
14
+ local TRAPDOOR_BOSS_REACTION_FRAMES = ____constants.TRAPDOOR_BOSS_REACTION_FRAMES
15
+ local TRAPDOOR_OPEN_DISTANCE = ____constants.TRAPDOOR_OPEN_DISTANCE
16
+ local TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS = ____constants.TRAPDOOR_OPEN_DISTANCE_AFTER_BOSS
17
17
  function shouldTrapdoorOpen(self, gridEntity, firstSpawn)
18
18
  local room = game:GetRoom()
19
19
  local roomClear = room:IsClear()
@@ -13,8 +13,8 @@ local ____vector = require("src.functions.vector")
13
13
  local isVector = ____vector.isVector
14
14
  local ____customGridEntity = require("src.features.customGridEntity")
15
15
  local spawnCustomGridEntity = ____customGridEntity.spawnCustomGridEntity
16
- local ____customTrapdoorConstants = require("src.features.customTrapdoor.customTrapdoorConstants")
17
- local GridEntityTypeCustom = ____customTrapdoorConstants.GridEntityTypeCustom
16
+ local ____constants = require("src.features.customTrapdoor.constants")
17
+ local GridEntityTypeCustom = ____constants.GridEntityTypeCustom
18
18
  local ____openClose = require("src.features.customTrapdoor.openClose")
19
19
  local shouldTrapdoorSpawnOpen = ____openClose.shouldTrapdoorSpawnOpen
20
20
  local ____v = require("src.features.customTrapdoor.v")
@@ -29,12 +29,12 @@ local isPlayerUsingPony = ____ponyDetection.isPlayerUsingPony
29
29
  local ____runInNFrames = require("src.features.runInNFrames")
30
30
  local runInNGameFrames = ____runInNFrames.runInNGameFrames
31
31
  local runNextRenderFrame = ____runInNFrames.runNextRenderFrame
32
- local ____customTrapdoorConstants = require("src.features.customTrapdoor.customTrapdoorConstants")
33
- local ANIMATIONS_THAT_PREVENT_STAGE_TRAVEL = ____customTrapdoorConstants.ANIMATIONS_THAT_PREVENT_STAGE_TRAVEL
34
- local CUSTOM_TRAPDOOR_FEATURE_NAME = ____customTrapdoorConstants.CUSTOM_TRAPDOOR_FEATURE_NAME
35
- local OTHER_PLAYER_TRAPDOOR_JUMP_DELAY_GAME_FRAMES = ____customTrapdoorConstants.OTHER_PLAYER_TRAPDOOR_JUMP_DELAY_GAME_FRAMES
36
- local OTHER_PLAYER_TRAPDOOR_JUMP_DURATION_GAME_FRAMES = ____customTrapdoorConstants.OTHER_PLAYER_TRAPDOOR_JUMP_DURATION_GAME_FRAMES
37
- local TRAPDOOR_TOUCH_DISTANCE = ____customTrapdoorConstants.TRAPDOOR_TOUCH_DISTANCE
32
+ local ____constants = require("src.features.customTrapdoor.constants")
33
+ local ANIMATIONS_THAT_PREVENT_STAGE_TRAVEL = ____constants.ANIMATIONS_THAT_PREVENT_STAGE_TRAVEL
34
+ local CUSTOM_TRAPDOOR_FEATURE_NAME = ____constants.CUSTOM_TRAPDOOR_FEATURE_NAME
35
+ local OTHER_PLAYER_TRAPDOOR_JUMP_DELAY_GAME_FRAMES = ____constants.OTHER_PLAYER_TRAPDOOR_JUMP_DELAY_GAME_FRAMES
36
+ local OTHER_PLAYER_TRAPDOOR_JUMP_DURATION_GAME_FRAMES = ____constants.OTHER_PLAYER_TRAPDOOR_JUMP_DURATION_GAME_FRAMES
37
+ local TRAPDOOR_TOUCH_DISTANCE = ____constants.TRAPDOOR_TOUCH_DISTANCE
38
38
  local ____v = require("src.features.customTrapdoor.v")
39
39
  local v = ____v.default
40
40
  function canPlayerInteractWithTrapdoor(self, player)
@@ -0,0 +1,10 @@
1
+ import { SaveDataKey } from "../../enums/SaveDataKey";
2
+ /** Set this to true to enable more verbosity in the save data manger. */
3
+ export declare const SAVE_DATA_MANAGER_DEBUG: boolean;
4
+ export declare const SAVE_DATA_MANAGER_FEATURE_NAME = "save data manager";
5
+ /**
6
+ * When the Glowing Hour Glass is used, certain save data keys will automatically be restored to a
7
+ * backup.
8
+ */
9
+ export declare const SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS: SaveDataKey[];
10
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAEtD,yEAAyE;AACzE,eAAO,MAAM,uBAAuB,SAAmB,CAAC;AAExD,eAAO,MAAM,8BAA8B,sBAAsB,CAAC;AAElE;;;GAGG;AACH,eAAO,MAAM,gDAAgD,eAG5D,CAAC"}
@@ -0,0 +1,10 @@
1
+ local ____exports = {}
2
+ local ____SaveDataKey = require("src.enums.SaveDataKey")
3
+ local SaveDataKey = ____SaveDataKey.SaveDataKey
4
+ --- Set this to true to enable more verbosity in the save data manger.
5
+ ____exports.SAVE_DATA_MANAGER_DEBUG = false
6
+ ____exports.SAVE_DATA_MANAGER_FEATURE_NAME = "save data manager"
7
+ --- When the Glowing Hour Glass is used, certain save data keys will automatically be restored to a
8
+ -- backup.
9
+ ____exports.SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS = {SaveDataKey.RUN, SaveDataKey.LEVEL}
10
+ return ____exports
@@ -72,9 +72,14 @@ import { SaveData } from "../../interfaces/SaveData";
72
72
  * data manager cannot do this on its own because it cannot know when your mod features are finished
73
73
  * initializing.)
74
74
  *
75
- * Finally, some features may have variables that need to be automatically reset per run/level, but
76
- * not saved to disk on game exit. (For example, if they contain functions or other non-serializable
77
- * data.) For these cases, set the second argument to `() => false`.
75
+ * Some features may have variables that need to be automatically reset per run/level, but not saved
76
+ * to disk on game exit. (For example, if they contain functions or other non-serializable data.)
77
+ * For these cases, set the second argument to `() => false`.
78
+ *
79
+ * Note that when the player uses Glowing Hour Glass, the save data manager will automatically
80
+ * restore any variables on a "run" or "level" object with a backup that was created when the room
81
+ * was entered. Thus, you should not have to explicitly program support for Glowing Hour Glass into
82
+ * your mod features that use the save data manager.
78
83
  *
79
84
  * @param key The name of the file or feature that is submitting data to be managed by the save data
80
85
  * manager. The save data manager will throw an error if the key is already registered.
@@ -1 +1 @@
1
- {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAKtD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAarD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyFG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,EACpD,GAAG,EAAE,MAAM,EAAE,qEAAqE;AAClF,CAAC,EAAE,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,EACnC,eAAe,CAAC,EAAE,MAAM,OAAO,GAC9B,IAAI,CAAC;AACR,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EAAE,kEAAkE;AAC/E,CAAC,EAAE,QAAQ,EACX,eAAe,EAAE,KAAK,GACrB,IAAI,CAAC;AA+CR;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAG1C;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAG1C;AAQD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAK/C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,WAAW,GAC1B,IAAI,CAiBN"}
1
+ {"version":3,"file":"exports.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/exports.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAKtD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAarD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8FG;AACH,wBAAgB,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,EACpD,GAAG,EAAE,MAAM,EAAE,qEAAqE;AAClF,CAAC,EAAE,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE,KAAK,CAAC,EACnC,eAAe,CAAC,EAAE,MAAM,OAAO,GAC9B,IAAI,CAAC;AACR,wBAAgB,eAAe,CAC7B,GAAG,EAAE,MAAM,EAAE,kEAAkE;AAC/E,CAAC,EAAE,QAAQ,EACX,eAAe,EAAE,KAAK,GACrB,IAAI,CAAC;AA+CR;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAG1C;AAED;;;;GAIG;AACH,wBAAgB,mBAAmB,IAAI,IAAI,CAG1C;AAQD;;;;;;GAMG;AACH,wBAAgB,wBAAwB,IAAI,IAAI,CAK/C;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,wBAAgB,oBAAoB,CAClC,GAAG,EAAE,MAAM,EACX,cAAc,EAAE,WAAW,GAC1B,IAAI,CAiBN"}
@@ -10,6 +10,8 @@ local ____deepCopy = require("src.functions.deepCopy")
10
10
  local deepCopy = ____deepCopy.deepCopy
11
11
  local ____types = require("src.functions.types")
12
12
  local isString = ____types.isString
13
+ local ____constants = require("src.features.saveDataManager.constants")
14
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
13
15
  local ____main = require("src.features.saveDataManager.main")
14
16
  local forceSaveDataManagerLoad = ____main.forceSaveDataManagerLoad
15
17
  local forceSaveDataManagerSave = ____main.forceSaveDataManagerSave
@@ -18,8 +20,6 @@ local ____maps = require("src.features.saveDataManager.maps")
18
20
  local saveDataConditionalFuncMap = ____maps.saveDataConditionalFuncMap
19
21
  local saveDataDefaultsMap = ____maps.saveDataDefaultsMap
20
22
  local saveDataMap = ____maps.saveDataMap
21
- local ____saveDataManagerConstants = require("src.features.saveDataManager.saveDataManagerConstants")
22
- local SAVE_DATA_MANAGER_FEATURE_NAME = ____saveDataManagerConstants.SAVE_DATA_MANAGER_FEATURE_NAME
23
23
  --- This is the entry point to the save data manager, a system which provides two major features:
24
24
  --
25
25
  -- 1. automatic resetting of variables on a new run, on a new level, or on a new room (as desired)
@@ -91,9 +91,14 @@ local SAVE_DATA_MANAGER_FEATURE_NAME = ____saveDataManagerConstants.SAVE_DATA_MA
91
91
  -- data manager cannot do this on its own because it cannot know when your mod features are finished
92
92
  -- initializing.)
93
93
  --
94
- -- Finally, some features may have variables that need to be automatically reset per run/level, but
95
- -- not saved to disk on game exit. (For example, if they contain functions or other non-serializable
96
- -- data.) For these cases, set the second argument to `() => false`.
94
+ -- Some features may have variables that need to be automatically reset per run/level, but not saved
95
+ -- to disk on game exit. (For example, if they contain functions or other non-serializable data.)
96
+ -- For these cases, set the second argument to `() => false`.
97
+ --
98
+ -- Note that when the player uses Glowing Hour Glass, the save data manager will automatically
99
+ -- restore any variables on a "run" or "level" object with a backup that was created when the room
100
+ -- was entered. Thus, you should not have to explicitly program support for Glowing Hour Glass into
101
+ -- your mod features that use the save data manager.
97
102
  --
98
103
  -- @param key The name of the file or feature that is submitting data to be managed by the save data
99
104
  -- manager. The save data manager will throw an error if the key is already registered.
@@ -1 +1 @@
1
- {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/load.ts"],"names":[],"mappings":";;AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AASrD,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GACpC,IAAI,CAmDN"}
1
+ {"version":3,"file":"load.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/load.ts"],"names":[],"mappings":";;AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AASrD,wBAAgB,YAAY,CAC1B,GAAG,EAAE,GAAG,EACR,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,GACpC,IAAI,CAuDN"}
@@ -12,11 +12,11 @@ local iterateTableInOrder = ____table.iterateTableInOrder
12
12
  local ____types = require("src.functions.types")
13
13
  local isString = ____types.isString
14
14
  local isTable = ____types.isTable
15
+ local ____constants = require("src.features.saveDataManager.constants")
16
+ local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
17
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
15
18
  local ____merge = require("src.features.saveDataManager.merge")
16
19
  local merge = ____merge.merge
17
- local ____saveDataManagerConstants = require("src.features.saveDataManager.saveDataManagerConstants")
18
- local SAVE_DATA_MANAGER_DEBUG = ____saveDataManagerConstants.SAVE_DATA_MANAGER_DEBUG
19
- local SAVE_DATA_MANAGER_FEATURE_NAME = ____saveDataManagerConstants.SAVE_DATA_MANAGER_FEATURE_NAME
20
20
  function readSaveDatFile(self, mod)
21
21
  local renderFrameCount = Isaac.GetFrameCount()
22
22
  local ok, jsonStringOrErrMsg = pcall(tryLoadModData, mod)
@@ -52,21 +52,21 @@ function ____exports.loadFromDisk(self, mod, oldSaveData)
52
52
  iterateTableInOrder(
53
53
  nil,
54
54
  newSaveData,
55
- function(____, key, value)
56
- if not isString(nil, key) then
55
+ function(____, subscriberName, saveData)
56
+ if not isString(nil, subscriberName) then
57
57
  return
58
58
  end
59
- if not isTable(nil, value) then
59
+ if not isTable(nil, saveData) then
60
60
  return
61
61
  end
62
- local oldSaveDataForSubscriber = oldSaveData[key]
62
+ local oldSaveDataForSubscriber = oldSaveData[subscriberName]
63
63
  if oldSaveDataForSubscriber == nil then
64
64
  return
65
65
  end
66
66
  if SAVE_DATA_MANAGER_DEBUG then
67
- log(nil, "Merging in stored data for feature: " .. key)
67
+ log(nil, "Merging in stored data for feature: " .. subscriberName)
68
68
  end
69
- merge(nil, oldSaveDataForSubscriber, value, key)
69
+ merge(nil, oldSaveDataForSubscriber, saveData, subscriberName)
70
70
  end,
71
71
  SAVE_DATA_MANAGER_DEBUG
72
72
  )
@@ -1 +1 @@
1
- {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAMtD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAsBrD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAelE;AA2FD,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,GACvB,IAAI,CA4CN;AAiBD,wBAAgB,wBAAwB,IAAI,IAAI,CAM/C;AAED,wBAAgB,wBAAwB,IAAI,IAAI,CAM/C"}
1
+ {"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/main.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAMtD,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AA0BrD,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,WAAW,GAAG,IAAI,CAelE;AAiKD,wBAAgB,sBAAsB,CACpC,cAAc,EAAE,MAAM,EACtB,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,WAAW,GACvB,IAAI,CA4CN;AAiBD,wBAAgB,wBAAwB,IAAI,IAAI,CAM/C;AAED,wBAAgB,wBAAwB,IAAI,IAAI,CAM/C"}
@@ -2,7 +2,7 @@ local ____lualib = require("lualib_bundle")
2
2
  local Set = ____lualib.Set
3
3
  local __TS__New = ____lualib.__TS__New
4
4
  local ____exports = {}
5
- local postUseItemGlowingHourGlass, postPlayerInit, preGameExit, postNewLevel, postNewRoomEarly, restoreDefaultsAll, restoreDefaults, clearAndCopyAllElements, RESETTABLE_SAVE_DATA_KEYS, mod, loadedDataOnThisRun
5
+ local postUseItemGlowingHourGlass, postPlayerInit, preGameExit, postNewLevel, postNewRoomEarly, makeGlowingHourGlassBackup, restoreGlowingHourGlassBackup, restoreDefaultsAll, restoreDefaults, clearAndCopyAllElements, RESETTABLE_SAVE_DATA_KEYS, mod, loadedDataOnThisRun, restoreGlowingHourGlassDataOnNextRoom
6
6
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
7
7
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
8
8
  local ModCallback = ____isaac_2Dtypescript_2Ddefinitions.ModCallback
@@ -23,18 +23,23 @@ local onFirstFloor = ____stage.onFirstFloor
23
23
  local ____table = require("src.functions.table")
24
24
  local clearTable = ____table.clearTable
25
25
  local iterateTableInOrder = ____table.iterateTableInOrder
26
+ local ____constants = require("src.features.saveDataManager.constants")
27
+ local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
28
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
29
+ local SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS = ____constants.SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS
26
30
  local ____load = require("src.features.saveDataManager.load")
27
31
  local loadFromDisk = ____load.loadFromDisk
28
32
  local ____maps = require("src.features.saveDataManager.maps")
29
33
  local saveDataConditionalFuncMap = ____maps.saveDataConditionalFuncMap
30
34
  local saveDataDefaultsMap = ____maps.saveDataDefaultsMap
35
+ local saveDataGlowingHourGlassMap = ____maps.saveDataGlowingHourGlassMap
31
36
  local saveDataMap = ____maps.saveDataMap
37
+ local ____merge = require("src.features.saveDataManager.merge")
38
+ local merge = ____merge.merge
32
39
  local ____save = require("src.features.saveDataManager.save")
33
40
  local saveToDisk = ____save.saveToDisk
34
- local ____saveDataManagerConstants = require("src.features.saveDataManager.saveDataManagerConstants")
35
- local SAVE_DATA_MANAGER_DEBUG = ____saveDataManagerConstants.SAVE_DATA_MANAGER_DEBUG
36
- local SAVE_DATA_MANAGER_FEATURE_NAME = ____saveDataManagerConstants.SAVE_DATA_MANAGER_FEATURE_NAME
37
41
  function postUseItemGlowingHourGlass(self)
42
+ restoreGlowingHourGlassDataOnNextRoom = true
38
43
  return nil
39
44
  end
40
45
  function postPlayerInit(self)
@@ -71,6 +76,63 @@ function postNewLevel(self)
71
76
  end
72
77
  function postNewRoomEarly(self)
73
78
  restoreDefaults(nil, SaveDataKey.ROOM)
79
+ if restoreGlowingHourGlassDataOnNextRoom then
80
+ restoreGlowingHourGlassDataOnNextRoom = false
81
+ restoreGlowingHourGlassBackup(nil)
82
+ else
83
+ makeGlowingHourGlassBackup(nil)
84
+ end
85
+ end
86
+ function makeGlowingHourGlassBackup(self)
87
+ iterateTableInOrder(
88
+ nil,
89
+ saveDataMap,
90
+ function(____, subscriberName, saveData)
91
+ for ____, saveDataKey in ipairs(SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS) do
92
+ do
93
+ local childTable = saveData[saveDataKey]
94
+ if childTable == nil then
95
+ goto __continue18
96
+ end
97
+ local saveDataGlowingHourGlass = saveDataGlowingHourGlassMap[subscriberName]
98
+ if saveDataGlowingHourGlass == nil then
99
+ saveDataGlowingHourGlass = {}
100
+ end
101
+ local copiedChildTable = deepCopy(nil, childTable)
102
+ saveDataGlowingHourGlass[saveDataKey] = copiedChildTable
103
+ end
104
+ ::__continue18::
105
+ end
106
+ end,
107
+ SAVE_DATA_MANAGER_DEBUG
108
+ )
109
+ end
110
+ function restoreGlowingHourGlassBackup(self)
111
+ iterateTableInOrder(
112
+ nil,
113
+ saveDataMap,
114
+ function(____, subscriberName, saveData)
115
+ for ____, saveDataKey in ipairs(SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS) do
116
+ do
117
+ local childTable = saveData[saveDataKey]
118
+ if childTable == nil then
119
+ goto __continue24
120
+ end
121
+ local saveDataGlowingHourGlass = saveDataGlowingHourGlassMap[subscriberName]
122
+ if saveDataGlowingHourGlass == nil then
123
+ goto __continue24
124
+ end
125
+ local childTableBackup = saveDataGlowingHourGlass[saveDataKey]
126
+ if childTableBackup == nil then
127
+ goto __continue24
128
+ end
129
+ merge(nil, childTable, childTableBackup, subscriberName .. "__glowingHourGlass")
130
+ end
131
+ ::__continue24::
132
+ end
133
+ end,
134
+ SAVE_DATA_MANAGER_DEBUG
135
+ )
74
136
  end
75
137
  function restoreDefaultsAll(self)
76
138
  restoreDefaults(nil, SaveDataKey.RUN)
@@ -117,6 +179,7 @@ end
117
179
  RESETTABLE_SAVE_DATA_KEYS = __TS__New(Set, {SaveDataKey.RUN, SaveDataKey.LEVEL, SaveDataKey.ROOM})
118
180
  mod = nil
119
181
  loadedDataOnThisRun = false
182
+ restoreGlowingHourGlassDataOnNextRoom = false
120
183
  function ____exports.saveDataManagerInit(self, incomingMod)
121
184
  mod = incomingMod
122
185
  mod:AddCallback(ModCallback.POST_USE_ITEM, postUseItemGlowingHourGlass, CollectibleType.GLOWING_HOUR_GLASS)
@@ -8,4 +8,9 @@ import { SaveData } from "../../interfaces/SaveData";
8
8
  export declare const saveDataMap: LuaMap<string, SaveData<unknown, unknown, unknown>>;
9
9
  export declare const saveDataDefaultsMap: LuaMap<string, SaveData<unknown, unknown, unknown>>;
10
10
  export declare const saveDataConditionalFuncMap: LuaMap<string, () => boolean>;
11
+ /**
12
+ * We backup some save data keys on every new room for the purposes of restoring it when Glowing
13
+ * Hour Glass is used.
14
+ */
15
+ export declare const saveDataGlowingHourGlassMap: LuaMap<string, SaveData<unknown, unknown, unknown>>;
11
16
  //# sourceMappingURL=maps.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"maps.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/maps.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,WAAW,qDAAiC,CAAC;AAE1D,eAAO,MAAM,mBAAmB,qDAAiC,CAAC;AAClE,eAAO,MAAM,0BAA0B,uBAA4B,OAAO,CAAG,CAAC"}
1
+ {"version":3,"file":"maps.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/maps.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAErD;;;;GAIG;AACH,eAAO,MAAM,WAAW,qDAAiC,CAAC;AAE1D,eAAO,MAAM,mBAAmB,qDAAiC,CAAC;AAClE,eAAO,MAAM,0BAA0B,uBAA4B,OAAO,CAAG,CAAC;AAE9E;;;GAGG;AACH,eAAO,MAAM,2BAA2B,qDAAiC,CAAC"}
@@ -5,4 +5,7 @@ local ____exports = {}
5
5
  ____exports.saveDataMap = {}
6
6
  ____exports.saveDataDefaultsMap = {}
7
7
  ____exports.saveDataConditionalFuncMap = {}
8
+ --- We backup some save data keys on every new room for the purposes of restoring it when Glowing
9
+ -- Hour Glass is used.
10
+ ____exports.saveDataGlowingHourGlassMap = {}
8
11
  return ____exports
@@ -27,8 +27,8 @@ local ____types = require("src.functions.types")
27
27
  local isTable = ____types.isTable
28
28
  local ____utils = require("src.functions.utils")
29
29
  local getTraversalDescription = ____utils.getTraversalDescription
30
- local ____saveDataManagerConstants = require("src.features.saveDataManager.saveDataManagerConstants")
31
- local SAVE_DATA_MANAGER_DEBUG = ____saveDataManagerConstants.SAVE_DATA_MANAGER_DEBUG
30
+ local ____constants = require("src.features.saveDataManager.constants")
31
+ local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
32
32
  local ____serializationBrands = require("src.features.saveDataManager.serializationBrands")
33
33
  local isSerializationBrand = ____serializationBrands.isSerializationBrand
34
34
  --- `merge` takes the values from a new table and recursively merges them into an old object (while
@@ -12,9 +12,9 @@ local ____log = require("src.functions.log")
12
12
  local log = ____log.log
13
13
  local ____table = require("src.functions.table")
14
14
  local iterateTableInOrder = ____table.iterateTableInOrder
15
- local ____saveDataManagerConstants = require("src.features.saveDataManager.saveDataManagerConstants")
16
- local SAVE_DATA_MANAGER_DEBUG = ____saveDataManagerConstants.SAVE_DATA_MANAGER_DEBUG
17
- local SAVE_DATA_MANAGER_FEATURE_NAME = ____saveDataManagerConstants.SAVE_DATA_MANAGER_FEATURE_NAME
15
+ local ____constants = require("src.features.saveDataManager.constants")
16
+ local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
17
+ local SAVE_DATA_MANAGER_FEATURE_NAME = ____constants.SAVE_DATA_MANAGER_FEATURE_NAME
18
18
  function getAllSaveDataToWriteToDisk(self, saveDataMap, saveDataConditionalFuncMap)
19
19
  local allSaveData = {}
20
20
  iterateTableInOrder(
@@ -68,6 +68,15 @@ export declare function addRoomClearChargeToSlot(player: EntityPlayer, activeSlo
68
68
  * is true.
69
69
  */
70
70
  export declare function addRoomClearCharges(bigRoomDoubleCharge?: boolean): void;
71
+ /**
72
+ * Helper function to get the amount of charges away from the maximum charge that a particular
73
+ * player is.
74
+ *
75
+ * This function accounts for The Battery. For example, if the player has 2/6 charges on a D6, this
76
+ * function will return 10 (because there are 4 charges remaining on the base charge and 6 charges
77
+ * remaining on The Battery charge).
78
+ */
79
+ export declare function getChargesAwayFromMax(player: EntityPlayer, activeSlot: ActiveSlot): int;
71
80
  /**
72
81
  * Helper function to get the combined normal charge and the battery charge for the player's active
73
82
  * item. This is useful because you have to add these two values together when setting the active
@@ -1 +1 @@
1
- {"version":3,"file":"charge.d.ts","sourceRoot":"","sources":["../../../src/functions/charge.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAKX,MAAM,8BAA8B,CAAC;AAStC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,EACtB,UAAU,SAAI,EACd,eAAe,UAAO,GACrB,GAAG,CA2BL;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,mBAAmB,UAAO,EAC1B,eAAe,UAAO,GACrB,IAAI,CAaN;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,EACtB,mBAAmB,UAAO,EAC1B,eAAe,UAAO,GACrB,IAAI,CAkBN;AAuED;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,mBAAmB,UAAO,GAAG,IAAI,CAIpE;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,GACrB,GAAG,CAKL;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,GACrB,OAAO,CAMT;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,GACrB,IAAI,CAYN"}
1
+ {"version":3,"file":"charge.d.ts","sourceRoot":"","sources":["../../../src/functions/charge.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAKX,MAAM,8BAA8B,CAAC;AAStC;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,SAAS,CACvB,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,EACtB,UAAU,SAAI,EACd,eAAe,UAAO,GACrB,GAAG,CA+BL;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,YAAY,EACpB,mBAAmB,UAAO,EAC1B,eAAe,UAAO,GACrB,IAAI,CAaN;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,wBAAwB,CACtC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,EACtB,mBAAmB,UAAO,EAC1B,eAAe,UAAO,GACrB,IAAI,CA4BN;AAqBD;;;;;;;;;;;;GAYG;AACH,wBAAgB,mBAAmB,CAAC,mBAAmB,UAAO,GAAG,IAAI,CAIpE;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,GACrB,GAAG,CAQL;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAC5B,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,GACrB,GAAG,CAKL;AAED,wBAAgB,yBAAyB,CACvC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,GACrB,OAAO,CAMT;AAED,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,YAAY,EACpB,UAAU,EAAE,UAAU,GACrB,IAAI,CAYN"}
@@ -1,5 +1,5 @@
1
1
  local ____exports = {}
2
- local getClampedChargesToAdd, getChargesToAddWithAAAModifier, shouldPlayFullRechargeSound
2
+ local getChargesToAddWithAAAModifier, shouldPlayFullRechargeSound
3
3
  local ____isaac_2Dtypescript_2Ddefinitions = require("isaac-typescript-definitions")
4
4
  local ActiveSlot = ____isaac_2Dtypescript_2Ddefinitions.ActiveSlot
5
5
  local CollectibleType = ____isaac_2Dtypescript_2Ddefinitions.CollectibleType
@@ -41,7 +41,8 @@ function ____exports.addCharge(self, player, activeSlot, numCharges, playSoundEf
41
41
  playSoundEffect = true
42
42
  end
43
43
  local hud = game:GetHUD()
44
- local chargesToAdd = getClampedChargesToAdd(nil, player, activeSlot, numCharges)
44
+ local chargesAwayFromMax = ____exports.getChargesAwayFromMax(nil, player, activeSlot)
45
+ local chargesToAdd = numCharges > chargesAwayFromMax and chargesAwayFromMax or numCharges
45
46
  local modifiedChargesToAdd = getChargesToAddWithAAAModifier(nil, player, activeSlot, chargesToAdd)
46
47
  local totalCharge = ____exports.getTotalCharge(nil, player, activeSlot)
47
48
  local newCharge = totalCharge + modifiedChargesToAdd
@@ -88,6 +89,9 @@ function ____exports.addRoomClearChargeToSlot(self, player, activeSlot, bigRoomD
88
89
  local room = game:GetRoom()
89
90
  local roomShape = room:GetRoomShape()
90
91
  local numCharges = bigRoomDoubleCharge and getRoomShapeCharges(nil, roomShape) or 1
92
+ if chargeType == ItemConfigChargeType.TIMED then
93
+ numCharges = getCollectibleMaxCharges(nil, activeItem)
94
+ end
91
95
  ____exports.addCharge(
92
96
  nil,
93
97
  player,
@@ -96,43 +100,28 @@ function ____exports.addRoomClearChargeToSlot(self, player, activeSlot, bigRoomD
96
100
  playSoundEffect
97
101
  )
98
102
  end
99
- function getClampedChargesToAdd(self, player, activeSlot, numCharges)
100
- local activeItem = player:GetActiveItem(activeSlot)
101
- local activeCharge = player:GetActiveCharge(activeSlot)
102
- local batteryCharge = player:GetBatteryCharge(activeSlot)
103
- local hasBattery = player:HasCollectible(CollectibleType.BATTERY)
104
- local maxCharges = getCollectibleMaxCharges(nil, activeItem)
105
- if not hasBattery and activeCharge == maxCharges then
106
- return 0
107
- end
108
- if hasBattery and batteryCharge == maxCharges then
109
- return 0
110
- end
111
- if not hasBattery and activeCharge + 1 == maxCharges then
112
- return 1
113
- end
114
- if hasBattery and batteryCharge + 1 == maxCharges then
115
- return 1
116
- end
117
- return numCharges
118
- end
119
103
  function getChargesToAddWithAAAModifier(self, player, activeSlot, chargesToAdd)
120
- local activeItem = player:GetActiveItem(activeSlot)
121
- local activeCharge = player:GetActiveCharge(activeSlot)
122
- local batteryCharge = player:GetBatteryCharge(activeSlot)
123
- local hasBattery = player:HasCollectible(CollectibleType.BATTERY)
124
104
  local hasAAABattery = player:HasTrinket(TrinketType.AAA_BATTERY)
125
- local maxCharges = getCollectibleMaxCharges(nil, activeItem)
126
105
  if not hasAAABattery then
127
106
  return chargesToAdd
128
107
  end
129
- if not hasBattery and activeCharge + chargesToAdd == maxCharges - 1 then
130
- return chargesToAdd + 1
131
- end
132
- if hasBattery and batteryCharge + chargesToAdd == maxCharges - 1 then
133
- return chargesToAdd + 1
134
- end
135
- return chargesToAdd
108
+ local chargesAwayFromMax = ____exports.getChargesAwayFromMax(nil, player, activeSlot)
109
+ local AAABatteryShouldApply = chargesToAdd == chargesAwayFromMax - 1
110
+ return AAABatteryShouldApply and chargesToAdd + 1 or chargesToAdd
111
+ end
112
+ --- Helper function to get the amount of charges away from the maximum charge that a particular
113
+ -- player is.
114
+ --
115
+ -- This function accounts for The Battery. For example, if the player has 2/6 charges on a D6, this
116
+ -- function will return 10 (because there are 4 charges remaining on the base charge and 6 charges
117
+ -- remaining on The Battery charge).
118
+ function ____exports.getChargesAwayFromMax(self, player, activeSlot)
119
+ local totalCharge = ____exports.getTotalCharge(nil, player, activeSlot)
120
+ local activeItem = player:GetActiveItem(activeSlot)
121
+ local hasBattery = player:HasCollectible(CollectibleType.BATTERY)
122
+ local maxCharges = getCollectibleMaxCharges(nil, activeItem)
123
+ local effectiveMaxCharges = hasBattery and maxCharges * 2 or maxCharges
124
+ return effectiveMaxCharges - totalCharge
136
125
  end
137
126
  --- Helper function to get the combined normal charge and the battery charge for the player's active
138
127
  -- item. This is useful because you have to add these two values together when setting the active
@@ -13,8 +13,8 @@ local ____SerializationBrand = require("src.enums.private.SerializationBrand")
13
13
  local SerializationBrand = ____SerializationBrand.SerializationBrand
14
14
  local ____SerializationType = require("src.enums.SerializationType")
15
15
  local SerializationType = ____SerializationType.SerializationType
16
- local ____saveDataManagerConstants = require("src.features.saveDataManager.saveDataManagerConstants")
17
- local SAVE_DATA_MANAGER_DEBUG = ____saveDataManagerConstants.SAVE_DATA_MANAGER_DEBUG
16
+ local ____constants = require("src.features.saveDataManager.constants")
17
+ local SAVE_DATA_MANAGER_DEBUG = ____constants.SAVE_DATA_MANAGER_DEBUG
18
18
  local ____serializationBrands = require("src.features.saveDataManager.serializationBrands")
19
19
  local isSerializationBrand = ____serializationBrands.isSerializationBrand
20
20
  local ____array = require("src.functions.array")
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "11.2.3",
3
+ "version": "12.0.0",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -17,7 +17,7 @@ import { isLRoom, isNarrowRoom } from "../../functions/roomShape";
17
17
  import { removeCharactersBefore, trimPrefix } from "../../functions/string";
18
18
  import { erange, irange } from "../../functions/utils";
19
19
  import { CustomStage } from "../../interfaces/private/CustomStage";
20
- import { ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH } from "./customStageConstants";
20
+ import { ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH } from "./constants";
21
21
 
22
22
  enum BackdropKind {
23
23
  /** The "N" stands for narrow rooms. */
@@ -17,7 +17,7 @@ import {
17
17
  import { CustomStage, RoomTypeMap } from "../../interfaces/private/CustomStage";
18
18
  import { saveDataManager } from "../saveDataManager/exports";
19
19
  import { setCustomStageBackdrop } from "./backdrop";
20
- import { CUSTOM_STAGE_FEATURE_NAME } from "./customStageConstants";
20
+ import { CUSTOM_STAGE_FEATURE_NAME } from "./constants";
21
21
  import {
22
22
  convertVanillaTrapdoors,
23
23
  removeUrnRewards,
@@ -4,7 +4,7 @@ import { getRandomArrayElement } from "../../functions/array";
4
4
  import { spawnEffectWithSeed } from "../../functions/entitiesSpecific";
5
5
  import { removeCharactersBefore } from "../../functions/string";
6
6
  import { CustomStage } from "../../interfaces/private/CustomStage";
7
- import { ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH } from "./customStageConstants";
7
+ import { ISAACSCRIPT_CUSTOM_STAGE_GFX_PATH } from "./constants";
8
8
  import v from "./v";
9
9
 
10
10
  type ShadowAnimation = "1x1" | "1x2" | "2x1" | "2x2";
@@ -7,10 +7,7 @@ import {
7
7
  getScreenTopCenterPos,
8
8
  } from "../../functions/ui";
9
9
  import { CustomStage } from "../../interfaces/private/CustomStage";
10
- import {
11
- UIStreakAnimation,
12
- UI_STREAK_ANIMATION_END_FRAMES,
13
- } from "./customStageConstants";
10
+ import { UIStreakAnimation, UI_STREAK_ANIMATION_END_FRAMES } from "./constants";
14
11
  import v from "./v";
15
12
 
16
13
  /** This must match the name of the shader in "shaders.xml". */
@@ -1,6 +1,6 @@
1
1
  import { ControllerIndex } from "isaac-typescript-definitions";
2
2
  import { CustomStage } from "../../interfaces/private/CustomStage";
3
- import { UIStreakAnimation } from "./customStageConstants";
3
+ import { UIStreakAnimation } from "./constants";
4
4
 
5
5
  const v = {
6
6
  run: {