@adatechnology/game-weapons-three 0.27.5 → 0.28.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.
@@ -96,6 +96,8 @@ function createAccessoryBench(options) {
96
96
  if (result?.reason === "busy") return;
97
97
  }
98
98
  };
99
+ const hasKind = (kind) => (host.tool().attachments ?? []).some((candidate) => arsenal.attachments.get(candidate.id)?.kind === kind);
100
+ const hasLauncher = () => (host.tool().attachments ?? []).some((part) => arsenal.attachments.get(part.id)?.launcher !== void 0);
99
101
  const toggleKind = (kind) => {
100
102
  const part = (host.tool().attachments ?? []).find((candidate) => arsenal.attachments.get(candidate.id)?.kind === kind);
101
103
  if (!part) host.log(kind === "light" ? text.noLight : text.noLaser);
@@ -110,8 +112,7 @@ function createAccessoryBench(options) {
110
112
  };
111
113
  const switchUnderbarrel = () => {
112
114
  const tool = host.tool();
113
- const hasLauncher = (tool.attachments ?? []).some((part) => arsenal.attachments.get(part.id)?.launcher !== void 0);
114
- if (!hasLauncher) host.log(text.noLauncher);
115
+ if (!hasLauncher()) host.log(text.noLauncher);
115
116
  else host.command?.({ type: "underbarrel", on: tool.underbarrelActive !== true });
116
117
  };
117
118
  const act = (id) => {
@@ -148,7 +149,7 @@ function createAccessoryBench(options) {
148
149
  const onKeyDown = (event) => {
149
150
  if (host.playerHeld?.()) return;
150
151
  if (event.repeat || event.ctrlKey || event.metaKey || event.altKey || TEXT_FIELDS.has(event.target?.tagName ?? "")) return;
151
- const handled2 = event.code === ACCESSORY_KEYS.light ? act(ACTION_IDS.light) : event.code === ACCESSORY_KEYS.laser ? act(ACTION_IDS.laser) : event.code === ACCESSORY_KEYS.underbarrel ? act(ACTION_IDS.underbarrel) : event.code === ACCESSORY_KEYS.stock && toggleStock();
152
+ const handled2 = event.code === ACCESSORY_KEYS.light ? hasKind("light") && act(ACTION_IDS.light) : event.code === ACCESSORY_KEYS.laser ? hasKind("laser") && act(ACTION_IDS.laser) : event.code === ACCESSORY_KEYS.underbarrel ? hasLauncher() && act(ACTION_IDS.underbarrel) : event.code === ACCESSORY_KEYS.stock && toggleStock();
152
153
  if (!handled2) return;
153
154
  event.preventDefault();
154
155
  event.stopImmediatePropagation();
@@ -9558,6 +9559,7 @@ var oneHandHold = (hold, hand) => {
9558
9559
  };
9559
9560
 
9560
9561
  // src/fx/tool-motion.ts
9562
+ import { MELEE_FAMILIES } from "@adatechnology/game-weapons";
9561
9563
  var HOLD = { offset: [0, 0, 0], turn: [0, 0, 0] };
9562
9564
  var SHOVEL_DIG = {
9563
9565
  keys: [
@@ -9588,8 +9590,45 @@ var SHOVEL_SWING = {
9588
9590
  { at: 1, ...HOLD }
9589
9591
  ]
9590
9592
  };
9591
- var TOOL_MOTIONS = /* @__PURE__ */ new Map([
9592
- ["shovel", /* @__PURE__ */ new Map([["dig", SHOVEL_DIG], ["fill", SHOVEL_FILL], ["swing", SHOVEL_SWING]])]
9593
+ var KNIFE_SLASH = {
9594
+ keys: [
9595
+ { at: 0, ...HOLD },
9596
+ { at: 0.3, offset: [0.06, 0.3, 0.04], turn: [0.35, 0, -0.5] },
9597
+ { at: 0.43, offset: [-0.1, 0.2, -0.2], turn: [-0.6, 0, 0.5] },
9598
+ { at: 0.62, offset: [-0.24, 0.04, -0.12], turn: [-1, 0, 0.9] },
9599
+ { at: 1, ...HOLD }
9600
+ ]
9601
+ };
9602
+ var KNIFE_STAB = {
9603
+ keys: [
9604
+ { at: 0, ...HOLD },
9605
+ { at: 0.28, offset: [0.02, 0.06, 0.08], turn: [0.15, 0, 0] },
9606
+ { at: 0.43, offset: [-0.04, 0.12, -0.22], turn: [-0.5, 0, 0] },
9607
+ { at: 0.6, offset: [-0.04, 0.11, -0.2], turn: [-0.45, 0, 0] },
9608
+ { at: 1, ...HOLD }
9609
+ ]
9610
+ };
9611
+ var ONE_HAND_CHOP = {
9612
+ keys: [
9613
+ { at: 0, ...HOLD },
9614
+ { at: 0.3, offset: [0.04, 0.4, 0.04], turn: [0.5, 0, -0.2] },
9615
+ { at: 0.43, offset: [-0.03, 0.18, -0.22], turn: [-0.6, 0, 0.1] },
9616
+ { at: 0.62, offset: [-0.05, -0.03, -0.18], turn: [-1.1, 0, 0.2] },
9617
+ { at: 1, ...HOLD }
9618
+ ]
9619
+ };
9620
+ var FAMILY_MOTIONS = /* @__PURE__ */ new Map([
9621
+ ["short_blade", /* @__PURE__ */ new Map([["slash", KNIFE_SLASH], ["stab", KNIFE_STAB]])],
9622
+ ["one_hand_swing", /* @__PURE__ */ new Map([["chop", ONE_HAND_CHOP]])],
9623
+ // a bat, a pipe or an axe swung with both hands goes as the shovel's swing
9624
+ ["two_hand_swing", /* @__PURE__ */ new Map([["swing", SHOVEL_SWING]])]
9625
+ ]);
9626
+ var TOOL_MOTIONS = new Map([
9627
+ ["shovel", /* @__PURE__ */ new Map([["dig", SHOVEL_DIG], ["fill", SHOVEL_FILL], ["swing", SHOVEL_SWING]])],
9628
+ ...MELEE_FAMILIES.flatMap((family) => {
9629
+ const motions = FAMILY_MOTIONS.get(family.id);
9630
+ return motions ? family.weapons.map((weapon) => [weapon, motions]) : [];
9631
+ })
9593
9632
  ]);
9594
9633
  var ease2 = (s) => s * s * (3 - 2 * s);
9595
9634
  function sampleToolMotion(motion, at2) {
@@ -15990,6 +16029,7 @@ export {
15990
16029
  createWeaponAudio,
15991
16030
  VIEW_HOLD,
15992
16031
  toWorldLens,
16032
+ FAMILY_MOTIONS,
15993
16033
  TOOL_MOTIONS,
15994
16034
  sampleToolMotion,
15995
16035
  BODY_ACTIONS,
@@ -16059,4 +16099,4 @@ export {
16059
16099
  DEFAULT_EXPLOSIVES_SCENE,
16060
16100
  createExplosivesTestModule
16061
16101
  };
16062
- //# sourceMappingURL=chunk-6L7CAZIF.js.map
16102
+ //# sourceMappingURL=chunk-IU5JELUL.js.map