@adatechnology/game-crowd 0.4.0 → 0.4.2

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.
@@ -54,6 +54,7 @@ var GameCrowd = (() => {
54
54
 
55
55
  // ../game-contracts/dist/index.js
56
56
  var DEFAULT_BLAST_SHOVE = { coupling: 0.02, maxSpeed: 20, lift: 0.3, minSpeed: 0.3, falloffPower: 2 };
57
+ var clampShare = (share) => Math.min(1, Math.max(0, share));
57
58
  function blastShove(blast, target, options = {}) {
58
59
  const o = { ...DEFAULT_BLAST_SHOVE, ...options };
59
60
  const dx = target.position[0] - blast.point[0];
@@ -63,12 +64,14 @@ var GameCrowd = (() => {
63
64
  if (!(blast.radius > 0) || distance > blast.radius) return void 0;
64
65
  const falloff = (1 - distance / blast.radius) ** o.falloffPower;
65
66
  const mass = Math.max(target.mass, 0.05);
66
- const speed = Math.min(o.maxSpeed, Math.sqrt(2 * blast.energy * (blast.reach ?? 1) * o.coupling / mass)) * falloff;
67
+ const reach = clampShare(blast.reach ?? 1);
68
+ const speed = Math.sqrt(reach) * Math.min(o.maxSpeed, Math.sqrt(2 * blast.energy * o.coupling / mass)) * falloff;
67
69
  if (!(speed >= o.minSpeed)) return void 0;
68
70
  const direction = distance > 1e-4 ? [dx / distance, dy / distance + o.lift, dz / distance] : [0, 1, 0];
69
71
  const length = Math.hypot(direction[0], direction[1], direction[2]);
70
72
  return { speed, direction: [direction[0] / length, direction[1] / length, direction[2] / length], distance, falloff };
71
73
  }
74
+ var DEFAULT_BLAST_IMPULSE = { bodyArea: 0.7, lift: 0.15, minSpeed: 0.3, tntPerJoule: 0.24 / 2e5 };
72
75
  var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
73
76
  var MISSING_BITS = {
74
77
  head: 1,