@adatechnology/game-vfx 0.13.0 → 0.15.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) {
@@ -1607,7 +1613,8 @@ function createPuffPool(capacity) {
1607
1613
  rng: placeholder,
1608
1614
  age: 0,
1609
1615
  heat: 0,
1610
- size: 0
1616
+ size: 0,
1617
+ source: void 0
1611
1618
  }));
1612
1619
  }
1613
1620
  function spawnPuff(pool, random, init) {
@@ -1640,6 +1647,7 @@ function spawnPuff(pool, random, init) {
1640
1647
  puff3.age = 0;
1641
1648
  puff3.heat = 0;
1642
1649
  puff3.size = 0;
1650
+ puff3.source = init.source;
1643
1651
  return puff3;
1644
1652
  }
1645
1653
  function ageOrKeep2(puff3, dt) {
@@ -1700,7 +1708,7 @@ function updatePuffs(pool, dt, wind, confiner) {
1700
1708
  var GROUND_LIFT = 0.02;
1701
1709
  var BOUNCE_SLIDE = 0.55;
1702
1710
  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 }));
1711
+ 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
1712
  }
1705
1713
  function spawnSpark(pool, init) {
1706
1714
  const spark = pool.acquire();
@@ -1719,6 +1727,7 @@ function spawnSpark(pool, init) {
1719
1727
  spark.g = init.g ?? 9.8;
1720
1728
  spark.bounce = init.bounce ?? 0.35;
1721
1729
  spark.age = 0;
1730
+ spark.source = init.source;
1722
1731
  return spark;
1723
1732
  }
1724
1733
  function ageOrKeep3(spark, dt) {
@@ -1754,22 +1763,26 @@ var HOT_GLOW_COLOR = [1, 0.45, 0.12];
1754
1763
  function addPuff(core, random, init) {
1755
1764
  core.spawned.puffs++;
1756
1765
  const puff3 = spawnPuff(core.puffs, random, init);
1766
+ puff3.source = init.source ?? core.source;
1757
1767
  core.trace?.puff?.(puff3);
1758
1768
  return puff3;
1759
1769
  }
1760
1770
  function addSpark(core, init) {
1761
1771
  core.spawned.sparks++;
1762
1772
  const spark = spawnSpark(core.sparks, init);
1773
+ spark.source = init.source ?? core.source;
1763
1774
  core.trace?.spark?.(spark);
1764
1775
  return spark;
1765
1776
  }
1766
1777
  function addGlow(core, init) {
1767
1778
  const glow = spawnGlow(core.glows, init);
1779
+ glow.source = init.source ?? core.source;
1768
1780
  core.trace?.glow?.(glow);
1769
1781
  return glow;
1770
1782
  }
1771
1783
  function addChunk(core, random, init) {
1772
1784
  const chunk = spawnChunk(core.chunks, random, init);
1785
+ chunk.source = core.source;
1773
1786
  core.spawned.chunks++;
1774
1787
  if (chunk.hot && core.layers.shrapnel) {
1775
1788
  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 +1813,8 @@ function createFirePool(capacity, placeholder) {
1800
1813
  fz: 0,
1801
1814
  color: SMOKE_COLORS.black,
1802
1815
  rng: placeholder,
1803
- handle: 0
1816
+ handle: 0,
1817
+ source: void 0
1804
1818
  }));
1805
1819
  }
1806
1820
  function spawnFire(pool, random, init, handle) {
@@ -1825,6 +1839,7 @@ function spawnFire(pool, random, init, handle) {
1825
1839
  fire.color = init.color ?? SMOKE_COLORS.black;
1826
1840
  fire.rng = random;
1827
1841
  fire.handle = handle;
1842
+ fire.source = init.source;
1828
1843
  return fire;
1829
1844
  }
1830
1845
  function addFire(core, random, init, handle) {
@@ -1859,7 +1874,8 @@ function emitFlames(core, fire, radius, dt) {
1859
1874
  buoy: 3.2,
1860
1875
  color: fire.color,
1861
1876
  kind: 0,
1862
- wind: 0.4
1877
+ wind: 0.4,
1878
+ source: fire.source
1863
1879
  });
1864
1880
  }
1865
1881
  }
@@ -1882,7 +1898,8 @@ function emitSmoke(core, fire, radius, dt) {
1882
1898
  drag: 0.6,
1883
1899
  buoy: 0.55,
1884
1900
  color: fire.color,
1885
- kind: 0
1901
+ kind: 0,
1902
+ source: fire.source
1886
1903
  });
1887
1904
  }
1888
1905
  }
@@ -1901,7 +1918,8 @@ function emitEmber(core, fire, radius, dt) {
1901
1918
  st: 0.02,
1902
1919
  kind: 4,
1903
1920
  g: -0.6,
1904
- drag: 1.2
1921
+ drag: 1.2,
1922
+ source: fire.source
1905
1923
  });
1906
1924
  }
1907
1925
  function updateFires(core, dt) {
@@ -3680,67 +3698,59 @@ var COUGH_AND_BREATH = {
3680
3698
  ]
3681
3699
  };
3682
3700
 
3683
- // src/effects/events.ts
3701
+ // src/effects/material-events.ts
3702
+ var DEBRIS_EFFECT_FAMILIES = ["wood", "masonry", "glass", "metal", "soft", "soil"];
3703
+ var DEBRIS_COLOR_VARIABLE = "debrisColor";
3704
+ var DUST_COLOR_VARIABLE = "dustColor";
3705
+ var FAMILIES = {
3706
+ wood: { debris: 8017200, dust: 10127986, piece: [0.015, 0.015, 0.1], spin: 6, cloud: 0.5, sparks: false, glints: false },
3707
+ masonry: { debris: 10197652, dust: 11052187, piece: [0.035, 0.028, 0.035], spin: 4, cloud: 1, sparks: false, glints: false },
3708
+ glass: { debris: 11061464, dust: 12572386, piece: [0.04, 4e-3, 0.04], spin: 14, cloud: 0.25, sparks: false, glints: true },
3709
+ metal: { debris: 9080726, dust: 9078138, piece: [0.04, 6e-3, 0.03], spin: 8, cloud: 0.15, sparks: true, glints: false },
3710
+ soft: { debris: 10130568, dust: 11578014, piece: [0.025, 4e-3, 0.02], spin: 6, cloud: 0.3, sparks: false, glints: false },
3711
+ soil: { debris: 8022613, dust: 9075298, piece: [0.03, 0.025, 0.03], spin: 3, cloud: 1, sparks: false, glints: false }
3712
+ };
3713
+ var ORIGIN = [0, 0, 0];
3684
3714
  var FACING4 = [0, 0, 1];
3685
3715
  var UP11 = [0, 1, 0];
3686
- var ORIGIN = [0, 0, 0];
3687
- var FORWARD4 = [0, 0, -1];
3688
- var IMPACT_MATERIALS = ["concrete", "metal", "wood", "glass", "flesh", "water"];
3689
- var impactEffect = (material) => ({
3690
- id: `impact_${material}`,
3691
- pageId: `event:impact_${material}`,
3692
- team: "weapons",
3693
- budget: { particles: 40, decals: 1 },
3694
- loop: 2,
3695
- timeline: [call2("impact", material, ORIGIN, FACING4, 1, 0)]
3696
- });
3697
- var muzzleEffect = (weapon) => ({
3698
- id: `muzzle_${weapon}`,
3699
- pageId: `event:muzzle_${weapon}`,
3700
- team: "weapons",
3701
- budget: { particles: 60, lights: 1 },
3702
- loop: 2.4,
3703
- timeline: [call2("muzzle", weapon, ORIGIN, FORWARD4)]
3704
- });
3705
- var casingEffect = (id, type) => ({
3706
- id,
3707
- pageId: `event:${id}`,
3708
- team: "weapons",
3709
- budget: { debris: 1 },
3710
- loop: 2,
3711
- timeline: [call2("casing", ORIGIN, type)]
3712
- });
3713
- var EVENT_EFFECTS = [
3714
- ...IMPACT_MATERIALS.map(impactEffect),
3715
- ...["glock", "ak", "r870", "barrett"].map(muzzleEffect),
3716
- casingEffect("casing_brass", ""),
3717
- casingEffect("casing_shell", "shell"),
3718
- casingEffect("casing_50", "50"),
3719
- {
3720
- // door_stages (W856-871): the dust a blow shakes loose from the frame and the splinters.
3721
- id: "stage_crack",
3722
- pageId: "event:stage_crack",
3716
+ var grow = (piece, factor) => [piece[0] * factor, piece[1] * factor, piece[2] * factor];
3717
+ var debrisTone = (look) => or(variable(DEBRIS_COLOR_VARIABLE), look.debris);
3718
+ var dustTone = (look) => or(variable(DUST_COLOR_VARIABLE), look.dust);
3719
+ var sparks = (look, count) => look.sparks ? [call2("spark_at", ORIGIN, FACING4, count, 0.9)] : [];
3720
+ var glints = (look, count) => look.glints ? [burst("add", count, { p: ORIGIN, r: 0.2, size: [0.02, 0.05], life: [0.2, 0.5], c0: 16777215, a: 0.9, fi: 0.3 })] : [];
3721
+ function stageCrack(family) {
3722
+ const look = FAMILIES[family];
3723
+ const dust = look.sparks ? [] : [burst("normal", 12, { p: ORIGIN, box: [0.3, 0.05, 0.02], dir: [0, -0.287, 0.958], cone: 0.6, sp: [0.2, 0.8], drag: 1.5, life: [0.8, 1.4], size: [0.08, 0.16], grow: 3, c0: dustTone(look), a: 0.45, g: 0.4 })];
3724
+ return {
3725
+ id: `stage_crack_${family}`,
3726
+ pageId: `event:stage_crack_${family}`,
3723
3727
  team: "destruction",
3724
- budget: { particles: 12, debris: 5 },
3728
+ budget: { particles: 16, debris: 6 },
3725
3729
  loop: 2,
3726
3730
  timeline: [
3727
- burst("normal", 12, { p: ORIGIN, box: [0.6, 0.05, 0.02], dir: [0, -0.287, 0.958], cone: 0.6, sp: [0.2, 0.8], drag: 1.5, life: [0.8, 1.4], size: [0.08, 0.16], grow: 3, c0: 8024934, a: 0.45, g: 0.4 }),
3728
- repeat(scaled(2), debris({ p: [rnd(-0.5, 0.5), rnd(0, 1.6), 0], dir: [0, 0.287, 0.958], cone: 0.6, sp: [1, 2.5], size: [0.015, 0.015, 0.1], c: 8017200, life: 12 }))
3731
+ ...dust,
3732
+ ...sparks(look, 8),
3733
+ ...glints(look, 4),
3734
+ repeat(scaled(look.sparks ? 1 : 4), debris({ p: ORIGIN, box: [0.15, 0.15, 0.02], dir: [0, 0.287, 0.958], cone: 0.6, sp: [1, 2.5], size: look.piece, k: [0.6, 1.4], spin: look.spin, c: debrisTone(look), life: 12 }))
3729
3735
  ]
3730
- },
3731
- {
3732
- // block_wall (W872-886, 3.6 s): the ring of dust that rolls out when the wall gives way.
3733
- id: "breach_dust",
3734
- pageId: "event:breach_dust",
3736
+ };
3737
+ }
3738
+ function breachDust(family) {
3739
+ const look = FAMILIES[family];
3740
+ return {
3741
+ id: `breach_dust_${family}`,
3742
+ pageId: `event:breach_dust_${family}`,
3735
3743
  team: "destruction",
3736
3744
  budget: { particles: 90, debris: 16 },
3737
3745
  loop: 5,
3738
3746
  timeline: [
3739
3747
  screen({ add: { shake: 0.25 } }),
3740
- burst("normal", 30, { 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: 9078138, c1: 4867648, a: 0.45 }),
3741
- repeat(scaled(16), debris({ p: ORIGIN, box: [1.3, 0.8, 0.1], sp: [1, 3], size: [0.08, 0.07, 0.08], k: [0.5, 1.5], c: 7236195, life: 20 })),
3748
+ ...sparks(look, 14),
3749
+ ...glints(look, 20),
3750
+ 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 }),
3751
+ 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 })),
3742
3752
  repeat(
3743
- scaled(60),
3753
+ scaled(Math.round(60 * look.cloud)),
3744
3754
  spawn("normal", local("angle", rnd(0, 6.283), {
3745
3755
  p: [rnd(-1.4, 1.4), 0.2, rnd(-0.6, 0.4)],
3746
3756
  dir: vnorm([cos(variable("angle")), 0.3, sin(variable("angle"))]),
@@ -3750,27 +3760,30 @@ var EVENT_EFFECTS = [
3750
3760
  life: [2.5, 4.5],
3751
3761
  size: [0.6, 1],
3752
3762
  grow: 3,
3753
- c0: 8024680,
3763
+ c0: dustTone(look),
3754
3764
  c1: 4867648,
3755
3765
  a: 0.45,
3756
3766
  fi: 0.12
3757
3767
  }))
3758
3768
  )
3759
3769
  ]
3760
- },
3761
- {
3762
- // building_collapse (W872-886): the slab dropping in blocks and the cloud that rolls along the street.
3763
- id: "collapse_dust",
3764
- pageId: "event:collapse_dust",
3770
+ };
3771
+ }
3772
+ function collapseDust(family) {
3773
+ const look = FAMILIES[family];
3774
+ return {
3775
+ id: `collapse_dust_${family}`,
3776
+ pageId: `event:collapse_dust_${family}`,
3765
3777
  team: "destruction",
3766
3778
  budget: { particles: 350, debris: 26 },
3767
3779
  loop: 8,
3768
3780
  timeline: [
3769
3781
  screen({ add: { shake: 0.45 } }),
3770
- 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), 0.25, rnd(0.4, 0.8)], c: 7236195, spin: 3, life: 30, bounce: 0.1 })),
3771
- 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: [0.12, 0.1, 0.12], k: [0.5, 1.5], c: 6183508, life: 30 })),
3782
+ ...sparks(look, 20),
3783
+ 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 })),
3784
+ 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 })),
3772
3785
  repeat(
3773
- scaled(70),
3786
+ scaled(Math.round(70 * look.cloud)),
3774
3787
  spawn("normal", local("angle", rnd(-0.4, 3.5), {
3775
3788
  p: [rnd(-2, 2), 0.2, rnd(-0.5, 0.5)],
3776
3789
  dir: vnorm([mul(cos(variable("angle")), 0.6), 0.25, sin(variable("angle"))]),
@@ -3780,14 +3793,68 @@ var EVENT_EFFECTS = [
3780
3793
  life: [3, 6],
3781
3794
  size: [0.7, 1.2],
3782
3795
  grow: 3,
3783
- c0: 8024680,
3796
+ c0: dustTone(look),
3784
3797
  c1: 4867648,
3785
3798
  a: 0.5,
3786
3799
  fi: 0.12
3787
3800
  }))
3788
3801
  )
3789
3802
  ]
3790
- },
3803
+ };
3804
+ }
3805
+ var MASONRY = FAMILIES.masonry;
3806
+ var REBAR_EXPOSE = {
3807
+ id: "rebar_expose",
3808
+ pageId: "event:rebar_expose",
3809
+ team: "destruction",
3810
+ budget: { particles: 24, debris: 8 },
3811
+ loop: 2,
3812
+ timeline: [
3813
+ repeat(scaled(8), debris({ p: ORIGIN, dir: UP11, cone: 0.9, sp: [1, 3], size: MASONRY.piece, k: [0.6, 1.4], spin: MASONRY.spin, c: debrisTone(MASONRY), life: 20 })),
3814
+ burst("normal", 8, { p: ORIGIN, dir: UP11, cone: 0.8, sp: [0.3, 1.2], drag: 2, life: [0.8, 1.4], size: [0.08, 0.15], grow: 3, c0: dustTone(MASONRY), a: 0.4 }),
3815
+ call2("rust_at", ORIGIN, 6)
3816
+ ]
3817
+ };
3818
+ var MATERIAL_EVENT_EFFECTS = [
3819
+ ...DEBRIS_EFFECT_FAMILIES.flatMap((family) => [stageCrack(family), breachDust(family), collapseDust(family)]),
3820
+ REBAR_EXPOSE
3821
+ ];
3822
+
3823
+ // src/effects/events.ts
3824
+ var FACING5 = [0, 0, 1];
3825
+ var ORIGIN2 = [0, 0, 0];
3826
+ var FORWARD4 = [0, 0, -1];
3827
+ var IMPACT_MATERIALS = ["concrete", "metal", "wood", "glass", "flesh", "water"];
3828
+ var impactEffect = (material) => ({
3829
+ id: `impact_${material}`,
3830
+ pageId: `event:impact_${material}`,
3831
+ team: "weapons",
3832
+ budget: { particles: 40, decals: 1 },
3833
+ loop: 2,
3834
+ timeline: [call2("impact", material, ORIGIN2, FACING5, 1, 0)]
3835
+ });
3836
+ var muzzleEffect = (weapon) => ({
3837
+ id: `muzzle_${weapon}`,
3838
+ pageId: `event:muzzle_${weapon}`,
3839
+ team: "weapons",
3840
+ budget: { particles: 60, lights: 1 },
3841
+ loop: 2.4,
3842
+ timeline: [call2("muzzle", weapon, ORIGIN2, FORWARD4)]
3843
+ });
3844
+ var casingEffect = (id, type) => ({
3845
+ id,
3846
+ pageId: `event:${id}`,
3847
+ team: "weapons",
3848
+ budget: { debris: 1 },
3849
+ loop: 2,
3850
+ timeline: [call2("casing", ORIGIN2, type)]
3851
+ });
3852
+ var EVENT_EFFECTS = [
3853
+ ...IMPACT_MATERIALS.map(impactEffect),
3854
+ ...["glock", "ak", "r870", "barrett"].map(muzzleEffect),
3855
+ casingEffect("casing_brass", ""),
3856
+ casingEffect("casing_shell", "shell"),
3857
+ casingEffect("casing_50", "50"),
3791
3858
  {
3792
3859
  // shopfront_glass (W846-855): the pane coming down as shards, the flash of the glints and the pale dust.
3793
3860
  id: "glass_burst",
@@ -3799,21 +3866,13 @@ var EVENT_EFFECTS = [
3799
3866
  screen({ add: { shake: 0.08 } }),
3800
3867
  repeat(
3801
3868
  scaled(75),
3802
- debris({ p: ORIGIN, box: [1.25, 0.85, 0.02], v: [rnd(-0.4, 0.4), rnd(-0.5, 0.8), rnd(0.6, 2)], sp: 0, size: [rnd(0.05, 0.18), 6e-3, rnd(0.05, 0.18)], c: 11061464, spin: 14, life: 30, bounce: 0.15 })
3869
+ debris({ p: ORIGIN2, box: [1.25, 0.85, 0.02], v: [rnd(-0.4, 0.4), rnd(-0.5, 0.8), rnd(0.6, 2)], sp: 0, size: [rnd(0.05, 0.18), 6e-3, rnd(0.05, 0.18)], c: 11061464, spin: 14, life: 30, bounce: 0.15 })
3803
3870
  ),
3804
- burst("add", 30, { p: ORIGIN, box: [1.2, 0.8, 0.05], size: [0.02, 0.05], life: [0.2, 0.6], c0: 16777215, a: 0.9, fi: 0.3 }),
3871
+ burst("add", 30, { p: ORIGIN2, box: [1.2, 0.8, 0.05], size: [0.02, 0.05], life: [0.2, 0.6], c0: 16777215, a: 0.9, fi: 0.3 }),
3805
3872
  burst("normal", 20, { p: [0, -0.6, 0.1], box: [1.2, 0.5, 0.1], sp: [0.2, 0.6], drag: 2, life: [0.8, 1.4], size: [0.12, 0.2], grow: 3, c0: 12572386, a: 0.2 })
3806
3873
  ]
3807
3874
  },
3808
- {
3809
- // The chips macro the page uses on wood (W849) plus rust (`rustAt`), for rebar laid bare in concrete.
3810
- id: "rebar_expose",
3811
- pageId: "event:rebar_expose",
3812
- team: "destruction",
3813
- budget: { particles: 20, debris: 8 },
3814
- loop: 2,
3815
- timeline: [call2("chips", ORIGIN, UP11, 8, 0.9), call2("rust_at", ORIGIN, 6)]
3816
- }
3875
+ ...MATERIAL_EVENT_EFFECTS
3817
3876
  ];
3818
3877
 
3819
3878
  // src/effects/weapons/viewmodel.ts
@@ -3826,7 +3885,7 @@ var FLASH_RAMP = [0.6, 0.9];
3826
3885
  var FLASH_OPACITY = 0.95;
3827
3886
  var FLAME_COLORS = [16742946, 16760896, 13121050, 16773296];
3828
3887
  var FLAME_ADDITIVE = 3;
3829
- var ORIGIN2 = [0, 0, 0];
3888
+ var ORIGIN3 = [0, 0, 0];
3830
3889
  var SIZE = variable("size");
3831
3890
  var FLASH_SCALE = variable("flash");
3832
3891
  var fallback = (name, defaultValue) => ite(ne(variable(name), void 0), variable(name), defaultValue);
@@ -3874,7 +3933,7 @@ var flameBit = (point, velocity, world, radius, life) => [
3874
3933
  grow: 2.2
3875
3934
  })
3876
3935
  ];
3877
- var flashPiece = (shape, radius, height, width, at3, rot, color) => mesh({ shape, r: radius, ...height === void 0 ? {} : { h: height }, seg: width, seg2: shape === "sphere" ? 8 : 1, p: ORIGIN2, at: at3, rot, roll: variable("roll"), ramp: FLASH_RAMP, life: FLASH_SECONDS, c0: color, a: FLASH_OPACITY, add: true });
3936
+ var flashPiece = (shape, radius, height, width, at3, rot, color) => mesh({ shape, r: radius, ...height === void 0 ? {} : { h: height }, seg: width, seg2: shape === "sphere" ? 8 : 1, p: ORIGIN3, at: at3, rot, roll: variable("roll"), ramp: FLASH_RAMP, life: FLASH_SECONDS, c0: color, a: FLASH_OPACITY, add: true });
3878
3937
  var MUZZLE_FLASH2 = {
3879
3938
  id: "viewmodel_muzzle_flash",
3880
3939
  pageId: "event:viewmodel_muzzle_flash",
@@ -3901,7 +3960,7 @@ var MUZZLE_FLASH2 = {
3901
3960
  repeat(4, append("angles", add(div(mul(INDEX, PI), 2), mul(rand(), 0.6)))),
3902
3961
  set("roll", mul(rand(), PI)),
3903
3962
  when(gt(FLASH_SCALE, 0), [
3904
- flash(ORIGIN2, 16756832, mul(4, SIZE, FLASH_SCALE), FLASH_SECONDS, mul(2, SIZE, FLASH_SCALE), true, true),
3963
+ flash(ORIGIN3, 16756832, mul(4, SIZE, FLASH_SCALE), FLASH_SECONDS, mul(2, SIZE, FLASH_SCALE), true, true),
3905
3964
  flashPiece("cone_open", mul(0.013, SIZE, FLASH_SCALE), mul(0.085, SIZE, FLASH_SCALE), 10, [mul(0.042, SIZE, FLASH_SCALE), 0, 0], [0, 0, -PI / 2], 16757575),
3906
3965
  repeat(
3907
3966
  4,
@@ -3921,7 +3980,7 @@ var MUZZLE_FLASH2 = {
3921
3980
  repeat(
3922
3981
  variable("puffs"),
3923
3982
  puff2(
3924
- ORIGIN2,
3983
+ ORIGIN3,
3925
3984
  [add(variable("drift"), mul(rand(), variable("driftSpread"))), add(variable("rise"), mul(rand(), variable("riseSpread"))), mul(sub(rand(), 0.5), variable("sideSpread"))],
3926
3985
  [0, 0, 0],
3927
3986
  mul(variable("radius"), SIZE),
@@ -3938,7 +3997,7 @@ var SMOKE_PUFF = {
3938
3997
  team: "weapons",
3939
3998
  budget: { particles: 1 },
3940
3999
  loop: 0.1,
3941
- timeline: [puff2(ORIGIN2, void 0, [variable("vx"), variable("vy"), variable("vz")], variable("radius"), variable("life"), variable("opacity"))]
4000
+ timeline: [puff2(ORIGIN3, void 0, [variable("vx"), variable("vy"), variable("vz")], variable("radius"), variable("life"), variable("opacity"))]
3942
4001
  };
3943
4002
  var BACKBLAST = {
3944
4003
  id: "launcher_backblast",
@@ -3947,8 +4006,8 @@ var BACKBLAST = {
3947
4006
  budget: { particles: 40 },
3948
4007
  loop: 0.1,
3949
4008
  timeline: [
3950
- repeat(26, puff2(ORIGIN2, [neg(add(1.5, mul(rand(), 3))), 0, 0], [wide(1.4), wide(0.8), wide(1.4)], add(0.03, mul(rand(), 0.03)), add(1.8, mul(rand(), 1.4)), 0.5)),
3951
- repeat(14, ...flameBit(ORIGIN2, [neg(add(2, mul(rand(), 2))), 0, 0], [wide(1), wide(0.6), wide(1)], 0.02, 0.25))
4009
+ repeat(26, puff2(ORIGIN3, [neg(add(1.5, mul(rand(), 3))), 0, 0], [wide(1.4), wide(0.8), wide(1.4)], add(0.03, mul(rand(), 0.03)), add(1.8, mul(rand(), 1.4)), 0.5)),
4010
+ repeat(14, ...flameBit(ORIGIN3, [neg(add(2, mul(rand(), 2))), 0, 0], [wide(1), wide(0.6), wide(1)], 0.02, 0.25))
3952
4011
  ]
3953
4012
  };
3954
4013
  var FLAME_JET = {
@@ -4087,7 +4146,7 @@ function impact(engine, material, point, normal, scale = 1, age = 0) {
4087
4146
  // src/effects/behaviors/blocks.ts
4088
4147
  var COLUMNS = 6;
4089
4148
  var ROWS = 5;
4090
- var ORIGIN3 = [-2.2, 0, 2.6];
4149
+ var ORIGIN4 = [-2.2, 0, 2.6];
4091
4150
  var BLOCK_SIZE = [0.5, 0.44, 0.25];
4092
4151
  var OBJECT_ID_DRAWS2 = 4;
4093
4152
  var FLOOR2 = 0.13;
@@ -4130,7 +4189,7 @@ function createBlocksBehavior() {
4130
4189
  const chipScale = random.between(0.8, 1.3) * scale;
4131
4190
  for (let draw = 0; draw < OBJECT_ID_DRAWS2; draw++) random.next();
4132
4191
  best.holes.push({ x: offsetX, y: offsetY, scale, chipTurn, chipScale });
4133
- impact(host.engine, "concrete", [ORIGIN3[0] + x, y, ORIGIN3[2] + 0.13], [0, 0, 1], 0.8);
4192
+ impact(host.engine, "concrete", [ORIGIN4[0] + x, y, ORIGIN4[2] + 0.13], [0, 0, 1], 0.8);
4134
4193
  } else if (action === "collapse") {
4135
4194
  const { x, y } = args;
4136
4195
  for (const block of blocks) {
@@ -4182,7 +4241,7 @@ function createBlocksBehavior() {
4182
4241
  }
4183
4242
 
4184
4243
  // src/effects/behaviors/car.ts
4185
- var ORIGIN4 = [5.6, 0, 0.8];
4244
+ var ORIGIN5 = [5.6, 0, 0.8];
4186
4245
  var MAX_TILT = 0.25;
4187
4246
  function createCarBehavior() {
4188
4247
  let y = 0;
@@ -4215,7 +4274,7 @@ function createCarBehavior() {
4215
4274
  }
4216
4275
  },
4217
4276
  query(_host, name, args) {
4218
- if (name === "position") return [ORIGIN4[0], y, ORIGIN4[2]];
4277
+ if (name === "position") return [ORIGIN5[0], y, ORIGIN5[2]];
4219
4278
  if (name === "point") {
4220
4279
  const [x, py, z] = args;
4221
4280
  const point = carPoint(x, py, z);
@@ -5120,7 +5179,7 @@ var EffectInstance = class {
5120
5179
  };
5121
5180
 
5122
5181
  // src/effects/player.ts
5123
- var ORIGIN5 = [0, 0, 0];
5182
+ var ORIGIN6 = [0, 0, 0];
5124
5183
  var DEFAULT_HEADING = [0, 0, -1];
5125
5184
  var DEFAULT_MAX_INSTANCES = 48;
5126
5185
  var ENDLESS_SECONDS = 60;
@@ -5197,7 +5256,7 @@ function createEffectPlayer(options) {
5197
5256
  random: playOptions.seed !== void 0 ? streamOf(playOptions.seed) : void 0,
5198
5257
  follow: playOptions.follow,
5199
5258
  origin: point,
5200
- anchor: def.anchor ?? ORIGIN5,
5259
+ anchor: def.anchor ?? ORIGIN6,
5201
5260
  yaw: yawOf(heading, playOptions.direction),
5202
5261
  orientation: playOptions.orientation,
5203
5262
  seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS),
@@ -5965,10 +6024,11 @@ function leaveTrail(core, chunk, dt) {
5965
6024
  st: 0.05,
5966
6025
  kind: 0,
5967
6026
  g: 0,
5968
- drag: 1
6027
+ drag: 1,
6028
+ source: chunk.source
5969
6029
  });
5970
6030
  if (random.next() < 0.25) {
5971
- 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 });
6031
+ 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 });
5972
6032
  }
5973
6033
  }
5974
6034
  function updateChunks(core, dt) {
@@ -6028,10 +6088,11 @@ function spriteRandom(seed) {
6028
6088
  };
6029
6089
  }
6030
6090
  var SpriteKindPool = class {
6031
- constructor(capacity, defs, owners) {
6091
+ constructor(capacity, defs, owners, sources = { ids: /* @__PURE__ */ new Map(), next: 0 }) {
6032
6092
  __publicField(this, "capacity", capacity);
6033
6093
  __publicField(this, "defs", defs);
6034
6094
  __publicField(this, "owners", owners);
6095
+ __publicField(this, "sources", sources);
6035
6096
  __publicField(this, "live", 0);
6036
6097
  /** Records from the start the renderer draws (the highest live index + 1). */
6037
6098
  __publicField(this, "drawCount", 0);
@@ -6051,6 +6112,7 @@ var SpriteKindPool = class {
6051
6112
  __publicField(this, "alphaMul");
6052
6113
  __publicField(this, "tag");
6053
6114
  __publicField(this, "owner");
6115
+ __publicField(this, "source");
6054
6116
  __publicField(this, "colorHex");
6055
6117
  __publicField(this, "rgbStart");
6056
6118
  __publicField(this, "rgbEnd");
@@ -6072,6 +6134,7 @@ var SpriteKindPool = class {
6072
6134
  this.alphaMul = new Float32Array(n);
6073
6135
  this.tag = new Int32Array(n);
6074
6136
  this.owner = new Int32Array(n);
6137
+ this.source = new Int32Array(n);
6075
6138
  this.colorHex = new Int32Array(n);
6076
6139
  this.rgbStart = new Float32Array(n * 3);
6077
6140
  this.rgbEnd = new Float32Array(n * 3);
@@ -6098,6 +6161,7 @@ var SpriteKindPool = class {
6098
6161
  this.alphaMul[i] = options?.alpha ?? 1;
6099
6162
  this.tag[i] = options?.tag ?? 0;
6100
6163
  this.owner[i] = options?.owner === void 0 ? -1 : this.ownerIndex(options.owner);
6164
+ this.source[i] = options?.source === void 0 ? -1 : this.sourceIndex(options.source);
6101
6165
  this.colorHex[i] = options?.color ?? -1;
6102
6166
  this.rgbStart.set(rgb(options?.color ?? def.c0), i * 3);
6103
6167
  this.rgbEnd.set(rgb(options?.color ?? def.c1), i * 3);
@@ -6112,6 +6176,26 @@ var SpriteKindPool = class {
6112
6176
  if (index < 0) index = this.owners.push(name) - 1;
6113
6177
  return index;
6114
6178
  }
6179
+ sourceIndex(name) {
6180
+ let index = this.sources.ids.get(name);
6181
+ if (index === void 0) {
6182
+ index = this.sources.next++;
6183
+ this.sources.ids.set(name, index);
6184
+ }
6185
+ return index;
6186
+ }
6187
+ /** Kills the live sprites made for `source`; returns how many went. */
6188
+ clearSource(source) {
6189
+ const index = this.sources.ids.get(source);
6190
+ if (index === void 0) return 0;
6191
+ let killed = 0;
6192
+ for (let i = 0; i < this.high; i++) {
6193
+ if (!this.alive[i] || this.source[i] !== index) continue;
6194
+ this.kill(i);
6195
+ killed++;
6196
+ }
6197
+ return killed;
6198
+ }
6115
6199
  kill(i) {
6116
6200
  if (!this.alive[i]) return;
6117
6201
  this.alive[i] = 0;
@@ -6571,14 +6655,15 @@ var SpriteKindSystem = class {
6571
6655
  __publicField(this, "defs");
6572
6656
  __publicField(this, "index", /* @__PURE__ */ new Map());
6573
6657
  __publicField(this, "owners", []);
6658
+ __publicField(this, "sources", { ids: /* @__PURE__ */ new Map(), next: 0 });
6574
6659
  __publicField(this, "listeners", /* @__PURE__ */ new Map());
6575
6660
  const kinds = options.kinds ?? SPRITE_KINDS;
6576
6661
  this.ids = Object.keys(kinds);
6577
6662
  this.defs = this.ids.map((id) => kinds[id]);
6578
6663
  this.ids.forEach((id, at3) => this.index.set(id, at3));
6579
6664
  const additiveCapacity = Math.floor(options.capacity * 0.4);
6580
- this.additive = new SpriteKindPool(additiveCapacity, this.defs, this.owners);
6581
- this.normal = new SpriteKindPool(options.capacity - additiveCapacity, this.defs, this.owners);
6665
+ this.additive = new SpriteKindPool(additiveCapacity, this.defs, this.owners, this.sources);
6666
+ this.normal = new SpriteKindPool(options.capacity - additiveCapacity, this.defs, this.owners, this.sources);
6582
6667
  this.random = spriteRandom(options.seed);
6583
6668
  }
6584
6669
  get capacity() {
@@ -6652,9 +6737,16 @@ var SpriteKindSystem = class {
6652
6737
  if (this.additive.live > 0 || this.additive.drawCount > 0) this.additive.update(dt, host);
6653
6738
  if (this.normal.live > 0 || this.normal.drawCount > 0) this.normal.update(dt, host);
6654
6739
  }
6740
+ /** Kills the live sprites made for `source` (`SpriteSpawnOptions.source`); returns how many went. */
6741
+ clearSource(source) {
6742
+ const killed = this.additive.clearSource(source) + this.normal.clearSource(source);
6743
+ this.sources.ids.delete(source);
6744
+ return killed;
6745
+ }
6655
6746
  clear() {
6656
6747
  this.additive.clear();
6657
6748
  this.normal.clear();
6749
+ this.sources.ids.clear();
6658
6750
  }
6659
6751
  };
6660
6752
 
@@ -7707,7 +7799,8 @@ function createVfx(options = {}) {
7707
7799
  groundAt,
7708
7800
  ...options.marklessAt ? { marklessAt: options.marklessAt } : {},
7709
7801
  ...options.cratersAt ? { cratersAt: options.cratersAt } : {},
7710
- emit: (request) => options.onRequest?.(request)
7802
+ emit: (request) => options.onRequest?.(request),
7803
+ source: void 0
7711
7804
  };
7712
7805
  function definitionOf(id) {
7713
7806
  return explosions[id] ?? explosions[aliases[id] ?? ""];
@@ -7718,7 +7811,13 @@ function createVfx(options = {}) {
7718
7811
  return streamFor(seed ?? Math.imul(handles.events, AUTO_SEED) + (options.seed ?? 0));
7719
7812
  }
7720
7813
  function detonate(def, point, call3) {
7721
- composeExplosion(core, def, { x: point[0], y: point[1], z: point[2], direction: call3.direction, random: call3.random, handle: call3.handle });
7814
+ const outer = core.source;
7815
+ core.source = call3.source;
7816
+ try {
7817
+ composeExplosion(core, def, { x: point[0], y: point[1], z: point[2], direction: call3.direction, random: call3.random, handle: call3.handle });
7818
+ } finally {
7819
+ core.source = outer;
7820
+ }
7722
7821
  }
7723
7822
  let engine;
7724
7823
  let player;
@@ -7759,8 +7858,9 @@ function createVfx(options = {}) {
7759
7858
  const handle = ++handles.next;
7760
7859
  const direction = explosionOptions.direction && { x: explosionOptions.direction[0], y: explosionOptions.direction[1], z: explosionOptions.direction[2] };
7761
7860
  const random = streamOf(explosionOptions.seed);
7762
- if (explosionOptions.delay) core.schedule.at(core.clock.time + explosionOptions.delay, () => detonate(def, point, { direction, random, handle }));
7763
- else detonate(def, point, { direction, random, handle });
7861
+ const source = explosionOptions.source;
7862
+ if (explosionOptions.delay) core.schedule.at(core.clock.time + explosionOptions.delay, () => detonate(def, point, { direction, random, handle, source }));
7863
+ else detonate(def, point, { direction, random, handle, source });
7764
7864
  return handle;
7765
7865
  },
7766
7866
  fire(fireOptions) {
@@ -7802,6 +7902,15 @@ function createVfx(options = {}) {
7802
7902
  const fires = core.fires;
7803
7903
  for (let index = fires.items.length - 1; index >= 0; index--) if (fires.items[index].handle === handle) fires.removeAt(index);
7804
7904
  },
7905
+ clearSource(source) {
7906
+ const keep = (record, gone) => record.source !== gone;
7907
+ const drop = (pool) => {
7908
+ const before = pool.count;
7909
+ pool.compact(keep, source);
7910
+ return before - pool.count;
7911
+ };
7912
+ return drop(core.fires) + drop(core.puffs) + drop(core.sparks) + drop(core.chunks) + drop(core.glows) + spriteSystem.clearSource(source);
7913
+ },
7805
7914
  setLayer(layer, on) {
7806
7915
  layers[layer] = on;
7807
7916
  },
@@ -7896,9 +8005,9 @@ function createVfx(options = {}) {
7896
8005
  // src/data/event-effects.json
7897
8006
  var event_effects_default = {
7898
8007
  spall: "impact_{material}",
7899
- stage: { "1": "stage_crack", "2": "breach_dust", "3": "collapse_dust" },
8008
+ stage: { "1": "stage_crack_{material}", "2": "breach_dust_{material}", "3": "collapse_dust_{material}" },
7900
8009
  expose: "rebar_expose",
7901
- collapse: "collapse_dust",
8010
+ collapse: "collapse_dust_{material}",
7902
8011
  explode: "explosion",
7903
8012
  fracture: { glass: "glass_burst" }
7904
8013
  };
@@ -7908,9 +8017,14 @@ var EVENT_EFFECTS_MAP = event_effects_default;
7908
8017
  function effectForEvent(event, map = EVENT_EFFECTS_MAP) {
7909
8018
  const entry = map[event.kind];
7910
8019
  if (entry === void 0) return void 0;
7911
- if (typeof entry === "string") return event.material || !entry.includes("{material}") ? entry.replace("{material}", event.material ?? "") : void 0;
8020
+ if (typeof entry === "string") return withMaterial(entry, event.material);
7912
8021
  const key = event.stage !== void 0 ? String(event.stage) : event.material;
7913
- return key === void 0 ? void 0 : entry[key];
8022
+ const chosen = key === void 0 ? void 0 : entry[key];
8023
+ return chosen === void 0 ? void 0 : withMaterial(chosen, event.material);
8024
+ }
8025
+ function withMaterial(entry, material) {
8026
+ if (!entry.includes("{material}")) return entry;
8027
+ return material ? entry.replace("{material}", material) : void 0;
7914
8028
  }
7915
8029
 
7916
8030
  // src/locales/en.ts
@@ -9628,6 +9742,9 @@ function createWaterEffects(options = {}) {
9628
9742
  }
9629
9743
  export {
9630
9744
  AREA_CAP_GAME,
9745
+ DEBRIS_COLOR_VARIABLE,
9746
+ DEBRIS_EFFECT_FAMILIES,
9747
+ DUST_COLOR_VARIABLE,
9631
9748
  EVENT_BUDGET,
9632
9749
  EVENT_EFFECTS,
9633
9750
  EVENT_EFFECTS_MAP,
@@ -9640,6 +9757,7 @@ export {
9640
9757
  GAME_EFFECTS,
9641
9758
  LOD_GAME,
9642
9759
  LOD_LAB,
9760
+ MATERIAL_EVENT_EFFECTS,
9643
9761
  MeshPool,
9644
9762
  OrderedPool,
9645
9763
  PROFILES,
@@ -9673,6 +9791,7 @@ export {
9673
9791
  createWorkshopBehaviors,
9674
9792
  effectForEvent,
9675
9793
  estimateCost,
9794
+ explosionEffectIds,
9676
9795
  hexToLinearRgb,
9677
9796
  hexToRgb,
9678
9797
  inPuddle,