@adatechnology/game-test-room 0.22.0 → 0.23.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/dist/index.d.ts +2 -0
- package/dist/index.global.js +133 -39
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +27 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -2147,6 +2147,7 @@ var LOOK = 22e-4;
|
|
|
2147
2147
|
var LYING_EYE = 0.3;
|
|
2148
2148
|
var LYING_PITCH = 1.05;
|
|
2149
2149
|
var LYING_ROLL = 0.35;
|
|
2150
|
+
var LYING_PITCH_FACE_DOWN = -1.05;
|
|
2150
2151
|
function createPlayer(THREE, o) {
|
|
2151
2152
|
const cam = o.camera;
|
|
2152
2153
|
let yaw = 0;
|
|
@@ -2185,11 +2186,12 @@ function createPlayer(THREE, o) {
|
|
|
2185
2186
|
floorLevel += Math.max(-reach, Math.min(reach, gap));
|
|
2186
2187
|
};
|
|
2187
2188
|
let knocked = null;
|
|
2189
|
+
let knockedForward = false;
|
|
2188
2190
|
let rollSide = 1;
|
|
2189
2191
|
const apply = () => {
|
|
2190
2192
|
const lying = knocked?.lying ?? 0;
|
|
2191
2193
|
const fallen = lying * lying * (3 - 2 * lying);
|
|
2192
|
-
euler.set(pitch + (LYING_PITCH - pitch) * fallen, yaw, LYING_ROLL * rollSide * fallen, "YXZ");
|
|
2194
|
+
euler.set(pitch + ((knockedForward ? LYING_PITCH_FACE_DOWN : LYING_PITCH) - pitch) * fallen, yaw, LYING_ROLL * rollSide * fallen, "YXZ");
|
|
2193
2195
|
cam.quaternion.setFromEuler(euler);
|
|
2194
2196
|
const standing = eye - CROUCH_DROP * crouch - bend;
|
|
2195
2197
|
cam.position.set(px.x, floorLevel + y + standing + (LYING_EYE - standing) * fallen, px.z);
|
|
@@ -2467,6 +2469,7 @@ function createPlayer(THREE, o) {
|
|
|
2467
2469
|
if (next.down) {
|
|
2468
2470
|
const right = Math.cos(yaw) * next.velocity[0] - Math.sin(yaw) * next.velocity[2];
|
|
2469
2471
|
rollSide = right >= 0 ? -1 : 1;
|
|
2472
|
+
knockedForward = -Math.sin(yaw) * next.velocity[0] - Math.cos(yaw) * next.velocity[2] > 0;
|
|
2470
2473
|
crouchLatched = false;
|
|
2471
2474
|
}
|
|
2472
2475
|
if (knocked.airborne) vy = Math.max(vy, knocked.velocity[1]);
|
|
@@ -2474,6 +2477,9 @@ function createPlayer(THREE, o) {
|
|
|
2474
2477
|
get knocked() {
|
|
2475
2478
|
return knocked;
|
|
2476
2479
|
},
|
|
2480
|
+
get knockedForward() {
|
|
2481
|
+
return knockedForward;
|
|
2482
|
+
},
|
|
2477
2483
|
update(dt) {
|
|
2478
2484
|
if (knocked) {
|
|
2479
2485
|
stepKnocked(dt);
|
|
@@ -6194,6 +6200,7 @@ function createTestRoom(options) {
|
|
|
6194
6200
|
explosives.clear();
|
|
6195
6201
|
fireZones.length = 0;
|
|
6196
6202
|
burningStains.length = 0;
|
|
6203
|
+
destructionSound?.reset();
|
|
6197
6204
|
terrain.setLayout(defaultGround);
|
|
6198
6205
|
for (const id of [...entries.keys()]) if (!entries.get(id)?.arena) removeEntry(id);
|
|
6199
6206
|
clearLoose();
|
|
@@ -6361,6 +6368,7 @@ function createTestRoom(options) {
|
|
|
6361
6368
|
avatarState.running = !player.crouching && (player.keys.has("ShiftLeft") || player.keys.has("ShiftRight"));
|
|
6362
6369
|
avatarState.crouch = crouchForced || player.crouching || push.isBent;
|
|
6363
6370
|
avatarState.down = downForced || Boolean(player.knocked?.down || (player.knocked?.lying ?? 0) > 0.5);
|
|
6371
|
+
avatarState.fallForward = downForced ? void 0 : player.knockedForward;
|
|
6364
6372
|
avatarState.armed = armedForced ?? tool.def.action.kind === "firearm";
|
|
6365
6373
|
avatarState.pitch = player.pitch;
|
|
6366
6374
|
avatarState.holding = heldPiece !== null;
|
|
@@ -6560,6 +6568,15 @@ function createTestRoom(options) {
|
|
|
6560
6568
|
};
|
|
6561
6569
|
const fireZones = [];
|
|
6562
6570
|
const burningStains = [];
|
|
6571
|
+
const poolFire = (point, burning) => playSound(burning ? "burn_loop" : "burn_end", point, 0.5, { fuel: "liquid" });
|
|
6572
|
+
const dropZone = (i) => {
|
|
6573
|
+
const [zone] = fireZones.splice(i, 1);
|
|
6574
|
+
if (zone) poolFire(zone.point, false);
|
|
6575
|
+
};
|
|
6576
|
+
const dropStain = (i) => {
|
|
6577
|
+
const [stain] = burningStains.splice(i, 1);
|
|
6578
|
+
if (stain) poolFire(stain.center, false);
|
|
6579
|
+
};
|
|
6563
6580
|
const stainRadius = (s) => {
|
|
6564
6581
|
let sum = 0;
|
|
6565
6582
|
for (const r of s.front) sum += r;
|
|
@@ -6576,6 +6593,7 @@ function createTestRoom(options) {
|
|
|
6576
6593
|
if (stainBurning(s)) continue;
|
|
6577
6594
|
const seconds = Math.max(3, Math.min(20, 4 + s.liters * 30 + stainRadius(s) * 6));
|
|
6578
6595
|
burningStains.push({ center: [s.center[0], s.center[1], s.center[2]], remaining: seconds, acc: 0 });
|
|
6596
|
+
poolFire([s.center[0], s.center[1], s.center[2]], true);
|
|
6579
6597
|
lit = true;
|
|
6580
6598
|
log.add({
|
|
6581
6599
|
channel: "event",
|
|
@@ -6606,7 +6624,7 @@ function createTestRoom(options) {
|
|
|
6606
6624
|
const a = rnd() * Math.PI * 2;
|
|
6607
6625
|
const r = Math.sqrt(rnd()) * z.radius;
|
|
6608
6626
|
renderer.emit("fire", [z.point[0] + Math.cos(a) * r, z.point[1] + 0.05, z.point[2] + Math.sin(a) * r], [0, 1, 0], 2, 1.5);
|
|
6609
|
-
if (z.remaining <= 0)
|
|
6627
|
+
if (z.remaining <= 0) dropZone(i);
|
|
6610
6628
|
}
|
|
6611
6629
|
if (burningStains.length) {
|
|
6612
6630
|
const stains = fluids.stains();
|
|
@@ -6627,7 +6645,7 @@ function createTestRoom(options) {
|
|
|
6627
6645
|
if (b.remaining <= 0 || !st) {
|
|
6628
6646
|
fluids.clearStains(b.center, r + 0.1);
|
|
6629
6647
|
log.add({ channel: "event", type: "stain_burned", text: t("ev.stain_burned"), data: { point: b.center } });
|
|
6630
|
-
|
|
6648
|
+
dropStain(i);
|
|
6631
6649
|
}
|
|
6632
6650
|
}
|
|
6633
6651
|
}
|
|
@@ -6964,8 +6982,8 @@ function createTestRoom(options) {
|
|
|
6964
6982
|
hit.add(r.object);
|
|
6965
6983
|
world.extinguish(r.object, void 0, u.coolC * Math.max(u.duration, 0.05) * 6);
|
|
6966
6984
|
fluids.clearStains(r.point, 0.5);
|
|
6967
|
-
for (let i = burningStains.length - 1; i >= 0; i--) if (Math.hypot(burningStains[i].center[0] - r.point[0], burningStains[i].center[2] - r.point[2]) < 1.2)
|
|
6968
|
-
for (let i = fireZones.length - 1; i >= 0; i--) if (Math.hypot(fireZones[i].point[0] - r.point[0], fireZones[i].point[2] - r.point[2]) < 1.5)
|
|
6985
|
+
for (let i = burningStains.length - 1; i >= 0; i--) if (Math.hypot(burningStains[i].center[0] - r.point[0], burningStains[i].center[2] - r.point[2]) < 1.2) dropStain(i);
|
|
6986
|
+
for (let i = fireZones.length - 1; i >= 0; i--) if (Math.hypot(fireZones[i].point[0] - r.point[0], fireZones[i].point[2] - r.point[2]) < 1.5) dropZone(i);
|
|
6969
6987
|
}
|
|
6970
6988
|
});
|
|
6971
6989
|
log.coalesce(
|
|
@@ -6976,7 +6994,9 @@ function createTestRoom(options) {
|
|
|
6976
6994
|
};
|
|
6977
6995
|
const startFire = (weapon, at, fire2, impact) => {
|
|
6978
6996
|
fluids.splash("fuel", [at[0], Math.max(at[1], groundAt(at[0], at[2])), at[2]], 0.5);
|
|
6979
|
-
|
|
6997
|
+
const zone = { point: [at[0], Math.max(0.02, groundAt(at[0], at[2])), at[2]], radius: fire2.radius, temperature: fire2.temperature, remaining: fire2.seconds, acc: 0 };
|
|
6998
|
+
fireZones.push(zone);
|
|
6999
|
+
poolFire(zone.point, true);
|
|
6980
7000
|
renderer.emit("fire", at, [0, 1, 0], 24, 3);
|
|
6981
7001
|
action("molotov_fire", t("act.molotov_fire", { weapon: toolName(weapon), seconds: num(fire2.seconds, 0), radius: num(fire2.radius, 1) }), { data: { weapon, impact } });
|
|
6982
7002
|
};
|
|
@@ -8114,6 +8134,7 @@ function createTestRoom(options) {
|
|
|
8114
8134
|
loading,
|
|
8115
8135
|
addView: (view) => moduleViews.add(view),
|
|
8116
8136
|
setViewCamera: (view) => moduleViews.setMain(view ?? null),
|
|
8137
|
+
holdPlayer: (held) => player.setWalkHeld(held),
|
|
8117
8138
|
...options.blastShove ? { blastShove: options.blastShove } : {},
|
|
8118
8139
|
blastReach: (point, target, ignore) => world.blastReach(point, target, ignore ? { ignore } : {}),
|
|
8119
8140
|
tool: () => ({
|