brs-js 2.0.12 → 2.0.14
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/dist.js +1 -1
- package/dist/dist.js.map +1 -0
- package/dist/dist.node.js +1 -1
- package/dist/dist.node.js.map +1 -0
- package/dist/dist.web.js +1 -1
- package/dist/dist.web.js.map +1 -0
- package/package.json +1 -1
- package/.babelrc +0 -5
- package/.prettierrc +0 -7
- package/debug/Conf Spacestation.brs +0 -0
- package/debug/Electrks_Feminine_Challenge.brs +0 -0
- package/debug/a5bricks.brs +0 -0
- package/debug/a5p2.2.brs +0 -0
- package/debug/a5p2.brs +0 -0
- package/debug/audio.brs +0 -0
- package/debug/brick a5.brs +0 -0
- package/debug/brick qa.brs +0 -0
- package/debug/brickparty.brs +0 -0
- package/debug/brsv10.brs +0 -0
- package/debug/brsv10brick.brs +0 -0
- package/debug/bruteforce.js +0 -254
- package/debug/click brick.brs +0 -0
- package/debug/clone.html +0 -36
- package/debug/ctf_tileset.brs +0 -0
- package/debug/ctf_tileset_5.brs +0 -0
- package/debug/evil.brs +0 -0
- package/debug/evilwrite.js +0 -390
- package/debug/foo.txt +0 -3080
- package/debug/kenko_big.brs +0 -0
- package/debug/light.brs +0 -0
- package/debug/out.json +0 -105
- package/debug/read.js +0 -30
- package/debug/readSpeed.js +0 -32
- package/debug/readTest.js +0 -45
- package/debug/temp.brs +0 -0
- package/debug/western.brs +0 -0
- package/examples/ATCFort.brs +0 -0
- package/examples/read_example.html +0 -34
- package/examples/read_example.js +0 -21
- package/examples/write_example.js +0 -25
- package/examples/write_planet.html +0 -144
- package/examples/write_simplex.html +0 -82
- package/examples/write_wedge_sphere.html +0 -173
- package/src/constants.ts +0 -6
- package/src/index.ts +0 -15
- package/src/read.ts +0 -57
- package/src/read.v1.ts +0 -99
- package/src/read.v10.ts +0 -185
- package/src/read.v2.ts +0 -102
- package/src/read.v3.ts +0 -111
- package/src/read.v4.ts +0 -112
- package/src/read.v8.ts +0 -172
- package/src/read.v9.ts +0 -181
- package/src/types.ts +0 -341
- package/src/utils.ts +0 -651
- package/src/uuid.ts +0 -78
- package/src/write.ts +0 -287
- package/test/lib.test.js +0 -51
- package/test/utils.test.js +0 -209
- package/tsconfig.json +0 -18
- package/webpack.config.js +0 -64
package/debug/evilwrite.js
DELETED
|
@@ -1,390 +0,0 @@
|
|
|
1
|
-
const {
|
|
2
|
-
utils: { write, isEqual, concat },
|
|
3
|
-
constants: { MAGIC, LATEST_VERSION, MAX_INT },
|
|
4
|
-
} = require('../dist/dist.node.js');
|
|
5
|
-
|
|
6
|
-
// looks up a value in an object or returns a defualt value
|
|
7
|
-
function get(obj, path = '', def) {
|
|
8
|
-
// Split the path up by .
|
|
9
|
-
path = path.split('.').filter(p => p.length > 0);
|
|
10
|
-
|
|
11
|
-
// Get the child at each part of the path
|
|
12
|
-
while (path.length && typeof obj === 'object') {
|
|
13
|
-
obj = obj[path.splice(0, 1)[0]];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return typeof obj !== 'undefined' ? obj : def;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
const EMPTY_ARR = new Uint8Array([]);
|
|
20
|
-
|
|
21
|
-
function writeSave(save) {
|
|
22
|
-
if (save.bricks.length > MAX_INT) {
|
|
23
|
-
throw new Error('Brick count out of range');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const version = typeof save.version !== 'undefined' ? save.version : LATEST_VERSION;
|
|
27
|
-
|
|
28
|
-
// Convert from BGRA to RGBA
|
|
29
|
-
const rgba = ([r, g, b, a]) => new Uint8Array([b, g, r, a]);
|
|
30
|
-
|
|
31
|
-
// stored brick indices from components on the bricks
|
|
32
|
-
const componentBricks = {};
|
|
33
|
-
|
|
34
|
-
const numColors = Math.max(get(save, 'colors', EMPTY_ARR).length, 2);
|
|
35
|
-
const numAssets = Math.max(get(save, 'brick_assets', EMPTY_ARR).length, 2);
|
|
36
|
-
const numMats = Math.max(get(save, 'materials.length', 0), 2);
|
|
37
|
-
const numPhysMats = Math.max(get(save, 'physical_materials.length', 0), 2);
|
|
38
|
-
|
|
39
|
-
const buff = concat(
|
|
40
|
-
// Write magic bytes
|
|
41
|
-
MAGIC,
|
|
42
|
-
write.u16(version),
|
|
43
|
-
|
|
44
|
-
version >= 8 ? write.i32(save.gameVersion || 0) : EMPTY_ARR,
|
|
45
|
-
|
|
46
|
-
// Header 1
|
|
47
|
-
write.compressed(
|
|
48
|
-
write.string(get(save, 'map', 'Unknown')),
|
|
49
|
-
write.string(get(save, 'author.name', 'Unknown')),
|
|
50
|
-
write.string(get(save, 'description', '')),
|
|
51
|
-
write.uuid(get(save, 'author.id', '00000000-0000-0000-0000-000000000000')),
|
|
52
|
-
version >= 8 ? concat(
|
|
53
|
-
write.string(get(save, 'host.name', 'Unknown')),
|
|
54
|
-
write.uuid(get(save, 'host.id', '00000000-0000-0000-0000-000000000000')),
|
|
55
|
-
) : EMPTY_ARR,
|
|
56
|
-
get(save, 'save_time', new Uint8Array([0, 0, 0, 0, 0, 0, 0, 0])),
|
|
57
|
-
write.i32(get(save, 'bricks', EMPTY_ARR).length),
|
|
58
|
-
),
|
|
59
|
-
|
|
60
|
-
// Header 2
|
|
61
|
-
write.compressed(
|
|
62
|
-
write.array(get(save, 'mods', EMPTY_ARR), write.string),
|
|
63
|
-
write.array(get(save, 'brick_assets', ['PB_DefaultBrick']), write.string),
|
|
64
|
-
write.array(get(save, 'colors', EMPTY_ARR), rgba),
|
|
65
|
-
write.array(get(save, 'materials', ['BMC_Plastic']), write.string),
|
|
66
|
-
write.array(get(save, 'brick_owners', [{}]), ({ id = '00000000-0000-0000-0000-000000000000', name = 'Unknown', bricks = 0 } = {}) => concat(
|
|
67
|
-
write.uuid(id),
|
|
68
|
-
write.string(name),
|
|
69
|
-
version >= 8 ? write.i32(bricks) : EMPTY_ARR,
|
|
70
|
-
)),
|
|
71
|
-
version >= 9
|
|
72
|
-
? write.array(get(save, 'physical_materials', ['BPMC_Default']), write.string)
|
|
73
|
-
: [],
|
|
74
|
-
),
|
|
75
|
-
|
|
76
|
-
// write the save preview if it exists
|
|
77
|
-
version >= 8
|
|
78
|
-
? concat(
|
|
79
|
-
new Uint8Array([save.preview ? 1 : 0]),
|
|
80
|
-
save.preview ? write.i32(get(save, 'preview.length', 0)) : EMPTY_ARR, // <- Sorry @Uxie https://i.imgur.com/hSRxdbf.png
|
|
81
|
-
get(save, 'preview', EMPTY_ARR),
|
|
82
|
-
)
|
|
83
|
-
: EMPTY_ARR,
|
|
84
|
-
|
|
85
|
-
// Bricks
|
|
86
|
-
write.compressed(write.bits()
|
|
87
|
-
.each(save.bricks, function (brick, i) {
|
|
88
|
-
this.align();
|
|
89
|
-
this.int(get(brick, 'asset_name_index', 0), numAssets);
|
|
90
|
-
|
|
91
|
-
const isSingularity = isEqual(brick.size, [0, 0, 0]);
|
|
92
|
-
this.bit(!isSingularity);
|
|
93
|
-
if (!isSingularity) {
|
|
94
|
-
brick.size.map(s => this.uint_packed(s));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
brick.position.map(s => this.int_packed(s));
|
|
98
|
-
const orientation = (get(brick, 'direction', 4) << 2) | get(brick, 'rotation', 0);
|
|
99
|
-
this.int(orientation, 24);
|
|
100
|
-
if (version >= 10) {
|
|
101
|
-
if (typeof brick.collison === 'boolean' && !brick.collision) {
|
|
102
|
-
this.bit(false);
|
|
103
|
-
this.bit(false);
|
|
104
|
-
this.bit(false);
|
|
105
|
-
this.bit(true);
|
|
106
|
-
} else {
|
|
107
|
-
this.bit(get(brick, 'collision.player', true));
|
|
108
|
-
this.bit(get(brick, 'collision.weapon', true));
|
|
109
|
-
this.bit(get(brick, 'collision.interaction', true));
|
|
110
|
-
this.bit(get(brick, 'collision.tool', true));
|
|
111
|
-
}
|
|
112
|
-
} else {
|
|
113
|
-
this.bit(get(brick, 'collision', true));
|
|
114
|
-
}
|
|
115
|
-
this.bit(get(brick, 'visibility', true));
|
|
116
|
-
if (version >= 8) {
|
|
117
|
-
this.int(brick.material_index, numMats)
|
|
118
|
-
} else {
|
|
119
|
-
this.bit(brick.material_index !== 1);
|
|
120
|
-
if (brick.material_index !== 1) {
|
|
121
|
-
this.uint_packed(brick.material_index);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
if (version >= 9) {
|
|
125
|
-
this.int(get(brick, 'physical_index', 0), numPhysMats);
|
|
126
|
-
this.int(get(brick, 'material_intensity', 5), 11);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
if (typeof brick.color === 'number') {
|
|
130
|
-
this.bit(false);
|
|
131
|
-
this.int(brick.color, numColors);
|
|
132
|
-
} else {
|
|
133
|
-
this.bit(true);
|
|
134
|
-
if (version >= 9) {
|
|
135
|
-
this.bytes(new Uint8Array(get(brick, 'color', [255, 255, 255])));
|
|
136
|
-
} else {
|
|
137
|
-
this.bytes(rgba(get(brick, 'color', [255, 255, 255, 255])));
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
this.uint_packed(get(brick, 'owner_index', 1));
|
|
142
|
-
|
|
143
|
-
if (version >= 8) {
|
|
144
|
-
// add all the brick indices to the components list
|
|
145
|
-
for (const key in brick.components || {}) {
|
|
146
|
-
componentBricks[key] = componentBricks[key] || [];
|
|
147
|
-
componentBricks[key].push(i);
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
})
|
|
151
|
-
.finish()
|
|
152
|
-
),
|
|
153
|
-
|
|
154
|
-
// write components section
|
|
155
|
-
version >= 8 ? write.compressed(write.array(Object.keys(get(save, 'components', {})).filter(name => componentBricks[name]), name => concat(
|
|
156
|
-
write.string(name),
|
|
157
|
-
write.bits()
|
|
158
|
-
.self(function () {
|
|
159
|
-
const component = save.components[name];
|
|
160
|
-
const brick_indices = componentBricks[name];
|
|
161
|
-
const properties = Object.entries(component.properties);
|
|
162
|
-
|
|
163
|
-
// write version
|
|
164
|
-
this.bytes(write.i32(component.version));
|
|
165
|
-
|
|
166
|
-
// write bricks;
|
|
167
|
-
this.array(brick_indices, i => {
|
|
168
|
-
this.int(i, Math.max(save.bricks.length, 2))
|
|
169
|
-
});
|
|
170
|
-
|
|
171
|
-
// write properties
|
|
172
|
-
this.array(properties, ([name, type]) => {
|
|
173
|
-
this.string(name);
|
|
174
|
-
this.string(type);
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
// read brick indices
|
|
178
|
-
for (const i of brick_indices) {
|
|
179
|
-
for (const [prop, type] of properties) {
|
|
180
|
-
this.unreal(type, get(save, `bricks.${i}.components.${name}.${prop}`));
|
|
181
|
-
}
|
|
182
|
-
};
|
|
183
|
-
this.align();
|
|
184
|
-
})
|
|
185
|
-
.finishSection(),
|
|
186
|
-
))) : EMPTY_ARR,
|
|
187
|
-
);
|
|
188
|
-
return buff;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
const fs = require('fs');
|
|
192
|
-
const path = require('path');
|
|
193
|
-
const _ = require('lodash');
|
|
194
|
-
|
|
195
|
-
// Write the save to a file
|
|
196
|
-
const outfile = path.resolve('/mnt/c/Users/ISAAC/AppData/Local/Brickadia/Saved/Builds', 'evil.brs');
|
|
197
|
-
|
|
198
|
-
// Print some info
|
|
199
|
-
fs.writeFileSync(outfile, writeSave({
|
|
200
|
-
"version": 10,
|
|
201
|
-
"bricks": [
|
|
202
|
-
{
|
|
203
|
-
"asset_name_index": 0,
|
|
204
|
-
"size": [ 5, 5, 6 ],
|
|
205
|
-
"position": [0, 0, 0],
|
|
206
|
-
"direction": 4,
|
|
207
|
-
"rotation": 0,
|
|
208
|
-
"collision": {
|
|
209
|
-
"player": true,
|
|
210
|
-
"weapon": true,
|
|
211
|
-
"interaction": true,
|
|
212
|
-
"tool": true
|
|
213
|
-
},
|
|
214
|
-
"visibility": true,
|
|
215
|
-
"material_index": 3,
|
|
216
|
-
"physical_index": 0,
|
|
217
|
-
"material_intensity": 5,
|
|
218
|
-
"color": 0,
|
|
219
|
-
"owner_index": 1,
|
|
220
|
-
"components": {
|
|
221
|
-
"BCD_AudioEmitter": {
|
|
222
|
-
"AudioDescriptor": "BA_AMB_Component_Fires_Fireplace_1",
|
|
223
|
-
"VolumeMultiplier": 1,
|
|
224
|
-
"PitchMultiplier": 1,
|
|
225
|
-
"InnerRadius": 15,
|
|
226
|
-
"MaxDistance": 400,
|
|
227
|
-
"bSpatialization": true
|
|
228
|
-
},
|
|
229
|
-
"BCD_ItemSpawn": {
|
|
230
|
-
"PickupClass": "BP_ItemPickup_StickGrenade",
|
|
231
|
-
"bPickupEnabled": true,
|
|
232
|
-
"bPickupRespawnOnMinigameReset": true,
|
|
233
|
-
"PickupMinigameResetRespawnDelay": 0,
|
|
234
|
-
"bPickupAutoDisableOnPickup": true,
|
|
235
|
-
"PickupRespawnTime": 0.1,
|
|
236
|
-
"PickupOffsetDirection": 4,
|
|
237
|
-
"PickupOffsetDistance": 5,
|
|
238
|
-
"PickupRotation": [ 0, 0, 5 ],
|
|
239
|
-
"PickupScale": 1,
|
|
240
|
-
"bPickupAnimationEnabled": true,
|
|
241
|
-
"PickupAnimationAxis": 2,
|
|
242
|
-
"bPickupAnimationAxisLocal": false,
|
|
243
|
-
"PickupSpinSpeed": 0.1,
|
|
244
|
-
"PickupBobSpeed": 0.1,
|
|
245
|
-
"PickupBobHeight": 4,
|
|
246
|
-
"PickupAnimationPhase": 0.1515854299068451
|
|
247
|
-
},
|
|
248
|
-
"BCD_PointLight": {
|
|
249
|
-
"bMatchBrickShape": true,
|
|
250
|
-
"Brightness": 15,
|
|
251
|
-
"Radius": 500,
|
|
252
|
-
"Color": [
|
|
253
|
-
255,
|
|
254
|
-
255,
|
|
255
|
-
255,
|
|
256
|
-
255
|
|
257
|
-
],
|
|
258
|
-
"bUseBrickColor": true,
|
|
259
|
-
"bCastShadows": true
|
|
260
|
-
},
|
|
261
|
-
"BCD_SpotLight": {
|
|
262
|
-
"Rotation": [
|
|
263
|
-
270,
|
|
264
|
-
0,
|
|
265
|
-
0
|
|
266
|
-
],
|
|
267
|
-
"InnerConeAngle": 30,
|
|
268
|
-
"OuterConeAngle": 0,
|
|
269
|
-
"Brightness": 15,
|
|
270
|
-
"Radius": 150,
|
|
271
|
-
"Color": [
|
|
272
|
-
0,
|
|
273
|
-
255,
|
|
274
|
-
255,
|
|
275
|
-
255
|
|
276
|
-
],
|
|
277
|
-
"bUseBrickColor": true,
|
|
278
|
-
"bCastShadows": true
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
},
|
|
282
|
-
],
|
|
283
|
-
"map": "Plate",
|
|
284
|
-
"author": {
|
|
285
|
-
"name": "cake",
|
|
286
|
-
"id": "60eab7e7-9aa9-4647-83e4-6ce4ec66ae7d"
|
|
287
|
-
},
|
|
288
|
-
"description": "a".repeat(5),
|
|
289
|
-
"host": {
|
|
290
|
-
"name": "cake",
|
|
291
|
-
"id": "60eab7e7-9aa9-4647-83e4-6ce4ec66ae7d"
|
|
292
|
-
},
|
|
293
|
-
"mods": [],
|
|
294
|
-
"brick_assets": ["PB_DefaultBrick"],
|
|
295
|
-
"colors": [
|
|
296
|
-
[255, 255, 255, 255],
|
|
297
|
-
],
|
|
298
|
-
"materials": [
|
|
299
|
-
"BMC_Hidden",
|
|
300
|
-
"BMC_Ghost",
|
|
301
|
-
"BMC_Ghost_Fail",
|
|
302
|
-
"BMC_Plastic",
|
|
303
|
-
"BMC_Glass",
|
|
304
|
-
"BMC_Glow",
|
|
305
|
-
"BMC_Metallic",
|
|
306
|
-
"BMC_Hologram"
|
|
307
|
-
],
|
|
308
|
-
"brick_owners": [
|
|
309
|
-
{
|
|
310
|
-
"id": "60eab7e7-9aa9-4647-83e4-6ce4ec66ae7d",
|
|
311
|
-
"name": "cake",
|
|
312
|
-
"bricks": 69
|
|
313
|
-
},
|
|
314
|
-
],
|
|
315
|
-
"physical_materials": [
|
|
316
|
-
"BPMC_Default"
|
|
317
|
-
],
|
|
318
|
-
"gameVersion": 6880,
|
|
319
|
-
"components": {
|
|
320
|
-
"BCD_AudioEmitter": {
|
|
321
|
-
"version": 1,
|
|
322
|
-
"brick_indices": [
|
|
323
|
-
0
|
|
324
|
-
],
|
|
325
|
-
"properties": {
|
|
326
|
-
"AudioDescriptor": "Object",
|
|
327
|
-
"VolumeMultiplier": "Float",
|
|
328
|
-
"PitchMultiplier": "Float",
|
|
329
|
-
"InnerRadius": "Float",
|
|
330
|
-
"MaxDistance": "Float",
|
|
331
|
-
"bSpatialization": "Boolean"
|
|
332
|
-
}
|
|
333
|
-
},
|
|
334
|
-
"BCD_ItemSpawn": {
|
|
335
|
-
"version": -1,
|
|
336
|
-
"brick_indices": [
|
|
337
|
-
0
|
|
338
|
-
],
|
|
339
|
-
"properties": {
|
|
340
|
-
"PickupClass": "Class",
|
|
341
|
-
"bPickupEnabled": "Boolean",
|
|
342
|
-
"bPickupRespawnOnMinigameReset": "Boolean",
|
|
343
|
-
"PickupMinigameResetRespawnDelay": "Float",
|
|
344
|
-
"bPickupAutoDisableOnPickup": "Boolean",
|
|
345
|
-
"PickupRespawnTime": "Float",
|
|
346
|
-
"PickupOffsetDirection": "Byte",
|
|
347
|
-
"PickupOffsetDistance": "Float",
|
|
348
|
-
"PickupRotation": "Rotator",
|
|
349
|
-
"PickupScale": "Float",
|
|
350
|
-
"bPickupAnimationEnabled": "Boolean",
|
|
351
|
-
"PickupAnimationAxis": "Byte",
|
|
352
|
-
"bPickupAnimationAxisLocal": "Boolean",
|
|
353
|
-
"PickupSpinSpeed": "Float",
|
|
354
|
-
"PickupBobSpeed": "Float",
|
|
355
|
-
"PickupBobHeight": "Float",
|
|
356
|
-
"PickupAnimationPhase": "Float"
|
|
357
|
-
},
|
|
358
|
-
},
|
|
359
|
-
"BCD_PointLight": {
|
|
360
|
-
"version": 1,
|
|
361
|
-
"brick_indices": [
|
|
362
|
-
0
|
|
363
|
-
],
|
|
364
|
-
"properties": {
|
|
365
|
-
"bMatchBrickShape": "Boolean",
|
|
366
|
-
"Brightness": "Float",
|
|
367
|
-
"Radius": "Float",
|
|
368
|
-
"Color": "Color",
|
|
369
|
-
"bUseBrickColor": "Boolean",
|
|
370
|
-
"bCastShadows": "Boolean"
|
|
371
|
-
}
|
|
372
|
-
},
|
|
373
|
-
"BCD_SpotLight": {
|
|
374
|
-
"version": 1,
|
|
375
|
-
"brick_indices": [
|
|
376
|
-
0
|
|
377
|
-
],
|
|
378
|
-
"properties": {
|
|
379
|
-
"Rotation": "Rotator",
|
|
380
|
-
"InnerConeAngle": "Float",
|
|
381
|
-
"OuterConeAngle": "Float",
|
|
382
|
-
"Brightness": "Float",
|
|
383
|
-
"Radius": "Float",
|
|
384
|
-
"Color": "Color",
|
|
385
|
-
"bUseBrickColor": "Boolean",
|
|
386
|
-
"bCastShadows": "Boolean"
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}));
|