@adatechnology/game-interactables 0.13.0 → 0.14.1
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 +16 -3
- package/dist/index.global.js +47 -9
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +45 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -298,11 +298,14 @@ interface ItemDef {
|
|
|
298
298
|
type ItemCatalog = Record<string, ItemDef>;
|
|
299
299
|
/** A spot where one stack sits, in object-local coordinates (bottom center of the stack). */
|
|
300
300
|
interface SlotSpec {
|
|
301
|
+
/** Where the item stands: the middle of its base. */
|
|
301
302
|
pos: Vec3;
|
|
302
|
-
/** Largest item [w, h, d] the slot holds. */
|
|
303
|
+
/** Largest item [w, h, d] the slot holds, as it lies in the slot. */
|
|
303
304
|
max: Vec3;
|
|
304
305
|
/** The slot moves with this part (a drawer or a door shelf). */
|
|
305
306
|
part?: string;
|
|
307
|
+
/** The item lies on its side, its height along `x` or `z` (a toothbrush or a tube laid on a counter); left out, it stands up. */
|
|
308
|
+
lay?: 'x' | 'z';
|
|
306
309
|
}
|
|
307
310
|
interface ContainerSpec {
|
|
308
311
|
id: string;
|
|
@@ -625,6 +628,14 @@ interface WashUseSpec {
|
|
|
625
628
|
readonly dishes?: WashDishesSpec;
|
|
626
629
|
/** Seconds of scrubbing per thing washed. Default `WASH_SCRUB_SECONDS`. */
|
|
627
630
|
readonly scrubSeconds?: number;
|
|
631
|
+
/**
|
|
632
|
+
* The hand use the rinse plays while the water takes the foam off a thing held in the hands (a dish under the tap), and its length in seconds: played as the rinse
|
|
633
|
+
* starts and again each time it ends, until the thing is clean. Left out, the rinse has no hold of its own (the scrubbing clip already rinses, as washing the hands).
|
|
634
|
+
*/
|
|
635
|
+
readonly rinse?: {
|
|
636
|
+
readonly clip: string;
|
|
637
|
+
readonly seconds: number;
|
|
638
|
+
};
|
|
628
639
|
}
|
|
629
640
|
/**
|
|
630
641
|
* Drinking at a fixture (`do: 'drink'`), one of two ways:
|
|
@@ -1181,7 +1192,9 @@ declare function rng(seed?: number | string): () => number;
|
|
|
1181
1192
|
|
|
1182
1193
|
/** True when an item of `size` [w, h, d] fits in a slot of `max`; width and depth may be swapped (the item is turned). */
|
|
1183
1194
|
declare function fitsSize(size: Vec3, max: Vec3): boolean;
|
|
1184
|
-
/**
|
|
1195
|
+
/** An item's size [w, h, d] as it lies in a slot: on its side (`SlotSpec.lay`) its height runs along that axis and its depth (or width) stands up. */
|
|
1196
|
+
declare function laidSize(size: Vec3, lay: SlotSpec['lay']): Vec3;
|
|
1197
|
+
/** Does the item type fit the slot, as it lies there. Types missing from the catalog are accepted (the host owns unknown items). */
|
|
1185
1198
|
declare function fitsSlot(type: string, slot: SlotSpec, items?: ItemCatalog): boolean;
|
|
1186
1199
|
/**
|
|
1187
1200
|
* Deterministic contents for a container: one entry per slot. A slot is filled with probability `fill`; the entry is a weighted pick
|
|
@@ -1596,4 +1609,4 @@ declare function createSinkRoutines(options: SinkUsesOptions): SinkRoutines;
|
|
|
1596
1609
|
declare const GESTURE_OF_ACTION: Readonly<Record<Action['do'], BodyGesture | null>>;
|
|
1597
1610
|
declare const GESTURE_OF_USE: Readonly<Record<UseSpec['do'], BodyGesture | null>>;
|
|
1598
1611
|
|
|
1599
|
-
export { type Action, type ActiveEmitter, type BasinContent, type BasinContentInput, type BasinContentKind, type BasinContentSave, type BasinContentStage, type BasinDrain, type BasinDrainSave, type BasinDrainState, type BasinDrainStep, type BasinSpec, type BasinWater, type BowlSpec, type BurnerSpec, CLOGGED, COLLAR_REACH, CONTROLLED_OBJECT, type CastBox, type Chain, type ChainSpec, type ClogCause, type ColliderOptions, type ColliderSpec, type ContainerSpec, DRINK_HANDS_LITRES, DRINK_HANDS_LPS, DRINK_LITRES, DRINK_LPS, DRY_SECONDS, type DamageKind, type DamageSpec, type DestructionDelegate, type DestructionJoint, type DeviceKind, type DeviceSpec, type DrainPhase, type DrainSpec, type DrainUses, type DrainUsesOptions, type DrinkUseSpec, END_GAP, type EmitterBowl, type EmitterKind, type EmitterSpec, type EnginePartDriver, type EnginePartOptions, type EnginePartPhysics, FILL_SHARE, FLOW_DEFAULTS, FLUSH_POUR_SECONDS, 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 PlungeUseSpec, type Pose, REACH_SECONDS, type Rect, type RelieveUseSpec, 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 UseBody, type UseBodyPose, 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, createBasinDrain, createDrainUses, createEnginePartPhysics, createFixtureEmitters, createObjectControls, createSinkRoutines, createUseBody, 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 };
|
|
1612
|
+
export { type Action, type ActiveEmitter, type BasinContent, type BasinContentInput, type BasinContentKind, type BasinContentSave, type BasinContentStage, type BasinDrain, type BasinDrainSave, type BasinDrainState, type BasinDrainStep, type BasinSpec, type BasinWater, type BowlSpec, type BurnerSpec, CLOGGED, COLLAR_REACH, CONTROLLED_OBJECT, type CastBox, type Chain, type ChainSpec, type ClogCause, type ColliderOptions, type ColliderSpec, type ContainerSpec, DRINK_HANDS_LITRES, DRINK_HANDS_LPS, DRINK_LITRES, DRINK_LPS, DRY_SECONDS, type DamageKind, type DamageSpec, type DestructionDelegate, type DestructionJoint, type DeviceKind, type DeviceSpec, type DrainPhase, type DrainSpec, type DrainUses, type DrainUsesOptions, type DrinkUseSpec, END_GAP, type EmitterBowl, type EmitterKind, type EmitterSpec, type EnginePartDriver, type EnginePartOptions, type EnginePartPhysics, FILL_SHARE, FLOW_DEFAULTS, FLUSH_POUR_SECONDS, 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 PlungeUseSpec, type Pose, REACH_SECONDS, type Rect, type RelieveUseSpec, 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 UseBody, type UseBodyPose, 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, createBasinDrain, createDrainUses, createEnginePartPhysics, createFixtureEmitters, createObjectControls, createSinkRoutines, createUseBody, createWorld, devicePointOf, dirtyDishes, disposeChain, endsMember, findNeeds, fitsInVolume, fitsSize, fitsSlot, fixtureFlowLps, format, generateLoot, hangTail, hashString, laidSize, localToWorld, locales, mergeColliders, pickLocale, polylineLength, poseOf, resolveStrings, rng, rotY, rotateAxis, sinkVerdict, solveSpan, spanStrength, wireRuns, worldToLocal, wrapsMember };
|
package/dist/index.global.js
CHANGED
|
@@ -63,6 +63,7 @@ var GameInteractables = (() => {
|
|
|
63
63
|
generateLoot: () => generateLoot,
|
|
64
64
|
hangTail: () => hangTail,
|
|
65
65
|
hashString: () => hashString,
|
|
66
|
+
laidSize: () => laidSize,
|
|
66
67
|
localToWorld: () => localToWorld,
|
|
67
68
|
locales: () => locales,
|
|
68
69
|
mergeColliders: () => mergeColliders,
|
|
@@ -436,9 +437,14 @@ var GameInteractables = (() => {
|
|
|
436
437
|
if (size[1] > max[1] + eps) return false;
|
|
437
438
|
return size[0] <= max[0] + eps && size[2] <= max[2] + eps || size[2] <= max[0] + eps && size[0] <= max[2] + eps;
|
|
438
439
|
}
|
|
440
|
+
function laidSize(size, lay) {
|
|
441
|
+
if (lay === "x") return [size[1], size[0], size[2]];
|
|
442
|
+
if (lay === "z") return [size[0], size[2], size[1]];
|
|
443
|
+
return size;
|
|
444
|
+
}
|
|
439
445
|
function fitsSlot(type, slot, items) {
|
|
440
446
|
const def = items?.[type];
|
|
441
|
-
return def ? fitsSize(def.size, slot.max) : true;
|
|
447
|
+
return def ? fitsSize(laidSize(def.size, slot.lay), slot.max) : true;
|
|
442
448
|
}
|
|
443
449
|
function generateLoot(tables, tableId, slots, seed, items) {
|
|
444
450
|
const table = tables?.[tableId];
|
|
@@ -528,6 +534,10 @@ var GameInteractables = (() => {
|
|
|
528
534
|
"use.wash_dishes": "Wash the dishes",
|
|
529
535
|
"use.drink_water": "Drink water from the glass",
|
|
530
536
|
"use.drink_from_hands": "Drink water from your hands",
|
|
537
|
+
"use.lather_body": "Soap yourself",
|
|
538
|
+
"use.shampoo_hair": "Shampoo your hair",
|
|
539
|
+
"use.wash_hands": "Wash your hands",
|
|
540
|
+
"use.brush_teeth": "Brush your teeth",
|
|
531
541
|
needs_in_hand: "Pick up {item} first",
|
|
532
542
|
needs_vessel: "You need a glass",
|
|
533
543
|
vessel_not_empty: "Empty {item} first",
|
|
@@ -617,6 +627,10 @@ var GameInteractables = (() => {
|
|
|
617
627
|
"use.wash_dishes": "Lavar a lou\xE7a",
|
|
618
628
|
"use.drink_water": "Beber \xE1gua no copo",
|
|
619
629
|
"use.drink_from_hands": "Beber \xE1gua com a m\xE3o",
|
|
630
|
+
"use.lather_body": "Ensaboar-se",
|
|
631
|
+
"use.shampoo_hair": "Passar shampoo",
|
|
632
|
+
"use.wash_hands": "Lavar as m\xE3os",
|
|
633
|
+
"use.brush_teeth": "Escovar os dentes",
|
|
620
634
|
needs_in_hand: "Pegue {item} antes",
|
|
621
635
|
needs_vessel: "Precisa de um copo",
|
|
622
636
|
vessel_not_empty: "Esvazie {item} antes",
|
|
@@ -2877,6 +2891,8 @@ var GameInteractables = (() => {
|
|
|
2877
2891
|
};
|
|
2878
2892
|
var MUST_DRAIN_QUEUE_IDS = /* @__PURE__ */ new Set([DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS, DEFERRED_QUEUE_ID.BREACH_CUT]);
|
|
2879
2893
|
var PLUNGE_STROKE_SECONDS = 0.8;
|
|
2894
|
+
var BODY_FOAM_SURFACES = ["hands", "arms", "torso", "hair", "mouth"];
|
|
2895
|
+
var WASH_SURFACES = [...BODY_FOAM_SURFACES, "brush"];
|
|
2880
2896
|
var SURFACE_IDS = ["concrete", "asphalt", "wood", "tile", "dirt", "grass", "gravel", "sand", "metal", "water", "glass", "carpet"];
|
|
2881
2897
|
var GAIT_IDS = ["walk", "run"];
|
|
2882
2898
|
var LANDING_IDS = ["light", "heavy"];
|
|
@@ -3250,7 +3266,7 @@ var GameInteractables = (() => {
|
|
|
3250
3266
|
}
|
|
3251
3267
|
};
|
|
3252
3268
|
};
|
|
3253
|
-
const scrubAndRinse = (use, body, target, fail) => {
|
|
3269
|
+
const scrubAndRinse = (use, body, target, fail, tool) => {
|
|
3254
3270
|
const item = typeof target === "string" ? void 0 : target;
|
|
3255
3271
|
const id = item?.objectId ?? target;
|
|
3256
3272
|
const seconds = use.scrubSeconds ?? WASH_SCRUB_SECONDS;
|
|
@@ -3259,7 +3275,7 @@ var GameInteractables = (() => {
|
|
|
3259
3275
|
const scrub = (dt) => {
|
|
3260
3276
|
if (scrubbed < 0) {
|
|
3261
3277
|
scrubbed = 0;
|
|
3262
|
-
if (!body.playUse(use.clip, item?.objectId, underStream(use))) {
|
|
3278
|
+
if (!body.playUse(use.clip, (item ?? tool)?.objectId, underStream(use))) {
|
|
3263
3279
|
fail({ key: "hands_busy", ok: false });
|
|
3264
3280
|
return true;
|
|
3265
3281
|
}
|
|
@@ -3270,15 +3286,28 @@ var GameInteractables = (() => {
|
|
|
3270
3286
|
return scrubbed >= seconds;
|
|
3271
3287
|
};
|
|
3272
3288
|
const running = waterOf(use);
|
|
3289
|
+
let sinceRinsePlay = Infinity;
|
|
3290
|
+
let clean = false;
|
|
3273
3291
|
const rinse = (dt) => {
|
|
3274
3292
|
const flow = running(dt);
|
|
3275
3293
|
if (flow === null) {
|
|
3276
3294
|
fail({ key: "no_water", ok: false });
|
|
3277
3295
|
return true;
|
|
3278
3296
|
}
|
|
3279
|
-
if (
|
|
3280
|
-
|
|
3281
|
-
|
|
3297
|
+
if (use.rinse && !clean && sinceRinsePlay >= use.rinse.seconds) {
|
|
3298
|
+
if (!body.playUse(use.rinse.clip, item?.objectId, underStream(use))) {
|
|
3299
|
+
fail({ key: "hands_busy", ok: false });
|
|
3300
|
+
return true;
|
|
3301
|
+
}
|
|
3302
|
+
sinceRinsePlay = 0;
|
|
3303
|
+
}
|
|
3304
|
+
sinceRinsePlay += dt;
|
|
3305
|
+
if (!clean) {
|
|
3306
|
+
if (flow <= 0 || body.rinse(id, flow, dt) > 0) return false;
|
|
3307
|
+
clean = true;
|
|
3308
|
+
if (dirt > 0) body.setDirt?.(id, 0);
|
|
3309
|
+
}
|
|
3310
|
+
return !use.rinse || sinceRinsePlay >= use.rinse.seconds;
|
|
3282
3311
|
};
|
|
3283
3312
|
return [scrub, rinse];
|
|
3284
3313
|
};
|
|
@@ -3290,15 +3319,24 @@ var GameInteractables = (() => {
|
|
|
3290
3319
|
};
|
|
3291
3320
|
const tap = tapPhases(use);
|
|
3292
3321
|
const dosed = use.dose ? items[use.dose.need] : void 0;
|
|
3293
|
-
const
|
|
3322
|
+
const waterForDose = waterOf(use);
|
|
3323
|
+
const dose = (dt) => {
|
|
3324
|
+
const flow = waterForDose(dt);
|
|
3325
|
+
if (flow === null) {
|
|
3326
|
+
fail({ key: "no_water", ok: false });
|
|
3327
|
+
return true;
|
|
3328
|
+
}
|
|
3329
|
+
if (flow <= 0) return false;
|
|
3294
3330
|
if (dosed && body.takeDose?.(dosed.objectId, use.dose?.amount).taken === 0) fail({ key: "item_spent", ok: false, vars: { item: dosed.name } });
|
|
3295
3331
|
return true;
|
|
3296
3332
|
};
|
|
3333
|
+
const tool = use.dishes ? void 0 : items[0];
|
|
3297
3334
|
const dishes = use.dishes ? dirtyDishes(use, spec, host) : [];
|
|
3298
3335
|
const rack = use.dishes?.rack ?? [];
|
|
3299
|
-
const work = use.dishes ? dishes.flatMap((dish, index) => [...scrubAndRinse(use, body, dish, fail), placePhase(host, dish, rack[Math.min(index, rack.length - 1)])]) : scrubAndRinse(use, body, use.surface, fail);
|
|
3336
|
+
const work = use.dishes ? dishes.flatMap((dish, index) => [...scrubAndRinse(use, body, dish, fail), placePhase(host, dish, rack[Math.min(index, rack.length - 1)])]) : scrubAndRinse(use, body, use.surface, fail, tool);
|
|
3300
3337
|
const guarded = work.map((phase) => (dt) => end !== null || phase(dt));
|
|
3301
|
-
const
|
|
3338
|
+
const giveBack = tool?.where === "reach" ? placePhase(host, tool, tool.at) : () => true;
|
|
3339
|
+
const run = runPhases([approachPhase(use, host), tap.open, dose, ...guarded, tap.close, giveBack]);
|
|
3302
3340
|
const done = use.dishes ? { key: "done_wash_dishes", ok: true, vars: { n: String(dishes.length) } } : { key: "done_wash", ok: true, vars: { surface: use.surface } };
|
|
3303
3341
|
return { use: use.id, step: (dt) => run(dt) ? end ?? done : null };
|
|
3304
3342
|
};
|