@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.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CarryHands, Thumbnail, ItemControls, ItemControlsHost, ReachedItem } from '@adatechnology/game-contracts';
|
|
1
|
+
import { BodyGesture, CarryHands, Thumbnail, ItemControls, ItemControlsHost, ReachedItem } from '@adatechnology/game-contracts';
|
|
2
2
|
import { BodyId, SeamWorld, JointId, Vec3 as Vec3$1, Quat } from '@adatechnology/game-physics';
|
|
3
3
|
|
|
4
4
|
/** A movable part (door, drawer, lid) moved by a physics engine instead of by `t` stepping at `Motion.speed`. */
|
|
@@ -779,6 +779,8 @@ interface Interactable {
|
|
|
779
779
|
id: string;
|
|
780
780
|
object: string;
|
|
781
781
|
kind: Action['do'];
|
|
782
|
+
/** What the body does to work it (`GESTURE_OF_ACTION`; CLAUDE.md §18): absent when the host does it with a move of its own (a leaf, a seat, a take). */
|
|
783
|
+
gesture?: BodyGesture;
|
|
782
784
|
pos: Vec3;
|
|
783
785
|
radius: number;
|
|
784
786
|
/** Current localized prompt as one phrase (`verb` + `object`). It never contains a key hint such as "E:"; the host adds its own. */
|
|
@@ -1230,6 +1232,11 @@ declare function castWithMember(member: CastBox, other: CastBox): boolean;
|
|
|
1230
1232
|
* container's inside, the bowl's capacity and what it accepts, the access part that must be open (or closed, for a program).
|
|
1231
1233
|
*/
|
|
1232
1234
|
|
|
1235
|
+
/**
|
|
1236
|
+
* Where the hand presses to run a device's program, object-local: the interaction the spec gives the device, else the part that shows it on (its button), else its plug,
|
|
1237
|
+
* the same point the world puts the device's own interaction at. Read from the spec, never from the id an interaction happens to get.
|
|
1238
|
+
*/
|
|
1239
|
+
declare function devicePointOf(spec: ObjectSpec, device: string): Vec3 | undefined;
|
|
1233
1240
|
/** What a basin holds, worst last: a flush washes it back to clean. */
|
|
1234
1241
|
type Soil = 'clean' | 'urine' | 'feces';
|
|
1235
1242
|
interface UsesState {
|
|
@@ -1343,4 +1350,13 @@ declare function sinkVerdict(use: SinkUseSpec, spec: ObjectSpec, host: ItemContr
|
|
|
1343
1350
|
declare const fixtureFlowLps: (fixture: FixtureSpec | undefined) => number;
|
|
1344
1351
|
declare function createSinkRoutines(options: SinkUsesOptions): SinkRoutines;
|
|
1345
1352
|
|
|
1346
|
-
|
|
1353
|
+
/**
|
|
1354
|
+
* What the player's body does for each interaction and use of an object (CLAUDE.md §18: every action has a body animation): the gesture the host plays with the free hand
|
|
1355
|
+
* (`ItemControl.gesture`, `createGestureTimeline` of game-player) before the object reacts. Null: the host plays the action with a body move of its own (a leaf opened by
|
|
1356
|
+
* the door code, a seat sat on, an item taken by the take sequence) or the use plays a hand use clip of its own (washing, drinking, relieving oneself).
|
|
1357
|
+
*/
|
|
1358
|
+
|
|
1359
|
+
declare const GESTURE_OF_ACTION: Readonly<Record<Action['do'], BodyGesture | null>>;
|
|
1360
|
+
declare const GESTURE_OF_USE: Readonly<Record<UseSpec['do'], BodyGesture | null>>;
|
|
1361
|
+
|
|
1362
|
+
export { type Action, type ActiveEmitter, type BasinSpec, type BowlSpec, type BurnerSpec, COLLAR_REACH, CONTROLLED_OBJECT, type CastBox, type Chain, type ChainSpec, type ColliderOptions, type ColliderSpec, type ContainerSpec, DRINK_LITRES, DRINK_LPS, DRY_SECONDS, type DamageKind, type DamageSpec, type DestructionDelegate, type DestructionJoint, type DeviceKind, type DeviceSpec, type DrinkUseSpec, END_GAP, type EmitterBowl, type EmitterKind, type EmitterSpec, type EnginePartDriver, type EnginePartOptions, type EnginePartPhysics, FILL_SHARE, FLOW_DEFAULTS, FLUSH_RUN_SECONDS, type FixtureEmitters, type FixtureKind, type FixtureSpec, type FuelSourceSpec, GESTURE_OF_ACTION, GESTURE_OF_USE, type HangTailParams, type Interactable, type InteractablesLocale, type InteractionSpec, type ItemCatalog, type ItemDef, type ItemStack, type LootEntry, type LootTable, type LootTables, type MirrorSpec, type Motion, type MotionKind, type ObjectControls, type ObjectControlsOptions, type ObjectControlsState, type ObjectSpec, type PartDestruction, type PartDriver, type PartPhysics, type PartSpec, type Pose, REACH_SECONDS, type Rect, type RoutineEnd, type RunningEmitter, type SeatPose, type SeatResult, type SeatSpec, type SinkRoutine, type SinkRoutines, type SinkUseSpec, type SinkUsesOptions, type SinkVerdict, type SlotSpec, type SocketSpec, type SoftDriver, type SoftSpec, type Soil, type SolveSpanParams, type Span, type SpanMaterial, type SpanShape, type Strings, type SwitchSpec, type TankSpec, type TargetOptions, type Transform, type UseNeed, type UseSpec, type UsesState, type Vec3, WASH_SCRUB_SECONDS, type WashDishesSpec, type WashUseSpec, type WireRun, type WireRunsParams, type World, type WorldCollider, type WorldEvent, type WorldObject, type WorldOptions, type WorldState, alignY, buildChain, castWithMember, chainPoints, createEnginePartPhysics, createFixtureEmitters, createObjectControls, createSinkRoutines, createWorld, devicePointOf, dirtyDishes, disposeChain, endsMember, findNeeds, fitsInVolume, fitsSize, fitsSlot, fixtureFlowLps, format, generateLoot, hangTail, hashString, localToWorld, locales, mergeColliders, pickLocale, polylineLength, poseOf, resolveStrings, rng, rotY, rotateAxis, sinkVerdict, solveSpan, spanStrength, wireRuns, worldToLocal, wrapsMember };
|
package/dist/index.global.js
CHANGED
|
@@ -30,6 +30,8 @@ var GameInteractables = (() => {
|
|
|
30
30
|
FILL_SHARE: () => FILL_SHARE,
|
|
31
31
|
FLOW_DEFAULTS: () => FLOW_DEFAULTS,
|
|
32
32
|
FLUSH_RUN_SECONDS: () => FLUSH_RUN_SECONDS,
|
|
33
|
+
GESTURE_OF_ACTION: () => GESTURE_OF_ACTION,
|
|
34
|
+
GESTURE_OF_USE: () => GESTURE_OF_USE,
|
|
33
35
|
REACH_SECONDS: () => REACH_SECONDS,
|
|
34
36
|
WASH_SCRUB_SECONDS: () => WASH_SCRUB_SECONDS,
|
|
35
37
|
alignY: () => alignY,
|
|
@@ -41,6 +43,7 @@ var GameInteractables = (() => {
|
|
|
41
43
|
createObjectControls: () => createObjectControls,
|
|
42
44
|
createSinkRoutines: () => createSinkRoutines,
|
|
43
45
|
createWorld: () => createWorld,
|
|
46
|
+
devicePointOf: () => devicePointOf,
|
|
44
47
|
dirtyDishes: () => dirtyDishes,
|
|
45
48
|
disposeChain: () => disposeChain,
|
|
46
49
|
endsMember: () => endsMember,
|
|
@@ -71,6 +74,33 @@ var GameInteractables = (() => {
|
|
|
71
74
|
wrapsMember: () => wrapsMember
|
|
72
75
|
});
|
|
73
76
|
|
|
77
|
+
// src/gestures.ts
|
|
78
|
+
var GESTURE_OF_ACTION = {
|
|
79
|
+
toggle_part: null,
|
|
80
|
+
open_container: null,
|
|
81
|
+
take: null,
|
|
82
|
+
sit: null,
|
|
83
|
+
toggle_device: "press",
|
|
84
|
+
cycle_device: "press",
|
|
85
|
+
toggle_switch: "flip",
|
|
86
|
+
toggle_breaker: "flip",
|
|
87
|
+
toggle_main: "flip",
|
|
88
|
+
toggle_fixture: "turn",
|
|
89
|
+
toggle_burner: "turn",
|
|
90
|
+
ignite: "strike",
|
|
91
|
+
toggle_fuel: "turn",
|
|
92
|
+
read: "read"
|
|
93
|
+
};
|
|
94
|
+
var GESTURE_OF_USE = {
|
|
95
|
+
program: "press",
|
|
96
|
+
put_in: "put_in",
|
|
97
|
+
empty: "tip",
|
|
98
|
+
fill: "pour",
|
|
99
|
+
relieve: null,
|
|
100
|
+
wash: null,
|
|
101
|
+
drink: null
|
|
102
|
+
};
|
|
103
|
+
|
|
74
104
|
// src/fixture-emitters.ts
|
|
75
105
|
var FLUSH_RUN_SECONDS = 2;
|
|
76
106
|
var START_OPENING = 0.05;
|
|
@@ -1399,6 +1429,7 @@ var GameInteractables = (() => {
|
|
|
1399
1429
|
id,
|
|
1400
1430
|
object: o.id,
|
|
1401
1431
|
kind: i.action.do,
|
|
1432
|
+
...GESTURE_OF_ACTION[i.action.do] ? { gesture: GESTURE_OF_ACTION[i.action.do] } : {},
|
|
1402
1433
|
pos: toWorld(o, i.pos),
|
|
1403
1434
|
radius: i.radius ?? DEFAULT_RADIUS,
|
|
1404
1435
|
label: p.label,
|
|
@@ -2739,6 +2770,14 @@ var GameInteractables = (() => {
|
|
|
2739
2770
|
}
|
|
2740
2771
|
|
|
2741
2772
|
// src/object-uses.ts
|
|
2773
|
+
function devicePointOf(spec, device) {
|
|
2774
|
+
const own = (spec.interactions ?? []).find((i) => i.action.do === "toggle_device" && i.action.device === device);
|
|
2775
|
+
if (own) return own.pos;
|
|
2776
|
+
const def = (spec.devices ?? []).find((d) => d.id === device);
|
|
2777
|
+
if (!def) return void 0;
|
|
2778
|
+
const part = def.part ? spec.parts?.find((p) => p.id === def.part)?.pivot : void 0;
|
|
2779
|
+
return part ?? def.plug ?? [0, 1, 0];
|
|
2780
|
+
}
|
|
2742
2781
|
var OPEN = 0.5;
|
|
2743
2782
|
var PREFIX = "use.";
|
|
2744
2783
|
var SOIL_RANK = { clean: 0, urine: 1, feces: 2 };
|
|
@@ -2862,6 +2901,12 @@ var GameInteractables = (() => {
|
|
|
2862
2901
|
const words = end.vars?.need ? { ...end.vars, need: itemName(end.vars.need) } : end.vars;
|
|
2863
2902
|
lastHost?.say(world.t(end.key, { name: name(), ...words }));
|
|
2864
2903
|
};
|
|
2904
|
+
const gestureOf = (use) => {
|
|
2905
|
+
const gesture = GESTURE_OF_USE[use.do];
|
|
2906
|
+
if (!gesture) return null;
|
|
2907
|
+
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;
|
|
2908
|
+
return at ? { gesture, at: [at[0], at[1], at[2]] } : null;
|
|
2909
|
+
};
|
|
2865
2910
|
const visible = (use) => use.do !== "program" || program === null;
|
|
2866
2911
|
return {
|
|
2867
2912
|
has: (id) => id.startsWith(PREFIX),
|
|
@@ -2871,7 +2916,8 @@ var GameInteractables = (() => {
|
|
|
2871
2916
|
if (program) entries.push({ id: `${PREFIX}stop`, label: world.t("use.program.stop", { name: name(), left: clock(program.left) }), available: true });
|
|
2872
2917
|
for (const use of all.filter(visible)) {
|
|
2873
2918
|
const v = verdict(use, host);
|
|
2874
|
-
|
|
2919
|
+
const body = gestureOf(use);
|
|
2920
|
+
entries.push({ id: `${PREFIX}${use.id}`, label: labelOf(use, host), available: v.available, ...v.available ? {} : { reason: reasonOf(v, use, host) }, ...body ?? {} });
|
|
2875
2921
|
}
|
|
2876
2922
|
return entries;
|
|
2877
2923
|
},
|
|
@@ -2958,7 +3004,10 @@ var GameInteractables = (() => {
|
|
|
2958
3004
|
return {
|
|
2959
3005
|
list(lent) {
|
|
2960
3006
|
lend(lent);
|
|
2961
|
-
const fromWorld = interactions().map((i) =>
|
|
3007
|
+
const fromWorld = interactions().map((i) => {
|
|
3008
|
+
const gesture = i.gesture;
|
|
3009
|
+
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]] } : {} };
|
|
3010
|
+
});
|
|
2962
3011
|
return [...fromWorld, ...uses.list(lent)];
|
|
2963
3012
|
},
|
|
2964
3013
|
run(id, lent) {
|