@adatechnology/game-weapons-three 0.27.4 → 0.27.6

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();
@@ -16059,4 +16060,4 @@ export {
16059
16060
  DEFAULT_EXPLOSIVES_SCENE,
16060
16061
  createExplosivesTestModule
16061
16062
  };
16062
- //# sourceMappingURL=chunk-6L7CAZIF.js.map
16063
+ //# sourceMappingURL=chunk-GXZM4CE6.js.map