@adatechnology/game-floorplan-three 0.11.0 → 0.11.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.
@@ -1547,6 +1547,26 @@ var GameFloorplanThree = (() => {
1547
1547
 
1548
1548
  // ../game-contracts/dist/index.js
1549
1549
  var DEFAULT_BLAST_IMPULSE = { bodyArea: 0.7, lift: 0.15, minSpeed: 0.3, tntPerJoule: 0.24 / 2e5 };
1550
+ var NEAREST = 0.3;
1551
+ function sideOnImpulse(tnt, distance2) {
1552
+ if (!(tnt > 0)) return 0;
1553
+ const w3 = Math.cbrt(tnt);
1554
+ const z = Math.max(distance2, NEAREST) / w3;
1555
+ const scaled = 0.067 * Math.sqrt(1 + (z / 0.23) ** 4) / (z * z * Math.cbrt(1 + (z / 1.55) ** 3));
1556
+ return scaled * w3 * 100;
1557
+ }
1558
+ var ATMOSPHERE = 101325;
1559
+ function sideOnOverpressure(tnt, distance2) {
1560
+ if (!(tnt > 0)) return 0;
1561
+ const z = Math.max(distance2, NEAREST) / Math.cbrt(tnt);
1562
+ const ratio = 808 * (1 + (z / 4.5) ** 2) / (Math.sqrt(1 + (z / 0.048) ** 2) * Math.sqrt(1 + (z / 0.32) ** 2) * Math.sqrt(1 + (z / 1.35) ** 2));
1563
+ return ratio * ATMOSPHERE;
1564
+ }
1565
+ function bodyImpulse(tnt, distance2) {
1566
+ if (!(tnt > 0)) return 0;
1567
+ const z = Math.max(distance2, NEAREST) / Math.cbrt(tnt);
1568
+ return sideOnImpulse(tnt, distance2) * (2 + 4 / (1 + z * z));
1569
+ }
1550
1570
  var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
1551
1571
  var DEFAULT_IGNITION_RULES = {
1552
1572
  fillCurve: [
@@ -14200,9 +14220,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
14200
14220
  var BREACH_AREA = 0.25;
14201
14221
  var BREACH_BLAST_REACH = 0.12;
14202
14222
  var MEMBER_CUT_REACH = 0.5;
14223
+ var FAR_MEMBER_HP_FLOOR = 0.25;
14203
14224
  var BLAST_REFERENCE_RESISTANCE = 200 * 1900 * 0.13;
14204
14225
  var BLAST_EDGE_RAGGED = 0.3;
14205
14226
  var BLAST_EDGE_LOOSE = 1.35;
14227
+ var PANEL_PRESSURE = 7e4;
14228
+ var PANEL_IMPULSE = 150;
14229
+ var PANEL_PI = 6e6;
14230
+ var PANEL_POINTS = [[0, 0], [-0.3, 0], [0.3, 0], [0, -0.3], [0, 0.3]];
14231
+ var PANEL_POINTS_LOADED = 4;
14206
14232
  var BLAST_EDGE_WEAR = 0.6;
14207
14233
  var RESIDUAL_CAPACITY = 0.15;
14208
14234
  var SEVER_BAND = 0.1;
@@ -15796,7 +15822,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15796
15822
  return BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3) * clamp2(Math.cbrt(BLAST_REFERENCE_RESISTANCE / resistance), 0.3, 2);
15797
15823
  };
15798
15824
  const blastUnits = (o, p, wp, energy, dist, src) => {
15799
- var _a, _b;
15825
+ var _a;
15800
15826
  if (!p.staged || p.st.stripped || isLost(p) || chipEnergy <= 0) return false;
15801
15827
  const reach = blastReachOf(p, energy);
15802
15828
  if (dist >= reach) return false;
@@ -15826,6 +15852,62 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15826
15852
  }
15827
15853
  }
15828
15854
  if (out.length === 0) return false;
15855
+ return knockOutUnits(o, p, wp, energy, out, src);
15856
+ };
15857
+ const blastPanel = (o, p, point, energy, src) => {
15858
+ var _a;
15859
+ if (!p.staged || p.st.stripped || isLost(p) || !p.spec.units || p.spec.units.mortar === p.spec.material || p.spec.reinforcement) return false;
15860
+ const [u, v] = planeAxes(p.thin);
15861
+ const lp = toLocal(p.pos, p.q, objLocal(o, point));
15862
+ const half = p.dims[u] / 2;
15863
+ const posts = [];
15864
+ for (const m of o.parts) {
15865
+ if (m === p || !m.spec.reinforcement || isLost(m) || m.spec.shape.kind !== "box") continue;
15866
+ const mp = toLocal(p.pos, p.q, m.pos);
15867
+ if (Math.abs(mp[p.thin]) > p.dims[p.thin] + 0.15 || Math.abs(mp[u]) > half + 0.15 || m.dims[v] < p.dims[v] * 0.5) continue;
15868
+ posts.push(mp[u]);
15869
+ }
15870
+ let from = -half, to = half;
15871
+ for (const x of posts) {
15872
+ if (x <= lp[u] && x > from) from = x;
15873
+ if (x >= lp[u] && x < to) to = x;
15874
+ }
15875
+ if (to - from < 0.2) return false;
15876
+ const tnt = energy * DEFAULT_BLAST_IMPULSE.tntPerJoule;
15877
+ const centre = objLocal(o, point);
15878
+ const span = to - from, height = p.dims[v];
15879
+ let loaded = 0;
15880
+ for (const [fu, fv] of PANEL_POINTS) {
15881
+ const at2 = [0, 0, 0];
15882
+ at2[u] = (from + to) / 2 + fu * span;
15883
+ at2[v] = fv * height;
15884
+ at2[p.thin] = Math.sign(lp[p.thin]) * p.dims[p.thin] / 2;
15885
+ const r = vec.distance(toWorld(p.pos, p.q, at2), centre);
15886
+ const side = sideOnOverpressure(tnt, r);
15887
+ const reflected = 2 * side + 6 * side * side / (side + 7 * 101325);
15888
+ const impulse = bodyImpulse(tnt, r);
15889
+ if (reflected > PANEL_PRESSURE && impulse > PANEL_IMPULSE && (reflected - PANEL_PRESSURE) * (impulse - PANEL_IMPULSE) >= PANEL_PI) loaded++;
15890
+ }
15891
+ if (loaded < PANEL_POINTS_LOADED) return false;
15892
+ const grid = gridOf(p);
15893
+ const worn = (_a = p.rt).chips ?? (_a.chips = {});
15894
+ const out = [];
15895
+ for (let i = 0; i < grid.length; i++) {
15896
+ const cell = grid[i];
15897
+ if (worn[i] === -1) continue;
15898
+ if (cell.center[u] - cell.size[u] / 2 >= from - 1e-6 && cell.center[u] + cell.size[u] / 2 <= to + 1e-6) out.push(i);
15899
+ }
15900
+ if (out.length === 0) return false;
15901
+ for (const i of out) worn[i] = -1;
15902
+ return knockOutUnits(o, p, point, energy, out, src);
15903
+ };
15904
+ const knockOutUnits = (o, p, wp, energy, out, src) => {
15905
+ var _a, _b;
15906
+ const [u, v] = planeAxes(p.thin);
15907
+ const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
15908
+ const grid = gridOf(p);
15909
+ const worn = (_a = p.rt).chips ?? (_a.chips = {});
15910
+ for (const i of out) worn[i] = -1;
15829
15911
  const loose = 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));
15830
15912
  for (const i of loose) worn[i] = -1;
15831
15913
  const blown = out.map((i) => grid[i]), fallen = loose.map((i) => grid[i]);
@@ -16308,12 +16390,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16308
16390
  return reach;
16309
16391
  }
16310
16392
  if (Ein > 20 && p.layers.length > 0) spallOuter(o, p, wp, faceOf(o, p, wn), wn, clamp2(0.05 + Math.sqrt(Ein) * 2e-3, 0.05, 0.4), src);
16311
- const dealt = applyDamage(o, p, amount, "explosive", point, null, Ein * 0.3, 40, src);
16393
+ const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
16394
+ const farMember = Boolean(p.spec.reinforcement && p.spec.units) && dist > MEMBER_CUT_REACH * breachReach;
16395
+ const dealt = farMember ? 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);
16312
16396
  res.damage += dealt;
16313
16397
  if (p.bend && flexure.enabled) bendByBlast(o, p, point, energy, radius, reach, src);
16314
- const breachReach = BREACH_BLAST_REACH * Math.cbrt(Math.max(0, energy) / 1e3);
16315
- if (p.spec.units && p.spec.units.mortar !== p.spec.material) blastUnits(o, p, wp, energy, dist, src);
16316
- else if (p.spec.reinforcement && p.spec.units && dist > MEMBER_CUT_REACH * breachReach) blastUnits(o, p, wp, energy, dist, src);
16398
+ if (p.spec.units && p.spec.units.mortar !== p.spec.material) {
16399
+ blastPanel(o, p, point, energy, src);
16400
+ if (!isLost(p)) blastUnits(o, p, wp, energy, dist, src);
16401
+ } else if (farMember) blastUnits(o, p, wp, energy, dist, src);
16317
16402
  else if (dist <= breachReach) addBreach(o, p, wp, breachAreaOf(p, dealt, true), Ein, null, src);
16318
16403
  return reach;
16319
16404
  };