@adatechnology/game-test-room 0.8.0 → 0.9.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 +2 -0
- package/dist/index.d.ts +15 -2
- package/dist/index.global.js +434 -71
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +70 -5
- package/dist/index.js.map +1 -1
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -322,6 +322,16 @@ var en = {
|
|
|
322
322
|
"ui.slow": "Slow motion 0.25\xD7",
|
|
323
323
|
"ui.fast": "Time \xD710",
|
|
324
324
|
"ui.tap": "Tap",
|
|
325
|
+
"ui.blast.shelter": "Shelter",
|
|
326
|
+
"ui.blast.fragmentHits": "Fragments",
|
|
327
|
+
"ui.blast.confinement": "Confinement",
|
|
328
|
+
"ui.blast.shelter.hint": "Blasts: walls and other parts between the blast and the target take their share",
|
|
329
|
+
"ui.blast.fragmentHits.hint": "Blasts: the pieces of what breaks fly on and hit what is behind",
|
|
330
|
+
"ui.blast.confinement.hint": "Blasts: pressure builds up in an enclosed room",
|
|
331
|
+
"metric.blast_shelter": "Blast reaching (%)",
|
|
332
|
+
"metric.blast_confinement": "Blast pressure (x)",
|
|
333
|
+
"metric.blast_fragments": "Fragment hits",
|
|
334
|
+
"act.blast_report": "Blast: {shelter}% reached the most sheltered target, pressure x{confinement}, {fragments} fragment hits, {n} targets",
|
|
325
335
|
"ui.quality": "Quality",
|
|
326
336
|
"ui.quality.low": "low",
|
|
327
337
|
"ui.quality.medium": "medium",
|
|
@@ -647,6 +657,16 @@ var ptBR = {
|
|
|
647
657
|
"ui.slow": "C\xE2mera lenta 0,25\xD7",
|
|
648
658
|
"ui.fast": "Tempo \xD710",
|
|
649
659
|
"ui.tap": "Torneira",
|
|
660
|
+
"ui.blast.shelter": "Abrigo",
|
|
661
|
+
"ui.blast.fragmentHits": "Estilha\xE7os",
|
|
662
|
+
"ui.blast.confinement": "Confinamento",
|
|
663
|
+
"ui.blast.shelter.hint": "Explos\xF5es: paredes e outras partes entre a explos\xE3o e o alvo ficam com a sua parte",
|
|
664
|
+
"ui.blast.fragmentHits.hint": "Explos\xF5es: os peda\xE7os do que quebra voam e acertam o que est\xE1 atr\xE1s",
|
|
665
|
+
"ui.blast.confinement.hint": "Explos\xF5es: a press\xE3o sobe num ambiente fechado",
|
|
666
|
+
"metric.blast_shelter": "Explos\xE3o que chegou (%)",
|
|
667
|
+
"metric.blast_confinement": "Press\xE3o da explos\xE3o (x)",
|
|
668
|
+
"metric.blast_fragments": "Estilha\xE7os que acertaram",
|
|
669
|
+
"act.blast_report": "Explos\xE3o: {shelter}% chegou ao alvo mais abrigado, press\xE3o x{confinement}, {fragments} estilha\xE7os acertaram, {n} alvos",
|
|
650
670
|
"ui.quality": "Qualidade",
|
|
651
671
|
"ui.quality.low": "baixa",
|
|
652
672
|
"ui.quality.medium": "m\xE9dia",
|
|
@@ -1372,6 +1392,16 @@ var segmentTouchesBox = (from, to, min, max) => {
|
|
|
1372
1392
|
|
|
1373
1393
|
// src/explosives.ts
|
|
1374
1394
|
var CONE_BLAST_RADIUS = 0.5;
|
|
1395
|
+
var summarizeBlast = (results) => {
|
|
1396
|
+
const reports = results.flatMap((r) => r.blast ? [r.blast] : []);
|
|
1397
|
+
if (reports.length === 0) return void 0;
|
|
1398
|
+
return {
|
|
1399
|
+
shelter: Math.min(...reports.map((r) => r.shelter)),
|
|
1400
|
+
confinement: reports[0].confinement,
|
|
1401
|
+
fragmentHits: reports.reduce((n, r) => n + r.fragmentHits, 0),
|
|
1402
|
+
targets: reports.length
|
|
1403
|
+
};
|
|
1404
|
+
};
|
|
1375
1405
|
var toArray = (vector) => [vector.x, vector.y, vector.z];
|
|
1376
1406
|
function createExplosives(context) {
|
|
1377
1407
|
const { THREE, scene, camera, world, renderer, arsenal, translate, format, action } = context;
|
|
@@ -1518,17 +1548,27 @@ function createExplosives(context) {
|
|
|
1518
1548
|
if (box2.isEmpty()) box2.expandByPoint(object.position);
|
|
1519
1549
|
const at = mostExposedPoint(box2, detonation);
|
|
1520
1550
|
if (!at) continue;
|
|
1521
|
-
|
|
1551
|
+
const results = world.explode(at, detonation.energy * blastEffect(detonation, at).falloff, CONE_BLAST_RADIUS, "player", context.blast());
|
|
1552
|
+
reached += results.length;
|
|
1553
|
+
told(results);
|
|
1522
1554
|
}
|
|
1523
1555
|
return reached;
|
|
1524
1556
|
};
|
|
1557
|
+
const told = (results) => {
|
|
1558
|
+
const summary = summarizeBlast(results);
|
|
1559
|
+
if (!summary) return;
|
|
1560
|
+
context.blasted(summary);
|
|
1561
|
+
action("blast_report", translate("act.blast_report", { shelter: format(summary.shelter * 100, 0), confinement: format(summary.confinement, 2), fragments: summary.fragmentHits, n: summary.targets }), { data: { ...summary } });
|
|
1562
|
+
};
|
|
1525
1563
|
const detonate = (projectile, detonation) => {
|
|
1526
1564
|
const weaponName = context.toolName(projectile.weapon);
|
|
1527
1565
|
const reach = Math.max(detonation.injuryRadius, detonation.lethalRadius);
|
|
1528
|
-
const
|
|
1566
|
+
const results = detonation.energy <= 0 || detonation.cone ? [] : world.explode(detonation.point, detonation.energy, reach, "player", context.blast());
|
|
1567
|
+
const reached = detonation.energy <= 0 ? 0 : detonation.cone ? coneBlast(detonation) : results.length;
|
|
1568
|
+
if (!detonation.cone) told(results);
|
|
1529
1569
|
if (detonation.energy > 0) {
|
|
1530
1570
|
const isPlayed = context.effects.explosion(detonation.explosive, detonation.point, { direction: detonation.direction }) !== null;
|
|
1531
|
-
renderer.explode(detonation.point, detonation.energy, reach, { visual: !isPlayed });
|
|
1571
|
+
renderer.explode(detonation.point, detonation.energy, reach, { visual: !isPlayed, report: results });
|
|
1532
1572
|
}
|
|
1533
1573
|
if (detonation.stunSeconds !== void 0) renderer.emit("flash", detonation.point, [0, 1, 0], 1, 1);
|
|
1534
1574
|
const onPlayer = blastEffect(detonation, toArray(camera.position));
|
|
@@ -1825,7 +1865,7 @@ function createLog(options = {}) {
|
|
|
1825
1865
|
}
|
|
1826
1866
|
|
|
1827
1867
|
// src/metrics.ts
|
|
1828
|
-
var ROOM_METRICS = ["fps", "frame_ms", "draw_calls", "triangles", "objects", "fragments", "particles", "decals"];
|
|
1868
|
+
var ROOM_METRICS = ["fps", "frame_ms", "draw_calls", "triangles", "objects", "fragments", "particles", "decals", "blast_shelter", "blast_confinement", "blast_fragments"];
|
|
1829
1869
|
var WINDOW_S = 0.5;
|
|
1830
1870
|
function createRoomMetrics(sources) {
|
|
1831
1871
|
const wanted = new Set(sources.ids);
|
|
@@ -1862,6 +1902,12 @@ function createRoomMetrics(sources) {
|
|
|
1862
1902
|
const render = ownsRender ? { calls, triangles } : gl.info?.render;
|
|
1863
1903
|
put("draw_calls", render?.calls);
|
|
1864
1904
|
put("triangles", render?.triangles);
|
|
1905
|
+
const blast = sources.blast?.();
|
|
1906
|
+
if (blast) {
|
|
1907
|
+
put("blast_shelter", blast.shelter * 100);
|
|
1908
|
+
put("blast_confinement", blast.confinement);
|
|
1909
|
+
put("blast_fragments", blast.fragmentHits);
|
|
1910
|
+
}
|
|
1865
1911
|
if (!["objects", "fragments", "particles", "decals"].some((id) => wanted.has(id))) return out;
|
|
1866
1912
|
const destruction = sources.destruction.stats();
|
|
1867
1913
|
const fluids = sources.fluids.stats();
|
|
@@ -3544,6 +3590,8 @@ function createUi(o) {
|
|
|
3544
3590
|
o.onFast(fast);
|
|
3545
3591
|
});
|
|
3546
3592
|
const tapBtn = ctl(t("ui.tap"), () => o.onTap());
|
|
3593
|
+
const blastBtns = ["shelter", "fragmentHits", "confinement"].map((key) => ({ key, b: ctl(t(`ui.blast.${key}`), () => o.onBlast(key)) }));
|
|
3594
|
+
for (const { key, b } of blastBtns) b.title = t(`ui.blast.${key}.hint`);
|
|
3547
3595
|
const qSel = mk2("select");
|
|
3548
3596
|
for (const q of ["low", "medium", "high"]) {
|
|
3549
3597
|
const op = mk2("option", void 0, t(`ui.quality.${q}`));
|
|
@@ -3748,6 +3796,7 @@ function createUi(o) {
|
|
|
3748
3796
|
}
|
|
3749
3797
|
slotsEl.forEach((b, i) => b.classList.toggle("on", i === s.slot));
|
|
3750
3798
|
tapBtn.classList.toggle("on", s.tap);
|
|
3799
|
+
for (const { key: key2, b } of blastBtns) b.classList.toggle("on", s.blast[key2]);
|
|
3751
3800
|
count.textContent = t("ui.objects", { n: s.objects });
|
|
3752
3801
|
const ak = JSON.stringify(s.animations);
|
|
3753
3802
|
if (ak !== lastAnim) {
|
|
@@ -4629,6 +4678,12 @@ function createTestRoom(options) {
|
|
|
4629
4678
|
bodies.push({ id: "player", box: new THREE.Box3(new THREE.Vector3(x - PLAYER_RADIUS, feet, z - PLAYER_RADIUS), new THREE.Vector3(x + PLAYER_RADIUS, y + 0.1, z + PLAYER_RADIUS)) });
|
|
4630
4679
|
return bodies;
|
|
4631
4680
|
}
|
|
4681
|
+
let blastOptions = { ...options.blast };
|
|
4682
|
+
let lastBlast;
|
|
4683
|
+
const blastOn = (key) => Boolean(blastOptions[key]);
|
|
4684
|
+
const toggleBlast = (key) => {
|
|
4685
|
+
blastOptions = { ...blastOptions, [key]: blastOn(key) ? false : true };
|
|
4686
|
+
};
|
|
4632
4687
|
const explosives = createExplosives({
|
|
4633
4688
|
THREE,
|
|
4634
4689
|
scene,
|
|
@@ -4643,6 +4698,10 @@ function createTestRoom(options) {
|
|
|
4643
4698
|
toolName,
|
|
4644
4699
|
withoutHeld,
|
|
4645
4700
|
groundAt,
|
|
4701
|
+
blast: () => blastOptions,
|
|
4702
|
+
blasted: (summary) => {
|
|
4703
|
+
lastBlast = summary;
|
|
4704
|
+
},
|
|
4646
4705
|
translate: t,
|
|
4647
4706
|
format: num,
|
|
4648
4707
|
action,
|
|
@@ -5069,7 +5128,7 @@ function createTestRoom(options) {
|
|
|
5069
5128
|
let metricsAcc = 0;
|
|
5070
5129
|
let ownsLoop = false;
|
|
5071
5130
|
const roomMetricIds = options.metrics === false ? [] : options.metrics ?? ROOM_METRICS;
|
|
5072
|
-
const roomMetrics = createRoomMetrics({ gl, destruction: renderer, fluids: fluidView, effects: vfx.world, ids: roomMetricIds });
|
|
5131
|
+
const roomMetrics = createRoomMetrics({ gl, destruction: renderer, fluids: fluidView, effects: vfx.world, ids: roomMetricIds, blast: () => lastBlast });
|
|
5073
5132
|
let qualityName = quality;
|
|
5074
5133
|
const syncContainers = (sdt) => {
|
|
5075
5134
|
for (const e of entries.values()) {
|
|
@@ -5188,6 +5247,7 @@ function createTestRoom(options) {
|
|
|
5188
5247
|
timeScale,
|
|
5189
5248
|
fast: fastForward,
|
|
5190
5249
|
tap: isTapOn(),
|
|
5250
|
+
blast: { shelter: blastOn("shelter"), fragmentHits: blastOn("fragmentHits"), confinement: blastOn("confinement") },
|
|
5191
5251
|
quality: qualityName,
|
|
5192
5252
|
objects: [...entries.values()].filter((e) => !e.arena).length
|
|
5193
5253
|
};
|
|
@@ -5703,6 +5763,10 @@ function createTestRoom(options) {
|
|
|
5703
5763
|
heldTilt = rad;
|
|
5704
5764
|
},
|
|
5705
5765
|
toggleTap,
|
|
5766
|
+
blast: () => ({ ...blastOptions }),
|
|
5767
|
+
setBlast: (next) => {
|
|
5768
|
+
blastOptions = { ...blastOptions, ...next };
|
|
5769
|
+
},
|
|
5706
5770
|
pause() {
|
|
5707
5771
|
paused = true;
|
|
5708
5772
|
},
|
|
@@ -5813,6 +5877,7 @@ function createTestRoom(options) {
|
|
|
5813
5877
|
setTool(loadout[index]);
|
|
5814
5878
|
},
|
|
5815
5879
|
onTap: () => toggleTap(),
|
|
5880
|
+
onBlast: (key) => toggleBlast(key),
|
|
5816
5881
|
onPlay: (objectId, clipId) => {
|
|
5817
5882
|
playAnimation(clipId, objectId);
|
|
5818
5883
|
},
|