isaacscript-common 30.12.7 → 30.12.9

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.
@@ -7566,16 +7566,16 @@ export declare function inHomeCloset(): boolean;
7566
7566
  * For example:
7567
7567
  *
7568
7568
  * ```ts
7569
- * const features = [
7569
+ * const MOD_FEATURES = [
7570
7570
  * MyFeature1,
7571
7571
  * MyFeature2,
7572
7572
  * MyFeature3,
7573
7573
  * ] as const;
7574
- * initModFeatures(mod, modFeatures);
7574
+ * initModFeatures(mod, MOD_FEATURES);
7575
7575
  * ```
7576
7576
  *
7577
7577
  * @returns An array of the instantiated features in the same order that the constructors were
7578
- * passed in.
7578
+ * passed in. (In most cases, you probably won't need the returned array.)
7579
7579
  */
7580
7580
  export declare function initModFeatures<T extends ReadonlyArray<typeof ModFeature>>(mod: ModUpgraded, modFeatures: T): {
7581
7581
  [K in keyof T]: InstanceType<T[K]>;
@@ -12798,24 +12798,22 @@ declare class ModdedElementSets extends Feature {
12798
12798
  * mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
12799
12799
  * that automatically subscribe to callbacks.
12800
12800
  *
12801
- * When instantiating a mod feature class, you must pass your upgraded mod as the first argument to
12802
- * the constructor.
12801
+ * It is recommended that you use the `initModFeatures` helper function to instantiate all of your
12802
+ * mod classes (instead of instantiating them yourself). This is so that any attached `v` objects
12803
+ * are properly registered with the save data manager; see below.
12803
12804
  *
12804
- * If your feature has variables that are managed by the save data manager, you need to explicitly
12805
- * register them with the save data manager yourself in your class constructor. (It can't be
12806
- * automatically done because parent classes don't have access to child class properties.)
12805
+ * If you are manually instantiating a mod feature yourself, then:
12807
12806
  *
12808
- * In almost all cases, you will want the callback functions to be immediately subscribed after
12809
- * instantiating the class. However, if this is not the case, you can pass `false` as the optional
12810
- * second argument to the constructor.
12807
+ * - You must pass your upgraded mod as the first argument to the constructor.
12808
+ * - In almost all cases, you will want the callback functions to be immediately subscribed after
12809
+ * instantiating the class. However, if this is not the case, you can pass `false` as the optional
12810
+ * second argument to the constructor.
12811
12811
  *
12812
12812
  * If your mod feature has a property called `v`, it will be assumed that these are variables that
12813
- * should be managed by the save data manager. Subsequently, they will automatically be registered
12814
- * with the save data manager upon initialization. Unfortunately, due to technical limitations with
12815
- * classes, this registration will only occur if you initialize the class with the `init` boolean
12816
- * argument set to false, and then explicitly call the `ModFeature.init` method yourself after the
12817
- * class is constructed. (This is because the parent class does not have access to the child's
12818
- * properties upon first construction.)
12813
+ * should be managed by the save data manager. Unfortunately, due to technical limitations with
12814
+ * classes, this registration will only occur if you initialize the class with the `initModFeatures`
12815
+ * helper function. (This is because the parent class does not have access to the child's properties
12816
+ * upon first construction.)
12819
12817
  */
12820
12818
  export declare class ModFeature {
12821
12819
  private readonly mod;
@@ -15169,21 +15167,20 @@ declare class SaveDataManager extends Feature {
15169
15167
  * desired).
15170
15168
  * 2. Automatic saving and loading of all tracked data to the "save#.dat" file.
15171
15169
  *
15172
- * You feed this function with an object containing your variables, and then it will automatically
15173
- * manage them for you. (See below for an example.)
15170
+ * You provide this function with an object containing your variables, and then it will
15171
+ * automatically manage them for you. (See below for an example.)
15174
15172
  *
15175
15173
  * In order to use this function, you must upgrade your mod with `ISCFeature.SAVE_DATA_MANAGER`.
15176
15174
  * (Upgrade your mod before registering any of your own callbacks so that the save data manager
15177
15175
  * will run before any of your code does.)
15178
15176
  *
15179
15177
  * The save data manager is meant to be called once for each feature of your mod. In other words,
15180
- * you should not put all of the data for your mod on the same object. Instead, scope your
15178
+ * you should not put all of the variables for your mod on the same object. Instead, scope your
15181
15179
  * variables locally to a single file that contains a mod feature, and then call this function to
15182
15180
  * register them. For example:
15183
15181
  *
15184
15182
  * ```ts
15185
15183
  * // In file: feature1.ts
15186
- * import { saveDataManager } from "isaacscript-common";
15187
15184
  *
15188
15185
  * // Declare local variables for this file or feature.
15189
15186
  * const v = {
@@ -15207,13 +15204,12 @@ declare class SaveDataManager extends Feature {
15207
15204
  * foo4: 0,
15208
15205
  * },
15209
15206
  * };
15210
- * // Every child object is optional; only create the ones that you need.
15207
+ * // The child objects of "persistent", "run", "level", and "room are optional; only create the
15208
+ * // ones that you need.
15211
15209
  *
15212
- * // Register the variables with the save data manager. (We need to provide a string key that
15213
- * // matches the name of this file.)
15214
- * function feature1Init() {
15215
- * saveDataManager("feature1", v);
15216
- * }
15210
+ * // Now, give `v` to the save data manager, and it will automatically manage the variables for
15211
+ * // you.
15212
+ * mod.saveDataManager("feature1", v);
15217
15213
  *
15218
15214
  * // Elsewhere in the file, use your variables.
15219
15215
  * function feature1Function() {
@@ -1,6 +1,6 @@
1
1
  --[[
2
2
 
3
- isaacscript-common 30.12.7
3
+ isaacscript-common 30.12.9
4
4
 
5
5
  This is the "isaacscript-common" library, which was created with the IsaacScript tool.
6
6
 
@@ -16650,15 +16650,16 @@ local __TS__Iterator = ____lualib.__TS__Iterator
16650
16650
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
16651
16651
  local __TS__ArraySort = ____lualib.__TS__ArraySort
16652
16652
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
16653
+ local __TS__ArrayUnshift = ____lualib.__TS__ArrayUnshift
16653
16654
  local __TS__ArraySlice = ____lualib.__TS__ArraySlice
16654
16655
  local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
16655
16656
  local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
16656
16657
  local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
16657
- local __TS__ArrayUnshift = ____lualib.__TS__ArrayUnshift
16658
16658
  local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
16659
16659
  local __TS__ArraySome = ____lualib.__TS__ArraySome
16660
16660
  local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
16661
16661
  local ____exports = {}
16662
+ local addCombinations
16662
16663
  local ____ReadonlySet = require("src.types.ReadonlySet")
16663
16664
  local ReadonlySet = ____ReadonlySet.ReadonlySet
16664
16665
  local ____random = require("src.functions.random")
@@ -16715,6 +16716,30 @@ function ____exports.copyArray(self, oldArray, numElements)
16715
16716
  end
16716
16717
  return newArrayWithFirstNElements
16717
16718
  end
16719
+ function addCombinations(self, n, src, got, all)
16720
+ if n == 0 then
16721
+ if #got > 0 then
16722
+ all[#all + 1] = got
16723
+ end
16724
+ return
16725
+ end
16726
+ for ____, ____value in __TS__Iterator(__TS__ArrayEntries(src)) do
16727
+ local i = ____value[1]
16728
+ local element = ____value[2]
16729
+ local ____addCombinations_3 = addCombinations
16730
+ local ____temp_1 = n - 1
16731
+ local ____TS__ArraySlice_result_2 = __TS__ArraySlice(src, i + 1)
16732
+ local ____array_0 = __TS__SparseArrayNew(table.unpack(got))
16733
+ __TS__SparseArrayPush(____array_0, element)
16734
+ ____addCombinations_3(
16735
+ nil,
16736
+ ____temp_1,
16737
+ ____TS__ArraySlice_result_2,
16738
+ {__TS__SparseArraySpread(____array_0)},
16739
+ all
16740
+ )
16741
+ end
16742
+ end
16718
16743
  function ____exports.getRandomArrayIndex(self, array, seedOrRNG, exceptions)
16719
16744
  if seedOrRNG == nil then
16720
16745
  seedOrRNG = getRandomSeed(nil)
@@ -16836,33 +16861,6 @@ function ____exports.getArrayCombinations(self, array, includeEmptyArray, min, m
16836
16861
  if max == nil or max <= 0 then
16837
16862
  max = #array
16838
16863
  end
16839
- local addCombinations
16840
- addCombinations = function(____, n, src, got, all)
16841
- if n == 0 then
16842
- if #got > 0 then
16843
- all[#all + 1] = got
16844
- end
16845
- return
16846
- end
16847
- do
16848
- local j = 0
16849
- while j < #src do
16850
- local value = src[j + 1]
16851
- local ____temp_1 = n - 1
16852
- local ____TS__ArraySlice_result_2 = __TS__ArraySlice(src, j + 1)
16853
- local ____array_0 = __TS__SparseArrayNew(table.unpack(got))
16854
- __TS__SparseArrayPush(____array_0, value)
16855
- addCombinations(
16856
- nil,
16857
- ____temp_1,
16858
- ____TS__ArraySlice_result_2,
16859
- {__TS__SparseArraySpread(____array_0)},
16860
- all
16861
- )
16862
- j = j + 1
16863
- end
16864
- end
16865
- end
16866
16864
  local all = {}
16867
16865
  do
16868
16866
  local i = min
@@ -8,24 +8,22 @@ export declare const MOD_FEATURE_CUSTOM_CALLBACKS_KEY = "__customCallbacks";
8
8
  * mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
9
9
  * that automatically subscribe to callbacks.
10
10
  *
11
- * When instantiating a mod feature class, you must pass your upgraded mod as the first argument to
12
- * the constructor.
11
+ * It is recommended that you use the `initModFeatures` helper function to instantiate all of your
12
+ * mod classes (instead of instantiating them yourself). This is so that any attached `v` objects
13
+ * are properly registered with the save data manager; see below.
13
14
  *
14
- * If your feature has variables that are managed by the save data manager, you need to explicitly
15
- * register them with the save data manager yourself in your class constructor. (It can't be
16
- * automatically done because parent classes don't have access to child class properties.)
15
+ * If you are manually instantiating a mod feature yourself, then:
17
16
  *
18
- * In almost all cases, you will want the callback functions to be immediately subscribed after
19
- * instantiating the class. However, if this is not the case, you can pass `false` as the optional
20
- * second argument to the constructor.
17
+ * - You must pass your upgraded mod as the first argument to the constructor.
18
+ * - In almost all cases, you will want the callback functions to be immediately subscribed after
19
+ * instantiating the class. However, if this is not the case, you can pass `false` as the optional
20
+ * second argument to the constructor.
21
21
  *
22
22
  * If your mod feature has a property called `v`, it will be assumed that these are variables that
23
- * should be managed by the save data manager. Subsequently, they will automatically be registered
24
- * with the save data manager upon initialization. Unfortunately, due to technical limitations with
25
- * classes, this registration will only occur if you initialize the class with the `init` boolean
26
- * argument set to false, and then explicitly call the `ModFeature.init` method yourself after the
27
- * class is constructed. (This is because the parent class does not have access to the child's
28
- * properties upon first construction.)
23
+ * should be managed by the save data manager. Unfortunately, due to technical limitations with
24
+ * classes, this registration will only occur if you initialize the class with the `initModFeatures`
25
+ * helper function. (This is because the parent class does not have access to the child's properties
26
+ * upon first construction.)
29
27
  */
30
28
  export declare class ModFeature {
31
29
  private readonly mod;
@@ -1 +1 @@
1
- {"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AASpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,gCAAgC,sBAAsB,CAAC;AAyBpE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAc;IAElC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,SAAS,CAAC,yBAAyB,EAC/B,CAAC,CAAC,CAAC,SAAS,OAAO,EACjB,OAAO,EAAE,CAAC,EACV,WAAW,EAAE,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,iBAAiB,EAC7D,GAAG,YAAY,EAAE,OAAO,EAAE,KACvB,OAAO,CAAC,GACb,IAAI,CAAQ;IAEhB;;;;;OAKG;IACI,WAAW,UAAS;gBAEf,GAAG,EAAE,WAAW,EAAE,IAAI,UAAO;IAQzC;;;;;OAKG;IACI,IAAI,CAAC,IAAI,UAAO,GAAG,IAAI;IAqB9B;;;;;OAKG;IACI,MAAM,IAAI,IAAI;CAGtB"}
1
+ {"version":3,"file":"ModFeature.d.ts","sourceRoot":"","sources":["../../../src/classes/ModFeature.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAEhE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AASpE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAEjD,eAAO,MAAM,yBAAyB,gBAAgB,CAAC;AACvD,eAAO,MAAM,gCAAgC,sBAAsB,CAAC;AAyBpE;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,qBAAa,UAAU;IACrB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAc;IAElC;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,SAAS,CAAC,yBAAyB,EAC/B,CAAC,CAAC,CAAC,SAAS,OAAO,EACjB,OAAO,EAAE,CAAC,EACV,WAAW,EAAE,CAAC,SAAS,IAAI,GAAG,WAAW,GAAG,iBAAiB,EAC7D,GAAG,YAAY,EAAE,OAAO,EAAE,KACvB,OAAO,CAAC,GACb,IAAI,CAAQ;IAEhB;;;;;OAKG;IACI,WAAW,UAAS;gBAEf,GAAG,EAAE,WAAW,EAAE,IAAI,UAAO;IAQzC;;;;;OAKG;IACI,IAAI,CAAC,IAAI,UAAO,GAAG,IAAI;IAqB9B;;;;;OAKG;IACI,MAAM,IAAI,IAAI;CAGtB"}
@@ -163,24 +163,22 @@ WRAPPED_CUSTOM_CALLBACK_METHODS_KEY = "__wrappedCustomCallbacksMethods"
163
163
  -- mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
164
164
  -- that automatically subscribe to callbacks.
165
165
  --
166
- -- When instantiating a mod feature class, you must pass your upgraded mod as the first argument to
167
- -- the constructor.
166
+ -- It is recommended that you use the `initModFeatures` helper function to instantiate all of your
167
+ -- mod classes (instead of instantiating them yourself). This is so that any attached `v` objects
168
+ -- are properly registered with the save data manager; see below.
168
169
  --
169
- -- If your feature has variables that are managed by the save data manager, you need to explicitly
170
- -- register them with the save data manager yourself in your class constructor. (It can't be
171
- -- automatically done because parent classes don't have access to child class properties.)
170
+ -- If you are manually instantiating a mod feature yourself, then:
172
171
  --
173
- -- In almost all cases, you will want the callback functions to be immediately subscribed after
174
- -- instantiating the class. However, if this is not the case, you can pass `false` as the optional
175
- -- second argument to the constructor.
172
+ -- - You must pass your upgraded mod as the first argument to the constructor.
173
+ -- - In almost all cases, you will want the callback functions to be immediately subscribed after
174
+ -- instantiating the class. However, if this is not the case, you can pass `false` as the optional
175
+ -- second argument to the constructor.
176
176
  --
177
177
  -- If your mod feature has a property called `v`, it will be assumed that these are variables that
178
- -- should be managed by the save data manager. Subsequently, they will automatically be registered
179
- -- with the save data manager upon initialization. Unfortunately, due to technical limitations with
180
- -- classes, this registration will only occur if you initialize the class with the `init` boolean
181
- -- argument set to false, and then explicitly call the `ModFeature.init` method yourself after the
182
- -- class is constructed. (This is because the parent class does not have access to the child's
183
- -- properties upon first construction.)
178
+ -- should be managed by the save data manager. Unfortunately, due to technical limitations with
179
+ -- classes, this registration will only occur if you initialize the class with the `initModFeatures`
180
+ -- helper function. (This is because the parent class does not have access to the child's properties
181
+ -- upon first construction.)
184
182
  ____exports.ModFeature = __TS__Class()
185
183
  local ModFeature = ____exports.ModFeature
186
184
  ModFeature.name = "ModFeature"
@@ -51,21 +51,20 @@ export declare class SaveDataManager extends Feature {
51
51
  * desired).
52
52
  * 2. Automatic saving and loading of all tracked data to the "save#.dat" file.
53
53
  *
54
- * You feed this function with an object containing your variables, and then it will automatically
55
- * manage them for you. (See below for an example.)
54
+ * You provide this function with an object containing your variables, and then it will
55
+ * automatically manage them for you. (See below for an example.)
56
56
  *
57
57
  * In order to use this function, you must upgrade your mod with `ISCFeature.SAVE_DATA_MANAGER`.
58
58
  * (Upgrade your mod before registering any of your own callbacks so that the save data manager
59
59
  * will run before any of your code does.)
60
60
  *
61
61
  * The save data manager is meant to be called once for each feature of your mod. In other words,
62
- * you should not put all of the data for your mod on the same object. Instead, scope your
62
+ * you should not put all of the variables for your mod on the same object. Instead, scope your
63
63
  * variables locally to a single file that contains a mod feature, and then call this function to
64
64
  * register them. For example:
65
65
  *
66
66
  * ```ts
67
67
  * // In file: feature1.ts
68
- * import { saveDataManager } from "isaacscript-common";
69
68
  *
70
69
  * // Declare local variables for this file or feature.
71
70
  * const v = {
@@ -89,13 +88,12 @@ export declare class SaveDataManager extends Feature {
89
88
  * foo4: 0,
90
89
  * },
91
90
  * };
92
- * // Every child object is optional; only create the ones that you need.
91
+ * // The child objects of "persistent", "run", "level", and "room are optional; only create the
92
+ * // ones that you need.
93
93
  *
94
- * // Register the variables with the save data manager. (We need to provide a string key that
95
- * // matches the name of this file.)
96
- * function feature1Init() {
97
- * saveDataManager("feature1", v);
98
- * }
94
+ * // Now, give `v` to the save data manager, and it will automatically manage the variables for
95
+ * // you.
96
+ * mod.saveDataManager("feature1", v);
99
97
  *
100
98
  * // Elsewhere in the file, use your variables.
101
99
  * function feature1Function() {
@@ -1 +1 @@
1
- {"version":3,"file":"SaveDataManager.d.ts","sourceRoot":"","sources":["../../../../../src/classes/features/other/SaveDataManager.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAOzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAExD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAsBhD,qBAAa,eAAgB,SAAQ,OAAO;IAC1C;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAM;IAE1B;;;;OAIG;IACH,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAkC;IAE9D;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAkC;IAEtE;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,0BAA0B,CAGvC;IAEJ;;;;;;OAMG;IACH,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAAkC;IAE9E;;;OAGG;IACH,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAkC;IAGpE,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,qCAAqC,CAAS;IAmCtD,OAAO,CAAC,QAAQ,CAAC,2BAA2B,CAU1C;IAGF,OAAO,CAAC,QAAQ,CAAC,cAAc,CA0B7B;IAGF,OAAO,CAAC,QAAQ,CAAC,WAAW,CAa1B;IAGF,OAAO,CAAC,QAAQ,CAAC,YAAY,CAY3B;IAGF,OAAO,C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KAAK,CAAC,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,CAAC,GACrC,OAAO,CAET;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,CAAC,EAC5B,aAAa,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,EAAE,EACjC,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,CAAC,EAAE,CAKL;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,KAAK,EAAE,CAAC,EAAE,EACV,SAAS,GAAE,IAAI,GAAG,GAAqB,GACtC,IAAI,CAWN;AAED,+DAA+D;AAC/D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,SAAS,MAAM,EAAE,GAAG,MAAM,CAEpE;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAM3E"}
@@ -8,15 +8,16 @@ local __TS__Iterator = ____lualib.__TS__Iterator
8
8
  local __TS__ArrayFilter = ____lualib.__TS__ArrayFilter
9
9
  local __TS__ArraySort = ____lualib.__TS__ArraySort
10
10
  local __TS__ArrayMap = ____lualib.__TS__ArrayMap
11
+ local __TS__ArrayUnshift = ____lualib.__TS__ArrayUnshift
11
12
  local __TS__ArraySlice = ____lualib.__TS__ArraySlice
12
13
  local __TS__SparseArrayNew = ____lualib.__TS__SparseArrayNew
13
14
  local __TS__SparseArrayPush = ____lualib.__TS__SparseArrayPush
14
15
  local __TS__SparseArraySpread = ____lualib.__TS__SparseArraySpread
15
- local __TS__ArrayUnshift = ____lualib.__TS__ArrayUnshift
16
16
  local __TS__ObjectKeys = ____lualib.__TS__ObjectKeys
17
17
  local __TS__ArraySome = ____lualib.__TS__ArraySome
18
18
  local __TS__ArrayReduce = ____lualib.__TS__ArrayReduce
19
19
  local ____exports = {}
20
+ local addCombinations
20
21
  local ____ReadonlySet = require("src.types.ReadonlySet")
21
22
  local ReadonlySet = ____ReadonlySet.ReadonlySet
22
23
  local ____random = require("src.functions.random")
@@ -98,6 +99,30 @@ function ____exports.copyArray(self, oldArray, numElements)
98
99
  end
99
100
  return newArrayWithFirstNElements
100
101
  end
102
+ function addCombinations(self, n, src, got, all)
103
+ if n == 0 then
104
+ if #got > 0 then
105
+ all[#all + 1] = got
106
+ end
107
+ return
108
+ end
109
+ for ____, ____value in __TS__Iterator(__TS__ArrayEntries(src)) do
110
+ local i = ____value[1]
111
+ local element = ____value[2]
112
+ local ____addCombinations_3 = addCombinations
113
+ local ____temp_1 = n - 1
114
+ local ____TS__ArraySlice_result_2 = __TS__ArraySlice(src, i + 1)
115
+ local ____array_0 = __TS__SparseArrayNew(table.unpack(got))
116
+ __TS__SparseArrayPush(____array_0, element)
117
+ ____addCombinations_3(
118
+ nil,
119
+ ____temp_1,
120
+ ____TS__ArraySlice_result_2,
121
+ {__TS__SparseArraySpread(____array_0)},
122
+ all
123
+ )
124
+ end
125
+ end
101
126
  --- Helper function to get a random index from the provided array.
102
127
  --
103
128
  -- @param array The array to get the index from.
@@ -294,33 +319,6 @@ function ____exports.getArrayCombinations(self, array, includeEmptyArray, min, m
294
319
  if max == nil or max <= 0 then
295
320
  max = #array
296
321
  end
297
- local addCombinations
298
- addCombinations = function(____, n, src, got, all)
299
- if n == 0 then
300
- if #got > 0 then
301
- all[#all + 1] = got
302
- end
303
- return
304
- end
305
- do
306
- local j = 0
307
- while j < #src do
308
- local value = src[j + 1]
309
- local ____temp_1 = n - 1
310
- local ____TS__ArraySlice_result_2 = __TS__ArraySlice(src, j + 1)
311
- local ____array_0 = __TS__SparseArrayNew(table.unpack(got))
312
- __TS__SparseArrayPush(____array_0, value)
313
- addCombinations(
314
- nil,
315
- ____temp_1,
316
- ____TS__ArraySlice_result_2,
317
- {__TS__SparseArraySpread(____array_0)},
318
- all
319
- )
320
- j = j + 1
321
- end
322
- end
323
- end
324
322
  local all = {}
325
323
  do
326
324
  local i = min
@@ -10,16 +10,16 @@ import type { ModUpgraded } from "../classes/ModUpgraded";
10
10
  * For example:
11
11
  *
12
12
  * ```ts
13
- * const features = [
13
+ * const MOD_FEATURES = [
14
14
  * MyFeature1,
15
15
  * MyFeature2,
16
16
  * MyFeature3,
17
17
  * ] as const;
18
- * initModFeatures(mod, modFeatures);
18
+ * initModFeatures(mod, MOD_FEATURES);
19
19
  * ```
20
20
  *
21
21
  * @returns An array of the instantiated features in the same order that the constructors were
22
- * passed in.
22
+ * passed in. (In most cases, you probably won't need the returned array.)
23
23
  */
24
24
  export declare function initModFeatures<T extends ReadonlyArray<typeof ModFeature>>(mod: ModUpgraded, modFeatures: T): {
25
25
  [K in keyof T]: InstanceType<T[K]>;
@@ -10,16 +10,16 @@ local ____exports = {}
10
10
  -- For example:
11
11
  --
12
12
  -- ```ts
13
- -- const features = [
13
+ -- const MOD_FEATURES = [
14
14
  -- MyFeature1,
15
15
  -- MyFeature2,
16
16
  -- MyFeature3,
17
17
  -- ] as const;
18
- -- initModFeatures(mod, modFeatures);
18
+ -- initModFeatures(mod, MOD_FEATURES);
19
19
  -- ```
20
20
  --
21
21
  -- @returns An array of the instantiated features in the same order that the constructors were
22
- -- passed in.
22
+ -- passed in. (In most cases, you probably won't need the returned array.)
23
23
  function ____exports.initModFeatures(self, mod, modFeatures)
24
24
  local instantiatedModFeatures = {}
25
25
  for ____, modFeature in ipairs(modFeatures) do
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "isaacscript-common",
3
- "version": "30.12.7",
3
+ "version": "30.12.9",
4
4
  "description": "Helper functions and features for IsaacScript mods.",
5
5
  "keywords": [
6
6
  "isaac",
@@ -21,10 +21,10 @@
21
21
  },
22
22
  "license": "GPL-3.0",
23
23
  "author": "Zamiell",
24
- "type": "module",
24
+ "type": "commonjs",
25
25
  "main": "dist/src/index",
26
26
  "types": "dist/index.rollup.d.ts",
27
27
  "dependencies": {
28
- "isaac-typescript-definitions": "^13.0.18"
28
+ "isaac-typescript-definitions": "^13.0.22"
29
29
  }
30
30
  }
@@ -42,26 +42,23 @@ type ModFeatureConstructor = TSTLClassMetatable["constructor"] & {
42
42
  * mod features from this class in order to enable the `@Callback` and `@CustomCallback` decorators
43
43
  * that automatically subscribe to callbacks.
44
44
  *
45
- * When instantiating a mod feature class, you must pass your upgraded mod as the first argument to
46
- * the constructor.
45
+ * It is recommended that you use the `initModFeatures` helper function to instantiate all of your
46
+ * mod classes (instead of instantiating them yourself). This is so that any attached `v` objects
47
+ * are properly registered with the save data manager; see below.
47
48
  *
48
- * If your feature has variables that are managed by the save data manager, you need to explicitly
49
- * register them with the save data manager yourself in your class constructor. (It can't be
50
- * automatically done because parent classes don't have access to child class properties.)
49
+ * If you are manually instantiating a mod feature yourself, then:
51
50
  *
52
- * In almost all cases, you will want the callback functions to be immediately subscribed after
53
- * instantiating the class. However, if this is not the case, you can pass `false` as the optional
54
- * second argument to the constructor.
51
+ * - You must pass your upgraded mod as the first argument to the constructor.
52
+ * - In almost all cases, you will want the callback functions to be immediately subscribed after
53
+ * instantiating the class. However, if this is not the case, you can pass `false` as the optional
54
+ * second argument to the constructor.
55
55
  *
56
56
  * If your mod feature has a property called `v`, it will be assumed that these are variables that
57
- * should be managed by the save data manager. Subsequently, they will automatically be registered
58
- * with the save data manager upon initialization. Unfortunately, due to technical limitations with
59
- * classes, this registration will only occur if you initialize the class with the `init` boolean
60
- * argument set to false, and then explicitly call the `ModFeature.init` method yourself after the
61
- * class is constructed. (This is because the parent class does not have access to the child's
62
- * properties upon first construction.)
57
+ * should be managed by the save data manager. Unfortunately, due to technical limitations with
58
+ * classes, this registration will only occur if you initialize the class with the `initModFeatures`
59
+ * helper function. (This is because the parent class does not have access to the child's properties
60
+ * upon first construction.)
63
61
  */
64
-
65
62
  export class ModFeature {
66
63
  private readonly mod: ModUpgraded;
67
64
 
@@ -221,21 +221,20 @@ export class SaveDataManager extends Feature {
221
221
  * desired).
222
222
  * 2. Automatic saving and loading of all tracked data to the "save#.dat" file.
223
223
  *
224
- * You feed this function with an object containing your variables, and then it will automatically
225
- * manage them for you. (See below for an example.)
224
+ * You provide this function with an object containing your variables, and then it will
225
+ * automatically manage them for you. (See below for an example.)
226
226
  *
227
227
  * In order to use this function, you must upgrade your mod with `ISCFeature.SAVE_DATA_MANAGER`.
228
228
  * (Upgrade your mod before registering any of your own callbacks so that the save data manager
229
229
  * will run before any of your code does.)
230
230
  *
231
231
  * The save data manager is meant to be called once for each feature of your mod. In other words,
232
- * you should not put all of the data for your mod on the same object. Instead, scope your
232
+ * you should not put all of the variables for your mod on the same object. Instead, scope your
233
233
  * variables locally to a single file that contains a mod feature, and then call this function to
234
234
  * register them. For example:
235
235
  *
236
236
  * ```ts
237
237
  * // In file: feature1.ts
238
- * import { saveDataManager } from "isaacscript-common";
239
238
  *
240
239
  * // Declare local variables for this file or feature.
241
240
  * const v = {
@@ -259,13 +258,12 @@ export class SaveDataManager extends Feature {
259
258
  * foo4: 0,
260
259
  * },
261
260
  * };
262
- * // Every child object is optional; only create the ones that you need.
261
+ * // The child objects of "persistent", "run", "level", and "room are optional; only create the
262
+ * // ones that you need.
263
263
  *
264
- * // Register the variables with the save data manager. (We need to provide a string key that
265
- * // matches the name of this file.)
266
- * function feature1Init() {
267
- * saveDataManager("feature1", v);
268
- * }
264
+ * // Now, give `v` to the save data manager, and it will automatically manage the variables for
265
+ * // you.
266
+ * mod.saveDataManager("feature1", v);
269
267
  *
270
268
  * // Elsewhere in the file, use your variables.
271
269
  * function feature1Function() {
@@ -269,26 +269,6 @@ export function getArrayCombinations<T>(
269
269
  max = array.length;
270
270
  }
271
271
 
272
- const addCombinations = (
273
- n: number,
274
- src: T[] | readonly T[],
275
- got: T[],
276
- all: Array<T[] | readonly T[]>,
277
- ) => {
278
- if (n === 0) {
279
- if (got.length > 0) {
280
- all[all.length] = got;
281
- }
282
-
283
- return;
284
- }
285
-
286
- for (let j = 0; j < src.length; j++) {
287
- const value = src[j]!; // eslint-disable-line @typescript-eslint/no-non-null-assertion
288
- addCombinations(n - 1, src.slice(j + 1), [...got, value], all);
289
- }
290
- };
291
-
292
272
  const all: Array<T[] | readonly T[]> = [];
293
273
  for (let i = min; i < array.length; i++) {
294
274
  addCombinations(i, array, [], all);
@@ -305,6 +285,25 @@ export function getArrayCombinations<T>(
305
285
  return all;
306
286
  }
307
287
 
288
+ function addCombinations<T>(
289
+ n: number,
290
+ src: T[] | readonly T[],
291
+ got: T[],
292
+ all: Array<T[] | readonly T[]>,
293
+ ) {
294
+ if (n === 0) {
295
+ if (got.length > 0) {
296
+ all[all.length] = got;
297
+ }
298
+
299
+ return;
300
+ }
301
+
302
+ for (const [i, element] of src.entries()) {
303
+ addCombinations(n - 1, src.slice(i + 1), [...got, element], all);
304
+ }
305
+ }
306
+
308
307
  /**
309
308
  * Helper function to get an array containing the indexes of an array.
310
309
  *
@@ -11,16 +11,16 @@ import type { ModUpgraded } from "../classes/ModUpgraded";
11
11
  * For example:
12
12
  *
13
13
  * ```ts
14
- * const features = [
14
+ * const MOD_FEATURES = [
15
15
  * MyFeature1,
16
16
  * MyFeature2,
17
17
  * MyFeature3,
18
18
  * ] as const;
19
- * initModFeatures(mod, modFeatures);
19
+ * initModFeatures(mod, MOD_FEATURES);
20
20
  * ```
21
21
  *
22
22
  * @returns An array of the instantiated features in the same order that the constructors were
23
- * passed in.
23
+ * passed in. (In most cases, you probably won't need the returned array.)
24
24
  */
25
25
  export function initModFeatures<T extends ReadonlyArray<typeof ModFeature>>(
26
26
  mod: ModUpgraded,