@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.js
CHANGED
|
@@ -353,9 +353,14 @@ function fitsSize(size, max) {
|
|
|
353
353
|
if (size[1] > max[1] + eps) return false;
|
|
354
354
|
return size[0] <= max[0] + eps && size[2] <= max[2] + eps || size[2] <= max[0] + eps && size[0] <= max[2] + eps;
|
|
355
355
|
}
|
|
356
|
+
function laidSize(size, lay) {
|
|
357
|
+
if (lay === "x") return [size[1], size[0], size[2]];
|
|
358
|
+
if (lay === "z") return [size[0], size[2], size[1]];
|
|
359
|
+
return size;
|
|
360
|
+
}
|
|
356
361
|
function fitsSlot(type, slot, items) {
|
|
357
362
|
const def = items?.[type];
|
|
358
|
-
return def ? fitsSize(def.size, slot.max) : true;
|
|
363
|
+
return def ? fitsSize(laidSize(def.size, slot.lay), slot.max) : true;
|
|
359
364
|
}
|
|
360
365
|
function generateLoot(tables, tableId, slots, seed, items) {
|
|
361
366
|
const table = tables?.[tableId];
|
|
@@ -445,6 +450,10 @@ var locales = {
|
|
|
445
450
|
"use.wash_dishes": "Wash the dishes",
|
|
446
451
|
"use.drink_water": "Drink water from the glass",
|
|
447
452
|
"use.drink_from_hands": "Drink water from your hands",
|
|
453
|
+
"use.lather_body": "Soap yourself",
|
|
454
|
+
"use.shampoo_hair": "Shampoo your hair",
|
|
455
|
+
"use.wash_hands": "Wash your hands",
|
|
456
|
+
"use.brush_teeth": "Brush your teeth",
|
|
448
457
|
needs_in_hand: "Pick up {item} first",
|
|
449
458
|
needs_vessel: "You need a glass",
|
|
450
459
|
vessel_not_empty: "Empty {item} first",
|
|
@@ -534,6 +543,10 @@ var locales = {
|
|
|
534
543
|
"use.wash_dishes": "Lavar a lou\xE7a",
|
|
535
544
|
"use.drink_water": "Beber \xE1gua no copo",
|
|
536
545
|
"use.drink_from_hands": "Beber \xE1gua com a m\xE3o",
|
|
546
|
+
"use.lather_body": "Ensaboar-se",
|
|
547
|
+
"use.shampoo_hair": "Passar shampoo",
|
|
548
|
+
"use.wash_hands": "Lavar as m\xE3os",
|
|
549
|
+
"use.brush_teeth": "Escovar os dentes",
|
|
537
550
|
needs_in_hand: "Pegue {item} antes",
|
|
538
551
|
needs_vessel: "Precisa de um copo",
|
|
539
552
|
vessel_not_empty: "Esvazie {item} antes",
|
|
@@ -3075,7 +3088,7 @@ function createSinkRoutines(options) {
|
|
|
3075
3088
|
}
|
|
3076
3089
|
};
|
|
3077
3090
|
};
|
|
3078
|
-
const scrubAndRinse = (use, body, target, fail) => {
|
|
3091
|
+
const scrubAndRinse = (use, body, target, fail, tool) => {
|
|
3079
3092
|
const item = typeof target === "string" ? void 0 : target;
|
|
3080
3093
|
const id = item?.objectId ?? target;
|
|
3081
3094
|
const seconds = use.scrubSeconds ?? WASH_SCRUB_SECONDS;
|
|
@@ -3084,7 +3097,7 @@ function createSinkRoutines(options) {
|
|
|
3084
3097
|
const scrub = (dt) => {
|
|
3085
3098
|
if (scrubbed < 0) {
|
|
3086
3099
|
scrubbed = 0;
|
|
3087
|
-
if (!body.playUse(use.clip, item?.objectId, underStream(use))) {
|
|
3100
|
+
if (!body.playUse(use.clip, (item ?? tool)?.objectId, underStream(use))) {
|
|
3088
3101
|
fail({ key: "hands_busy", ok: false });
|
|
3089
3102
|
return true;
|
|
3090
3103
|
}
|
|
@@ -3095,15 +3108,28 @@ function createSinkRoutines(options) {
|
|
|
3095
3108
|
return scrubbed >= seconds;
|
|
3096
3109
|
};
|
|
3097
3110
|
const running = waterOf(use);
|
|
3111
|
+
let sinceRinsePlay = Infinity;
|
|
3112
|
+
let clean = false;
|
|
3098
3113
|
const rinse = (dt) => {
|
|
3099
3114
|
const flow = running(dt);
|
|
3100
3115
|
if (flow === null) {
|
|
3101
3116
|
fail({ key: "no_water", ok: false });
|
|
3102
3117
|
return true;
|
|
3103
3118
|
}
|
|
3104
|
-
if (
|
|
3105
|
-
|
|
3106
|
-
|
|
3119
|
+
if (use.rinse && !clean && sinceRinsePlay >= use.rinse.seconds) {
|
|
3120
|
+
if (!body.playUse(use.rinse.clip, item?.objectId, underStream(use))) {
|
|
3121
|
+
fail({ key: "hands_busy", ok: false });
|
|
3122
|
+
return true;
|
|
3123
|
+
}
|
|
3124
|
+
sinceRinsePlay = 0;
|
|
3125
|
+
}
|
|
3126
|
+
sinceRinsePlay += dt;
|
|
3127
|
+
if (!clean) {
|
|
3128
|
+
if (flow <= 0 || body.rinse(id, flow, dt) > 0) return false;
|
|
3129
|
+
clean = true;
|
|
3130
|
+
if (dirt > 0) body.setDirt?.(id, 0);
|
|
3131
|
+
}
|
|
3132
|
+
return !use.rinse || sinceRinsePlay >= use.rinse.seconds;
|
|
3107
3133
|
};
|
|
3108
3134
|
return [scrub, rinse];
|
|
3109
3135
|
};
|
|
@@ -3115,15 +3141,24 @@ function createSinkRoutines(options) {
|
|
|
3115
3141
|
};
|
|
3116
3142
|
const tap = tapPhases(use);
|
|
3117
3143
|
const dosed = use.dose ? items[use.dose.need] : void 0;
|
|
3118
|
-
const
|
|
3144
|
+
const waterForDose = waterOf(use);
|
|
3145
|
+
const dose = (dt) => {
|
|
3146
|
+
const flow = waterForDose(dt);
|
|
3147
|
+
if (flow === null) {
|
|
3148
|
+
fail({ key: "no_water", ok: false });
|
|
3149
|
+
return true;
|
|
3150
|
+
}
|
|
3151
|
+
if (flow <= 0) return false;
|
|
3119
3152
|
if (dosed && body.takeDose?.(dosed.objectId, use.dose?.amount).taken === 0) fail({ key: "item_spent", ok: false, vars: { item: dosed.name } });
|
|
3120
3153
|
return true;
|
|
3121
3154
|
};
|
|
3155
|
+
const tool = use.dishes ? void 0 : items[0];
|
|
3122
3156
|
const dishes = use.dishes ? dirtyDishes(use, spec, host) : [];
|
|
3123
3157
|
const rack = use.dishes?.rack ?? [];
|
|
3124
|
-
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);
|
|
3158
|
+
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);
|
|
3125
3159
|
const guarded = work.map((phase) => (dt) => end !== null || phase(dt));
|
|
3126
|
-
const
|
|
3160
|
+
const giveBack = tool?.where === "reach" ? placePhase(host, tool, tool.at) : () => true;
|
|
3161
|
+
const run = runPhases([approachPhase(use, host), tap.open, dose, ...guarded, tap.close, giveBack]);
|
|
3127
3162
|
const done = use.dishes ? { key: "done_wash_dishes", ok: true, vars: { n: String(dishes.length) } } : { key: "done_wash", ok: true, vars: { surface: use.surface } };
|
|
3128
3163
|
return { use: use.id, step: (dt) => run(dt) ? end ?? done : null };
|
|
3129
3164
|
};
|
|
@@ -3595,6 +3630,7 @@ export {
|
|
|
3595
3630
|
generateLoot,
|
|
3596
3631
|
hangTail,
|
|
3597
3632
|
hashString,
|
|
3633
|
+
laidSize,
|
|
3598
3634
|
localToWorld,
|
|
3599
3635
|
locales,
|
|
3600
3636
|
mergeColliders,
|