@adatechnology/game-destruction 0.11.0 → 0.12.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.
@@ -1974,6 +1974,7 @@ var GameDestruction = (() => {
1974
1974
  },
1975
1975
  hitDebris: "chips",
1976
1976
  breakDebris: "dust",
1977
+ visual: { innerColor: 10197652 },
1977
1978
  thermal: {
1978
1979
  conductivity: 0.15,
1979
1980
  heatCapacity: 2.5
@@ -2004,6 +2005,7 @@ var GameDestruction = (() => {
2004
2005
  ],
2005
2006
  hitDebris: "chips",
2006
2007
  breakDebris: "dust",
2008
+ visual: { innerColor: 12085567 },
2007
2009
  thermal: {
2008
2010
  conductivity: 0.15,
2009
2011
  heatCapacity: 2.5
@@ -2034,6 +2036,7 @@ var GameDestruction = (() => {
2034
2036
  ],
2035
2037
  hitDebris: "dust",
2036
2038
  breakDebris: "dust",
2039
+ visual: { innerColor: 14999507 },
2037
2040
  thermal: {
2038
2041
  conductivity: 0.1,
2039
2042
  heatCapacity: 1.5
@@ -2059,6 +2062,7 @@ var GameDestruction = (() => {
2059
2062
  ],
2060
2063
  hitDebris: "chips",
2061
2064
  breakDebris: "dust",
2065
+ visual: { innerColor: 9407364 },
2062
2066
  thermal: {
2063
2067
  conductivity: 0.2,
2064
2068
  heatCapacity: 2.5
@@ -2979,6 +2983,7 @@ var GameDestruction = (() => {
2979
2983
  var CHIP_ENERGY = 200;
2980
2984
  var CHIP_SPLASH = 0.5;
2981
2985
  var BAR_BOW = 0.08;
2986
+ var BULLET_JOINT_SPAN = 0.3;
2982
2987
  var CUT_SLICE = 1;
2983
2988
  var cutFactorOf = (shape) => clamp2(Math.max(...shapeDims(shape)) / CUT_SLICE, 1, 50);
2984
2989
  var clamp2 = (v, a, b) => Math.max(a, Math.min(b, v));
@@ -4105,7 +4110,7 @@ var GameDestruction = (() => {
4105
4110
  emit({ ...base(o, src), type: "crack", part: p.spec.id, crack, worldPoint: wp });
4106
4111
  setStage(o, p, 1, {}, src);
4107
4112
  };
4108
- const debris = (o, p, kind, point, normal, count, speed, src) => emit({ ...base(o, src), type: "debris", part: p.spec.id, kind, point, normal, count, speed });
4113
+ const debris = (o, p, kind, point, normal, count, speed, src, material) => emit({ ...base(o, src), type: "debris", part: p.spec.id, kind, point, normal, count, speed, ...material && material !== p.spec.material ? { material } : {} });
4109
4114
  const holeRate = (hole, pressurized) => (pressurized ? 0.5 : 0.1) * (hole.diameter / 9e-3);
4110
4115
  const detachEvents = (o, opened, by, src) => {
4111
4116
  for (const j of opened) emit({ ...base(o, src), type: "detach", joint: j.spec.id, parts: [j.spec.a, j.spec.b], by, groups: o.st.groups.map((g) => [...g]) });
@@ -4146,7 +4151,13 @@ var GameDestruction = (() => {
4146
4151
  const small = pa.dims[0] * pa.dims[1] * pa.dims[2] <= pb.dims[0] * pb.dims[1] * pb.dims[2] ? pa : pb;
4147
4152
  return Math.max(0.06, 0.5 * Math.min(small.dims[0], small.dims[1], small.dims[2]));
4148
4153
  };
4149
- const wearJoints = (o, p, amount, near, radius = 0.06, src, split = false) => {
4154
+ const jointLength = (o, j) => {
4155
+ const A = partWorldAabb(o, o.parts[j.ia]), B = partWorldAabb(o, o.parts[j.ib]);
4156
+ let len = 0;
4157
+ for (let k = 0; k < 3; k++) len = Math.max(len, Math.min(A.max[k], B.max[k]) - Math.max(A.min[k], B.min[k]));
4158
+ return len;
4159
+ };
4160
+ const wearJoints = (o, p, amount, near, radius = 0.06, src, split = false, span) => {
4150
4161
  if (amount <= 0) return;
4151
4162
  const mine = (o.byPart.get(p.spec.id) ?? []).filter((j) => !j.st.open);
4152
4163
  if (split && mine.length) amount /= mine.length;
@@ -4154,7 +4165,7 @@ var GameDestruction = (() => {
4154
4165
  if (j.st.open) continue;
4155
4166
  if (j.spec.kind === "rebar" && (isReinforced(o.parts[j.ia].spec) || isReinforced(o.parts[j.ib].spec))) continue;
4156
4167
  if (near && jointReach(o, j, near) > Math.max(radius, jointReachLimit(o, j))) continue;
4157
- j.st.hp -= amount;
4168
+ j.st.hp -= span === void 0 ? amount : amount * Math.min(1, span / Math.max(jointLength(o, j), 1e-6));
4158
4169
  if (j.st.hp <= 0) {
4159
4170
  j.st.hp = 0;
4160
4171
  j.st.open = true;
@@ -4183,7 +4194,7 @@ var GameDestruction = (() => {
4183
4194
  if (spalls.length > MAX_SPALLS) spalls.shift();
4184
4195
  markDamaged(p);
4185
4196
  emit({ ...base(o, src), type: "spall", part: p.spec.id, layer: layer.index, point: wp, area: Math.PI * radius * radius });
4186
- debris(o, p, layer.mat.hitDebris, wp, normal, 5, 2, src);
4197
+ debris(o, p, layer.mat.hitDebris, wp, normal, 5, 2, src, layer.mat.id);
4187
4198
  setStage(o, p, 1, {}, src);
4188
4199
  };
4189
4200
  const crater = (o, p, wp, normal, radius, src) => {
@@ -4670,7 +4681,7 @@ var GameDestruction = (() => {
4670
4681
  if (mat.fracture !== "shatter") addHole(o, p, entry, n, caliber / 1e3, false, void 0, src);
4671
4682
  } else addHole(o, p, entry, n, caliber / 1e3, false, void 0, src);
4672
4683
  debris(o, p, mat.hitDebris, entry, n, clamp2(Math.round(E / 60) + 2, 2, 14), clamp2(Math.sqrt(E) / 6, 1, 8), src);
4673
- wearJoints(o, p, (penetrated ? thr : E) * 0.02, void 0, 0, src, true);
4684
+ wearJoints(o, p, (penetrated ? thr : E) * 0.02, void 0, 0, src, true, BULLET_JOINT_SPAN);
4674
4685
  const absorbed = penetrated && mat.ductility >= 0.5 && mat.fracture !== "tear" ? Math.min(E, thr) : E;
4675
4686
  const dmg = applyDamage(o, p, absorbed * DMG_PER_J * scale, "ballistic", entry, d, absorbed * 0.1, 12, src);
4676
4687
  if (!isLost(p)) tearAt(o, p, "ballistic", entry, penetrated ? exitPoint : void 0, d, E, caliber / 1e3, src);