@adatechnology/game-vfx 0.5.0 → 0.6.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.
@@ -32,6 +32,7 @@ var GameVfx = (() => {
32
32
  EffectCamera: () => EffectCamera,
33
33
  EffectInstance: () => EffectInstance,
34
34
  EffectRunner: () => EffectRunner,
35
+ Enclosures: () => Enclosures,
35
36
  GAME_EFFECTS: () => GAME_EFFECTS,
36
37
  LOD_GAME: () => LOD_GAME,
37
38
  LOD_LAB: () => LOD_LAB,
@@ -72,6 +73,7 @@ var GameVfx = (() => {
72
73
  patchExplosions: () => patchExplosions,
73
74
  patchSpriteKinds: () => patchSpriteKinds,
74
75
  resolveStrings: () => resolveStrings,
76
+ slideAlong: () => slideAlong,
75
77
  streamFor: () => streamFor,
76
78
  updateScreen: () => updateScreen,
77
79
  workshopGround: () => workshopGround
@@ -1395,12 +1397,262 @@ var GameVfx = (() => {
1395
1397
  }
1396
1398
  }
1397
1399
 
1400
+ // src/random.ts
1401
+ var LEHMER_MULTIPLIER = 16807;
1402
+ var LEHMER_MODULUS = 2147483647;
1403
+ var LCG_MULTIPLIER = 1664525;
1404
+ var LCG_INCREMENT = 1013904223;
1405
+ var LCG_RANGE = 4294967296;
1406
+ var HASH_MIX = 2654435761;
1407
+ function normalizeLehmerSeed(seed) {
1408
+ const whole = Math.floor(Math.abs(seed)) % (LEHMER_MODULUS - 1);
1409
+ return whole === 0 ? 1 : whole;
1410
+ }
1411
+ function lehmer(seed) {
1412
+ let state = normalizeLehmerSeed(seed);
1413
+ const next = () => {
1414
+ state = state * LEHMER_MULTIPLIER % LEHMER_MODULUS;
1415
+ return (state - 1) / (LEHMER_MODULUS - 1);
1416
+ };
1417
+ return {
1418
+ next,
1419
+ between: (min2, max2) => min2 + (max2 - min2) * next(),
1420
+ direction(out) {
1421
+ const up = next() * 2 - 1;
1422
+ const angle = next() * Math.PI * 2;
1423
+ const ring2 = Math.sqrt(1 - up * up);
1424
+ out.x = ring2 * Math.cos(angle);
1425
+ out.y = up;
1426
+ out.z = ring2 * Math.sin(angle);
1427
+ return out;
1428
+ },
1429
+ get state() {
1430
+ return state;
1431
+ }
1432
+ };
1433
+ }
1434
+ function lcg(seed) {
1435
+ let state = seed >>> 0;
1436
+ const next = () => {
1437
+ state = Math.imul(state, LCG_MULTIPLIER) + LCG_INCREMENT >>> 0;
1438
+ return state / LCG_RANGE;
1439
+ };
1440
+ return {
1441
+ next,
1442
+ between: (min2, max2) => min2 + (max2 - min2) * next(),
1443
+ direction(out) {
1444
+ const up = next() * 2 - 1;
1445
+ const angle = next() * Math.PI * 2;
1446
+ const ring2 = Math.sqrt(1 - up * up);
1447
+ out.x = ring2 * Math.cos(angle);
1448
+ out.y = up;
1449
+ out.z = ring2 * Math.sin(angle);
1450
+ return out;
1451
+ },
1452
+ get state() {
1453
+ return state;
1454
+ }
1455
+ };
1456
+ }
1457
+ function mixEventSeed(eventSeed) {
1458
+ let mixed = Math.imul((eventSeed | 0) ^ HASH_MIX, 2246822507);
1459
+ mixed ^= mixed >>> 13;
1460
+ mixed = Math.imul(mixed, 3266489909);
1461
+ mixed ^= mixed >>> 16;
1462
+ return (mixed >>> 0) % (LEHMER_MODULUS - 1) + 1;
1463
+ }
1464
+ function streamFor(eventSeed) {
1465
+ return lehmer(mixEventSeed(eventSeed));
1466
+ }
1467
+
1468
+ // src/enclosures.ts
1469
+ var SKIN = 5e-3;
1470
+ var MAX_PAD = 0.45;
1471
+ function rotation(q) {
1472
+ const [x, y, z, w] = q ?? [0, 0, 0, 1];
1473
+ const n = Math.hypot(x, y, z, w) || 1;
1474
+ const qx = x / n;
1475
+ const qy = y / n;
1476
+ const qz = z / n;
1477
+ const qw = w / n;
1478
+ return new Float64Array([
1479
+ 1 - 2 * (qy * qy + qz * qz),
1480
+ 2 * (qx * qy - qz * qw),
1481
+ 2 * (qx * qz + qy * qw),
1482
+ 2 * (qx * qy + qz * qw),
1483
+ 1 - 2 * (qx * qx + qz * qz),
1484
+ 2 * (qy * qz - qx * qw),
1485
+ 2 * (qx * qz - qy * qw),
1486
+ 2 * (qy * qz + qx * qw),
1487
+ 1 - 2 * (qx * qx + qy * qy)
1488
+ ]);
1489
+ }
1490
+ var Enclosures = class {
1491
+ constructor(seed = 20973) {
1492
+ __publicField(this, "spaces", /* @__PURE__ */ new Map());
1493
+ __publicField(this, "list", []);
1494
+ __publicField(this, "random");
1495
+ __publicField(this, "out", { x: 0, y: 0, z: 0, nx: 0, ny: 0, nz: 0 });
1496
+ __publicField(this, "l0", new Float64Array(3));
1497
+ __publicField(this, "l1", new Float64Array(3));
1498
+ __publicField(this, "q", new Float64Array(3));
1499
+ this.random = lehmer(seed);
1500
+ }
1501
+ get empty() {
1502
+ return this.list.length === 0;
1503
+ }
1504
+ get size() {
1505
+ return this.list.length;
1506
+ }
1507
+ /** Declares, moves or (with `null`) ends the space `id`. */
1508
+ set(id, enclosure) {
1509
+ if (!enclosure) {
1510
+ if (this.spaces.delete(id)) this.list = [...this.spaces.values()];
1511
+ return;
1512
+ }
1513
+ const [hx, hy, hz] = enclosure.halfSize;
1514
+ const space = {
1515
+ cx: enclosure.center[0],
1516
+ cy: enclosure.center[1],
1517
+ cz: enclosure.center[2],
1518
+ hx: Math.abs(hx),
1519
+ hy: Math.abs(hy),
1520
+ hz: Math.abs(hz),
1521
+ r: rotation(enclosure.orientation),
1522
+ radius: Math.hypot(hx, hy, hz),
1523
+ openings: enclosure.openings ?? [],
1524
+ leak: Math.max(0, enclosure.leak ?? 0)
1525
+ };
1526
+ const old = this.spaces.get(id);
1527
+ this.spaces.set(id, space);
1528
+ const at3 = old ? this.list.indexOf(old) : -1;
1529
+ if (at3 >= 0) this.list[at3] = space;
1530
+ else this.list.push(space);
1531
+ }
1532
+ get(id) {
1533
+ const s = this.spaces.get(id);
1534
+ if (!s) return void 0;
1535
+ return { center: [s.cx, s.cy, s.cz], halfSize: [s.hx, s.hy, s.hz], openings: s.openings, leak: s.leak };
1536
+ }
1537
+ ids() {
1538
+ return [...this.spaces.keys()];
1539
+ }
1540
+ clear() {
1541
+ this.spaces.clear();
1542
+ this.list = [];
1543
+ }
1544
+ /** Whether a point is inside any space (on the inside of its walls). */
1545
+ inside(x, y, z) {
1546
+ for (const s of this.list) {
1547
+ this.toLocal(s, x, y, z, this.l0);
1548
+ if (Math.abs(this.l0[0]) <= s.hx && Math.abs(this.l0[1]) <= s.hy && Math.abs(this.l0[2]) <= s.hz) return true;
1549
+ }
1550
+ return false;
1551
+ }
1552
+ toLocal(s, x, y, z, out) {
1553
+ const dx = x - s.cx;
1554
+ const dy = y - s.cy;
1555
+ const dz = z - s.cz;
1556
+ const r = s.r;
1557
+ out[0] = r[0] * dx + r[3] * dy + r[6] * dz;
1558
+ out[1] = r[1] * dx + r[4] * dy + r[7] * dz;
1559
+ out[2] = r[2] * dx + r[5] * dy + r[8] * dz;
1560
+ }
1561
+ /** Passes at `rate` per second. */
1562
+ chance(rate, dt) {
1563
+ return rate > 0 && this.random.next() < 1 - Math.exp(-rate * dt);
1564
+ }
1565
+ /** The opening the wall point `q` (local) is in lets it through now. */
1566
+ through(s, q, dt) {
1567
+ for (const o of s.openings) {
1568
+ if (Math.abs(q[0] - o.center[0]) > o.halfSize[0] || Math.abs(q[1] - o.center[1]) > o.halfSize[1] || Math.abs(q[2] - o.center[2]) > o.halfSize[2]) continue;
1569
+ if (o.rate === void 0 || this.chance(o.rate, dt)) return true;
1570
+ }
1571
+ return this.chance(s.leak, dt);
1572
+ }
1573
+ confine(x0, y0, z0, x1, y1, z1, pad, dt) {
1574
+ const list = this.list;
1575
+ if (list.length === 0) return false;
1576
+ const p = Math.min(Math.max(0, pad), MAX_PAD);
1577
+ const l0 = this.l0;
1578
+ const l1 = this.l1;
1579
+ const q = this.q;
1580
+ for (const s of list) {
1581
+ const reach = s.radius + p + 0.05;
1582
+ const dx = x1 - s.cx;
1583
+ const dy = y1 - s.cy;
1584
+ const dz = z1 - s.cz;
1585
+ if (dx * dx + dy * dy + dz * dz > reach * reach) {
1586
+ const ex = x0 - s.cx;
1587
+ const ey = y0 - s.cy;
1588
+ const ez = z0 - s.cz;
1589
+ if (ex * ex + ey * ey + ez * ez > reach * reach) continue;
1590
+ }
1591
+ this.toLocal(s, x0, y0, z0, l0);
1592
+ this.toLocal(s, x1, y1, z1, l1);
1593
+ const h = [s.hx, s.hy, s.hz];
1594
+ const in0 = Math.abs(l0[0]) <= s.hx && Math.abs(l0[1]) <= s.hy && Math.abs(l0[2]) <= s.hz;
1595
+ let axis2 = 0;
1596
+ let sign = 1;
1597
+ if (in0) {
1598
+ if (Math.abs(l1[0]) <= s.hx && Math.abs(l1[1]) <= s.hy && Math.abs(l1[2]) <= s.hz) continue;
1599
+ for (let a = 0; a < 3; a++) q[a] = Math.min(h[a], Math.max(-h[a], l1[a]));
1600
+ if (this.through(s, q, dt)) continue;
1601
+ let worst = -Infinity;
1602
+ for (let a = 0; a < 3; a++) {
1603
+ const over = Math.abs(l1[a]) - h[a];
1604
+ if (over > worst) {
1605
+ worst = over;
1606
+ axis2 = a;
1607
+ }
1608
+ }
1609
+ sign = l1[axis2] < 0 ? -1 : 1;
1610
+ for (let a = 0; a < 3; a++) l1[a] = Math.min(h[a] - SKIN, Math.max(-(h[a] - SKIN), l1[a]));
1611
+ sign = -sign;
1612
+ } else {
1613
+ const padded0 = Math.abs(l0[0]) <= s.hx + p && Math.abs(l0[1]) <= s.hy + p && Math.abs(l0[2]) <= s.hz + p;
1614
+ const bound = padded0 ? 0 : p;
1615
+ if (!(Math.abs(l1[0]) <= s.hx + bound && Math.abs(l1[1]) <= s.hy + bound && Math.abs(l1[2]) <= s.hz + bound)) continue;
1616
+ for (let a = 0; a < 3; a++) q[a] = Math.min(h[a], Math.max(-h[a], l1[a]));
1617
+ if (this.through(s, q, dt)) continue;
1618
+ let worst = -Infinity;
1619
+ for (let a = 0; a < 3; a++) {
1620
+ const over = Math.abs(l0[a]) - (h[a] + bound);
1621
+ if (over > worst) {
1622
+ worst = over;
1623
+ axis2 = a;
1624
+ }
1625
+ }
1626
+ sign = l0[axis2] < 0 ? -1 : 1;
1627
+ l1[axis2] = sign * (h[axis2] + bound + SKIN);
1628
+ }
1629
+ const r = s.r;
1630
+ const out = this.out;
1631
+ out.x = s.cx + r[0] * l1[0] + r[1] * l1[1] + r[2] * l1[2];
1632
+ out.y = s.cy + r[3] * l1[0] + r[4] * l1[1] + r[5] * l1[2];
1633
+ out.z = s.cz + r[6] * l1[0] + r[7] * l1[1] + r[8] * l1[2];
1634
+ out.nx = r[axis2] * sign;
1635
+ out.ny = r[3 + axis2] * sign;
1636
+ out.nz = r[6 + axis2] * sign;
1637
+ return true;
1638
+ }
1639
+ return false;
1640
+ }
1641
+ };
1642
+ function slideAlong(out, vx2, vy2, vz2) {
1643
+ const into = vx2 * out.nx + vy2 * out.ny + vz2 * out.nz;
1644
+ if (into >= 0) return [vx2, vy2, vz2];
1645
+ return [vx2 - into * out.nx, vy2 - into * out.ny, vz2 - into * out.nz];
1646
+ }
1647
+
1398
1648
  // src/pools/puffs.ts
1399
1649
  var FLOOR_FRACTION = 0.4;
1400
1650
  var FLOOR_BOUNCE = -0.2;
1401
1651
  var ARRIVAL_FRAME = 30;
1402
1652
  var ARRIVAL_BASE = 0.3;
1403
1653
  var GROWTH_CAP_SECONDS = 3.5;
1654
+ var CARRIED_KINDS = [true, true, false, true, false];
1655
+ var PAD_OF_SIZE = 0.35;
1404
1656
  function createPuffPool(capacity) {
1405
1657
  const placeholder = { next: () => 0, between: (min2) => min2, direction: (out) => out, state: 0 };
1406
1658
  return new OrderedPool(capacity, () => ({
@@ -1495,13 +1747,24 @@ var GameVfx = (() => {
1495
1747
  if (puff3.vy < 0) puff3.vy *= FLOOR_BOUNCE;
1496
1748
  }
1497
1749
  }
1498
- function updatePuffs(pool, dt, wind) {
1750
+ function updatePuffs(pool, dt, wind, confiner) {
1499
1751
  pool.compact(ageOrKeep2, dt);
1752
+ const confining = confiner !== void 0 && !confiner.empty;
1500
1753
  for (const puff3 of pool.items) {
1501
1754
  const age = puff3.t / puff3.life;
1502
1755
  const heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
1756
+ const x0 = puff3.x;
1757
+ const y0 = puff3.y;
1758
+ const z0 = puff3.z;
1503
1759
  if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
1504
1760
  else moveFree(puff3, dt, age, heat, wind);
1761
+ if (confining && CARRIED_KINDS[puff3.kind] && confiner.confine(x0, y0, z0, puff3.x, puff3.y, puff3.z, puff3.size * PAD_OF_SIZE, dt)) {
1762
+ const out = confiner.out;
1763
+ puff3.x = out.x;
1764
+ puff3.y = out.y;
1765
+ puff3.z = out.z;
1766
+ [puff3.vx, puff3.vy, puff3.vz] = slideAlong(out, puff3.vx, puff3.vy, puff3.vz);
1767
+ }
1505
1768
  const size = puff3.s0 + (puff3.s1 - puff3.s0) * (1 - Math.exp(-puff3.t * puff3.gk)) + puff3.sg * Math.min(puff3.t, GROWTH_CAP_SECONDS);
1506
1769
  puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
1507
1770
  puff3.age = age;
@@ -2055,10 +2318,10 @@ var GameVfx = (() => {
2055
2318
  };
2056
2319
 
2057
2320
  // src/effects/props.ts
2058
- function localToWorld(translation, rotation, local2) {
2321
+ function localToWorld(translation, rotation2, local2) {
2059
2322
  const [x, y, z] = local2;
2060
- const [a, c, e] = [Math.cos(rotation[0]), Math.cos(rotation[1]), Math.cos(rotation[2])];
2061
- const [b, d, f] = [Math.sin(rotation[0]), Math.sin(rotation[1]), Math.sin(rotation[2])];
2323
+ const [a, c, e] = [Math.cos(rotation2[0]), Math.cos(rotation2[1]), Math.cos(rotation2[2])];
2324
+ const [b, d, f] = [Math.sin(rotation2[0]), Math.sin(rotation2[1]), Math.sin(rotation2[2])];
2062
2325
  const [ae, af, be, bf] = [a * e, a * f, b * e, b * f];
2063
2326
  return [
2064
2327
  c * e * x + -c * f * y + d * z + translation[0],
@@ -3815,74 +4078,6 @@ var GameVfx = (() => {
3815
4078
  return result;
3816
4079
  }
3817
4080
 
3818
- // src/random.ts
3819
- var LEHMER_MULTIPLIER = 16807;
3820
- var LEHMER_MODULUS = 2147483647;
3821
- var LCG_MULTIPLIER = 1664525;
3822
- var LCG_INCREMENT = 1013904223;
3823
- var LCG_RANGE = 4294967296;
3824
- var HASH_MIX = 2654435761;
3825
- function normalizeLehmerSeed(seed) {
3826
- const whole = Math.floor(Math.abs(seed)) % (LEHMER_MODULUS - 1);
3827
- return whole === 0 ? 1 : whole;
3828
- }
3829
- function lehmer(seed) {
3830
- let state = normalizeLehmerSeed(seed);
3831
- const next = () => {
3832
- state = state * LEHMER_MULTIPLIER % LEHMER_MODULUS;
3833
- return (state - 1) / (LEHMER_MODULUS - 1);
3834
- };
3835
- return {
3836
- next,
3837
- between: (min2, max2) => min2 + (max2 - min2) * next(),
3838
- direction(out) {
3839
- const up = next() * 2 - 1;
3840
- const angle = next() * Math.PI * 2;
3841
- const ring2 = Math.sqrt(1 - up * up);
3842
- out.x = ring2 * Math.cos(angle);
3843
- out.y = up;
3844
- out.z = ring2 * Math.sin(angle);
3845
- return out;
3846
- },
3847
- get state() {
3848
- return state;
3849
- }
3850
- };
3851
- }
3852
- function lcg(seed) {
3853
- let state = seed >>> 0;
3854
- const next = () => {
3855
- state = Math.imul(state, LCG_MULTIPLIER) + LCG_INCREMENT >>> 0;
3856
- return state / LCG_RANGE;
3857
- };
3858
- return {
3859
- next,
3860
- between: (min2, max2) => min2 + (max2 - min2) * next(),
3861
- direction(out) {
3862
- const up = next() * 2 - 1;
3863
- const angle = next() * Math.PI * 2;
3864
- const ring2 = Math.sqrt(1 - up * up);
3865
- out.x = ring2 * Math.cos(angle);
3866
- out.y = up;
3867
- out.z = ring2 * Math.sin(angle);
3868
- return out;
3869
- },
3870
- get state() {
3871
- return state;
3872
- }
3873
- };
3874
- }
3875
- function mixEventSeed(eventSeed) {
3876
- let mixed = Math.imul((eventSeed | 0) ^ HASH_MIX, 2246822507);
3877
- mixed ^= mixed >>> 13;
3878
- mixed = Math.imul(mixed, 3266489909);
3879
- mixed ^= mixed >>> 16;
3880
- return (mixed >>> 0) % (LEHMER_MODULUS - 1) + 1;
3881
- }
3882
- function streamFor(eventSeed) {
3883
- return lehmer(mixEventSeed(eventSeed));
3884
- }
3885
-
3886
4081
  // src/effects/builders/impact-table.ts
3887
4082
  var TABLE = {
3888
4083
  concrete: { dust: 9078138, chip: 7236195, spark: 2 },
@@ -5233,8 +5428,8 @@ var GameVfx = (() => {
5233
5428
  function addScorch(store, random, x, z, radius) {
5234
5429
  const variant = Math.floor(random.next() * SCORCH_VARIANTS);
5235
5430
  const lift = 0.03 + nextLift(store) * 1e-3;
5236
- const rotation = random.next() * 6;
5237
- store.add({ kind: "scorch", x, z, radius, variant, lift, rotation });
5431
+ const rotation2 = random.next() * 6;
5432
+ store.add({ kind: "scorch", x, z, radius, variant, lift, rotation: rotation2 });
5238
5433
  }
5239
5434
  function addRimRocks(store, ground, random, x, z, radius) {
5240
5435
  const count = Math.round(6 + radius * 7);
@@ -5263,8 +5458,8 @@ var GameVfx = (() => {
5263
5458
  function addCrater(store, ground, random, spec) {
5264
5459
  ground?.dent(random, spec.x, spec.z, spec.radius, spec.depth);
5265
5460
  if (!spec.marks) return;
5266
- const rotation = random.next() * 6;
5267
- store.add({ kind: "dirt", x: spec.x, z: spec.z, radius: spec.radius * 1.02, lift: 0.045, rotation });
5461
+ const rotation2 = random.next() * 6;
5462
+ store.add({ kind: "dirt", x: spec.x, z: spec.z, radius: spec.radius * 1.02, lift: 0.045, rotation: rotation2 });
5268
5463
  addRimRocks(store, ground, random, spec.x, spec.z, spec.radius);
5269
5464
  }
5270
5465
  function addBloodSplat(store, ground, random, spec) {
@@ -5832,6 +6027,7 @@ var GameVfx = (() => {
5832
6027
  }
5833
6028
 
5834
6029
  // src/sprites/kind-pool.ts
6030
+ var PAD_OF_SIZE2 = 0.35;
5835
6031
  var clamp4 = (v, lo, hi) => v < lo ? lo : v > hi ? hi : v;
5836
6032
  var lerp4 = (a, b, t) => a + (b - a) * t;
5837
6033
  function rgb(hex) {
@@ -5992,9 +6188,20 @@ var GameVfx = (() => {
5992
6188
  vy2 *= k;
5993
6189
  vz2 *= k;
5994
6190
  }
5995
- const x = this.position[i3] + vx2 * dt;
6191
+ let x = this.position[i3] + vx2 * dt;
5996
6192
  let y = this.position[i3 + 1] + vy2 * dt;
5997
- const z = this.position[i3 + 2] + vz2 * dt;
6193
+ let z = this.position[i3 + 2] + vz2 * dt;
6194
+ const confiner = host.confiner;
6195
+ if (def.carried && confiner && !confiner.empty) {
6196
+ const pad = this.size0[i] * lerp4(1, def.grow, t) * PAD_OF_SIZE2;
6197
+ if (confiner.confine(this.position[i3], this.position[i3 + 1], this.position[i3 + 2], x, y, z, pad, dt)) {
6198
+ const out = confiner.out;
6199
+ x = out.x;
6200
+ y = out.y;
6201
+ z = out.z;
6202
+ [vx2, vy2, vz2] = slideAlong(out, vx2, vy2, vz2);
6203
+ }
6204
+ }
5998
6205
  if (def.ground !== "none") {
5999
6206
  const own = this.floor[i];
6000
6207
  const gy = Number.isNaN(own) ? host.groundAt(x, z) + 5e-3 : own;
@@ -6082,7 +6289,8 @@ var GameVfx = (() => {
6082
6289
  alpha: 0.35,
6083
6290
  fadeIn: 0.15,
6084
6291
  cone: 0.6,
6085
- ground: "none"
6292
+ ground: "none",
6293
+ carried: true
6086
6294
  },
6087
6295
  sparks: {
6088
6296
  id: "sparks",
@@ -6126,7 +6334,8 @@ var GameVfx = (() => {
6126
6334
  alpha: 0.4,
6127
6335
  fadeIn: 0.1,
6128
6336
  cone: 0.4,
6129
- ground: "none"
6337
+ ground: "none",
6338
+ carried: true
6130
6339
  },
6131
6340
  shards: {
6132
6341
  id: "shards",
@@ -6284,7 +6493,8 @@ var GameVfx = (() => {
6284
6493
  fadeIn: 0.1,
6285
6494
  cone: 0.5,
6286
6495
  ground: "stop",
6287
- flutter: 0.6
6496
+ flutter: 0.6,
6497
+ carried: true
6288
6498
  },
6289
6499
  steam: {
6290
6500
  id: "steam",
@@ -6306,7 +6516,8 @@ var GameVfx = (() => {
6306
6516
  alpha: 0.35,
6307
6517
  fadeIn: 0.15,
6308
6518
  cone: 0.6,
6309
- ground: "none"
6519
+ ground: "none",
6520
+ carried: true
6310
6521
  },
6311
6522
  flash: {
6312
6523
  id: "flash",
@@ -6451,7 +6662,8 @@ var GameVfx = (() => {
6451
6662
  const host = {
6452
6663
  groundAt: this.options.groundAt,
6453
6664
  gravity: this.options.gravity,
6454
- land: (owner, x, y, z, color, tag) => this.listeners.get(owner)?.(x, y, z, color, tag)
6665
+ land: (owner, x, y, z, color, tag) => this.listeners.get(owner)?.(x, y, z, color, tag),
6666
+ ...this.options.confiner ? { confiner: this.options.confiner } : {}
6455
6667
  };
6456
6668
  if (this.additive.live > 0 || this.additive.drawCount > 0) this.additive.update(dt, host);
6457
6669
  if (this.normal.live > 0 || this.normal.drawCount > 0) this.normal.update(dt, host);
@@ -6663,8 +6875,8 @@ var GameVfx = (() => {
6663
6875
  * Takes away the marks inside a box: world `center`, `half` extents along the axes of the world `rotation` (a quaternion, x y z w; none means the
6664
6876
  * world axes). The surface they were on is gone (a brick came out of a wall with its bullet holes). Returns how many went.
6665
6877
  */
6666
- clearInside(center, half, rotation = [0, 0, 0, 1]) {
6667
- const qx = -rotation[0], qy = -rotation[1], qz = -rotation[2], qw = rotation[3];
6878
+ clearInside(center, half, rotation2 = [0, 0, 0, 1]) {
6879
+ const qx = -rotation2[0], qy = -rotation2[1], qz = -rotation2[2], qw = rotation2[3];
6668
6880
  let gone = 0;
6669
6881
  for (const decal2 of this.decals) {
6670
6882
  if (!decal2.on) continue;
@@ -6789,10 +7001,14 @@ var GameVfx = (() => {
6789
7001
  var DEFAULT_FADE_IN = 0.1;
6790
7002
  var FLOATS_PER_VECTOR = 3;
6791
7003
  var BYTE_MAX2 = 255;
7004
+ var CARRIED_GRAVITY = 3;
7005
+ var PAD_OF_SIZE3 = 0.35;
6792
7006
  var SpritePool = class {
6793
- constructor(capacity, context) {
7007
+ /** `carried`: the normal-blend pool (smoke, dust, steam), whose light sprites go round the closed spaces; the additive one (flames, sparks) does not. */
7008
+ constructor(capacity, context, carried = false) {
6794
7009
  __publicField(this, "capacity", capacity);
6795
7010
  __publicField(this, "context", context);
7011
+ __publicField(this, "carried", carried);
6796
7012
  __publicField(this, "count", 0);
6797
7013
  __publicField(this, "position");
6798
7014
  __publicField(this, "velocity");
@@ -6893,6 +7109,7 @@ var GameVfx = (() => {
6893
7109
  }
6894
7110
  update(dt, leaveDecal) {
6895
7111
  const { position, velocity } = this;
7112
+ const confiner = this.context.confiner;
6896
7113
  for (let index = this.count - 1; index >= 0; index--) {
6897
7114
  this.life[index] -= dt;
6898
7115
  if (this.life[index] <= 0) {
@@ -6906,9 +7123,25 @@ var GameVfx = (() => {
6906
7123
  velocity[offset] *= factor;
6907
7124
  velocity[offset + 1] *= factor;
6908
7125
  velocity[offset + 2] *= factor;
7126
+ const x0 = position[offset];
7127
+ const y0 = position[offset + 1];
7128
+ const z0 = position[offset + 2];
6909
7129
  position[offset] += velocity[offset] * dt;
6910
7130
  position[offset + 1] += velocity[offset + 1] * dt;
6911
7131
  position[offset + 2] += velocity[offset + 2] * dt;
7132
+ if (this.carried && confiner && !confiner.empty && Math.abs(this.gravity[index]) < CARRIED_GRAVITY) {
7133
+ const size = this.startSize[index] * (1 + (this.growth[index] - 1) * age);
7134
+ if (confiner.confine(x0, y0, z0, position[offset], position[offset + 1], position[offset + 2], size * PAD_OF_SIZE3, dt)) {
7135
+ const out = confiner.out;
7136
+ position[offset] = out.x;
7137
+ position[offset + 1] = out.y;
7138
+ position[offset + 2] = out.z;
7139
+ const [vx2, vy2, vz2] = slideAlong(out, velocity[offset], velocity[offset + 1], velocity[offset + 2]);
7140
+ velocity[offset] = vx2;
7141
+ velocity[offset + 1] = vy2;
7142
+ velocity[offset + 2] = vz2;
7143
+ }
7144
+ }
6912
7145
  const mode = this.groundMode[index];
6913
7146
  if (mode) {
6914
7147
  const groundHeight = this.context.groundAt(position[offset], position[offset + 2]);
@@ -7193,9 +7426,9 @@ var GameVfx = (() => {
7193
7426
  __publicField(this, "placement");
7194
7427
  __publicField(this, "accumulators", /* @__PURE__ */ new Map());
7195
7428
  const profile = options.profile ?? PROFILES.high;
7196
- this.context = { random: options.random, groundAt: options.groundAt ?? workshopGround, quality: { level: 0, mult: 1 }, trace: options.trace };
7429
+ this.context = { random: options.random, groundAt: options.groundAt ?? workshopGround, quality: { level: 0, mult: 1 }, trace: options.trace, ...options.confiner ? { confiner: options.confiner } : {} };
7197
7430
  this.add = new SpritePool(profile.sprites.add, this.context);
7198
- this.normal = new SpritePool(profile.sprites.normal, this.context);
7431
+ this.normal = new SpritePool(profile.sprites.normal, this.context, true);
7199
7432
  this.streaks = new StreakPool(profile.streaks, this.context);
7200
7433
  this.debris = new DebrisPool(this.context);
7201
7434
  this.decals = new DecalPool(this.context);
@@ -7387,12 +7620,14 @@ var GameVfx = (() => {
7387
7620
  const groundAt = options.groundAt ?? (ground ? (x, z) => ground.heightAt(x, z) : () => 0);
7388
7621
  const handles = { next: 0, events: 0 };
7389
7622
  const low = options.profile === "low";
7623
+ const enclosures = new Enclosures(20973 + (options.seed ?? 0));
7390
7624
  const spriteSystem = new SpriteKindSystem({
7391
7625
  capacity: options.sprites?.capacity ?? (low ? 1250 : 2500),
7392
7626
  density: options.sprites?.density ?? (low ? 0.6 : 1),
7393
7627
  seed: 2654435761 + (options.seed ?? 0),
7394
7628
  groundAt,
7395
7629
  gravity: options.gravity ?? DEFAULT_GRAVITY,
7630
+ confiner: enclosures,
7396
7631
  ...options.sprites?.kinds ? { kinds: options.sprites.kinds } : {}
7397
7632
  });
7398
7633
  const core = {
@@ -7442,7 +7677,7 @@ var GameVfx = (() => {
7442
7677
  return [camera2.x, camera2.y, camera2.z];
7443
7678
  }, forward: (local2) => [local2[0] ?? 0, local2[1] ?? 0, local2[2] ?? 0] };
7444
7679
  function workshop() {
7445
- return engine ?? (engine = new WorkshopEngine({ random: sharedRandom, profile, groundAt }));
7680
+ return engine ?? (engine = new WorkshopEngine({ random: sharedRandom, profile, groundAt, confiner: enclosures }));
7446
7681
  }
7447
7682
  function effectPlayer() {
7448
7683
  return player ?? (player = createEffectPlayer({ engine: workshop(), effects, view }));
@@ -7501,6 +7736,10 @@ var GameVfx = (() => {
7501
7736
  puff3.vz += dz * strength;
7502
7737
  }
7503
7738
  },
7739
+ enclose(id, enclosure) {
7740
+ enclosures.set(id, enclosure);
7741
+ },
7742
+ enclosures: () => enclosures,
7504
7743
  stop(handle) {
7505
7744
  player?.stop(handle);
7506
7745
  const fires = core.fires;
@@ -7528,7 +7767,7 @@ var GameVfx = (() => {
7528
7767
  core.clock.time += dt;
7529
7768
  core.schedule.update(core.clock.time);
7530
7769
  updateRings(core.rings, dt);
7531
- updatePuffs(core.puffs, dt, wind);
7770
+ updatePuffs(core.puffs, dt, wind, enclosures);
7532
7771
  updateSparks(core.sparks, { dt, groundAt });
7533
7772
  updateGlows(core.glows, dt);
7534
7773
  updateShocks(core.shocks, core.puffs.items, dt);