@adatechnology/game-interactables 0.14.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 +8 -0
- package/dist/index.global.js +22 -7
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +22 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -3088,7 +3088,7 @@ function createSinkRoutines(options) {
|
|
|
3088
3088
|
}
|
|
3089
3089
|
};
|
|
3090
3090
|
};
|
|
3091
|
-
const scrubAndRinse = (use, body, target, fail) => {
|
|
3091
|
+
const scrubAndRinse = (use, body, target, fail, tool) => {
|
|
3092
3092
|
const item = typeof target === "string" ? void 0 : target;
|
|
3093
3093
|
const id = item?.objectId ?? target;
|
|
3094
3094
|
const seconds = use.scrubSeconds ?? WASH_SCRUB_SECONDS;
|
|
@@ -3097,7 +3097,7 @@ function createSinkRoutines(options) {
|
|
|
3097
3097
|
const scrub = (dt) => {
|
|
3098
3098
|
if (scrubbed < 0) {
|
|
3099
3099
|
scrubbed = 0;
|
|
3100
|
-
if (!body.playUse(use.clip, item?.objectId, underStream(use))) {
|
|
3100
|
+
if (!body.playUse(use.clip, (item ?? tool)?.objectId, underStream(use))) {
|
|
3101
3101
|
fail({ key: "hands_busy", ok: false });
|
|
3102
3102
|
return true;
|
|
3103
3103
|
}
|
|
@@ -3108,15 +3108,28 @@ function createSinkRoutines(options) {
|
|
|
3108
3108
|
return scrubbed >= seconds;
|
|
3109
3109
|
};
|
|
3110
3110
|
const running = waterOf(use);
|
|
3111
|
+
let sinceRinsePlay = Infinity;
|
|
3112
|
+
let clean = false;
|
|
3111
3113
|
const rinse = (dt) => {
|
|
3112
3114
|
const flow = running(dt);
|
|
3113
3115
|
if (flow === null) {
|
|
3114
3116
|
fail({ key: "no_water", ok: false });
|
|
3115
3117
|
return true;
|
|
3116
3118
|
}
|
|
3117
|
-
if (
|
|
3118
|
-
|
|
3119
|
-
|
|
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;
|
|
3120
3133
|
};
|
|
3121
3134
|
return [scrub, rinse];
|
|
3122
3135
|
};
|
|
@@ -3139,11 +3152,13 @@ function createSinkRoutines(options) {
|
|
|
3139
3152
|
if (dosed && body.takeDose?.(dosed.objectId, use.dose?.amount).taken === 0) fail({ key: "item_spent", ok: false, vars: { item: dosed.name } });
|
|
3140
3153
|
return true;
|
|
3141
3154
|
};
|
|
3155
|
+
const tool = use.dishes ? void 0 : items[0];
|
|
3142
3156
|
const dishes = use.dishes ? dirtyDishes(use, spec, host) : [];
|
|
3143
3157
|
const rack = use.dishes?.rack ?? [];
|
|
3144
|
-
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);
|
|
3145
3159
|
const guarded = work.map((phase) => (dt) => end !== null || phase(dt));
|
|
3146
|
-
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]);
|
|
3147
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 } };
|
|
3148
3163
|
return { use: use.id, step: (dt) => run(dt) ? end ?? done : null };
|
|
3149
3164
|
};
|