isaacscript-common 10.0.1 → 10.0.2
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.
- package/dist/index.d.ts +66 -19
- package/dist/isaacscript-common.lua +181 -88
- package/dist/package.lua +2 -2
- package/dist/src/features/deployJSONRoom.d.ts +16 -6
- package/dist/src/features/deployJSONRoom.d.ts.map +1 -1
- package/dist/src/features/deployJSONRoom.lua +16 -6
- package/dist/src/functions/bitSet128.d.ts +2 -1
- package/dist/src/functions/bitSet128.d.ts.map +1 -1
- package/dist/src/functions/color.d.ts +2 -3
- package/dist/src/functions/color.d.ts.map +1 -1
- package/dist/src/functions/curses.d.ts +1 -1
- package/dist/src/functions/curses.lua +1 -1
- package/dist/src/functions/deepCopy.d.ts +2 -1
- package/dist/src/functions/deepCopy.d.ts.map +1 -1
- package/dist/src/functions/deepCopy.lua +19 -25
- package/dist/src/functions/deepCopyTests.lua +13 -26
- package/dist/src/functions/kColor.d.ts +2 -3
- package/dist/src/functions/kColor.d.ts.map +1 -1
- package/dist/src/functions/rng.d.ts +2 -2
- package/dist/src/functions/rng.d.ts.map +1 -1
- package/dist/src/functions/serialization.d.ts +11 -4
- package/dist/src/functions/serialization.d.ts.map +1 -1
- package/dist/src/functions/serialization.lua +15 -0
- package/dist/src/functions/vector.d.ts +2 -1
- package/dist/src/functions/vector.d.ts.map +1 -1
- package/dist/src/functions/weighted.d.ts +6 -0
- package/dist/src/functions/weighted.d.ts.map +1 -0
- package/dist/src/functions/weighted.lua +35 -0
- package/dist/src/index.d.ts +2 -1
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.lua +8 -0
- package/dist/src/interfaces/SaveData.d.ts +3 -8
- package/dist/src/interfaces/SaveData.d.ts.map +1 -1
- package/dist/src/objects/isaacAPIClassTypeToBrand.d.ts +1 -1
- package/dist/src/objects/isaacAPIClassTypeToBrand.d.ts.map +1 -1
- package/dist/src/objects/isaacAPIClassTypeToBrand.lua +2 -2
- package/dist/src/objects/isaacAPIClassTypeToFunctions.d.ts +36 -8
- package/dist/src/objects/isaacAPIClassTypeToFunctions.d.ts.map +1 -1
- package/dist/src/objects/isaacAPIClassTypeToFunctions.lua +42 -7
- package/dist/src/types/WeightedArray.d.ts +4 -0
- package/dist/src/types/WeightedArray.d.ts.map +1 -0
- package/dist/src/types/{SerializedIsaacAPIClass.lua → WeightedArray.lua} +0 -0
- package/package.json +2 -2
- package/src/features/deployJSONRoom.ts +16 -6
- package/src/features/saveDataManager/exports.ts +1 -1
- package/src/functions/bitSet128.ts +2 -0
- package/src/functions/color.ts +2 -0
- package/src/functions/curses.ts +1 -1
- package/src/functions/deepCopy.ts +25 -15
- package/src/functions/deepCopyTests.ts +19 -41
- package/src/functions/initArray.ts +1 -1
- package/src/functions/kColor.ts +2 -0
- package/src/functions/rng.ts +2 -0
- package/src/functions/serialization.ts +72 -18
- package/src/functions/vector.ts +5 -1
- package/src/functions/weighted.ts +36 -0
- package/src/index.ts +2 -1
- package/src/interfaces/SaveData.ts +4 -3
- package/src/objects/isaacAPIClassTypeToBrand.ts +1 -1
- package/src/objects/isaacAPIClassTypeToFunctions.ts +58 -9
- package/src/types/WeightedArray.ts +2 -0
- package/dist/src/enums/private/CopyableIsaacAPIClassType.d.ts +0 -12
- package/dist/src/enums/private/CopyableIsaacAPIClassType.d.ts.map +0 -1
- package/dist/src/enums/private/CopyableIsaacAPIClassType.lua +0 -10
- package/dist/src/types/SerializedIsaacAPIClass.d.ts +0 -11
- package/dist/src/types/SerializedIsaacAPIClass.d.ts.map +0 -1
- package/src/enums/private/CopyableIsaacAPIClassType.ts +0 -11
- package/src/types/SerializedIsaacAPIClass.ts +0 -9
package/src/functions/rng.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
|
|
1
2
|
import { game } from "../core/cachedClasses";
|
|
2
3
|
import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
3
4
|
import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
|
|
@@ -6,6 +7,7 @@ import { isTable } from "./types";
|
|
|
6
7
|
|
|
7
8
|
export type SerializedRNG = LuaMap<string, unknown> & {
|
|
8
9
|
readonly __serializedRNGBrand: symbol;
|
|
10
|
+
readonly __kind: CopyableIsaacAPIClassType.RNG;
|
|
9
11
|
};
|
|
10
12
|
|
|
11
13
|
/**
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import { CopyableIsaacAPIClassType } from "
|
|
1
|
+
import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
|
|
2
2
|
import { ISAAC_API_CLASS_TYPE_TO_BRAND } from "../objects/isaacAPIClassTypeToBrand";
|
|
3
|
-
import {
|
|
4
|
-
|
|
3
|
+
import {
|
|
4
|
+
CopyableIsaacAPIClass,
|
|
5
|
+
IsaacAPIClassTypeFunctions,
|
|
6
|
+
IsaacAPIClassTypeToSerializedType,
|
|
7
|
+
IsaacAPIClassTypeToType,
|
|
8
|
+
ISAAC_API_CLASS_TYPE_TO_FUNCTIONS,
|
|
9
|
+
SerializedIsaacAPIClass,
|
|
10
|
+
} from "../objects/isaacAPIClassTypeToFunctions";
|
|
5
11
|
import { getIsaacAPIClassName } from "./isaacAPIClass";
|
|
6
12
|
import { isTable, isUserdata } from "./types";
|
|
7
13
|
|
|
@@ -11,7 +17,9 @@ import { isTable, isUserdata } from "./types";
|
|
|
11
17
|
*
|
|
12
18
|
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
13
19
|
*/
|
|
14
|
-
export function copyIsaacAPIClass
|
|
20
|
+
export function copyIsaacAPIClass<T extends CopyableIsaacAPIClass>(
|
|
21
|
+
isaacAPIClass: T,
|
|
22
|
+
): T {
|
|
15
23
|
if (!isUserdata(isaacAPIClass)) {
|
|
16
24
|
error(
|
|
17
25
|
`Failed to copy an Isaac API class since the provided object was of type: ${typeof isaacAPIClass}`,
|
|
@@ -27,9 +35,19 @@ export function copyIsaacAPIClass(isaacAPIClass: unknown): unknown {
|
|
|
27
35
|
|
|
28
36
|
const copyableIsaacAPIClassType =
|
|
29
37
|
isaacAPIClassType as CopyableIsaacAPIClassType;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
38
|
+
|
|
39
|
+
type ThisIsaacAPIClassType = T;
|
|
40
|
+
type ThisSerializedIsaacAPIClassType =
|
|
41
|
+
IsaacAPIClassTypeToSerializedType[T["__kind"]];
|
|
42
|
+
|
|
43
|
+
const functions = ISAAC_API_CLASS_TYPE_TO_FUNCTIONS[
|
|
44
|
+
copyableIsaacAPIClassType
|
|
45
|
+
] as unknown as
|
|
46
|
+
| IsaacAPIClassTypeFunctions<
|
|
47
|
+
ThisIsaacAPIClassType,
|
|
48
|
+
ThisSerializedIsaacAPIClassType
|
|
49
|
+
>
|
|
50
|
+
| undefined;
|
|
33
51
|
if (functions === undefined) {
|
|
34
52
|
error(
|
|
35
53
|
`Failed to copy an Isaac API class since the associated functions were not found for Isaac API class type: ${copyableIsaacAPIClassType}`,
|
|
@@ -46,9 +64,11 @@ export function copyIsaacAPIClass(isaacAPIClass: unknown): unknown {
|
|
|
46
64
|
*
|
|
47
65
|
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
48
66
|
*/
|
|
49
|
-
export function deserializeIsaacAPIClass
|
|
50
|
-
|
|
51
|
-
|
|
67
|
+
export function deserializeIsaacAPIClass<
|
|
68
|
+
SerializedT extends SerializedIsaacAPIClass,
|
|
69
|
+
>(
|
|
70
|
+
serializedIsaacAPIClass: SerializedT,
|
|
71
|
+
): IsaacAPIClassTypeToType[SerializedT["__kind"]] {
|
|
52
72
|
if (!isTable(serializedIsaacAPIClass)) {
|
|
53
73
|
error(
|
|
54
74
|
`Failed to deserialize an Isaac API class since the provided object was of type: ${typeof serializedIsaacAPIClass}`,
|
|
@@ -64,9 +84,17 @@ export function deserializeIsaacAPIClass(
|
|
|
64
84
|
);
|
|
65
85
|
}
|
|
66
86
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
87
|
+
type ThisIsaacAPIClassType = IsaacAPIClassTypeToType[SerializedT["__kind"]];
|
|
88
|
+
type ThisSerializedIsaacAPIClassType = SerializedT;
|
|
89
|
+
|
|
90
|
+
const functions = ISAAC_API_CLASS_TYPE_TO_FUNCTIONS[
|
|
91
|
+
copyableIsaacAPIClassType
|
|
92
|
+
] as unknown as
|
|
93
|
+
| IsaacAPIClassTypeFunctions<
|
|
94
|
+
ThisIsaacAPIClassType,
|
|
95
|
+
ThisSerializedIsaacAPIClassType
|
|
96
|
+
>
|
|
97
|
+
| undefined;
|
|
70
98
|
if (functions === undefined) {
|
|
71
99
|
error(
|
|
72
100
|
`Failed to deserialize an Isaac API class since the associated functions were not found for class type: ${copyableIsaacAPIClassType}`,
|
|
@@ -81,7 +109,7 @@ export function deserializeIsaacAPIClass(
|
|
|
81
109
|
* serialized table for brands.
|
|
82
110
|
*/
|
|
83
111
|
function getSerializedTableType(
|
|
84
|
-
serializedIsaacAPIClass:
|
|
112
|
+
serializedIsaacAPIClass: SerializedIsaacAPIClass,
|
|
85
113
|
): CopyableIsaacAPIClassType | undefined {
|
|
86
114
|
for (const [copyableIsaacAPIClassType, serializationBrand] of Object.entries(
|
|
87
115
|
ISAAC_API_CLASS_TYPE_TO_BRAND,
|
|
@@ -94,6 +122,20 @@ function getSerializedTableType(
|
|
|
94
122
|
return undefined;
|
|
95
123
|
}
|
|
96
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Helper function to generically check if a given object is a copyable Isaac API class. (This is
|
|
127
|
+
* used by the save data manager when determining what is safe to copy.)
|
|
128
|
+
*
|
|
129
|
+
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
130
|
+
*/
|
|
131
|
+
export function isCopyableIsaacAPIClass(
|
|
132
|
+
object: unknown,
|
|
133
|
+
): object is CopyableIsaacAPIClass {
|
|
134
|
+
const allFunctions = Object.values(ISAAC_API_CLASS_TYPE_TO_FUNCTIONS);
|
|
135
|
+
const isFunctions = allFunctions.map((functions) => functions.is);
|
|
136
|
+
return isFunctions.some((identityFunction) => identityFunction(object));
|
|
137
|
+
}
|
|
138
|
+
|
|
97
139
|
/**
|
|
98
140
|
* Helper function to generically check if a given Lua table is a serialized Isaac API class. (This
|
|
99
141
|
* is used by the save data manager when reading data from the "save#.dat" file.)
|
|
@@ -118,7 +160,9 @@ export function isSerializedIsaacAPIClass(
|
|
|
118
160
|
*
|
|
119
161
|
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
120
162
|
*/
|
|
121
|
-
export function serializeIsaacAPIClass
|
|
163
|
+
export function serializeIsaacAPIClass<T extends CopyableIsaacAPIClass>(
|
|
164
|
+
isaacAPIClass: T,
|
|
165
|
+
): IsaacAPIClassTypeToSerializedType[T["__kind"]] {
|
|
122
166
|
if (!isUserdata(isaacAPIClass)) {
|
|
123
167
|
error(
|
|
124
168
|
`Failed to serialize an Isaac API class since the provided object was of type: ${typeof isaacAPIClass}`,
|
|
@@ -134,9 +178,19 @@ export function serializeIsaacAPIClass(isaacAPIClass: unknown): unknown {
|
|
|
134
178
|
|
|
135
179
|
const copyableIsaacAPIClassType =
|
|
136
180
|
isaacAPIClassType as CopyableIsaacAPIClassType;
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
181
|
+
|
|
182
|
+
type ThisIsaacAPIClassType = T;
|
|
183
|
+
type ThisSerializedIsaacAPIClassType =
|
|
184
|
+
IsaacAPIClassTypeToSerializedType[T["__kind"]];
|
|
185
|
+
|
|
186
|
+
const functions = ISAAC_API_CLASS_TYPE_TO_FUNCTIONS[
|
|
187
|
+
copyableIsaacAPIClassType
|
|
188
|
+
] as unknown as
|
|
189
|
+
| IsaacAPIClassTypeFunctions<
|
|
190
|
+
ThisIsaacAPIClassType,
|
|
191
|
+
ThisSerializedIsaacAPIClassType
|
|
192
|
+
>
|
|
193
|
+
| undefined;
|
|
140
194
|
if (functions === undefined) {
|
|
141
195
|
error(
|
|
142
196
|
`Failed to serialize an Isaac API class since the associated functions were not found for class type: ${copyableIsaacAPIClassType}`,
|
package/src/functions/vector.ts
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
CopyableIsaacAPIClassType,
|
|
3
|
+
Direction,
|
|
4
|
+
} from "isaac-typescript-definitions";
|
|
2
5
|
import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
3
6
|
import { angleToDirection } from "./direction";
|
|
4
7
|
import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
|
|
@@ -13,6 +16,7 @@ import { isTable } from "./types";
|
|
|
13
16
|
|
|
14
17
|
export type SerializedVector = LuaMap<string, unknown> & {
|
|
15
18
|
readonly __serializedVectorBrand: symbol;
|
|
19
|
+
readonly __kind: CopyableIsaacAPIClassType.VECTOR;
|
|
16
20
|
};
|
|
17
21
|
|
|
18
22
|
const OBJECT_NAME = "Vector";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { WeightedArray } from "../types/WeightedArray";
|
|
2
|
+
import { arrayToString, sumArray } from "./array";
|
|
3
|
+
import { getRandomFloat } from "./random";
|
|
4
|
+
import { getRandomSeed } from "./rng";
|
|
5
|
+
|
|
6
|
+
/** Get a random value from a `WeightedArray`. (The second element in the array is the weight.) */
|
|
7
|
+
export function getRandomFromWeightedArray<T>(
|
|
8
|
+
weightedArray: WeightedArray<T>,
|
|
9
|
+
seedOrRNG: Seed | RNG = getRandomSeed(),
|
|
10
|
+
): T {
|
|
11
|
+
if (weightedArray.length === 0) {
|
|
12
|
+
error(
|
|
13
|
+
"Failed to get a random element from a weighted array since the provided array was empty.",
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const weights = weightedArray.map((tuple) => tuple[1]);
|
|
18
|
+
const totalWeight = sumArray(weights);
|
|
19
|
+
const randomWeight = getRandomFloat(0, totalWeight, seedOrRNG);
|
|
20
|
+
|
|
21
|
+
let weightAccumulator = 0;
|
|
22
|
+
for (const tuple of weightedArray) {
|
|
23
|
+
const [element, weight] = tuple;
|
|
24
|
+
|
|
25
|
+
weightAccumulator += weight;
|
|
26
|
+
if (weightAccumulator >= randomWeight) {
|
|
27
|
+
return element;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
error(
|
|
32
|
+
`Failed to get a random element from a weighted array: ${arrayToString(
|
|
33
|
+
weightedArray,
|
|
34
|
+
)}`,
|
|
35
|
+
);
|
|
36
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -149,6 +149,7 @@ export * from "./functions/types";
|
|
|
149
149
|
export * from "./functions/ui";
|
|
150
150
|
export * from "./functions/utils";
|
|
151
151
|
export * from "./functions/vector";
|
|
152
|
+
export * from "./functions/weighted";
|
|
152
153
|
export * from "./interfaces/ChargeBarSprites";
|
|
153
154
|
export * from "./interfaces/Corner";
|
|
154
155
|
export * from "./interfaces/CustomStageTSConfig";
|
|
@@ -174,5 +175,5 @@ export * from "./types/PickingUpItem";
|
|
|
174
175
|
export * from "./types/PickupIndex";
|
|
175
176
|
export * from "./types/PlayerIndex";
|
|
176
177
|
export * from "./types/PossibleStatType";
|
|
177
|
-
export * from "./types/SerializedIsaacAPIClass";
|
|
178
178
|
export * from "./types/TSTLClass";
|
|
179
|
+
export * from "./types/WeightedArray";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* eslint-disable max-classes-per-file */
|
|
2
2
|
|
|
3
|
+
import { CopyableIsaacAPIClass } from "../objects/isaacAPIClassTypeToFunctions";
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* This is the format of the object that you give to the save data manager. It will contains all of
|
|
5
7
|
* the variables for the particular mod feature.
|
|
@@ -45,7 +47,7 @@ type Serializable<T> =
|
|
|
45
47
|
T extends SerializablePrimitive
|
|
46
48
|
? T
|
|
47
49
|
: // Allow a specific subset of Isaac API classes that are copyable / serializable.
|
|
48
|
-
T extends
|
|
50
|
+
T extends CopyableIsaacAPIClass
|
|
49
51
|
? T
|
|
50
52
|
: // Disallow all other Isaac API classes.
|
|
51
53
|
T extends IsaacAPIClass
|
|
@@ -77,7 +79,7 @@ type SerializableInsideArrayOrMap<T> =
|
|
|
77
79
|
T extends SerializablePrimitive
|
|
78
80
|
? T
|
|
79
81
|
: // Allow a specific subset of Isaac API classes that are copyable / serializable.
|
|
80
|
-
T extends
|
|
82
|
+
T extends CopyableIsaacAPIClass
|
|
81
83
|
? T
|
|
82
84
|
: // Disallow all other Isaac API classes.
|
|
83
85
|
T extends IsaacAPIClass
|
|
@@ -125,7 +127,6 @@ type SerializableReadonlyMap<K, V> = ReadonlyMap<
|
|
|
125
127
|
type SerializableSet<T> = Set<SerializableInsideArrayOrMap<T>>;
|
|
126
128
|
type SerializableReadonlySet<T> = ReadonlySet<SerializableInsideArrayOrMap<T>>;
|
|
127
129
|
type SerializableObject<T> = { [K in keyof T]: Serializable<T[K]> };
|
|
128
|
-
type SerializableIsaacAPIClass = BitSet128 | Color | KColor | RNG | Vector;
|
|
129
130
|
|
|
130
131
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
131
132
|
type HasMethods<T> = {} extends {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CopyableIsaacAPIClassType } from "
|
|
1
|
+
import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
|
|
2
2
|
import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
3
3
|
|
|
4
4
|
export const ISAAC_API_CLASS_TYPE_TO_BRAND: {
|
|
@@ -1,72 +1,121 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
1
|
+
import { CopyableIsaacAPIClassType } from "isaac-typescript-definitions";
|
|
4
2
|
import {
|
|
5
3
|
copyBitSet128,
|
|
6
4
|
deserializeBitSet128,
|
|
5
|
+
isBitSet128,
|
|
7
6
|
isSerializedBitSet128,
|
|
8
7
|
serializeBitSet128,
|
|
8
|
+
SerializedBitSet128,
|
|
9
9
|
} from "../functions/bitSet128";
|
|
10
10
|
import {
|
|
11
11
|
copyColor,
|
|
12
12
|
deserializeColor,
|
|
13
|
+
isColor,
|
|
13
14
|
isSerializedColor,
|
|
14
15
|
serializeColor,
|
|
16
|
+
SerializedColor,
|
|
15
17
|
} from "../functions/color";
|
|
16
18
|
import {
|
|
17
19
|
copyKColor,
|
|
18
20
|
deserializeKColor,
|
|
21
|
+
isKColor,
|
|
19
22
|
isSerializedKColor,
|
|
23
|
+
SerializedKColor,
|
|
20
24
|
serializeKColor,
|
|
21
25
|
} from "../functions/kColor";
|
|
22
26
|
import {
|
|
23
27
|
copyRNG,
|
|
24
28
|
deserializeRNG,
|
|
29
|
+
isRNG,
|
|
25
30
|
isSerializedRNG,
|
|
31
|
+
SerializedRNG,
|
|
26
32
|
serializeRNG,
|
|
27
33
|
} from "../functions/rng";
|
|
28
34
|
import {
|
|
29
35
|
copyVector,
|
|
30
36
|
deserializeVector,
|
|
31
37
|
isSerializedVector,
|
|
38
|
+
isVector,
|
|
39
|
+
SerializedVector,
|
|
32
40
|
serializeVector,
|
|
33
41
|
} from "../functions/vector";
|
|
34
42
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
43
|
+
/** A type representing an Isaac API class that can be safely copied or serialized. */
|
|
44
|
+
export type CopyableIsaacAPIClass = BitSet128 | Color | KColor | RNG | Vector;
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* A type representing an Isaac API class like `Color` or `RNG` that has been written to the
|
|
48
|
+
* "save#.dat" file. It is used by the save data manager when reading and writing to that file.
|
|
49
|
+
*
|
|
50
|
+
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
51
|
+
*/
|
|
52
|
+
export type SerializedIsaacAPIClass =
|
|
53
|
+
| SerializedBitSet128
|
|
54
|
+
| SerializedColor
|
|
55
|
+
| SerializedKColor
|
|
56
|
+
| SerializedRNG
|
|
57
|
+
| SerializedVector;
|
|
58
|
+
|
|
59
|
+
export interface IsaacAPIClassTypeToType {
|
|
60
|
+
[CopyableIsaacAPIClassType.BIT_SET_128]: BitSet128;
|
|
61
|
+
[CopyableIsaacAPIClassType.COLOR]: Color;
|
|
62
|
+
[CopyableIsaacAPIClassType.K_COLOR]: KColor;
|
|
63
|
+
[CopyableIsaacAPIClassType.RNG]: RNG;
|
|
64
|
+
[CopyableIsaacAPIClassType.VECTOR]: Vector;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export interface IsaacAPIClassTypeToSerializedType {
|
|
68
|
+
[CopyableIsaacAPIClassType.BIT_SET_128]: SerializedBitSet128;
|
|
69
|
+
[CopyableIsaacAPIClassType.COLOR]: SerializedColor;
|
|
70
|
+
[CopyableIsaacAPIClassType.K_COLOR]: SerializedKColor;
|
|
71
|
+
[CopyableIsaacAPIClassType.RNG]: SerializedRNG;
|
|
72
|
+
[CopyableIsaacAPIClassType.VECTOR]: SerializedVector;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface IsaacAPIClassTypeFunctions<T, SerializedT> {
|
|
76
|
+
is: (object: unknown) => object is T;
|
|
77
|
+
isSerialized: (object: unknown) => object is SerializedT;
|
|
78
|
+
copy: (object: T) => T;
|
|
79
|
+
serialize: (object: T) => SerializedT;
|
|
80
|
+
deserialize: (object: SerializedT) => T;
|
|
40
81
|
}
|
|
41
82
|
|
|
42
83
|
export const ISAAC_API_CLASS_TYPE_TO_FUNCTIONS: {
|
|
43
|
-
readonly [key in CopyableIsaacAPIClassType]: IsaacAPIClassTypeFunctions
|
|
84
|
+
readonly [key in CopyableIsaacAPIClassType]: IsaacAPIClassTypeFunctions<
|
|
85
|
+
IsaacAPIClassTypeToType[key],
|
|
86
|
+
IsaacAPIClassTypeToSerializedType[key]
|
|
87
|
+
>;
|
|
44
88
|
} = {
|
|
45
89
|
[CopyableIsaacAPIClassType.BIT_SET_128]: {
|
|
90
|
+
is: isBitSet128,
|
|
46
91
|
isSerialized: isSerializedBitSet128,
|
|
47
92
|
copy: copyBitSet128,
|
|
48
93
|
serialize: serializeBitSet128,
|
|
49
94
|
deserialize: deserializeBitSet128,
|
|
50
95
|
},
|
|
51
96
|
[CopyableIsaacAPIClassType.COLOR]: {
|
|
97
|
+
is: isColor,
|
|
52
98
|
isSerialized: isSerializedColor,
|
|
53
99
|
copy: copyColor,
|
|
54
100
|
serialize: serializeColor,
|
|
55
101
|
deserialize: deserializeColor,
|
|
56
102
|
},
|
|
57
103
|
[CopyableIsaacAPIClassType.K_COLOR]: {
|
|
104
|
+
is: isKColor,
|
|
58
105
|
isSerialized: isSerializedKColor,
|
|
59
106
|
copy: copyKColor,
|
|
60
107
|
serialize: serializeKColor,
|
|
61
108
|
deserialize: deserializeKColor,
|
|
62
109
|
},
|
|
63
110
|
[CopyableIsaacAPIClassType.RNG]: {
|
|
111
|
+
is: isRNG,
|
|
64
112
|
isSerialized: isSerializedRNG,
|
|
65
113
|
copy: copyRNG,
|
|
66
114
|
serialize: serializeRNG,
|
|
67
115
|
deserialize: deserializeRNG,
|
|
68
116
|
},
|
|
69
117
|
[CopyableIsaacAPIClassType.VECTOR]: {
|
|
118
|
+
is: isVector,
|
|
70
119
|
isSerialized: isSerializedVector,
|
|
71
120
|
copy: copyVector,
|
|
72
121
|
serialize: serializeVector,
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* - This must match the JSDoc comments for `deepCopy` and `merge`.
|
|
3
|
-
* - This must match the `SerializableIsaacAPIClass` type union.
|
|
4
|
-
*/
|
|
5
|
-
export declare enum CopyableIsaacAPIClassType {
|
|
6
|
-
BIT_SET_128 = "BitSet128",
|
|
7
|
-
COLOR = "Color",
|
|
8
|
-
K_COLOR = "KColor",
|
|
9
|
-
RNG = "RNG",
|
|
10
|
-
VECTOR = "Vector"
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=CopyableIsaacAPIClassType.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CopyableIsaacAPIClassType.d.ts","sourceRoot":"","sources":["../../../../src/enums/private/CopyableIsaacAPIClassType.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,yBAAyB;IACnC,WAAW,cAAc;IACzB,KAAK,UAAU;IACf,OAAO,WAAW;IAClB,GAAG,QAAQ;IACX,MAAM,WAAW;CAClB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
local ____exports = {}
|
|
2
|
-
--- - This must match the JSDoc comments for `deepCopy` and `merge`.
|
|
3
|
-
-- - This must match the `SerializableIsaacAPIClass` type union.
|
|
4
|
-
____exports.CopyableIsaacAPIClassType = {}
|
|
5
|
-
____exports.CopyableIsaacAPIClassType.BIT_SET_128 = "BitSet128"
|
|
6
|
-
____exports.CopyableIsaacAPIClassType.COLOR = "Color"
|
|
7
|
-
____exports.CopyableIsaacAPIClassType.K_COLOR = "KColor"
|
|
8
|
-
____exports.CopyableIsaacAPIClassType.RNG = "RNG"
|
|
9
|
-
____exports.CopyableIsaacAPIClassType.VECTOR = "Vector"
|
|
10
|
-
return ____exports
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/// <reference types="@typescript-to-lua/language-extensions" />
|
|
2
|
-
/**
|
|
3
|
-
* This is a type representing an Isaac API class like `Color` or `RNG` that has been written to the
|
|
4
|
-
* "save#.dat" file. It is used by the save data manager when reading and writing to that file.
|
|
5
|
-
*
|
|
6
|
-
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
7
|
-
*/
|
|
8
|
-
export declare type SerializedIsaacAPIClass = LuaMap<string, unknown> & {
|
|
9
|
-
readonly __serializedIsaacAPIClassBrand: symbol;
|
|
10
|
-
};
|
|
11
|
-
//# sourceMappingURL=SerializedIsaacAPIClass.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SerializedIsaacAPIClass.d.ts","sourceRoot":"","sources":["../../../src/types/SerializedIsaacAPIClass.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;AACH,oBAAY,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC9D,QAAQ,CAAC,8BAA8B,EAAE,MAAM,CAAC;CACjD,CAAC"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* - This must match the JSDoc comments for `deepCopy` and `merge`.
|
|
3
|
-
* - This must match the `SerializableIsaacAPIClass` type union.
|
|
4
|
-
*/
|
|
5
|
-
export enum CopyableIsaacAPIClassType {
|
|
6
|
-
BIT_SET_128 = "BitSet128",
|
|
7
|
-
COLOR = "Color",
|
|
8
|
-
K_COLOR = "KColor",
|
|
9
|
-
RNG = "RNG",
|
|
10
|
-
VECTOR = "Vector",
|
|
11
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This is a type representing an Isaac API class like `Color` or `RNG` that has been written to the
|
|
3
|
-
* "save#.dat" file. It is used by the save data manager when reading and writing to that file.
|
|
4
|
-
*
|
|
5
|
-
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
6
|
-
*/
|
|
7
|
-
export type SerializedIsaacAPIClass = LuaMap<string, unknown> & {
|
|
8
|
-
readonly __serializedIsaacAPIClassBrand: symbol;
|
|
9
|
-
};
|