@adatechnology/game-vfx 0.1.3 → 0.2.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,152 @@ 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
+
3368
3759
  // 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];
3760
+ 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
3761
  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])) };
3762
+ var GAME_EFFECTS = { ...WORKSHOP_EFFECTS, ...Object.fromEntries([...EVENT_EFFECTS, ...VIEWMODEL_EFFECTS].map((effect) => [effect.id, effect])) };
3372
3763
  function patchEffects(base, changes) {
3373
3764
  const result = { ...base };
3374
3765
  for (const [id, change] of Object.entries(changes)) {
@@ -3506,7 +3897,7 @@ var GameVfx = (() => {
3506
3897
  // src/effects/behaviors/blocks.ts
3507
3898
  var COLUMNS = 6;
3508
3899
  var ROWS = 5;
3509
- var ORIGIN2 = [-2.2, 0, 2.6];
3900
+ var ORIGIN3 = [-2.2, 0, 2.6];
3510
3901
  var BLOCK_SIZE = [0.5, 0.44, 0.25];
3511
3902
  var OBJECT_ID_DRAWS2 = 4;
3512
3903
  var FLOOR2 = 0.13;
@@ -3549,7 +3940,7 @@ var GameVfx = (() => {
3549
3940
  const chipScale = random.between(0.8, 1.3) * scale;
3550
3941
  for (let draw = 0; draw < OBJECT_ID_DRAWS2; draw++) random.next();
3551
3942
  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);
3943
+ impact(host.engine, "concrete", [ORIGIN3[0] + x, y, ORIGIN3[2] + 0.13], [0, 0, 1], 0.8);
3553
3944
  } else if (action === "collapse") {
3554
3945
  const { x, y } = args;
3555
3946
  for (const block of blocks) {
@@ -3601,7 +3992,7 @@ var GameVfx = (() => {
3601
3992
  }
3602
3993
 
3603
3994
  // src/effects/behaviors/car.ts
3604
- var ORIGIN3 = [5.6, 0, 0.8];
3995
+ var ORIGIN4 = [5.6, 0, 0.8];
3605
3996
  var MAX_TILT = 0.25;
3606
3997
  function createCarBehavior() {
3607
3998
  let y = 0;
@@ -3633,8 +4024,13 @@ var GameVfx = (() => {
3633
4024
  }
3634
4025
  }
3635
4026
  },
3636
- query(_host, name) {
3637
- if (name === "position") return [ORIGIN3[0], y, ORIGIN3[2]];
4027
+ query(_host, name, args) {
4028
+ if (name === "position") return [ORIGIN4[0], y, ORIGIN4[2]];
4029
+ if (name === "point") {
4030
+ const [x, py, z] = args;
4031
+ const point = carPoint(x, py, z);
4032
+ return [point[0], point[1] + y, point[2]];
4033
+ }
3638
4034
  if (name === "roll") return roll;
3639
4035
  throw new Error(`car: unknown query ${name}`);
3640
4036
  },
@@ -3843,6 +4239,31 @@ var GameVfx = (() => {
3843
4239
  };
3844
4240
  }
3845
4241
 
4242
+ // src/effects/behaviors/rain.ts
4243
+ function createRainBehavior() {
4244
+ return {
4245
+ reset() {
4246
+ },
4247
+ act(host, action, args) {
4248
+ const { engine, camera: camera2 } = host;
4249
+ if (action === "init") {
4250
+ const { count, wind } = args;
4251
+ engine.rain.init(count, wind);
4252
+ } else if (action === "update") {
4253
+ const { dt, splash } = args;
4254
+ engine.rain.update(dt, splash, camera2.position);
4255
+ }
4256
+ },
4257
+ query(host, name) {
4258
+ if (name === "count") return host.engine.rain.count;
4259
+ if (name === "on") return host.engine.rain.on;
4260
+ throw new Error(`rain: unknown query ${name}`);
4261
+ },
4262
+ update() {
4263
+ }
4264
+ };
4265
+ }
4266
+
3846
4267
  // src/effects/behaviors/walkers.ts
3847
4268
  var WALKER_COUNT = 10;
3848
4269
  var ARRIVAL_DISTANCE = 0.05;
@@ -3911,7 +4332,8 @@ var GameVfx = (() => {
3911
4332
  blocks: () => createBlocksBehavior(),
3912
4333
  plate: () => createPlateBehavior(),
3913
4334
  cylinder: () => createCylinderBehavior(),
3914
- car: () => createCarBehavior()
4335
+ car: () => createCarBehavior(),
4336
+ rain: () => createRainBehavior()
3915
4337
  };
3916
4338
  function createWorkshopBehaviors(factories = WORKSHOP_BEHAVIORS) {
3917
4339
  return Object.fromEntries(Object.entries(factories).map(([id, make]) => [id, make()]));
@@ -3989,6 +4411,8 @@ var GameVfx = (() => {
3989
4411
  return Math.abs(asNumber(first));
3990
4412
  case "sqrt":
3991
4413
  return Math.sqrt(asNumber(first));
4414
+ case "exp":
4415
+ return Math.exp(asNumber(first));
3992
4416
  case "sin":
3993
4417
  return Math.sin(asNumber(first));
3994
4418
  case "cos":
@@ -4109,7 +4533,7 @@ var GameVfx = (() => {
4109
4533
  }
4110
4534
 
4111
4535
  // src/effects/builders/fire.ts
4112
- var UP11 = [0, 1, 0];
4536
+ var UP12 = [0, 1, 0];
4113
4537
  var ZERO = [0, 0, 0];
4114
4538
  var FULL_TURN_DRAWN = 6.283;
4115
4539
  function scaledSizes(range, factor) {
@@ -4122,7 +4546,7 @@ var GameVfx = (() => {
4122
4546
  p: centre,
4123
4547
  r: radius,
4124
4548
  flat: true,
4125
- dir: options.dir ?? UP11,
4549
+ dir: options.dir ?? UP12,
4126
4550
  cone: 0.35,
4127
4551
  sp: [0.4, 1.4],
4128
4552
  v: wind,
@@ -4139,7 +4563,7 @@ var GameVfx = (() => {
4139
4563
  p: centre,
4140
4564
  r: radius * 0.6,
4141
4565
  flat: true,
4142
- dir: UP11,
4566
+ dir: UP12,
4143
4567
  cone: 0.3,
4144
4568
  sp: [0.3, 0.8],
4145
4569
  life: [0.2, 0.4],
@@ -4154,14 +4578,14 @@ var GameVfx = (() => {
4154
4578
  if (engine.quality < 2) {
4155
4579
  engine.emit(`${key}e`, "streak", 10 * factor, dt, () => {
4156
4580
  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 };
4581
+ 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
4582
  });
4159
4583
  }
4160
4584
  if (options.noSmoke) return;
4161
4585
  engine.emit(`${key}s`, "normal", (options.smoke || 14) * factor, dt, () => ({
4162
4586
  p: plus(centre, 0, 0.8 * sqrtFactor, 0),
4163
4587
  r: radius * 0.7,
4164
- dir: UP11,
4588
+ dir: UP12,
4165
4589
  cone: 0.35,
4166
4590
  sp: [0.6, 1.4],
4167
4591
  v: wind,
@@ -4201,15 +4625,15 @@ var GameVfx = (() => {
4201
4625
  engine.screen.shake += 0.7 * scale;
4202
4626
  engine.screen.white += 0.18 * scale;
4203
4627
  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 });
4628
+ 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
4629
  engine.ring([plus(point, 0, 0.05, 0), 0.3, 7 * scale, 0.55, 16767136]);
4206
4630
  const toCamera = normalized([cameraPosition[0] - point[0], cameraPosition[1] - point[1], cameraPosition[2] - point[2]]);
4207
4631
  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 });
4632
+ 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
4633
  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 });
4634
+ 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
4635
  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 });
4636
+ 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
4637
  }
4214
4638
  engine.decal([point[0], engine.context.groundAt(point[0], point[2]), point[2], 3 * scale, 657930, { grow: 0.15, life: 60 }]);
4215
4639
  }
@@ -4360,6 +4784,7 @@ var GameVfx = (() => {
4360
4784
  if (!def) return;
4361
4785
  this.schedule.clear();
4362
4786
  this.variables.clear();
4787
+ for (const [name, value] of Object.entries(this.setup.values ?? {})) this.variables.set(name, value);
4363
4788
  for (const behavior2 of this.deps.behaviors()) behavior2.reset(this.host);
4364
4789
  this.time = 0;
4365
4790
  this.within(() => {
@@ -4418,6 +4843,10 @@ var GameVfx = (() => {
4418
4843
  return engine.spawn(step.system, this.value(step.spawn));
4419
4844
  case "emit":
4420
4845
  return engine.emit(step.key, step.system, this.value(step.rate), this.dt, () => this.value(step.spawn));
4846
+ case "mesh": {
4847
+ engine.mesh(this.value(step.spawn));
4848
+ return;
4849
+ }
4421
4850
  case "debris":
4422
4851
  return engine.debrisPiece(this.value(step.spawn));
4423
4852
  case "decal":
@@ -4501,7 +4930,7 @@ var GameVfx = (() => {
4501
4930
  };
4502
4931
 
4503
4932
  // src/effects/player.ts
4504
- var ORIGIN4 = [0, 0, 0];
4933
+ var ORIGIN5 = [0, 0, 0];
4505
4934
  var DEFAULT_HEADING = [0, 0, -1];
4506
4935
  var DEFAULT_MAX_INSTANCES = 48;
4507
4936
  var ENDLESS_SECONDS = 60;
@@ -4546,7 +4975,7 @@ var GameVfx = (() => {
4546
4975
  }
4547
4976
  function placementOf(entry) {
4548
4977
  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 };
4978
+ return { origin, anchor: entry.anchor, yaw: entry.yaw, ...entry.orientation ? { orientation: entry.orientation } : {} };
4550
4979
  }
4551
4980
  function drawing(entry, action) {
4552
4981
  const context = engine.context;
@@ -4570,8 +4999,9 @@ var GameVfx = (() => {
4570
4999
  random: playOptions.seed !== void 0 ? streamOf(playOptions.seed) : void 0,
4571
5000
  follow: playOptions.follow,
4572
5001
  origin: point,
4573
- anchor: def.anchor ?? ORIGIN4,
5002
+ anchor: def.anchor ?? ORIGIN5,
4574
5003
  yaw: yawOf(heading, playOptions.direction),
5004
+ orientation: playOptions.orientation,
4575
5005
  seconds: playOptions.seconds ?? (def.loop && def.loop > 0 ? def.loop : ENDLESS_SECONDS)
4576
5006
  };
4577
5007
  playing.push(entry);
@@ -4580,7 +5010,8 @@ var GameVfx = (() => {
4580
5010
  () => instance.begin(def, paramIndex(def, playOptions.param), {
4581
5011
  placement: placementOf(entry),
4582
5012
  ...playOptions.direction ? { direction: playOptions.direction } : {},
4583
- ...playOptions.normal ? { normal: playOptions.normal } : {}
5013
+ ...playOptions.normal ? { normal: playOptions.normal } : {},
5014
+ ...playOptions.values ? { values: playOptions.values } : {}
4584
5015
  })
4585
5016
  );
4586
5017
  return entry.handle;
@@ -4851,15 +5282,15 @@ var GameVfx = (() => {
4851
5282
  return shock;
4852
5283
  }
4853
5284
  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;
5285
+ for (const puff3 of puffs) {
5286
+ if (puff3.ring || puff3.t > PUSH_AGE_LIMIT) continue;
5287
+ const dx = puff3.x - shock.x;
5288
+ const dz = puff3.z - shock.z;
4858
5289
  const distance = Math.hypot(dx, dz) + 1e-3;
4859
- if (Math.abs(distance - reach) < PUSH_BAND && puff2.y < PUSH_CEILING) {
5290
+ if (Math.abs(distance - reach) < PUSH_BAND && puff3.y < PUSH_CEILING) {
4860
5291
  const strength = 4 * dt * (1 - age);
4861
- puff2.vx += dx / distance * strength * 6;
4862
- puff2.vz += dz / distance * strength * 6;
5292
+ puff3.vx += dx / distance * strength * 6;
5293
+ puff3.vz += dz / distance * strength * 6;
4863
5294
  }
4864
5295
  }
4865
5296
  }
@@ -5161,10 +5592,10 @@ var GameVfx = (() => {
5161
5592
  const life = random.between(ring2.life * 0.75, ring2.life);
5162
5593
  const h0 = random.between(1, 1.25);
5163
5594
  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;
5595
+ 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 });
5596
+ puff3.ring = ring2;
5597
+ puff3.ph = random.next() * Math.PI * 2;
5598
+ puff3.th = random.next() * Math.PI * 2;
5168
5599
  }
5169
5600
  const stemCount = Math.round((spec.stem || 18) * Math.max(lod, 0.4));
5170
5601
  for (let index = 0; index < stemCount; index++) {
@@ -5988,7 +6419,7 @@ var GameVfx = (() => {
5988
6419
  // src/workshop/direction.ts
5989
6420
  var TWO_PI_ROUNDED = 6.2832;
5990
6421
  var WIDE_CONE = 3.1;
5991
- var UP12 = [0, 1, 0];
6422
+ var UP13 = [0, 1, 0];
5992
6423
  function drawRange(random, range) {
5993
6424
  if (Array.isArray(range)) return random.between(range[0], range[1]);
5994
6425
  return range || 0;
@@ -6016,7 +6447,7 @@ var GameVfx = (() => {
6016
6447
  }
6017
6448
  function coneDirection(random, direction, cone, out) {
6018
6449
  if (cone >= WIDE_CONE) return randomUnit(random, out);
6019
- const [dx, dy, dz] = direction ?? UP12;
6450
+ const [dx, dy, dz] = direction ?? UP13;
6020
6451
  const cosTilt = 1 - random.next() * (1 - Math.cos(cone));
6021
6452
  const sinTilt = Math.sqrt(1 - cosTilt * cosTilt);
6022
6453
  const phase = random.next() * TWO_PI_ROUNDED;
@@ -6140,12 +6571,12 @@ var GameVfx = (() => {
6140
6571
 
6141
6572
  // src/workshop/decals.ts
6142
6573
  var CAPACITY2 = 400;
6143
- var UP13 = [0, 1, 0];
6574
+ var UP14 = [0, 1, 0];
6144
6575
  var DEFAULT_LIFE2 = 60;
6145
6576
  var DEFAULT_GROW = 1.2;
6146
6577
  var EVAPORATION = { fuel: [6, 5], water: [40, 20] };
6147
6578
  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 };
6579
+ 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
6580
  }
6150
6581
  var DecalPool = class {
6151
6582
  constructor(context) {
@@ -6158,7 +6589,7 @@ var GameVfx = (() => {
6158
6589
  const random = this.context.random;
6159
6590
  const index = this.next++ % CAPACITY2;
6160
6591
  const decal2 = this.decals[index];
6161
- const normal = options.n ?? UP13;
6592
+ const normal = options.n ?? UP14;
6162
6593
  random.between(0, 6.28);
6163
6594
  const offset = 4e-3 + index % 40 * 4e-4;
6164
6595
  decal2.on = true;
@@ -6200,6 +6631,96 @@ var GameVfx = (() => {
6200
6631
  }
6201
6632
  };
6202
6633
 
6634
+ // src/workshop/meshes.ts
6635
+ var CAPACITY3 = 400;
6636
+ var IDENTITY = [0, 0, 0, 1];
6637
+ function multiply(a, b) {
6638
+ const [ax, ay, az, aw] = a;
6639
+ const [bx, by, bz, bw] = b;
6640
+ 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];
6641
+ }
6642
+ var aboutX = (angle) => [Math.sin(angle / 2), 0, 0, Math.cos(angle / 2)];
6643
+ var MeshPool = class {
6644
+ constructor(capacity = CAPACITY3) {
6645
+ __publicField(this, "capacity", capacity);
6646
+ __publicField(this, "particles", []);
6647
+ __publicField(this, "serial", 0);
6648
+ }
6649
+ get count() {
6650
+ return this.particles.length;
6651
+ }
6652
+ spawn(options, frame = IDENTITY) {
6653
+ const velocity = options.v ?? [0, 0, 0];
6654
+ const world = options.wv ?? [0, 0, 0];
6655
+ const particle = {
6656
+ id: ++this.serial,
6657
+ shape: options.shape,
6658
+ radius: options.r,
6659
+ height: options.h ?? 0,
6660
+ segments: options.seg ?? 0,
6661
+ segments2: options.seg2 ?? 0,
6662
+ color: options.c0,
6663
+ additive: options.add === true,
6664
+ lit: options.lit === true,
6665
+ x: options.p[0],
6666
+ y: options.p[1],
6667
+ z: options.p[2],
6668
+ frame: options.roll ? multiply(frame, aboutX(options.roll)) : frame,
6669
+ at: options.at ?? [0, 0, 0],
6670
+ rx: options.rot?.[0] ?? 0,
6671
+ ry: options.rot?.[1] ?? 0,
6672
+ rz: options.rot?.[2] ?? 0,
6673
+ scale: 1,
6674
+ opacity: options.a,
6675
+ age: 0,
6676
+ life: options.life,
6677
+ vx: velocity[0] + world[0],
6678
+ vy: velocity[1] + world[1],
6679
+ vz: velocity[2] + world[2],
6680
+ spin: options.spin ?? [0, 0, 0],
6681
+ gravity: options.g ?? 0,
6682
+ drag: options.drag ?? 0,
6683
+ grow: options.grow ?? 0,
6684
+ ramp: options.ramp,
6685
+ fade: options.fade === true,
6686
+ startOpacity: options.a
6687
+ };
6688
+ this.particles.push(particle);
6689
+ if (this.particles.length > this.capacity) this.particles.shift();
6690
+ return particle;
6691
+ }
6692
+ update(dt) {
6693
+ const live = this.particles;
6694
+ for (let index = 0; index < live.length; index++) {
6695
+ const particle = live[index];
6696
+ particle.age += dt;
6697
+ if (particle.ramp ? particle.age >= particle.life : particle.age > particle.life) {
6698
+ live.splice(index--, 1);
6699
+ continue;
6700
+ }
6701
+ if (particle.fade) particle.opacity = Math.max(0, particle.startOpacity * (1 - particle.age / particle.life));
6702
+ particle.vy -= particle.gravity * dt;
6703
+ if (particle.drag) {
6704
+ const keep = Math.max(0, 1 - particle.drag * dt);
6705
+ particle.vx *= keep;
6706
+ particle.vy *= keep;
6707
+ particle.vz *= keep;
6708
+ }
6709
+ particle.x += particle.vx * dt;
6710
+ particle.y += particle.vy * dt;
6711
+ particle.z += particle.vz * dt;
6712
+ particle.rx += particle.spin[0] * dt;
6713
+ particle.ry += particle.spin[1] * dt;
6714
+ particle.rz += particle.spin[2] * dt;
6715
+ if (particle.grow) particle.scale *= 1 + particle.grow * dt;
6716
+ if (particle.ramp) particle.scale = particle.ramp[0] + Math.min(1, particle.age / particle.life) * particle.ramp[1];
6717
+ }
6718
+ }
6719
+ clear() {
6720
+ this.particles.length = 0;
6721
+ }
6722
+ };
6723
+
6203
6724
  // src/workshop/sprites.ts
6204
6725
  var DEFAULT_FADE_IN = 0.1;
6205
6726
  var FLOATS_PER_VECTOR = 3;
@@ -6496,11 +7017,11 @@ var GameVfx = (() => {
6496
7017
  // src/workshop/waves.ts
6497
7018
  var RING_CAPACITY = 120;
6498
7019
  var LIGHT_CAPACITY = 4;
6499
- var UP14 = [0, 1, 0];
7020
+ var UP15 = [0, 1, 0];
6500
7021
  var DEFAULT_LIGHT_DISTANCE = 14;
6501
7022
  var WaveRingPool = class {
6502
7023
  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 })));
7024
+ __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
7025
  __publicField(this, "count", 0);
6505
7026
  __publicField(this, "next", 0);
6506
7027
  }
@@ -6513,7 +7034,7 @@ var GameVfx = (() => {
6513
7034
  ring2.t = 0;
6514
7035
  ring2.duration = duration;
6515
7036
  ring2.color = color;
6516
- ring2.normal = normal ?? UP14;
7037
+ ring2.normal = normal ?? UP15;
6517
7038
  ring2.hold = hold || 0;
6518
7039
  }
6519
7040
  clear() {
@@ -6533,7 +7054,7 @@ var GameVfx = (() => {
6533
7054
  var FlashLightPool = class {
6534
7055
  constructor(context) {
6535
7056
  __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 })));
7057
+ __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
7058
  __publicField(this, "fire", [
6538
7059
  { x: 0, y: 0, z: 0, intensity: 0 },
6539
7060
  { x: 0, y: 0, z: 0, intensity: 0 }
@@ -6543,7 +7064,7 @@ var GameVfx = (() => {
6543
7064
  get lit() {
6544
7065
  return this.lights.filter((light) => light.intensity > 0).length;
6545
7066
  }
6546
- flash(point, color, intensity, duration, distance, force) {
7067
+ flash(point, color, intensity, duration, distance, force, steady) {
6547
7068
  const { level } = this.context.quality;
6548
7069
  if (level >= 1 && !force) return;
6549
7070
  if (level >= 2 && force !== "boom") return;
@@ -6556,6 +7077,7 @@ var GameVfx = (() => {
6556
7077
  light.peak = intensity;
6557
7078
  light.duration = duration;
6558
7079
  light.t = 0;
7080
+ light.steady = steady === true;
6559
7081
  light.intensity = intensity;
6560
7082
  }
6561
7083
  clear() {
@@ -6567,7 +7089,7 @@ var GameVfx = (() => {
6567
7089
  if (light.intensity <= 0) continue;
6568
7090
  light.t += dt;
6569
7091
  const age = light.t / light.duration;
6570
- light.intensity = age >= 1 ? 0 : light.peak * (1 - age) * (1 - age);
7092
+ light.intensity = age >= 1 ? 0 : light.steady ? light.peak : light.peak * (1 - age) * (1 - age);
6571
7093
  }
6572
7094
  }
6573
7095
  };
@@ -6577,6 +7099,14 @@ var GameVfx = (() => {
6577
7099
  var FIRE_FLICKER_SWAY = 0.25;
6578
7100
  var FIRE_FLICKER_JITTER = 0.08;
6579
7101
  var LENS_FADE = 0.16;
7102
+ function rotate(q, v) {
7103
+ const [qx, qy, qz, qw] = q;
7104
+ const ix = qw * v[0] + qy * v[2] - qz * v[1];
7105
+ const iy = qw * v[1] + qz * v[0] - qx * v[2];
7106
+ const iz = qw * v[2] + qx * v[1] - qy * v[0];
7107
+ const iw = -qx * v[0] - qy * v[1] - qz * v[2];
7108
+ 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];
7109
+ }
6580
7110
  function workshopGround(x, z) {
6581
7111
  return z < -2.9 && z > -4.5 && Math.abs(x) < 13 ? 0.12 : 0;
6582
7112
  }
@@ -6590,6 +7120,8 @@ var GameVfx = (() => {
6590
7120
  __publicField(this, "decals");
6591
7121
  __publicField(this, "rings", new WaveRingPool());
6592
7122
  __publicField(this, "lights");
7123
+ __publicField(this, "rain", new RainField(this));
7124
+ __publicField(this, "meshes", new MeshPool());
6593
7125
  __publicField(this, "screen", createScreenState());
6594
7126
  __publicField(this, "lens", []);
6595
7127
  __publicField(this, "post", {});
@@ -6623,7 +7155,11 @@ var GameVfx = (() => {
6623
7155
  place(point) {
6624
7156
  const placement = this.placement;
6625
7157
  if (!placement) return point;
6626
- const { anchor, origin, yaw } = placement;
7158
+ const { anchor, origin, yaw, orientation } = placement;
7159
+ if (orientation) {
7160
+ const turned = rotate(orientation, [point[0] - anchor[0], point[1] - anchor[1], point[2] - anchor[2]]);
7161
+ return [origin[0] + turned[0], origin[1] + turned[1], origin[2] + turned[2]];
7162
+ }
6627
7163
  const x = point[0] - anchor[0];
6628
7164
  const z = point[2] - anchor[2];
6629
7165
  const cos2 = Math.cos(yaw);
@@ -6634,6 +7170,7 @@ var GameVfx = (() => {
6634
7170
  turn(vector) {
6635
7171
  const placement = this.placement;
6636
7172
  if (!placement) return vector;
7173
+ if (placement.orientation) return rotate(placement.orientation, vector);
6637
7174
  const cos2 = Math.cos(placement.yaw);
6638
7175
  const sin2 = Math.sin(placement.yaw);
6639
7176
  return [cos2 * vector[0] + sin2 * vector[2], vector[1], -sin2 * vector[0] + cos2 * vector[2]];
@@ -6662,6 +7199,14 @@ var GameVfx = (() => {
6662
7199
  }
6663
7200
  this.accumulators.set(key, carried);
6664
7201
  }
7202
+ /** 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. */
7203
+ mesh(recipe) {
7204
+ const placement = this.placement;
7205
+ const options = placement ? { ...recipe, p: this.place(recipe.p), ...recipe.v ? { v: this.turn(recipe.v) } : {} } : recipe;
7206
+ this.context.trace?.("mesh", [options]);
7207
+ const grouped = recipe.at !== void 0 || recipe.roll !== void 0;
7208
+ return this.meshes.spawn(options, placement && grouped ? placement.orientation ?? [0, Math.sin(placement.yaw / 2), 0, Math.cos(placement.yaw / 2)] : void 0);
7209
+ }
6665
7210
  debrisPiece(recipe) {
6666
7211
  const options = this.placed(recipe);
6667
7212
  this.context.trace?.("debris", [options]);
@@ -6682,10 +7227,11 @@ var GameVfx = (() => {
6682
7227
  this.context.trace?.("ring", args);
6683
7228
  this.rings.add(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
6684
7229
  }
7230
+ /** `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
7231
  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]);
7232
+ const args = this.placement ? [this.place(recipe[0]), recipe[1], recipe[2], recipe[3], recipe[4], recipe[5], recipe[6]] : recipe;
7233
+ this.context.trace?.("flash", args.slice(0, 6));
7234
+ this.lights.flash(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
6689
7235
  }
6690
7236
  /** `fireLight` (W400): sways with the clock and flickers with one draw. */
6691
7237
  fireLight(slot, recipe, intensity, time) {
@@ -6710,6 +7256,7 @@ var GameVfx = (() => {
6710
7256
  this.debris.update(dt);
6711
7257
  this.decals.update(dt);
6712
7258
  this.rings.update(dt);
7259
+ this.meshes.update(dt);
6713
7260
  this.lights.update(dt);
6714
7261
  updateScreen(this.screen, dt);
6715
7262
  for (let index = this.lens.length - 1; index >= 0; index--) {
@@ -6726,7 +7273,9 @@ var GameVfx = (() => {
6726
7273
  this.debris.clear();
6727
7274
  this.decals.clear();
6728
7275
  this.rings.clear();
7276
+ this.meshes.clear();
6729
7277
  this.lights.clear();
7278
+ this.rain.clear();
6730
7279
  this.accumulators.clear();
6731
7280
  resetScreenState(this.screen);
6732
7281
  this.lens.length = 0;
@@ -6876,16 +7425,16 @@ var GameVfx = (() => {
6876
7425
  },
6877
7426
  push(point, radius, speed) {
6878
7427
  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];
7428
+ for (const puff3 of core.puffs.items) {
7429
+ const dx = puff3.x - point[0];
7430
+ const dy = puff3.y - point[1];
7431
+ const dz = puff3.z - point[2];
6883
7432
  const distance = Math.sqrt(dx * dx + dy * dy + dz * dz);
6884
7433
  if (distance >= radius) continue;
6885
7434
  const strength = speed * (1 - distance / radius) / (distance + 1e-3);
6886
- puff2.vx += dx * strength;
6887
- puff2.vy += dy * strength;
6888
- puff2.vz += dz * strength;
7435
+ puff3.vx += dx * strength;
7436
+ puff3.vy += dy * strength;
7437
+ puff3.vz += dz * strength;
6889
7438
  }
6890
7439
  },
6891
7440
  stop(handle) {
@@ -6902,6 +7451,12 @@ var GameVfx = (() => {
6902
7451
  camera2.y = position[1];
6903
7452
  camera2.z = position[2];
6904
7453
  },
7454
+ setWind(next) {
7455
+ wind.x = next[0];
7456
+ wind.y = next[1];
7457
+ wind.z = next[2];
7458
+ },
7459
+ wind: () => [wind.x, wind.y, wind.z],
6905
7460
  forceLod(scale) {
6906
7461
  core.clock.forcedLod = scale;
6907
7462
  },
@@ -7253,6 +7808,27 @@ var GameVfx = (() => {
7253
7808
  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
7809
  network: "A fire entity on the server per building, with a spread state."
7255
7810
  },
7811
+ rain_and_puddles: {
7812
+ name: "Rain, splashes and puddles",
7813
+ short: "Drops with wind, splashes and rings only near the camera, lightning in the storm.",
7814
+ cost: "\u2264 4,000 drops",
7815
+ costNote: "splash up to 12 m",
7816
+ paramLabel: "Intensity",
7817
+ when: "The weather of the world. Rain raises the background noise and masks footsteps (it can be used for stealth).",
7818
+ 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.",
7819
+ 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.",
7820
+ network: "The server sends the weather and the lightning seed, so everyone sees the same flash."
7821
+ },
7822
+ fog_and_ash: {
7823
+ name: "Fog and ash",
7824
+ short: "Low layered mist, ash falling and the lamp post with its cone of light.",
7825
+ cost: "\u2264 120 sprites",
7826
+ costNote: "1 cone of light",
7827
+ when: "Before dawn, near the river and in burnt zones (ash). It cuts the sight of the zombies and of the player.",
7828
+ 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.",
7829
+ budget: "Up to 60 large mist sprites (half resolution) and 60 of ash. The lamp cone is an additive mesh, not real volumetric light.",
7830
+ network: "The weather comes from the server. The density is local, by zone."
7831
+ },
7256
7832
  scraping_sparks: {
7257
7833
  name: "Scraping sparks",
7258
7834
  short: "A bumper dragging on the asphalt: a river of bouncing sparks and a mark on the ground.",
@@ -7304,6 +7880,16 @@ var GameVfx = (() => {
7304
7880
  budget: "Texture only: a crack mask with 4 stages and a blood decal on the glass. Glass dust: 6 particles per blow.",
7305
7881
  network: "The server sends the glass health. Blood on the glass is local."
7306
7882
  },
7883
+ headlights_in_rain: {
7884
+ name: "Headlights in the rain",
7885
+ short: "A visible beam, drops lit inside the cone and the horde walking into the light.",
7886
+ cost: "\u2264 600 lit drops",
7887
+ costNote: "2 spots, no shadow",
7888
+ when: "Headlights on at night, with rain or fog.",
7889
+ 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.",
7890
+ 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.",
7891
+ network: "The state of the headlights is already replicated with the car."
7892
+ },
7307
7893
  damage_and_bite: {
7308
7894
  name: "Damage and bite",
7309
7895
  short: "A red edge on the side of the blow, blood on the lens and the pulse of the bite.",
@@ -7623,6 +8209,27 @@ var GameVfx = (() => {
7623
8209
  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
8210
  network: "Entidade de fogo no servidor por pr\xE9dio, com estado de espalhar."
7625
8211
  },
8212
+ rain_and_puddles: {
8213
+ name: "Chuva, respingos e po\xE7as",
8214
+ short: "Gotas com vento, respingos e an\xE9is s\xF3 perto da c\xE2mera, rel\xE2mpago no temporal.",
8215
+ cost: "\u2264 4.000 gotas",
8216
+ costNote: "respingo at\xE9 12 m",
8217
+ paramLabel: "Intensidade",
8218
+ when: "Clima do mundo. Chuva aumenta o ru\xEDdo de fundo e mascara passos (d\xE1 para usar na furtividade).",
8219
+ 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.",
8220
+ 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.",
8221
+ network: "O servidor manda o clima e a semente do rel\xE2mpago, para todos verem o mesmo clar\xE3o."
8222
+ },
8223
+ fog_and_ash: {
8224
+ name: "Neblina e cinzas",
8225
+ short: "N\xE9voa rasteira em camadas, cinza caindo e o poste com cone de luz.",
8226
+ cost: "\u2264 120 sprites",
8227
+ costNote: "1 cone de luz",
8228
+ when: "Madrugada, perto de rio e em zonas queimadas (cinza). Reduz a vis\xE3o dos zumbis e do jogador.",
8229
+ 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.",
8230
+ 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.",
8231
+ network: "Clima vem do servidor. Densidade \xE9 local por zona."
8232
+ },
7626
8233
  scraping_sparks: {
7627
8234
  name: "Fa\xEDscas de raspagem",
7628
8235
  short: "Para-choque arrastando no asfalto: rio de fa\xEDscas que quicam e marca no ch\xE3o.",
@@ -7674,6 +8281,16 @@ var GameVfx = (() => {
7674
8281
  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
8282
  network: "O servidor manda a vida do vidro. Sangue no vidro \xE9 local."
7676
8283
  },
8284
+ headlights_in_rain: {
8285
+ name: "Far\xF3is na chuva",
8286
+ short: "Feixe vis\xEDvel, gotas acesas dentro do cone e a horda entrando na luz.",
8287
+ cost: "\u2264 600 gotas acesas",
8288
+ costNote: "2 spots sem sombra",
8289
+ when: "Far\xF3is ligados \xE0 noite, com chuva ou neblina.",
8290
+ 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.",
8291
+ 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.",
8292
+ network: "Estado do farol j\xE1 \xE9 replicado com o carro."
8293
+ },
7677
8294
  damage_and_bite: {
7678
8295
  name: "Dano e mordida",
7679
8296
  short: "Borda vermelha do lado do golpe, sangue na lente e o pulso da mordida.",
@@ -7773,7 +8390,7 @@ var GameVfx = (() => {
7773
8390
  function mix(from, to, amount) {
7774
8391
  return [from[0] + (to[0] - from[0]) * amount, from[1] + (to[1] - from[1]) * amount, from[2] + (to[2] - from[2]) * amount];
7775
8392
  }
7776
- function rotate(local2, x, y, z, w) {
8393
+ function rotate2(local2, x, y, z, w) {
7777
8394
  const [vx2, vy2, vz2] = local2;
7778
8395
  const ix = w * vx2 + y * vz2 - z * vy2;
7779
8396
  const iy = w * vy2 + z * vx2 - x * vz2;
@@ -7831,7 +8448,7 @@ var GameVfx = (() => {
7831
8448
  /** A direction given in the camera's own axes, in world axes. */
7832
8449
  forward(local2) {
7833
8450
  const [x, y, z, w] = lookAtQuaternion(this.position, this.target);
7834
- return rotate(local2, x, y, z, w);
8451
+ return rotate2(local2, x, y, z, w);
7835
8452
  }
7836
8453
  };
7837
8454