isaacscript-common 6.15.0 → 6.16.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/callbacks/postGridEntityCustomCollision.d.ts +2 -0
- package/dist/callbacks/postGridEntityCustomCollision.d.ts.map +1 -0
- package/dist/callbacks/postGridEntityCustomCollision.lua +71 -0
- package/dist/callbacks/postGridEntityCustomRender.lua +0 -7
- package/dist/callbacks/postGridEntityCustomUpdate.lua +0 -7
- package/dist/callbacks/subscriptions/postGridEntityCustomBroken.d.ts +6 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomBroken.d.ts.map +1 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomBroken.lua +24 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomCollision.d.ts +6 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomCollision.d.ts.map +1 -0
- package/dist/callbacks/subscriptions/postGridEntityCustomCollision.lua +29 -0
- package/dist/enums/ModCallbackCustom.d.ts +96 -62
- package/dist/enums/ModCallbackCustom.d.ts.map +1 -1
- package/dist/enums/ModCallbackCustom.lua +64 -60
- package/dist/features/customGridEntity.d.ts +5 -1
- package/dist/features/customGridEntity.d.ts.map +1 -1
- package/dist/features/customGridEntity.lua +65 -5
- package/dist/functions/color.d.ts +11 -15
- package/dist/functions/color.d.ts.map +1 -1
- package/dist/functions/color.lua +55 -74
- package/dist/functions/deepCopy.d.ts.map +1 -1
- package/dist/functions/deepCopy.lua +22 -1
- package/dist/functions/gridEntities.d.ts +0 -16
- package/dist/functions/gridEntities.d.ts.map +1 -1
- package/dist/functions/gridEntities.lua +0 -19
- package/dist/functions/isaacAPIClass.d.ts +1 -1
- package/dist/functions/isaacAPIClass.d.ts.map +1 -1
- package/dist/functions/kColor.d.ts +11 -15
- package/dist/functions/kColor.d.ts.map +1 -1
- package/dist/functions/kColor.lua +42 -61
- package/dist/functions/mergeTests.lua +2 -2
- package/dist/functions/npcs.d.ts +1 -29
- package/dist/functions/npcs.d.ts.map +1 -1
- package/dist/functions/npcs.lua +0 -45
- package/dist/functions/projectiles.d.ts +32 -0
- package/dist/functions/projectiles.d.ts.map +1 -0
- package/dist/functions/projectiles.lua +73 -0
- package/dist/functions/rng.d.ts +11 -15
- package/dist/functions/rng.d.ts.map +1 -1
- package/dist/functions/rng.lua +32 -52
- package/dist/functions/rockAlt.d.ts +27 -3
- package/dist/functions/rockAlt.d.ts.map +1 -1
- package/dist/functions/rockAlt.lua +113 -33
- package/dist/functions/saveFile.d.ts.map +1 -1
- package/dist/functions/saveFile.lua +3 -1
- package/dist/functions/serialization.d.ts +26 -7
- package/dist/functions/serialization.d.ts.map +1 -1
- package/dist/functions/serialization.lua +51 -19
- package/dist/functions/table.d.ts +2 -2
- package/dist/functions/table.lua +2 -2
- package/dist/functions/tstlClass.d.ts +1 -1
- package/dist/functions/tstlClass.d.ts.map +1 -1
- package/dist/functions/vector.d.ts +11 -15
- package/dist/functions/vector.d.ts.map +1 -1
- package/dist/functions/vector.lua +36 -55
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.lua +8 -0
- package/dist/initCustomCallbacks.d.ts.map +1 -1
- package/dist/initCustomCallbacks.lua +3 -0
- package/dist/interfaces/AddCallbackParameterCustom.d.ts +4 -0
- package/dist/interfaces/AddCallbackParameterCustom.d.ts.map +1 -1
- package/dist/objects/callbackRegisterFunctions.d.ts.map +1 -1
- package/dist/objects/callbackRegisterFunctions.lua +6 -0
- package/dist/objects/isaacAPIClassTypeToFunctions.d.ts +12 -0
- package/dist/objects/isaacAPIClassTypeToFunctions.d.ts.map +1 -0
- package/dist/objects/isaacAPIClassTypeToFunctions.lua +25 -0
- package/dist/types/{private/IsaacAPIClass.d.ts → IsaacAPIClass.d.ts} +0 -0
- package/dist/types/IsaacAPIClass.d.ts.map +1 -0
- package/dist/types/{private/IsaacAPIClass.lua → IsaacAPIClass.lua} +0 -0
- package/dist/types/{private/SerializedIsaacAPIClass.d.ts → SerializedIsaacAPIClass.d.ts} +0 -0
- package/dist/types/SerializedIsaacAPIClass.d.ts.map +1 -0
- package/dist/types/{private/SerializedIsaacAPIClass.lua → SerializedIsaacAPIClass.lua} +0 -0
- package/dist/types/{private/TSTLClass.d.ts → TSTLClass.d.ts} +0 -0
- package/dist/types/TSTLClass.d.ts.map +1 -0
- package/dist/types/{private/TSTLClass.lua → TSTLClass.lua} +0 -0
- package/package.json +2 -2
- package/src/callbacks/postGridEntityCustomCollision.ts +74 -0
- package/src/callbacks/postGridEntityCustomRender.ts +1 -17
- package/src/callbacks/postGridEntityCustomUpdate.ts +1 -17
- package/src/callbacks/subscriptions/postGridEntityCustomBroken.ts +36 -0
- package/src/callbacks/subscriptions/postGridEntityCustomCollision.ts +43 -0
- package/src/enums/ModCallbackCustom.ts +38 -2
- package/src/features/customGridEntity.ts +76 -0
- package/src/functions/color.ts +67 -87
- package/src/functions/deepCopy.ts +15 -2
- package/src/functions/gridEntities.ts +0 -23
- package/src/functions/isaacAPIClass.ts +1 -1
- package/src/functions/kColor.ts +65 -84
- package/src/functions/mergeTests.ts +2 -2
- package/src/functions/npcs.ts +1 -58
- package/src/functions/projectiles.ts +78 -0
- package/src/functions/rng.ts +45 -65
- package/src/functions/rockAlt.ts +127 -40
- package/src/functions/saveFile.ts +2 -1
- package/src/functions/serialization.ts +81 -25
- package/src/functions/table.ts +2 -2
- package/src/functions/tstlClass.ts +1 -1
- package/src/functions/vector.ts +55 -74
- package/src/index.ts +1 -0
- package/src/initCustomCallbacks.ts +2 -0
- package/src/interfaces/AddCallbackParameterCustom.ts +4 -0
- package/src/objects/callbackRegisterFunctions.ts +6 -0
- package/src/objects/isaacAPIClassTypeToFunctions.ts +63 -0
- package/src/types/{private/IsaacAPIClass.ts → IsaacAPIClass.ts} +0 -0
- package/src/types/{private/SerializedIsaacAPIClass.ts → SerializedIsaacAPIClass.ts} +0 -0
- package/src/types/{private/TSTLClass.ts → TSTLClass.ts} +0 -0
- package/dist/objects/isaacAPIClassTypeToCopyFunction.d.ts +0 -6
- package/dist/objects/isaacAPIClassTypeToCopyFunction.d.ts.map +0 -1
- package/dist/objects/isaacAPIClassTypeToCopyFunction.lua +0 -13
- package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.d.ts +0 -5
- package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.d.ts.map +0 -1
- package/dist/objects/serializedIsaacAPIClassTypeToIdentityFunction.lua +0 -13
- package/dist/types/private/IsaacAPIClass.d.ts.map +0 -1
- package/dist/types/private/SerializedIsaacAPIClass.d.ts.map +0 -1
- package/dist/types/private/TSTLClass.d.ts.map +0 -1
- package/src/objects/isaacAPIClassTypeToCopyFunction.ts +0 -18
- package/src/objects/serializedIsaacAPIClassTypeToIdentityFunction.ts +0 -14
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
2
|
-
import { SerializationType } from "../enums/SerializationType";
|
|
3
2
|
import { ISAAC_API_CLASS_TYPE_TO_BRAND } from "../objects/isaacAPIClassTypeToBrand";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { SerializedIsaacAPIClass } from "../types/private/SerializedIsaacAPIClass";
|
|
3
|
+
import { ISAAC_API_CLASS_TYPE_TO_FUNCTIONS } from "../objects/isaacAPIClassTypeToFunctions";
|
|
4
|
+
import { SerializedIsaacAPIClass } from "../types/SerializedIsaacAPIClass";
|
|
7
5
|
import { getIsaacAPIClassName } from "./isaacAPIClass";
|
|
8
6
|
import { isTable, isUserdata } from "./types";
|
|
9
7
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Helper function to generically copy an Isaac API class without knowing what specific type of
|
|
10
|
+
* class it is. (This is used by the save data manager.)
|
|
11
|
+
*
|
|
12
|
+
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
13
|
+
*/
|
|
14
|
+
export function copyIsaacAPIClass(isaacAPIClass: unknown): unknown {
|
|
14
15
|
if (!isUserdata(isaacAPIClass)) {
|
|
15
16
|
error(
|
|
16
17
|
`Failed to copy an Isaac API class since the provided object was of type: ${typeof isaacAPIClass}`,
|
|
@@ -26,26 +27,27 @@ export function copyIsaacAPIClass(
|
|
|
26
27
|
|
|
27
28
|
const copyableIsaacAPIClassType =
|
|
28
29
|
isaacAPIClassType as CopyableIsaacAPIClassType;
|
|
29
|
-
const
|
|
30
|
-
|
|
30
|
+
const functions =
|
|
31
|
+
ISAAC_API_CLASS_TYPE_TO_FUNCTIONS[copyableIsaacAPIClassType];
|
|
31
32
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
32
|
-
if (
|
|
33
|
+
if (functions === undefined) {
|
|
33
34
|
error(
|
|
34
|
-
`Failed to copy Isaac API class
|
|
35
|
+
`Failed to copy an Isaac API class since the associated functions were not found for Isaac API class type: ${copyableIsaacAPIClassType}`,
|
|
35
36
|
);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
return
|
|
39
|
+
return functions.copy(isaacAPIClass);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
|
-
*
|
|
43
|
+
* Helper function to generically deserialize an Isaac API class without knowing what specific type
|
|
44
|
+
* of class it is. (This is used by the save data manager when reading data from the "save#.dat"
|
|
45
|
+
* file.)
|
|
43
46
|
*
|
|
44
|
-
*
|
|
45
|
-
* "copyIsaacAPIClass" function can handle all serialization types.
|
|
47
|
+
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
46
48
|
*/
|
|
47
49
|
export function deserializeIsaacAPIClass(
|
|
48
|
-
serializedIsaacAPIClass:
|
|
50
|
+
serializedIsaacAPIClass: unknown,
|
|
49
51
|
): unknown {
|
|
50
52
|
if (!isTable(serializedIsaacAPIClass)) {
|
|
51
53
|
error(
|
|
@@ -58,17 +60,28 @@ export function deserializeIsaacAPIClass(
|
|
|
58
60
|
);
|
|
59
61
|
if (copyableIsaacAPIClassType === undefined) {
|
|
60
62
|
error(
|
|
61
|
-
"Failed to deserialize an API class since a valid class type brand was not found.",
|
|
63
|
+
"Failed to deserialize an Isaac API class since a valid class type brand was not found.",
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const functions =
|
|
68
|
+
ISAAC_API_CLASS_TYPE_TO_FUNCTIONS[copyableIsaacAPIClassType];
|
|
69
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
70
|
+
if (functions === undefined) {
|
|
71
|
+
error(
|
|
72
|
+
`Failed to deserialize an Isaac API class since the associated functions were not found for class type: ${copyableIsaacAPIClassType}`,
|
|
62
73
|
);
|
|
63
74
|
}
|
|
64
75
|
|
|
65
|
-
|
|
66
|
-
ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION[copyableIsaacAPIClassType];
|
|
67
|
-
return copyFunction(serializedIsaacAPIClass, SerializationType.DESERIALIZE);
|
|
76
|
+
return functions.deserialize(serializedIsaacAPIClass);
|
|
68
77
|
}
|
|
69
78
|
|
|
79
|
+
/**
|
|
80
|
+
* In order to find out what type of serialized Isaac API class this is, we search through the
|
|
81
|
+
* serialized table for brands.
|
|
82
|
+
*/
|
|
70
83
|
function getSerializedTableType(
|
|
71
|
-
serializedIsaacAPIClass:
|
|
84
|
+
serializedIsaacAPIClass: LuaMap<AnyNotNil, unknown>,
|
|
72
85
|
): CopyableIsaacAPIClassType | undefined {
|
|
73
86
|
for (const [copyableIsaacAPIClassType, serializationBrand] of Object.entries(
|
|
74
87
|
ISAAC_API_CLASS_TYPE_TO_BRAND,
|
|
@@ -81,11 +94,54 @@ function getSerializedTableType(
|
|
|
81
94
|
return undefined;
|
|
82
95
|
}
|
|
83
96
|
|
|
97
|
+
/**
|
|
98
|
+
* Helper function to generically check if a given Lua table is a serialized Isaac API class. (This
|
|
99
|
+
* is used by the save data manager when reading data from the "save#.dat" file.)
|
|
100
|
+
*
|
|
101
|
+
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
102
|
+
*/
|
|
84
103
|
export function isSerializedIsaacAPIClass(
|
|
85
104
|
object: unknown,
|
|
86
105
|
): object is SerializedIsaacAPIClass {
|
|
87
|
-
const
|
|
88
|
-
|
|
106
|
+
const allFunctions = Object.values(ISAAC_API_CLASS_TYPE_TO_FUNCTIONS);
|
|
107
|
+
const isSerializedFunctions = allFunctions.map(
|
|
108
|
+
(functions) => functions.isSerialized,
|
|
109
|
+
);
|
|
110
|
+
return isSerializedFunctions.some((identityFunction) =>
|
|
111
|
+
identityFunction(object),
|
|
89
112
|
);
|
|
90
|
-
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Helper function to generically serialize an Isaac API class without knowing what specific type of
|
|
117
|
+
* class it is. (This is used by the save data manager when writing data to the "save#.dat" file.)
|
|
118
|
+
*
|
|
119
|
+
* For the list of supported classes, see the `CopyableIsaacAPIClassType` enum.
|
|
120
|
+
*/
|
|
121
|
+
export function serializeIsaacAPIClass(isaacAPIClass: unknown): unknown {
|
|
122
|
+
if (!isUserdata(isaacAPIClass)) {
|
|
123
|
+
error(
|
|
124
|
+
`Failed to serialize an Isaac API class since the provided object was of type: ${typeof isaacAPIClass}`,
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
const isaacAPIClassType = getIsaacAPIClassName(isaacAPIClass);
|
|
129
|
+
if (isaacAPIClassType === undefined) {
|
|
130
|
+
error(
|
|
131
|
+
"Failed to serialize an Isaac API class since it does not have a class type.",
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const copyableIsaacAPIClassType =
|
|
136
|
+
isaacAPIClassType as CopyableIsaacAPIClassType;
|
|
137
|
+
const functions =
|
|
138
|
+
ISAAC_API_CLASS_TYPE_TO_FUNCTIONS[copyableIsaacAPIClassType];
|
|
139
|
+
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
140
|
+
if (functions === undefined) {
|
|
141
|
+
error(
|
|
142
|
+
`Failed to serialize an Isaac API class since the associated functions were not found for class type: ${copyableIsaacAPIClassType}`,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
return functions.serialize(isaacAPIClass);
|
|
91
147
|
}
|
package/src/functions/table.ts
CHANGED
|
@@ -57,8 +57,8 @@ export function getBooleansFromTable(
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
/**
|
|
60
|
-
* Helper function to safely get number values from a Lua table. Will throw an
|
|
61
|
-
* value does not exist on the table or if it cannot be converted to a number.
|
|
60
|
+
* Helper function to safely get number values from specific keys on a Lua table. Will throw an
|
|
61
|
+
* error if the specific value does not exist on the table or if it cannot be converted to a number.
|
|
62
62
|
*
|
|
63
63
|
* This function is variadic, meaning that you can specify N arguments to get N values.
|
|
64
64
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DefaultMap } from "../classes/DefaultMap";
|
|
2
2
|
import { TSTLClassMetatable } from "../interfaces/private/TSTLClassMetatable";
|
|
3
|
-
import { TSTLClass } from "../types/
|
|
3
|
+
import { TSTLClass } from "../types/TSTLClass";
|
|
4
4
|
import { isString, isTable } from "./types";
|
|
5
5
|
|
|
6
6
|
const VANILLA_TSTL_CLASSES = new Set(["Map", "Set", "WeakMap", "WeakSet"]);
|
package/src/functions/vector.ts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { Direction } from "isaac-typescript-definitions";
|
|
2
2
|
import { SerializationBrand } from "../enums/private/SerializationBrand";
|
|
3
|
-
import { SerializationType } from "../enums/SerializationType";
|
|
4
3
|
import { angleToDirection } from "./direction";
|
|
5
4
|
import { isaacAPIClassEquals, isIsaacAPIClassOfType } from "./isaacAPIClass";
|
|
6
5
|
import { getRandomFloat } from "./random";
|
|
@@ -8,88 +7,53 @@ import { getRandomSeed, isRNG, newRNG } from "./rng";
|
|
|
8
7
|
import { copyValuesToTable, getNumbersFromTable, tableHasKeys } from "./table";
|
|
9
8
|
import { isTable } from "./types";
|
|
10
9
|
|
|
11
|
-
type SerializedVector = LuaMap<string, unknown> & {
|
|
10
|
+
export type SerializedVector = LuaMap<string, unknown> & {
|
|
12
11
|
readonly __serializedVectorBrand: symbol;
|
|
13
12
|
};
|
|
14
13
|
|
|
15
|
-
interface CopyVectorReturn {
|
|
16
|
-
[SerializationType.NONE]: Vector;
|
|
17
|
-
[SerializationType.SERIALIZE]: SerializedVector;
|
|
18
|
-
[SerializationType.DESERIALIZE]: Vector;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
14
|
const KEYS = ["X", "Y"];
|
|
22
15
|
const OBJECT_NAME = "Vector";
|
|
23
16
|
|
|
17
|
+
/** Helper function to copy a `Vector` Isaac API class. */
|
|
18
|
+
export function copyVector(vector: Vector): Vector {
|
|
19
|
+
if (!isVector(vector)) {
|
|
20
|
+
error(
|
|
21
|
+
`Failed to copy a ${OBJECT_NAME} object since the provided object was not a userdata ${OBJECT_NAME} class.`,
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return Vector(vector.X, vector.Y);
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
/**
|
|
25
|
-
* Helper function to
|
|
26
|
-
*
|
|
27
|
-
* @param vector The vector to copy. In the case of deserialization, this will actually be a Lua
|
|
28
|
-
* table instead of an instantiated Vector class.
|
|
29
|
-
* @param serializationType Default is `SerializationType.NONE`.
|
|
29
|
+
* Helper function to convert a `SerializedVector` object to a normal `RNG` object. (This is used by
|
|
30
|
+
* the save data manager when reading data from the "save#.dat" file.)
|
|
30
31
|
*/
|
|
31
|
-
export function
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return Vector(vector.X, vector.Y);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
case SerializationType.SERIALIZE: {
|
|
54
|
-
if (!isVector(vector)) {
|
|
55
|
-
error(
|
|
56
|
-
`Failed to serialize a ${OBJECT_NAME} object since the provided object was not a userdata ${OBJECT_NAME} class.`,
|
|
57
|
-
);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
const vectorTable = new LuaMap<string, unknown>();
|
|
61
|
-
copyValuesToTable(vector, KEYS, vectorTable);
|
|
62
|
-
vectorTable.set(SerializationBrand.VECTOR, "");
|
|
63
|
-
return vectorTable as SerializedVector;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
case SerializationType.DESERIALIZE: {
|
|
67
|
-
if (!isTable(vector)) {
|
|
68
|
-
error(
|
|
69
|
-
`Failed to deserialize a ${OBJECT_NAME} object since the provided object was not a Lua table.`,
|
|
70
|
-
);
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const [x, y] = getNumbersFromTable(
|
|
74
|
-
vector as LuaMap<string, unknown>,
|
|
75
|
-
OBJECT_NAME,
|
|
76
|
-
...KEYS,
|
|
77
|
-
);
|
|
78
|
-
|
|
79
|
-
if (x === undefined) {
|
|
80
|
-
error(
|
|
81
|
-
`Failed to deserialize a ${OBJECT_NAME} object since the provided object did not have a value for: x`,
|
|
82
|
-
);
|
|
83
|
-
}
|
|
84
|
-
if (y === undefined) {
|
|
85
|
-
error(
|
|
86
|
-
`Failed to deserialize a ${OBJECT_NAME} object since the provided object did not have a value for: y`,
|
|
87
|
-
);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return Vector(x, y);
|
|
91
|
-
}
|
|
32
|
+
export function deserializeVector(vector: SerializedVector): Vector {
|
|
33
|
+
if (!isTable(vector)) {
|
|
34
|
+
error(
|
|
35
|
+
`Failed to deserialize a ${OBJECT_NAME} object since the provided object was not a Lua table.`,
|
|
36
|
+
);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const [x, y] = getNumbersFromTable(
|
|
40
|
+
vector as LuaMap<string, unknown>,
|
|
41
|
+
OBJECT_NAME,
|
|
42
|
+
...KEYS,
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
if (x === undefined) {
|
|
46
|
+
error(
|
|
47
|
+
`Failed to deserialize a ${OBJECT_NAME} object since the provided object did not have a value for: X`,
|
|
48
|
+
);
|
|
92
49
|
}
|
|
50
|
+
if (y === undefined) {
|
|
51
|
+
error(
|
|
52
|
+
`Failed to deserialize a ${OBJECT_NAME} object since the provided object did not have a value for: Y`,
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return Vector(x, y);
|
|
93
57
|
}
|
|
94
58
|
|
|
95
59
|
/**
|
|
@@ -132,6 +96,23 @@ export function isVector(object: unknown): object is Vector {
|
|
|
132
96
|
return isIsaacAPIClassOfType(object, OBJECT_NAME);
|
|
133
97
|
}
|
|
134
98
|
|
|
99
|
+
/**
|
|
100
|
+
* Helper function to convert a `Vector` object to a `SerializedVector` object. (This is used by the
|
|
101
|
+
* save data manager when writing data from the "save#.dat" file.)
|
|
102
|
+
*/
|
|
103
|
+
export function serializeVector(vector: Vector): SerializedVector {
|
|
104
|
+
if (!isVector(vector)) {
|
|
105
|
+
error(
|
|
106
|
+
`Failed to serialize a ${OBJECT_NAME} object since the provided object was not a userdata ${OBJECT_NAME} class.`,
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const vectorTable = new LuaMap<string, unknown>();
|
|
111
|
+
copyValuesToTable(vector, KEYS, vectorTable);
|
|
112
|
+
vectorTable.set(SerializationBrand.VECTOR, "");
|
|
113
|
+
return vectorTable as SerializedVector;
|
|
114
|
+
}
|
|
115
|
+
|
|
135
116
|
export function vectorEquals(vector1: Vector, vector2: Vector): boolean {
|
|
136
117
|
return isaacAPIClassEquals(vector1, vector2, KEYS);
|
|
137
118
|
}
|
package/src/index.ts
CHANGED
|
@@ -142,6 +142,7 @@ export * from "./functions/players";
|
|
|
142
142
|
export * from "./functions/pocketItems";
|
|
143
143
|
export * from "./functions/positionVelocity";
|
|
144
144
|
export * from "./functions/pressurePlate";
|
|
145
|
+
export * from "./functions/projectiles";
|
|
145
146
|
export * from "./functions/random";
|
|
146
147
|
export * from "./functions/revive";
|
|
147
148
|
export * from "./functions/rng";
|
|
@@ -20,6 +20,7 @@ import { postFlipCallbacksInit } from "./callbacks/postFlip";
|
|
|
20
20
|
import { postGreedModeWaveInit } from "./callbacks/postGreedModeWave";
|
|
21
21
|
import { postGridEntityCallbacksInit } from "./callbacks/postGridEntity";
|
|
22
22
|
import { postGridEntityCollisionInit } from "./callbacks/postGridEntityCollision";
|
|
23
|
+
import { postGridEntityCustomCollisionInit } from "./callbacks/postGridEntityCustomCollision";
|
|
23
24
|
import { postGridEntityCustomRenderInit } from "./callbacks/postGridEntityCustomRender";
|
|
24
25
|
import { postGridEntityCustomUpdateInit } from "./callbacks/postGridEntityCustomUpdate";
|
|
25
26
|
import { postGridEntityRenderInit } from "./callbacks/postGridEntityRender";
|
|
@@ -91,6 +92,7 @@ export function initCustomCallbacks(mod: ModUpgraded): void {
|
|
|
91
92
|
postGreedModeWaveInit(mod);
|
|
92
93
|
postGridEntityCallbacksInit(mod);
|
|
93
94
|
postGridEntityCollisionInit(mod);
|
|
95
|
+
postGridEntityCustomCollisionInit(mod);
|
|
94
96
|
postGridEntityCustomRenderInit(mod);
|
|
95
97
|
postGridEntityCustomUpdateInit(mod);
|
|
96
98
|
postGridEntityRenderInit(mod);
|
|
@@ -23,6 +23,8 @@ import { PostGameStartedReorderedRegisterParameters } from "../callbacks/subscri
|
|
|
23
23
|
import { PostGreedModeWaveRegisterParameters } from "../callbacks/subscriptions/postGreedModeWave";
|
|
24
24
|
import { PostGridEntityBrokenRegisterParameters } from "../callbacks/subscriptions/postGridEntityBroken";
|
|
25
25
|
import { PostGridEntityCollisionRegisterParameters } from "../callbacks/subscriptions/postGridEntityCollision";
|
|
26
|
+
import { PostGridEntityCustomBrokenRegisterParameters } from "../callbacks/subscriptions/postGridEntityCustomBroken";
|
|
27
|
+
import { PostGridEntityCustomCollisionRegisterParameters } from "../callbacks/subscriptions/postGridEntityCustomCollision";
|
|
26
28
|
import { PostGridEntityCustomRenderRegisterParameters } from "../callbacks/subscriptions/postGridEntityCustomRender";
|
|
27
29
|
import { PostGridEntityCustomUpdateRegisterParameters } from "../callbacks/subscriptions/postGridEntityCustomUpdate";
|
|
28
30
|
import { PostGridEntityInitRegisterParameters } from "../callbacks/subscriptions/postGridEntityInit";
|
|
@@ -111,6 +113,8 @@ export interface AddCallbackParameterCustom {
|
|
|
111
113
|
[ModCallbackCustom.POST_GREED_MODE_WAVE]: PostGreedModeWaveRegisterParameters;
|
|
112
114
|
[ModCallbackCustom.POST_GRID_ENTITY_BROKEN]: PostGridEntityBrokenRegisterParameters;
|
|
113
115
|
[ModCallbackCustom.POST_GRID_ENTITY_COLLISION]: PostGridEntityCollisionRegisterParameters;
|
|
116
|
+
[ModCallbackCustom.POST_GRID_ENTITY_CUSTOM_BROKEN]: PostGridEntityCustomBrokenRegisterParameters;
|
|
117
|
+
[ModCallbackCustom.POST_GRID_ENTITY_CUSTOM_COLLISION]: PostGridEntityCustomCollisionRegisterParameters;
|
|
114
118
|
[ModCallbackCustom.POST_GRID_ENTITY_CUSTOM_RENDER]: PostGridEntityCustomRenderRegisterParameters;
|
|
115
119
|
[ModCallbackCustom.POST_GRID_ENTITY_CUSTOM_UPDATE]: PostGridEntityCustomUpdateRegisterParameters;
|
|
116
120
|
[ModCallbackCustom.POST_GRID_ENTITY_INIT]: PostGridEntityInitRegisterParameters;
|
|
@@ -23,6 +23,8 @@ import { postGameStartedReorderedRegister } from "../callbacks/subscriptions/pos
|
|
|
23
23
|
import { postGreedModeWaveRegister } from "../callbacks/subscriptions/postGreedModeWave";
|
|
24
24
|
import { postGridEntityBrokenRegister } from "../callbacks/subscriptions/postGridEntityBroken";
|
|
25
25
|
import { postGridEntityCollisionRegister } from "../callbacks/subscriptions/postGridEntityCollision";
|
|
26
|
+
import { postGridEntityCustomBrokenRegister } from "../callbacks/subscriptions/postGridEntityCustomBroken";
|
|
27
|
+
import { postGridEntityCustomCollisionRegister } from "../callbacks/subscriptions/postGridEntityCustomCollision";
|
|
26
28
|
import { postGridEntityCustomRenderRegister } from "../callbacks/subscriptions/postGridEntityCustomRender";
|
|
27
29
|
import { postGridEntityCustomUpdateRegister } from "../callbacks/subscriptions/postGridEntityCustomUpdate";
|
|
28
30
|
import { postGridEntityInitRegister } from "../callbacks/subscriptions/postGridEntityInit";
|
|
@@ -120,6 +122,10 @@ export const CALLBACK_REGISTER_FUNCTIONS: {
|
|
|
120
122
|
[ModCallbackCustom.POST_GRID_ENTITY_BROKEN]: postGridEntityBrokenRegister,
|
|
121
123
|
[ModCallbackCustom.POST_GRID_ENTITY_COLLISION]:
|
|
122
124
|
postGridEntityCollisionRegister,
|
|
125
|
+
[ModCallbackCustom.POST_GRID_ENTITY_CUSTOM_BROKEN]:
|
|
126
|
+
postGridEntityCustomBrokenRegister,
|
|
127
|
+
[ModCallbackCustom.POST_GRID_ENTITY_CUSTOM_COLLISION]:
|
|
128
|
+
postGridEntityCustomCollisionRegister,
|
|
123
129
|
[ModCallbackCustom.POST_GRID_ENTITY_CUSTOM_RENDER]:
|
|
124
130
|
postGridEntityCustomRenderRegister,
|
|
125
131
|
[ModCallbackCustom.POST_GRID_ENTITY_CUSTOM_UPDATE]:
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
2
|
+
|
|
3
|
+
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
4
|
+
import {
|
|
5
|
+
copyColor,
|
|
6
|
+
deserializeColor,
|
|
7
|
+
isSerializedColor,
|
|
8
|
+
serializeColor,
|
|
9
|
+
} from "../functions/color";
|
|
10
|
+
import {
|
|
11
|
+
copyKColor,
|
|
12
|
+
deserializeKColor,
|
|
13
|
+
isSerializedKColor,
|
|
14
|
+
serializeKColor,
|
|
15
|
+
} from "../functions/kColor";
|
|
16
|
+
import {
|
|
17
|
+
copyRNG,
|
|
18
|
+
deserializeRNG,
|
|
19
|
+
isSerializedRNG,
|
|
20
|
+
serializeRNG,
|
|
21
|
+
} from "../functions/rng";
|
|
22
|
+
import {
|
|
23
|
+
copyVector,
|
|
24
|
+
deserializeVector,
|
|
25
|
+
isSerializedVector,
|
|
26
|
+
serializeVector,
|
|
27
|
+
} from "../functions/vector";
|
|
28
|
+
|
|
29
|
+
interface IsaacAPIClassTypeFunctions {
|
|
30
|
+
isSerialized: (object: unknown) => object is unknown;
|
|
31
|
+
copy: (object: any) => any;
|
|
32
|
+
serialize: (object: any) => any;
|
|
33
|
+
deserialize: (object: any) => any;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export const ISAAC_API_CLASS_TYPE_TO_FUNCTIONS: {
|
|
37
|
+
readonly [key in CopyableIsaacAPIClassType]: IsaacAPIClassTypeFunctions;
|
|
38
|
+
} = {
|
|
39
|
+
[CopyableIsaacAPIClassType.COLOR]: {
|
|
40
|
+
isSerialized: isSerializedColor,
|
|
41
|
+
copy: copyColor,
|
|
42
|
+
serialize: serializeColor,
|
|
43
|
+
deserialize: deserializeColor,
|
|
44
|
+
},
|
|
45
|
+
[CopyableIsaacAPIClassType.K_COLOR]: {
|
|
46
|
+
isSerialized: isSerializedKColor,
|
|
47
|
+
copy: copyKColor,
|
|
48
|
+
serialize: serializeKColor,
|
|
49
|
+
deserialize: deserializeKColor,
|
|
50
|
+
},
|
|
51
|
+
[CopyableIsaacAPIClassType.RNG]: {
|
|
52
|
+
isSerialized: isSerializedRNG,
|
|
53
|
+
copy: copyRNG,
|
|
54
|
+
serialize: serializeRNG,
|
|
55
|
+
deserialize: deserializeRNG,
|
|
56
|
+
},
|
|
57
|
+
[CopyableIsaacAPIClassType.VECTOR]: {
|
|
58
|
+
isSerialized: isSerializedVector,
|
|
59
|
+
copy: copyVector,
|
|
60
|
+
serialize: serializeVector,
|
|
61
|
+
deserialize: deserializeVector,
|
|
62
|
+
},
|
|
63
|
+
} as const;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
2
|
-
import { SerializationType } from "../enums/SerializationType";
|
|
3
|
-
export declare const ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION: {
|
|
4
|
-
readonly [key in CopyableIsaacAPIClassType]: (object: unknown, serializationType: SerializationType) => boolean;
|
|
5
|
-
};
|
|
6
|
-
//# sourceMappingURL=isaacAPIClassTypeToCopyFunction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isaacAPIClassTypeToCopyFunction.d.ts","sourceRoot":"","sources":["../../src/objects/isaacAPIClassTypeToCopyFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AACvF,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAM/D,eAAO,MAAM,qCAAqC,EAAE;IAClD,QAAQ,EAAE,GAAG,IAAI,yBAAyB,GAAG,CAC3C,MAAM,EAAE,OAAO,EACf,iBAAiB,EAAE,iBAAiB,KACjC,OAAO;CAMJ,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
local ____exports = {}
|
|
2
|
-
local ____CopyableIsaacAPIClassType = require("enums.private.CopyableIsaacAPIClassType")
|
|
3
|
-
local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
|
|
4
|
-
local ____color = require("functions.color")
|
|
5
|
-
local copyColor = ____color.copyColor
|
|
6
|
-
local ____kColor = require("functions.kColor")
|
|
7
|
-
local copyKColor = ____kColor.copyKColor
|
|
8
|
-
local ____rng = require("functions.rng")
|
|
9
|
-
local copyRNG = ____rng.copyRNG
|
|
10
|
-
local ____vector = require("functions.vector")
|
|
11
|
-
local copyVector = ____vector.copyVector
|
|
12
|
-
____exports.ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION = {[CopyableIsaacAPIClassType.COLOR] = copyColor, [CopyableIsaacAPIClassType.K_COLOR] = copyKColor, [CopyableIsaacAPIClassType.RNG] = copyRNG, [CopyableIsaacAPIClassType.VECTOR] = copyVector}
|
|
13
|
-
return ____exports
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
2
|
-
export declare const SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION: {
|
|
3
|
-
readonly [key in CopyableIsaacAPIClassType]: (object: unknown) => boolean;
|
|
4
|
-
};
|
|
5
|
-
//# sourceMappingURL=serializedIsaacAPIClassTypeToIdentityFunction.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"serializedIsaacAPIClassTypeToIdentityFunction.d.ts","sourceRoot":"","sources":["../../src/objects/serializedIsaacAPIClassTypeToIdentityFunction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAC;AAMvF,eAAO,MAAM,oDAAoD,EAAE;IACjE,QAAQ,EAAE,GAAG,IAAI,yBAAyB,GAAG,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO;CAMjE,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
local ____exports = {}
|
|
2
|
-
local ____CopyableIsaacAPIClassType = require("enums.private.CopyableIsaacAPIClassType")
|
|
3
|
-
local CopyableIsaacAPIClassType = ____CopyableIsaacAPIClassType.CopyableIsaacAPIClassType
|
|
4
|
-
local ____color = require("functions.color")
|
|
5
|
-
local isSerializedColor = ____color.isSerializedColor
|
|
6
|
-
local ____kColor = require("functions.kColor")
|
|
7
|
-
local isSerializedKColor = ____kColor.isSerializedKColor
|
|
8
|
-
local ____rng = require("functions.rng")
|
|
9
|
-
local isSerializedRNG = ____rng.isSerializedRNG
|
|
10
|
-
local ____vector = require("functions.vector")
|
|
11
|
-
local isSerializedVector = ____vector.isSerializedVector
|
|
12
|
-
____exports.SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION = {[CopyableIsaacAPIClassType.COLOR] = isSerializedColor, [CopyableIsaacAPIClassType.K_COLOR] = isSerializedKColor, [CopyableIsaacAPIClassType.RNG] = isSerializedRNG, [CopyableIsaacAPIClassType.VECTOR] = isSerializedVector}
|
|
13
|
-
return ____exports
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"IsaacAPIClass.d.ts","sourceRoot":"","sources":["../../../src/types/private/IsaacAPIClass.ts"],"names":[],"mappings":";AAAA,oBAAY,aAAa,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IACpD,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;CACvC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SerializedIsaacAPIClass.d.ts","sourceRoot":"","sources":["../../../src/types/private/SerializedIsaacAPIClass.ts"],"names":[],"mappings":";AAAA,oBAAY,uBAAuB,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG;IAC9D,QAAQ,CAAC,8BAA8B,EAAE,MAAM,CAAC;CACjD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TSTLClass.d.ts","sourceRoot":"","sources":["../../../src/types/private/TSTLClass.ts"],"names":[],"mappings":";AAAA,oBAAY,SAAS,GAAG,MAAM,CAAC,SAAS,EAAE,OAAO,CAAC,GAAG;IACnD,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAC;CACnC,CAAC"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
2
|
-
import { SerializationType } from "../enums/SerializationType";
|
|
3
|
-
import { copyColor } from "../functions/color";
|
|
4
|
-
import { copyKColor } from "../functions/kColor";
|
|
5
|
-
import { copyRNG } from "../functions/rng";
|
|
6
|
-
import { copyVector } from "../functions/vector";
|
|
7
|
-
|
|
8
|
-
export const ISAAC_API_CLASS_TYPE_TO_COPY_FUNCTION: {
|
|
9
|
-
readonly [key in CopyableIsaacAPIClassType]: (
|
|
10
|
-
object: unknown,
|
|
11
|
-
serializationType: SerializationType,
|
|
12
|
-
) => boolean;
|
|
13
|
-
} = {
|
|
14
|
-
[CopyableIsaacAPIClassType.COLOR]: copyColor,
|
|
15
|
-
[CopyableIsaacAPIClassType.K_COLOR]: copyKColor,
|
|
16
|
-
[CopyableIsaacAPIClassType.RNG]: copyRNG,
|
|
17
|
-
[CopyableIsaacAPIClassType.VECTOR]: copyVector,
|
|
18
|
-
} as const;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { CopyableIsaacAPIClassType } from "../enums/private/CopyableIsaacAPIClassType";
|
|
2
|
-
import { isSerializedColor } from "../functions/color";
|
|
3
|
-
import { isSerializedKColor } from "../functions/kColor";
|
|
4
|
-
import { isSerializedRNG } from "../functions/rng";
|
|
5
|
-
import { isSerializedVector } from "../functions/vector";
|
|
6
|
-
|
|
7
|
-
export const SERIALIZED_ISAAC_API_CLASS_TYPE_TO_IDENTITY_FUNCTION: {
|
|
8
|
-
readonly [key in CopyableIsaacAPIClassType]: (object: unknown) => boolean;
|
|
9
|
-
} = {
|
|
10
|
-
[CopyableIsaacAPIClassType.COLOR]: isSerializedColor,
|
|
11
|
-
[CopyableIsaacAPIClassType.K_COLOR]: isSerializedKColor,
|
|
12
|
-
[CopyableIsaacAPIClassType.RNG]: isSerializedRNG,
|
|
13
|
-
[CopyableIsaacAPIClassType.VECTOR]: isSerializedVector,
|
|
14
|
-
} as const;
|