@adatechnology/game-vehicles 0.6.8 → 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.
@@ -13652,6 +13652,8 @@ var GameVehicles = (() => {
13652
13652
  var DOOR_STRIP_OVER = 0.05;
13653
13653
  var DOOR_TOP_OVER_PANE = 0.03;
13654
13654
  var HOLE_TEXTURE_SIZE = 64;
13655
+ var LAMP_BOX_MARGIN = 0.03;
13656
+ var GLOW_MIN_EMISSIVE = 0.05;
13655
13657
  var LAMINATED_HP = 1e3;
13656
13658
  var HOOD_SINK = 2e-3;
13657
13659
  var HOOD_GAP_CLOSED = 0.016;
@@ -14737,7 +14739,7 @@ var GameVehicles = (() => {
14737
14739
  this.lightsOn = on;
14738
14740
  const dark = this.I.MATERIALS.bulbBroken;
14739
14741
  for (const L of this.c.lights) {
14740
- if (L.broken) continue;
14742
+ if (L.broken || L.dark) continue;
14741
14743
  for (const h of L.halo ?? []) h.visible = on;
14742
14744
  for (const m of L.inner ?? []) {
14743
14745
  if (on) {
@@ -14751,12 +14753,31 @@ var GameVehicles = (() => {
14751
14753
  }
14752
14754
  /** 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. */
14753
14755
  crackLight(p, pierced) {
14756
+ if (pierced) this.darkenGlowIn(p);
14754
14757
  const z = this.zone(p);
14755
14758
  if (!z) return;
14756
14759
  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);
14757
14760
  }
14761
+ /** 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. */
14762
+ darkenGlowIn(p) {
14763
+ const dark = this.I.MATERIALS.bulbBroken;
14764
+ const [cx, cy, cz] = p.box.center;
14765
+ const [sx, sy, sz] = p.box.size;
14766
+ this.c.vehicle.updateMatrixWorld(true);
14767
+ this.c.vehicle.traverse((o) => {
14768
+ const mesh2 = o;
14769
+ if (!mesh2.isMesh || mesh2.userData.glass || mesh2.material === dark || Array.isArray(mesh2.material)) return;
14770
+ const { emissive, emissiveIntensity } = mesh2.material;
14771
+ if (!emissive || !(emissiveIntensity > 0) || emissive.r + emissive.g + emissive.b < GLOW_MIN_EMISSIVE) return;
14772
+ mesh2.geometry.computeBoundingBox();
14773
+ const mid = this.c.vehicle.worldToLocal(mesh2.localToWorld(mesh2.geometry.boundingBox.getCenter(new this.THREE.Vector3())));
14774
+ 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;
14775
+ mesh2.material = dark;
14776
+ });
14777
+ }
14758
14778
  /** The lens of a light breaks and its unit stays (damaged) or goes (destroyed). */
14759
14779
  breakLight(p, gone) {
14780
+ this.darkenGlowIn(p);
14760
14781
  const z = this.zone(p);
14761
14782
  if (!z) return;
14762
14783
  for (const L of z.lights) {
@@ -15401,9 +15422,10 @@ var GameVehicles = (() => {
15401
15422
  if (p.lost || !(amount > 0)) return;
15402
15423
  const before = p.hp;
15403
15424
  const crumples = dtype === "blunt" && CRUMPLES.has(p.def.role) && (p.def.material === "steel" || p.def.material === "aluminium");
15404
- p.hp = Math.max(WELDED.has(p.def.role) || crumples ? 1 : 0, p.hp - amount);
15425
+ const punctures = dtype === "ballistic" && p.def.role === "tyre";
15426
+ p.hp = Math.max(WELDED.has(p.def.role) || crumples || punctures ? 1 : 0, p.hp - amount);
15405
15427
  out.push(ev({ type: "damage", part: p.def.id, amount: r2(before - p.hp), hp: r2(p.hp), damageType: dtype, ...source ? { source } : {} }));
15406
- wear(p, amount, out);
15428
+ if (!punctures) wear(p, amount, out);
15407
15429
  syncZone(p);
15408
15430
  if (p.hp <= 0) lose(p, "broken", out, cause);
15409
15431
  else if (p.def.role === "light") vis?.crackLight(p.def, dtype === "ballistic");