@adatechnology/game-vfx 0.16.0 → 0.17.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -20,6 +20,17 @@ type Follow = {
20
20
  readonly z: number;
21
21
  };
22
22
  };
23
+ /**
24
+ * A burning body a fire follows (`FireOptions.follow`): its base centre (`x`, `y` the bottom, `z`), its half width and its height, all read every frame. The fire
25
+ * keeps the body's size as it burns away or falls apart: flames leave the whole of its height, not a layer at its foot, and the smoke rises off its top.
26
+ */
27
+ interface FireBody {
28
+ readonly x: number;
29
+ readonly y: number;
30
+ readonly z: number;
31
+ readonly radius: number;
32
+ readonly height: number;
33
+ }
23
34
  /** A residual fire left behind by an explosion (L798 `residual`), or started by `world.fire`. */
24
35
  interface FireSpec {
25
36
  /** Offsets from the blast point. */
@@ -268,6 +279,8 @@ interface Fire {
268
279
  y: number;
269
280
  z: number;
270
281
  r: number;
282
+ /** Height of what burns (m): the flames leave the whole of it, from `y` to `y + h`, and the smoke rises off its top. 0 is a flat fire (a pool, a patch of ground). */
283
+ h: number;
271
284
  r0: number;
272
285
  grow: number;
273
286
  life: number;
@@ -277,7 +290,7 @@ interface Fire {
277
290
  smoke: number;
278
291
  smokeAcc: number;
279
292
  fade: number;
280
- follow: Follow | null;
293
+ follow: Follow | FireBody | null;
281
294
  fx: number;
282
295
  fy: number;
283
296
  fz: number;
@@ -882,6 +895,22 @@ interface WorkshopContext {
882
895
  readonly trace: WorkshopTrace | undefined;
883
896
  /** The closed spaces the carried sprites (smoke, dust, steam) do not cross; absent: none. */
884
897
  readonly confiner?: Confiner;
898
+ /**
899
+ * The debris pieces touch what is round them (the host turned it on, `WorkshopEngine.setDebrisContacts`): they pile on the pieces at rest under them and
900
+ * do not go through `obstacles` (the player), which push them. Absent: they only bounce on the ground, as the Workshop page (its recording) does.
901
+ */
902
+ debrisContacts?: {
903
+ readonly obstacles: () => readonly DebrisObstacle[];
904
+ };
905
+ }
906
+ /** An upright body the debris pieces stop against and are pushed off by (a person standing): a vertical cylinder. */
907
+ interface DebrisObstacle {
908
+ readonly x: number;
909
+ readonly z: number;
910
+ /** Height of its foot and of its top, metres. */
911
+ readonly bottom: number;
912
+ readonly top: number;
913
+ readonly radius: number;
885
914
  }
886
915
 
887
916
  /** A unit quaternion `[x, y, z, w]`. */
@@ -929,6 +958,7 @@ declare class DebrisPool {
929
958
  count: number;
930
959
  private next;
931
960
  private readonly direction;
961
+ private readonly resting;
932
962
  constructor(context: WorkshopContext);
933
963
  spawn(options: DebrisSpawn): void;
934
964
  clear(): void;
@@ -1000,6 +1030,8 @@ declare class RainField {
1000
1030
  puddles: readonly Puddle[];
1001
1031
  /** Replaces the puddle test (a game knows its own wet spots). */
1002
1032
  puddleAt: ((x: number, z: number) => boolean) | undefined;
1033
+ /** Top (world y) of the roof or slab over (x, z), `undefined` for open sky: a streak that falls under it is gone, with no splash and no ring. Unset: nothing is roofed. */
1034
+ coverTopAt: ((x: number, z: number) => number | undefined) | undefined;
1003
1035
  constructor(engine: WorkshopEngine);
1004
1036
  /** `initRain` (W321): `count` streaks (thinned by the quality), each drawn at a random place in the box. */
1005
1037
  init(count: number, wind: number): void;
@@ -1012,6 +1044,7 @@ declare class RainField {
1012
1044
  update(dt: number, splash: boolean, camera: Vec3Tuple): void;
1013
1045
  /** `rain.visible = false; RN.on = false` (W440): the field stops; the streaks stay where they were. */
1014
1046
  clear(): void;
1047
+ private restart;
1015
1048
  private set;
1016
1049
  }
1017
1050
 
@@ -1272,6 +1305,11 @@ declare class WorkshopEngine {
1272
1305
  placement: Placement | undefined;
1273
1306
  private readonly accumulators;
1274
1307
  constructor(options: WorkshopOptions);
1308
+ /**
1309
+ * Turns on the touch of the debris pieces (a game's world; the Workshop page's recording has none): they pile on the pieces at rest under them, and the
1310
+ * upright bodies `obstacles` answers (the player, asked once a frame while a piece moves) stop them and push them. `null` turns it off.
1311
+ */
1312
+ setDebrisContacts(obstacles: (() => readonly DebrisObstacle[]) | null): void;
1275
1313
  get random(): RandomStream;
1276
1314
  get quality(): number;
1277
1315
  setQuality(level: number): void;
@@ -1800,6 +1838,8 @@ interface ExplosionOptions {
1800
1838
  interface FireOptions {
1801
1839
  readonly point: Vec3Like;
1802
1840
  readonly radius: number;
1841
+ /** Height of what burns (m, default 0): flames leave the whole of it and the smoke rises off its top. A `FireBody` to `follow` sets it every frame. */
1842
+ readonly height?: number;
1803
1843
  readonly life: number;
1804
1844
  /** Flames per second per square-ish metre (the Lab's `rate`, default 22) and smoke puffs (default .6). */
1805
1845
  readonly rate?: number;
@@ -1809,8 +1849,8 @@ interface FireOptions {
1809
1849
  readonly grow?: number;
1810
1850
  /** `0xRRGGBB` of the smoke (default soot black). */
1811
1851
  readonly smokeColor?: number;
1812
- /** Moves with a thing (a burning part): the fire sits at its position plus `offset`. */
1813
- readonly follow?: Follow;
1852
+ /** Moves with a thing (a burning part): the fire sits at its position plus `offset`; a `FireBody` also gives it its radius and height every frame. */
1853
+ readonly follow?: Follow | FireBody;
1814
1854
  readonly offset?: Vec3Like;
1815
1855
  readonly seed?: number;
1816
1856
  /** The thing that burns (a world object's id): `clearSource` puts the fire out and takes away the flames, smoke and embers it gave off. */
@@ -2462,4 +2502,4 @@ declare function resolveWaterShotProfile(profile: string | WaterShotProfile, tab
2462
2502
  /** Changes a profile table without touching the kit's: `null` removes an entry, a partial entry is merged over the old one. */
2463
2503
  declare function patchWaterShotProfiles(base: Readonly<Record<string, WaterShotProfile>>, changes: Readonly<Record<string, Partial<WaterShotProfile> | null>>): Record<string, WaterShotProfile>;
2464
2504
 
2465
- export { AREA_CAP_GAME, type AreaCap, type AreaCapTracker, type Behavior, type BehaviorHost, type BlastLight, type BloodMark, type Carrier, type Chunk, type ConfineMove, type ConfineResult, type Confiner, type CueRequest, DEBRIS_COLOR_VARIABLE, DEBRIS_EFFECT_FAMILIES, DUST_COLOR_VARIABLE, type DebrisEffectFamily, type DebrisSpawn, type Decal, type DecalOptions, type DirtMark, EVENT_BUDGET, EVENT_EFFECTS, EVENT_EFFECTS_MAP, EXPLOSIONS, EXPLOSION_ALIASES, EffectCamera, type EffectDef, EffectInstance, type EffectPlayer, type EffectPlayerOptions, EffectRunner, type EffectRunnerOptions, type EffectStep, type EffectTexts, type EffectTrack, type EffectView, Enclosures, type ExplosionCall, type ExplosionDef, type ExplosionOptions, type Fire, type FireLight, type FireOptions, type FireSpec, type Follow, GAME_EFFECTS, type GameEvent, type Glow, type GroundField, type GroundFieldOptions, type InstanceDeps, type InstanceSetup, type KindPoolHost, LOD_GAME, LOD_LAB, type LandListener, type LensBlob, type LightGlow, type LightPool, type LodBands, MATERIAL_EVENT_EFFECTS, type Mark, type MarkEvent, type MarkStore, type MeshParticle, MeshPool, type MeshShape, type MeshSpawn, type MushroomSpec, type MutableVec3, OrderedPool, PIECES_DRAWN_VARIABLE, PROFILES, type Placement, type PlayOptions, type PostProcess, type Puddle, type Puff, type Quaternion, RAIN_CAPACITY, RainField, type RandomStream, type Rgb, type Ring, type RockMark, SCRAPE_LIMIT, SMOKE_COLORS, SPRITE_KINDS, type Schedule, type ScorchMark, type ScrapeMark, type ScreenState, type SheetLabels, type Shock, type Spark, type SpriteGround, type SpriteKind, type SpriteKindDef, SpriteKindPool, SpriteKindSystem, type SpriteKindSystemOptions, type SpriteSpawn, type SpriteSpawnOptions, type SpriteSystem, VFX_LAYERS, VIEWMODEL_EFFECTS, type Vec3Like, type Vec3Tuple, type VfxEnclosure, type VfxEnclosureBox, type VfxLayer, type VfxLocale, type VfxOptions, type VfxPoolsView, type VfxProfile, type VfxProfileName, type VfxSideRequest, type VfxStats, type VfxStrings, type VfxTrace, type VfxWorld, WATER_BLASTS, WATER_BLAST_KINDS, WATER_LIMITS, WATER_SHOT_BY_CALIBER, WATER_SHOT_PROFILES, WORKSHOP_BEHAVIORS, WORKSHOP_EFFECTS, WORKSHOP_PUDDLES, type WaterBlastCharge, type WaterBlastKind, type WaterBlastKindId, type WaterBlastParams, type WaterBlastPlan, type WaterBubble, type WaterColumn, type WaterDrop, type WaterEffects, type WaterEffectsLimits, type WaterEffectsOptions, type WaterEffectsStats, type WaterFoam, type WaterMist, type WaterRing, type WaterRound, type WaterShotClass, type WaterShotParams, type WaterShotPlan, type WaterShotProfile, type WaterVec3, type WaterWave, type WaterWaveSample, type WorkshopContext, WorkshopEngine, type WorkshopOptions, type WorkshopTrace, colorOfChunk, composeExplosion, createAreaCap, createEffectPlayer, createGroundField, createSchedule, createScreenState, createVfx, createWaterEffects, createWorkshopBehaviors, effectForEvent, estimateCost, explosionEffectIds, hexToLinearRgb, hexToRgb, inPuddle, lcg, lehmer, locales, lodScale, patchEffects, patchExplosions, patchSpriteKinds, patchWaterShotProfiles, planWaterBlast, planWaterShot, resolveStrings, resolveWaterBlast, resolveWaterShotProfile, slideAlong, slideInto, streamFor, updateScreen, waterShotClassOf, workshopGround };
2505
+ export { AREA_CAP_GAME, type AreaCap, type AreaCapTracker, type Behavior, type BehaviorHost, type BlastLight, type BloodMark, type Carrier, type Chunk, type ConfineMove, type ConfineResult, type Confiner, type CueRequest, DEBRIS_COLOR_VARIABLE, DEBRIS_EFFECT_FAMILIES, DUST_COLOR_VARIABLE, type DebrisEffectFamily, type DebrisObstacle, type DebrisSpawn, type Decal, type DecalOptions, type DirtMark, EVENT_BUDGET, EVENT_EFFECTS, EVENT_EFFECTS_MAP, EXPLOSIONS, EXPLOSION_ALIASES, EffectCamera, type EffectDef, EffectInstance, type EffectPlayer, type EffectPlayerOptions, EffectRunner, type EffectRunnerOptions, type EffectStep, type EffectTexts, type EffectTrack, type EffectView, Enclosures, type ExplosionCall, type ExplosionDef, type ExplosionOptions, type Fire, type FireBody, type FireLight, type FireOptions, type FireSpec, type Follow, GAME_EFFECTS, type GameEvent, type Glow, type GroundField, type GroundFieldOptions, type InstanceDeps, type InstanceSetup, type KindPoolHost, LOD_GAME, LOD_LAB, type LandListener, type LensBlob, type LightGlow, type LightPool, type LodBands, MATERIAL_EVENT_EFFECTS, type Mark, type MarkEvent, type MarkStore, type MeshParticle, MeshPool, type MeshShape, type MeshSpawn, type MushroomSpec, type MutableVec3, OrderedPool, PIECES_DRAWN_VARIABLE, PROFILES, type Placement, type PlayOptions, type PostProcess, type Puddle, type Puff, type Quaternion, RAIN_CAPACITY, RainField, type RandomStream, type Rgb, type Ring, type RockMark, SCRAPE_LIMIT, SMOKE_COLORS, SPRITE_KINDS, type Schedule, type ScorchMark, type ScrapeMark, type ScreenState, type SheetLabels, type Shock, type Spark, type SpriteGround, type SpriteKind, type SpriteKindDef, SpriteKindPool, SpriteKindSystem, type SpriteKindSystemOptions, type SpriteSpawn, type SpriteSpawnOptions, type SpriteSystem, VFX_LAYERS, VIEWMODEL_EFFECTS, type Vec3Like, type Vec3Tuple, type VfxEnclosure, type VfxEnclosureBox, type VfxLayer, type VfxLocale, type VfxOptions, type VfxPoolsView, type VfxProfile, type VfxProfileName, type VfxSideRequest, type VfxStats, type VfxStrings, type VfxTrace, type VfxWorld, WATER_BLASTS, WATER_BLAST_KINDS, WATER_LIMITS, WATER_SHOT_BY_CALIBER, WATER_SHOT_PROFILES, WORKSHOP_BEHAVIORS, WORKSHOP_EFFECTS, WORKSHOP_PUDDLES, type WaterBlastCharge, type WaterBlastKind, type WaterBlastKindId, type WaterBlastParams, type WaterBlastPlan, type WaterBubble, type WaterColumn, type WaterDrop, type WaterEffects, type WaterEffectsLimits, type WaterEffectsOptions, type WaterEffectsStats, type WaterFoam, type WaterMist, type WaterRing, type WaterRound, type WaterShotClass, type WaterShotParams, type WaterShotPlan, type WaterShotProfile, type WaterVec3, type WaterWave, type WaterWaveSample, type WorkshopContext, WorkshopEngine, type WorkshopOptions, type WorkshopTrace, colorOfChunk, composeExplosion, createAreaCap, createEffectPlayer, createGroundField, createSchedule, createScreenState, createVfx, createWaterEffects, createWorkshopBehaviors, effectForEvent, estimateCost, explosionEffectIds, hexToLinearRgb, hexToRgb, inPuddle, lcg, lehmer, locales, lodScale, patchEffects, patchExplosions, patchSpriteKinds, patchWaterShotProfiles, planWaterBlast, planWaterShot, resolveStrings, resolveWaterBlast, resolveWaterShotProfile, slideAlong, slideInto, streamFor, updateScreen, waterShotClassOf, workshopGround };
@@ -1927,6 +1927,7 @@ var GameVfx = (() => {
1927
1927
  y: 0,
1928
1928
  z: 0,
1929
1929
  r: 0.6,
1930
+ h: 0,
1930
1931
  r0: 0.6,
1931
1932
  grow: 0,
1932
1933
  life: 6,
@@ -1952,6 +1953,7 @@ var GameVfx = (() => {
1952
1953
  fire.y = init.y ?? 0;
1953
1954
  fire.z = init.z ?? 0;
1954
1955
  fire.r = init.r ?? 0.6;
1956
+ fire.h = init.h ?? 0;
1955
1957
  fire.r0 = init.startRadius ?? fire.r;
1956
1958
  fire.grow = init.grow ?? 0;
1957
1959
  fire.life = init.life ?? 6;
@@ -1976,19 +1978,23 @@ var GameVfx = (() => {
1976
1978
  core.trace?.fire?.(fire);
1977
1979
  return fire;
1978
1980
  }
1981
+ var FLAMES_PER_HEIGHT = 1.5;
1982
+ var SMOKE_PER_HEIGHT = 2;
1979
1983
  function positionOf(follow) {
1980
1984
  return "position" in follow ? follow.position : follow;
1981
1985
  }
1986
+ var heightOf = (fire) => fire.h > 0 ? fire.rng.next() * fire.h : 0;
1987
+ var isBody = (follow) => "radius" in follow && "height" in follow;
1982
1988
  function emitFlames(core, fire, radius, dt) {
1983
1989
  const random = fire.rng;
1984
- fire.acc += dt * fire.rate * (0.5 + radius * 0.9) * fire.fade * core.clock.lod;
1990
+ fire.acc += dt * fire.rate * (0.5 + radius * 0.9) * (1 + fire.h * FLAMES_PER_HEIGHT) * fire.fade * core.clock.lod;
1985
1991
  while (fire.acc >= 1) {
1986
1992
  fire.acc -= 1;
1987
1993
  const angle = random.next() * Math.PI * 2;
1988
1994
  const distance = Math.sqrt(random.next()) * radius;
1989
1995
  addPuff(core, random, {
1990
1996
  x: fire.x + Math.cos(angle) * distance,
1991
- y: fire.y + 0.05,
1997
+ y: fire.y + 0.05 + heightOf(fire),
1992
1998
  z: fire.z + Math.sin(angle) * distance,
1993
1999
  vx: random.between(-0.2, 0.2),
1994
2000
  vy: random.between(0.6, 1.4),
@@ -2010,12 +2016,12 @@ var GameVfx = (() => {
2010
2016
  }
2011
2017
  function emitSmoke(core, fire, radius, dt) {
2012
2018
  const random = fire.rng;
2013
- fire.smokeAcc += dt * fire.smoke * (1 + radius * 0.8) * fire.fade * core.clock.lod;
2019
+ fire.smokeAcc += dt * fire.smoke * (1 + radius * 0.8) * (1 + fire.h * SMOKE_PER_HEIGHT) * fire.fade * core.clock.lod;
2014
2020
  while (fire.smokeAcc >= 1 && core.layers.smoke) {
2015
2021
  fire.smokeAcc -= 1;
2016
2022
  addPuff(core, random, {
2017
2023
  x: fire.x + random.between(-radius, radius) * 0.5,
2018
- y: fire.y + 0.6 + radius * 0.3,
2024
+ y: fire.y + fire.h + 0.6 + radius * 0.3,
2019
2025
  z: fire.z + random.between(-radius, radius) * 0.5,
2020
2026
  vy: random.between(0.8, 1.5),
2021
2027
  s0: 0.25,
@@ -2037,7 +2043,7 @@ var GameVfx = (() => {
2037
2043
  if (!(random.next() < dt * 6 * fire.fade && core.layers.shrapnel)) return;
2038
2044
  addSpark(core, {
2039
2045
  x: fire.x + random.between(-radius, radius) * 0.6,
2040
- y: fire.y + 0.4,
2046
+ y: fire.y + 0.4 + heightOf(fire),
2041
2047
  z: fire.z + random.between(-radius, radius) * 0.6,
2042
2048
  vx: random.between(-0.4, 0.4),
2043
2049
  vy: random.between(1.5, 3.2),
@@ -2061,6 +2067,10 @@ var GameVfx = (() => {
2061
2067
  fire.x = point.x + fire.fx;
2062
2068
  fire.y = point.y + fire.fy;
2063
2069
  fire.z = point.z + fire.fz;
2070
+ if (isBody(fire.follow)) {
2071
+ fire.r = fire.follow.radius;
2072
+ fire.h = fire.follow.height;
2073
+ }
2064
2074
  }
2065
2075
  const radius = fire.grow ? lerp(fire.r0, fire.r, Math.min(1, fire.t / fire.grow)) : fire.r;
2066
2076
  fire.fade = fire.t < fire.life - 1.5 ? Math.min(1, fire.t * 3) : Math.max(0, (fire.life - fire.t) / 1.5);
@@ -2135,6 +2145,7 @@ var GameVfx = (() => {
2135
2145
  var QUALITY = { $: "quality" };
2136
2146
  var FRESH = { $: "fresh" };
2137
2147
  var DIRECTION = { $: "direction" };
2148
+ var NORMAL = { $: "normal" };
2138
2149
  var CAMERA_POSITION = { $: "cameraPosition" };
2139
2150
 
2140
2151
  // src/effects/steps.ts
@@ -2690,7 +2701,7 @@ var GameVfx = (() => {
2690
2701
  var TIP2 = [-0.8, 1.38, 3.4 - 0.78];
2691
2702
  var PORT2 = [-0.76, 1.4, 3.32];
2692
2703
  var FORWARD3 = [0, 0, -1];
2693
- var NORMAL = [0, 0, 1];
2704
+ var NORMAL2 = [0, 0, 1];
2694
2705
  var WALL_Z2 = -4.45;
2695
2706
  var SHOTS = [[0, 0.45, 0.9], [0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6], [0], [0]];
2696
2707
  var SHOT_TIME = pick(pick(SHOTS, PARAM), INDEX);
@@ -2715,8 +2726,8 @@ var GameVfx = (() => {
2715
2726
  set("target", [add(-0.8, rnd(-0.4, 0.4)), add(1.4, rnd(-0.3, 0.3)), WALL_Z2]),
2716
2727
  when(
2717
2728
  eq(PARAM, SHOTGUN),
2718
- [repeat(8, call2("impact", "concrete", [add(-0.8, rnd(-0.5, 0.5)), add(1.4, rnd(-0.4, 0.4)), WALL_Z2], NORMAL, 0.35))],
2719
- [call2("impact", "concrete", variable("target"), NORMAL, ite(eq(PARAM, BARRETT), 2, 1))]
2729
+ [repeat(8, call2("impact", "concrete", [add(-0.8, rnd(-0.5, 0.5)), add(1.4, rnd(-0.4, 0.4)), WALL_Z2], NORMAL2, 0.35))],
2730
+ [call2("impact", "concrete", variable("target"), NORMAL2, ite(eq(PARAM, BARRETT), 2, 1))]
2720
2731
  ),
2721
2732
  when(and(eq(PARAM, AK), eq(mod(round(mul(SHOT_TIME, 10)), 3), 0)), [spawn("streak", { p: TIP2, dir: FORWARD3, cone: 0, sp: 90, life: 0.09, len: 0.025, c0: 16752704, a: 1 })])
2722
2733
  )
@@ -3274,6 +3285,8 @@ var GameVfx = (() => {
3274
3285
  __publicField(this, "puddles", WORKSHOP_PUDDLES);
3275
3286
  /** Replaces the puddle test (a game knows its own wet spots). */
3276
3287
  __publicField(this, "puddleAt");
3288
+ /** Top (world y) of the roof or slab over (x, z), `undefined` for open sky: a streak that falls under it is gone, with no splash and no ring. Unset: nothing is roofed. */
3289
+ __publicField(this, "coverTopAt");
3277
3290
  }
3278
3291
  /** `initRain` (W321): `count` streaks (thinned by the quality), each drawn at a random place in the box. */
3279
3292
  init(count, wind) {
@@ -3319,6 +3332,13 @@ var GameVfx = (() => {
3319
3332
  positions[o + 3] += slant;
3320
3333
  positions[o + 1] -= fall;
3321
3334
  positions[o + 4] -= fall;
3335
+ if (this.coverTopAt) {
3336
+ const top = this.coverTopAt(positions[o], positions[o + 2]);
3337
+ if (top !== void 0 && positions[o + 4] < top) {
3338
+ this.restart(o);
3339
+ continue;
3340
+ }
3341
+ }
3322
3342
  const ground = context.groundAt(positions[o], positions[o + 2]);
3323
3343
  if (positions[o + 4] < ground) {
3324
3344
  const x = positions[o];
@@ -3334,10 +3354,7 @@ var GameVfx = (() => {
3334
3354
  }
3335
3355
  }
3336
3356
  }
3337
- const nx = random.between(BOX_X[0], BOX_X[1]) + this.centerX;
3338
- const ny = random.between(REENTRY_HEIGHT[0], REENTRY_HEIGHT[1]);
3339
- const nz = random.between(BOX_Z[0], BOX_Z[1]) + this.centerZ;
3340
- this.set(o, nx, ny, nz);
3357
+ this.restart(o);
3341
3358
  }
3342
3359
  }
3343
3360
  }
@@ -3345,6 +3362,13 @@ var GameVfx = (() => {
3345
3362
  clear() {
3346
3363
  this.on = false;
3347
3364
  }
3365
+ restart(offset) {
3366
+ const { random } = this.engine;
3367
+ const nx = random.between(BOX_X[0], BOX_X[1]) + this.centerX;
3368
+ const ny = random.between(REENTRY_HEIGHT[0], REENTRY_HEIGHT[1]);
3369
+ const nz = random.between(BOX_Z[0], BOX_Z[1]) + this.centerZ;
3370
+ this.set(offset, nx, ny, nz);
3371
+ }
3348
3372
  set(offset, x, y, z) {
3349
3373
  const positions = this.positions;
3350
3374
  positions[offset] = x;
@@ -3954,7 +3978,6 @@ var GameVfx = (() => {
3954
3978
  ];
3955
3979
 
3956
3980
  // src/effects/events.ts
3957
- var FACING5 = [0, 0, 1];
3958
3981
  var ORIGIN2 = [0, 0, 0];
3959
3982
  var FORWARD4 = [0, 0, -1];
3960
3983
  var IMPACT_MATERIALS = ["concrete", "metal", "wood", "glass", "flesh", "water"];
@@ -3964,7 +3987,7 @@ var GameVfx = (() => {
3964
3987
  team: "weapons",
3965
3988
  budget: { particles: 40, decals: 1 },
3966
3989
  loop: 2,
3967
- timeline: [call2("impact", material, ORIGIN2, FACING5, 1, 0)]
3990
+ timeline: [call2("impact", material, ORIGIN2, NORMAL, 1, 0)]
3968
3991
  });
3969
3992
  var muzzleEffect = (weapon) => ({
3970
3993
  id: `muzzle_${weapon}`,
@@ -4170,13 +4193,25 @@ var GameVfx = (() => {
4170
4193
 
4171
4194
  // src/effects/vehicles/game-effects.ts
4172
4195
  var aliasOf = (base, id, changes) => ({ ...base, id, pageId: `vehicle:${id}`, anchor: CAR_ORIGIN2, ...changes });
4196
+ var BODYWORK_IMPACT = {
4197
+ id: "impact_bodywork",
4198
+ pageId: "vehicle:impact_bodywork",
4199
+ team: "vehicles",
4200
+ budget: { particles: 80, debris: 20, lights: 1 },
4201
+ loop: 2,
4202
+ timeline: [call2("bodywork_impact", [0, 0, 0], NORMAL, [variable("dx"), variable("dy"), variable("dz")], variable("bore"), variable("paint"), variable("metal"))]
4203
+ };
4173
4204
  var VEHICLE_EFFECTS = [
4205
+ BODYWORK_IMPACT,
4174
4206
  /** The engine on fire: `engine_smoke` at its worst condition (black smoke, flames in the hood, a light). */
4175
4207
  aliasOf(ENGINE_SMOKE, "vehicle_fire", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 3 }, loop: 12 }),
4176
4208
  /** The exhaust of a car under way: `engine_smoke` in the best condition, for half a second so a moving car asks again. */
4177
4209
  aliasOf(ENGINE_SMOKE, "vehicle_exhaust", { params: { id: "condition", options: ["100", "60", "30", "10"], default: 0 }, loop: 0.5 }),
4178
- /** A hole in the tank: the page's petrol leak without the fire and the blast (the pool and the drips). A normal bullet does only this. */
4179
- aliasOf(FUEL_LEAK_ONLY, "vehicle_leak", {}),
4210
+ /**
4211
+ * A hole in a tank: the page's drips, falling from the point it is played at (the hole). No pool of its own: the pool is the liquid that came out, laid by the
4212
+ * host's fluid world as it leaks (it grows with the volume and spreads by the liquid's own kind), not a drawing of a size the page chose.
4213
+ */
4214
+ aliasOf(FUEL_LEAK_ONLY, "vehicle_leak", { anchor: TANK, timeline: [] }),
4180
4215
  /** The leak caught fire (an incendiary or tracer round, a spark, a fire near): the page's whole sequence, the fire running along the pool to the tank and the blast. */
4181
4216
  aliasOf(FUEL_LEAK, "vehicle_leak_ignited", {})
4182
4217
  ];
@@ -4914,6 +4949,48 @@ var GameVfx = (() => {
4914
4949
  }
4915
4950
  }
4916
4951
 
4952
+ // src/effects/builders/bodywork.ts
4953
+ var PISTOL_BORE = 9e-3;
4954
+ var BARE_STEEL = 11778236;
4955
+ var DEFAULT_PAINT = 9147290;
4956
+ var DEFAULT_DIRECTION = [0, 0, -1];
4957
+ var MAX_SCALE = 3;
4958
+ var MIN_SCALE = 0.6;
4959
+ function reflected(direction, normal) {
4960
+ const along = direction[0] * normal[0] + direction[1] * normal[1] + direction[2] * normal[2];
4961
+ const out = [direction[0] - 2 * along * normal[0], direction[1] - 2 * along * normal[1], direction[2] - 2 * along * normal[2]];
4962
+ const length = Math.hypot(out[0], out[1], out[2]);
4963
+ if (length < 1e-6 || Math.abs(along) > 0.98) return normal;
4964
+ return [out[0] / length, out[1] / length, out[2] / length];
4965
+ }
4966
+ var numberOr = (value, fallback2) => typeof value === "number" && Number.isFinite(value) ? value : fallback2;
4967
+ function bodyworkHitOf(values) {
4968
+ const raw = Array.isArray(values.direction) ? values.direction : [];
4969
+ const direction = raw.length === 3 && raw.every((entry) => typeof entry === "number" && Number.isFinite(entry)) ? [raw[0], raw[1], raw[2]] : DEFAULT_DIRECTION;
4970
+ return { direction, bore: numberOr(values.bore, PISTOL_BORE), paint: numberOr(values.paint, DEFAULT_PAINT), metal: numberOr(values.metal, BARE_STEEL) };
4971
+ }
4972
+ function bodyworkScale(bore) {
4973
+ return Math.min(MAX_SCALE, Math.max(MIN_SCALE, bore / PISTOL_BORE));
4974
+ }
4975
+ function bodyworkImpact(engine, point, normal, hit) {
4976
+ const scale = bodyworkScale(hit.bore);
4977
+ const off = reflected(hit.direction, normal);
4978
+ if (engine.quality < 2) {
4979
+ engine.burst("streak", Math.round(14 * scale), { p: point, dir: off, cone: 0.75, sp: [4, 12], life: [0.08, 0.3], len: 0.03, c0: 16774352, c1: 16738840, g: 9.8, gnd: 2 });
4980
+ engine.burst("add", 2, { p: plusScaled(point, normal, 0.01), size: [0.06 * scale, 0.12 * scale], life: 0.05, c0: 16770736, fi: 0 });
4981
+ engine.flash([plusScaled(point, normal, 0.15), 16760432, 1.6 * scale, 0.05, 4]);
4982
+ }
4983
+ const flakes = engine.scaled(Math.round(5 * scale));
4984
+ for (let index = 0; index < flakes; index++) {
4985
+ engine.debrisPiece({ p: point, dir: normal, cone: 0.9, sp: [1.2, 3.5], size: [8e-3 * scale, 12e-4, 6e-3 * scale], k: [0.5, 1.4], c: hit.paint, life: 6, bounce: 0.2 });
4986
+ }
4987
+ const slivers = engine.scaled(Math.round(2 * scale));
4988
+ for (let index = 0; index < slivers; index++) {
4989
+ engine.debrisPiece({ p: point, dir: off, cone: 0.6, sp: [2.5, 6], size: [25e-4, 15e-4, 0.01 * scale], k: [0.6, 1.3], c: hit.metal, life: 6, bounce: 0.35 });
4990
+ }
4991
+ engine.burst("normal", Math.round(6 * scale), { p: point, dir: normal, cone: 0.7, sp: [0.4, 1.4], drag: 2.5, life: [0.4, 0.9], size: [0.03, 0.07], grow: 3, c0: hit.paint, a: 0.45, g: -0.05 });
4992
+ }
4993
+
4917
4994
  // src/effects/builders/fire.ts
4918
4995
  var UP12 = [0, 1, 0];
4919
4996
  var ZERO = [0, 0, 0];
@@ -5068,11 +5145,12 @@ var GameVfx = (() => {
5068
5145
  casing: ({ engine }, [port, type]) => casing(engine, port, type),
5069
5146
  chips: ({ engine }, [point, direction, count, spread]) => chips(engine, point, direction, count, spread),
5070
5147
  spark_at: ({ engine }, [point, direction, count, spread]) => sparkAt(engine, point, direction, count, spread),
5071
- rust_at: ({ engine }, [point, count]) => rustAt(engine, point, count)
5148
+ rust_at: ({ engine }, [point, count]) => rustAt(engine, point, count),
5149
+ bodywork_impact: ({ engine }, [point, normal, direction, bore, paint, metal]) => bodyworkImpact(engine, point, normal, bodyworkHitOf({ direction, bore, paint, metal }))
5072
5150
  };
5073
5151
 
5074
5152
  // src/effects/instance.ts
5075
- var DEFAULT_DIRECTION = [0, 0, -1];
5153
+ var DEFAULT_DIRECTION2 = [0, 0, -1];
5076
5154
  var DEFAULT_NORMAL = [0, 1, 0];
5077
5155
  var SCREEN_FIELDS = {
5078
5156
  shake: "shake",
@@ -5141,7 +5219,7 @@ var GameVfx = (() => {
5141
5219
  return instance().fresh;
5142
5220
  },
5143
5221
  get direction() {
5144
- return instance().setup.direction ?? DEFAULT_DIRECTION;
5222
+ return instance().setup.direction ?? DEFAULT_DIRECTION2;
5145
5223
  },
5146
5224
  get normal() {
5147
5225
  return instance().setup.normal ?? DEFAULT_NORMAL;
@@ -6938,6 +7016,71 @@ var GameVfx = (() => {
6938
7016
  return out;
6939
7017
  }
6940
7018
 
7019
+ // src/workshop/debris-contact.ts
7020
+ var CELL = 0.12;
7021
+ var OBSTACLE_BOUNCE = 0.3;
7022
+ var radiusOf = (piece) => Math.max(piece.sx, piece.sz) * 0.5;
7023
+ var thicknessOf = (piece) => Math.min(piece.sx, piece.sy, piece.sz);
7024
+ var cellKey = (i, k) => (i + 4096) * 8192 + (k + 4096);
7025
+ var RestingGrid = class {
7026
+ constructor() {
7027
+ __publicField(this, "cells", /* @__PURE__ */ new Map());
7028
+ }
7029
+ clear() {
7030
+ for (const list of this.cells.values()) list.length = 0;
7031
+ }
7032
+ rebuild(pieces) {
7033
+ this.clear();
7034
+ for (const piece of pieces) {
7035
+ if (!piece.on || !piece.rest) continue;
7036
+ const key = cellKey(Math.floor(piece.x / CELL), Math.floor(piece.z / CELL));
7037
+ const list = this.cells.get(key);
7038
+ if (list) list.push(piece);
7039
+ else this.cells.set(key, [piece]);
7040
+ }
7041
+ }
7042
+ /** The height a piece at `piece`'s place lands at on the pieces under it (the top of the highest one it overlaps), or `-Infinity` over none. */
7043
+ supportUnder(piece) {
7044
+ const i = Math.floor(piece.x / CELL);
7045
+ const k = Math.floor(piece.z / CELL);
7046
+ const reach = radiusOf(piece);
7047
+ let top = -Infinity;
7048
+ for (let di = -1; di <= 1; di++) {
7049
+ for (let dk = -1; dk <= 1; dk++) {
7050
+ for (const other of this.cells.get(cellKey(i + di, k + dk)) ?? []) {
7051
+ if (other === piece) continue;
7052
+ if (Math.hypot(other.x - piece.x, other.z - piece.z) > reach + radiusOf(other)) continue;
7053
+ const otherTop = other.y + thicknessOf(other) * 0.5;
7054
+ if (otherTop <= piece.y + thicknessOf(piece) * 0.5) top = Math.max(top, otherTop + thicknessOf(piece) * 0.5);
7055
+ }
7056
+ }
7057
+ }
7058
+ return top;
7059
+ }
7060
+ };
7061
+ function pushOutOfObstacles(piece, obstacles) {
7062
+ let moved = false;
7063
+ for (const body of obstacles) {
7064
+ if (piece.y < body.bottom || piece.y > body.top) continue;
7065
+ const dx = piece.x - body.x;
7066
+ const dz = piece.z - body.z;
7067
+ const distance = Math.hypot(dx, dz);
7068
+ const reach = body.radius + radiusOf(piece);
7069
+ if (distance >= reach) continue;
7070
+ const nx = distance > 1e-6 ? dx / distance : 1;
7071
+ const nz = distance > 1e-6 ? dz / distance : 0;
7072
+ piece.x = body.x + nx * reach;
7073
+ piece.z = body.z + nz * reach;
7074
+ const into = piece.vx * nx + piece.vz * nz;
7075
+ if (into < 0) {
7076
+ piece.vx -= (1 + OBSTACLE_BOUNCE) * into * nx;
7077
+ piece.vz -= (1 + OBSTACLE_BOUNCE) * into * nz;
7078
+ }
7079
+ moved = true;
7080
+ }
7081
+ return moved;
7082
+ }
7083
+
6941
7084
  // src/workshop/debris.ts
6942
7085
  var CAPACITY = 500;
6943
7086
  var GRAVITY2 = 9.8;
@@ -6959,6 +7102,7 @@ var GameVfx = (() => {
6959
7102
  __publicField(this, "count", 0);
6960
7103
  __publicField(this, "next", 0);
6961
7104
  __publicField(this, "direction", { x: 0, y: 0, z: 0 });
7105
+ __publicField(this, "resting", new RestingGrid());
6962
7106
  }
6963
7107
  spawn(options) {
6964
7108
  const random = this.context.random;
@@ -6996,14 +7140,21 @@ var GameVfx = (() => {
6996
7140
  }
6997
7141
  update(dt) {
6998
7142
  this.count = 0;
7143
+ const contacts = this.context.debrisContacts;
7144
+ const obstacles = contacts?.obstacles() ?? [];
7145
+ let moving = false;
6999
7146
  for (const piece of this.pieces) {
7000
7147
  if (!piece.on) continue;
7001
- this.count++;
7002
7148
  piece.life -= dt;
7003
- if (piece.life <= 0) {
7004
- piece.on = false;
7005
- continue;
7006
- }
7149
+ if (piece.life <= 0) piece.on = false;
7150
+ else if (!piece.rest) moving = true;
7151
+ }
7152
+ if (moving && contacts) this.resting.rebuild(this.pieces);
7153
+ else this.resting.clear();
7154
+ for (const piece of this.pieces) {
7155
+ if (!piece.on) continue;
7156
+ this.count++;
7157
+ if (obstacles.length > 0 && pushOutOfObstacles(piece, obstacles)) piece.rest = false;
7007
7158
  if (!piece.rest) this.move(piece, dt);
7008
7159
  }
7009
7160
  }
@@ -7019,7 +7170,7 @@ var GameVfx = (() => {
7019
7170
  piece.rx += piece.ax * dt;
7020
7171
  piece.ry += piece.ay * dt;
7021
7172
  piece.rz += piece.az * dt;
7022
- const groundHeight = this.context.groundAt(piece.x, piece.z) + Math.min(piece.sx, piece.sy, piece.sz) * 0.5;
7173
+ const groundHeight = Math.max(this.context.groundAt(piece.x, piece.z) + Math.min(piece.sx, piece.sy, piece.sz) * 0.5, this.resting.supportUnder(piece));
7023
7174
  if (piece.y >= groundHeight) return;
7024
7175
  piece.y = groundHeight;
7025
7176
  piece.vy *= -piece.bounce;
@@ -7657,7 +7808,6 @@ var GameVfx = (() => {
7657
7808
  var FIRE_FLICKER_SWAY = 0.25;
7658
7809
  var FIRE_FLICKER_JITTER = 0.08;
7659
7810
  var LENS_FADE = 0.16;
7660
- var FLOOR_NORMAL_Y = 0.9;
7661
7811
  function rotate2(q, v) {
7662
7812
  const [qx, qy, qz, qw] = q;
7663
7813
  const ix = qw * v[0] + qy * v[2] - qz * v[1];
@@ -7696,6 +7846,14 @@ var GameVfx = (() => {
7696
7846
  this.decals = new DecalPool(this.context);
7697
7847
  this.lights = new FlashLightPool(this.context);
7698
7848
  }
7849
+ /**
7850
+ * Turns on the touch of the debris pieces (a game's world; the Workshop page's recording has none): they pile on the pieces at rest under them, and the
7851
+ * upright bodies `obstacles` answers (the player, asked once a frame while a piece moves) stop them and push them. `null` turns it off.
7852
+ */
7853
+ setDebrisContacts(obstacles) {
7854
+ if (obstacles) this.context.debrisContacts = { obstacles };
7855
+ else delete this.context.debrisContacts;
7856
+ }
7699
7857
  get random() {
7700
7858
  return this.context.random;
7701
7859
  }
@@ -7787,7 +7945,7 @@ var GameVfx = (() => {
7787
7945
  const [x, y, z] = this.place([recipe[0], recipe[1], recipe[2]]);
7788
7946
  const options = recipe[5];
7789
7947
  const normal = options?.n ? this.turn(options.n) : void 0;
7790
- const onFloor = !normal || normal[1] > FLOOR_NORMAL_Y;
7948
+ const onFloor = !normal;
7791
7949
  args = [x, onFloor ? this.context.groundAt(x, z) : y, z, recipe[3], recipe[4], normal ? { ...options, n: normal } : options];
7792
7950
  }
7793
7951
  this.context.trace?.("decal", args);
@@ -8016,10 +8174,11 @@ var GameVfx = (() => {
8016
8174
  },
8017
8175
  fire(fireOptions) {
8018
8176
  const handle = ++handles.next;
8019
- const { point, offset, seed, radius, smokeColor, ...rest } = fireOptions;
8177
+ const { point, offset, seed, radius, height, smokeColor, ...rest } = fireOptions;
8020
8178
  addFire(core, streamOf(seed), {
8021
8179
  ...rest,
8022
8180
  r: radius,
8181
+ ...height !== void 0 ? { h: height } : {},
8023
8182
  x: point[0],
8024
8183
  y: point[1],
8025
8184
  z: point[2],