@adatechnology/game-items-three 0.11.5 → 0.11.7

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.
@@ -573,12 +573,12 @@ var GameItemsThree = (() => {
573
573
  }
574
574
  return pack("TorusGeometry", parameters, { vertices, normals, uvs, indices, groups: [] });
575
575
  }
576
- function difference(size, subtract) {
576
+ function difference(size, subtract2) {
577
577
  const [w, h, d] = size;
578
578
  const hw = w / 2;
579
579
  const hh = h / 2;
580
580
  const hd = d / 2;
581
- const holes = subtract.map((hole) => ({ x0: Math.max(-hw, Math.min(hole.min[0], hole.max[0])), x1: Math.min(hw, Math.max(hole.min[0], hole.max[0])), y0: Math.max(-hh, Math.min(hole.min[1], hole.max[1])), y1: Math.min(hh, Math.max(hole.min[1], hole.max[1])) })).filter((hole) => hole.x1 > hole.x0 && hole.y1 > hole.y0);
581
+ const holes = subtract2.map((hole) => ({ x0: Math.max(-hw, Math.min(hole.min[0], hole.max[0])), x1: Math.min(hw, Math.max(hole.min[0], hole.max[0])), y0: Math.max(-hh, Math.min(hole.min[1], hole.max[1])), y1: Math.min(hh, Math.max(hole.min[1], hole.max[1])) })).filter((hole) => hole.x1 > hole.x0 && hole.y1 > hole.y0);
582
582
  const cuts = (lo, hi, values) => [.../* @__PURE__ */ new Set([lo, hi, ...values.filter((v) => v > lo && v < hi)])].sort((a, b) => a - b);
583
583
  const xs = cuts(-hw, hw, holes.flatMap((hole) => [hole.x0, hole.x1]));
584
584
  const ys = cuts(-hh, hh, holes.flatMap((hole) => [hole.y0, hole.y1]));
@@ -15222,6 +15222,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15222
15222
  heatCapacity: 1.5,
15223
15223
  thermalShockC: 200
15224
15224
  },
15225
+ visual: {
15226
+ innerColor: 13148794
15227
+ },
15225
15228
  tags: [
15226
15229
  "ceramic",
15227
15230
  "brittle"
@@ -15519,7 +15522,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15519
15522
  },
15520
15523
  visual: {
15521
15524
  charColor: 855309,
15522
- innerColor: 15254346
15525
+ innerColor: 14271631
15523
15526
  },
15524
15527
  tags: [
15525
15528
  "fabric",
@@ -16348,6 +16351,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16348
16351
  return { ...base2, mesh: { vertices, indices: piece3.mesh.indices } };
16349
16352
  };
16350
16353
  var THIN_SHEET_DISHING = 5e-3;
16354
+ var TEAR_CALIBERS = 1.1;
16351
16355
  var SHELL_YIELD_SHARE = 0.5;
16352
16356
  var STEEL_YIELD_MPA = 250;
16353
16357
  var SWEEP_BACK = 0.01;
@@ -16417,9 +16421,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16417
16421
  var SURFACE_SAME = 5e-4;
16418
16422
  var SEVER_ASPECT = 3;
16419
16423
  var SEVER_BALLISTIC = 2;
16424
+ var SEVER_TRACK = 4;
16420
16425
  var TEAR_JOULES = 150;
16421
16426
  var STRIP_THICKNESS = 15e-4;
16422
- var tears = 0;
16423
16427
  var UNIT_FRAGMENT_FACTOR = 4;
16424
16428
  var BREACH_GRID_CAP = 4096;
16425
16429
  var MASONRY_CRUMBLE_SPEED = 0.6;
@@ -16440,7 +16444,16 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16440
16444
  var MAX_PLASTER_FLAKES = 24;
16441
16445
  var CHIP_ENERGY = 200;
16442
16446
  var CHIP_SPLASH = 0.5;
16447
+ var SHARD_CUT = [0.3, 0.7];
16448
+ var MORTAR_JOINT = 0.01;
16449
+ var MIN_UNIT_SHARE = 0.8;
16450
+ var CHIP_DRIVE = 0.6;
16451
+ var BLAST_DRIVE = 2.5;
16443
16452
  var CRATER_SPENT = 0.6;
16453
+ var BONDING_JOINTS = /* @__PURE__ */ new Set(["glue", "mortar", "nail", "screw"]);
16454
+ var PLATE_ASPECT = 0.25;
16455
+ var PLATE_BACK_SHARE = 0.5;
16456
+ var BONDED_REMNANT = 0.25;
16444
16457
  var EDGE_REACH = 1.5;
16445
16458
  var BAR_BOW = 0.08;
16446
16459
  var BULLET_JOINT_SPAN = 0.3;
@@ -16590,6 +16603,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16590
16603
  const rnd = () => rng3.next();
16591
16604
  let time = 0;
16592
16605
  let counter = 0;
16606
+ let tears = 0;
16593
16607
  const objects = /* @__PURE__ */ new Map();
16594
16608
  const slots = /* @__PURE__ */ new Map();
16595
16609
  let slotCounter = 0;
@@ -18948,6 +18962,34 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18948
18962
  };
18949
18963
  const isTrim = (p) => (p.spec.structure?.role ?? "none") === "none";
18950
18964
  const fixesTrim = (o, j) => isTrim(o.parts[j.ia]) !== isTrim(o.parts[j.ib]);
18965
+ const bondedPlate = (o, p) => isPlateTrim(p) && (o.byPart.get(p.spec.id) ?? []).some((j) => !j.st.open && bondsPlate(o, j));
18966
+ const isPlateTrim = (p) => {
18967
+ if (!isTrim(p) || p.spec.units || p.spec.reinforcement || p.mat.ductility >= 0.5 || p.mat.fracture === "none" || p.mat.tags?.includes("glass") === true || p.spec.shape.kind !== "box") return false;
18968
+ const [u, v] = planeAxes(p.thin);
18969
+ return p.dims[p.thin] <= PLATE_ASPECT * Math.min(p.dims[u], p.dims[v]) && gridOf(p).length >= 2;
18970
+ };
18971
+ const bondsPlate = (o, j) => {
18972
+ if (!BONDING_JOINTS.has(j.spec.kind)) return false;
18973
+ const a = o.parts[j.ia], b = o.parts[j.ib];
18974
+ return isPlateTrim(a) && !isTrim(b) && backOn(a, b) || isPlateTrim(b) && !isTrim(a) && backOn(b, a);
18975
+ };
18976
+ const backOn = (plate, carrier) => {
18977
+ const A = aabbOf(plate.spec.shape, plate.spec.position, plate.q);
18978
+ const B = aabbOf(carrier.spec.shape, carrier.spec.position, carrier.q);
18979
+ const face = (k) => (Math.min(A.max[k], B.max[k]) - Math.max(A.min[k], B.min[k])) / Math.max(A.max[k] - A.min[k], 1e-9);
18980
+ const sides = [0, 1, 2].sort((x, y) => A.max[y] - A.min[y] - (A.max[x] - A.min[x])).slice(0, 2);
18981
+ return sides.every((k) => face(k) >= PLATE_BACK_SHARE);
18982
+ };
18983
+ const bondedShareLeft = (p) => {
18984
+ const whole2 = p.st.mass + (p.rt.removed ?? 0);
18985
+ return whole2 > 0 ? p.st.mass / whole2 : 0;
18986
+ };
18987
+ const settleBonded = (o, p, origin, dir, src) => {
18988
+ if (isLost(p)) return;
18989
+ const share = bondedShareLeft(p);
18990
+ p.st.hp = Math.max(1, Math.min(p.st.hp, p.st.maxHp * share));
18991
+ if (share < BONDED_REMNANT) failPart(o, p, origin, dir, 0, 4, src);
18992
+ };
18951
18993
  const holdsEmbedded = (o, j) => {
18952
18994
  const a = o.parts[j.ia], b = o.parts[j.ib];
18953
18995
  return a.embedded === true && a.spec.hostedIn === b.spec.id && a.st.exposed !== true || b.embedded === true && b.spec.hostedIn === a.spec.id && b.st.exposed !== true;
@@ -18965,6 +19007,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
18965
19007
  if (j.st.open) continue;
18966
19008
  if (j.spec.kind === "rebar" && (isReinforced(o.parts[j.ia].spec) || isReinforced(o.parts[j.ib].spec))) continue;
18967
19009
  if (holdsEmbedded(o, j)) continue;
19010
+ if (bondsPlate(o, j)) continue;
18968
19011
  if (near && jointReach(o, j, near) > Math.max(radius, jointReachLimit(o, j))) continue;
18969
19012
  if (blast && fixesTrim(o, j) && jointReach(o, j, blast.point) > Math.max(blast.reach, jointReachLimit(o, j))) continue;
18970
19013
  j.st.hp -= span === void 0 ? amount : Math.min(amount, j.st.maxHp) * Math.min(1, span / Math.max(jointLength(o, j), 1e-6));
@@ -19004,19 +19047,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19004
19047
  emit({ ...base2(o, src), type: "spall", part: p.spec.id, layer: torn.layer.index, point: centre, area: Math.PI * r * r, ...spallNormal(o, p, s[1]) });
19005
19048
  debris(o, p, torn.layer.mat.hitDebris, toWorld(o.st.position, o.st.rotation, lp), normal, 5, 2, src, torn.layer.mat.id);
19006
19049
  };
19007
- const spallOuter = (o, p, wp, face, normal, radius, src) => {
19050
+ const spallOuter = (o, p, wp, face, normal, radius, src, tearRadius = radius) => {
19008
19051
  var _a;
19009
19052
  if (p.layers.length === 0) return;
19010
19053
  const lp = objLocal(o, wp);
19011
19054
  const torn = tornPatchAt(p.layers, p.rt.spalls, face, lp, radius);
19012
- if (torn) return widenTear(o, p, torn, lp, normal, radius, src);
19055
+ if (torn) return widenTear(o, p, torn, lp, normal, tearRadius, src);
19013
19056
  const layer = outerLayer(p.layers, p.rt.spalls, face, lp);
19014
19057
  if (!layer) return;
19058
+ const patch = layer.mat.fracture === "tear" ? tearRadius : radius;
19015
19059
  const spalls = (_a = p.rt).spalls ?? (_a.spalls = []);
19016
- spalls.push([layer.index, face, lp[0], lp[1], lp[2], radius]);
19060
+ spalls.push([layer.index, face, lp[0], lp[1], lp[2], patch]);
19017
19061
  if (spalls.length > MAX_SPALLS) spalls.shift();
19018
19062
  markDamaged(p);
19019
- emit({ ...base2(o, src), type: "spall", part: p.spec.id, layer: layer.index, point: wp, area: Math.PI * radius * radius, ...spallNormal(o, p, face) });
19063
+ emit({ ...base2(o, src), type: "spall", part: p.spec.id, layer: layer.index, point: wp, area: Math.PI * patch * patch, ...spallNormal(o, p, face) });
19020
19064
  debris(o, p, layer.mat.hitDebris, wp, normal, 5, 2, src, layer.mat.id);
19021
19065
  setStage(o, p, 1, {}, src);
19022
19066
  };
@@ -19056,7 +19100,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19056
19100
  return first && first.size[u] > size[0] + 1e-6 ? [first.size[u], first.size[v]] : [Math.min(size[0], p.dims[u]), Math.min(size[1], p.dims[v])];
19057
19101
  };
19058
19102
  const FRAGMENT_SHAPE = { shatter: "shard", splinter: "splinter", tear: "scrap" };
19059
- const cellFragments = (o, p, cells, hitW, dir, speed, mass, tag, inner = false, knownHoles) => {
19103
+ const shardsOfCell = (cell, u, v) => {
19104
+ const own = createRng(seedOf2(cell.center[0], cell.center[1], cell.center[2]));
19105
+ const cu = SHARD_CUT[0] + (SHARD_CUT[1] - SHARD_CUT[0]) * own.next(), cv = SHARD_CUT[0] + (SHARD_CUT[1] - SHARD_CUT[0]) * own.next();
19106
+ const out = [];
19107
+ for (const [a0, a1] of [[0, cu], [cu, 1]]) for (const [b0, b1] of [[0, cv], [cv, 1]]) {
19108
+ const size = [cell.size[0], cell.size[1], cell.size[2]];
19109
+ const center = [cell.center[0], cell.center[1], cell.center[2]];
19110
+ size[u] = cell.size[u] * (a1 - a0);
19111
+ size[v] = cell.size[v] * (b1 - b0);
19112
+ center[u] = cell.center[u] - cell.size[u] / 2 + cell.size[u] * (a0 + a1) / 2;
19113
+ center[v] = cell.center[v] - cell.size[v] / 2 + cell.size[v] * (b0 + b1) / 2;
19114
+ out.push({ ...cell, center, size });
19115
+ }
19116
+ return out;
19117
+ };
19118
+ const cellFragments = (o, p, cells, hitW, dir, speed, mass, tag, inner = false, knownHoles, drive = CHIP_DRIVE) => {
19060
19119
  const { c, q } = partXf(o, p);
19061
19120
  const holes = knownHoles ?? (p.st.holes.length > 0 ? localHolesOf(p) : []);
19062
19121
  const [u, v] = planeAxes(p.thin);
@@ -19064,19 +19123,22 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19064
19123
  const total = cells.reduce((sum, cell) => sum + faceArea(cell), 0) || 1;
19065
19124
  const shape = p.spec.units ? "chunk" : FRAGMENT_SHAPE[p.mat.fracture] ?? "chunk";
19066
19125
  const laid = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
19067
- return cells.map((cell, i) => {
19126
+ const pieces = shape === "shard" && bondedPlate(o, p) ? cells.flatMap((cell) => shardsOfCell(cell, u, v)) : cells;
19127
+ return pieces.map((cell, i) => {
19068
19128
  const cw = toWorld(c, q, cell.center);
19069
19129
  const out = vec.normalize(vec.sub(cw, hitW), [0, 1, 0]);
19070
- const dv = dir ? vec.normalize(vec.madd(out, dir, 0.6)) : out;
19130
+ const dv = dir ? vec.normalize(vec.madd(out, dir, drive)) : out;
19071
19131
  const k = speed * (0.6 + 0.8 * rnd());
19072
19132
  const marks = marksInBox(cell.center, cell.size, void 0, holes);
19133
+ const size = [cell.size[0], cell.size[1], cell.size[2]];
19134
+ if (laid) for (const a of [u, v]) size[a] = Math.max(size[a] * MIN_UNIT_SHARE, size[a] - MORTAR_JOINT);
19073
19135
  return {
19074
19136
  id: `${p.spec.id}#${tag}${i}`,
19075
19137
  part: p.spec.id,
19076
19138
  material: p.spec.material,
19077
19139
  shape,
19078
19140
  center: cw,
19079
- size: [cell.size[0], cell.size[1], cell.size[2]],
19141
+ size,
19080
19142
  rotation: q,
19081
19143
  velocity: [dv[0] * k, dv[1] * k + 0.5 * rnd(), dv[2] * k],
19082
19144
  angularVelocity: bornSpin(cell.size, 8, rnd),
@@ -19327,7 +19389,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19327
19389
  };
19328
19390
  const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
19329
19391
  var _a, _b, _c;
19330
- if (!p.spec.units || !p.staged || chipEnergy <= 0 || p.st.stripped || isLost(p) || (p.st.stage ?? 0) >= 2) return;
19392
+ const bonded = bondedPlate(o, p);
19393
+ if (!bonded && (!p.spec.units || !p.staged) || chipEnergy <= 0 || p.st.stripped || isLost(p) || (p.st.stage ?? 0) >= 2) return;
19331
19394
  const rule = p.mat.hits?.[kind];
19332
19395
  const perKg = rule?.unitJoules ?? chipEnergy;
19333
19396
  const energy = hitEnergy - (rule?.floor ?? 0);
@@ -19401,6 +19464,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19401
19464
  if (Object.values(worn).filter((w) => w === -1).length > wholeBefore) dropUnsupported(o, p, src);
19402
19465
  if (p.spec.reinforcement) exposeRebar(o, p, src);
19403
19466
  for (const cell of out) addBreach(o, p, toWorld(c, q, cell.center), cell.size[u] * cell.size[v], energy, dir, src);
19467
+ if (bonded) settleBonded(o, p, wp, dir, src);
19404
19468
  if (p.structural && !isLost(p)) {
19405
19469
  solveStructure(o);
19406
19470
  collapseCheck(o, src);
@@ -19516,18 +19580,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19516
19580
  if (p.structural) solveStructure(o);
19517
19581
  };
19518
19582
  const blastReachOf = (p, energy) => {
19519
- const perKg = p.mat.hits?.blunt?.unitJoules ?? chipEnergy;
19520
- const resistance = Math.max(1, perKg * p.mat.density * p.thickness);
19583
+ const resistance = Math.max(1, (p.mat.hits?.blunt?.unitJoules ?? chipEnergy) * p.mat.density * p.thickness);
19521
19584
  return BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3) * clamp2(Math.cbrt(BLAST_REFERENCE_RESISTANCE / resistance), 0.3, 2);
19522
19585
  };
19523
- const blastUnits = (o, p, wp, energy, dist, src) => {
19586
+ const blastUnits = (o, p, wp, energy, dist, src, from) => {
19524
19587
  var _a;
19525
- if (!p.staged || p.st.stripped || isLost(p) || chipEnergy <= 0) return false;
19588
+ if (!p.staged && !bondedPlate(o, p) || p.st.stripped || isLost(p) || chipEnergy <= 0) return false;
19526
19589
  const reach2 = blastReachOf(p, energy);
19527
19590
  if (dist >= reach2) return false;
19528
- const radius = Math.sqrt(reach2 * reach2 - dist * dist);
19529
19591
  const [u, v] = planeAxes(p.thin);
19530
- const lp = toLocal(p.pos, p.q, objLocal(o, wp));
19592
+ const charge = from ? toLocal(p.pos, p.q, objLocal(o, from)) : null;
19593
+ const lp = charge ?? toLocal(p.pos, p.q, objLocal(o, wp));
19594
+ const off = charge ? Math.max(0, Math.abs(charge[p.thin]) - p.dims[p.thin] / 2) : dist;
19595
+ const radius = Math.sqrt(Math.max(0, reach2 * reach2 - off * off));
19531
19596
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
19532
19597
  const grid = gridOf(p);
19533
19598
  const worn = (_a = p.rt).chips ?? (_a.chips = {});
@@ -19551,7 +19616,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19551
19616
  }
19552
19617
  }
19553
19618
  if (out.length === 0) return false;
19554
- return knockOutUnits(o, p, wp, energy, out, src);
19619
+ return knockOutUnits(o, p, wp, energy, out, src, from ? awayFromCharge(o, p, from) : void 0, BLAST_DRIVE);
19620
+ };
19621
+ const awayFromCharge = (o, p, charge) => {
19622
+ const axis = [0, 0, 0];
19623
+ axis[p.thin] = toLocal(p.pos, p.q, objLocal(o, charge))[p.thin] >= 0 ? -1 : 1;
19624
+ return rotateVec(partXf(o, p).q, axis);
19555
19625
  };
19556
19626
  const wedgedUnder = (o, p, loose) => {
19557
19627
  if (loose.length === 0) return loose;
@@ -19643,7 +19713,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19643
19713
  for (const i of out) worn[i] = -1;
19644
19714
  return knockOutUnits(o, p, point, energy, out, src);
19645
19715
  };
19646
- const knockOutUnits = (o, p, wp, energy, out, src, d) => {
19716
+ const knockOutUnits = (o, p, wp, energy, out, src, d, drive = CHIP_DRIVE) => {
19647
19717
  var _a, _b;
19648
19718
  const [u, v] = planeAxes(p.thin);
19649
19719
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
@@ -19653,7 +19723,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19653
19723
  out = out.filter((i) => !castHere.has(i));
19654
19724
  if (out.length === 0) return false;
19655
19725
  for (const i of out) worn[i] = -1;
19656
- const cast = p.spec.units?.mortar === p.spec.material;
19726
+ const bonded = bondedPlate(o, p);
19727
+ const cast = p.spec.units?.mortar === p.spec.material || bonded;
19657
19728
  const loose = cast ? [] : wedgedUnder(o, p, unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !(op && p.st.opening && Math.hypot(grid[i].center[u] - op[u], grid[i].center[v] - op[v]) <= p.st.opening.radius))).filter((i) => !castHere.has(i));
19658
19729
  for (const i of loose) worn[i] = -1;
19659
19730
  const blown = out.map((i) => grid[i]), fallen = loose.map((i) => grid[i]);
@@ -19666,7 +19737,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19666
19737
  const tag = `x${chipped.length}_`;
19667
19738
  const holes = localHolesOf(p);
19668
19739
  const fragments = [
19669
- ...cellFragments(o, p, clumpUnits(blown, p.thin, unitSpan(p), unitClumps), wp, null, speed, blownMass, tag, true, holes),
19740
+ ...cellFragments(o, p, clumpUnits(blown, p.thin, unitSpan(p), unitClumps), wp, d ?? null, speed, blownMass, tag, true, holes, drive),
19670
19741
  ...fallen.length > 0 ? cellFragments(o, p, clumpUnits(fallen, p.thin, unitSpan(p), fallenClumps), wp, null, 0.3, fallenMass, `${tag}f`, true, holes) : [],
19671
19742
  ...plasterFlakes(o, p, blown, wp, speed, `${tag}p`)
19672
19743
  ];
@@ -19691,6 +19762,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19691
19762
  debris(o, p, p.mat.breakDebris, center, vec.normalize(vec.sub(center, wp), [0, 1, 0]), 14, 3, src);
19692
19763
  const cut = wornLocally(p) && cutBandsGone(o, p, cells, d ?? vec.normalize(vec.sub(partXf(o, p).c, wp), [1, 0, 0]), src);
19693
19764
  if (p.spec.reinforcement && !cut) exposeRebar(o, p, src);
19765
+ if (bonded) settleBonded(o, p, wp, d ?? null, src);
19694
19766
  if (p.structural && !isLost(p)) {
19695
19767
  solveStructure(o);
19696
19768
  collapseCheck(o, src);
@@ -19998,13 +20070,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19998
20070
  const order2 = [0, 1, 2].sort((a, b) => d[b] - d[a]);
19999
20071
  return d[order2[0]] >= SEVER_ASPECT * d[order2[1]] && d[order2[0]] >= 3 * SEVER_BAND ? order2[0] : -1;
20000
20072
  };
20073
+ const roundSection = (o, p, d, holeWidth, depth) => {
20074
+ const axis = severAxis(p);
20075
+ if (axis < 0) return 1;
20076
+ const local = rotateVec(quat.conjugate(partXf(o, p).q), d);
20077
+ const [a, b] = [0, 1, 2].filter((k) => k !== axis);
20078
+ const across2 = Math.abs(local[a]) >= Math.abs(local[b]) ? p.dims[b] : p.dims[a];
20079
+ return Math.min(1, SEVER_TRACK * holeWidth / Math.max(across2, 1e-6)) * clamp2(depth, 0, 1);
20080
+ };
20001
20081
  const bandOf = (o, p, axis, origin) => {
20002
20082
  const { c, q } = partXf(o, p);
20003
20083
  const along2 = toLocal(c, q, origin)[axis];
20004
20084
  const L = p.dims[axis];
20005
20085
  return clamp2(Math.floor((along2 + L / 2) / SEVER_BAND), 0, Math.ceil(L / SEVER_BAND) - 1);
20006
20086
  };
20007
- const applyDamage = (o, p, amount, type, origin, dir, fragEnergy, cap, src, weight = 1) => {
20087
+ const applyDamage = (o, p, amount, type, origin, dir, fragEnergy, cap, src, weight = 1, section = 1) => {
20008
20088
  var _a;
20009
20089
  if (isLost(p) || amount <= 0) return 0;
20010
20090
  const prev = p.st.hp;
@@ -20013,7 +20093,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20013
20093
  if (axis >= 0 && p.st.hp > 0) {
20014
20094
  const band = bandOf(o, p, axis, origin);
20015
20095
  const cuts = (_a = p.rt).cuts ?? (_a.cuts = {});
20016
- cuts[band] = (cuts[band] ?? 0) + amount * (type === "ballistic" ? SEVER_BALLISTIC : 1);
20096
+ cuts[band] = (cuts[band] ?? 0) + amount * section * (type === "ballistic" ? SEVER_BALLISTIC : 1);
20017
20097
  if (cuts[band] >= p.st.maxHp * SEVER_BAND / p.dims[axis]) {
20018
20098
  p.rt.cutAt = -p.dims[axis] / 2 + (band + 0.5) * SEVER_BAND;
20019
20099
  p.st.hp = 0;
@@ -20025,6 +20105,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20025
20105
  if (chained && p.st.hp <= 0 && p.rt.chainDue === void 0) p.st.hp = Math.min(prev, 1);
20026
20106
  if (p.st.hp <= 0 && p.mat.fracture === "none" && !p.spec.explodes) p.st.hp = Math.min(prev, 1);
20027
20107
  if (p.st.hp <= 0 && type === "ballistic" && wornLocally(p)) p.st.hp = Math.min(prev, 1);
20108
+ if (p.st.hp <= 0 && type !== "fire" && type !== "heat" && bondedPlate(o, p)) p.st.hp = Math.min(prev, 1);
20028
20109
  const done = prev - p.st.hp;
20029
20110
  if (done > 0) emit({ ...base2(o, src), type: "damage", part: p.spec.id, amount: done, hp: Math.max(0, p.st.hp), damageType: type });
20030
20111
  if (p.st.hp <= 0) failPart(o, p, origin, dir, fragEnergy * weight, cap, src);
@@ -20133,19 +20214,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20133
20214
  const dmg2 = applyDamage(o, p, E * DMG_PER_J * scale * 0.2, "ballistic", entry2, d, E * 0.1, 12, src, weight);
20134
20215
  return { penetrated: false, exitEnergy: 0, damage: dmg2 };
20135
20216
  }
20136
- if (p.layers.length > 0) spallOuter(o, p, entry2, face, n, Math.max(0.03, caliber / 1e3 * 4), src);
20217
+ if (p.layers.length > 0) spallOuter(o, p, entry2, face, n, Math.max(0.03, caliber / 1e3 * 4), src, caliber / 1e3 * TEAR_CALIBERS);
20137
20218
  else if (mat.hits?.ballistic?.crater) crater(o, p, entry2, n, clamp2(0.02 + Math.sqrt(E) * 15e-4, 0.02, 0.15), src);
20138
20219
  const brittle = mat.ductility < 0.3;
20139
20220
  const ratio = Ep / Math.max(thr, 1e-6);
20140
20221
  const crackLen = clamp2(0.03 + ratio * 0.2, 0.03, 0.8);
20141
20222
  let exitPoint;
20142
20223
  let shellShare = 0;
20224
+ const holeWidth = caliber / 1e3 * (mat.ductility >= 0.3 ? 1 : 1.5);
20143
20225
  if (penetrated) {
20144
20226
  const exitDist = p.spec.contains || p.spec.fill !== void 0 && p.spec.fill < 0.5 || p.thickness < pathLen * 0.5 ? pathLen : Math.min(pathLen, effM + layersThickness(p.layers, face) / slant + layersThickness(p.layers, -face) / slant);
20145
20227
  exitPoint = vec.madd(entry2, d, exitDist);
20146
- const hole = addHole(o, p, entry2, n, caliber / 1e3 * (mat.ductility >= 0.3 ? 1 : 1.5), true, exitPoint, src);
20228
+ const hole = addHole(o, p, entry2, n, holeWidth, true, exitPoint, src);
20147
20229
  shellShare = wearsShell(p, hole.diameter * 2);
20148
- if (p.layers.length > 0) spallOuter(o, p, exitPoint, -face, vec.scale(n, -1), Math.max(0.03, caliber / 1e3 * 4), src);
20230
+ if (p.layers.length > 0) spallOuter(o, p, exitPoint, -face, vec.scale(n, -1), Math.max(0.03, caliber / 1e3 * 4), src, caliber / 1e3 * TEAR_CALIBERS);
20149
20231
  addBreach(o, p, entry2, Math.PI * (hole.diameter / 2) * (hole.diameter / 2), E, d, src);
20150
20232
  if (mat.ductility >= 0.5 && p.thickness <= THIN_SHEET_DISHING) addDent(o, p, entry2, n, Math.max(caliber * 3 / 1e3, 0.012), clamp2(E * 2e-5, 1e-3, 0.03), src);
20151
20233
  if (brittle && mat.fracture === "shatter") addCrack(o, p, entry2, n, crackLen, src);
@@ -20173,7 +20255,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20173
20255
  wearJoints(o, p, (penetrated ? thr : E) * 0.02 * weight, void 0, 0, src, true, BULLET_JOINT_SPAN);
20174
20256
  const hollowTear = mat.fracture === "tear" && p.spec.fill !== void 0 && p.spec.fill < 0.5;
20175
20257
  const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear || mat.cellular === true) ? Math.min(E, thr) : E;
20176
- const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale, "ballistic", entry2, d, absorbed * 0.1, 12, src, weight);
20258
+ const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale, "ballistic", entry2, d, absorbed * 0.1, 12, src, weight, roundSection(o, p, d, holeWidth, penetrated ? 1 : ratio));
20177
20259
  if (shellShare > 0 && !isLost(p)) yieldShell(o, p, shellShare, entry2, d, src);
20178
20260
  if (!isLost(p)) tearAt(o, p, "ballistic", entry2, penetrated ? exitPoint : void 0, d, E, caliber / 1e3, src);
20179
20261
  if (!wearMember(o, p, entry2, d, E, caliber, penMm, src)) chipUnits(o, p, "ballistic", entry2, penetrated ? Math.min(E, Math.max(thr, E * 0.5)) : E, d, Math.max(0.05, caliber / 1e3 * 8), src);
@@ -20317,13 +20399,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20317
20399
  const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
20318
20400
  const caged2 = Boolean(p.spec.reinforcement && p.spec.units);
20319
20401
  const member = caged2 && (isMember(p.dims, p.spec.structure?.role) || dist > MEMBER_CUT_REACH * breachReach);
20320
- const dealt = member ? applyDamage(o, p, Math.min(amount, Math.max(0, p.st.hp - p.st.maxHp * FAR_MEMBER_HP_FLOOR)), "explosive", null, null, Ein * 0.3, 40, src) : applyDamage(o, p, amount, "explosive", point, null, Ein * 0.3, 40, src);
20402
+ const bonded = bondedPlate(o, p);
20403
+ const dealt = bonded ? applyDamage(o, p, Math.min(amount, Math.max(0, p.st.hp - 1)), "explosive", null, null, Ein * 0.3, 40, src) : member ? applyDamage(o, p, Math.min(amount, Math.max(0, p.st.hp - p.st.maxHp * FAR_MEMBER_HP_FLOOR)), "explosive", null, null, Ein * 0.3, 40, src) : applyDamage(o, p, amount, "explosive", point, null, Ein * 0.3, 40, src);
20321
20404
  res.damage += dealt;
20322
20405
  if (p.bend && flexure.enabled) bendByBlast(o, p, point, energy, radius, reach2, src);
20323
20406
  if (p.spec.units && p.spec.units.mortar !== p.spec.material) {
20324
20407
  blastPanel(o, p, point, energy, src);
20325
- if (!isLost(p)) blastUnits(o, p, wp, energy, dist, src);
20326
- } else if (member) blastUnits(o, p, wp, energy, dist, src);
20408
+ if (!isLost(p)) blastUnits(o, p, wp, energy, dist, src, point);
20409
+ } else if (member || bonded) blastUnits(o, p, wp, energy, dist, src, point);
20327
20410
  else if (dist <= breachReach) addBreach(o, p, wp, breachAreaOf(p, dealt, true), Ein, null, src);
20328
20411
  return reach2;
20329
20412
  };
@@ -21861,6 +21944,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21861
21944
  }).events;
21862
21945
  },
21863
21946
  state: (id) => objects.get(id)?.st ?? impls.get(id)?.impl.state() ?? null,
21947
+ layers: (id, partId) => objects.get(id)?.byId.get(partId)?.spec.layers ?? [],
21864
21948
  anchoredParts: (id) => objects.get(id)?.parts.filter((p) => p.anchored && !isLost(p)).map((p) => p.spec.id) ?? [],
21865
21949
  fixedInPlace: (id) => {
21866
21950
  const o = objects.get(id);
@@ -21897,6 +21981,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21897
21981
  time,
21898
21982
  rng: rng3.state(),
21899
21983
  counter,
21984
+ ...tears > 0 ? { tears } : {},
21900
21985
  objects: [...objects.values()].map(serializeObject),
21901
21986
  ...impls.size ? { impls: [...impls.values()].map((im) => ({ id: im.impl.id, position: [...im.position], rotation: [...im.rotation], data: im.impl.serialize?.() })) } : {}
21902
21987
  };
@@ -21921,6 +22006,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21921
22006
  time = snap.time;
21922
22007
  rng3.set(snap.rng);
21923
22008
  counter = snap.counter ?? 0;
22009
+ tears = snap.tears ?? 0;
21924
22010
  for (const e of snap.objects) putObject(e.id, buildFromEntry(e, e.id));
21925
22011
  for (const e of snap.impls ?? []) {
21926
22012
  const im = impls.get(e.id);
@@ -22410,7 +22496,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22410
22496
  var MIN_PILLAR_AREA = 0.036;
22411
22497
  var BEAM_DEPTH_RATIO = 10;
22412
22498
  var PLASTER_PER_FACE = 0.015;
22413
- var MORTAR_JOINT = 0.01;
22499
+ var MORTAR_JOINT2 = 0.01;
22414
22500
  var SECTION_STEP = 0.05;
22415
22501
  var ceilTo = (value, step) => Math.ceil(value / step - 1e-9) * step;
22416
22502
  var round22 = (value) => Math.round(value * 100) / 100;
@@ -22424,7 +22510,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
22424
22510
  function coursingOf(unitId, assemblyUnits) {
22425
22511
  if (unitId !== void 0) {
22426
22512
  const unit = getMasonryUnit(unitId);
22427
- return { courseHeight: round22(unit.height + MORTAR_JOINT), unitLength: round22(unit.length + MORTAR_JOINT) };
22513
+ return { courseHeight: round22(unit.height + MORTAR_JOINT2), unitLength: round22(unit.length + MORTAR_JOINT2) };
22428
22514
  }
22429
22515
  return assemblyUnits ? { courseHeight: assemblyUnits.size[1], unitLength: assemblyUnits.size[0] } : void 0;
22430
22516
  }
@@ -35731,7 +35817,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
35731
35817
  ],
35732
35818
  estimated: [
35733
35819
  "parts"
35734
- ]
35820
+ ],
35821
+ consumable: {
35822
+ form: "bar",
35823
+ unit: "g",
35824
+ amount: 100,
35825
+ dose: 1.5,
35826
+ emptyKg: 0
35827
+ }
35735
35828
  },
35736
35829
  {
35737
35830
  id: "shampoo",
@@ -35749,7 +35842,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
35749
35842
  stack: 3,
35750
35843
  shape: "bottle",
35751
35844
  color: 4885200,
35752
- rarity: "common"
35845
+ rarity: "common",
35846
+ consumable: {
35847
+ form: "liquid",
35848
+ unit: "ml",
35849
+ amount: 300,
35850
+ dose: 8,
35851
+ emptyKg: 0.044,
35852
+ density: 1.02
35853
+ }
35753
35854
  },
35754
35855
  {
35755
35856
  id: "toothpaste",
@@ -35767,7 +35868,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
35767
35868
  stack: 3,
35768
35869
  shape: "tube",
35769
35870
  color: 15790320,
35770
- rarity: "common"
35871
+ rarity: "common",
35872
+ consumable: {
35873
+ form: "paste",
35874
+ unit: "g",
35875
+ amount: 90,
35876
+ dose: 1,
35877
+ emptyKg: 0.01
35878
+ }
35771
35879
  },
35772
35880
  {
35773
35881
  id: "toothbrush",
@@ -47291,7 +47399,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
47291
47399
  }
47292
47400
  var residentialTower = residentialTowerTemplate();
47293
47401
 
47294
- // ../game-floorplan-three/dist/chunk-XI3CKQAV.js
47402
+ // ../game-floorplan-three/dist/chunk-Y7TCDFDL.js
47295
47403
  var __defProp3 = Object.defineProperty;
47296
47404
  var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
47297
47405
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -57003,6 +57111,25 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57003
57111
  }
57004
57112
  return [...groups.values()];
57005
57113
  };
57114
+ function subtract(boxes, cuts) {
57115
+ let out = [...boxes];
57116
+ for (const k of cuts) {
57117
+ const next = [];
57118
+ for (const b of out) {
57119
+ if (k.a >= b.b - EPSILON22 || k.b <= b.a + EPSILON22 || k.y0 >= b.y1 - EPSILON22 || k.y1 <= b.y0 + EPSILON22) {
57120
+ next.push(b);
57121
+ continue;
57122
+ }
57123
+ const y0 = Math.max(b.y0, k.y0), y1 = Math.min(b.y1, k.y1);
57124
+ if (y0 - b.y0 > EPSILON22) next.push({ a: b.a, b: b.b, y0: b.y0, y1: y0 });
57125
+ if (b.y1 - y1 > EPSILON22) next.push({ a: b.a, b: b.b, y0: y1, y1: b.y1 });
57126
+ if (k.a - b.a > EPSILON22) next.push({ a: b.a, b: k.a, y0, y1 });
57127
+ if (b.b - k.b > EPSILON22) next.push({ a: k.b, b: b.b, y0, y1 });
57128
+ }
57129
+ out = next;
57130
+ }
57131
+ return out;
57132
+ }
57006
57133
  function mergeSpans(spans, share = JOINT_SHARE) {
57007
57134
  const runs = [];
57008
57135
  const unitLengths = /* @__PURE__ */ new Map();
@@ -57053,7 +57180,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57053
57180
  const point = new THREE.Vector3();
57054
57181
  const out = [];
57055
57182
  for (const part of parts2) {
57056
- const boxes = mergeSpans(part.spans);
57183
+ const boxes = part.gone?.length ? subtract(mergeSpans(part.spans), part.gone) : mergeSpans(part.spans);
57057
57184
  for (const s of line.open ? mergeSpans(carve(boxes, line.open), 0) : boxes) {
57058
57185
  const along2 = line.start + (s.a + s.b) / 2;
57059
57186
  point.set(line.alongU ? along2 : part.mid, (s.y0 + s.y1) / 2, line.alongU ? part.mid : along2).applyMatrix4(toMesh);
@@ -57559,11 +57686,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57559
57686
  function publishStanding(view) {
57560
57687
  if (!view.saved) return;
57561
57688
  const { mask } = view;
57689
+ const along2 = (p) => (mask.alongU ? p[0] : p[2]) - mask.start;
57562
57690
  const parts2 = view.parts.map((id) => {
57563
57691
  const part = structure.byId.get(id);
57564
57692
  const thick = mask.alongU ? part.aabb[3] - part.aabb[1] : part.aabb[2] - part.aabb[0];
57565
57693
  const mid = mask.alongU ? (part.aabb[1] + part.aabb[3]) / 2 : (part.aabb[0] + part.aabb[2]) / 2;
57566
- return { spans: view.kept.get(id) ?? [], thick, mid };
57694
+ const gone = (view.chips.get(id) ?? []).map((k) => ({ a: along2(k.center) - k.along, b: along2(k.center) + k.along, y0: k.center[1] - k.up, y1: k.center[1] + k.up }));
57695
+ return { spans: view.kept.get(id) ?? [], gone, thick, mid };
57567
57696
  });
57568
57697
  const line = { alongU: mask.alongU, start: mask.start, open: view.core };
57569
57698
  view.items.forEach((it, k) => publishSolids(it.mesh, it.v0, it.v1, k === 0 ? standingSolids(THREE, house, it.mesh, line, parts2) : []));