@adatechnology/game-vfx 0.14.0 → 0.16.0

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
@@ -1041,6 +1041,9 @@ function patchExplosions(base, changes) {
1041
1041
  }
1042
1042
  return result;
1043
1043
  }
1044
+ function explosionEffectIds(explosions = EXPLOSIONS) {
1045
+ return Object.keys(explosions);
1046
+ }
1044
1047
 
1045
1048
  // src/color.ts
1046
1049
  var BYTE_MAX = 255;
@@ -1166,7 +1169,8 @@ function createChunkPool(capacity, placeholder) {
1166
1169
  trail: 0,
1167
1170
  glow: null,
1168
1171
  rng: placeholder,
1169
- outColor: [0, 0, 0]
1172
+ outColor: [0, 0, 0],
1173
+ source: void 0
1170
1174
  }),
1171
1175
  freezeFollowingGlow
1172
1176
  );
@@ -1272,7 +1276,8 @@ function createGlowPool(capacity) {
1272
1276
  outY: 0,
1273
1277
  outZ: 0,
1274
1278
  outSize: 0,
1275
- outIntensity: 0
1279
+ outIntensity: 0,
1280
+ source: void 0
1276
1281
  }));
1277
1282
  }
1278
1283
  function spawnGlow(pool, init) {
@@ -1292,6 +1297,7 @@ function spawnGlow(pool, init) {
1292
1297
  glow.fx = init.fx ?? 0;
1293
1298
  glow.fy = init.fy ?? 0;
1294
1299
  glow.fz = init.fz ?? 0;
1300
+ glow.source = init.source;
1295
1301
  return glow;
1296
1302
  }
1297
1303
  function ageOrKeep(glow, dt) {
@@ -1420,6 +1426,8 @@ var Enclosures = class {
1420
1426
  __publicField(this, "l0", new Float64Array(3));
1421
1427
  __publicField(this, "l1", new Float64Array(3));
1422
1428
  __publicField(this, "q", new Float64Array(3));
1429
+ __publicField(this, "h", new Float64Array(3));
1430
+ __publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
1423
1431
  this.random = lehmer(seed);
1424
1432
  }
1425
1433
  get empty() {
@@ -1495,9 +1503,21 @@ var Enclosures = class {
1495
1503
  return this.chance(s.leak, dt);
1496
1504
  }
1497
1505
  confine(x0, y0, z0, x1, y1, z1, pad, dt) {
1506
+ const move = this.move;
1507
+ move.x0 = x0;
1508
+ move.y0 = y0;
1509
+ move.z0 = z0;
1510
+ move.x1 = x1;
1511
+ move.y1 = y1;
1512
+ move.z1 = z1;
1513
+ move.pad = pad;
1514
+ return this.confineMove(move, dt);
1515
+ }
1516
+ confineMove(move, dt) {
1498
1517
  const list = this.list;
1499
1518
  if (list.length === 0) return false;
1500
- const p = Math.min(Math.max(0, pad), MAX_PAD);
1519
+ const { x0, y0, z0, x1, y1, z1 } = move;
1520
+ const p = Math.min(Math.max(0, move.pad), MAX_PAD);
1501
1521
  const l0 = this.l0;
1502
1522
  const l1 = this.l1;
1503
1523
  const q = this.q;
@@ -1514,7 +1534,10 @@ var Enclosures = class {
1514
1534
  }
1515
1535
  this.toLocal(s, x0, y0, z0, l0);
1516
1536
  this.toLocal(s, x1, y1, z1, l1);
1517
- const h = [s.hx, s.hy, s.hz];
1537
+ const h = this.h;
1538
+ h[0] = s.hx;
1539
+ h[1] = s.hy;
1540
+ h[2] = s.hz;
1518
1541
  const in0 = Math.abs(l0[0]) <= s.hx && Math.abs(l0[1]) <= s.hy && Math.abs(l0[2]) <= s.hz;
1519
1542
  let axis2 = 0;
1520
1543
  let sign = 1;
@@ -1563,6 +1586,13 @@ var Enclosures = class {
1563
1586
  return false;
1564
1587
  }
1565
1588
  };
1589
+ function slideInto(out, velocity) {
1590
+ const into = velocity.vx * out.nx + velocity.vy * out.ny + velocity.vz * out.nz;
1591
+ if (into >= 0) return;
1592
+ velocity.vx -= into * out.nx;
1593
+ velocity.vy -= into * out.ny;
1594
+ velocity.vz -= into * out.nz;
1595
+ }
1566
1596
  function slideAlong(out, vx2, vy2, vz2) {
1567
1597
  const into = vx2 * out.nx + vy2 * out.ny + vz2 * out.nz;
1568
1598
  if (into >= 0) return [vx2, vy2, vz2];
@@ -1577,6 +1607,7 @@ var ARRIVAL_BASE = 0.3;
1577
1607
  var GROWTH_CAP_SECONDS = 3.5;
1578
1608
  var CARRIED_KINDS = [true, true, false, true, false];
1579
1609
  var PAD_OF_SIZE = 0.35;
1610
+ var MOVE = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
1580
1611
  function createPuffPool(capacity) {
1581
1612
  const placeholder = { next: () => 0, between: (min2) => min2, direction: (out) => out, state: 0 };
1582
1613
  return new OrderedPool(capacity, () => ({
@@ -1607,7 +1638,8 @@ function createPuffPool(capacity) {
1607
1638
  rng: placeholder,
1608
1639
  age: 0,
1609
1640
  heat: 0,
1610
- size: 0
1641
+ size: 0,
1642
+ source: void 0
1611
1643
  }));
1612
1644
  }
1613
1645
  function spawnPuff(pool, random, init) {
@@ -1640,6 +1672,7 @@ function spawnPuff(pool, random, init) {
1640
1672
  puff3.age = 0;
1641
1673
  puff3.heat = 0;
1642
1674
  puff3.size = 0;
1675
+ puff3.source = init.source;
1643
1676
  return puff3;
1644
1677
  }
1645
1678
  function ageOrKeep2(puff3, dt) {
@@ -1671,23 +1704,30 @@ function moveFree(puff3, dt, age, heat, wind) {
1671
1704
  if (puff3.vy < 0) puff3.vy *= FLOOR_BOUNCE;
1672
1705
  }
1673
1706
  }
1707
+ function confine(confiner, puff3, dt) {
1708
+ MOVE.x1 = puff3.x;
1709
+ MOVE.y1 = puff3.y;
1710
+ MOVE.z1 = puff3.z;
1711
+ MOVE.pad = puff3.size * PAD_OF_SIZE;
1712
+ return confiner.confineMove(MOVE, dt);
1713
+ }
1674
1714
  function updatePuffs(pool, dt, wind, confiner) {
1675
1715
  pool.compact(ageOrKeep2, dt);
1676
1716
  const confining = confiner !== void 0 && !confiner.empty;
1677
1717
  for (const puff3 of pool.items) {
1678
1718
  const age = puff3.t / puff3.life;
1679
1719
  const heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
1680
- const x0 = puff3.x;
1681
- const y0 = puff3.y;
1682
- const z0 = puff3.z;
1720
+ MOVE.x0 = puff3.x;
1721
+ MOVE.y0 = puff3.y;
1722
+ MOVE.z0 = puff3.z;
1683
1723
  if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
1684
1724
  else moveFree(puff3, dt, age, heat, wind);
1685
- if (confining && CARRIED_KINDS[puff3.kind] && confiner.confine(x0, y0, z0, puff3.x, puff3.y, puff3.z, puff3.size * PAD_OF_SIZE, dt)) {
1725
+ if (confining && CARRIED_KINDS[puff3.kind] && confine(confiner, puff3, dt)) {
1686
1726
  const out = confiner.out;
1687
1727
  puff3.x = out.x;
1688
1728
  puff3.y = out.y;
1689
1729
  puff3.z = out.z;
1690
- [puff3.vx, puff3.vy, puff3.vz] = slideAlong(out, puff3.vx, puff3.vy, puff3.vz);
1730
+ slideInto(out, puff3);
1691
1731
  }
1692
1732
  const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
1693
1733
  puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
@@ -1700,7 +1740,7 @@ function updatePuffs(pool, dt, wind, confiner) {
1700
1740
  var GROUND_LIFT = 0.02;
1701
1741
  var BOUNCE_SLIDE = 0.55;
1702
1742
  function createSparkPool(capacity) {
1703
- return new OrderedPool(capacity, () => ({ x: 0, y: 0, z: 0, vx: 0, vy: 0, vz: 0, t: 0, life: 0.8, w: 0.04, st: 0.035, kind: 0, drag: 0.6, g: 9.8, bounce: 0.35, age: 0 }));
1743
+ return new OrderedPool(capacity, () => ({ x: 0, y: 0, z: 0, vx: 0, vy: 0, vz: 0, t: 0, life: 0.8, w: 0.04, st: 0.035, kind: 0, drag: 0.6, g: 9.8, bounce: 0.35, age: 0, source: void 0 }));
1704
1744
  }
1705
1745
  function spawnSpark(pool, init) {
1706
1746
  const spark = pool.acquire();
@@ -1719,6 +1759,7 @@ function spawnSpark(pool, init) {
1719
1759
  spark.g = init.g ?? 9.8;
1720
1760
  spark.bounce = init.bounce ?? 0.35;
1721
1761
  spark.age = 0;
1762
+ spark.source = init.source;
1722
1763
  return spark;
1723
1764
  }
1724
1765
  function ageOrKeep3(spark, dt) {
@@ -1754,22 +1795,26 @@ var HOT_GLOW_COLOR = [1, 0.45, 0.12];
1754
1795
  function addPuff(core, random, init) {
1755
1796
  core.spawned.puffs++;
1756
1797
  const puff3 = spawnPuff(core.puffs, random, init);
1798
+ puff3.source = init.source ?? core.source;
1757
1799
  core.trace?.puff?.(puff3);
1758
1800
  return puff3;
1759
1801
  }
1760
1802
  function addSpark(core, init) {
1761
1803
  core.spawned.sparks++;
1762
1804
  const spark = spawnSpark(core.sparks, init);
1805
+ spark.source = init.source ?? core.source;
1763
1806
  core.trace?.spark?.(spark);
1764
1807
  return spark;
1765
1808
  }
1766
1809
  function addGlow(core, init) {
1767
1810
  const glow = spawnGlow(core.glows, init);
1811
+ glow.source = init.source ?? core.source;
1768
1812
  core.trace?.glow?.(glow);
1769
1813
  return glow;
1770
1814
  }
1771
1815
  function addChunk(core, random, init) {
1772
1816
  const chunk = spawnChunk(core.chunks, random, init);
1817
+ chunk.source = core.source;
1773
1818
  core.spawned.chunks++;
1774
1819
  if (chunk.hot && core.layers.shrapnel) {
1775
1820
  chunk.glow = addGlow(core, { follow: chunk, s: 0.35 + chunk.sx, i: 2.2, life: random.between(1, 2.2), color: HOT_GLOW_COLOR, curve: 1.5 });
@@ -1800,7 +1845,8 @@ function createFirePool(capacity, placeholder) {
1800
1845
  fz: 0,
1801
1846
  color: SMOKE_COLORS.black,
1802
1847
  rng: placeholder,
1803
- handle: 0
1848
+ handle: 0,
1849
+ source: void 0
1804
1850
  }));
1805
1851
  }
1806
1852
  function spawnFire(pool, random, init, handle) {
@@ -1825,6 +1871,7 @@ function spawnFire(pool, random, init, handle) {
1825
1871
  fire.color = init.color ?? SMOKE_COLORS.black;
1826
1872
  fire.rng = random;
1827
1873
  fire.handle = handle;
1874
+ fire.source = init.source;
1828
1875
  return fire;
1829
1876
  }
1830
1877
  function addFire(core, random, init, handle) {
@@ -1859,7 +1906,8 @@ function emitFlames(core, fire, radius, dt) {
1859
1906
  buoy: 3.2,
1860
1907
  color: fire.color,
1861
1908
  kind: 0,
1862
- wind: 0.4
1909
+ wind: 0.4,
1910
+ source: fire.source
1863
1911
  });
1864
1912
  }
1865
1913
  }
@@ -1882,7 +1930,8 @@ function emitSmoke(core, fire, radius, dt) {
1882
1930
  drag: 0.6,
1883
1931
  buoy: 0.55,
1884
1932
  color: fire.color,
1885
- kind: 0
1933
+ kind: 0,
1934
+ source: fire.source
1886
1935
  });
1887
1936
  }
1888
1937
  }
@@ -1901,7 +1950,8 @@ function emitEmber(core, fire, radius, dt) {
1901
1950
  st: 0.02,
1902
1951
  kind: 4,
1903
1952
  g: -0.6,
1904
- drag: 1.2
1953
+ drag: 1.2,
1954
+ source: fire.source
1905
1955
  });
1906
1956
  }
1907
1957
  function updateFires(core, dt) {
@@ -3684,6 +3734,8 @@ var COUGH_AND_BREATH = {
3684
3734
  var DEBRIS_EFFECT_FAMILIES = ["wood", "masonry", "glass", "metal", "soft", "soil"];
3685
3735
  var DEBRIS_COLOR_VARIABLE = "debrisColor";
3686
3736
  var DUST_COLOR_VARIABLE = "dustColor";
3737
+ var PIECES_DRAWN_VARIABLE = "piecesDrawn";
3738
+ var standIns = (...steps) => when(not(variable(PIECES_DRAWN_VARIABLE)), steps);
3687
3739
  var FAMILIES = {
3688
3740
  wood: { debris: 8017200, dust: 10127986, piece: [0.015, 0.015, 0.1], spin: 6, cloud: 0.5, sparks: false, glints: false },
3689
3741
  masonry: { debris: 10197652, dust: 11052187, piece: [0.035, 0.028, 0.035], spin: 4, cloud: 1, sparks: false, glints: false },
@@ -3730,7 +3782,7 @@ function breachDust(family) {
3730
3782
  ...sparks(look, 14),
3731
3783
  ...glints(look, 20),
3732
3784
  burst("normal", Math.round(30 * look.cloud), { p: ORIGIN, box: [1.4, 0.8, 0.2], sp: [0.3, 1.2], drag: 1.5, life: [1.5, 2.6], size: [0.4, 0.7], grow: 3, c0: dustTone(look), c1: 4867648, a: 0.45 }),
3733
- repeat(scaled(16), debris({ p: ORIGIN, box: [1.3, 0.8, 0.1], sp: [1, 3], size: grow(look.piece, 2.2), k: [0.5, 1.5], spin: look.spin, c: debrisTone(look), life: 20 })),
3785
+ standIns(repeat(scaled(16), debris({ p: ORIGIN, box: [1.3, 0.8, 0.1], sp: [1, 3], size: grow(look.piece, 2.2), k: [0.5, 1.5], spin: look.spin, c: debrisTone(look), life: 20 }))),
3734
3786
  repeat(
3735
3787
  scaled(Math.round(60 * look.cloud)),
3736
3788
  spawn("normal", local("angle", rnd(0, 6.283), {
@@ -3762,8 +3814,10 @@ function collapseDust(family) {
3762
3814
  timeline: [
3763
3815
  screen({ add: { shake: 0.45 } }),
3764
3816
  ...sparks(look, 20),
3765
- repeat(6, debris({ p: ORIGIN, box: [2, 0.05, 0.6], v: [rnd(-0.5, 0.5), rnd(-0.5, 0), rnd(0, 0.8)], sp: 0, size: [rnd(0.5, 1.1), look.piece[1] > 0.01 ? 0.25 : 0.03, rnd(0.4, 0.8)], c: debrisTone(look), spin: 3, life: 30, bounce: 0.1 })),
3766
- repeat(scaled(20), debris({ p: ORIGIN, box: [2.1, 0.1, 0.7], v: [rnd(-1, 1), rnd(-1, 1), rnd(0, 1.5)], sp: 0, size: grow(look.piece, 3.4), k: [0.5, 1.5], spin: look.spin, c: debrisTone(look), life: 30 })),
3817
+ standIns(
3818
+ repeat(6, debris({ p: ORIGIN, box: [2, 0.05, 0.6], v: [rnd(-0.5, 0.5), rnd(-0.5, 0), rnd(0, 0.8)], sp: 0, size: [rnd(0.5, 1.1), look.piece[1] > 0.01 ? 0.25 : 0.03, rnd(0.4, 0.8)], c: debrisTone(look), spin: 3, life: 30, bounce: 0.1 })),
3819
+ repeat(scaled(20), debris({ p: ORIGIN, box: [2.1, 0.1, 0.7], v: [rnd(-1, 1), rnd(-1, 1), rnd(0, 1.5)], sp: 0, size: grow(look.piece, 3.4), k: [0.5, 1.5], spin: look.spin, c: debrisTone(look), life: 30 }))
3820
+ ),
3767
3821
  repeat(
3768
3822
  scaled(Math.round(70 * look.cloud)),
3769
3823
  spawn("normal", local("angle", rnd(-0.4, 3.5), {
@@ -6006,10 +6060,11 @@ function leaveTrail(core, chunk, dt) {
6006
6060
  st: 0.05,
6007
6061
  kind: 0,
6008
6062
  g: 0,
6009
- drag: 1
6063
+ drag: 1,
6064
+ source: chunk.source
6010
6065
  });
6011
6066
  if (random.next() < 0.25) {
6012
- addPuff(core, random, { x: chunk.x, y: chunk.y, z: chunk.z, s0: 0.04, s1: 0.14 + chunk.sx * 0.3, sg: 0.15, life: random.between(1, 1.6), drag: 2, buoy: 0.6, color: SMOKE_COLORS.grey, kind: 0 });
6067
+ addPuff(core, random, { x: chunk.x, y: chunk.y, z: chunk.z, s0: 0.04, s1: 0.14 + chunk.sx * 0.3, sg: 0.15, life: random.between(1, 1.6), drag: 2, buoy: 0.6, color: SMOKE_COLORS.grey, kind: 0, source: chunk.source });
6013
6068
  }
6014
6069
  }
6015
6070
  function updateChunks(core, dt) {
@@ -6069,10 +6124,11 @@ function spriteRandom(seed) {
6069
6124
  };
6070
6125
  }
6071
6126
  var SpriteKindPool = class {
6072
- constructor(capacity, defs, owners) {
6127
+ constructor(capacity, defs, owners, sources = { ids: /* @__PURE__ */ new Map(), next: 0 }) {
6073
6128
  __publicField(this, "capacity", capacity);
6074
6129
  __publicField(this, "defs", defs);
6075
6130
  __publicField(this, "owners", owners);
6131
+ __publicField(this, "sources", sources);
6076
6132
  __publicField(this, "live", 0);
6077
6133
  /** Records from the start the renderer draws (the highest live index + 1). */
6078
6134
  __publicField(this, "drawCount", 0);
@@ -6092,6 +6148,7 @@ var SpriteKindPool = class {
6092
6148
  __publicField(this, "alphaMul");
6093
6149
  __publicField(this, "tag");
6094
6150
  __publicField(this, "owner");
6151
+ __publicField(this, "source");
6095
6152
  __publicField(this, "colorHex");
6096
6153
  __publicField(this, "rgbStart");
6097
6154
  __publicField(this, "rgbEnd");
@@ -6113,6 +6170,7 @@ var SpriteKindPool = class {
6113
6170
  this.alphaMul = new Float32Array(n);
6114
6171
  this.tag = new Int32Array(n);
6115
6172
  this.owner = new Int32Array(n);
6173
+ this.source = new Int32Array(n);
6116
6174
  this.colorHex = new Int32Array(n);
6117
6175
  this.rgbStart = new Float32Array(n * 3);
6118
6176
  this.rgbEnd = new Float32Array(n * 3);
@@ -6139,6 +6197,7 @@ var SpriteKindPool = class {
6139
6197
  this.alphaMul[i] = options?.alpha ?? 1;
6140
6198
  this.tag[i] = options?.tag ?? 0;
6141
6199
  this.owner[i] = options?.owner === void 0 ? -1 : this.ownerIndex(options.owner);
6200
+ this.source[i] = options?.source === void 0 ? -1 : this.sourceIndex(options.source);
6142
6201
  this.colorHex[i] = options?.color ?? -1;
6143
6202
  this.rgbStart.set(rgb(options?.color ?? def.c0), i * 3);
6144
6203
  this.rgbEnd.set(rgb(options?.color ?? def.c1), i * 3);
@@ -6153,6 +6212,26 @@ var SpriteKindPool = class {
6153
6212
  if (index < 0) index = this.owners.push(name) - 1;
6154
6213
  return index;
6155
6214
  }
6215
+ sourceIndex(name) {
6216
+ let index = this.sources.ids.get(name);
6217
+ if (index === void 0) {
6218
+ index = this.sources.next++;
6219
+ this.sources.ids.set(name, index);
6220
+ }
6221
+ return index;
6222
+ }
6223
+ /** Kills the live sprites made for `source`; returns how many went. */
6224
+ clearSource(source) {
6225
+ const index = this.sources.ids.get(source);
6226
+ if (index === void 0) return 0;
6227
+ let killed = 0;
6228
+ for (let i = 0; i < this.high; i++) {
6229
+ if (!this.alive[i] || this.source[i] !== index) continue;
6230
+ this.kill(i);
6231
+ killed++;
6232
+ }
6233
+ return killed;
6234
+ }
6156
6235
  kill(i) {
6157
6236
  if (!this.alive[i]) return;
6158
6237
  this.alive[i] = 0;
@@ -6612,14 +6691,15 @@ var SpriteKindSystem = class {
6612
6691
  __publicField(this, "defs");
6613
6692
  __publicField(this, "index", /* @__PURE__ */ new Map());
6614
6693
  __publicField(this, "owners", []);
6694
+ __publicField(this, "sources", { ids: /* @__PURE__ */ new Map(), next: 0 });
6615
6695
  __publicField(this, "listeners", /* @__PURE__ */ new Map());
6616
6696
  const kinds = options.kinds ?? SPRITE_KINDS;
6617
6697
  this.ids = Object.keys(kinds);
6618
6698
  this.defs = this.ids.map((id) => kinds[id]);
6619
6699
  this.ids.forEach((id, at3) => this.index.set(id, at3));
6620
6700
  const additiveCapacity = Math.floor(options.capacity * 0.4);
6621
- this.additive = new SpriteKindPool(additiveCapacity, this.defs, this.owners);
6622
- this.normal = new SpriteKindPool(options.capacity - additiveCapacity, this.defs, this.owners);
6701
+ this.additive = new SpriteKindPool(additiveCapacity, this.defs, this.owners, this.sources);
6702
+ this.normal = new SpriteKindPool(options.capacity - additiveCapacity, this.defs, this.owners, this.sources);
6623
6703
  this.random = spriteRandom(options.seed);
6624
6704
  }
6625
6705
  get capacity() {
@@ -6693,9 +6773,16 @@ var SpriteKindSystem = class {
6693
6773
  if (this.additive.live > 0 || this.additive.drawCount > 0) this.additive.update(dt, host);
6694
6774
  if (this.normal.live > 0 || this.normal.drawCount > 0) this.normal.update(dt, host);
6695
6775
  }
6776
+ /** Kills the live sprites made for `source` (`SpriteSpawnOptions.source`); returns how many went. */
6777
+ clearSource(source) {
6778
+ const killed = this.additive.clearSource(source) + this.normal.clearSource(source);
6779
+ this.sources.ids.delete(source);
6780
+ return killed;
6781
+ }
6696
6782
  clear() {
6697
6783
  this.additive.clear();
6698
6784
  this.normal.clear();
6785
+ this.sources.ids.clear();
6699
6786
  }
6700
6787
  };
6701
6788
 
@@ -7473,6 +7560,7 @@ var QUALITY_MULTIPLIERS = [1, 0.5, 0.2];
7473
7560
  var FIRE_FLICKER_SWAY = 0.25;
7474
7561
  var FIRE_FLICKER_JITTER = 0.08;
7475
7562
  var LENS_FADE = 0.16;
7563
+ var FLOOR_NORMAL_Y = 0.9;
7476
7564
  function rotate2(q, v) {
7477
7565
  const [qx, qy, qz, qw] = q;
7478
7566
  const ix = qw * v[0] + qy * v[2] - qz * v[1];
@@ -7601,7 +7689,9 @@ var WorkshopEngine = class {
7601
7689
  if (this.placement) {
7602
7690
  const [x, y, z] = this.place([recipe[0], recipe[1], recipe[2]]);
7603
7691
  const options = recipe[5];
7604
- args = [x, y, z, recipe[3], recipe[4], options?.n ? { ...options, n: this.turn(options.n) } : options];
7692
+ const normal = options?.n ? this.turn(options.n) : void 0;
7693
+ const onFloor = !normal || normal[1] > FLOOR_NORMAL_Y;
7694
+ args = [x, onFloor ? this.context.groundAt(x, z) : y, z, recipe[3], recipe[4], normal ? { ...options, n: normal } : options];
7605
7695
  }
7606
7696
  this.context.trace?.("decal", args);
7607
7697
  this.decals.add(args[0], args[1], args[2], args[3], args[4], args[5]);
@@ -7748,7 +7838,8 @@ function createVfx(options = {}) {
7748
7838
  groundAt,
7749
7839
  ...options.marklessAt ? { marklessAt: options.marklessAt } : {},
7750
7840
  ...options.cratersAt ? { cratersAt: options.cratersAt } : {},
7751
- emit: (request) => options.onRequest?.(request)
7841
+ emit: (request) => options.onRequest?.(request),
7842
+ source: void 0
7752
7843
  };
7753
7844
  function definitionOf(id) {
7754
7845
  return explosions[id] ?? explosions[aliases[id] ?? ""];
@@ -7759,7 +7850,13 @@ function createVfx(options = {}) {
7759
7850
  return streamFor(seed ?? Math.imul(handles.events, AUTO_SEED) + (options.seed ?? 0));
7760
7851
  }
7761
7852
  function detonate(def, point, call3) {
7762
- composeExplosion(core, def, { x: point[0], y: point[1], z: point[2], direction: call3.direction, random: call3.random, handle: call3.handle });
7853
+ const outer = core.source;
7854
+ core.source = call3.source;
7855
+ try {
7856
+ composeExplosion(core, def, { x: point[0], y: point[1], z: point[2], direction: call3.direction, random: call3.random, handle: call3.handle });
7857
+ } finally {
7858
+ core.source = outer;
7859
+ }
7763
7860
  }
7764
7861
  let engine;
7765
7862
  let player;
@@ -7776,6 +7873,21 @@ function createVfx(options = {}) {
7776
7873
  return {
7777
7874
  hostGroundAt: options.groundAt,
7778
7875
  play(id, point, playOptions = {}) {
7876
+ if (id === "volumetric_fire") {
7877
+ const values = playOptions.values;
7878
+ const handle = ++handles.next;
7879
+ addFire(core, streamOf(playOptions.seed), {
7880
+ x: point[0],
7881
+ y: point[1],
7882
+ z: point[2],
7883
+ r: values?.radius ?? 0.55,
7884
+ life: values?.life ?? 24,
7885
+ ...values?.rate !== void 0 ? { rate: values.rate } : {},
7886
+ ...values?.smoke !== void 0 ? { smoke: values.smoke } : {},
7887
+ ...values?.smokeColor !== void 0 ? { color: hexToLinearRgb(values.smokeColor) } : {}
7888
+ }, handle);
7889
+ return handle;
7890
+ }
7779
7891
  if (!(id in effects)) return null;
7780
7892
  const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
7781
7893
  return effectPlayer().play(id, [point[0], point[1], point[2]], { ...playOptions, ...seed !== void 0 ? { seed } : {} });
@@ -7792,7 +7904,7 @@ function createVfx(options = {}) {
7792
7904
  sprites: () => spriteSystem,
7793
7905
  workshop,
7794
7906
  peekWorkshop: () => engine,
7795
- effectIds: () => Object.keys(effects),
7907
+ effectIds: () => "volumetric_fire" in effects ? Object.keys(effects) : [...Object.keys(effects), "volumetric_fire"],
7796
7908
  explosion(id, point, explosionOptions = {}) {
7797
7909
  const base = definitionOf(id);
7798
7910
  if (!base) return null;
@@ -7800,8 +7912,9 @@ function createVfx(options = {}) {
7800
7912
  const handle = ++handles.next;
7801
7913
  const direction = explosionOptions.direction && { x: explosionOptions.direction[0], y: explosionOptions.direction[1], z: explosionOptions.direction[2] };
7802
7914
  const random = streamOf(explosionOptions.seed);
7803
- if (explosionOptions.delay) core.schedule.at(core.clock.time + explosionOptions.delay, () => detonate(def, point, { direction, random, handle }));
7804
- else detonate(def, point, { direction, random, handle });
7915
+ const source = explosionOptions.source;
7916
+ if (explosionOptions.delay) core.schedule.at(core.clock.time + explosionOptions.delay, () => detonate(def, point, { direction, random, handle, source }));
7917
+ else detonate(def, point, { direction, random, handle, source });
7805
7918
  return handle;
7806
7919
  },
7807
7920
  fire(fireOptions) {
@@ -7843,6 +7956,15 @@ function createVfx(options = {}) {
7843
7956
  const fires = core.fires;
7844
7957
  for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
7845
7958
  },
7959
+ clearSource(source) {
7960
+ const keep = (record, gone) => record.source !== gone;
7961
+ const drop = (pool) => {
7962
+ const before = pool.count;
7963
+ pool.compact(keep, source);
7964
+ return before - pool.count;
7965
+ };
7966
+ return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
7967
+ },
7846
7968
  setLayer(layer, on) {
7847
7969
  layers[layer] = on;
7848
7970
  },
@@ -9692,6 +9814,7 @@ export {
9692
9814
  MATERIAL_EVENT_EFFECTS,
9693
9815
  MeshPool,
9694
9816
  OrderedPool,
9817
+ PIECES_DRAWN_VARIABLE,
9695
9818
  PROFILES,
9696
9819
  RAIN_CAPACITY,
9697
9820
  RainField,
@@ -9723,6 +9846,7 @@ export {
9723
9846
  createWorkshopBehaviors,
9724
9847
  effectForEvent,
9725
9848
  estimateCost,
9849
+ explosionEffectIds,
9726
9850
  hexToLinearRgb,
9727
9851
  hexToRgb,
9728
9852
  inPuddle,
@@ -9740,6 +9864,7 @@ export {
9740
9864
  resolveWaterBlast,
9741
9865
  resolveWaterShotProfile,
9742
9866
  slideAlong,
9867
+ slideInto,
9743
9868
  streamFor,
9744
9869
  updateScreen,
9745
9870
  waterShotClassOf,