@adatechnology/game-vehicles 0.6.18 → 0.6.19

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
@@ -891,6 +891,11 @@ type SpawnOptions = {
891
891
  mat?: Material;
892
892
  r?: number;
893
893
  floor?: number;
894
+ /** End size as a multiple of the start size, over the life (the plume law); without it the puff follows the kit's own growth. */
895
+ growth?: number;
896
+ /** Upward pull (m/s²) and drag (1/s) of a routed puff; without them the effects world's defaults for smoke. */
897
+ lift?: number;
898
+ drag?: number;
894
899
  };
895
900
  /** A burst of particles: the spawn options plus a main direction, speed, spread and how far from the point they start. */
896
901
  type BurstOptions = SpawnOptions & {
@@ -1617,6 +1622,8 @@ interface VehicleEmitter {
1617
1622
  s: number;
1618
1623
  dir: Vector3 | null;
1619
1624
  gap: number;
1625
+ /** How wrecked the source is (0 intact, 1 wrecked): smoke thickens with it (`smokeRate` of `engine-smoke.ts`). */
1626
+ damage?: () => number;
1620
1627
  }
1621
1628
  /** A lamp the kit drew (`c.lights`): its group, the lens and the inner meshes (bulb, reflector), its tint and what happened to it. */
1622
1629
  interface VehicleLamp {
@@ -2028,6 +2035,66 @@ declare function legacyGlassId(key: string | null, label: string, side: number,
2028
2035
  /** Original id of a light zone: `farol_e`, `lanterna_c`, `farol_d_2`... */
2029
2036
  declare function legacyLightId(kind: string, side: string, index: number): string;
2030
2037
 
2038
+ /**
2039
+ * Smoke out of a damaged engine bay as a plume: many small, see-through puffs that leave the top of the bay, climb, widen, drift with the
2040
+ * wind and thin out. The colour says the cause: coolant steam is white, oil burning on the hot block is light grey, and only a fire of
2041
+ * rubber or fuel gives black smoke. Pure numbers: `particles.ts` turns each puff into a sprite (or a request to the host's effects world).
2042
+ */
2043
+ /** What is burning or boiling under the hood. */
2044
+ declare const SmokeCause: {
2045
+ readonly STEAM: "steam";
2046
+ readonly OIL: "oil";
2047
+ readonly FIRE: "fire";
2048
+ };
2049
+ type SmokeCause = (typeof SmokeCause)[keyof typeof SmokeCause];
2050
+ /** Colour and peak opacity of one puff of a cause. */
2051
+ interface SmokeLook {
2052
+ readonly color: number;
2053
+ readonly alpha: number;
2054
+ }
2055
+ declare const SMOKE_LOOKS: Readonly<Record<SmokeCause, SmokeLook>>;
2056
+ declare const smokeCauseOfEmitter: (kind: string) => SmokeCause | undefined;
2057
+ declare function smokeRate(baseRate: number, damage: number): number;
2058
+ /** Puffs born per emission: a plume is many faint puffs overlapping, never a few dense ones. */
2059
+ declare const PLUME_PUFFS = 3;
2060
+ /** The wind the plume leans with, metres a second (the same wind the kit's own puffs drift to). */
2061
+ declare const SMOKE_WIND: readonly [number, number, number];
2062
+ /** The numbers of one puff, in the emitter's frame (offset from the vent, velocity) and as the sprite reads them. */
2063
+ interface SmokePuff {
2064
+ readonly offset: readonly [number, number, number];
2065
+ readonly velocity: readonly [number, number, number];
2066
+ /** Start size in metres and end size as a multiple of it. */
2067
+ readonly size: number;
2068
+ readonly growth: number;
2069
+ readonly life: number;
2070
+ readonly color: number;
2071
+ readonly alpha: number;
2072
+ /** Upward pull (m/s²) and drag (1/s) the effects world applies over the life. */
2073
+ readonly lift: number;
2074
+ readonly drag: number;
2075
+ }
2076
+ interface SmokePuffParams {
2077
+ readonly cause: SmokeCause;
2078
+ /** Size of the source (1 a car's engine bay). */
2079
+ readonly scale: number;
2080
+ /** Uniform random numbers in [0, 1). */
2081
+ readonly random: () => number;
2082
+ /** Wind in the emitter's frame (default `SMOKE_WIND`). */
2083
+ readonly wind?: readonly [number, number, number];
2084
+ }
2085
+ /** One puff of the plume: small and see-through at birth, rising and leaning with the wind, several times wider when it fades. */
2086
+ declare function smokePuff(params: SmokePuffParams): SmokePuff;
2087
+ /** A box of the vehicle frame: centre and full size. */
2088
+ interface BayBox {
2089
+ readonly center: readonly [number, number, number];
2090
+ readonly size: readonly [number, number, number];
2091
+ }
2092
+ /**
2093
+ * Where the smoke leaves the bay: just over the top of the engine, and towards the front of it (`+x` is forward in the vehicle frame), so the
2094
+ * plume rises off the hood and not through the windshield behind it.
2095
+ */
2096
+ declare function engineBayVent(box: BayBox): [number, number, number];
2097
+
2031
2098
  /**
2032
2099
  * Armour levels of a vehicle, after NIJ 0108: the level says which rounds the glass and the steel stop, and how many hits they take
2033
2100
  * before they give. Every number is configurable: a game passes its own table in `VehicleDestructibleOptions.armourLevels`.
@@ -2397,4 +2464,4 @@ declare const CABIN_MINIMUMS: Readonly<Record<CabinCategory, CabinMinimum>>;
2397
2464
  /** Returns the minimum interior clearances for a cabin category. */
2398
2465
  declare const cabinMinimumOf: (category: CabinCategory) => CabinMinimum;
2399
2466
 
2400
- export { ARMOUR_LEVELS, type ArmourLevel, type ArmourLevelId, type Band, type BandId, type BandIndex, type BandOverride, type BuildFunction, type BuildOptions, type BuildState, type BuildZoneState, type BusRowsOptions, CABIN_CATEGORIES, CABIN_LEAK, CABIN_MINIMUMS, CABIN_SOURCE, CRASH_RULES, type CabinBox, type CabinCategory, type CabinDoorMinimum, type CabinEnclosureOptions, type CabinMinimum, type CabinSource, type CarSpec, type CarWheel, type CrashOptions, type CrashResult, type CrashRules, type CreaseQueue, type CreaseWork, type CutTest, type DamageMapOptions, type DamageZone, type Damageable, type DamageableKind, type DamageableMaterial, type DamageableSide, type DashboardOptions, type DriveReport, ENTRY_DUCK_FACTOR, type EngineBaySpec, type ExplodeOptions, type FlagEffect, type FluidDefinition, type GlassOptions, type GlassQuad, type Greenhouse, type GrilleOptions, type HeadlightLens, type HeadlightOptions, type ImpactOptions, type InteriorOptions, JOINT_RULES, type JointDef, type KitConfiguration, type KitInternals, type KitTexts, LEGACY_STATES, LEGACY_ZONE_IDS, type LabelArgument, type LocalBox, type LocaleStrings, type LodSettings, type LoftRow, type LoftStation, type OverallHealth, type PaneLook, type PartDef, type PartLabel, type PartRole, type PartialLocaleStrings, type ParticleEffectRequest, type ParticleEffects, type ParticleMaterials, type PathItem, type Plugin, type Puddle, type PuddleLobe, type ResolvedConfiguration, type RollState, SEED_SALTS, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SceneNode, type SeatOptions, type ShellSpec, type SmoothLoftOptions, type Splat, type SplatOptions, type StrayLamp, type TaillightOptions, type ThreeObject, type ThreeVector, type Translate, type TumbleSpec, type UiHelpers, type UnderbodySpec, type VehicleContext, type VehicleDestructible, type VehicleDestructibleOptions, type VehicleItem, type VehicleItemOptions, type VehicleKit, type VehicleKitOptions, type VehicleLamp, type VehicleMeta, type VehicleModel, type VehiclePart, type VehicleSpec, type VehicleStatus, type WarpFn, type WarpOptions, type ZoneDamageEntry, type ZoneDef, type ZoneEffect, type ZoneState, armourLevelOf, buildVehicleItem, buildVehicleModel, cabinBoxOf, cabinEnclosure, cabinMinimumOf, clamp, crackedGlassMaterial, crashDeltaV, crashVehicle, createCreaseQueue, createLod, createTranslate, createVehicleDestructible, createVehicleKit, defaultDamageableKinds, defaultLodSettings, format, hash, legacyGlassId, legacyLightId, legacyZoneId, listLocales, registerLegacySeeds, registerLocale, resolveStrings, rng, smooth, strHash, strayLampsOf, swingOf, wrapThreeForLod };
2467
+ export { ARMOUR_LEVELS, type ArmourLevel, type ArmourLevelId, type Band, type BandId, type BandIndex, type BandOverride, type BayBox, type BuildFunction, type BuildOptions, type BuildState, type BuildZoneState, type BusRowsOptions, CABIN_CATEGORIES, CABIN_LEAK, CABIN_MINIMUMS, CABIN_SOURCE, CRASH_RULES, type CabinBox, type CabinCategory, type CabinDoorMinimum, type CabinEnclosureOptions, type CabinMinimum, type CabinSource, type CarSpec, type CarWheel, type CrashOptions, type CrashResult, type CrashRules, type CreaseQueue, type CreaseWork, type CutTest, type DamageMapOptions, type DamageZone, type Damageable, type DamageableKind, type DamageableMaterial, type DamageableSide, type DashboardOptions, type DriveReport, ENTRY_DUCK_FACTOR, type EngineBaySpec, type ExplodeOptions, type FlagEffect, type FluidDefinition, type GlassOptions, type GlassQuad, type Greenhouse, type GrilleOptions, type HeadlightLens, type HeadlightOptions, type ImpactOptions, type InteriorOptions, JOINT_RULES, type JointDef, type KitConfiguration, type KitInternals, type KitTexts, LEGACY_STATES, LEGACY_ZONE_IDS, type LabelArgument, type LocalBox, type LocaleStrings, type LodSettings, type LoftRow, type LoftStation, type OverallHealth, PLUME_PUFFS, type PaneLook, type PartDef, type PartLabel, type PartRole, type PartialLocaleStrings, type ParticleEffectRequest, type ParticleEffects, type ParticleMaterials, type PathItem, type Plugin, type Puddle, type PuddleLobe, type ResolvedConfiguration, type RollState, SEED_SALTS, SMOKE_LOOKS, SMOKE_WIND, type ScenarioContext, type ScenarioDefinition, type ScenarioResult, type SceneNode, type SeatOptions, type ShellSpec, SmokeCause, type SmokeLook, type SmokePuff, type SmokePuffParams, type SmoothLoftOptions, type Splat, type SplatOptions, type StrayLamp, type TaillightOptions, type ThreeObject, type ThreeVector, type Translate, type TumbleSpec, type UiHelpers, type UnderbodySpec, type VehicleContext, type VehicleDestructible, type VehicleDestructibleOptions, type VehicleItem, type VehicleItemOptions, type VehicleKit, type VehicleKitOptions, type VehicleLamp, type VehicleMeta, type VehicleModel, type VehiclePart, type VehicleSpec, type VehicleStatus, type WarpFn, type WarpOptions, type ZoneDamageEntry, type ZoneDef, type ZoneEffect, type ZoneState, armourLevelOf, buildVehicleItem, buildVehicleModel, cabinBoxOf, cabinEnclosure, cabinMinimumOf, clamp, crackedGlassMaterial, crashDeltaV, crashVehicle, createCreaseQueue, createLod, createTranslate, createVehicleDestructible, createVehicleKit, defaultDamageableKinds, defaultLodSettings, engineBayVent, format, hash, legacyGlassId, legacyLightId, legacyZoneId, listLocales, registerLegacySeeds, registerLocale, resolveStrings, rng, smokeCauseOfEmitter, smokePuff, smokeRate, smooth, strHash, strayLampsOf, swingOf, wrapThreeForLod };
@@ -33,7 +33,11 @@ var GameVehicles = (() => {
33
33
  JOINT_RULES: () => JOINT_RULES,
34
34
  LEGACY_STATES: () => LEGACY_STATES,
35
35
  LEGACY_ZONE_IDS: () => LEGACY_ZONE_IDS,
36
+ PLUME_PUFFS: () => PLUME_PUFFS,
36
37
  SEED_SALTS: () => SEED_SALTS,
38
+ SMOKE_LOOKS: () => SMOKE_LOOKS,
39
+ SMOKE_WIND: () => SMOKE_WIND,
40
+ SmokeCause: () => SmokeCause,
37
41
  armourLevelOf: () => armourLevelOf,
38
42
  buildVehicleItem: () => buildVehicleItem,
39
43
  buildVehicleModel: () => buildVehicleModel,
@@ -51,6 +55,7 @@ var GameVehicles = (() => {
51
55
  createVehicleKit: () => createVehicleKit,
52
56
  defaultDamageableKinds: () => defaultDamageableKinds,
53
57
  defaultLodSettings: () => defaultLodSettings,
58
+ engineBayVent: () => engineBayVent,
54
59
  format: () => format,
55
60
  hash: () => hash,
56
61
  legacyGlassId: () => legacyGlassId,
@@ -61,6 +66,9 @@ var GameVehicles = (() => {
61
66
  registerLocale: () => registerLocale,
62
67
  resolveStrings: () => resolveStrings,
63
68
  rng: () => rng,
69
+ smokeCauseOfEmitter: () => smokeCauseOfEmitter,
70
+ smokePuff: () => smokePuff,
71
+ smokeRate: () => smokeRate,
64
72
  smooth: () => smooth,
65
73
  strHash: () => strHash,
66
74
  strayLampsOf: () => strayLampsOf,
@@ -6124,6 +6132,51 @@ var GameVehicles = (() => {
6124
6132
  return shared;
6125
6133
  }
6126
6134
 
6135
+ // src/engine-smoke.ts
6136
+ var SmokeCause = { STEAM: "steam", OIL: "oil", FIRE: "fire" };
6137
+ var SMOKE_LOOKS = {
6138
+ [SmokeCause.STEAM]: { color: 14870248, alpha: 0.18 },
6139
+ [SmokeCause.OIL]: { color: 11120306, alpha: 0.2 },
6140
+ [SmokeCause.FIRE]: { color: 2302756, alpha: 0.3 }
6141
+ };
6142
+ var CAUSE_OF_EMITTER = { white: SmokeCause.STEAM, oil: SmokeCause.OIL, black: SmokeCause.FIRE };
6143
+ var smokeCauseOfEmitter = (kind) => CAUSE_OF_EMITTER[kind];
6144
+ var RATE_AT_NO_DAMAGE = 0.25;
6145
+ var RATE_AT_WRECK = 1;
6146
+ function smokeRate(baseRate, damage) {
6147
+ const level = Math.min(1, Math.max(0, damage));
6148
+ return baseRate * (RATE_AT_NO_DAMAGE + (RATE_AT_WRECK - RATE_AT_NO_DAMAGE) * level);
6149
+ }
6150
+ var PLUME_PUFFS = 3;
6151
+ var SMOKE_WIND = [-0.45, 0, 0.16];
6152
+ var LIFT = { [SmokeCause.STEAM]: 0.5, [SmokeCause.OIL]: 0.45, [SmokeCause.FIRE]: 0.6 };
6153
+ var DRAG = 0.4;
6154
+ var VENT_CLEARANCE = 0.08;
6155
+ var VENT_SPREAD = 0.18;
6156
+ var jitter = (random, span) => (random() - 0.5) * 2 * span;
6157
+ function smokePuff(params) {
6158
+ const { cause, scale, random } = params;
6159
+ const wind = params.wind ?? SMOKE_WIND;
6160
+ const look = SMOKE_LOOKS[cause];
6161
+ const isFire = cause === SmokeCause.FIRE;
6162
+ return {
6163
+ offset: [jitter(random, VENT_SPREAD * scale), random() * 0.05, jitter(random, VENT_SPREAD * scale)],
6164
+ velocity: [wind[0] + jitter(random, 0.22), 0.55 + random() * 0.5, wind[2] + jitter(random, 0.22)],
6165
+ size: (isFire ? 0.2 : 0.14) * scale * (0.8 + random() * 0.4),
6166
+ growth: (isFire ? 6 : 5) + random() * 2,
6167
+ life: (isFire ? 3.4 : 2.6) + random() * 1.2,
6168
+ color: look.color,
6169
+ alpha: look.alpha * (0.8 + random() * 0.4),
6170
+ lift: LIFT[cause],
6171
+ drag: DRAG
6172
+ };
6173
+ }
6174
+ function engineBayVent(box2) {
6175
+ const [cx, cy, cz] = box2.center;
6176
+ const [sx, sy] = box2.size;
6177
+ return [cx + sx * 0.15, cy + sy / 2 + VENT_CLEARANCE, cz];
6178
+ }
6179
+
6127
6180
  // src/routed-particles.ts
6128
6181
  var ROUTED_PARTICLE_TYPES = { smoke: "particle_puff", dust: "particle_puff", fire: "particle_glow" };
6129
6182
  var PUFF_LOOKS = {
@@ -6143,7 +6196,7 @@ var GameVehicles = (() => {
6143
6196
  const life = input.life ?? LIFE[type] ?? 99;
6144
6197
  const size = (input.size ?? 1) * (input.grow ?? 1);
6145
6198
  const isFire = type === "fire";
6146
- const growth = isFire ? 1 : (SMOKE_START_SCALE + 1.5 * (1 - Math.exp(-life * 1.1)) + life * 0.12) / SMOKE_START_SCALE;
6199
+ const growth = input.growth ?? (isFire ? 1 : (SMOKE_START_SCALE + 1.5 * (1 - Math.exp(-life * 1.1)) + life * 0.12) / SMOKE_START_SCALE);
6147
6200
  return {
6148
6201
  effect: ROUTED_PARTICLE_TYPES[type],
6149
6202
  point: input.position,
@@ -6152,12 +6205,12 @@ var GameVehicles = (() => {
6152
6205
  vy: input.velocity[1],
6153
6206
  vz: input.velocity[2],
6154
6207
  life,
6155
- size: isFire ? size * 0.85 : size * SMOKE_START_SCALE,
6208
+ size: input.growth !== void 0 ? size : isFire ? size * 0.85 : size * SMOKE_START_SCALE,
6156
6209
  grow: growth,
6157
6210
  color: input.color ?? (isFire ? FIRE_COLOR : look[0]),
6158
6211
  alpha: input.alpha ?? look[1],
6159
- gravity: isFire ? 0 : type === "dust" ? 0 : -0.08,
6160
- drag: type === "dust" ? 2.5 : isFire ? 1.5 : 0.9
6212
+ gravity: input.gravity ?? (isFire ? 0 : type === "dust" ? 0 : -0.08),
6213
+ drag: input.drag ?? (type === "dust" ? 2.5 : isFire ? 1.5 : 0.9)
6161
6214
  }
6162
6215
  };
6163
6216
  }
@@ -6310,7 +6363,10 @@ var GameVehicles = (() => {
6310
6363
  ...o.op != null ? { alpha: o.op } : {},
6311
6364
  ...o.s ? { size: o.s } : {},
6312
6365
  ...o.life ? { life: o.life } : {},
6313
- ...o.grow ? { grow: o.grow } : {}
6366
+ ...o.grow ? { grow: o.grow } : {},
6367
+ ...o.growth ? { growth: o.growth } : {},
6368
+ ...o.lift != null ? { gravity: -o.lift } : {},
6369
+ ...o.drag != null ? { drag: o.drag } : {}
6314
6370
  })
6315
6371
  );
6316
6372
  return null;
@@ -6365,7 +6421,8 @@ var GameVehicles = (() => {
6365
6421
  r: o.r || 0.01,
6366
6422
  spin: (c.rand() - 0.5) * 1.2,
6367
6423
  ph: c.rand() * 6.28,
6368
- grow: o.grow || 1
6424
+ grow: o.grow || 1,
6425
+ growth: o.growth || 0
6369
6426
  };
6370
6427
  c.particles.push(P);
6371
6428
  return P;
@@ -6406,7 +6463,7 @@ var GameVehicles = (() => {
6406
6463
  m.position.addScaledVector(P.v, dt);
6407
6464
  m.position.x += Math.sin(P.age * 1.7 + P.ph) * 0.08 * dt;
6408
6465
  m.position.z += Math.cos(P.age * 1.3 + P.ph) * 0.08 * dt;
6409
- const gs = P.s0 * P.grow * (0.18 + 1.5 * (1 - Math.exp(-P.age * 1.1)) + P.age * 0.12);
6466
+ const gs = P.growth ? P.s0 * (1 + (P.growth - 1) * t) : P.s0 * P.grow * (0.18 + 1.5 * (1 - Math.exp(-P.age * 1.1)) + P.age * 0.12);
6410
6467
  m.scale.set(gs, gs, 1);
6411
6468
  m.material.rotation += P.spin * dt;
6412
6469
  m.material.opacity = P.op * Math.min(1, P.age / 0.3);
@@ -6482,7 +6539,8 @@ var GameVehicles = (() => {
6482
6539
  acc: 0,
6483
6540
  s: o.s || 1,
6484
6541
  dir: o.dir || null,
6485
- gap: 0
6542
+ gap: 0,
6543
+ ...o.damage ? { damage: o.damage } : {}
6486
6544
  };
6487
6545
  c.emitters.push(e);
6488
6546
  return e;
@@ -6494,7 +6552,31 @@ var GameVehicles = (() => {
6494
6552
  return ["#141414", 0.66];
6495
6553
  }
6496
6554
  kit.exhaustLook = exhaustLook;
6555
+ function spawnSmokePuff(c, cause, scale, vent) {
6556
+ for (let k = 0; k < PLUME_PUFFS; k++) {
6557
+ const puff = smokePuff({ cause, scale, random: c.rand });
6558
+ const at = vent.clone().add(c.dirToEffects(new V3(puff.offset[0], puff.offset[1], puff.offset[2])));
6559
+ kit.spawn(c, "smoke", at, new V3(puff.velocity[0], puff.velocity[1], puff.velocity[2]), {
6560
+ col: puff.color,
6561
+ op: puff.alpha,
6562
+ s: puff.size,
6563
+ life: puff.life,
6564
+ growth: puff.growth,
6565
+ lift: puff.lift,
6566
+ drag: puff.drag
6567
+ });
6568
+ }
6569
+ }
6570
+ function spawnOwnSmokePuff(c, e, p) {
6571
+ const black = e.kind === "black" || e.kind === "oil";
6572
+ kit.spawn(c, "smoke", p, new V3((c.rand() - 0.5) * 0.2, black ? 0.9 + c.rand() * 0.3 : 1.1 + c.rand() * 0.3, (c.rand() - 0.5) * 0.2), {
6573
+ variant: black ? "black" : "steam",
6574
+ s: (black ? 0.75 : 0.6) * e.s * (0.8 + c.rand() * 0.4),
6575
+ life: black ? 3.2 : 2
6576
+ });
6577
+ }
6497
6578
  function tickEmit(c, dt) {
6579
+ const plume = !!kit.effects?.();
6498
6580
  c.emitters.forEach(function(e) {
6499
6581
  if (e.kind === "exhaust") {
6500
6582
  const h = c.engineHealth == null ? 1 : c.engineHealth;
@@ -6505,7 +6587,7 @@ var GameVehicles = (() => {
6505
6587
  if (e.gap > 0) return;
6506
6588
  }
6507
6589
  }
6508
- e.acc += e.rate * dt;
6590
+ e.acc += (plume && e.damage ? smokeRate(e.rate, e.damage()) : e.rate) * dt;
6509
6591
  while (e.acc >= 1) {
6510
6592
  e.acc -= 1;
6511
6593
  const p = e.world ? e.p.clone() : c.toEffects(e.p);
@@ -6518,8 +6600,10 @@ var GameVehicles = (() => {
6518
6600
  s: (0.45 + c.rand() * 0.45) * e.s,
6519
6601
  life: 0.55 + c.rand() * 0.35
6520
6602
  });
6521
- if (c.rand() < 0.45)
6522
- kit.spawn(c, "smoke", p.clone().add(new V3(0, 0.7 * e.s, 0)), new V3(0, 1, 0), { variant: "black", s: 0.9 * e.s, life: 3.2 });
6603
+ if (c.rand() < 0.45) {
6604
+ if (plume) spawnSmokePuff(c, SmokeCause.FIRE, e.s, p.clone().add(new V3(0, 0.5 * e.s, 0)));
6605
+ else kit.spawn(c, "smoke", p.clone().add(new V3(0, 0.7 * e.s, 0)), new V3(0, 1, 0), { variant: "black", s: 0.9 * e.s, life: 3.2 });
6606
+ }
6523
6607
  if (c.rand() < 0.15)
6524
6608
  kit.spawn(
6525
6609
  c,
@@ -6538,14 +6622,9 @@ var GameVehicles = (() => {
6538
6622
  life: 1.4 + c.rand() * 0.5
6539
6623
  });
6540
6624
  } else {
6541
- const preta = e.kind === "black";
6542
- kit.spawn(
6543
- c,
6544
- "smoke",
6545
- p,
6546
- new V3((c.rand() - 0.5) * 0.2, preta ? 0.9 + c.rand() * 0.3 : 1.1 + c.rand() * 0.3, (c.rand() - 0.5) * 0.2),
6547
- { variant: preta ? "black" : "steam", s: (preta ? 0.75 : 0.6) * e.s * (0.8 + c.rand() * 0.4), life: preta ? 3.2 : 2 }
6548
- );
6625
+ const cause = smokeCauseOfEmitter(e.kind);
6626
+ if (cause && plume) spawnSmokePuff(c, cause, e.s, p);
6627
+ else spawnOwnSmokePuff(c, e, p);
6549
6628
  }
6550
6629
  }
6551
6630
  });
@@ -7520,7 +7599,7 @@ var GameVehicles = (() => {
7520
7599
  kit.addEmitter(c, pt.pos.clone().add(new V3(-0.1, 0.25, 0)), "white");
7521
7600
  hurtEngine(c, 0.6);
7522
7601
  } else if (k === "engine") {
7523
- kit.addEmitter(c, pt.pos.clone().add(new V3(0, 0.3, 0)), "black");
7602
+ kit.addEmitter(c, pt.pos.clone().add(new V3(0, 0.3, 0)), "oil", { rate: 6, damage: () => 1 - (c.engineHealth ?? 1) });
7524
7603
  hurtEngine(c, force > 1.1 ? 0.1 : 0.3);
7525
7604
  if (c.hood && force > 0.5 && !c.hood.noLatch) {
7526
7605
  c.hood.latch = Math.max(c.hood.latch, 0.15);
@@ -10634,7 +10713,7 @@ var GameVehicles = (() => {
10634
10713
  }
10635
10714
  if (b >= 3) {
10636
10715
  I.hurtEngine(c, b === 4 ? 0.05 : 0.25);
10637
- kit.addEmitter(c, p.clone().add(new V3(0, 0.3, 0)), "black", { rate: b === 4 ? 6 : 4 });
10716
+ kit.addEmitter(c, p.clone().add(new V3(0, 0.3, 0)), "oil", { rate: b === 4 ? 6 : 4, damage: () => 1 - (c.engineHealth ?? 1) });
10638
10717
  if (land) I.puddle(c, "oil", p.clone().setY(Math.max(0.2, m.clearance || 0.3)), b === 4 ? 0.9 : 0.6);
10639
10718
  }
10640
10719
  if (b === 4) kit.addEmitter(c, p.clone().add(new V3(0, 0.15, 0)), "fire", { rate: 7, s: 0.7 });
@@ -14226,7 +14305,7 @@ var GameVehicles = (() => {
14226
14305
  if (!z) return;
14227
14306
  const B = z.box;
14228
14307
  const THREE = this.THREE;
14229
- const mats = this.I.MATERIALS;
14308
+ const lining = this.I.makeMaterial(DOOR_CARD_COLOR, { roughness: 0.85 });
14230
14309
  const grid = (a0, a1, b0, b1) => {
14231
14310
  const out = [];
14232
14311
  for (const fa of [0.25, 0.5, 0.75]) for (const fb of [0.3, 0.7]) out.push([a0 + (a1 - a0) * fa, b0 + (b1 - b0) * fb]);
@@ -14241,7 +14320,7 @@ var GameVehicles = (() => {
14241
14320
  const hingeFront = z.hinge !== "rear";
14242
14321
  const hx = hingeFront ? B.x1 - 0.03 : B.x0 + 0.03;
14243
14322
  const cy = (B.y0 + B.y1) / 2;
14244
- const recess = this.box(len - 0.04, hgt - 0.04, 0.01, mats.dark, (B.x0 + B.x1) / 2, cy, sk + s * 4e-3);
14323
+ const recess = this.box(len - 0.04, hgt - 0.04, 0.01, lining, (B.x0 + B.x1) / 2, cy, sk + s * 4e-3);
14245
14324
  recess.userData.noFollow = true;
14246
14325
  const piv = new THREE.Group();
14247
14326
  piv.name = p.id;
@@ -14258,7 +14337,7 @@ var GameVehicles = (() => {
14258
14337
  if (sk == null) return;
14259
14338
  const wy = B.y1 - B.y0 - 0.1;
14260
14339
  const wz = B.z1 - B.z0 - 0.1;
14261
- const recess = this.box(0.01, wy - 0.04, wz - 0.04, mats.dark, sk + 4e-3, (B.y0 + B.y1) / 2, 0);
14340
+ const recess = this.box(0.01, wy - 0.04, wz - 0.04, lining, sk + 4e-3, (B.y0 + B.y1) / 2, 0);
14262
14341
  recess.userData.noFollow = true;
14263
14342
  const piv = new THREE.Group();
14264
14343
  piv.name = p.id;
@@ -14282,16 +14361,16 @@ var GameVehicles = (() => {
14282
14361
  if (busy) return;
14283
14362
  const r = piv.rotation;
14284
14363
  const open = Math.abs(r.x) + Math.abs(r.y) + Math.abs(r.z) > 1e-3 || this.gone.has(id) || piv.parent !== this.c.vehicle;
14285
- if (open && !this.gone.has(id) && piv.parent === this.c.vehicle && !this.skins.has(id)) {
14364
+ if (open && piv.parent === this.c.vehicle && !this.skins.has(id)) {
14286
14365
  busy = true;
14287
14366
  try {
14288
- this.skins.set(id, this.takeSkin(id, piv));
14367
+ this.skins.set(id, this.takeSkin(id, piv, this.gone.has(id)));
14289
14368
  } finally {
14290
14369
  busy = false;
14291
14370
  }
14292
14371
  }
14293
14372
  panel.visible = open && !this.skins.get(id);
14294
- recess.visible = open && !this.skins.get(id);
14373
+ recess.visible = open && !this.skins.get(id) && !this.gone.has(id);
14295
14374
  if (open) this.openNow.add(id);
14296
14375
  else this.openNow.delete(id);
14297
14376
  this.seams.forEach((doors, seam) => {
@@ -14317,7 +14396,7 @@ var GameVehicles = (() => {
14317
14396
  * Cuts the skin of a door or lid zone out of the body (as the damage's hanging door does) and hangs it, with the thin parts on it (trim, handle) and, for a door, the side
14318
14397
  * window over it, on the hinge. Done with the hinge closed, so every piece keeps its place; answers whether there was skin to take.
14319
14398
  */
14320
- takeSkin(id, piv) {
14399
+ takeSkin(id, piv, torn = false) {
14321
14400
  const p = this.byId.get(id);
14322
14401
  const z = p && this.zone(p);
14323
14402
  if (!p || !z) return false;
@@ -14337,7 +14416,8 @@ var GameVehicles = (() => {
14337
14416
  this.doorTops.set(id, top);
14338
14417
  const rect = [B.x0 + 0.03, B.x1 - 0.03, B.y0 + Math.min(0.08, (B.y1 - B.y0) * 0.1), top];
14339
14418
  const pcs = I.cutPanel(this.c, z, rect, true, dirty, { anyN: true }).map((x) => x.mesh).filter((m) => !!m);
14340
- this.mend(dirty);
14419
+ if (torn) this.mendLater(dirty);
14420
+ else this.mend(dirty);
14341
14421
  if (pcs.length) {
14342
14422
  leaveDeepSkinOnBody(this.THREE, pcs, { toVehicle: inv, side: z.side < 0 ? -1 : 1, depth: DOOR_SKIN_DEPTH });
14343
14423
  const panes = I.windowsOver(this.c, z, inv);
@@ -15288,13 +15368,16 @@ var GameVehicles = (() => {
15288
15368
  else this.I.panelBand(this.c, z, 4, dirty);
15289
15369
  } catch {
15290
15370
  }
15371
+ this.mendLater(dirty);
15372
+ this.gone.add(p.id);
15373
+ }
15374
+ mendLater(dirty) {
15291
15375
  dirty.forEach((msh) => {
15292
15376
  const g = msh.geometry;
15293
15377
  if (g.userData.crease || !g.index) this.smoothLater(msh);
15294
15378
  else g.computeVertexNormals();
15295
15379
  this.I.refreshBounds(g);
15296
15380
  });
15297
- this.gone.add(p.id);
15298
15381
  }
15299
15382
  // ---- parts coming off --------------------------------------------------------------------------------------------------------------------
15300
15383
  outward(p, away) {
@@ -15555,6 +15638,8 @@ var GameVehicles = (() => {
15555
15638
  var TYRE_FLAT_AIR = 0.2;
15556
15639
  var BRAKE_FLUID_NEEDED = 0.6;
15557
15640
  var BRAKE_NO_FLUID = 0.15;
15641
+ var ENGINE_SMOKE_FROM = 0.85;
15642
+ var ENGINE_OIL_SMOKE_RATE = 4;
15558
15643
  var ENGINE_WORKING_C = 90;
15559
15644
  var ENGINE_SETTLE_S = 30;
15560
15645
  var ENGINE_HEATING = 0.5;
@@ -15798,6 +15883,7 @@ var GameVehicles = (() => {
15798
15883
  out.push(ev({ type: "damage", part: p.def.id, amount: r2(before - p.hp), hp: r2(p.hp), damageType: dtype, ...source ? { source } : {} }));
15799
15884
  if (!punctures) wear(p, amount, out);
15800
15885
  syncZone(p);
15886
+ if (vis && p.def.role === "engine" && p.hp < p.def.hp * ENGINE_SMOKE_FROM) smokeFromBay(p, "oil", ENGINE_OIL_SMOKE_RATE);
15801
15887
  if (p.hp <= 0) lose(p, "broken", out, cause);
15802
15888
  else if (p.def.role === "light") vis?.crackLight(p.def, dtype === "ballistic");
15803
15889
  if (p.def.role === "tyre" && !p.flat && p.hp < p.def.hp * 0.6 && !p.lost) {
@@ -15882,6 +15968,10 @@ var GameVehicles = (() => {
15882
15968
  const out3 = dirToWorld(new V3(dirLocal.x * 0.5, dirLocal.y * 0.5 - 0.6, dirLocal.z * 0.5));
15883
15969
  out.push(ev({ type: "leak", part: d.id, fluid, point: toWorld(holePoint), direction: r3(out3), rate: r2(rate), pressurized: !!d.contains.pressurized }));
15884
15970
  };
15971
+ const smokeFromBay = (p, kind, rate) => {
15972
+ const [x, y, z] = engineBayVent(p.def.box);
15973
+ kit.addEmitter(c, new V3(x, y, z), kind, { rate, damage: () => 1 - p.hp / p.def.hp });
15974
+ };
15885
15975
  const centreOf = (d) => new V3(d.box.center[0], d.box.center[1], d.box.center[2]);
15886
15976
  const ignite = (p, out) => {
15887
15977
  if (p.burning || p.lost) return;
@@ -15891,7 +15981,8 @@ var GameVehicles = (() => {
15891
15981
  if (!vis) return;
15892
15982
  const cen = centreOf(d);
15893
15983
  kit.addEmitter(c, cen.clone().add(new V3(0, 0.1, 0)), "fire", { rate: d.role === "tyre" ? 7 : 10, s: d.role === "tyre" ? 0.6 : 0.9 });
15894
- kit.addEmitter(c, cen.clone().add(new V3(0, 0.6, 0)), "black", { rate: 4, s: 1.1 });
15984
+ if (d.role === "engine") smokeFromBay(p, "black", 5);
15985
+ else kit.addEmitter(c, cen.clone().add(new V3(0, 0.6, 0)), "black", { rate: 4, s: 1.1 });
15895
15986
  if (d.role === "fuel_tank" || d.role === "engine") {
15896
15987
  const l = leaks.get("fuel_tank");
15897
15988
  if (l?.pud && l.fluid === "fuel") I.igniteFuel(c, l.pud);
@@ -16622,7 +16713,7 @@ var GameVehicles = (() => {
16622
16713
  if (oil < OIL_NEEDED) engine.hp = Math.max(0, engine.hp - engine.def.hp * OIL_WEAR * work * seconds * ((OIL_NEEDED - oil) / OIL_NEEDED));
16623
16714
  if (engineHeat >= ENGINE_STEAM_C && vis && !steaming) {
16624
16715
  steaming = true;
16625
- kit.addEmitter(c, new V3(engine.def.box.center[0], engine.def.box.center[1] + 0.4, 0), "white", { rate: 8, s: 1 });
16716
+ smokeFromBay(engine, "white", 8);
16626
16717
  }
16627
16718
  if (engineHeat >= ENGINE_SEIZE_C || engine.hp <= engine.def.hp * ENGINE_SEIZE_HP) {
16628
16719
  seized = true;