@adatechnology/game-test-room 0.4.0 → 0.5.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.
- package/dist/index.global.js +9553 -3541
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +41 -2
- package/dist/index.js.map +1 -1
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -1648,7 +1648,7 @@ var toHostEvent = (weapon, event, options = {}) => {
|
|
|
1648
1648
|
return event.phase === "start" ? { type: "tool", weapon, ...durationOf(phase, "draw") } : null;
|
|
1649
1649
|
// a launcher spends a round and throws one projectile: the weapon counts none because it is a throw, a host counts the one that leaves
|
|
1650
1650
|
case "shot":
|
|
1651
|
-
return { type: "shot", weapon, shots: Math.max(1, event.shots), recoil, rounds: event.rounds, mode: event.mode };
|
|
1651
|
+
return { type: "shot", weapon, shots: Math.max(1, event.shots), recoil, rounds: event.rounds, mode: event.mode, ...event.suppressed ? { suppressed: true } : {} };
|
|
1652
1652
|
case "misfire":
|
|
1653
1653
|
return { type: "misfire", weapon };
|
|
1654
1654
|
case "reload":
|
|
@@ -1671,6 +1671,14 @@ var toHostEvent = (weapon, event, options = {}) => {
|
|
|
1671
1671
|
return { type: "safety", weapon, on: event.on };
|
|
1672
1672
|
case "cook":
|
|
1673
1673
|
return { type: "cook", weapon, phase: event.phase, fuse: event.fuse };
|
|
1674
|
+
case "attachment":
|
|
1675
|
+
return { type: "attachment", weapon, action: event.action, attachment: event.id, mount: event.mount, ...event.action === "break" ? {} : durationOf(phase, "fit") };
|
|
1676
|
+
case "toggle":
|
|
1677
|
+
return { type: "toggle", weapon, attachment: event.id, on: event.on };
|
|
1678
|
+
case "stock":
|
|
1679
|
+
return { type: "stock", weapon, state: event.state, kind: event.kind, ...durationOf(phase, "stock") };
|
|
1680
|
+
case "underbarrel":
|
|
1681
|
+
return { type: "underbarrel", weapon, on: event.on, ...durationOf(phase, "switch") };
|
|
1674
1682
|
default:
|
|
1675
1683
|
return null;
|
|
1676
1684
|
}
|
|
@@ -5188,6 +5196,26 @@ function createTestRoom(options) {
|
|
|
5188
5196
|
flushEvents(toolId, tool);
|
|
5189
5197
|
say(t(tool.safety ? "hud.safety_on" : "hud.safety_off"));
|
|
5190
5198
|
}
|
|
5199
|
+
function runToolCommand(request) {
|
|
5200
|
+
const work = (done) => done.ok ? { ok: true, seconds: done.seconds } : { ok: false, reason: done.reason };
|
|
5201
|
+
switch (request.type) {
|
|
5202
|
+
case "fit":
|
|
5203
|
+
return work(tool.fit(request.attachment, { install: "bench", ...request.mount ? { mount: request.mount } : {} }));
|
|
5204
|
+
case "remove":
|
|
5205
|
+
return work(tool.remove(request.attachment, { install: "bench" }));
|
|
5206
|
+
case "toggle":
|
|
5207
|
+
return tool.toggle(request.attachment) === null ? { ok: false, reason: "not_fitted" } : { ok: true };
|
|
5208
|
+
case "stock":
|
|
5209
|
+
return tool.setStock(request.state) ? { ok: true } : { ok: false, reason: "busy" };
|
|
5210
|
+
case "underbarrel":
|
|
5211
|
+
return tool.useUnderbarrel(request.on) ? { ok: true } : { ok: false, reason: "busy" };
|
|
5212
|
+
case "stance":
|
|
5213
|
+
tool.setStance({ ...request.aiming === void 0 ? {} : { aiming: request.aiming }, ...request.supported === void 0 ? {} : { supported: request.supported } });
|
|
5214
|
+
return { ok: true };
|
|
5215
|
+
default:
|
|
5216
|
+
return { ok: false, reason: "unknown" };
|
|
5217
|
+
}
|
|
5218
|
+
}
|
|
5191
5219
|
const host = {
|
|
5192
5220
|
THREE,
|
|
5193
5221
|
scene,
|
|
@@ -5204,8 +5232,19 @@ function createTestRoom(options) {
|
|
|
5204
5232
|
mode: tool.mode,
|
|
5205
5233
|
...tool.fault ? { fault: tool.fault } : {},
|
|
5206
5234
|
safety: tool.safety,
|
|
5207
|
-
heat: tool.heatLevel
|
|
5235
|
+
heat: tool.heatLevel,
|
|
5236
|
+
attachments: tool.attachments.map((part) => ({ id: part.id, mount: part.mount, ...part.integral ? { integral: true } : {}, ...part.on === void 0 ? {} : { on: part.on } })),
|
|
5237
|
+
stock: tool.stock,
|
|
5238
|
+
suppressed: tool.suppressed,
|
|
5239
|
+
underbarrelActive: tool.underbarrelActive,
|
|
5240
|
+
mass: tool.mass,
|
|
5241
|
+
aimSeconds: tool.aimSeconds
|
|
5208
5242
|
}),
|
|
5243
|
+
command(request) {
|
|
5244
|
+
const result = runToolCommand(request);
|
|
5245
|
+
flushEvents(toolId, tool);
|
|
5246
|
+
return result;
|
|
5247
|
+
},
|
|
5209
5248
|
configureTool(settings) {
|
|
5210
5249
|
const condition = settings[SETTING_IDS.condition];
|
|
5211
5250
|
const ammoQuality = settings[SETTING_IDS.ammoQuality];
|