@adatechnology/game-vfx 0.1.3 → 0.3.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.
@@ -35,15 +35,20 @@ var GameVfx = (() => {
35
35
  GAME_EFFECTS: () => GAME_EFFECTS,
36
36
  LOD_GAME: () => LOD_GAME,
37
37
  LOD_LAB: () => LOD_LAB,
38
+ MeshPool: () => MeshPool,
38
39
  OrderedPool: () => OrderedPool,
39
40
  PROFILES: () => PROFILES,
41
+ RAIN_CAPACITY: () => RAIN_CAPACITY,
42
+ RainField: () => RainField,
40
43
  SMOKE_COLORS: () => SMOKE_COLORS,
41
44
  SPRITE_KINDS: () => SPRITE_KINDS,
42
45
  SpriteKindPool: () => SpriteKindPool,
43
46
  SpriteKindSystem: () => SpriteKindSystem,
44
47
  VFX_LAYERS: () => VFX_LAYERS,
48
+ VIEWMODEL_EFFECTS: () => VIEWMODEL_EFFECTS,
45
49
  WORKSHOP_BEHAVIORS: () => WORKSHOP_BEHAVIORS,
46
50
  WORKSHOP_EFFECTS: () => WORKSHOP_EFFECTS,
51
+ WORKSHOP_PUDDLES: () => WORKSHOP_PUDDLES,
47
52
  WorkshopEngine: () => WorkshopEngine,
48
53
  colorOfChunk: () => colorOfChunk,
49
54
  composeExplosion: () => composeExplosion,
@@ -58,6 +63,7 @@ var GameVfx = (() => {
58
63
  estimateCost: () => estimateCost,
59
64
  hexToLinearRgb: () => hexToLinearRgb,
60
65
  hexToRgb: () => hexToRgb,
66
+ inPuddle: () => inPuddle,
61
67
  lcg: () => lcg,
62
68
  lehmer: () => lehmer,
63
69
  locales: () => locales,
@@ -1429,77 +1435,77 @@ var GameVfx = (() => {
1429
1435
  }));
1430
1436
  }
1431
1437
  function spawnPuff(pool, random, init) {
1432
- const puff2 = pool.acquire();
1433
- puff2.x = init.x ?? 0;
1434
- puff2.y = init.y ?? 0;
1435
- puff2.z = init.z ?? 0;
1436
- puff2.vx = init.vx ?? 0;
1437
- puff2.vy = init.vy ?? 0;
1438
- puff2.vz = init.vz ?? 0;
1439
- puff2.s0 = init.s0 ?? 0.2;
1440
- puff2.s1 = init.s1 ?? 1;
1441
- puff2.sg = init.sg ?? 0.1;
1442
- puff2.gk = init.gk ?? 6;
1443
- puff2.life = init.life ?? 3;
1444
- puff2.t = 0;
1445
- puff2.h0 = init.h0 ?? 0;
1446
- puff2.hl = init.hl ?? 0.4;
1447
- puff2.drag = init.drag ?? 3;
1448
- puff2.buoy = init.buoy ?? 0.5;
1449
- puff2.grav = init.grav ?? 0;
1450
- puff2.kind = init.kind ?? 0;
1451
- puff2.seed = random.next();
1452
- puff2.wind = init.wind ?? 1;
1453
- puff2.color = init.color ?? SMOKE_COLORS.grey;
1454
- puff2.ring = init.ring ?? null;
1455
- puff2.ph = init.ph ?? 0;
1456
- puff2.th = init.th ?? 0;
1457
- puff2.rng = random;
1458
- puff2.age = 0;
1459
- puff2.heat = 0;
1460
- puff2.size = 0;
1461
- return puff2;
1462
- }
1463
- function ageOrKeep2(puff2, dt) {
1464
- puff2.t += dt;
1465
- return puff2.t < puff2.life;
1466
- }
1467
- function moveOnRing(puff2, ring2, wind) {
1438
+ const puff3 = pool.acquire();
1439
+ puff3.x = init.x ?? 0;
1440
+ puff3.y = init.y ?? 0;
1441
+ puff3.z = init.z ?? 0;
1442
+ puff3.vx = init.vx ?? 0;
1443
+ puff3.vy = init.vy ?? 0;
1444
+ puff3.vz = init.vz ?? 0;
1445
+ puff3.s0 = init.s0 ?? 0.2;
1446
+ puff3.s1 = init.s1 ?? 1;
1447
+ puff3.sg = init.sg ?? 0.1;
1448
+ puff3.gk = init.gk ?? 6;
1449
+ puff3.life = init.life ?? 3;
1450
+ puff3.t = 0;
1451
+ puff3.h0 = init.h0 ?? 0;
1452
+ puff3.hl = init.hl ?? 0.4;
1453
+ puff3.drag = init.drag ?? 3;
1454
+ puff3.buoy = init.buoy ?? 0.5;
1455
+ puff3.grav = init.grav ?? 0;
1456
+ puff3.kind = init.kind ?? 0;
1457
+ puff3.seed = random.next();
1458
+ puff3.wind = init.wind ?? 1;
1459
+ puff3.color = init.color ?? SMOKE_COLORS.grey;
1460
+ puff3.ring = init.ring ?? null;
1461
+ puff3.ph = init.ph ?? 0;
1462
+ puff3.th = init.th ?? 0;
1463
+ puff3.rng = random;
1464
+ puff3.age = 0;
1465
+ puff3.heat = 0;
1466
+ puff3.size = 0;
1467
+ return puff3;
1468
+ }
1469
+ function ageOrKeep2(puff3, dt) {
1470
+ puff3.t += dt;
1471
+ return puff3.t < puff3.life;
1472
+ }
1473
+ function moveOnRing(puff3, ring2, wind) {
1468
1474
  const ringTime = ring2.t;
1469
1475
  const centerY = ring2.y0 + ring2.rise * (1 - Math.exp(-ringTime * ring2.rk));
1470
1476
  const majorRadius = ring2.R0 + (ring2.R1 - ring2.R0) * (1 - Math.exp(-ringTime * 1.6));
1471
- const theta = puff2.th + ringTime * ring2.roll;
1477
+ const theta = puff3.th + ringTime * ring2.roll;
1472
1478
  const minorRadius = ring2.r * (0.8 + 0.4 * Math.min(1, ringTime));
1473
1479
  const radius = majorRadius + minorRadius * Math.cos(theta);
1474
- puff2.x = ring2.x + Math.cos(puff2.ph) * radius + wind.x * ringTime * 0.6;
1475
- puff2.z = ring2.z + Math.sin(puff2.ph) * radius + wind.z * ringTime * 0.6;
1476
- puff2.y = centerY + minorRadius * Math.sin(theta);
1477
- }
1478
- function moveFree(puff2, dt, age, heat, wind) {
1479
- const damping = Math.exp(-puff2.drag * dt);
1480
- puff2.vx *= damping;
1481
- puff2.vy *= damping;
1482
- puff2.vz *= damping;
1483
- puff2.vy += (puff2.buoy * (heat > 0 ? 1.6 : 1) - puff2.grav) * dt;
1484
- puff2.x += (puff2.vx + wind.x * puff2.wind * age) * dt;
1485
- puff2.y += puff2.vy * dt;
1486
- puff2.z += (puff2.vz + wind.z * puff2.wind * age) * dt;
1487
- if (puff2.y < puff2.s0 * FLOOR_FRACTION) {
1488
- puff2.y = puff2.s0 * FLOOR_FRACTION;
1489
- if (puff2.vy < 0) puff2.vy *= FLOOR_BOUNCE;
1480
+ puff3.x = ring2.x + Math.cos(puff3.ph) * radius + wind.x * ringTime * 0.6;
1481
+ puff3.z = ring2.z + Math.sin(puff3.ph) * radius + wind.z * ringTime * 0.6;
1482
+ puff3.y = centerY + minorRadius * Math.sin(theta);
1483
+ }
1484
+ function moveFree(puff3, dt, age, heat, wind) {
1485
+ const damping = Math.exp(-puff3.drag * dt);
1486
+ puff3.vx *= damping;
1487
+ puff3.vy *= damping;
1488
+ puff3.vz *= damping;
1489
+ puff3.vy += (puff3.buoy * (heat > 0 ? 1.6 : 1) - puff3.grav) * dt;
1490
+ puff3.x += (puff3.vx + wind.x * puff3.wind * age) * dt;
1491
+ puff3.y += puff3.vy * dt;
1492
+ puff3.z += (puff3.vz + wind.z * puff3.wind * age) * dt;
1493
+ if (puff3.y < puff3.s0 * FLOOR_FRACTION) {
1494
+ puff3.y = puff3.s0 * FLOOR_FRACTION;
1495
+ if (puff3.vy < 0) puff3.vy *= FLOOR_BOUNCE;
1490
1496
  }
1491
1497
  }
1492
1498
  function updatePuffs(pool, dt, wind) {
1493
1499
  pool.compact(ageOrKeep2, dt);
1494
- for (const puff2 of pool.items) {
1495
- const age = puff2.t / puff2.life;
1496
- const heat = puff2.h0 > 0 ? puff2.h0 * Math.pow(Math.max(0, 1 - puff2.t / puff2.hl), 1.25) : 0;
1497
- if (puff2.ring) moveOnRing(puff2, puff2.ring, wind);
1498
- else moveFree(puff2, dt, age, heat, wind);
1499
- const size = puff2.s0 + (puff2.s1 - puff2.s0) * (1 - Math.exp(-puff2.t * puff2.gk)) + puff2.sg * Math.min(puff2.t, GROWTH_CAP_SECONDS);
1500
- puff2.size = size * Math.min(1, puff2.t * ARRIVAL_FRAME + ARRIVAL_BASE);
1501
- puff2.age = age;
1502
- puff2.heat = heat;
1500
+ for (const puff3 of pool.items) {
1501
+ const age = puff3.t / puff3.life;
1502
+ const heat = puff3.h0 > 0 ? puff3.h0 * Math.pow(Math.max(0, 1 - puff3.t / puff3.hl), 1.25) : 0;
1503
+ if (puff3.ring) moveOnRing(puff3, puff3.ring, wind);
1504
+ else moveFree(puff3, dt, age, heat, wind);
1505
+ 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
+ puff3.size = size * Math.min(1, puff3.t * ARRIVAL_FRAME + ARRIVAL_BASE);
1507
+ puff3.age = age;
1508
+ puff3.heat = heat;
1503
1509
  }
1504
1510
  }
1505
1511
 
@@ -1560,9 +1566,9 @@ var GameVfx = (() => {
1560
1566
  var HOT_GLOW_COLOR = [1, 0.45, 0.12];
1561
1567
  function addPuff(core, random, init) {
1562
1568
  core.spawned.puffs++;
1563
- const puff2 = spawnPuff(core.puffs, random, init);
1564
- core.trace?.puff?.(puff2);
1565
- return puff2;
1569
+ const puff3 = spawnPuff(core.puffs, random, init);
1570
+ core.trace?.puff?.(puff3);
1571
+ return puff3;
1566
1572
  }
1567
1573
  function addSpark(core, init) {
1568
1574
  core.spawned.sparks++;
@@ -1748,6 +1754,7 @@ var GameVfx = (() => {
1748
1754
  var neg = call("neg");
1749
1755
  var abs = call("abs");
1750
1756
  var sqrt = call("sqrt");
1757
+ var exp = call("exp");
1751
1758
  var sin = call("sin");
1752
1759
  var cos = call("cos");
1753
1760
  var atan2 = call("atan2");
@@ -1793,12 +1800,14 @@ var GameVfx = (() => {
1793
1800
  var INDEX = { $: "index" };
1794
1801
  var QUALITY = { $: "quality" };
1795
1802
  var FRESH = { $: "fresh" };
1803
+ var DIRECTION = { $: "direction" };
1796
1804
  var CAMERA_POSITION = { $: "cameraPosition" };
1797
1805
 
1798
1806
  // src/effects/steps.ts
1799
1807
  var burst = (system, count, spawn2) => ({ op: "burst", system, count, spawn: spawn2 });
1800
1808
  var spawn = (system, options) => ({ op: "spawn", system, spawn: options });
1801
1809
  var emit = (key, system, rate, options) => ({ op: "emit", key, system, rate, spawn: options });
1810
+ var mesh = (options) => ({ op: "mesh", spawn: options });
1802
1811
  var debris = (options) => ({ op: "debris", spawn: options });
1803
1812
  var decal = (...args) => ({ op: "decal", args });
1804
1813
  var ring = (...args) => ({ op: "ring", args });
@@ -2867,6 +2876,256 @@ var GameVfx = (() => {
2867
2876
  ]
2868
2877
  };
2869
2878
 
2879
+ // src/effects/world/fog-and-ash.ts
2880
+ var SPOTS_X = [-3, 1, 5];
2881
+ var SPOTS_Z = [-1, -2.4, 0.4];
2882
+ var FOG_AND_ASH = {
2883
+ id: "fog_and_ash",
2884
+ pageId: "neblina",
2885
+ team: "world",
2886
+ budget: { particles: 120, lights: 1 },
2887
+ loop: 0,
2888
+ view: { eye: [3, 1.8, 7.5], target: [-3, 1.2, -1] },
2889
+ setup: [
2890
+ cue("fog", { density: 0.075 }),
2891
+ cue("lamp_cone", { visible: true }),
2892
+ cue("zombie_visible", { index: -1, visible: false }),
2893
+ repeat(
2894
+ SPOTS_X.length,
2895
+ set("turn", rnd(-0.6, 0.6)),
2896
+ behavior("walkers", "place", { index: INDEX, x: pick(SPOTS_X, INDEX), z: pick(SPOTS_Z, INDEX), facing: variable("turn") })
2897
+ )
2898
+ ],
2899
+ timeline: [],
2900
+ tick: [
2901
+ emit("fog", "normal", 5, { p: [rnd(-14, 10), rnd(0.2, 1.1), rnd(-3, 8)], v: [rnd(0.15, 0.35), 0, rnd(-0.05, 0.05)], sp: 0, life: [9, 13], size: [3, 5], grow: 1.4, c0: 8227488, a: 0.13, fi: 0.35 }),
2902
+ emit("ash", "normal", 14, { p: [rnd(-10, 8), rnd(4, 6), rnd(-3, 7)], v: [rnd(0.1, 0.4), -0.35, rnd(-0.1, 0.1)], sp: [0.05, 0.15], life: [8, 12], size: [0.025, 0.04], c0: 10525328, a: 0.75, fi: 0.1, gnd: 1 })
2903
+ ]
2904
+ };
2905
+
2906
+ // src/workshop/rain.ts
2907
+ var RAIN_CAPACITY = 4e3;
2908
+ var FALL_SPEED = 15;
2909
+ var WIND_PER_FALL = 0.07;
2910
+ var STREAK_SLANT = 0.04;
2911
+ var STREAK_LENGTH = 0.6;
2912
+ var BOX_X = [-15, 15];
2913
+ var BOX_Z = [-6, 16];
2914
+ var START_HEIGHT = [0, 16];
2915
+ var REENTRY_HEIGHT = [14, 17];
2916
+ var SPLASH_CHANCE = 0.35;
2917
+ var SPLASH_RANGE = 12;
2918
+ var SPRITE_CHANCE = 0.5;
2919
+ var UP9 = [0, 1, 0];
2920
+ var WORKSHOP_PUDDLES = [
2921
+ [-1.5, 2.2, 1.6, 0.9],
2922
+ [3, 3.6, 1.1, 0.7],
2923
+ [-6, 3.2, 1.3, 0.8],
2924
+ [1.4, -2.2, 0.9, 0.5]
2925
+ ];
2926
+ var inPuddle = (puddles, x, z) => puddles.some((p) => ((x - p[0]) / p[2]) ** 2 + ((z - p[1]) / p[3]) ** 2 < 1);
2927
+ var RainField = class {
2928
+ constructor(engine) {
2929
+ __publicField(this, "engine", engine);
2930
+ /** Two points per streak: x, y, z of the top and x, y, z of the bottom. */
2931
+ __publicField(this, "positions", new Float32Array(RAIN_CAPACITY * 6));
2932
+ /** Streaks alive. */
2933
+ __publicField(this, "count", 0);
2934
+ /** The slant (the wind along x in the Workshop's units). */
2935
+ __publicField(this, "wind", 1);
2936
+ __publicField(this, "on", false);
2937
+ /** Where the box is centred (the Workshop leaves it at the origin; a game follows the camera). */
2938
+ __publicField(this, "centerX", 0);
2939
+ __publicField(this, "centerZ", 0);
2940
+ __publicField(this, "puddles", WORKSHOP_PUDDLES);
2941
+ /** Replaces the puddle test (a game knows its own wet spots). */
2942
+ __publicField(this, "puddleAt");
2943
+ }
2944
+ /** `initRain` (W321): `count` streaks (thinned by the quality), each drawn at a random place in the box. */
2945
+ init(count, wind) {
2946
+ const { random } = this.engine;
2947
+ this.count = Math.min(RAIN_CAPACITY, Math.round(count * this.engine.context.quality.mult));
2948
+ this.wind = wind;
2949
+ this.on = true;
2950
+ for (let index = 0; index < this.count; index++) {
2951
+ const offset = index * 6;
2952
+ const x = random.between(BOX_X[0], BOX_X[1]);
2953
+ const y = random.between(START_HEIGHT[0], START_HEIGHT[1]);
2954
+ const z = random.between(BOX_Z[0], BOX_Z[1]);
2955
+ this.set(offset, x, y, z);
2956
+ }
2957
+ }
2958
+ /**
2959
+ * What a game does with the field every frame: the box follows the camera (`centerX`, `centerZ`), the streaks thin or thicken to `count` (a new streak
2960
+ * starts at a random place of the box, as `init` draws it) and the wind slants them. The golden never calls it.
2961
+ */
2962
+ drive(count, wind, centerX, centerZ) {
2963
+ const { random } = this.engine;
2964
+ const target = Math.max(0, Math.min(RAIN_CAPACITY, Math.round(count * this.engine.context.quality.mult)));
2965
+ this.wind = wind;
2966
+ this.centerX = centerX;
2967
+ this.centerZ = centerZ;
2968
+ this.on = target > 0;
2969
+ for (let index = this.count; index < target; index++) {
2970
+ this.set(index * 6, random.between(BOX_X[0], BOX_X[1]) + centerX, random.between(START_HEIGHT[0], START_HEIGHT[1]), random.between(BOX_Z[0], BOX_Z[1]) + centerZ);
2971
+ }
2972
+ this.count = target;
2973
+ }
2974
+ /** `updateRain` (W322-329). `camera` is where the eye is; `splash` lets the drops that land leave a splash. */
2975
+ update(dt, splash, camera2) {
2976
+ if (!this.on) return;
2977
+ const { random, context } = this.engine;
2978
+ const positions = this.positions;
2979
+ const fall = FALL_SPEED * dt;
2980
+ const slant = this.wind * fall * WIND_PER_FALL;
2981
+ const reach = SPLASH_RANGE / (1 + context.quality.level);
2982
+ for (let index = 0; index < this.count; index++) {
2983
+ const o = index * 6;
2984
+ positions[o] += slant;
2985
+ positions[o + 3] += slant;
2986
+ positions[o + 1] -= fall;
2987
+ positions[o + 4] -= fall;
2988
+ const ground = context.groundAt(positions[o], positions[o + 2]);
2989
+ if (positions[o + 4] < ground) {
2990
+ const x = positions[o];
2991
+ const z = positions[o + 2];
2992
+ if (splash && random.next() < SPLASH_CHANCE) {
2993
+ const distance = Math.hypot(x - camera2[0], z - camera2[2]);
2994
+ if (distance < reach) {
2995
+ if (random.next() < SPRITE_CHANCE) {
2996
+ this.engine.spawn("normal", { p: [x, ground + 0.01, z], dir: UP9, cone: 0.6, sp: [0.6, 1.3], life: [0.18, 0.3], size: 0.035, c0: 12110044, a: 0.6, g: 9.8, fi: 0 });
2997
+ }
2998
+ if (this.puddleAt ? this.puddleAt(x, z) : inPuddle(this.puddles, x, z)) {
2999
+ this.engine.ring([[x, ground + 0.012, z], 0.01, random.between(0.12, 0.25), random.between(0.4, 0.6), 6978192]);
3000
+ }
3001
+ }
3002
+ }
3003
+ const nx = random.between(BOX_X[0], BOX_X[1]) + this.centerX;
3004
+ const ny = random.between(REENTRY_HEIGHT[0], REENTRY_HEIGHT[1]);
3005
+ const nz = random.between(BOX_Z[0], BOX_Z[1]) + this.centerZ;
3006
+ this.set(o, nx, ny, nz);
3007
+ }
3008
+ }
3009
+ }
3010
+ /** `rain.visible = false; RN.on = false` (W440): the field stops; the streaks stay where they were. */
3011
+ clear() {
3012
+ this.on = false;
3013
+ }
3014
+ set(offset, x, y, z) {
3015
+ const positions = this.positions;
3016
+ positions[offset] = x;
3017
+ positions[offset + 1] = y;
3018
+ positions[offset + 2] = z;
3019
+ positions[offset + 3] = x + this.wind * STREAK_SLANT;
3020
+ positions[offset + 4] = y - STREAK_LENGTH;
3021
+ positions[offset + 5] = z;
3022
+ }
3023
+ };
3024
+
3025
+ // src/effects/world/rain.ts
3026
+ var DROPS = [900, 2200, 4e3];
3027
+ var SLANT = [0.3, 1.2, 4.5];
3028
+ var STORM = 2;
3029
+ var FLASH_STEPS = ite(lt(variable("flash"), 0.08), 1, ite(lt(variable("flash"), 0.16), 0.2, ite(lt(variable("flash"), 0.26), 0.8, 0)));
3030
+ var RAIN_AND_PUDDLES = {
3031
+ id: "rain_and_puddles",
3032
+ pageId: "chuva",
3033
+ team: "world",
3034
+ params: { id: "intensity", options: ["drizzle", "rain", "storm"], default: 1 },
3035
+ budget: { particles: 4e3, decals: 4 },
3036
+ loop: 0,
3037
+ view: { eye: [2, 2, 7], target: [-1, 0.6, 1] },
3038
+ setup: [
3039
+ cue("lamp_cone", { visible: true }),
3040
+ ...WORKSHOP_PUDDLES.map(([x, z, radiusX, radiusZ]) => decal(x, 0, z, radiusX * 2, 790550, { grow: 0, life: 1e6, ar: radiusZ / radiusX }))
3041
+ ],
3042
+ timeline: [
3043
+ behavior("rain", "init", { count: ite(eq(PARAM, 0), DROPS[0], ite(eq(PARAM, 1), DROPS[1], DROPS[2])), wind: ite(eq(PARAM, 0), SLANT[0], ite(eq(PARAM, 1), SLANT[1], SLANT[2])) }),
3044
+ set("nextStrike", rnd(2, 4)),
3045
+ set("flash", -1)
3046
+ ],
3047
+ tick: [
3048
+ behavior("rain", "update", { dt: DELTA, splash: gt(PARAM, 0) }),
3049
+ when(eq(PARAM, STORM), [
3050
+ when(gt(TIME, variable("nextStrike")), [set("nextStrike", add(TIME, rnd(3.5, 6))), set("flash", 0)]),
3051
+ when(ge(variable("flash"), 0), [
3052
+ set("flash", add(variable("flash"), DELTA)),
3053
+ set("light", FLASH_STEPS),
3054
+ cue("lightning", { intensity: variable("light") }),
3055
+ screen({ max: { white: mul(variable("light"), 0.12) } }),
3056
+ when(gt(variable("flash"), 0.4), [set("flash", -1), cue("lightning", { intensity: 0 })])
3057
+ ]),
3058
+ emit("sheet", "normal", 2.5, { p: [-12, 2.5, rnd(-1, 8)], box: [0, 2, 0], v: [7, -0.5, 0], sp: 0, life: [3, 4], size: [3, 5], grow: 1.3, c0: 9083568, a: 0.06, fi: 0.3 })
3059
+ ])
3060
+ ]
3061
+ };
3062
+
3063
+ // src/effects/vehicles/car.ts
3064
+ var CAR_ORIGIN2 = [5.6, 0, 0.8];
3065
+ var CAR_ROTATION2 = [0, -0.4, 0];
3066
+ var carPoint = (x, y, z) => localToWorld(CAR_ORIGIN2, CAR_ROTATION2, [x, y, z]);
3067
+ var carDirection = (from, to) => normalized([to[0] - from[0], to[1] - from[1], to[2] - from[2]]);
3068
+
3069
+ // src/effects/vehicles/headlights.ts
3070
+ var BEAM_FROM = carPoint(0, 0.74, 2.15);
3071
+ var BEAM_DIRECTION = carDirection(BEAM_FROM, carPoint(0, 0.74, 3.15));
3072
+ var BEAM_SIDE = [BEAM_DIRECTION[2], 0, -BEAM_DIRECTION[0]];
3073
+ var WALKERS = 6;
3074
+ var WALK_SPEED2 = 0.7;
3075
+ var DROPS2 = 1800;
3076
+ var SLANT2 = 0.8;
3077
+ var startWalking = [
3078
+ set("spot", query("car", "point", rnd(-2, 2), 0, rnd(8, 18))),
3079
+ set("goal", query("car", "point", rnd(-0.6, 0.6), 0, 2.6)),
3080
+ behavior("walkers", "place", { index: INDEX, x: pick(variable("spot"), 0), z: pick(variable("spot"), 2), facing: 0 }),
3081
+ behavior("walkers", "walk", { index: INDEX, to: variable("goal"), speed: WALK_SPEED2 })
3082
+ ];
3083
+ var HEADLIGHTS_IN_RAIN = {
3084
+ id: "headlights_in_rain",
3085
+ pageId: "farol",
3086
+ team: "vehicles",
3087
+ budget: { particles: 600, lights: 2 },
3088
+ loop: 0,
3089
+ view: { eye: [-2.5, 2, 5.5], target: [4, 1, 6] },
3090
+ setup: [
3091
+ cue("fog", { density: 0.05 }),
3092
+ cue("headlights", { on: true, intensity: 2.4, color: 16773584 }),
3093
+ behavior("rain", "init", { count: DROPS2, wind: SLANT2 }),
3094
+ repeat(WALKERS, ...startWalking)
3095
+ ],
3096
+ timeline: [],
3097
+ tick: [
3098
+ behavior("rain", "update", { dt: DELTA, splash: true }),
3099
+ emit(
3100
+ "lit",
3101
+ "streak",
3102
+ 600,
3103
+ local(
3104
+ "depth",
3105
+ rnd(1, 13),
3106
+ local(
3107
+ "spread",
3108
+ mul(variable("depth"), 0.33, sqrt(rand())),
3109
+ local(
3110
+ "turn",
3111
+ rnd(0, 6.283),
3112
+ local("base", vadd(BEAM_FROM, vscale(BEAM_DIRECTION, variable("depth")), vscale(BEAM_SIDE, mul(cos(variable("turn")), variable("spread")))), {
3113
+ p: vwith(variable("base"), 1, add(vy(variable("base")), mul(sin(variable("turn")), variable("spread"), 0.6))),
3114
+ v: [0.8, -14, 0],
3115
+ sp: 0,
3116
+ life: 0.06,
3117
+ len: 0.035,
3118
+ c0: 13622512,
3119
+ a: 0.9
3120
+ })
3121
+ )
3122
+ )
3123
+ )
3124
+ ),
3125
+ repeat(WALKERS, when(not(query("walkers", "is_walking", INDEX)), startWalking))
3126
+ ]
3127
+ };
3128
+
2870
3129
  // src/effects/vehicles/scraping-sparks.ts
2871
3130
  var YAW = -Math.PI / 2;
2872
3131
  var COS = Math.cos(YAW);
@@ -2896,12 +3155,6 @@ var GameVfx = (() => {
2896
3155
  ]
2897
3156
  };
2898
3157
 
2899
- // src/effects/vehicles/car.ts
2900
- var CAR_ORIGIN2 = [5.6, 0, 0.8];
2901
- var CAR_ROTATION2 = [0, -0.4, 0];
2902
- var carPoint = (x, y, z) => localToWorld(CAR_ORIGIN2, CAR_ROTATION2, [x, y, z]);
2903
- var carDirection = (from, to) => normalized([to[0] - from[0], to[1] - from[1], to[2] - from[2]]);
2904
-
2905
3158
  // src/effects/vehicles/engine-smoke.ts
2906
3159
  var HOOD = carPoint(0, 1.02, 1.4);
2907
3160
  var EXHAUST = carPoint(0.5, 0.3, -2.2);
@@ -2938,7 +3191,7 @@ var GameVfx = (() => {
2938
3191
  };
2939
3192
 
2940
3193
  // src/effects/vehicles/boom.ts
2941
- var UP9 = [0, 1, 0];
3194
+ var UP10 = [0, 1, 0];
2942
3195
  var doorVelocity = (side) => {
2943
3196
  const out = carPoint(side * 4, 3, 0.3);
2944
3197
  const centre = carPoint(0, 0, 0.3);
@@ -2948,7 +3201,7 @@ var GameVfx = (() => {
2948
3201
  call2("explode", vadd(query("car", "position"), [0, 0.6, 0]), 1.8, 2759188),
2949
3202
  cue("car_burnt"),
2950
3203
  behavior("car", "launch", { rise: 4.5, spin: 0.9 }),
2951
- repeat(scaled(30), debris({ p: vadd(query("car", "position"), [0, 1.3, 0]), dir: UP9, cone: 1.3, sp: [2, 6], size: [0.06, 6e-3, 0.06], c: 11061464, life: 20 })),
3204
+ repeat(scaled(30), debris({ p: vadd(query("car", "position"), [0, 1.3, 0]), dir: UP10, cone: 1.3, sp: [2, 6], size: [0.06, 6e-3, 0.06], c: 11061464, life: 20 })),
2952
3205
  debris({ p: carPoint(0, 1, 1.4), v: [rnd(-1, 1), 9, rnd(-1, 1)], sp: 0, size: [1.6, 0.06, 1.2], c: 3808536, spin: 6, life: 20, bounce: 0.2 }),
2953
3206
  ...[-1, 1].map((side) => debris({ p: carPoint(side * 0.95, 0.7, 0.3), v: doorVelocity(side), sp: 0, size: [0.06, 0.7, 1.1], c: 3808536, spin: 5, life: 20, bounce: 0.2 })),
2954
3207
  debris({ p: carPoint(0.95, 0.38, 1.35), v: [3, 4, 2], sp: 0, size: [0.3, 0.76, 0.76], c: 1118481, spin: 8, life: 20, bounce: 0.4 })
@@ -3130,7 +3383,7 @@ var GameVfx = (() => {
3130
3383
  };
3131
3384
 
3132
3385
  // src/effects/screen/panic.ts
3133
- var WALKERS = 6;
3386
+ var WALKERS2 = 6;
3134
3387
  var NEAR = 9;
3135
3388
  var RANGE = 7;
3136
3389
  var RESTING_BPM = 70;
@@ -3146,7 +3399,7 @@ var GameVfx = (() => {
3146
3399
  setup: [
3147
3400
  cue("zombie_visible", { index: -1, visible: false }),
3148
3401
  repeat(
3149
- WALKERS,
3402
+ WALKERS2,
3150
3403
  set("startX", rnd(-4, 4)),
3151
3404
  set("startZ", sub(rnd(-4, -2), mul(INDEX, 0.6))),
3152
3405
  behavior("walkers", "place", { index: INDEX, x: variable("startX"), z: variable("startZ"), facing: 0 }),
@@ -3156,7 +3409,7 @@ var GameVfx = (() => {
3156
3409
  timeline: [],
3157
3410
  tick: [
3158
3411
  set("nearest", 99),
3159
- repeat(WALKERS, set("nearest", min(variable("nearest"), vdist(walkerPoint, CAMERA_POSITION)))),
3412
+ repeat(WALKERS2, set("nearest", min(variable("nearest"), vdist(walkerPoint, CAMERA_POSITION)))),
3160
3413
  set("fear", clamp(div(sub(NEAR, variable("nearest")), RANGE), 0, 1)),
3161
3414
  set("bpm", add(RESTING_BPM, mul(BPM_RISE, variable("fear")))),
3162
3415
  when(lt(mod(div(mul(TIME, variable("bpm")), 60), 1), div(mul(DELTA, variable("bpm")), 60)), [screen({ set: { beat: add(0.4, mul(0.6, variable("fear"))) } })]),
@@ -3231,7 +3484,7 @@ var GameVfx = (() => {
3231
3484
 
3232
3485
  // src/effects/events.ts
3233
3486
  var FACING4 = [0, 0, 1];
3234
- var UP10 = [0, 1, 0];
3487
+ var UP11 = [0, 1, 0];
3235
3488
  var ORIGIN = [0, 0, 0];
3236
3489
  var FORWARD4 = [0, 0, -1];
3237
3490
  var IMPACT_MATERIALS = ["concrete", "metal", "wood", "glass", "flesh", "water"];
@@ -3361,14 +3614,163 @@ var GameVfx = (() => {
3361
3614
  team: "destruction",
3362
3615
  budget: { particles: 20, debris: 8 },
3363
3616
  loop: 2,
3364
- timeline: [call2("chips", ORIGIN, UP10, 8, 0.9), call2("rust_at", ORIGIN, 6)]
3617
+ timeline: [call2("chips", ORIGIN, UP11, 8, 0.9), call2("rust_at", ORIGIN, 6)]
3365
3618
  }
3366
3619
  ];
3367
3620
 
3621
+ // src/effects/weapons/viewmodel.ts
3622
+ var PI = Math.PI;
3623
+ var SMOKE = { color: 9079430, width: 10, height: 8, gravity: -0.08, drag: 2.2, growth: 2.1 };
3624
+ var FLASH_SECONDS = 0.055;
3625
+ var FLASH_RAMP = [0.6, 0.9];
3626
+ var FLASH_OPACITY = 0.95;
3627
+ var FLAME_COLORS = [16742946, 16760896, 13121050, 16773296];
3628
+ var FLAME_ADDITIVE = 3;
3629
+ var ORIGIN2 = [0, 0, 0];
3630
+ var SIZE = variable("size");
3631
+ var wide = (width) => mul(sub(rand(), 0.5), width);
3632
+ var puff2 = (point, velocity, world, radius, life, opacity) => mesh({
3633
+ shape: "sphere",
3634
+ p: point,
3635
+ v: velocity,
3636
+ wv: world,
3637
+ r: radius,
3638
+ seg: SMOKE.width,
3639
+ seg2: SMOKE.height,
3640
+ life,
3641
+ c0: SMOKE.color,
3642
+ a: opacity,
3643
+ fade: true,
3644
+ lit: true,
3645
+ g: SMOKE.gravity,
3646
+ drag: SMOKE.drag,
3647
+ grow: SMOKE.growth
3648
+ });
3649
+ var flameBit = (point, velocity, world, radius, life) => [
3650
+ set("bitPoint", point),
3651
+ set("bitVelocity", velocity),
3652
+ set("bitWorld", world),
3653
+ set("bitRadius", radius),
3654
+ set("bitLife", life),
3655
+ set("bitColour", floor(mul(rand(), FLAME_COLORS.length))),
3656
+ mesh({
3657
+ shape: "icosahedron",
3658
+ p: variable("bitPoint"),
3659
+ v: variable("bitVelocity"),
3660
+ wv: variable("bitWorld"),
3661
+ r: variable("bitRadius"),
3662
+ seg: 1,
3663
+ rot: [mul(rand(), 3), mul(rand(), 3), 0],
3664
+ spin: [3, 4, 2],
3665
+ life: variable("bitLife"),
3666
+ c0: pick(FLAME_COLORS, variable("bitColour")),
3667
+ add: eq(variable("bitColour"), FLAME_ADDITIVE),
3668
+ a: 0.9,
3669
+ fade: true,
3670
+ g: -1.4,
3671
+ drag: 1.4,
3672
+ grow: 2.2
3673
+ })
3674
+ ];
3675
+ 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 });
3676
+ var MUZZLE_FLASH2 = {
3677
+ id: "viewmodel_muzzle_flash",
3678
+ pageId: "event:viewmodel_muzzle_flash",
3679
+ team: "weapons",
3680
+ budget: { particles: 12, lights: 1 },
3681
+ loop: 0.1,
3682
+ timeline: [
3683
+ set("angles", []),
3684
+ repeat(4, append("angles", add(div(mul(INDEX, PI), 2), mul(rand(), 0.6)))),
3685
+ set("roll", mul(rand(), PI)),
3686
+ flash(ORIGIN2, 16756832, mul(4, SIZE), FLASH_SECONDS, mul(2, SIZE), true, true),
3687
+ flashPiece("cone_open", mul(0.013, SIZE), mul(0.085, SIZE), 10, [mul(0.042, SIZE), 0, 0], [0, 0, -PI / 2], 16757575),
3688
+ repeat(
3689
+ 4,
3690
+ set("angle", pick(variable("angles"), INDEX)),
3691
+ flashPiece(
3692
+ "cone",
3693
+ mul(5e-3, SIZE),
3694
+ mul(0.04, SIZE),
3695
+ 6,
3696
+ [mul(0.012, SIZE), mul(cos(variable("angle")), 0.016, SIZE), mul(sin(variable("angle")), 0.016, SIZE)],
3697
+ [variable("angle"), 0, -PI / 2],
3698
+ 16757575
3699
+ )
3700
+ ),
3701
+ flashPiece("sphere", mul(0.016, SIZE), void 0, 12, [mul(8e-3, SIZE), 0, 0], [0, 0, 0], 16773568),
3702
+ repeat(
3703
+ 6,
3704
+ puff2(
3705
+ ORIGIN2,
3706
+ [add(0.15, mul(rand(), 0.35)), add(0.03, mul(rand(), 0.12)), mul(sub(rand(), 0.5), 0.14)],
3707
+ [0, 0, 0],
3708
+ mul(0.013, SIZE),
3709
+ add(1.3, mul(rand(), 0.6)),
3710
+ 0.45
3711
+ )
3712
+ )
3713
+ ]
3714
+ };
3715
+ var SMOKE_PUFF = {
3716
+ id: "weapon_smoke_puff",
3717
+ pageId: "event:weapon_smoke_puff",
3718
+ team: "weapons",
3719
+ budget: { particles: 1 },
3720
+ loop: 0.1,
3721
+ timeline: [puff2(ORIGIN2, void 0, [variable("vx"), variable("vy"), variable("vz")], variable("radius"), variable("life"), variable("opacity"))]
3722
+ };
3723
+ var BACKBLAST = {
3724
+ id: "launcher_backblast",
3725
+ pageId: "event:launcher_backblast",
3726
+ team: "weapons",
3727
+ budget: { particles: 40 },
3728
+ loop: 0.1,
3729
+ timeline: [
3730
+ 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)),
3731
+ repeat(14, ...flameBit(ORIGIN2, [neg(add(2, mul(rand(), 2))), 0, 0], [wide(1), wide(0.6), wide(1)], 0.02, 0.25))
3732
+ ]
3733
+ };
3734
+ var FLAME_JET = {
3735
+ id: "flame_jet",
3736
+ pageId: "event:flame_jet",
3737
+ team: "weapons",
3738
+ budget: { particles: 30 },
3739
+ loop: 0.1,
3740
+ timeline: [
3741
+ repeat(
3742
+ floor(mul(420, variable("dt"), variable("scale"))),
3743
+ set("speed", mul(add(2.2, mul(rand(), 1.1)), variable("scale"))),
3744
+ ...flameBit(
3745
+ [mul(rand(), variable("speed"), min(variable("dt"), 0.3)), 0, 0],
3746
+ [variable("speed"), 0, 0],
3747
+ [wide(0.35), mul(sub(rand(), 0.3), 0.3), wide(0.35)],
3748
+ add(0.02, mul(rand(), 0.022)),
3749
+ add(0.4, mul(rand(), 0.35))
3750
+ )
3751
+ ),
3752
+ when(lt(rand(), 0.5), [
3753
+ puff2([add(mul(1.1, variable("scale")), mul(rand(), 0.4)), 0, 0], void 0, [mul(vx(DIRECTION), 0.6), 0.35, mul(vz(DIRECTION), 0.6)], 0.03, 1.6, 0.4)
3754
+ ])
3755
+ ]
3756
+ };
3757
+ var VIEWMODEL_EFFECTS = [MUZZLE_FLASH2, SMOKE_PUFF, BACKBLAST, FLAME_JET];
3758
+
3759
+ // src/effects/vehicles/game-effects.ts
3760
+ var aliasOf = (base, id, changes) => ({ ...base, id, pageId: `vehicle:${id}`, anchor: CAR_ORIGIN2, ...changes });
3761
+ var VEHICLE_EFFECTS = [
3762
+ /** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
3763
+ aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
3764
+ /** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
3765
+ aliasOf(ENGINE_SMOKE, "vehicle_exhaust", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 0 }, loop: 0.5 }),
3766
+ /** A hole in the tank: the page's own petrol leak (drips, pool, sparks, fire running to the tank). */
3767
+ aliasOf(FUEL_LEAK, "vehicle_leak", {})
3768
+ ];
3769
+
3368
3770
  // src/effects/catalog.ts
3369
- var ALL_EFFECTS = [BLOOD_HIT, HEADSHOT, DISMEMBER, BLOATER_CLOUD, SCREAMER_SHRIEK, CORPSE_DECAY, REANIMATION, EYES_IN_FOG, MUZZLE_FLASH, IMPACT_BY_MATERIAL, PENETRATION, CASINGS_AND_MAGAZINE, MOLOTOV, GRENADE, EXPLOSIVE_BARREL, SHOPFRONT_GLASS, DOOR_STAGES, BUILDING_COLLAPSE, BLOCK_WALL, METAL_DOOR_EFFECT, IRON_RAILING, WOODEN_FENCE, HIT_POINT_BREAKAGE, PRESSURE_CYLINDERS, BUILDING_FIRE, SCRAPING_SPARKS, ENGINE_SMOKE, FUEL_LEAK, CAR_EXPLOSION, WINDSHIELD, DAMAGE_AND_BITE, INFECTION_PHASES, PANIC, BLOATER_BLINDNESS, CAMPFIRE, COUGH_AND_BREATH];
3771
+ var ALL_EFFECTS = [BLOOD_HIT, HEADSHOT, DISMEMBER, BLOATER_CLOUD, SCREAMER_SHRIEK, CORPSE_DECAY, REANIMATION, EYES_IN_FOG, MUZZLE_FLASH, IMPACT_BY_MATERIAL, PENETRATION, CASINGS_AND_MAGAZINE, MOLOTOV, GRENADE, EXPLOSIVE_BARREL, SHOPFRONT_GLASS, DOOR_STAGES, BUILDING_COLLAPSE, BLOCK_WALL, METAL_DOOR_EFFECT, IRON_RAILING, WOODEN_FENCE, HIT_POINT_BREAKAGE, PRESSURE_CYLINDERS, BUILDING_FIRE, RAIN_AND_PUDDLES, FOG_AND_ASH, SCRAPING_SPARKS, ENGINE_SMOKE, FUEL_LEAK, CAR_EXPLOSION, WINDSHIELD, HEADLIGHTS_IN_RAIN, DAMAGE_AND_BITE, INFECTION_PHASES, PANIC, BLOATER_BLINDNESS, CAMPFIRE, COUGH_AND_BREATH];
3370
3772
  var WORKSHOP_EFFECTS = Object.fromEntries(ALL_EFFECTS.map((effect) => [effect.id, effect]));
3371
- var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries(EVENT_EFFECTS.map((effect) => [effect.id, effect])) };
3773
+ var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries([...EVENT_EFFECTS, ...VIEWMODEL_EFFECTS, ...VEHICLE_EFFECTS].map((effect) => [effect.id, effect])) };
3372
3774
  function patchEffects(base, changes) {
3373
3775
  const result = { ...base };
3374
3776
  for (const [id, change] of Object.entries(changes)) {
@@ -3506,7 +3908,7 @@ var GameVfx = (() => {
3506
3908
  // src/effects/behaviors/blocks.ts
3507
3909
  var COLUMNS = 6;
3508
3910
  var ROWS = 5;
3509
- var ORIGIN2 = [-2.2, 0, 2.6];
3911
+ var ORIGIN3 = [-2.2, 0, 2.6];
3510
3912
  var BLOCK_SIZE = [0.5, 0.44, 0.25];
3511
3913
  var OBJECT_ID_DRAWS2 = 4;
3512
3914
  var FLOOR2 = 0.13;
@@ -3549,7 +3951,7 @@ var GameVfx = (() => {
3549
3951
  const chipScale = random.between(0.8, 1.3) * scale;
3550
3952
  for (let draw = 0; draw < OBJECT_ID_DRAWS2; draw++) random.next();
3551
3953
  best.holes.push({ x: offsetX, y: offsetY, scale, chipTurn, chipScale });
3552
- impact(host.engine, "concrete", [ORIGIN2[0] + x, y, ORIGIN2[2] + 0.13], [0, 0, 1], 0.8);
3954
+ impact(host.engine, "concrete", [ORIGIN3[0] + x, y, ORIGIN3[2] + 0.13], [0, 0, 1], 0.8);
3553
3955
  } else if (action === "collapse") {
3554
3956
  const { x, y } = args;
3555
3957
  for (const block of blocks) {
@@ -3601,7 +4003,7 @@ var GameVfx = (() => {
3601
4003
  }
3602
4004
 
3603
4005
  // src/effects/behaviors/car.ts
3604
- var ORIGIN3 = [5.6, 0, 0.8];
4006
+ var ORIGIN4 = [5.6, 0, 0.8];
3605
4007
  var MAX_TILT = 0.25;
3606
4008
  function createCarBehavior() {
3607
4009
  let y = 0;
@@ -3633,8 +4035,13 @@ var GameVfx = (() => {
3633
4035
  }
3634
4036
  }
3635
4037
  },
3636
- query(_host, name) {
3637
- if (name === "position") return [ORIGIN3[0], y, ORIGIN3[2]];
4038
+ query(_host, name, args) {
4039
+ if (name === "position") return [ORIGIN4[0], y, ORIGIN4[2]];
4040
+ if (name === "point") {
4041
+ const [x, py, z] = args;
4042
+ const point = carPoint(x, py, z);
4043
+ return [point[0], point[1] + y, point[2]];
4044
+ }
3638
4045
  if (name === "roll") return roll;
3639
4046
  throw new Error(`car: unknown query ${name}`);
3640
4047
  },
@@ -3843,6 +4250,31 @@ var GameVfx = (() => {
3843
4250
  };
3844
4251
  }
3845
4252
 
4253
+ // src/effects/behaviors/rain.ts
4254
+ function createRainBehavior() {
4255
+ return {
4256
+ reset() {
4257
+ },
4258
+ act(host, action, args) {
4259
+ const { engine, camera: camera2 } = host;
4260
+ if (action === "init") {
4261
+ const { count, wind } = args;
4262
+ engine.rain.init(count, wind);
4263
+ } else if (action === "update") {
4264
+ const { dt, splash } = args;
4265
+ engine.rain.update(dt, splash, camera2.position);
4266
+ }
4267
+ },
4268
+ query(host, name) {
4269
+ if (name === "count") return host.engine.rain.count;
4270
+ if (name === "on") return host.engine.rain.on;
4271
+ throw new Error(`rain: unknown query ${name}`);
4272
+ },
4273
+ update() {
4274
+ }
4275
+ };
4276
+ }
4277
+
3846
4278
  // src/effects/behaviors/walkers.ts
3847
4279
  var WALKER_COUNT = 10;
3848
4280
  var ARRIVAL_DISTANCE = 0.05;
@@ -3911,7 +4343,8 @@ var GameVfx = (() => {
3911
4343
  blocks: () => createBlocksBehavior(),
3912
4344
  plate: () => createPlateBehavior(),
3913
4345
  cylinder: () => createCylinderBehavior(),
3914
- car: () => createCarBehavior()
4346
+ car: () => createCarBehavior(),
4347
+ rain: () => createRainBehavior()
3915
4348
  };
3916
4349
  function createWorkshopBehaviors(factories = WORKSHOP_BEHAVIORS) {
3917
4350
  return Object.fromEntries(Object.entries(factories).map(([id, make]) => [id, make()]));
@@ -3989,6 +4422,8 @@ var GameVfx = (() => {
3989
4422
  return Math.abs(asNumber(first));
3990
4423
  case "sqrt":
3991
4424
  return Math.sqrt(asNumber(first));
4425
+ case "exp":
4426
+ return Math.exp(asNumber(first));
3992
4427
  case "sin":
3993
4428
  return Math.sin(asNumber(first));
3994
4429
  case "cos":
@@ -4109,7 +4544,7 @@ var GameVfx = (() => {
4109
4544
  }
4110
4545
 
4111
4546
  // src/effects/builders/fire.ts
4112
- var UP11 = [0, 1, 0];
4547
+ var UP12 = [0, 1, 0];
4113
4548
  var ZERO = [0, 0, 0];
4114
4549
  var FULL_TURN_DRAWN = 6.283;
4115
4550
  function scaledSizes(range, factor) {
@@ -4122,7 +4557,7 @@ var GameVfx = (() => {
4122
4557
  p: centre,
4123
4558
  r: radius,
4124
4559
  flat: true,
4125
- dir: options.dir ?? UP11,
4560
+ dir: options.dir ?? UP12,
4126
4561
  cone: 0.35,
4127
4562
  sp: [0.4, 1.4],
4128
4563
  v: wind,
@@ -4139,7 +4574,7 @@ var GameVfx = (() => {
4139
4574
  p: centre,
4140
4575
  r: radius * 0.6,
4141
4576
  flat: true,
4142
- dir: UP11,
4577
+ dir: UP12,
4143
4578
  cone: 0.3,
4144
4579
  sp: [0.3, 0.8],
4145
4580
  life: [0.2, 0.4],
@@ -4154,14 +4589,14 @@ var GameVfx = (() => {
4154
4589
  if (engine.quality < 2) {
4155
4590
  engine.emit(`${key}e`, "streak", 10 * factor, dt, () => {
4156
4591
  const jitter = plus(wind, engine.random.between(-0.4, 0.4), 0, engine.random.between(-0.4, 0.4));
4157
- return { p: centre, box: [radius, 0, radius], dir: UP11, cone: 0.5, sp: [1.5, 3.5], v: jitter, life: [0.8, 1.8], len: 0.03, c0: 16756816, c1: 6295552, g: -0.6, drag: 0.4 };
4592
+ return { p: centre, box: [radius, 0, radius], dir: UP12, cone: 0.5, sp: [1.5, 3.5], v: jitter, life: [0.8, 1.8], len: 0.03, c0: 16756816, c1: 6295552, g: -0.6, drag: 0.4 };
4158
4593
  });
4159
4594
  }
4160
4595
  if (options.noSmoke) return;
4161
4596
  engine.emit(`${key}s`, "normal", (options.smoke || 14) * factor, dt, () => ({
4162
4597
  p: plus(centre, 0, 0.8 * sqrtFactor, 0),
4163
4598
  r: radius * 0.7,
4164
- dir: UP11,
4599
+ dir: UP12,
4165
4600
  cone: 0.35,
4166
4601
  sp: [0.6, 1.4],
4167
4602
  v: wind,
@@ -4201,15 +4636,15 @@ var GameVfx = (() => {
4201
4636
  engine.screen.shake += 0.7 * scale;
4202
4637
  engine.screen.white += 0.18 * scale;
4203
4638
  engine.burst("add", 55 * scale, { p: point, r: 0.3 * scale, sp: [2, 7 * scale], drag: 4, life: [0.25, 0.6], size: [0.7 * scale, 1.4 * scale], grow: 1.7, c0: 16773296, c1: 10103304, fi: 0.04 });
4204
- engine.burst("add", 28 * scale, { p: plus(point, 0, 0.3, 0), r: 0.3, dir: UP11, cone: 0.7, sp: [2, 5 * scale], drag: 1.5, life: [0.6, 1.1], size: [0.6 * scale, 1 * scale], grow: 1.3, c0: 16760928, c1: 5902853, g: -2, fi: 0.05 });
4639
+ engine.burst("add", 28 * scale, { p: plus(point, 0, 0.3, 0), r: 0.3, dir: UP12, cone: 0.7, sp: [2, 5 * scale], drag: 1.5, life: [0.6, 1.1], size: [0.6 * scale, 1 * scale], grow: 1.3, c0: 16760928, c1: 5902853, g: -2, fi: 0.05 });
4205
4640
  engine.ring([plus(point, 0, 0.05, 0), 0.3, 7 * scale, 0.55, 16767136]);
4206
4641
  const toCamera = normalized([cameraPosition[0] - point[0], cameraPosition[1] - point[1], cameraPosition[2] - point[2]]);
4207
4642
  engine.ring([plus(point, 0, 1, 0), 0.3, 5 * scale, 0.35, 16773328, toCamera]);
4208
- engine.burst("normal", 32 * scale, { p: plus(point, 0, 0.6, 0), r: 0.8 * scale, dir: UP11, cone: 1.1, sp: [1, 3], drag: 1.2, life: [3, 6], size: [1 * scale, 1.8 * scale], grow: 2.6, c0: 2828068, c1: 987155, a: 0.6, fi: 0.18, g: -0.35 });
4643
+ engine.burst("normal", 32 * scale, { p: plus(point, 0, 0.6, 0), r: 0.8 * scale, dir: UP12, cone: 1.1, sp: [1, 3], drag: 1.2, life: [3, 6], size: [1 * scale, 1.8 * scale], grow: 2.6, c0: 2828068, c1: 987155, a: 0.6, fi: 0.18, g: -0.35 });
4209
4644
  ringOfDust(engine, point, scale);
4210
- if (engine.quality < 2) engine.burst("streak", 44 * scale, { p: point, dir: UP11, cone: 1.45, sp: [10, 26], life: [0.3, 0.7], len: 0.03, c0: 16760944, c1: 8396800, g: 9.8, gnd: 2 });
4645
+ if (engine.quality < 2) engine.burst("streak", 44 * scale, { p: point, dir: UP12, cone: 1.45, sp: [10, 26], life: [0.3, 0.7], len: 0.03, c0: 16760944, c1: 8396800, g: 9.8, gnd: 2 });
4211
4646
  for (let index = 0; index < engine.scaled(16 * scale); index++) {
4212
- engine.debrisPiece({ p: point, dir: UP11, cone: 1.2, sp: [3, 9], size: [0.12, 0.06, 0.1], k: [0.6, 1.6], c: chipColor || 2762274, life: 9 });
4647
+ engine.debrisPiece({ p: point, dir: UP12, cone: 1.2, sp: [3, 9], size: [0.12, 0.06, 0.1], k: [0.6, 1.6], c: chipColor || 2762274, life: 9 });
4213
4648
  }
4214
4649
  engine.decal([point[0], engine.context.groundAt(point[0], point[2]), point[2], 3 * scale, 657930, { grow: 0.15, life: 60 }]);
4215
4650
  }
@@ -4360,6 +4795,7 @@ var GameVfx = (() => {
4360
4795
  if (!def) return;
4361
4796
  this.schedule.clear();
4362
4797
  this.variables.clear();
4798
+ for (const [name, value] of Object.entries(this.setup.values ?? {})) this.variables.set(name, value);
4363
4799
  for (const behavior2 of this.deps.behaviors()) behavior2.reset(this.host);
4364
4800
  this.time = 0;
4365
4801
  this.within(() => {
@@ -4418,6 +4854,10 @@ var GameVfx = (() => {
4418
4854
  return engine.spawn(step.system, this.value(step.spawn));
4419
4855
  case "emit":
4420
4856
  return engine.emit(step.key, step.system, this.value(step.rate), this.dt, () => this.value(step.spawn));
4857
+ case "mesh": {
4858
+ engine.mesh(this.value(step.spawn));
4859
+ return;
4860
+ }
4421
4861
  case "debris":
4422
4862
  return engine.debrisPiece(this.value(step.spawn));
4423
4863
  case "decal":
@@ -4501,7 +4941,7 @@ var GameVfx = (() => {
4501
4941
  };
4502
4942
 
4503
4943
  // src/effects/player.ts
4504
- var ORIGIN4 = [0, 0, 0];
4944
+ var ORIGIN5 = [0, 0, 0];
4505
4945
  var DEFAULT_HEADING = [0, 0, -1];
4506
4946
  var DEFAULT_MAX_INSTANCES = 48;
4507
4947
  var ENDLESS_SECONDS = 60;
@@ -4546,7 +4986,7 @@ var GameVfx = (() => {
4546
4986
  }
4547
4987
  function placementOf(entry) {
4548
4988
  const origin = entry.follow ? [entry.origin[0] + positionOf2(entry.follow)[0], entry.origin[1] + positionOf2(entry.follow)[1], entry.origin[2] + positionOf2(entry.follow)[2]] : entry.origin;
4549
- return { origin, anchor: entry.anchor, yaw: entry.yaw };
4989
+ return { origin, anchor: entry.anchor, yaw: entry.yaw, ...entry.orientation ? { orientation: entry.orientation } : {} };
4550
4990
  }
4551
4991
  function drawing(entry, action) {
4552
4992
  const context = engine.context;
@@ -4570,8 +5010,9 @@ var GameVfx = (() => {
4570
5010
  random: playOptions.seed !== void 0 ? streamOf(playOptions.seed) : void 0,
4571
5011
  follow: playOptions.follow,
4572
5012
  origin: point,
4573
- anchor: def.anchor ?? ORIGIN4,
5013
+ anchor: def.anchor ?? ORIGIN5,
4574
5014
  yaw: yawOf(heading, playOptions.direction),
5015
+ orientation: playOptions.orientation,
4575
5016
  seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS)
4576
5017
  };
4577
5018
  playing.push(entry);
@@ -4580,7 +5021,8 @@ var GameVfx = (() => {
4580
5021
  () => instance.begin(def, paramIndex(def, playOptions.param), {
4581
5022
  placement: placementOf(entry),
4582
5023
  ...playOptions.direction ? { direction: playOptions.direction } : {},
4583
- ...playOptions.normal ? { normal: playOptions.normal } : {}
5024
+ ...playOptions.normal ? { normal: playOptions.normal } : {},
5025
+ ...playOptions.values ? { values: playOptions.values } : {}
4584
5026
  })
4585
5027
  );
4586
5028
  return entry.handle;
@@ -4851,15 +5293,15 @@ var GameVfx = (() => {
4851
5293
  return shock;
4852
5294
  }
4853
5295
  function pushPuffs(puffs, shock, reach, dt, age) {
4854
- for (const puff2 of puffs) {
4855
- if (puff2.ring || puff2.t > PUSH_AGE_LIMIT) continue;
4856
- const dx = puff2.x - shock.x;
4857
- const dz = puff2.z - shock.z;
5296
+ for (const puff3 of puffs) {
5297
+ if (puff3.ring || puff3.t > PUSH_AGE_LIMIT) continue;
5298
+ const dx = puff3.x - shock.x;
5299
+ const dz = puff3.z - shock.z;
4858
5300
  const distance = Math.hypot(dx, dz) + 1e-3;
4859
- if (Math.abs(distance - reach) < PUSH_BAND && puff2.y < PUSH_CEILING) {
5301
+ if (Math.abs(distance - reach) < PUSH_BAND && puff3.y < PUSH_CEILING) {
4860
5302
  const strength = 4 * dt * (1 - age);
4861
- puff2.vx += dx / distance * strength * 6;
4862
- puff2.vz += dz / distance * strength * 6;
5303
+ puff3.vx += dx / distance * strength * 6;
5304
+ puff3.vz += dz / distance * strength * 6;
4863
5305
  }
4864
5306
  }
4865
5307
  }
@@ -5161,10 +5603,10 @@ var GameVfx = (() => {
5161
5603
  const life = random.between(ring2.life * 0.75, ring2.life);
5162
5604
  const h0 = random.between(1, 1.25);
5163
5605
  const hl = random.between(0.9, 1.6);
5164
- const puff2 = addPuff(core, random, { x, y, z, s0: spec.radius * 0.2, s1, sg: spec.radius * 0.06, gk: 3, life, h0, hl, color, kind: 0 });
5165
- puff2.ring = ring2;
5166
- puff2.ph = random.next() * Math.PI * 2;
5167
- puff2.th = random.next() * Math.PI * 2;
5606
+ const puff3 = addPuff(core, random, { x, y, z, s0: spec.radius * 0.2, s1, sg: spec.radius * 0.06, gk: 3, life, h0, hl, color, kind: 0 });
5607
+ puff3.ring = ring2;
5608
+ puff3.ph = random.next() * Math.PI * 2;
5609
+ puff3.th = random.next() * Math.PI * 2;
5168
5610
  }
5169
5611
  const stemCount = Math.round((spec.stem || 18) * Math.max(lod, 0.4));
5170
5612
  for (let index = 0; index < stemCount; index++) {
@@ -5988,7 +6430,7 @@ var GameVfx = (() => {
5988
6430
  // src/workshop/direction.ts
5989
6431
  var TWO_PI_ROUNDED = 6.2832;
5990
6432
  var WIDE_CONE = 3.1;
5991
- var UP12 = [0, 1, 0];
6433
+ var UP13 = [0, 1, 0];
5992
6434
  function drawRange(random, range) {
5993
6435
  if (Array.isArray(range)) return random.between(range[0], range[1]);
5994
6436
  return range || 0;
@@ -6016,7 +6458,7 @@ var GameVfx = (() => {
6016
6458
  }
6017
6459
  function coneDirection(random, direction, cone, out) {
6018
6460
  if (cone >= WIDE_CONE) return randomUnit(random, out);
6019
- const [dx, dy, dz] = direction ?? UP12;
6461
+ const [dx, dy, dz] = direction ?? UP13;
6020
6462
  const cosTilt = 1 - random.next() * (1 - Math.cos(cone));
6021
6463
  const sinTilt = Math.sqrt(1 - cosTilt * cosTilt);
6022
6464
  const phase = random.next() * TWO_PI_ROUNDED;
@@ -6140,12 +6582,12 @@ var GameVfx = (() => {
6140
6582
 
6141
6583
  // src/workshop/decals.ts
6142
6584
  var CAPACITY2 = 400;
6143
- var UP13 = [0, 1, 0];
6585
+ var UP14 = [0, 1, 0];
6144
6586
  var DEFAULT_LIFE2 = 60;
6145
6587
  var DEFAULT_GROW = 1.2;
6146
6588
  var EVAPORATION = { fuel: [6, 5], water: [40, 20] };
6147
6589
  function createDecal() {
6148
- return { on: false, x: 0, y: 0, z: 0, sx: 0, sy: 0, t: 0, life: 0, grow: 0, color: 0, normal: UP13, fluid: void 0, dryColor: -1, dryAt: 0, dryTime: 0 };
6590
+ return { on: false, x: 0, y: 0, z: 0, sx: 0, sy: 0, t: 0, life: 0, grow: 0, color: 0, normal: UP14, fluid: void 0, dryColor: -1, dryAt: 0, dryTime: 0 };
6149
6591
  }
6150
6592
  var DecalPool = class {
6151
6593
  constructor(context) {
@@ -6158,7 +6600,7 @@ var GameVfx = (() => {
6158
6600
  const random = this.context.random;
6159
6601
  const index = this.next++ % CAPACITY2;
6160
6602
  const decal2 = this.decals[index];
6161
- const normal = options.n ?? UP13;
6603
+ const normal = options.n ?? UP14;
6162
6604
  random.between(0, 6.28);
6163
6605
  const offset = 4e-3 + index % 40 * 4e-4;
6164
6606
  decal2.on = true;
@@ -6200,6 +6642,96 @@ var GameVfx = (() => {
6200
6642
  }
6201
6643
  };
6202
6644
 
6645
+ // src/workshop/meshes.ts
6646
+ var CAPACITY3 = 400;
6647
+ var IDENTITY = [0, 0, 0, 1];
6648
+ function multiply(a, b) {
6649
+ const [ax, ay, az, aw] = a;
6650
+ const [bx, by, bz, bw] = b;
6651
+ return [aw * bx + ax * bw + ay * bz - az * by, aw * by - ax * bz + ay * bw + az * bx, aw * bz + ax * by - ay * bx + az * bw, aw * bw - ax * bx - ay * by - az * bz];
6652
+ }
6653
+ var aboutX = (angle) => [Math.sin(angle / 2), 0, 0, Math.cos(angle / 2)];
6654
+ var MeshPool = class {
6655
+ constructor(capacity = CAPACITY3) {
6656
+ __publicField(this, "capacity", capacity);
6657
+ __publicField(this, "particles", []);
6658
+ __publicField(this, "serial", 0);
6659
+ }
6660
+ get count() {
6661
+ return this.particles.length;
6662
+ }
6663
+ spawn(options, frame = IDENTITY) {
6664
+ const velocity = options.v ?? [0, 0, 0];
6665
+ const world = options.wv ?? [0, 0, 0];
6666
+ const particle = {
6667
+ id: ++this.serial,
6668
+ shape: options.shape,
6669
+ radius: options.r,
6670
+ height: options.h ?? 0,
6671
+ segments: options.seg ?? 0,
6672
+ segments2: options.seg2 ?? 0,
6673
+ color: options.c0,
6674
+ additive: options.add === true,
6675
+ lit: options.lit === true,
6676
+ x: options.p[0],
6677
+ y: options.p[1],
6678
+ z: options.p[2],
6679
+ frame: options.roll ? multiply(frame, aboutX(options.roll)) : frame,
6680
+ at: options.at ?? [0, 0, 0],
6681
+ rx: options.rot?.[0] ?? 0,
6682
+ ry: options.rot?.[1] ?? 0,
6683
+ rz: options.rot?.[2] ?? 0,
6684
+ scale: 1,
6685
+ opacity: options.a,
6686
+ age: 0,
6687
+ life: options.life,
6688
+ vx: velocity[0] + world[0],
6689
+ vy: velocity[1] + world[1],
6690
+ vz: velocity[2] + world[2],
6691
+ spin: options.spin ?? [0, 0, 0],
6692
+ gravity: options.g ?? 0,
6693
+ drag: options.drag ?? 0,
6694
+ grow: options.grow ?? 0,
6695
+ ramp: options.ramp,
6696
+ fade: options.fade === true,
6697
+ startOpacity: options.a
6698
+ };
6699
+ this.particles.push(particle);
6700
+ if (this.particles.length > this.capacity) this.particles.shift();
6701
+ return particle;
6702
+ }
6703
+ update(dt) {
6704
+ const live = this.particles;
6705
+ for (let index = 0; index < live.length; index++) {
6706
+ const particle = live[index];
6707
+ particle.age += dt;
6708
+ if (particle.ramp ? particle.age >= particle.life : particle.age > particle.life) {
6709
+ live.splice(index--, 1);
6710
+ continue;
6711
+ }
6712
+ if (particle.fade) particle.opacity = Math.max(0, particle.startOpacity * (1 - particle.age / particle.life));
6713
+ particle.vy -= particle.gravity * dt;
6714
+ if (particle.drag) {
6715
+ const keep = Math.max(0, 1 - particle.drag * dt);
6716
+ particle.vx *= keep;
6717
+ particle.vy *= keep;
6718
+ particle.vz *= keep;
6719
+ }
6720
+ particle.x += particle.vx * dt;
6721
+ particle.y += particle.vy * dt;
6722
+ particle.z += particle.vz * dt;
6723
+ particle.rx += particle.spin[0] * dt;
6724
+ particle.ry += particle.spin[1] * dt;
6725
+ particle.rz += particle.spin[2] * dt;
6726
+ if (particle.grow) particle.scale *= 1 + particle.grow * dt;
6727
+ if (particle.ramp) particle.scale = particle.ramp[0] + Math.min(1, particle.age / particle.life) * particle.ramp[1];
6728
+ }
6729
+ }
6730
+ clear() {
6731
+ this.particles.length = 0;
6732
+ }
6733
+ };
6734
+
6203
6735
  // src/workshop/sprites.ts
6204
6736
  var DEFAULT_FADE_IN = 0.1;
6205
6737
  var FLOATS_PER_VECTOR = 3;
@@ -6496,11 +7028,11 @@ var GameVfx = (() => {
6496
7028
  // src/workshop/waves.ts
6497
7029
  var RING_CAPACITY = 120;
6498
7030
  var LIGHT_CAPACITY = 4;
6499
- var UP14 = [0, 1, 0];
7031
+ var UP15 = [0, 1, 0];
6500
7032
  var DEFAULT_LIGHT_DISTANCE = 14;
6501
7033
  var WaveRingPool = class {
6502
7034
  constructor() {
6503
- __publicField(this, "rings", Array.from({ length: RING_CAPACITY }, () => ({ on: false, point: UP14, from: 0, to: 0, t: 0, duration: 1, color: 0, normal: UP14, hold: 0 })));
7035
+ __publicField(this, "rings", Array.from({ length: RING_CAPACITY }, () => ({ on: false, point: UP15, from: 0, to: 0, t: 0, duration: 1, color: 0, normal: UP15, hold: 0 })));
6504
7036
  __publicField(this, "count", 0);
6505
7037
  __publicField(this, "next", 0);
6506
7038
  }
@@ -6513,7 +7045,7 @@ var GameVfx = (() => {
6513
7045
  ring2.t = 0;
6514
7046
  ring2.duration = duration;
6515
7047
  ring2.color = color;
6516
- ring2.normal = normal ?? UP14;
7048
+ ring2.normal = normal ?? UP15;
6517
7049
  ring2.hold = hold || 0;
6518
7050
  }
6519
7051
  clear() {
@@ -6533,7 +7065,7 @@ var GameVfx = (() => {
6533
7065
  var FlashLightPool = class {
6534
7066
  constructor(context) {
6535
7067
  __publicField(this, "context", context);
6536
- __publicField(this, "lights", Array.from({ length: LIGHT_CAPACITY }, () => ({ x: 0, y: 0, z: 0, color: 16760944, distance: DEFAULT_LIGHT_DISTANCE, peak: 0, duration: 1, t: 0, intensity: 0 })));
7068
+ __publicField(this, "lights", Array.from({ length: LIGHT_CAPACITY }, () => ({ x: 0, y: 0, z: 0, color: 16760944, distance: DEFAULT_LIGHT_DISTANCE, peak: 0, duration: 1, t: 0, intensity: 0, steady: false })));
6537
7069
  __publicField(this, "fire", [
6538
7070
  { x: 0, y: 0, z: 0, intensity: 0 },
6539
7071
  { x: 0, y: 0, z: 0, intensity: 0 }
@@ -6543,7 +7075,7 @@ var GameVfx = (() => {
6543
7075
  get lit() {
6544
7076
  return this.lights.filter((light) => light.intensity > 0).length;
6545
7077
  }
6546
- flash(point, color, intensity, duration, distance, force) {
7078
+ flash(point, color, intensity, duration, distance, force, steady) {
6547
7079
  const { level } = this.context.quality;
6548
7080
  if (level >= 1 && !force) return;
6549
7081
  if (level >= 2 && force !== "boom") return;
@@ -6556,6 +7088,7 @@ var GameVfx = (() => {
6556
7088
  light.peak = intensity;
6557
7089
  light.duration = duration;
6558
7090
  light.t = 0;
7091
+ light.steady = steady === true;
6559
7092
  light.intensity = intensity;
6560
7093
  }
6561
7094
  clear() {
@@ -6567,7 +7100,7 @@ var GameVfx = (() => {
6567
7100
  if (light.intensity <= 0) continue;
6568
7101
  light.t += dt;
6569
7102
  const age = light.t / light.duration;
6570
- light.intensity = age >= 1 ? 0 : light.peak * (1 - age) * (1 - age);
7103
+ light.intensity = age >= 1 ? 0 : light.steady ? light.peak : light.peak * (1 - age) * (1 - age);
6571
7104
  }
6572
7105
  }
6573
7106
  };
@@ -6577,6 +7110,14 @@ var GameVfx = (() => {
6577
7110
  var FIRE_FLICKER_SWAY = 0.25;
6578
7111
  var FIRE_FLICKER_JITTER = 0.08;
6579
7112
  var LENS_FADE = 0.16;
7113
+ function rotate(q, v) {
7114
+ const [qx, qy, qz, qw] = q;
7115
+ const ix = qw * v[0] + qy * v[2] - qz * v[1];
7116
+ const iy = qw * v[1] + qz * v[0] - qx * v[2];
7117
+ const iz = qw * v[2] + qx * v[1] - qy * v[0];
7118
+ const iw = -qx * v[0] - qy * v[1] - qz * v[2];
7119
+ return [ix * qw + iw * -qx + iy * -qz - iz * -qy, iy * qw + iw * -qy + iz * -qx - ix * -qz, iz * qw + iw * -qz + ix * -qy - iy * -qx];
7120
+ }
6580
7121
  function workshopGround(x, z) {
6581
7122
  return z < -2.9 && z > -4.5 && Math.abs(x) < 13 ? 0.12 : 0;
6582
7123
  }
@@ -6590,6 +7131,8 @@ var GameVfx = (() => {
6590
7131
  __publicField(this, "decals");
6591
7132
  __publicField(this, "rings", new WaveRingPool());
6592
7133
  __publicField(this, "lights");
7134
+ __publicField(this, "rain", new RainField(this));
7135
+ __publicField(this, "meshes", new MeshPool());
6593
7136
  __publicField(this, "screen", createScreenState());
6594
7137
  __publicField(this, "lens", []);
6595
7138
  __publicField(this, "post", {});
@@ -6623,7 +7166,11 @@ var GameVfx = (() => {
6623
7166
  place(point) {
6624
7167
  const placement = this.placement;
6625
7168
  if (!placement) return point;
6626
- const { anchor, origin, yaw } = placement;
7169
+ const { anchor, origin, yaw, orientation } = placement;
7170
+ if (orientation) {
7171
+ const turned = rotate(orientation, [point[0] - anchor[0], point[1] - anchor[1], point[2] - anchor[2]]);
7172
+ return [origin[0] + turned[0], origin[1] + turned[1], origin[2] + turned[2]];
7173
+ }
6627
7174
  const x = point[0] - anchor[0];
6628
7175
  const z = point[2] - anchor[2];
6629
7176
  const cos2 = Math.cos(yaw);
@@ -6634,6 +7181,7 @@ var GameVfx = (() => {
6634
7181
  turn(vector) {
6635
7182
  const placement = this.placement;
6636
7183
  if (!placement) return vector;
7184
+ if (placement.orientation) return rotate(placement.orientation, vector);
6637
7185
  const cos2 = Math.cos(placement.yaw);
6638
7186
  const sin2 = Math.sin(placement.yaw);
6639
7187
  return [cos2 * vector[0] + sin2 * vector[2], vector[1], -sin2 * vector[0] + cos2 * vector[2]];
@@ -6662,6 +7210,14 @@ var GameVfx = (() => {
6662
7210
  }
6663
7211
  this.accumulators.set(key, carried);
6664
7212
  }
7213
+ /** A solid particle (a cone, a sphere): the group sits at `p` turned by the placement, `v` is turned with it and `wv` is not. */
7214
+ mesh(recipe) {
7215
+ const placement = this.placement;
7216
+ const options = placement ? { ...recipe, p: this.place(recipe.p), ...recipe.v ? { v: this.turn(recipe.v) } : {} } : recipe;
7217
+ this.context.trace?.("mesh", [options]);
7218
+ const grouped = recipe.at !== void 0 || recipe.roll !== void 0;
7219
+ return this.meshes.spawn(options, placement && grouped ? placement.orientation ?? [0, Math.sin(placement.yaw / 2), 0, Math.cos(placement.yaw / 2)] : void 0);
7220
+ }
6665
7221
  debrisPiece(recipe) {
6666
7222
  const options = this.placed(recipe);
6667
7223
  this.context.trace?.("debris", [options]);
@@ -6682,10 +7238,11 @@ var GameVfx = (() => {
6682
7238
  this.context.trace?.("ring", args);
6683
7239
  this.rings.add(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
6684
7240
  }
7241
+ /** `steady` (a seventh number): the light holds its intensity for its duration and goes out, where the Workshop's fades with the square of its age. */
6685
7242
  flash(recipe) {
6686
- const args = this.placement ? [this.place(recipe[0]), recipe[1], recipe[2], recipe[3], recipe[4], recipe[5]] : recipe;
6687
- this.context.trace?.("flash", args);
6688
- this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5]);
7243
+ const args = this.placement ? [this.place(recipe[0]), recipe[1], recipe[2], recipe[3], recipe[4], recipe[5], recipe[6]] : recipe;
7244
+ this.context.trace?.("flash", args.slice(0, 6));
7245
+ this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
6689
7246
  }
6690
7247
  /** `fireLight` (W400): sways with the clock and flickers with one draw. */
6691
7248
  fireLight(slot, recipe, intensity, time) {
@@ -6710,6 +7267,7 @@ var GameVfx = (() => {
6710
7267
  this.debris.update(dt);
6711
7268
  this.decals.update(dt);
6712
7269
  this.rings.update(dt);
7270
+ this.meshes.update(dt);
6713
7271
  this.lights.update(dt);
6714
7272
  updateScreen(this.screen, dt);
6715
7273
  for (let index = this.lens.length - 1; index >= 0; index--) {
@@ -6726,7 +7284,9 @@ var GameVfx = (() => {
6726
7284
  this.debris.clear();
6727
7285
  this.decals.clear();
6728
7286
  this.rings.clear();
7287
+ this.meshes.clear();
6729
7288
  this.lights.clear();
7289
+ this.rain.clear();
6730
7290
  this.accumulators.clear();
6731
7291
  resetScreenState(this.screen);
6732
7292
  this.lens.length = 0;
@@ -6876,16 +7436,16 @@ var GameVfx = (() => {
6876
7436
  },
6877
7437
  push(point, radius, speed) {
6878
7438
  spriteSystem.push(point, radius, speed);
6879
- for (const puff2 of core.puffs.items) {
6880
- const dx = puff2.x - point[0];
6881
- const dy = puff2.y - point[1];
6882
- const dz = puff2.z - point[2];
7439
+ for (const puff3 of core.puffs.items) {
7440
+ const dx = puff3.x - point[0];
7441
+ const dy = puff3.y - point[1];
7442
+ const dz = puff3.z - point[2];
6883
7443
  const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
6884
7444
  if (distance >= radius) continue;
6885
7445
  const strength = speed * (1 - distance / radius) / (distance + 1e-3);
6886
- puff2.vx += dx * strength;
6887
- puff2.vy += dy * strength;
6888
- puff2.vz += dz * strength;
7446
+ puff3.vx += dx * strength;
7447
+ puff3.vy += dy * strength;
7448
+ puff3.vz += dz * strength;
6889
7449
  }
6890
7450
  },
6891
7451
  stop(handle) {
@@ -6902,6 +7462,12 @@ var GameVfx = (() => {
6902
7462
  camera2.y = position[1];
6903
7463
  camera2.z = position[2];
6904
7464
  },
7465
+ setWind(next) {
7466
+ wind.x = next[0];
7467
+ wind.y = next[1];
7468
+ wind.z = next[2];
7469
+ },
7470
+ wind: () => [wind.x, wind.y, wind.z],
6905
7471
  forceLod(scale) {
6906
7472
  core.clock.forcedLod = scale;
6907
7473
  },
@@ -7253,6 +7819,27 @@ var GameVfx = (() => {
7253
7819
  budget: "Up to 600 particles per building and 2 fire lights. Beyond 80 m only the smoke column and the glow of the windows remain, which become a landmark.",
7254
7820
  network: "A fire entity on the server per building, with a spread state."
7255
7821
  },
7822
+ rain_and_puddles: {
7823
+ name: "Rain, splashes and puddles",
7824
+ short: "Drops with wind, splashes and rings only near the camera, lightning in the storm.",
7825
+ cost: "\u2264 4,000 drops",
7826
+ costNote: "splash up to 12 m",
7827
+ paramLabel: "Intensity",
7828
+ when: "The weather of the world. Rain raises the background noise and masks footsteps (it can be used for stealth).",
7829
+ look: "A fine drizzle, almost vertical. Rain with splashes on the asphalt and rings in the puddles, which are dark and mirror-like. A storm with drops slanted by the wind, sheets of water passing and a double flash of lightning that lights the scene for 0.2 s and reveals the horde.",
7830
+ budget: "Up to 4,000 drops tied to the camera in a 30 m box. Splashes and rings only within 12 m and only on what the camera sees.",
7831
+ network: "The server sends the weather and the lightning seed, so everyone sees the same flash."
7832
+ },
7833
+ fog_and_ash: {
7834
+ name: "Fog and ash",
7835
+ short: "Low layered mist, ash falling and the lamp post with its cone of light.",
7836
+ cost: "\u2264 120 sprites",
7837
+ costNote: "1 cone of light",
7838
+ when: "Before dawn, near the river and in burnt zones (ash). It cuts the sight of the zombies and of the player.",
7839
+ look: "The engine fog plus a layer of low mist that moves slowly, fine ash falling in a spiral and the beam of the lamp posts in view. Zombie silhouettes show before their details.",
7840
+ budget: "Up to 60 large mist sprites (half resolution) and 60 of ash. The lamp cone is an additive mesh, not real volumetric light.",
7841
+ network: "The weather comes from the server. The density is local, by zone."
7842
+ },
7256
7843
  scraping_sparks: {
7257
7844
  name: "Scraping sparks",
7258
7845
  short: "A bumper dragging on the asphalt: a river of bouncing sparks and a mark on the ground.",
@@ -7304,6 +7891,16 @@ var GameVfx = (() => {
7304
7891
  budget: "Texture only: a crack mask with 4 stages and a blood decal on the glass. Glass dust: 6 particles per blow.",
7305
7892
  network: "The server sends the glass health. Blood on the glass is local."
7306
7893
  },
7894
+ headlights_in_rain: {
7895
+ name: "Headlights in the rain",
7896
+ short: "A visible beam, drops lit inside the cone and the horde walking into the light.",
7897
+ cost: "\u2264 600 lit drops",
7898
+ costNote: "2 spots, no shadow",
7899
+ when: "Headlights on at night, with rain or fog.",
7900
+ look: "Two cones of light in the air, rain drops that shine only inside the beam and zombie silhouettes that light up when they enter the light. Outside the cone the rain almost disappears.",
7901
+ budget: "2 spotlights without shadow, 2 additive cones and up to 600 extra drops only inside the cone. Headlights of cars beyond 40 m stay as a cone only, with no real light.",
7902
+ network: "The state of the headlights is already replicated with the car."
7903
+ },
7307
7904
  damage_and_bite: {
7308
7905
  name: "Damage and bite",
7309
7906
  short: "A red edge on the side of the blow, blood on the lens and the pulse of the bite.",
@@ -7623,6 +8220,27 @@ var GameVfx = (() => {
7623
8220
  budget: "At\xE9 600 part\xEDculas por pr\xE9dio e 2 luzes de fogo. Al\xE9m de 80 m fica s\xF3 a coluna de fuma\xE7a e o brilho das janelas, que viram ponto de refer\xEAncia.",
7624
8221
  network: "Entidade de fogo no servidor por pr\xE9dio, com estado de espalhar."
7625
8222
  },
8223
+ rain_and_puddles: {
8224
+ name: "Chuva, respingos e po\xE7as",
8225
+ short: "Gotas com vento, respingos e an\xE9is s\xF3 perto da c\xE2mera, rel\xE2mpago no temporal.",
8226
+ cost: "\u2264 4.000 gotas",
8227
+ costNote: "respingo at\xE9 12 m",
8228
+ paramLabel: "Intensidade",
8229
+ when: "Clima do mundo. Chuva aumenta o ru\xEDdo de fundo e mascara passos (d\xE1 para usar na furtividade).",
8230
+ look: "Garoa fina quase vertical. Chuva com respingos no asfalto e an\xE9is nas po\xE7as, que ficam escuras e espelhadas. Temporal com gotas inclinadas pelo vento, cortinas de \xE1gua passando e rel\xE2mpago duplo que clareia a cena por 0,2 s e revela a horda.",
8231
+ budget: "At\xE9 4.000 gotas presas \xE0 c\xE2mera numa caixa de 30 m. Respingos e an\xE9is s\xF3 a menos de 12 m e s\xF3 em cima do que a c\xE2mera v\xEA.",
8232
+ network: "O servidor manda o clima e a semente do rel\xE2mpago, para todos verem o mesmo clar\xE3o."
8233
+ },
8234
+ fog_and_ash: {
8235
+ name: "Neblina e cinzas",
8236
+ short: "N\xE9voa rasteira em camadas, cinza caindo e o poste com cone de luz.",
8237
+ cost: "\u2264 120 sprites",
8238
+ costNote: "1 cone de luz",
8239
+ when: "Madrugada, perto de rio e em zonas queimadas (cinza). Reduz a vis\xE3o dos zumbis e do jogador.",
8240
+ look: "Neblina do motor mais uma camada de n\xE9voa baixa que se move devagar, cinza fina caindo em espiral e o feixe dos postes vis\xEDvel. Silhuetas de zumbis aparecem antes dos detalhes.",
8241
+ budget: "At\xE9 60 sprites grandes de n\xE9voa (meia resolu\xE7\xE3o) e 60 de cinza. O cone do poste \xE9 uma malha aditiva, n\xE3o luz volum\xE9trica real.",
8242
+ network: "Clima vem do servidor. Densidade \xE9 local por zona."
8243
+ },
7626
8244
  scraping_sparks: {
7627
8245
  name: "Fa\xEDscas de raspagem",
7628
8246
  short: "Para-choque arrastando no asfalto: rio de fa\xEDscas que quicam e marca no ch\xE3o.",
@@ -7674,6 +8292,16 @@ var GameVfx = (() => {
7674
8292
  budget: "S\xF3 textura: uma m\xE1scara de rachadura com 4 est\xE1gios e um decal de sangue no vidro. P\xF3 de vidro: 6 part\xEDculas por golpe.",
7675
8293
  network: "O servidor manda a vida do vidro. Sangue no vidro \xE9 local."
7676
8294
  },
8295
+ headlights_in_rain: {
8296
+ name: "Far\xF3is na chuva",
8297
+ short: "Feixe vis\xEDvel, gotas acesas dentro do cone e a horda entrando na luz.",
8298
+ cost: "\u2264 600 gotas acesas",
8299
+ costNote: "2 spots sem sombra",
8300
+ when: "Far\xF3is ligados \xE0 noite, com chuva ou neblina.",
8301
+ look: "Dois cones de luz vis\xEDveis no ar, gotas de chuva que brilham s\xF3 dentro do feixe e silhuetas de zumbi que acendem quando entram na luz. Fora do cone, a chuva quase some.",
8302
+ budget: "2 spotlights sem sombra, 2 cones aditivos e at\xE9 600 gotas extras s\xF3 dentro do cone. Far\xF3is de carros a mais de 40 m ficam s\xF3 como cone, sem luz real.",
8303
+ network: "Estado do farol j\xE1 \xE9 replicado com o carro."
8304
+ },
7677
8305
  damage_and_bite: {
7678
8306
  name: "Dano e mordida",
7679
8307
  short: "Borda vermelha do lado do golpe, sangue na lente e o pulso da mordida.",
@@ -7773,7 +8401,7 @@ var GameVfx = (() => {
7773
8401
  function mix(from, to, amount) {
7774
8402
  return [from[0] + (to[0] - from[0]) * amount, from[1] + (to[1] - from[1]) * amount, from[2] + (to[2] - from[2]) * amount];
7775
8403
  }
7776
- function rotate(local2, x, y, z, w) {
8404
+ function rotate2(local2, x, y, z, w) {
7777
8405
  const [vx2, vy2, vz2] = local2;
7778
8406
  const ix = w * vx2 + y * vz2 - z * vy2;
7779
8407
  const iy = w * vy2 + z * vx2 - x * vz2;
@@ -7831,7 +8459,7 @@ var GameVfx = (() => {
7831
8459
  /** A direction given in the camera's own axes, in world axes. */
7832
8460
  forward(local2) {
7833
8461
  const [x, y, z, w] = lookAtQuaternion(this.position, this.target);
7834
- return rotate(local2, x, y, z, w);
8462
+ return rotate2(local2, x, y, z, w);
7835
8463
  }
7836
8464
  };
7837
8465