@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.
@@ -42,6 +42,7 @@ var GameVfx = (() => {
42
42
  MATERIAL_EVENT_EFFECTS: () => MATERIAL_EVENT_EFFECTS,
43
43
  MeshPool: () => MeshPool,
44
44
  OrderedPool: () => OrderedPool,
45
+ PIECES_DRAWN_VARIABLE: () => PIECES_DRAWN_VARIABLE,
45
46
  PROFILES: () => PROFILES,
46
47
  RAIN_CAPACITY: () => RAIN_CAPACITY,
47
48
  RainField: () => RainField,
@@ -73,6 +74,7 @@ var GameVfx = (() => {
73
74
  createWorkshopBehaviors: () => createWorkshopBehaviors,
74
75
  effectForEvent: () => effectForEvent,
75
76
  estimateCost: () => estimateCost,
77
+ explosionEffectIds: () => explosionEffectIds,
76
78
  hexToLinearRgb: () => hexToLinearRgb,
77
79
  hexToRgb: () => hexToRgb,
78
80
  inPuddle: () => inPuddle,
@@ -90,6 +92,7 @@ var GameVfx = (() => {
90
92
  resolveWaterBlast: () => resolveWaterBlast,
91
93
  resolveWaterShotProfile: () => resolveWaterShotProfile,
92
94
  slideAlong: () => slideAlong,
95
+ slideInto: () => slideInto,
93
96
  streamFor: () => streamFor,
94
97
  updateScreen: () => updateScreen,
95
98
  waterShotClassOf: () => waterShotClassOf,
@@ -1135,6 +1138,9 @@ var GameVfx = (() => {
1135
1138
  }
1136
1139
  return result;
1137
1140
  }
1141
+ function explosionEffectIds(explosions = EXPLOSIONS) {
1142
+ return Object.keys(explosions);
1143
+ }
1138
1144
 
1139
1145
  // src/color.ts
1140
1146
  var BYTE_MAX = 255;
@@ -1260,7 +1266,8 @@ var GameVfx = (() => {
1260
1266
  trail: 0,
1261
1267
  glow: null,
1262
1268
  rng: placeholder,
1263
- outColor: [0, 0, 0]
1269
+ outColor: [0, 0, 0],
1270
+ source: void 0
1264
1271
  }),
1265
1272
  freezeFollowingGlow
1266
1273
  );
@@ -1366,7 +1373,8 @@ var GameVfx = (() => {
1366
1373
  outY: 0,
1367
1374
  outZ: 0,
1368
1375
  outSize: 0,
1369
- outIntensity: 0
1376
+ outIntensity: 0,
1377
+ source: void 0
1370
1378
  }));
1371
1379
  }
1372
1380
  function spawnGlow(pool, init) {
@@ -1386,6 +1394,7 @@ var GameVfx = (() => {
1386
1394
  glow.fx = init.fx ?? 0;
1387
1395
  glow.fy = init.fy ?? 0;
1388
1396
  glow.fz = init.fz ?? 0;
1397
+ glow.source = init.source;
1389
1398
  return glow;
1390
1399
  }
1391
1400
  function ageOrKeep(glow, dt) {
@@ -1514,6 +1523,8 @@ var GameVfx = (() => {
1514
1523
  __publicField(this, "l0", new Float64Array(3));
1515
1524
  __publicField(this, "l1", new Float64Array(3));
1516
1525
  __publicField(this, "q", new Float64Array(3));
1526
+ __publicField(this, "h", new Float64Array(3));
1527
+ __publicField(this, "move", { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 });
1517
1528
  this.random = lehmer(seed);
1518
1529
  }
1519
1530
  get empty() {
@@ -1589,9 +1600,21 @@ var GameVfx = (() => {
1589
1600
  return this.chance(s.leak, dt);
1590
1601
  }
1591
1602
  confine(x0, y0, z0, x1, y1, z1, pad, dt) {
1603
+ const move = this.move;
1604
+ move.x0 = x0;
1605
+ move.y0 = y0;
1606
+ move.z0 = z0;
1607
+ move.x1 = x1;
1608
+ move.y1 = y1;
1609
+ move.z1 = z1;
1610
+ move.pad = pad;
1611
+ return this.confineMove(move, dt);
1612
+ }
1613
+ confineMove(move, dt) {
1592
1614
  const list = this.list;
1593
1615
  if (list.length === 0) return false;
1594
- const p = Math.min(Math.max(0, pad), MAX_PAD);
1616
+ const { x0, y0, z0, x1, y1, z1 } = move;
1617
+ const p = Math.min(Math.max(0, move.pad), MAX_PAD);
1595
1618
  const l0 = this.l0;
1596
1619
  const l1 = this.l1;
1597
1620
  const q = this.q;
@@ -1608,7 +1631,10 @@ var GameVfx = (() => {
1608
1631
  }
1609
1632
  this.toLocal(s, x0, y0, z0, l0);
1610
1633
  this.toLocal(s, x1, y1, z1, l1);
1611
- const h = [s.hx, s.hy, s.hz];
1634
+ const h = this.h;
1635
+ h[0] = s.hx;
1636
+ h[1] = s.hy;
1637
+ h[2] = s.hz;
1612
1638
  const in0 = Math.abs(l0[0]) <= s.hx && Math.abs(l0[1]) <= s.hy && Math.abs(l0[2]) <= s.hz;
1613
1639
  let axis2 = 0;
1614
1640
  let sign = 1;
@@ -1657,6 +1683,13 @@ var GameVfx = (() => {
1657
1683
  return false;
1658
1684
  }
1659
1685
  };
1686
+ function slideInto(out, velocity) {
1687
+ const into = velocity.vx * out.nx + velocity.vy * out.ny + velocity.vz * out.nz;
1688
+ if (into >= 0) return;
1689
+ velocity.vx -= into * out.nx;
1690
+ velocity.vy -= into * out.ny;
1691
+ velocity.vz -= into * out.nz;
1692
+ }
1660
1693
  function slideAlong(out, vx2, vy2, vz2) {
1661
1694
  const into = vx2 * out.nx + vy2 * out.ny + vz2 * out.nz;
1662
1695
  if (into >= 0) return [vx2, vy2, vz2];
@@ -1671,6 +1704,7 @@ var GameVfx = (() => {
1671
1704
  var GROWTH_CAP_SECONDS = 3.5;
1672
1705
  var CARRIED_KINDS = [true, true, false, true, false];
1673
1706
  var PAD_OF_SIZE = 0.35;
1707
+ var MOVE = { x0: 0, y0: 0, z0: 0, x1: 0, y1: 0, z1: 0, pad: 0 };
1674
1708
  function createPuffPool(capacity) {
1675
1709
  const placeholder = { next: () => 0, between: (min2) => min2, direction: (out) => out, state: 0 };
1676
1710
  return new OrderedPool(capacity, () => ({
@@ -1701,7 +1735,8 @@ var GameVfx = (() => {
1701
1735
  rng: placeholder,
1702
1736
  age: 0,
1703
1737
  heat: 0,
1704
- size: 0
1738
+ size: 0,
1739
+ source: void 0
1705
1740
  }));
1706
1741
  }
1707
1742
  function spawnPuff(pool, random, init) {
@@ -1734,6 +1769,7 @@ var GameVfx = (() => {
1734
1769
  puff3.age = 0;
1735
1770
  puff3.heat = 0;
1736
1771
  puff3.size = 0;
1772
+ puff3.source = init.source;
1737
1773
  return puff3;
1738
1774
  }
1739
1775
  function ageOrKeep2(puff3, dt) {
@@ -1765,23 +1801,30 @@ var GameVfx = (() => {
1765
1801
  if (puff3.vy < 0) puff3.vy *= FLOOR_BOUNCE;
1766
1802
  }
1767
1803
  }
1804
+ function confine(confiner, puff3, dt) {
1805
+ MOVE.x1 = puff3.x;
1806
+ MOVE.y1 = puff3.y;
1807
+ MOVE.z1 = puff3.z;
1808
+ MOVE.pad = puff3.size * PAD_OF_SIZE;
1809
+ return confiner.confineMove(MOVE, dt);
1810
+ }
1768
1811
  function updatePuffs(pool, dt, wind, confiner) {
1769
1812
  pool.compact(ageOrKeep2, dt);
1770
1813
  const confining = confiner !== void 0 && !confiner.empty;
1771
1814
  for (const puff3 of pool.items) {
1772
1815
  const age = puff3.t / puff3.life;
1773
1816
  const heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
1774
- const x0 = puff3.x;
1775
- const y0 = puff3.y;
1776
- const z0 = puff3.z;
1817
+ MOVE.x0 = puff3.x;
1818
+ MOVE.y0 = puff3.y;
1819
+ MOVE.z0 = puff3.z;
1777
1820
  if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
1778
1821
  else moveFree(puff3, dt, age, heat, wind);
1779
- if (confining && CARRIED_KINDS[puff3.kind] && confiner.confine(x0, y0, z0, puff3.x, puff3.y, puff3.z, puff3.size * PAD_OF_SIZE, dt)) {
1822
+ if (confining && CARRIED_KINDS[puff3.kind] && confine(confiner, puff3, dt)) {
1780
1823
  const out = confiner.out;
1781
1824
  puff3.x = out.x;
1782
1825
  puff3.y = out.y;
1783
1826
  puff3.z = out.z;
1784
- [puff3.vx, puff3.vy, puff3.vz] = slideAlong(out, puff3.vx, puff3.vy, puff3.vz);
1827
+ slideInto(out, puff3);
1785
1828
  }
1786
1829
  const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
1787
1830
  puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
@@ -1794,7 +1837,7 @@ var GameVfx = (() => {
1794
1837
  var GROUND_LIFT = 0.02;
1795
1838
  var BOUNCE_SLIDE = 0.55;
1796
1839
  function createSparkPool(capacity) {
1797
- 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 }));
1840
+ 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 }));
1798
1841
  }
1799
1842
  function spawnSpark(pool, init) {
1800
1843
  const spark = pool.acquire();
@@ -1813,6 +1856,7 @@ var GameVfx = (() => {
1813
1856
  spark.g = init.g ?? 9.8;
1814
1857
  spark.bounce = init.bounce ?? 0.35;
1815
1858
  spark.age = 0;
1859
+ spark.source = init.source;
1816
1860
  return spark;
1817
1861
  }
1818
1862
  function ageOrKeep3(spark, dt) {
@@ -1848,22 +1892,26 @@ var GameVfx = (() => {
1848
1892
  function addPuff(core, random, init) {
1849
1893
  core.spawned.puffs++;
1850
1894
  const puff3 = spawnPuff(core.puffs, random, init);
1895
+ puff3.source = init.source ?? core.source;
1851
1896
  core.trace?.puff?.(puff3);
1852
1897
  return puff3;
1853
1898
  }
1854
1899
  function addSpark(core, init) {
1855
1900
  core.spawned.sparks++;
1856
1901
  const spark = spawnSpark(core.sparks, init);
1902
+ spark.source = init.source ?? core.source;
1857
1903
  core.trace?.spark?.(spark);
1858
1904
  return spark;
1859
1905
  }
1860
1906
  function addGlow(core, init) {
1861
1907
  const glow = spawnGlow(core.glows, init);
1908
+ glow.source = init.source ?? core.source;
1862
1909
  core.trace?.glow?.(glow);
1863
1910
  return glow;
1864
1911
  }
1865
1912
  function addChunk(core, random, init) {
1866
1913
  const chunk = spawnChunk(core.chunks, random, init);
1914
+ chunk.source = core.source;
1867
1915
  core.spawned.chunks++;
1868
1916
  if (chunk.hot && core.layers.shrapnel) {
1869
1917
  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 });
@@ -1894,7 +1942,8 @@ var GameVfx = (() => {
1894
1942
  fz: 0,
1895
1943
  color: SMOKE_COLORS.black,
1896
1944
  rng: placeholder,
1897
- handle: 0
1945
+ handle: 0,
1946
+ source: void 0
1898
1947
  }));
1899
1948
  }
1900
1949
  function spawnFire(pool, random, init, handle) {
@@ -1919,6 +1968,7 @@ var GameVfx = (() => {
1919
1968
  fire.color = init.color ?? SMOKE_COLORS.black;
1920
1969
  fire.rng = random;
1921
1970
  fire.handle = handle;
1971
+ fire.source = init.source;
1922
1972
  return fire;
1923
1973
  }
1924
1974
  function addFire(core, random, init, handle) {
@@ -1953,7 +2003,8 @@ var GameVfx = (() => {
1953
2003
  buoy: 3.2,
1954
2004
  color: fire.color,
1955
2005
  kind: 0,
1956
- wind: 0.4
2006
+ wind: 0.4,
2007
+ source: fire.source
1957
2008
  });
1958
2009
  }
1959
2010
  }
@@ -1976,7 +2027,8 @@ var GameVfx = (() => {
1976
2027
  drag: 0.6,
1977
2028
  buoy: 0.55,
1978
2029
  color: fire.color,
1979
- kind: 0
2030
+ kind: 0,
2031
+ source: fire.source
1980
2032
  });
1981
2033
  }
1982
2034
  }
@@ -1995,7 +2047,8 @@ var GameVfx = (() => {
1995
2047
  st: 0.02,
1996
2048
  kind: 4,
1997
2049
  g: -0.6,
1998
- drag: 1.2
2050
+ drag: 1.2,
2051
+ source: fire.source
1999
2052
  });
2000
2053
  }
2001
2054
  function updateFires(core, dt) {
@@ -3778,6 +3831,8 @@ var GameVfx = (() => {
3778
3831
  var DEBRIS_EFFECT_FAMILIES = ["wood", "masonry", "glass", "metal", "soft", "soil"];
3779
3832
  var DEBRIS_COLOR_VARIABLE = "debrisColor";
3780
3833
  var DUST_COLOR_VARIABLE = "dustColor";
3834
+ var PIECES_DRAWN_VARIABLE = "piecesDrawn";
3835
+ var standIns = (...steps) => when(not(variable(PIECES_DRAWN_VARIABLE)), steps);
3781
3836
  var FAMILIES = {
3782
3837
  wood: { debris: 8017200, dust: 10127986, piece: [0.015, 0.015, 0.1], spin: 6, cloud: 0.5, sparks: false, glints: false },
3783
3838
  masonry: { debris: 10197652, dust: 11052187, piece: [0.035, 0.028, 0.035], spin: 4, cloud: 1, sparks: false, glints: false },
@@ -3824,7 +3879,7 @@ var GameVfx = (() => {
3824
3879
  ...sparks(look, 14),
3825
3880
  ...glints(look, 20),
3826
3881
  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 }),
3827
- 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 })),
3882
+ 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 }))),
3828
3883
  repeat(
3829
3884
  scaled(Math.round(60 * look.cloud)),
3830
3885
  spawn("normal", local("angle", rnd(0, 6.283), {
@@ -3856,8 +3911,10 @@ var GameVfx = (() => {
3856
3911
  timeline: [
3857
3912
  screen({ add: { shake: 0.45 } }),
3858
3913
  ...sparks(look, 20),
3859
- 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 })),
3860
- 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 })),
3914
+ standIns(
3915
+ 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 })),
3916
+ 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 }))
3917
+ ),
3861
3918
  repeat(
3862
3919
  scaled(Math.round(70 * look.cloud)),
3863
3920
  spawn("normal", local("angle", rnd(-0.4, 3.5), {
@@ -6100,10 +6157,11 @@ var GameVfx = (() => {
6100
6157
  st: 0.05,
6101
6158
  kind: 0,
6102
6159
  g: 0,
6103
- drag: 1
6160
+ drag: 1,
6161
+ source: chunk.source
6104
6162
  });
6105
6163
  if (random.next() < 0.25) {
6106
- 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 });
6164
+ 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 });
6107
6165
  }
6108
6166
  }
6109
6167
  function updateChunks(core, dt) {
@@ -6163,10 +6221,11 @@ var GameVfx = (() => {
6163
6221
  };
6164
6222
  }
6165
6223
  var SpriteKindPool = class {
6166
- constructor(capacity, defs, owners) {
6224
+ constructor(capacity, defs, owners, sources = { ids: /* @__PURE__ */ new Map(), next: 0 }) {
6167
6225
  __publicField(this, "capacity", capacity);
6168
6226
  __publicField(this, "defs", defs);
6169
6227
  __publicField(this, "owners", owners);
6228
+ __publicField(this, "sources", sources);
6170
6229
  __publicField(this, "live", 0);
6171
6230
  /** Records from the start the renderer draws (the highest live index + 1). */
6172
6231
  __publicField(this, "drawCount", 0);
@@ -6186,6 +6245,7 @@ var GameVfx = (() => {
6186
6245
  __publicField(this, "alphaMul");
6187
6246
  __publicField(this, "tag");
6188
6247
  __publicField(this, "owner");
6248
+ __publicField(this, "source");
6189
6249
  __publicField(this, "colorHex");
6190
6250
  __publicField(this, "rgbStart");
6191
6251
  __publicField(this, "rgbEnd");
@@ -6207,6 +6267,7 @@ var GameVfx = (() => {
6207
6267
  this.alphaMul = new Float32Array(n);
6208
6268
  this.tag = new Int32Array(n);
6209
6269
  this.owner = new Int32Array(n);
6270
+ this.source = new Int32Array(n);
6210
6271
  this.colorHex = new Int32Array(n);
6211
6272
  this.rgbStart = new Float32Array(n * 3);
6212
6273
  this.rgbEnd = new Float32Array(n * 3);
@@ -6233,6 +6294,7 @@ var GameVfx = (() => {
6233
6294
  this.alphaMul[i] = options?.alpha ?? 1;
6234
6295
  this.tag[i] = options?.tag ?? 0;
6235
6296
  this.owner[i] = options?.owner === void 0 ? -1 : this.ownerIndex(options.owner);
6297
+ this.source[i] = options?.source === void 0 ? -1 : this.sourceIndex(options.source);
6236
6298
  this.colorHex[i] = options?.color ?? -1;
6237
6299
  this.rgbStart.set(rgb(options?.color ?? def.c0), i * 3);
6238
6300
  this.rgbEnd.set(rgb(options?.color ?? def.c1), i * 3);
@@ -6247,6 +6309,26 @@ var GameVfx = (() => {
6247
6309
  if (index < 0) index = this.owners.push(name) - 1;
6248
6310
  return index;
6249
6311
  }
6312
+ sourceIndex(name) {
6313
+ let index = this.sources.ids.get(name);
6314
+ if (index === void 0) {
6315
+ index = this.sources.next++;
6316
+ this.sources.ids.set(name, index);
6317
+ }
6318
+ return index;
6319
+ }
6320
+ /** Kills the live sprites made for `source`; returns how many went. */
6321
+ clearSource(source) {
6322
+ const index = this.sources.ids.get(source);
6323
+ if (index === void 0) return 0;
6324
+ let killed = 0;
6325
+ for (let i = 0; i < this.high; i++) {
6326
+ if (!this.alive[i] || this.source[i] !== index) continue;
6327
+ this.kill(i);
6328
+ killed++;
6329
+ }
6330
+ return killed;
6331
+ }
6250
6332
  kill(i) {
6251
6333
  if (!this.alive[i]) return;
6252
6334
  this.alive[i] = 0;
@@ -6706,14 +6788,15 @@ var GameVfx = (() => {
6706
6788
  __publicField(this, "defs");
6707
6789
  __publicField(this, "index", /* @__PURE__ */ new Map());
6708
6790
  __publicField(this, "owners", []);
6791
+ __publicField(this, "sources", { ids: /* @__PURE__ */ new Map(), next: 0 });
6709
6792
  __publicField(this, "listeners", /* @__PURE__ */ new Map());
6710
6793
  const kinds = options.kinds ?? SPRITE_KINDS;
6711
6794
  this.ids = Object.keys(kinds);
6712
6795
  this.defs = this.ids.map((id) => kinds[id]);
6713
6796
  this.ids.forEach((id, at3) => this.index.set(id, at3));
6714
6797
  const additiveCapacity = Math.floor(options.capacity * 0.4);
6715
- this.additive = new SpriteKindPool(additiveCapacity, this.defs, this.owners);
6716
- this.normal = new SpriteKindPool(options.capacity - additiveCapacity, this.defs, this.owners);
6798
+ this.additive = new SpriteKindPool(additiveCapacity, this.defs, this.owners, this.sources);
6799
+ this.normal = new SpriteKindPool(options.capacity - additiveCapacity, this.defs, this.owners, this.sources);
6717
6800
  this.random = spriteRandom(options.seed);
6718
6801
  }
6719
6802
  get capacity() {
@@ -6787,9 +6870,16 @@ var GameVfx = (() => {
6787
6870
  if (this.additive.live > 0 || this.additive.drawCount > 0) this.additive.update(dt, host);
6788
6871
  if (this.normal.live > 0 || this.normal.drawCount > 0) this.normal.update(dt, host);
6789
6872
  }
6873
+ /** Kills the live sprites made for `source` (`SpriteSpawnOptions.source`); returns how many went. */
6874
+ clearSource(source) {
6875
+ const killed = this.additive.clearSource(source) + this.normal.clearSource(source);
6876
+ this.sources.ids.delete(source);
6877
+ return killed;
6878
+ }
6790
6879
  clear() {
6791
6880
  this.additive.clear();
6792
6881
  this.normal.clear();
6882
+ this.sources.ids.clear();
6793
6883
  }
6794
6884
  };
6795
6885
 
@@ -7567,6 +7657,7 @@ var GameVfx = (() => {
7567
7657
  var FIRE_FLICKER_SWAY = 0.25;
7568
7658
  var FIRE_FLICKER_JITTER = 0.08;
7569
7659
  var LENS_FADE = 0.16;
7660
+ var FLOOR_NORMAL_Y = 0.9;
7570
7661
  function rotate2(q, v) {
7571
7662
  const [qx, qy, qz, qw] = q;
7572
7663
  const ix = qw * v[0] + qy * v[2] - qz * v[1];
@@ -7695,7 +7786,9 @@ var GameVfx = (() => {
7695
7786
  if (this.placement) {
7696
7787
  const [x, y, z] = this.place([recipe[0], recipe[1], recipe[2]]);
7697
7788
  const options = recipe[5];
7698
- args = [x, y, z, recipe[3], recipe[4], options?.n ? { ...options, n: this.turn(options.n) } : options];
7789
+ const normal = options?.n ? this.turn(options.n) : void 0;
7790
+ const onFloor = !normal || normal[1] > FLOOR_NORMAL_Y;
7791
+ args = [x, onFloor ? this.context.groundAt(x, z) : y, z, recipe[3], recipe[4], normal ? { ...options, n: normal } : options];
7699
7792
  }
7700
7793
  this.context.trace?.("decal", args);
7701
7794
  this.decals.add(args[0], args[1], args[2], args[3], args[4], args[5]);
@@ -7842,7 +7935,8 @@ var GameVfx = (() => {
7842
7935
  groundAt,
7843
7936
  ...options.marklessAt ? { marklessAt: options.marklessAt } : {},
7844
7937
  ...options.cratersAt ? { cratersAt: options.cratersAt } : {},
7845
- emit: (request) => options.onRequest?.(request)
7938
+ emit: (request) => options.onRequest?.(request),
7939
+ source: void 0
7846
7940
  };
7847
7941
  function definitionOf(id) {
7848
7942
  return explosions[id] ?? explosions[aliases[id] ?? ""];
@@ -7853,7 +7947,13 @@ var GameVfx = (() => {
7853
7947
  return streamFor(seed ?? Math.imul(handles.events, AUTO_SEED) + (options.seed ?? 0));
7854
7948
  }
7855
7949
  function detonate(def, point, call3) {
7856
- composeExplosion(core, def, { x: point[0], y: point[1], z: point[2], direction: call3.direction, random: call3.random, handle: call3.handle });
7950
+ const outer = core.source;
7951
+ core.source = call3.source;
7952
+ try {
7953
+ composeExplosion(core, def, { x: point[0], y: point[1], z: point[2], direction: call3.direction, random: call3.random, handle: call3.handle });
7954
+ } finally {
7955
+ core.source = outer;
7956
+ }
7857
7957
  }
7858
7958
  let engine;
7859
7959
  let player;
@@ -7870,6 +7970,21 @@ var GameVfx = (() => {
7870
7970
  return {
7871
7971
  hostGroundAt: options.groundAt,
7872
7972
  play(id, point, playOptions = {}) {
7973
+ if (id === "volumetric_fire") {
7974
+ const values = playOptions.values;
7975
+ const handle = ++handles.next;
7976
+ addFire(core, streamOf(playOptions.seed), {
7977
+ x: point[0],
7978
+ y: point[1],
7979
+ z: point[2],
7980
+ r: values?.radius ?? 0.55,
7981
+ life: values?.life ?? 24,
7982
+ ...values?.rate !== void 0 ? { rate: values.rate } : {},
7983
+ ...values?.smoke !== void 0 ? { smoke: values.smoke } : {},
7984
+ ...values?.smokeColor !== void 0 ? { color: hexToLinearRgb(values.smokeColor) } : {}
7985
+ }, handle);
7986
+ return handle;
7987
+ }
7873
7988
  if (!(id in effects)) return null;
7874
7989
  const seed = playOptions.seed ?? (randomMode === "shared" ? void 0 : Math.imul(++handles.events, AUTO_SEED) + (options.seed ?? 0));
7875
7990
  return effectPlayer().play(id, [point[0], point[1], point[2]], { ...playOptions, ...seed !== void 0 ? { seed } : {} });
@@ -7886,7 +8001,7 @@ var GameVfx = (() => {
7886
8001
  sprites: () => spriteSystem,
7887
8002
  workshop,
7888
8003
  peekWorkshop: () => engine,
7889
- effectIds: () => Object.keys(effects),
8004
+ effectIds: () => "volumetric_fire" in effects ? Object.keys(effects) : [...Object.keys(effects), "volumetric_fire"],
7890
8005
  explosion(id, point, explosionOptions = {}) {
7891
8006
  const base = definitionOf(id);
7892
8007
  if (!base) return null;
@@ -7894,8 +8009,9 @@ var GameVfx = (() => {
7894
8009
  const handle = ++handles.next;
7895
8010
  const direction = explosionOptions.direction && { x: explosionOptions.direction[0], y: explosionOptions.direction[1], z: explosionOptions.direction[2] };
7896
8011
  const random = streamOf(explosionOptions.seed);
7897
- if (explosionOptions.delay) core.schedule.at(core.clock.time + explosionOptions.delay, () => detonate(def, point, { direction, random, handle }));
7898
- else detonate(def, point, { direction, random, handle });
8012
+ const source = explosionOptions.source;
8013
+ if (explosionOptions.delay) core.schedule.at(core.clock.time + explosionOptions.delay, () => detonate(def, point, { direction, random, handle, source }));
8014
+ else detonate(def, point, { direction, random, handle, source });
7899
8015
  return handle;
7900
8016
  },
7901
8017
  fire(fireOptions) {
@@ -7937,6 +8053,15 @@ var GameVfx = (() => {
7937
8053
  const fires = core.fires;
7938
8054
  for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
7939
8055
  },
8056
+ clearSource(source) {
8057
+ const keep = (record, gone) => record.source !== gone;
8058
+ const drop = (pool) => {
8059
+ const before = pool.count;
8060
+ pool.compact(keep, source);
8061
+ return before - pool.count;
8062
+ };
8063
+ return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
8064
+ },
7940
8065
  setLayer(layer, on) {
7941
8066
  layers[layer] = on;
7942
8067
  },