@adatechnology/game-destruction 0.5.0 → 0.6.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.
package/dist/index.js CHANGED
@@ -1619,6 +1619,8 @@ var createDestruction = (options = {}) => {
1619
1619
  const listeners = /* @__PURE__ */ new Map();
1620
1620
  let cur = [];
1621
1621
  const blasts = [];
1622
+ const frontQueue = [];
1623
+ const blastFrontSpeed = options.blastFrontSpeed ?? 0;
1622
1624
  const primed = /* @__PURE__ */ new Map();
1623
1625
  let orderCounter = 0;
1624
1626
  const impls = /* @__PURE__ */ new Map();
@@ -2360,7 +2362,7 @@ var createDestruction = (options = {}) => {
2360
2362
  return;
2361
2363
  }
2362
2364
  if (ex) {
2363
- emit({ ...base(o, src), type: "explode", part: p.spec.id, point: c, energy: ex.energy, radius: ex.radius });
2365
+ emit({ ...base(o, src), type: "explode", part: p.spec.id, point: c, energy: ex.energy, radius: ex.radius, ...ex.effect !== void 0 ? { effect: ex.effect } : {} });
2364
2366
  blasts.push({ point: c, energy: ex.energy, radius: ex.radius, source: src });
2365
2367
  }
2366
2368
  partLost(o, p, src);
@@ -2507,8 +2509,13 @@ var createDestruction = (options = {}) => {
2507
2509
  }
2508
2510
  }
2509
2511
  wearJoints(o, p, Ein * 0.5, void 0, 0, src);
2512
+ const amount = Ein * DMG_PER_J * (mat.damageScale?.explosive ?? 1);
2513
+ if (blastFrontSpeed > 0 && dist > 0 && mat.tags?.includes("glass")) {
2514
+ frontQueue.push({ o, p, due: time + dist / blastFrontSpeed, amount, fragEnergy: Ein * 0.3, point, ...src !== void 0 ? { src } : {} });
2515
+ continue;
2516
+ }
2510
2517
  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);
2511
- const dealt = applyDamage(o, p, Ein * DMG_PER_J * (mat.damageScale?.explosive ?? 1), "explosive", point, null, Ein * 0.3, 40, src);
2518
+ const dealt = applyDamage(o, p, amount, "explosive", point, null, Ein * 0.3, 40, src);
2512
2519
  res.damage += dealt;
2513
2520
  addBreach(o, p, wp, breachAreaOf(p, dealt, true), Ein, null, src);
2514
2521
  }
@@ -2833,6 +2840,15 @@ var createDestruction = (options = {}) => {
2833
2840
  }
2834
2841
  time = end;
2835
2842
  };
2843
+ const releaseFront = () => {
2844
+ if (frontQueue.length === 0) return;
2845
+ frontQueue.sort((a, b) => a.due - b.due);
2846
+ while (frontQueue.length > 0 && frontQueue[0].due <= time) {
2847
+ const hit = frontQueue.shift();
2848
+ if (objects.get(hit.o.id) !== hit.o) continue;
2849
+ applyDamage(hit.o, hit.p, hit.amount, "explosive", hit.point, null, hit.fragEnergy, 40, hit.src);
2850
+ }
2851
+ };
2836
2852
  const withCollapses = (r) => {
2837
2853
  const last = r.value[r.value.length - 1];
2838
2854
  if (!last) return r.value;
@@ -3084,6 +3100,7 @@ var createDestruction = (options = {}) => {
3084
3100
  for (const o of [...objects.values()]) if (o.active) stepObject(o, dt, sources);
3085
3101
  if (sources.length) spread2(sources, dt);
3086
3102
  detonatePrimed(time);
3103
+ releaseFront();
3087
3104
  for (const im of [...impls.values()]) {
3088
3105
  if (!im.impl.update) continue;
3089
3106
  for (const e of im.impl.update(dt) ?? []) emit(e.time === void 0 ? { ...e, time } : e);