@adatechnology/game-vehicles 0.6.9 → 0.6.10

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.js CHANGED
@@ -11961,6 +11961,8 @@ var DOOR_SILL = 0.25;
11961
11961
  var DOOR_STRIP_OVER = 0.05;
11962
11962
  var DOOR_TOP_OVER_PANE = 0.03;
11963
11963
  var HOLE_TEXTURE_SIZE = 64;
11964
+ var LAMP_BOX_MARGIN = 0.03;
11965
+ var GLOW_MIN_EMISSIVE = 0.05;
11964
11966
  var LAMINATED_HP = 1e3;
11965
11967
  var HOOD_SINK = 2e-3;
11966
11968
  var HOOD_GAP_CLOSED = 0.016;
@@ -13046,7 +13048,7 @@ var VehicleVisuals = class {
13046
13048
  this.lightsOn = on;
13047
13049
  const dark = this.I.MATERIALS.bulbBroken;
13048
13050
  for (const L of this.c.lights) {
13049
- if (L.broken) continue;
13051
+ if (L.broken || L.dark) continue;
13050
13052
  for (const h of L.halo ?? []) h.visible = on;
13051
13053
  for (const m of L.inner ?? []) {
13052
13054
  if (on) {
@@ -13060,12 +13062,31 @@ var VehicleVisuals = class {
13060
13062
  }
13061
13063
  /** The lens of a light is holed or cracked and stays; `pierced`: a round went through it to the bulb, and the lamp goes dark. */
13062
13064
  crackLight(p, pierced) {
13065
+ if (pierced) this.darkenGlowIn(p);
13063
13066
  const z = this.zone(p);
13064
13067
  if (!z) return;
13065
13068
  for (const L of z.lights) this.kit.crackLight(this.c, L, new this.THREE.Vector3(p.box.center[0] > 0 ? -1 : 1, 0, 0), pierced);
13066
13069
  }
13070
+ /** Everything of the lamp that glows goes dark: the fleet draws extra bulbs, reversing and amber strips in a lamp's place that the lamp's own list does not hold. */
13071
+ darkenGlowIn(p) {
13072
+ const dark = this.I.MATERIALS.bulbBroken;
13073
+ const [cx, cy, cz] = p.box.center;
13074
+ const [sx, sy, sz] = p.box.size;
13075
+ this.c.vehicle.updateMatrixWorld(true);
13076
+ this.c.vehicle.traverse((o) => {
13077
+ const mesh = o;
13078
+ if (!mesh.isMesh || mesh.userData.glass || mesh.material === dark || Array.isArray(mesh.material)) return;
13079
+ const { emissive, emissiveIntensity } = mesh.material;
13080
+ if (!emissive || !(emissiveIntensity > 0) || emissive.r + emissive.g + emissive.b < GLOW_MIN_EMISSIVE) return;
13081
+ mesh.geometry.computeBoundingBox();
13082
+ const mid = this.c.vehicle.worldToLocal(mesh.localToWorld(mesh.geometry.boundingBox.getCenter(new this.THREE.Vector3())));
13083
+ if (Math.abs(mid.x - cx) > sx / 2 + LAMP_BOX_MARGIN || Math.abs(mid.y - cy) > sy / 2 + LAMP_BOX_MARGIN || Math.abs(mid.z - cz) > sz / 2 + LAMP_BOX_MARGIN) return;
13084
+ mesh.material = dark;
13085
+ });
13086
+ }
13067
13087
  /** The lens of a light breaks and its unit stays (damaged) or goes (destroyed). */
13068
13088
  breakLight(p, gone) {
13089
+ this.darkenGlowIn(p);
13069
13090
  const z = this.zone(p);
13070
13091
  if (!z) return;
13071
13092
  for (const L of z.lights) {
@@ -13710,9 +13731,10 @@ function createVehicleDestructible(kit, vehicleCtx, options = {}) {
13710
13731
  if (p.lost || !(amount > 0)) return;
13711
13732
  const before = p.hp;
13712
13733
  const crumples = dtype === "blunt" && CRUMPLES.has(p.def.role) && (p.def.material === "steel" || p.def.material === "aluminium");
13713
- p.hp = Math.max(WELDED.has(p.def.role) || crumples ? 1 : 0, p.hp - amount);
13734
+ const punctures = dtype === "ballistic" && p.def.role === "tyre";
13735
+ p.hp = Math.max(WELDED.has(p.def.role) || crumples || punctures ? 1 : 0, p.hp - amount);
13714
13736
  out.push(ev({ type: "damage", part: p.def.id, amount: r2(before - p.hp), hp: r2(p.hp), damageType: dtype, ...source ? { source } : {} }));
13715
- wear(p, amount, out);
13737
+ if (!punctures) wear(p, amount, out);
13716
13738
  syncZone(p);
13717
13739
  if (p.hp <= 0) lose(p, "broken", out, cause);
13718
13740
  else if (p.def.role === "light") vis?.crackLight(p.def, dtype === "ballistic");