@adatechnology/game-interactables 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.
- package/dist/index.d.ts +18 -2
- package/dist/index.global.js +51 -2
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +51 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,3 +1,30 @@
|
|
|
1
|
+
// src/gestures.ts
|
|
2
|
+
var GESTURE_OF_ACTION = {
|
|
3
|
+
toggle_part: null,
|
|
4
|
+
open_container: null,
|
|
5
|
+
take: null,
|
|
6
|
+
sit: null,
|
|
7
|
+
toggle_device: "press",
|
|
8
|
+
cycle_device: "press",
|
|
9
|
+
toggle_switch: "flip",
|
|
10
|
+
toggle_breaker: "flip",
|
|
11
|
+
toggle_main: "flip",
|
|
12
|
+
toggle_fixture: "turn",
|
|
13
|
+
toggle_burner: "turn",
|
|
14
|
+
ignite: "strike",
|
|
15
|
+
toggle_fuel: "turn",
|
|
16
|
+
read: "read"
|
|
17
|
+
};
|
|
18
|
+
var GESTURE_OF_USE = {
|
|
19
|
+
program: "press",
|
|
20
|
+
put_in: "put_in",
|
|
21
|
+
empty: "tip",
|
|
22
|
+
fill: "pour",
|
|
23
|
+
relieve: null,
|
|
24
|
+
wash: null,
|
|
25
|
+
drink: null
|
|
26
|
+
};
|
|
27
|
+
|
|
1
28
|
// src/fixture-emitters.ts
|
|
2
29
|
var FLUSH_RUN_SECONDS = 2;
|
|
3
30
|
var START_OPENING = 0.05;
|
|
@@ -1326,6 +1353,7 @@ function createWorld(options = {}) {
|
|
|
1326
1353
|
id,
|
|
1327
1354
|
object: o.id,
|
|
1328
1355
|
kind: i.action.do,
|
|
1356
|
+
...GESTURE_OF_ACTION[i.action.do] ? { gesture: GESTURE_OF_ACTION[i.action.do] } : {},
|
|
1329
1357
|
pos: toWorld(o, i.pos),
|
|
1330
1358
|
radius: i.radius ?? DEFAULT_RADIUS,
|
|
1331
1359
|
label: p.label,
|
|
@@ -2666,6 +2694,14 @@ function createSinkRoutines(options) {
|
|
|
2666
2694
|
}
|
|
2667
2695
|
|
|
2668
2696
|
// src/object-uses.ts
|
|
2697
|
+
function devicePointOf(spec, device) {
|
|
2698
|
+
const own = (spec.interactions ?? []).find((i) => i.action.do === "toggle_device" && i.action.device === device);
|
|
2699
|
+
if (own) return own.pos;
|
|
2700
|
+
const def = (spec.devices ?? []).find((d) => d.id === device);
|
|
2701
|
+
if (!def) return void 0;
|
|
2702
|
+
const part = def.part ? spec.parts?.find((p) => p.id === def.part)?.pivot : void 0;
|
|
2703
|
+
return part ?? def.plug ?? [0, 1, 0];
|
|
2704
|
+
}
|
|
2669
2705
|
var OPEN = 0.5;
|
|
2670
2706
|
var PREFIX = "use.";
|
|
2671
2707
|
var SOIL_RANK = { clean: 0, urine: 1, feces: 2 };
|
|
@@ -2789,6 +2825,12 @@ function createUses(options) {
|
|
|
2789
2825
|
const words = end.vars?.need ? { ...end.vars, need: itemName(end.vars.need) } : end.vars;
|
|
2790
2826
|
lastHost?.say(world.t(end.key, { name: name(), ...words }));
|
|
2791
2827
|
};
|
|
2828
|
+
const gestureOf = (use) => {
|
|
2829
|
+
const gesture = GESTURE_OF_USE[use.do];
|
|
2830
|
+
if (!gesture) return null;
|
|
2831
|
+
const at = use.do === "program" ? devicePointOf(spec, use.device) : use.do === "put_in" || use.do === "empty" ? containers.get(use.container)?.volume.center : use.do === "fill" ? bowls.get(use.bowl)?.center : void 0;
|
|
2832
|
+
return at ? { gesture, at: [at[0], at[1], at[2]] } : null;
|
|
2833
|
+
};
|
|
2792
2834
|
const visible = (use) => use.do !== "program" || program === null;
|
|
2793
2835
|
return {
|
|
2794
2836
|
has: (id) => id.startsWith(PREFIX),
|
|
@@ -2798,7 +2840,8 @@ function createUses(options) {
|
|
|
2798
2840
|
if (program) entries.push({ id: `${PREFIX}stop`, label: world.t("use.program.stop", { name: name(), left: clock(program.left) }), available: true });
|
|
2799
2841
|
for (const use of all.filter(visible)) {
|
|
2800
2842
|
const v = verdict(use, host);
|
|
2801
|
-
|
|
2843
|
+
const body = gestureOf(use);
|
|
2844
|
+
entries.push({ id: `${PREFIX}${use.id}`, label: labelOf(use, host), available: v.available, ...v.available ? {} : { reason: reasonOf(v, use, host) }, ...body ?? {} });
|
|
2802
2845
|
}
|
|
2803
2846
|
return entries;
|
|
2804
2847
|
},
|
|
@@ -2885,7 +2928,10 @@ function createObjectControls(options) {
|
|
|
2885
2928
|
return {
|
|
2886
2929
|
list(lent) {
|
|
2887
2930
|
lend(lent);
|
|
2888
|
-
const fromWorld = interactions().map((i) =>
|
|
2931
|
+
const fromWorld = interactions().map((i) => {
|
|
2932
|
+
const gesture = i.gesture;
|
|
2933
|
+
return { id: i.id, label: i.label, available: i.available, ...i.reason ? { reason: world.t(i.reason) } : {}, ...gesture ? { gesture, at: [i.pos[0], i.pos[1], i.pos[2]] } : {} };
|
|
2934
|
+
});
|
|
2889
2935
|
return [...fromWorld, ...uses.list(lent)];
|
|
2890
2936
|
},
|
|
2891
2937
|
run(id, lent) {
|
|
@@ -2924,6 +2970,8 @@ export {
|
|
|
2924
2970
|
FILL_SHARE,
|
|
2925
2971
|
FLOW_DEFAULTS,
|
|
2926
2972
|
FLUSH_RUN_SECONDS,
|
|
2973
|
+
GESTURE_OF_ACTION,
|
|
2974
|
+
GESTURE_OF_USE,
|
|
2927
2975
|
REACH_SECONDS,
|
|
2928
2976
|
WASH_SCRUB_SECONDS,
|
|
2929
2977
|
alignY,
|
|
@@ -2935,6 +2983,7 @@ export {
|
|
|
2935
2983
|
createObjectControls,
|
|
2936
2984
|
createSinkRoutines,
|
|
2937
2985
|
createWorld,
|
|
2986
|
+
devicePointOf,
|
|
2938
2987
|
dirtyDishes,
|
|
2939
2988
|
disposeChain,
|
|
2940
2989
|
endsMember,
|