@adatechnology/game-destruction 0.13.0 → 0.13.2

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.js CHANGED
@@ -2723,6 +2723,7 @@ var BREACH_GRID_CAP = 4096;
2723
2723
  var CHIP_ENERGY = 200;
2724
2724
  var CHIP_SPLASH = 0.5;
2725
2725
  var CRATER_SPENT = 0.6;
2726
+ var EDGE_REACH = 1.5;
2726
2727
  var BAR_BOW = 0.08;
2727
2728
  var BULLET_JOINT_SPAN = 0.3;
2728
2729
  var CUT_SLICE = 1;
@@ -4096,6 +4097,9 @@ var createDestruction = (options = {}) => {
4096
4097
  const lo = cell.center[a] - cell.size[a] / 2 + w / 2, hi = cell.center[a] + cell.size[a] / 2 - w / 2;
4097
4098
  size[a] = w;
4098
4099
  center[a] = clamp2(lp[a], lo, hi);
4100
+ const [from, to] = tornToEdge({ p, cell, a, b: a === u ? v : u, at: lp[a], crater: [center[a] - w / 2, center[a] + w / 2], reach: w * EDGE_REACH, gone: (k) => worn[k] === -1 });
4101
+ size[a] = to - from;
4102
+ center[a] = (from + to) / 2;
4099
4103
  }
4100
4104
  const taken2 = (cut[i] ?? 0) + size[u] * size[v];
4101
4105
  if (taken2 >= cell.size[u] * cell.size[v] * CRATER_SPENT) {
@@ -4133,6 +4137,19 @@ var createDestruction = (options = {}) => {
4133
4137
  collapseCheck(o, src);
4134
4138
  }
4135
4139
  };
4140
+ const tornToEdge = (o) => {
4141
+ const { p, cell, a, b, at, crater: crater2, reach, gone } = o;
4142
+ const half = p.dims[a] / 2;
4143
+ const lo = cell.center[a] - cell.size[a] / 2, hi = cell.center[a] + cell.size[a] / 2;
4144
+ const free = (side, sign) => {
4145
+ if (sign > 0 ? side >= half - 1e-6 : side <= -half + 1e-6) return sign > 0 || a !== planeAxes(p.thin)[1];
4146
+ const probe = side + sign * 1e-3;
4147
+ return gridOf(p).some((c, k) => gone(k) && Math.abs(probe - c.center[a]) <= c.size[a] / 2 && Math.abs(cell.center[b] - c.center[b]) <= c.size[b] / 2);
4148
+ };
4149
+ if (at - lo <= reach && free(lo, -1)) return [lo, Math.max(crater2[1], lo)];
4150
+ if (hi - at <= reach && free(hi, 1)) return [Math.min(crater2[0], hi), hi];
4151
+ return crater2;
4152
+ };
4136
4153
  const craterAcross = (energy) => clamp2(0.03 + 12e-4 * Math.sqrt(Math.max(0, energy)), 0.03, 0.14);
4137
4154
  const craterFragments = (o, p, cell, dir, speed, mass, tag) => {
4138
4155
  const { c, q } = partXf(o, p);