@adatechnology/game-test-room 0.30.0 → 0.30.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.
@@ -1480,7 +1480,8 @@ var GameTestRoom = (() => {
1480
1480
  for (const l of layers) if (onFace(l, face)) sum2 += l.def.thickness;
1481
1481
  return sum2;
1482
1482
  };
1483
- var COVER = 0.03;
1483
+ var REBAR_COVER = 0.03;
1484
+ var COVER = REBAR_COVER;
1484
1485
  var MAX_BARS_PER_DIRECTION = 24;
1485
1486
  var MAX_MEMBER_BARS_PER_SIDE = 6;
1486
1487
  var STEEL_DENSITY = 7850;
@@ -3711,6 +3712,10 @@ var GameTestRoom = (() => {
3711
3712
  var PANEL_PI = 6e6;
3712
3713
  var PANEL_POINTS = [[0, 0], [-0.3, 0], [0.3, 0], [0, -0.3], [0, 0.3]];
3713
3714
  var PANEL_POINTS_LOADED = 4;
3715
+ var MEMBER_BAND = 0.1;
3716
+ var MEMBER_CRATER_CALIBRES = 3.4;
3717
+ var MEMBER_BARED_MAX = 24;
3718
+ var MEMBER_CUT_LOSS = 0.9;
3714
3719
  var BLAST_EDGE_WEAR = 0.6;
3715
3720
  var RESIDUAL_CAPACITY = 0.15;
3716
3721
  var SEVER_BAND = 0.1;
@@ -5117,6 +5122,57 @@ var GameTestRoom = (() => {
5117
5122
  const lp = toLocal(p.pos, p.q, objectPoint);
5118
5123
  return cells.some((c) => Math.abs(lp[u] - c.center[u]) <= c.size[u] / 2 && Math.abs(lp[v] - c.center[v]) <= c.size[v] / 2);
5119
5124
  };
5125
+ const wearMember = (o, p, entry, d, E, caliber, penMm, src) => {
5126
+ var _a, _b;
5127
+ if (!p.spec.reinforcement || !p.spec.units || !isMember(p.dims) || p.st.stripped || isLost(p) || p.spec.shape.kind !== "box") return false;
5128
+ const along = p.dims.indexOf(Math.max(...p.dims));
5129
+ const lp = toLocal(p.pos, p.q, objLocal(o, entry));
5130
+ const ld = rotateVec(quat.conjugate(p.q), objLocalDir(o, d));
5131
+ let depth = Infinity;
5132
+ for (let a = 0; a < 3; a++) if (a !== along && Math.abs(ld[a]) > 1e-3) depth = Math.min(depth, p.dims[a] / Math.abs(ld[a]));
5133
+ if (!Number.isFinite(depth)) return true;
5134
+ const into = (penMm ?? E / Math.max(p.mat.penetration, 1e-6)) / 1e3;
5135
+ const h = Math.min(into, depth);
5136
+ const r = Math.min(MEMBER_CRATER_CALIBRES * caliber / 1e3, h);
5137
+ const volume = Math.PI / 3 * r * r * h;
5138
+ const section = p.dims.reduce((product2, size, a) => a === along ? product2 : product2 * size, 1);
5139
+ const bands = Math.max(1, Math.round(p.dims[along] / MEMBER_BAND));
5140
+ const band = clamp2(Math.floor((lp[along] + p.dims[along] / 2) / p.dims[along] * bands), 0, bands - 1);
5141
+ const height = p.dims[along] / bands;
5142
+ const worn = (_a = p.rt).bands ?? (_a.bands = {});
5143
+ const before = worn[band] ?? 0;
5144
+ const after2 = Math.min(1, before + volume / (section * height));
5145
+ worn[band] = after2;
5146
+ markDamaged(p);
5147
+ const bandCenter = -p.dims[along] / 2 + (band + 0.5) * height;
5148
+ if (h > REBAR_COVER && after2 < MEMBER_CUT_LOSS) {
5149
+ const bared = (_b = p.rt).bared ?? (_b.bared = []);
5150
+ const center = [lp[0], lp[1], lp[2]];
5151
+ const size = [p.dims[0], p.dims[1], p.dims[2]];
5152
+ for (let a = 0; a < 3; a++) if (Math.abs(ld[a]) < 0.5) size[a] = 2 * r;
5153
+ if (bared.length < MEMBER_BARED_MAX && !bared.some((box2) => box2.center.every((x, a) => Math.abs(x - center[a]) < box2.size[a] / 4))) {
5154
+ bared.push({ center, size });
5155
+ exposeRebar(o, p, src);
5156
+ }
5157
+ }
5158
+ if (before >= MEMBER_CUT_LOSS || after2 < MEMBER_CUT_LOSS) return true;
5159
+ const axisUp = rotateVec(p.q, [0, 0, 0].map((_, k) => k === along ? 1 : 0));
5160
+ const standing = Math.abs(axisUp[1]) > 0.7;
5161
+ const upward = axisUp[1] >= 0 ? 1 : -1;
5162
+ const grid = gridOf(p);
5163
+ const gone = p.rt.chips ?? {};
5164
+ const out = [];
5165
+ for (let i = 0; i < grid.length; i++) {
5166
+ if (gone[i] === -1) continue;
5167
+ const at3 = grid[i].center[along];
5168
+ const inBand = Math.abs(at3 - bandCenter) <= height / 2 + 1e-6;
5169
+ const above2 = standing && (at3 - bandCenter) * upward > height / 2;
5170
+ if (inBand || above2) out.push(i);
5171
+ }
5172
+ if (out.length > 0) knockOutUnits(o, p, entry, E, out, src);
5173
+ giveAtCut(o, p, src);
5174
+ return true;
5175
+ };
5120
5176
  const chipUnits = (o, p, kind, wp, hitEnergy, dir, radius, src) => {
5121
5177
  var _a, _b, _c;
5122
5178
  if (!p.spec.units || !p.staged || chipEnergy <= 0 || p.st.stripped || isLost(p) || (p.st.stage ?? 0) >= 2) return;
@@ -5258,6 +5314,7 @@ var GameTestRoom = (() => {
5258
5314
  else {
5259
5315
  bars = [];
5260
5316
  for (const cell of p.st.chipped ?? []) bars.push(...clipBarsToBox(all, u, v, cell.center, cell.size));
5317
+ for (const box2 of p.rt.bared ?? []) bars.push(...clipBarsToBox(all, u, v, box2.center, box2.size));
5261
5318
  const op = p.st.opening;
5262
5319
  if (op) {
5263
5320
  const lc = toLocal(p.pos, p.q, op.center);
@@ -5796,7 +5853,7 @@ var GameTestRoom = (() => {
5796
5853
  const absorbed = penetrated && (mat.ductility >= 0.5 && mat.fracture !== "tear" || hollowTear) ? Math.min(E, thr) : E;
5797
5854
  const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale2, "ballistic", entry, d, absorbed * 0.1, 12, src);
5798
5855
  if (!isLost(p)) tearAt(o, p, "ballistic", entry, penetrated ? exitPoint : void 0, d, E, caliber / 1e3, src);
5799
- chipUnits(o, p, "ballistic", entry, penetrated ? Math.min(E, Math.max(thr, E * 0.5)) : E, d, Math.max(0.05, caliber / 1e3 * 8), src);
5856
+ if (!wearMember(o, p, entry, d, E, caliber, penMm, src)) chipUnits(o, p, "ballistic", entry, penetrated ? Math.min(E, Math.max(thr, E * 0.5)) : E, d, Math.max(0.05, caliber / 1e3 * 8), src);
5800
5857
  return { penetrated, exitEnergy: penetrated ? penMm !== void 0 ? E * (1 - thr / Ep) : E - thr / (hard ? piercing : 1) : 0, exitPoint, damage: dmg };
5801
5858
  };
5802
5859
  const melee = (o, p, kind, E, point, n, d, contactR, src) => {