isaacscript-common 11.2.4 → 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 (67) hide show
  1. package/dist/index.d.ts +8 -3
  2. package/dist/isaacscript-common.lua +138 -62
  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/deepCopy.lua +2 -2
  40. package/package.json +1 -1
  41. package/src/features/customStage/backdrop.ts +1 -1
  42. package/src/features/customStage/{customStageConstants.ts → constants.ts} +0 -0
  43. package/src/features/customStage/init.ts +1 -1
  44. package/src/features/customStage/shadows.ts +1 -1
  45. package/src/features/customStage/streakText.ts +1 -4
  46. package/src/features/customStage/v.ts +1 -1
  47. package/src/features/customStage/versusScreen.ts +1 -1
  48. package/src/features/customTrapdoor/{customTrapdoorConstants.ts → constants.ts} +0 -0
  49. package/src/features/customTrapdoor/exports.ts +1 -1
  50. package/src/features/customTrapdoor/init.ts +1 -1
  51. package/src/features/customTrapdoor/openClose.ts +1 -1
  52. package/src/features/customTrapdoor/spawn.ts +1 -1
  53. package/src/features/customTrapdoor/touched.ts +1 -1
  54. package/src/features/saveDataManager/constants.ts +15 -0
  55. package/src/features/saveDataManager/exports.ts +9 -4
  56. package/src/features/saveDataManager/load.ts +13 -9
  57. package/src/features/saveDataManager/main.ts +78 -4
  58. package/src/features/saveDataManager/maps.ts +6 -0
  59. package/src/features/saveDataManager/merge.ts +1 -1
  60. package/src/features/saveDataManager/save.ts +1 -1
  61. package/src/functions/deepCopy.ts +1 -1
  62. package/dist/src/features/customStage/customStageConstants.d.ts.map +0 -1
  63. package/dist/src/features/customTrapdoor/customTrapdoorConstants.d.ts.map +0 -1
  64. package/dist/src/features/saveDataManager/saveDataManagerConstants.d.ts +0 -4
  65. package/dist/src/features/saveDataManager/saveDataManagerConstants.d.ts.map +0 -1
  66. package/dist/src/features/saveDataManager/saveDataManagerConstants.lua +0 -5
  67. package/src/features/saveDataManager/saveDataManagerConstants.ts +0 -4
@@ -9,17 +9,20 @@ import { logError } from "../../functions/log";
9
9
  import { onFirstFloor } from "../../functions/stage";
10
10
  import { clearTable, iterateTableInOrder } from "../../functions/table";
11
11
  import { SaveData } from "../../interfaces/SaveData";
12
+ import {
13
+ SAVE_DATA_MANAGER_DEBUG,
14
+ SAVE_DATA_MANAGER_FEATURE_NAME,
15
+ SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS,
16
+ } from "./constants";
12
17
  import { loadFromDisk } from "./load";
13
18
  import {
14
19
  saveDataConditionalFuncMap,
15
20
  saveDataDefaultsMap,
21
+ saveDataGlowingHourGlassMap,
16
22
  saveDataMap,
17
23
  } from "./maps";
24
+ import { merge } from "./merge";
18
25
  import { saveToDisk } from "./save";
19
- import {
20
- SAVE_DATA_MANAGER_DEBUG,
21
- SAVE_DATA_MANAGER_FEATURE_NAME,
22
- } from "./saveDataManagerConstants";
23
26
 
24
27
  const RESETTABLE_SAVE_DATA_KEYS: ReadonlySet<SaveDataKey> = new Set([
25
28
  SaveDataKey.RUN,
@@ -29,6 +32,7 @@ const RESETTABLE_SAVE_DATA_KEYS: ReadonlySet<SaveDataKey> = new Set([
29
32
 
30
33
  let mod: ModUpgraded | null = null;
31
34
  let loadedDataOnThisRun = false;
35
+ let restoreGlowingHourGlassDataOnNextRoom = false;
32
36
 
33
37
  export function saveDataManagerInit(incomingMod: ModUpgraded): void {
34
38
  mod = incomingMod;
@@ -50,6 +54,7 @@ export function saveDataManagerInit(incomingMod: ModUpgraded): void {
50
54
  // ModCallback.POST_USE_ITEM (3)
51
55
  // CollectibleType.GLOWING_HOUR_GLASS (422)
52
56
  function postUseItemGlowingHourGlass() {
57
+ restoreGlowingHourGlassDataOnNextRoom = true;
53
58
  return undefined;
54
59
  }
55
60
 
@@ -118,6 +123,75 @@ function postNewLevel() {
118
123
  // ModCallbackCustom.POST_NEW_ROOM_EARLY
119
124
  function postNewRoomEarly() {
120
125
  restoreDefaults(SaveDataKey.ROOM);
126
+
127
+ // Handle the Glowing Hour Glass.
128
+ if (restoreGlowingHourGlassDataOnNextRoom) {
129
+ restoreGlowingHourGlassDataOnNextRoom = false;
130
+ restoreGlowingHourGlassBackup();
131
+ } else {
132
+ makeGlowingHourGlassBackup();
133
+ }
134
+ }
135
+
136
+ function makeGlowingHourGlassBackup() {
137
+ iterateTableInOrder(
138
+ saveDataMap,
139
+ (subscriberName, saveData) => {
140
+ for (const saveDataKey of SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS) {
141
+ const childTable = saveData[saveDataKey];
142
+ if (childTable === undefined) {
143
+ // This feature does not happen to store any variables on this particular child table.
144
+ continue;
145
+ }
146
+
147
+ let saveDataGlowingHourGlass =
148
+ saveDataGlowingHourGlassMap.get(subscriberName);
149
+ if (saveDataGlowingHourGlass === undefined) {
150
+ saveDataGlowingHourGlass = new LuaMap<string, unknown>() as SaveData;
151
+ }
152
+
153
+ const copiedChildTable = deepCopy(childTable);
154
+ saveDataGlowingHourGlass[saveDataKey] = copiedChildTable;
155
+ }
156
+ },
157
+ SAVE_DATA_MANAGER_DEBUG,
158
+ );
159
+ }
160
+
161
+ function restoreGlowingHourGlassBackup() {
162
+ iterateTableInOrder(
163
+ saveDataMap,
164
+ (subscriberName, saveData) => {
165
+ for (const saveDataKey of SAVE_DATA_MANAGER_GLOWING_HOUR_GLASS_BACKUP_KEYS) {
166
+ const childTable = saveData[saveDataKey];
167
+ if (childTable === undefined) {
168
+ // This feature does not happen to store any variables on this particular child table.
169
+ continue;
170
+ }
171
+
172
+ const saveDataGlowingHourGlass =
173
+ saveDataGlowingHourGlassMap.get(subscriberName);
174
+ if (saveDataGlowingHourGlass === undefined) {
175
+ // This should never happen.
176
+ continue;
177
+ }
178
+
179
+ const childTableBackup = saveDataGlowingHourGlass[saveDataKey];
180
+ if (childTableBackup === undefined) {
181
+ // This should never happen.
182
+ continue;
183
+ }
184
+
185
+ merge(
186
+ childTable as LuaMap<AnyNotNil, unknown>,
187
+ childTableBackup as LuaMap<AnyNotNil, unknown>,
188
+ // Append an arbitrary suffix for better error messages.
189
+ `${subscriberName}__glowingHourGlass`,
190
+ );
191
+ }
192
+ },
193
+ SAVE_DATA_MANAGER_DEBUG,
194
+ );
121
195
  }
122
196
 
123
197
  function restoreDefaultsAll() {
@@ -9,3 +9,9 @@ export const saveDataMap = new LuaMap<string, SaveData>();
9
9
 
10
10
  export const saveDataDefaultsMap = new LuaMap<string, SaveData>();
11
11
  export const saveDataConditionalFuncMap = new LuaMap<string, () => boolean>();
12
+
13
+ /**
14
+ * We backup some save data keys on every new room for the purposes of restoring it when Glowing
15
+ * Hour Glass is used.
16
+ */
17
+ export const saveDataGlowingHourGlassMap = new LuaMap<string, SaveData>();
@@ -11,7 +11,7 @@ import { clearTable, iterateTableInOrder } from "../../functions/table";
11
11
  import { isDefaultMap, isTSTLMap, isTSTLSet } from "../../functions/tstlClass";
12
12
  import { isTable } from "../../functions/types";
13
13
  import { getTraversalDescription } from "../../functions/utils";
14
- import { SAVE_DATA_MANAGER_DEBUG } from "./saveDataManagerConstants";
14
+ import { SAVE_DATA_MANAGER_DEBUG } from "./constants";
15
15
  import { isSerializationBrand } from "./serializationBrands";
16
16
 
17
17
  /**
@@ -7,7 +7,7 @@ import { SaveData } from "../../interfaces/SaveData";
7
7
  import {
8
8
  SAVE_DATA_MANAGER_DEBUG,
9
9
  SAVE_DATA_MANAGER_FEATURE_NAME,
10
- } from "./saveDataManagerConstants";
10
+ } from "./constants";
11
11
 
12
12
  export function saveToDisk(
13
13
  mod: Mod,
@@ -1,7 +1,7 @@
1
1
  import { DefaultMap } from "../classes/DefaultMap";
2
2
  import { SerializationBrand } from "../enums/private/SerializationBrand";
3
3
  import { SerializationType } from "../enums/SerializationType";
4
- import { SAVE_DATA_MANAGER_DEBUG } from "../features/saveDataManager/saveDataManagerConstants";
4
+ import { SAVE_DATA_MANAGER_DEBUG } from "../features/saveDataManager/constants";
5
5
  import { isSerializationBrand } from "../features/saveDataManager/serializationBrands";
6
6
  import { TSTLClass } from "../types/TSTLClass";
7
7
  import { isArray } from "./array";
@@ -1 +0,0 @@
1
- {"version":3,"file":"customStageConstants.d.ts","sourceRoot":"","sources":["../../../../src/features/customStage/customStageConstants.ts"],"names":[],"mappings":";AAAA,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AAEvD,eAAO,MAAM,iCAAiC,iCAAiC,CAAC;AAEhF,uCAAuC;AACvC,oBAAY,iBAAiB;IAC3B,IAAI,IAAA;IACJ,IAAI,IAAA;IACJ,SAAS,IAAA;CACV;AAED,uCAAuC;AACvC,eAAO,MAAM,8BAA8B,EAAE;IAC3C,QAAQ,EAAE,GAAG,IAAI,iBAAiB,GAAG,GAAG;CAKhC,CAAC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"customTrapdoorConstants.d.ts","sourceRoot":"","sources":["../../../../src/features/customTrapdoor/customTrapdoorConstants.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"}
@@ -1,4 +0,0 @@
1
- /** Set this to true to enable more verbosity in the save data manger. */
2
- export declare const SAVE_DATA_MANAGER_DEBUG: boolean;
3
- export declare const SAVE_DATA_MANAGER_FEATURE_NAME = "save data manager";
4
- //# sourceMappingURL=saveDataManagerConstants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"saveDataManagerConstants.d.ts","sourceRoot":"","sources":["../../../../src/features/saveDataManager/saveDataManagerConstants.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,eAAO,MAAM,uBAAuB,SAAmB,CAAC;AAExD,eAAO,MAAM,8BAA8B,sBAAsB,CAAC"}
@@ -1,5 +0,0 @@
1
- local ____exports = {}
2
- --- Set this to true to enable more verbosity in the save data manger.
3
- ____exports.SAVE_DATA_MANAGER_DEBUG = false
4
- ____exports.SAVE_DATA_MANAGER_FEATURE_NAME = "save data manager"
5
- return ____exports
@@ -1,4 +0,0 @@
1
- /** Set this to true to enable more verbosity in the save data manger. */
2
- export const SAVE_DATA_MANAGER_DEBUG = false as boolean;
3
-
4
- export const SAVE_DATA_MANAGER_FEATURE_NAME = "save data manager";