@adatechnology/game-test-room 0.29.0 → 0.29.1
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.global.js +451 -92
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +52 -5
- package/dist/index.js.map +1 -1
- package/package.json +15 -15
package/dist/index.js
CHANGED
|
@@ -635,6 +635,8 @@ var SMOKE_PUFF_LIFE = 3.2;
|
|
|
635
635
|
var SMOKE_PUFF_SPEED = 1.7;
|
|
636
636
|
var SMOKE_PUFF_SIZE = 5;
|
|
637
637
|
var SMOKE_PUFF_ALPHA = 1.5;
|
|
638
|
+
var SMOKE_HISS = { loop: "smoke_grenade_hiss", volume: 0.7, halfAt: 6, max: 1 };
|
|
639
|
+
var GRENADE_PIN_SOUND = "grenade_pin_pull";
|
|
638
640
|
var CONE_BLAST_RADIUS = 0.5;
|
|
639
641
|
var summarizeBlast = (results) => {
|
|
640
642
|
const reports = results.flatMap((r) => r.blast ? [r.blast] : []);
|
|
@@ -654,12 +656,31 @@ function createExplosives(context) {
|
|
|
654
656
|
const random = context.random ?? Math.random;
|
|
655
657
|
const meshes = [];
|
|
656
658
|
const up = new THREE.Vector3(0, 1, 0);
|
|
659
|
+
let smokeHiss = null;
|
|
660
|
+
const hissSmoke = () => {
|
|
661
|
+
if (!context.audio) return;
|
|
662
|
+
if (smokeSources.length === 0) {
|
|
663
|
+
smokeHiss?.stop();
|
|
664
|
+
smokeHiss = null;
|
|
665
|
+
return;
|
|
666
|
+
}
|
|
667
|
+
const at = camera.position;
|
|
668
|
+
let level = 0;
|
|
669
|
+
for (const source of smokeSources) {
|
|
670
|
+
const distance = Math.hypot(source.point[0] - at.x, source.point[1] - at.y, source.point[2] - at.z);
|
|
671
|
+
level += SMOKE_HISS.volume / (1 + (distance / SMOKE_HISS.halfAt) ** 2);
|
|
672
|
+
}
|
|
673
|
+
smokeHiss ?? (smokeHiss = context.audio.loop(SMOKE_HISS.loop));
|
|
674
|
+
smokeHiss.set({ volume: Math.min(SMOKE_HISS.max, level) });
|
|
675
|
+
};
|
|
657
676
|
const drop = (objects) => {
|
|
658
677
|
for (const object of objects) object.removeFromParent();
|
|
659
678
|
releaseObject3D(objects, { keep: scene });
|
|
660
679
|
};
|
|
661
680
|
const clear = () => {
|
|
662
681
|
smokeSources.length = 0;
|
|
682
|
+
smokeHiss?.stop();
|
|
683
|
+
smokeHiss = null;
|
|
663
684
|
projectiles.length = 0;
|
|
664
685
|
drop(meshes);
|
|
665
686
|
meshes.length = 0;
|
|
@@ -713,6 +734,7 @@ function createExplosives(context) {
|
|
|
713
734
|
age: 0,
|
|
714
735
|
...use.explosive !== void 0 ? { body: createExplosiveBody(use, arsenal.explosives, arsenal.rules.explosives), aligned: isRocket } : {}
|
|
715
736
|
});
|
|
737
|
+
if (!isRocket && !isMolotov && use.explosive !== void 0) context.audio?.play(GRENADE_PIN_SOUND, { position: use.origin });
|
|
716
738
|
const key2 = isRocket ? "act.launch" : isMolotov ? "act.throw.molotov" : "act.throw.grenade";
|
|
717
739
|
action(isRocket ? "launch_projectile" : "throw_projectile", translate(key2, { weapon: context.toolName(), fuse: format(use.fuse, 1), arm: format(use.armDistance ?? 0, 0) }), {
|
|
718
740
|
data: { weapon: context.toolId(), fuse: use.fuse, explosive: use.explosive }
|
|
@@ -966,6 +988,7 @@ function createExplosives(context) {
|
|
|
966
988
|
}
|
|
967
989
|
if (source.left <= 0) smokeSources.splice(index, 1);
|
|
968
990
|
}
|
|
991
|
+
hissSmoke();
|
|
969
992
|
};
|
|
970
993
|
const update = (dt) => {
|
|
971
994
|
burnSmoke(dt);
|
|
@@ -3695,6 +3718,7 @@ var en = {
|
|
|
3695
3718
|
"act.player_thrown_wounded": "The blast threw the player at {speed} m/s, {distance} m from it: badly wounded, stunned for {stun} s ({reach}% got through the cover)",
|
|
3696
3719
|
"act.player_stunned": "The blast stunned the player for {stun} s, {distance} m from it: dizzy, ears ringing",
|
|
3697
3720
|
"act.came_apart": "{name} came apart: what stayed is loose and falls",
|
|
3721
|
+
"check.broken_floating": "ERROR: what was left of {name} stood on nothing after the break; it was let go to fall",
|
|
3698
3722
|
"act.shoved": "{name} stands free: the shots moved it",
|
|
3699
3723
|
"act.impact": "{name} hit {where} at {speed} m/s: {energy} J of blunt damage",
|
|
3700
3724
|
"act.use_item": "{name}: {use}",
|
|
@@ -4073,6 +4097,7 @@ var ptBR = {
|
|
|
4073
4097
|
"act.player_thrown_wounded": "A explos\xE3o arremessou o jogador a {speed} m/s, a {distance} m dela: ferido gravemente, atordoado por {stun} s ({reach}% passou pela cobertura)",
|
|
4074
4098
|
"act.player_stunned": "A explos\xE3o atordoou o jogador por {stun} s, a {distance} m dela: tonto, com os ouvidos zumbindo",
|
|
4075
4099
|
"act.came_apart": "{name} se desmontou: o que ficou est\xE1 solto e cai",
|
|
4100
|
+
"check.broken_floating": "ERRO: o que sobrou de {name} ficou sem apoio depois de quebrar; foi solto para cair",
|
|
4076
4101
|
"act.shoved": "{name} estava solto no ch\xE3o: os tiros o moveram",
|
|
4077
4102
|
"act.impact": "{name} bateu em {where} a {speed} m/s: {energy} J de dano de impacto",
|
|
4078
4103
|
"act.use_item": "{name}: {use}",
|
|
@@ -5803,6 +5828,14 @@ function createTestRoom(options) {
|
|
|
5803
5828
|
rendererPieces.set(objectId, piece);
|
|
5804
5829
|
action("loosened", t(cause === "blast" ? "act.loosened" : "act.came_apart", { name: e.name }), { objectId, itemId: e.so.itemId });
|
|
5805
5830
|
},
|
|
5831
|
+
// after a break the collision of the object is measured again from what is still drawn; what stood on nothing was let go, which is a bug the room says aloud
|
|
5832
|
+
onBrokenChecked: (objectId, released) => {
|
|
5833
|
+
bodyBoxes.delete(objectId);
|
|
5834
|
+
if (standingIds.includes(objectId)) leaveFootprint(objectId);
|
|
5835
|
+
if (!released) return;
|
|
5836
|
+
const e = entries.get(objectId);
|
|
5837
|
+
log.add({ channel: "check", type: "fail", text: t("check.broken_floating", { name: e?.name ?? objectId }), objectId, ...e ? { itemId: e.so.itemId } : {}, data: { invariant: "broken_floating" } });
|
|
5838
|
+
},
|
|
5806
5839
|
onPiece: (piece) => {
|
|
5807
5840
|
rendererPieces.set(piece.objectId, piece);
|
|
5808
5841
|
loose.push(piece);
|
|
@@ -6466,9 +6499,14 @@ function createTestRoom(options) {
|
|
|
6466
6499
|
bodyBoxes.delete(id);
|
|
6467
6500
|
return null;
|
|
6468
6501
|
}
|
|
6469
|
-
|
|
6470
|
-
if (
|
|
6471
|
-
|
|
6502
|
+
const parts = renderer.shownBoxes(id);
|
|
6503
|
+
if (parts.length === 0) {
|
|
6504
|
+
bodyBoxes.delete(id);
|
|
6505
|
+
return null;
|
|
6506
|
+
}
|
|
6507
|
+
bodyBounds.makeEmpty();
|
|
6508
|
+
for (const p of parts) bodyBounds.expandByPoint(tmpV.set(p[0], p[1], p[2])).expandByPoint(tmpV.set(p[3], p[4], p[5]));
|
|
6509
|
+
const box2 = { minX: bodyBounds.min.x, maxX: bodyBounds.max.x, minZ: bodyBounds.min.z, maxZ: bodyBounds.max.z, base: bodyBounds.min.y, top: bodyBounds.max.y, stamp: frameStamp, parts };
|
|
6472
6510
|
bodyBoxes.set(id, box2);
|
|
6473
6511
|
return box2;
|
|
6474
6512
|
};
|
|
@@ -6485,7 +6523,15 @@ function createTestRoom(options) {
|
|
|
6485
6523
|
const reach = c.radius + r;
|
|
6486
6524
|
return (x - footPos.x) ** 2 + (z - footPos.z) ** 2 < reach * reach ? { ...b, top: Math.min(b.top, footPos.y + (c.height ?? b.top - footPos.y)) } : null;
|
|
6487
6525
|
}
|
|
6488
|
-
|
|
6526
|
+
if (!(x > b.minX - r && x < b.maxX + r && z > b.minZ - r && z < b.maxZ + r)) return null;
|
|
6527
|
+
let base = Infinity;
|
|
6528
|
+
let top = -Infinity;
|
|
6529
|
+
for (const p of b.parts) {
|
|
6530
|
+
if (!(x > p[0] - r && x < p[3] + r && z > p[2] - r && z < p[5] + r)) continue;
|
|
6531
|
+
base = Math.min(base, p[1]);
|
|
6532
|
+
top = Math.max(top, p[4]);
|
|
6533
|
+
}
|
|
6534
|
+
return top > base ? { ...b, base, top } : null;
|
|
6489
6535
|
};
|
|
6490
6536
|
blockers.add((x, z, r) => {
|
|
6491
6537
|
for (const e of entries.values()) {
|
|
@@ -7543,7 +7589,8 @@ function createTestRoom(options) {
|
|
|
7543
7589
|
emitHost,
|
|
7544
7590
|
startFire,
|
|
7545
7591
|
say,
|
|
7546
|
-
projectileModel: options.projectileModel
|
|
7592
|
+
projectileModel: options.projectileModel,
|
|
7593
|
+
audio
|
|
7547
7594
|
});
|
|
7548
7595
|
const toolOf = (hand) => hand === "L" ? offTool && offToolId ? { id: offToolId, state: offTool } : null : { id: toolId, state: tool };
|
|
7549
7596
|
const dualReload = createDualReload(
|