@adatechnology/game-weapons-three 0.21.6 → 0.22.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/{chunk-O5SQTNFW.js → chunk-5M3ANYC5.js} +74 -4
- package/dist/chunk-5M3ANYC5.js.map +1 -0
- package/dist/index.d.ts +15 -3
- package/dist/index.global.js +434 -52
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/{testing-CyfMbH0P.d.ts → testing-CocgzbYC.d.ts} +4 -1
- package/dist/testing.d.ts +1 -1
- package/dist/testing.js +1 -1
- package/package.json +10 -10
- package/dist/chunk-O5SQTNFW.js.map +0 -1
|
@@ -13822,6 +13822,7 @@ function weaponThumbnailUrl(id, base = DEFAULT_THUMBNAIL_BASE) {
|
|
|
13822
13822
|
}
|
|
13823
13823
|
|
|
13824
13824
|
// src/world-explosives.ts
|
|
13825
|
+
import { markShared as markShared4 } from "@adatechnology/game-shapes-three";
|
|
13825
13826
|
var WORLD_EXPLOSIVE_PREFIX = "world_";
|
|
13826
13827
|
var P13_VALVE_MESH = "valve";
|
|
13827
13828
|
var P13_VALVE_COLOR = 12095802;
|
|
@@ -13895,6 +13896,25 @@ var worldExplosiveShell = (THREE, defId, items) => {
|
|
|
13895
13896
|
model.name = `${WORLD_EXPLOSIVE_PREFIX}${defId}_shell`;
|
|
13896
13897
|
return model;
|
|
13897
13898
|
};
|
|
13899
|
+
var createWorldExplosiveShells = (THREE, defId, items) => {
|
|
13900
|
+
const model = worldExplosiveShell(THREE, defId, items);
|
|
13901
|
+
const geometries = /* @__PURE__ */ new Set();
|
|
13902
|
+
const materials = /* @__PURE__ */ new Set();
|
|
13903
|
+
model?.traverse((node) => {
|
|
13904
|
+
const mesh = node;
|
|
13905
|
+
if (!mesh.isMesh) return;
|
|
13906
|
+
geometries.add(mesh.geometry);
|
|
13907
|
+
for (const material of Array.isArray(mesh.material) ? mesh.material : [mesh.material]) materials.add(material);
|
|
13908
|
+
});
|
|
13909
|
+
markShared4(...geometries, ...materials);
|
|
13910
|
+
return {
|
|
13911
|
+
next: () => model?.clone(),
|
|
13912
|
+
dispose() {
|
|
13913
|
+
for (const geometry of geometries) geometry.dispose();
|
|
13914
|
+
for (const material of materials) material.dispose();
|
|
13915
|
+
}
|
|
13916
|
+
};
|
|
13917
|
+
};
|
|
13898
13918
|
var worldExplosiveItem = (def, name, options = {}) => {
|
|
13899
13919
|
const shape = SHAPES2[def.id];
|
|
13900
13920
|
if (!shape) return void 0;
|
|
@@ -14677,6 +14697,7 @@ function createExplosivesBench(options) {
|
|
|
14677
14697
|
const vessels = /* @__PURE__ */ new Map();
|
|
14678
14698
|
const wallParts = /* @__PURE__ */ new Set();
|
|
14679
14699
|
const shells = [];
|
|
14700
|
+
let shellModel = null;
|
|
14680
14701
|
const T = () => host?.THREE;
|
|
14681
14702
|
const now = () => room?.world.time ?? 0;
|
|
14682
14703
|
const say = (message, data = {}) => host?.log(message, { source: EXPLOSIVES_AREA_ID, ...data });
|
|
@@ -14783,7 +14804,7 @@ function createExplosivesBench(options) {
|
|
|
14783
14804
|
const launchShell = (vessel, point) => {
|
|
14784
14805
|
const config = def.shell;
|
|
14785
14806
|
if (!config || !host) return;
|
|
14786
|
-
const mesh =
|
|
14807
|
+
const mesh = shellModel?.next();
|
|
14787
14808
|
if (!mesh) return;
|
|
14788
14809
|
mesh.position.set(point[0], Math.max(point[1], 0.3), point[2]);
|
|
14789
14810
|
host.scene.add(mesh);
|
|
@@ -15128,6 +15149,7 @@ function createExplosivesBench(options) {
|
|
|
15128
15149
|
],
|
|
15129
15150
|
attach(lent) {
|
|
15130
15151
|
host = lent;
|
|
15152
|
+
if (def.shell) shellModel = createWorldExplosiveShells(T(), def.id, options.items);
|
|
15131
15153
|
const offs = [];
|
|
15132
15154
|
if (room) {
|
|
15133
15155
|
offs.push(room.world.on("*", onEvent));
|
|
@@ -15158,6 +15180,8 @@ function createExplosivesBench(options) {
|
|
|
15158
15180
|
for (const vessel of vessels.values()) clearRings(vessel);
|
|
15159
15181
|
vessels.clear();
|
|
15160
15182
|
clearShells();
|
|
15183
|
+
shellModel?.dispose();
|
|
15184
|
+
shellModel = null;
|
|
15161
15185
|
host = null;
|
|
15162
15186
|
};
|
|
15163
15187
|
},
|
|
@@ -15174,6 +15198,40 @@ function createExplosivesBench(options) {
|
|
|
15174
15198
|
|
|
15175
15199
|
// src/test-area/explosives-scenarios.ts
|
|
15176
15200
|
import { blastBodySpeed, DEFAULT_BLAST_IMPULSE } from "@adatechnology/game-contracts";
|
|
15201
|
+
|
|
15202
|
+
// src/test-area/torn-body.ts
|
|
15203
|
+
function boxesCentre(boxes) {
|
|
15204
|
+
if (boxes.length === 0) return void 0;
|
|
15205
|
+
const low = [Infinity, Infinity, Infinity];
|
|
15206
|
+
const high = [-Infinity, -Infinity, -Infinity];
|
|
15207
|
+
for (const box2 of boxes) {
|
|
15208
|
+
for (let axis = 0; axis < 3; axis++) {
|
|
15209
|
+
low[axis] = Math.min(low[axis], box2[axis]);
|
|
15210
|
+
high[axis] = Math.max(high[axis], box2[axis + 3]);
|
|
15211
|
+
}
|
|
15212
|
+
}
|
|
15213
|
+
return [(low[0] + high[0]) / 2, (low[1] + high[1]) / 2, (low[2] + high[2]) / 2];
|
|
15214
|
+
}
|
|
15215
|
+
function tornBodyShift(before, after) {
|
|
15216
|
+
let mass = 0;
|
|
15217
|
+
const from = [0, 0];
|
|
15218
|
+
const to = [0, 0];
|
|
15219
|
+
for (const [key, first] of before) {
|
|
15220
|
+
const second = after.get(key);
|
|
15221
|
+
const start = boxesCentre(first.boxes);
|
|
15222
|
+
const end = second ? boxesCentre(second.boxes) : void 0;
|
|
15223
|
+
if (!start || !end || first.mass <= 0) continue;
|
|
15224
|
+
mass += first.mass;
|
|
15225
|
+
from[0] += start[0] * first.mass;
|
|
15226
|
+
from[1] += start[2] * first.mass;
|
|
15227
|
+
to[0] += end[0] * first.mass;
|
|
15228
|
+
to[1] += end[2] * first.mass;
|
|
15229
|
+
}
|
|
15230
|
+
if (mass === 0) return void 0;
|
|
15231
|
+
return Math.hypot((to[0] - from[0]) / mass, (to[1] - from[1]) / mass);
|
|
15232
|
+
}
|
|
15233
|
+
|
|
15234
|
+
// src/test-area/explosives-scenarios.ts
|
|
15177
15235
|
var TORCH_WINDOW = [0.7, 1];
|
|
15178
15236
|
var BLAST_WITHIN = 1.6;
|
|
15179
15237
|
var CYLINDER_ITEM = `${WORLD_EXPLOSIVE_PREFIX}propane_p13`;
|
|
@@ -15247,6 +15305,13 @@ function pushScenario(all, bench, mode) {
|
|
|
15247
15305
|
origin.set(body.objectId, body.from);
|
|
15248
15306
|
}
|
|
15249
15307
|
const partsBefore = new Map(placed.map((body) => [body.objectId, partsOf(body.objectId)]));
|
|
15308
|
+
const partPlaces = (objectId, keep = () => true) => (room.world.state(objectId)?.parts ?? []).filter(keep).map((part) => [part, { mass: part.mass, boxes: room.renderer.shownBoxes?.(objectId, part.id) ?? [] }]);
|
|
15309
|
+
const heavyBefore = new Map(placed.filter((body) => HEAVY_ITEMS.includes(body.kind)).map((body) => [body.objectId, new Map(partPlaces(body.objectId))]));
|
|
15310
|
+
const heavyShift = (objectId) => {
|
|
15311
|
+
const before = heavyBefore.get(objectId);
|
|
15312
|
+
if (!before) return void 0;
|
|
15313
|
+
return tornBodyShift(before, new Map(room.world.ids().flatMap((id) => partPlaces(id, (part) => before.has(part)))));
|
|
15314
|
+
};
|
|
15250
15315
|
expect(placed.length > 0, fillText2(text.push_found, { n: placed.length, kinds: [...new Set(placed.map((body) => body.kind))].join(", ") }), { placed: placed.map((body) => body.itemId) });
|
|
15251
15316
|
const aimOf = new Map(
|
|
15252
15317
|
placed.map((body) => {
|
|
@@ -15323,7 +15388,10 @@ function pushScenario(all, bench, mode) {
|
|
|
15323
15388
|
expect(row.outward <= most, fillText2(text.push_person_wave, { who: things[row.kind] ?? row.kind, distance: row.distance.toFixed(1), moved: Math.max(0, row.outward).toFixed(2), most: most.toFixed(2) }), { row: { kind: row.kind, distance: row.distance, outward: row.outward, speed, most } });
|
|
15324
15389
|
}
|
|
15325
15390
|
const table = rows.find((row) => HEAVY_ITEMS.includes(row.kind) && row.distance < blast.radius * 0.85);
|
|
15326
|
-
if (table)
|
|
15391
|
+
if (table) {
|
|
15392
|
+
const moved = heavyShift(table.objectId) ?? table.moved;
|
|
15393
|
+
expect(moved >= MOVED, fillText2(text.push_heavy, { what: things[table.itemId] ?? table.itemId, moved: moved.toFixed(2) }), { table, moved, rootMoved: table.moved });
|
|
15394
|
+
}
|
|
15327
15395
|
}
|
|
15328
15396
|
};
|
|
15329
15397
|
}
|
|
@@ -15422,7 +15490,8 @@ var DEFAULT_EXPLOSIVES_SCENE = {
|
|
|
15422
15490
|
{ item: "fridge", at: [-1.65, 0, -10.55] },
|
|
15423
15491
|
{ item: "kitchen_cabinet_base", at: [-0.78, 0, -10.6] },
|
|
15424
15492
|
{ item: "stove", at: [0.72, 0, -10.58] },
|
|
15425
|
-
|
|
15493
|
+
// on open floor in the blast's sight, off the paving along the wall: the slabs a blast leaves fixed beyond the stretch it breaks (since #281) held the table's legs out of its reach
|
|
15494
|
+
{ item: "camp_table", at: [1.82, 0, -8.52], rotationY: Math.PI / 2 }
|
|
15426
15495
|
],
|
|
15427
15496
|
cylinder: [0.02, 0, -10.66],
|
|
15428
15497
|
zombie: { item: "zombie_walker", at: [-1.6, 0, -8.1] },
|
|
@@ -15545,6 +15614,7 @@ export {
|
|
|
15545
15614
|
WORLD_EXPLOSIVE_IDS,
|
|
15546
15615
|
worldExplosiveValve,
|
|
15547
15616
|
worldExplosiveShell,
|
|
15617
|
+
createWorldExplosiveShells,
|
|
15548
15618
|
worldExplosiveItem,
|
|
15549
15619
|
WORLD_EFFECTS,
|
|
15550
15620
|
createWorldEffects,
|
|
@@ -15559,4 +15629,4 @@ export {
|
|
|
15559
15629
|
DEFAULT_EXPLOSIVES_SCENE,
|
|
15560
15630
|
createExplosivesTestModule
|
|
15561
15631
|
};
|
|
15562
|
-
//# sourceMappingURL=chunk-
|
|
15632
|
+
//# sourceMappingURL=chunk-5M3ANYC5.js.map
|