rw-parser-ng 2.1.0 → 2.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +252 -52
- package/lib/codecs/bitmap.d.ts +6 -0
- package/lib/codecs/bitmap.js +77 -0
- package/lib/codecs/color.d.ts +6 -0
- package/lib/codecs/color.js +43 -0
- package/lib/codecs/dxt.d.ts +3 -0
- package/lib/codecs/dxt.js +212 -0
- package/lib/codecs/formats.d.ts +25 -0
- package/lib/codecs/formats.js +32 -0
- package/lib/codecs/index.d.ts +5 -0
- package/lib/codecs/index.js +21 -0
- package/lib/codecs/palette.d.ts +6 -0
- package/lib/codecs/palette.js +86 -0
- package/lib/common/types.d.ts +50 -0
- package/lib/common/types.js +2 -0
- package/lib/core/byte-stream.d.ts +20 -0
- package/lib/core/byte-stream.js +71 -0
- package/lib/core/errors.d.ts +5 -0
- package/lib/core/errors.js +34 -0
- package/lib/core/index.d.ts +5 -0
- package/lib/core/index.js +21 -0
- package/lib/core/rw-file.d.ts +9 -0
- package/lib/core/rw-file.js +36 -0
- package/lib/core/rw-sections.d.ts +24 -0
- package/lib/core/rw-sections.js +28 -0
- package/lib/core/rw-version.d.ts +3 -0
- package/lib/core/rw-version.js +27 -0
- package/lib/dff/dff-model-type.d.ts +5 -0
- package/lib/dff/dff-model-type.js +9 -0
- package/lib/dff/index.d.ts +4 -0
- package/lib/dff/index.js +20 -0
- package/lib/dff/parser.d.ts +5 -0
- package/lib/dff/parser.js +154 -0
- package/lib/dff/readers/2d-effect.d.ts +3 -0
- package/lib/dff/readers/2d-effect.js +211 -0
- package/lib/dff/readers/geometry.d.ts +4 -0
- package/lib/dff/readers/geometry.js +229 -0
- package/lib/dff/readers/index.d.ts +5 -0
- package/lib/dff/readers/index.js +21 -0
- package/lib/dff/readers/material.d.ts +5 -0
- package/lib/dff/readers/material.js +72 -0
- package/lib/dff/readers/mesh.d.ts +5 -0
- package/lib/dff/readers/mesh.js +84 -0
- package/lib/dff/readers/structure.d.ts +6 -0
- package/lib/dff/readers/structure.js +67 -0
- package/lib/dff/types.d.ts +237 -0
- package/lib/dff/types.js +44 -0
- package/lib/fxp/index.d.ts +2 -0
- package/lib/fxp/index.js +18 -0
- package/lib/fxp/info-parser.d.ts +2 -0
- package/lib/fxp/info-parser.js +169 -0
- package/lib/fxp/parser.d.ts +3 -0
- package/lib/fxp/parser.js +285 -0
- package/lib/fxp/types/common.d.ts +36 -0
- package/lib/fxp/types/common.js +2 -0
- package/lib/fxp/types/index.d.ts +3 -0
- package/lib/fxp/types/index.js +19 -0
- package/lib/fxp/types/info.d.ts +186 -0
- package/lib/fxp/types/info.js +2 -0
- package/lib/fxp/types/system.d.ts +27 -0
- package/lib/fxp/types/system.js +2 -0
- package/lib/ifp/index.d.ts +4 -0
- package/lib/ifp/index.js +20 -0
- package/lib/ifp/parser.d.ts +5 -0
- package/lib/ifp/parser.js +38 -0
- package/lib/ifp/readers/anp3.d.ts +3 -0
- package/lib/ifp/readers/anp3.js +56 -0
- package/lib/ifp/readers/anpk.d.ts +3 -0
- package/lib/ifp/readers/anpk.js +86 -0
- package/lib/ifp/types.d.ts +28 -0
- package/lib/ifp/types.js +9 -0
- package/lib/index.d.ts +6 -9
- package/lib/index.js +6 -13
- package/lib/renderware/fxp/FxpData.d.ts +246 -0
- package/lib/renderware/fxp/FxpData.js +2 -0
- package/lib/renderware/fxp/FxpParser.d.ts +3 -0
- package/lib/renderware/fxp/FxpParser.js +512 -0
- package/lib/renderware/fxp/index.d.ts +2 -0
- package/lib/renderware/fxp/index.js +18 -0
- package/lib/renderware/txd/TxdParser.js +3 -2
- package/lib/txd/bitmap-decoder.d.ts +3 -0
- package/lib/txd/bitmap-decoder.js +57 -0
- package/lib/txd/index.d.ts +3 -0
- package/lib/txd/index.js +19 -0
- package/lib/txd/parser.d.ts +8 -0
- package/lib/txd/parser.js +122 -0
- package/lib/txd/types.d.ts +27 -0
- package/lib/txd/types.js +2 -0
- package/package.json +16 -9
- package/src/codecs/bitmap.ts +75 -0
- package/src/codecs/color.ts +40 -0
- package/src/codecs/dxt.ts +243 -0
- package/src/codecs/formats.ts +28 -0
- package/src/codecs/index.ts +5 -0
- package/src/codecs/palette.ts +106 -0
- package/src/common/types.ts +59 -0
- package/src/core/byte-stream.ts +87 -0
- package/src/core/errors.ts +7 -0
- package/src/core/index.ts +5 -0
- package/src/core/rw-file.ts +23 -0
- package/src/core/rw-sections.ts +24 -0
- package/src/core/rw-version.ts +24 -0
- package/src/dff/dff-model-type.ts +5 -0
- package/src/dff/index.ts +4 -0
- package/src/dff/parser.ts +142 -0
- package/src/dff/readers/2d-effect.ts +265 -0
- package/src/dff/readers/geometry.ts +264 -0
- package/src/dff/readers/index.ts +5 -0
- package/src/dff/readers/material.ts +89 -0
- package/src/dff/readers/mesh.ts +93 -0
- package/src/dff/readers/structure.ts +79 -0
- package/src/dff/types.ts +278 -0
- package/src/fxp/index.ts +2 -0
- package/src/fxp/info-parser.ts +166 -0
- package/src/fxp/parser.ts +323 -0
- package/src/fxp/types/common.ts +23 -0
- package/src/fxp/types/index.ts +3 -0
- package/src/fxp/types/info.ts +251 -0
- package/src/fxp/types/system.ts +30 -0
- package/src/ifp/index.ts +4 -0
- package/src/ifp/parser.ts +16 -0
- package/src/ifp/readers/anp3.ts +75 -0
- package/src/ifp/readers/anpk.ts +110 -0
- package/src/ifp/types.ts +33 -0
- package/src/index.ts +6 -12
- package/src/txd/bitmap-decoder.ts +73 -0
- package/src/txd/index.ts +3 -0
- package/src/txd/parser.ts +148 -0
- package/src/txd/types.ts +29 -0
- package/src/renderware/RwFile.ts +0 -26
- package/src/renderware/RwSections.ts +0 -27
- package/src/renderware/common/types.ts +0 -59
- package/src/renderware/dff/DffModelType.ts +0 -5
- package/src/renderware/dff/DffParser.ts +0 -611
- package/src/renderware/errors/RwParseError.ts +0 -11
- package/src/renderware/ifp/IfpData.ts +0 -33
- package/src/renderware/ifp/IfpParser.ts +0 -203
- package/src/renderware/txd/TxdParser.ts +0 -234
- package/src/renderware/utils/ImageDecoder.ts +0 -571
- package/src/renderware/utils/ImageFormatEnums.ts +0 -28
- package/src/renderware/utils/RwVersion.ts +0 -28
- package/src/utils/ByteStream.ts +0 -80
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { RwFile } from "../../core/rw-file";
|
|
2
|
+
import type { RwAnimNode, RwAtomic, RwBone, RwClump, RwFrame, RwFrameList } from "../types";
|
|
3
|
+
|
|
4
|
+
export function readClump(file: RwFile): RwClump {
|
|
5
|
+
const { versionNumber } = file.readSectionHeader();
|
|
6
|
+
const atomicCount = file.readUint32();
|
|
7
|
+
|
|
8
|
+
let lightCount: number | undefined;
|
|
9
|
+
let cameraCount: number | undefined;
|
|
10
|
+
|
|
11
|
+
if (versionNumber > 0x33000) {
|
|
12
|
+
lightCount = file.readUint32();
|
|
13
|
+
cameraCount = file.readUint32();
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return { atomicCount, lightCount, cameraCount };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function readFrameList(file: RwFile): RwFrameList {
|
|
20
|
+
file.readSectionHeader();
|
|
21
|
+
const frameCount = file.readUint32();
|
|
22
|
+
const frames: RwFrame[] = [];
|
|
23
|
+
|
|
24
|
+
for (let i = 0; i < frameCount; i++) {
|
|
25
|
+
const rotationMatrix = {
|
|
26
|
+
right: {
|
|
27
|
+
x: file.readFloat(),
|
|
28
|
+
y: file.readFloat(),
|
|
29
|
+
z: file.readFloat(),
|
|
30
|
+
},
|
|
31
|
+
up: { x: file.readFloat(), y: file.readFloat(), z: file.readFloat() },
|
|
32
|
+
at: { x: file.readFloat(), y: file.readFloat(), z: file.readFloat() },
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const coordinatesOffset = {
|
|
36
|
+
x: file.readFloat(),
|
|
37
|
+
y: file.readFloat(),
|
|
38
|
+
z: file.readFloat(),
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const parentFrame = file.readInt32();
|
|
42
|
+
file.skip(4);
|
|
43
|
+
|
|
44
|
+
frames.push({ rotationMatrix, coordinatesOffset, parentFrame });
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return { frameCount, frames };
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function readAnimNode(file: RwFile): RwAnimNode {
|
|
51
|
+
file.skip(4);
|
|
52
|
+
const boneId = file.readInt32();
|
|
53
|
+
const boneCount = file.readInt32();
|
|
54
|
+
const bones: RwBone[] = [];
|
|
55
|
+
|
|
56
|
+
if (boneCount > 0) {
|
|
57
|
+
file.skip(8);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
for (let i = 0; i < boneCount; i++) {
|
|
61
|
+
bones.push({
|
|
62
|
+
boneId: file.readInt32(),
|
|
63
|
+
boneIndex: file.readInt32(),
|
|
64
|
+
flags: file.readInt32(),
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return { boneId, bonesCount: boneCount, bones };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export function readAtomic(file: RwFile): RwAtomic {
|
|
72
|
+
file.readSectionHeader();
|
|
73
|
+
const frameIndex = file.readUint32();
|
|
74
|
+
const geometryIndex = file.readUint32();
|
|
75
|
+
const flags = file.readUint32();
|
|
76
|
+
file.skip(4);
|
|
77
|
+
|
|
78
|
+
return { frameIndex, geometryIndex, flags };
|
|
79
|
+
}
|
package/src/dff/types.ts
ADDED
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
RwColor,
|
|
3
|
+
RwMatrix3,
|
|
4
|
+
RwMatrix4,
|
|
5
|
+
RwSphere,
|
|
6
|
+
RwTextureCoordinate,
|
|
7
|
+
RwTriangle,
|
|
8
|
+
RwVector2,
|
|
9
|
+
RwVector3,
|
|
10
|
+
} from "../common/types";
|
|
11
|
+
import type { DffModelType } from "./dff-model-type";
|
|
12
|
+
|
|
13
|
+
export interface RwDff {
|
|
14
|
+
modelType: DffModelType;
|
|
15
|
+
version: string;
|
|
16
|
+
versionNumber: number;
|
|
17
|
+
geometryList: RwGeometryList | null;
|
|
18
|
+
frameList: RwFrameList | null;
|
|
19
|
+
atomics: number[];
|
|
20
|
+
dummies: string[];
|
|
21
|
+
animNodes: RwAnimNode[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface RwClump {
|
|
25
|
+
atomicCount: number;
|
|
26
|
+
lightCount?: number;
|
|
27
|
+
cameraCount?: number;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface RwAnimNode {
|
|
31
|
+
boneId: number;
|
|
32
|
+
bonesCount: number;
|
|
33
|
+
bones: RwBone[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface RwBone {
|
|
37
|
+
boneId: number;
|
|
38
|
+
boneIndex: number;
|
|
39
|
+
flags: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface RwFrame {
|
|
43
|
+
rotationMatrix: RwMatrix3;
|
|
44
|
+
coordinatesOffset: RwVector3;
|
|
45
|
+
parentFrame: number;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface RwFrameList {
|
|
49
|
+
frameCount: number;
|
|
50
|
+
frames: RwFrame[];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface RwTexture {
|
|
54
|
+
textureFiltering: number;
|
|
55
|
+
uAddressing: number;
|
|
56
|
+
vAddressing: number;
|
|
57
|
+
usesMipLevels: boolean;
|
|
58
|
+
textureName: string;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export interface RwMaterial {
|
|
62
|
+
color: RwColor;
|
|
63
|
+
isTextured: boolean;
|
|
64
|
+
ambient?: number;
|
|
65
|
+
specular?: number;
|
|
66
|
+
diffuse?: number;
|
|
67
|
+
texture?: RwTexture;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface RwMaterialList {
|
|
71
|
+
materialInstanceCount: number;
|
|
72
|
+
materialData: RwMaterial[];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export interface RwGeometry {
|
|
76
|
+
vertexColorInformation: RwColor[];
|
|
77
|
+
textureCoordinatesCount: number;
|
|
78
|
+
textureMappingInformation: RwTextureCoordinate[][];
|
|
79
|
+
hasVertices: boolean;
|
|
80
|
+
hasNormals: boolean;
|
|
81
|
+
isTriangleStrip: boolean;
|
|
82
|
+
triangleInformation: RwTriangle[];
|
|
83
|
+
vertexInformation: RwVector3[];
|
|
84
|
+
normalInformation: RwVector3[];
|
|
85
|
+
boundingSphere?: RwSphere;
|
|
86
|
+
materialList: RwMaterialList;
|
|
87
|
+
binMesh?: RwBinMesh;
|
|
88
|
+
skin?: RwSkin;
|
|
89
|
+
effects2d?: Rw2dEffect[];
|
|
90
|
+
extraVertColour?: RwColor[];
|
|
91
|
+
breakable?: RwBreakable;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface RwBreakable {
|
|
95
|
+
positionRule: number;
|
|
96
|
+
vertices: RwVector3[];
|
|
97
|
+
texCoords: RwTextureCoordinate[];
|
|
98
|
+
colors: RwColor[];
|
|
99
|
+
triangles: { a: number; b: number; c: number }[];
|
|
100
|
+
triangleMaterialIndices: number[];
|
|
101
|
+
materials: RwBreakableMaterial[];
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export interface RwBreakableMaterial {
|
|
105
|
+
textureName: string;
|
|
106
|
+
maskName: string;
|
|
107
|
+
color: { r: number; g: number; b: number };
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
export interface RwGeometryList {
|
|
111
|
+
geometricObjectCount: number;
|
|
112
|
+
geometries: RwGeometry[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export interface RwAtomic {
|
|
116
|
+
frameIndex: number;
|
|
117
|
+
geometryIndex: number;
|
|
118
|
+
flags: number;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export interface RwBinMesh {
|
|
122
|
+
meshCount: number;
|
|
123
|
+
meshes: RwMesh[];
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export interface RwSkin {
|
|
127
|
+
boneCount: number;
|
|
128
|
+
usedBoneCount: number;
|
|
129
|
+
maxWeightsPerVertex: number;
|
|
130
|
+
boneVertexIndices: number[][];
|
|
131
|
+
vertexWeights: number[][];
|
|
132
|
+
inverseBoneMatrices: RwMatrix4[];
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export interface RwMesh {
|
|
136
|
+
materialIndex: number;
|
|
137
|
+
indexCount: number;
|
|
138
|
+
indices: number[];
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
export enum Rw2dEffectType {
|
|
142
|
+
LIGHT = 0,
|
|
143
|
+
PARTICLE = 1,
|
|
144
|
+
ATTRACTOR = 3,
|
|
145
|
+
SUN_GLARE = 4,
|
|
146
|
+
INTERIOR = 5,
|
|
147
|
+
ENEX = 6,
|
|
148
|
+
ROADSIGN = 7,
|
|
149
|
+
TRIGGER_POINT = 8,
|
|
150
|
+
COVER_POINT = 9,
|
|
151
|
+
ESCALATOR = 10,
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
export enum Rw2dCoronaFlashType {
|
|
155
|
+
DEFAULT = 0,
|
|
156
|
+
RANDOM = 1,
|
|
157
|
+
RANDOM_WHEN_WET = 2,
|
|
158
|
+
ANIM_SPEED_4X = 3,
|
|
159
|
+
ANIM_SPEED_2X = 4,
|
|
160
|
+
ANIM_SPEED_1X = 5,
|
|
161
|
+
TRAFFICLIGHT = 7,
|
|
162
|
+
TRAINCROSSING = 8,
|
|
163
|
+
ONLY_RAIN = 10,
|
|
164
|
+
FIVE_ON_FIVE_OFF = 11,
|
|
165
|
+
SIX_ON_FOUR_OFF = 12,
|
|
166
|
+
FOUR_ON_SIX_OFF = 13,
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
export enum RwPedAttractorType {
|
|
170
|
+
ATM = 0,
|
|
171
|
+
SEAT = 1,
|
|
172
|
+
STOP = 2,
|
|
173
|
+
PIZZA = 3,
|
|
174
|
+
SHELTER = 4,
|
|
175
|
+
TRIGGER_SCRIPT = 5,
|
|
176
|
+
LOOK_AT = 6,
|
|
177
|
+
SCRIPTED = 7,
|
|
178
|
+
PARK = 8,
|
|
179
|
+
STEP = 9,
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
export interface Rw2dEffectLight {
|
|
183
|
+
type: Rw2dEffectType.LIGHT;
|
|
184
|
+
position: RwVector3;
|
|
185
|
+
color: RwColor;
|
|
186
|
+
coronaFarClip: number;
|
|
187
|
+
pointlightRange: number;
|
|
188
|
+
coronaSize: number;
|
|
189
|
+
shadowSize: number;
|
|
190
|
+
coronaShowMode: number;
|
|
191
|
+
coronaEnableReflection: boolean;
|
|
192
|
+
coronaFlareType: number;
|
|
193
|
+
shadowColorMultiplier: number;
|
|
194
|
+
flags1: number;
|
|
195
|
+
coronaTexName: string;
|
|
196
|
+
shadowTexName: string;
|
|
197
|
+
shadowZDistance: number;
|
|
198
|
+
flags2: number;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
export interface Rw2dEffectParticle {
|
|
202
|
+
type: Rw2dEffectType.PARTICLE;
|
|
203
|
+
position: RwVector3;
|
|
204
|
+
effectName: string;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
export interface Rw2dEffectAttractor {
|
|
208
|
+
type: Rw2dEffectType.ATTRACTOR;
|
|
209
|
+
position: RwVector3;
|
|
210
|
+
queueDir: RwVector3;
|
|
211
|
+
useDir: RwVector3;
|
|
212
|
+
forwardDir: RwVector3;
|
|
213
|
+
attractorType: RwPedAttractorType;
|
|
214
|
+
pedExistingProbability: number;
|
|
215
|
+
flags: number;
|
|
216
|
+
scriptName: string;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
export interface Rw2dEffectEnEx {
|
|
220
|
+
type: Rw2dEffectType.ENEX;
|
|
221
|
+
position: RwVector3;
|
|
222
|
+
enterAngle: number;
|
|
223
|
+
radiusX: number;
|
|
224
|
+
radiusY: number;
|
|
225
|
+
exitPos: RwVector3;
|
|
226
|
+
exitAngle: number;
|
|
227
|
+
interiorId: number;
|
|
228
|
+
flags1: number;
|
|
229
|
+
skyColor: number;
|
|
230
|
+
interiorName: string;
|
|
231
|
+
timeOn: number;
|
|
232
|
+
timeOff: number;
|
|
233
|
+
flags2: number;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export interface Rw2dEffectRoadsign {
|
|
237
|
+
type: Rw2dEffectType.ROADSIGN;
|
|
238
|
+
position: RwVector3;
|
|
239
|
+
size: RwVector2;
|
|
240
|
+
rotation: RwVector3;
|
|
241
|
+
flags: number;
|
|
242
|
+
text: string;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export interface Rw2dEffectCoverPoint {
|
|
246
|
+
type: Rw2dEffectType.COVER_POINT;
|
|
247
|
+
position: RwVector3;
|
|
248
|
+
coverDir: RwVector2;
|
|
249
|
+
usage: number;
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
export interface Rw2dEffectEscalator {
|
|
253
|
+
type: Rw2dEffectType.ESCALATOR;
|
|
254
|
+
position: RwVector3;
|
|
255
|
+
bottom: RwVector3;
|
|
256
|
+
top: RwVector3;
|
|
257
|
+
end: RwVector3;
|
|
258
|
+
direction: number;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export interface Rw2dEffectGeneric {
|
|
262
|
+
type:
|
|
263
|
+
| Rw2dEffectType.SUN_GLARE
|
|
264
|
+
| Rw2dEffectType.INTERIOR
|
|
265
|
+
| Rw2dEffectType.TRIGGER_POINT;
|
|
266
|
+
position: RwVector3;
|
|
267
|
+
data: Uint8Array;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
export type Rw2dEffect =
|
|
271
|
+
| Rw2dEffectLight
|
|
272
|
+
| Rw2dEffectParticle
|
|
273
|
+
| Rw2dEffectAttractor
|
|
274
|
+
| Rw2dEffectEnEx
|
|
275
|
+
| Rw2dEffectRoadsign
|
|
276
|
+
| Rw2dEffectCoverPoint
|
|
277
|
+
| Rw2dEffectEscalator
|
|
278
|
+
| Rw2dEffectGeneric;
|
package/src/fxp/index.ts
ADDED
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
import type { FxInfo, FxInterpData } from "./types";
|
|
2
|
+
|
|
3
|
+
const DEFAULT_INTERP: FxInterpData = { looped: false, keys: [] };
|
|
4
|
+
|
|
5
|
+
export function parseInfo(typeKey: string, interps: Record<string, FxInterpData>): FxInfo | null {
|
|
6
|
+
const get = (key: string, ...alt: string[]) =>
|
|
7
|
+
interps[key] ??
|
|
8
|
+
alt.reduce((r, k) => r ?? interps[k], undefined as FxInterpData | undefined) ??
|
|
9
|
+
DEFAULT_INTERP;
|
|
10
|
+
|
|
11
|
+
switch (typeKey) {
|
|
12
|
+
case "underwater":
|
|
13
|
+
case "selflit":
|
|
14
|
+
return { type: typeKey } as FxInfo;
|
|
15
|
+
case "emrate":
|
|
16
|
+
return { type: "emrate", rate: get("RATE") };
|
|
17
|
+
case "emsize":
|
|
18
|
+
return {
|
|
19
|
+
type: "emsize",
|
|
20
|
+
radius: get("RADIUS"),
|
|
21
|
+
sizeMinX: get("SIZEMINX"),
|
|
22
|
+
sizeMaxX: get("SIZEMAXX"),
|
|
23
|
+
sizeMinY: get("SIZEMINY"),
|
|
24
|
+
sizeMaxY: get("SIZEMAXY"),
|
|
25
|
+
sizeMinZ: get("SIZEMINZ"),
|
|
26
|
+
sizeMaxZ: get("SIZEMAXZ"),
|
|
27
|
+
};
|
|
28
|
+
case "emspeed":
|
|
29
|
+
return { type: "emspeed", speed: get("SPEED"), bias: get("BIAS") };
|
|
30
|
+
case "emdir":
|
|
31
|
+
return {
|
|
32
|
+
type: "emdir",
|
|
33
|
+
dirX: get("DIRX"),
|
|
34
|
+
dirY: get("DIRY"),
|
|
35
|
+
dirZ: get("DIRZ"),
|
|
36
|
+
};
|
|
37
|
+
case "emangle":
|
|
38
|
+
return {
|
|
39
|
+
type: "emangle",
|
|
40
|
+
min: get("MIN", "ANGLEMIN"),
|
|
41
|
+
max: get("MAX", "ANGLEMAX"),
|
|
42
|
+
};
|
|
43
|
+
case "emlife":
|
|
44
|
+
return { type: "emlife", life: get("LIFE"), bias: get("BIAS") };
|
|
45
|
+
case "empos":
|
|
46
|
+
return { type: "empos", x: get("X"), y: get("Y"), z: get("Z") };
|
|
47
|
+
case "emweather":
|
|
48
|
+
return { type: "emweather", interp: get("WEATHER") };
|
|
49
|
+
case "emrotation":
|
|
50
|
+
return { type: "emrotation", min: get("ANGLEMIN"), max: get("ANGLEMAX") };
|
|
51
|
+
case "noise":
|
|
52
|
+
return { type: "noise", x: get("NOISE", "X"), y: get("Y"), z: get("Z") };
|
|
53
|
+
case "force":
|
|
54
|
+
return {
|
|
55
|
+
type: "force",
|
|
56
|
+
forceX: get("FORCEX"),
|
|
57
|
+
forceY: get("FORCEY"),
|
|
58
|
+
forceZ: get("FORCEZ"),
|
|
59
|
+
};
|
|
60
|
+
case "friction":
|
|
61
|
+
return { type: "friction", friction: get("FRICTION") };
|
|
62
|
+
case "attractpt":
|
|
63
|
+
return {
|
|
64
|
+
type: "attractpt",
|
|
65
|
+
x: get("X"),
|
|
66
|
+
y: get("Y"),
|
|
67
|
+
z: get("Z"),
|
|
68
|
+
power: get("POWER"),
|
|
69
|
+
};
|
|
70
|
+
case "attractline":
|
|
71
|
+
return {
|
|
72
|
+
type: "attractline",
|
|
73
|
+
x1: get("X1"),
|
|
74
|
+
y1: get("Y1"),
|
|
75
|
+
z1: get("Z1"),
|
|
76
|
+
x2: get("X2"),
|
|
77
|
+
y2: get("Y2"),
|
|
78
|
+
z2: get("Z2"),
|
|
79
|
+
power: get("POWER"),
|
|
80
|
+
};
|
|
81
|
+
case "groundcollide":
|
|
82
|
+
return {
|
|
83
|
+
type: "groundcollide",
|
|
84
|
+
damping: get("DAMPING"),
|
|
85
|
+
bounce: get("BOUNCE"),
|
|
86
|
+
};
|
|
87
|
+
case "wind":
|
|
88
|
+
return { type: "wind", interp: get("WINDFACTOR") };
|
|
89
|
+
case "jitter":
|
|
90
|
+
return { type: "jitter", x: get("X"), y: get("Y"), z: get("Z") };
|
|
91
|
+
case "rotspeed":
|
|
92
|
+
return {
|
|
93
|
+
type: "rotspeed",
|
|
94
|
+
speed: get("SPEED"),
|
|
95
|
+
speedBias: get("SPEEDBIAS"),
|
|
96
|
+
accel: get("ACCEL"),
|
|
97
|
+
accelBias: get("ACCELBIAS"),
|
|
98
|
+
};
|
|
99
|
+
case "float":
|
|
100
|
+
return { type: "float", interp: get("FLOAT") };
|
|
101
|
+
case "colour":
|
|
102
|
+
return {
|
|
103
|
+
type: "colour",
|
|
104
|
+
red: get("RED"),
|
|
105
|
+
green: get("GREEN"),
|
|
106
|
+
blue: get("BLUE"),
|
|
107
|
+
alpha: get("ALPHA"),
|
|
108
|
+
};
|
|
109
|
+
case "size":
|
|
110
|
+
return {
|
|
111
|
+
type: "size",
|
|
112
|
+
sizeX: get("SIZEX"),
|
|
113
|
+
sizeY: get("SIZEY"),
|
|
114
|
+
sizeXBias: get("SIZEXBIAS"),
|
|
115
|
+
sizeYBias: get("SIZEYBIAS"),
|
|
116
|
+
};
|
|
117
|
+
case "spriterect":
|
|
118
|
+
return { type: "spriterect", interps: Object.values(interps) };
|
|
119
|
+
case "heathaze":
|
|
120
|
+
return { type: "heathaze", interps: Object.values(interps) };
|
|
121
|
+
case "trail":
|
|
122
|
+
return { type: "trail", interps: Object.values(interps) };
|
|
123
|
+
case "flat":
|
|
124
|
+
return {
|
|
125
|
+
type: "flat",
|
|
126
|
+
rightX: get("RIGHTX"),
|
|
127
|
+
rightY: get("RIGHTY"),
|
|
128
|
+
rightZ: get("RIGHTZ"),
|
|
129
|
+
upX: get("UPX"),
|
|
130
|
+
upY: get("UPY"),
|
|
131
|
+
upZ: get("UPZ"),
|
|
132
|
+
atX: get("ATX"),
|
|
133
|
+
atY: get("ATY"),
|
|
134
|
+
atZ: get("ATZ"),
|
|
135
|
+
};
|
|
136
|
+
case "dir":
|
|
137
|
+
return { type: "dir", interps: Object.values(interps) };
|
|
138
|
+
case "animtex":
|
|
139
|
+
return { type: "animtex", interps: Object.values(interps) };
|
|
140
|
+
case "colourrange":
|
|
141
|
+
return {
|
|
142
|
+
type: "colourrange",
|
|
143
|
+
redMin: get("REDMIN"),
|
|
144
|
+
redMax: get("REDMAX"),
|
|
145
|
+
greenMin: get("GREENMIN"),
|
|
146
|
+
greenMax: get("GREENMAX"),
|
|
147
|
+
blueMin: get("BLUEMIN"),
|
|
148
|
+
blueMax: get("BLUEMAX"),
|
|
149
|
+
alphaMin: get("ALPHAMIN"),
|
|
150
|
+
alphaMax: get("ALPHAMAX"),
|
|
151
|
+
};
|
|
152
|
+
case "colourbright":
|
|
153
|
+
return {
|
|
154
|
+
type: "colourbright",
|
|
155
|
+
red: get("RED"),
|
|
156
|
+
green: get("GREEN"),
|
|
157
|
+
blue: get("BLUE"),
|
|
158
|
+
alpha: get("ALPHA"),
|
|
159
|
+
brightness: get("BRIGHTNESS", "BIAS"),
|
|
160
|
+
};
|
|
161
|
+
case "smoke":
|
|
162
|
+
return { type: "smoke", interps: Object.values(interps) };
|
|
163
|
+
default:
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
}
|