@adatechnology/game-interactables 0.10.0 → 0.11.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 +134 -3
- package/dist/index.global.js +284 -16
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +284 -16
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -220,7 +220,19 @@ var locales = {
|
|
|
220
220
|
done_program_stop: "{name} stopped",
|
|
221
221
|
done_relieve_urine: "You peed in {name}",
|
|
222
222
|
done_relieve_feces: "You pooed in {name}",
|
|
223
|
-
done_clean: "{name} flushed clean"
|
|
223
|
+
done_clean: "{name} flushed clean",
|
|
224
|
+
"use.wash_dishes": "Wash the dishes",
|
|
225
|
+
"use.drink_water": "Drink water",
|
|
226
|
+
busy: "Already in use",
|
|
227
|
+
needs_running: "Turn the water on first",
|
|
228
|
+
needs_item: "You need {need}",
|
|
229
|
+
item_spent: "{item} is empty",
|
|
230
|
+
no_dirty_dishes: "No dirty dishes in the sink",
|
|
231
|
+
started_wash: "{label}\u2026",
|
|
232
|
+
started_drink: "{label}\u2026",
|
|
233
|
+
done_wash: "Washed and rinsed",
|
|
234
|
+
done_wash_dishes: "Dishes washed: {n} on the rack",
|
|
235
|
+
done_drink: "You drank {litres} l of water"
|
|
224
236
|
},
|
|
225
237
|
"pt-BR": {
|
|
226
238
|
"prompt.open": "Abrir {name}",
|
|
@@ -273,7 +285,19 @@ var locales = {
|
|
|
273
285
|
done_program_stop: "{name} parou",
|
|
274
286
|
done_relieve_urine: "Voc\xEA fez xixi em {name}",
|
|
275
287
|
done_relieve_feces: "Voc\xEA fez coc\xF4 em {name}",
|
|
276
|
-
done_clean: "Descarga dada: {name} limpo"
|
|
288
|
+
done_clean: "Descarga dada: {name} limpo",
|
|
289
|
+
"use.wash_dishes": "Lavar a lou\xE7a",
|
|
290
|
+
"use.drink_water": "Beber \xE1gua",
|
|
291
|
+
busy: "J\xE1 est\xE1 em uso",
|
|
292
|
+
needs_running: "Abra a \xE1gua primeiro",
|
|
293
|
+
needs_item: "Precisa de {need}",
|
|
294
|
+
item_spent: "{item} acabou",
|
|
295
|
+
no_dirty_dishes: "N\xE3o h\xE1 lou\xE7a suja na pia",
|
|
296
|
+
started_wash: "{label}\u2026",
|
|
297
|
+
started_drink: "{label}\u2026",
|
|
298
|
+
done_wash: "Lavado e enxaguado",
|
|
299
|
+
done_wash_dishes: "Lou\xE7a lavada: {n} no escorredor",
|
|
300
|
+
done_drink: "Voc\xEA bebeu {litres} l de \xE1gua"
|
|
277
301
|
}
|
|
278
302
|
};
|
|
279
303
|
function pickLocale(locale) {
|
|
@@ -2434,6 +2458,29 @@ function wireRuns(params) {
|
|
|
2434
2458
|
return runs;
|
|
2435
2459
|
}
|
|
2436
2460
|
|
|
2461
|
+
// src/cast-with-member.ts
|
|
2462
|
+
var COLLAR_REACH = 0.03;
|
|
2463
|
+
var END_GAP = 5e-3;
|
|
2464
|
+
function centredOn(member, other) {
|
|
2465
|
+
for (const k of [0, 2]) {
|
|
2466
|
+
if (other[k] < member[k] - COLLAR_REACH || other[k + 3] > member[k + 3] + COLLAR_REACH) return false;
|
|
2467
|
+
if (Math.abs((other[k] + other[k + 3]) / 2 - (member[k] + member[k + 3]) / 2) > COLLAR_REACH) return false;
|
|
2468
|
+
}
|
|
2469
|
+
return true;
|
|
2470
|
+
}
|
|
2471
|
+
function wrapsMember(member, collar) {
|
|
2472
|
+
const overlap2 = Math.min(collar[4], member[4]) - Math.max(collar[1], member[1]);
|
|
2473
|
+
return overlap2 >= (collar[4] - collar[1]) / 2 && centredOn(member, collar);
|
|
2474
|
+
}
|
|
2475
|
+
function endsMember(member, end) {
|
|
2476
|
+
const under = Math.abs(end[4] - member[1]) <= END_GAP;
|
|
2477
|
+
const over = Math.abs(end[1] - member[4]) <= END_GAP;
|
|
2478
|
+
return (under || over) && end[4] - end[1] <= member[4] - member[1] && centredOn(member, end);
|
|
2479
|
+
}
|
|
2480
|
+
function castWithMember(member, other) {
|
|
2481
|
+
return wrapsMember(member, other) || endsMember(member, other);
|
|
2482
|
+
}
|
|
2483
|
+
|
|
2437
2484
|
// src/fits-volume.ts
|
|
2438
2485
|
function fitsInVolume(size, half) {
|
|
2439
2486
|
const thing = [...size].sort((a, b) => b - a);
|
|
@@ -2441,6 +2488,183 @@ function fitsInVolume(size, half) {
|
|
|
2441
2488
|
return thing.every((side, i) => side <= (room[i] ?? 0));
|
|
2442
2489
|
}
|
|
2443
2490
|
|
|
2491
|
+
// src/sink-uses.ts
|
|
2492
|
+
var WASH_SCRUB_SECONDS = 3;
|
|
2493
|
+
var DRINK_LITRES = 0.25;
|
|
2494
|
+
var FILL_SHARE = 0.85;
|
|
2495
|
+
var DRINK_LPS = 0.06;
|
|
2496
|
+
var REACH_SECONDS = 0.6;
|
|
2497
|
+
var DRY_SECONDS = 0.5;
|
|
2498
|
+
var SCRUBBED_DIRT = 0.15;
|
|
2499
|
+
var YES = { available: true };
|
|
2500
|
+
var idsOf = (need) => typeof need === "string" ? [need] : need;
|
|
2501
|
+
function findNeeds(needs, host) {
|
|
2502
|
+
const items = [];
|
|
2503
|
+
for (const need of needs) {
|
|
2504
|
+
const item = host.itemAt?.(idsOf(need)) ?? null;
|
|
2505
|
+
if (!item) return { items, missing: idsOf(need) };
|
|
2506
|
+
items.push(item);
|
|
2507
|
+
}
|
|
2508
|
+
return { items };
|
|
2509
|
+
}
|
|
2510
|
+
function dirtyDishes(use, spec, host) {
|
|
2511
|
+
const dishes = use.dishes;
|
|
2512
|
+
const basin = dishes ? (spec.basins ?? []).find((b) => b.id === dishes.basin) : void 0;
|
|
2513
|
+
if (!dishes || !basin) return [];
|
|
2514
|
+
return (host.itemsInside?.(dishes.ids, basin.from, basin.to) ?? []).filter((item) => (item.dirt ?? 0) > 0);
|
|
2515
|
+
}
|
|
2516
|
+
function sinkVerdict(use, spec, host, flowing) {
|
|
2517
|
+
if (use.do === "wash" && use.requiresFlowing && !flowing) return { available: false, reason: "needs_running" };
|
|
2518
|
+
const found = findNeeds(use.needs ?? [], host);
|
|
2519
|
+
if (found.missing) return { available: false, reason: "needs_item", vars: { need: found.missing[0] ?? "" } };
|
|
2520
|
+
if (use.do === "drink") return YES;
|
|
2521
|
+
const dosed = use.dose ? found.items[use.dose.need] : void 0;
|
|
2522
|
+
if (dosed && (dosed.remaining ?? 1) <= 0) return { available: false, reason: "item_spent", vars: { item: dosed.name } };
|
|
2523
|
+
if (use.dishes && dirtyDishes(use, spec, host).length === 0) return { available: false, reason: "no_dirty_dishes" };
|
|
2524
|
+
return YES;
|
|
2525
|
+
}
|
|
2526
|
+
var fixtureFlowLps = (fixture) => fixture ? (fixture.flow ?? FLOW_DEFAULTS[fixture.kind] ?? 6) / 60 : 0;
|
|
2527
|
+
function runPhases(phases) {
|
|
2528
|
+
let index = 0;
|
|
2529
|
+
return (dt) => {
|
|
2530
|
+
if (index < phases.length && phases[index]?.(dt)) index++;
|
|
2531
|
+
return index >= phases.length;
|
|
2532
|
+
};
|
|
2533
|
+
}
|
|
2534
|
+
function wait(seconds) {
|
|
2535
|
+
let left = seconds;
|
|
2536
|
+
return (dt) => (left -= dt) <= 0;
|
|
2537
|
+
}
|
|
2538
|
+
function placePhase(host, item, spot) {
|
|
2539
|
+
return () => {
|
|
2540
|
+
if (spot) host.placeItem?.(item.objectId, [spot[0], spot[1], spot[2]]);
|
|
2541
|
+
return true;
|
|
2542
|
+
};
|
|
2543
|
+
}
|
|
2544
|
+
function createSinkRoutines(options) {
|
|
2545
|
+
const { spec, world, objectId } = options;
|
|
2546
|
+
const fixtureOf = (id) => (spec.fixtures ?? []).find((f) => f.id === id);
|
|
2547
|
+
const flowing = (use) => world.water.isFlowing(objectId, use.fixture);
|
|
2548
|
+
const water = (use) => flowing(use) ? fixtureFlowLps(fixtureOf(use.fixture)) : 0;
|
|
2549
|
+
const waterOf = (use) => {
|
|
2550
|
+
let dry = 0;
|
|
2551
|
+
return (dt) => {
|
|
2552
|
+
const flow = water(use);
|
|
2553
|
+
dry = flow > 0 ? 0 : dry + dt;
|
|
2554
|
+
return dry > DRY_SECONDS ? null : flow;
|
|
2555
|
+
};
|
|
2556
|
+
};
|
|
2557
|
+
const tapPhases = (use) => {
|
|
2558
|
+
let opened = false;
|
|
2559
|
+
const reach = wait(REACH_SECONDS);
|
|
2560
|
+
return {
|
|
2561
|
+
open: (dt) => {
|
|
2562
|
+
if (opened || use.opensFixture === false || flowing(use)) return true;
|
|
2563
|
+
if (!reach(dt)) return false;
|
|
2564
|
+
opened = world.setFixture(objectId, use.fixture, true);
|
|
2565
|
+
return true;
|
|
2566
|
+
},
|
|
2567
|
+
close: () => {
|
|
2568
|
+
if (opened) world.setFixture(objectId, use.fixture, false);
|
|
2569
|
+
return true;
|
|
2570
|
+
}
|
|
2571
|
+
};
|
|
2572
|
+
};
|
|
2573
|
+
const scrubAndRinse = (use, host, target, fail) => {
|
|
2574
|
+
const item = typeof target === "string" ? void 0 : target;
|
|
2575
|
+
const id = item?.objectId ?? target;
|
|
2576
|
+
const seconds = use.scrubSeconds ?? WASH_SCRUB_SECONDS;
|
|
2577
|
+
const dirt = item?.dirt ?? 0;
|
|
2578
|
+
let scrubbed = -1;
|
|
2579
|
+
const scrub = (dt) => {
|
|
2580
|
+
if (scrubbed < 0) {
|
|
2581
|
+
scrubbed = 0;
|
|
2582
|
+
host.playUse?.(use.clip, item?.objectId);
|
|
2583
|
+
}
|
|
2584
|
+
scrubbed = Math.min(seconds, scrubbed + dt);
|
|
2585
|
+
host.lather?.(id, dt / seconds);
|
|
2586
|
+
if (dirt > 0) host.setDirt?.(id, dirt - (dirt - Math.min(dirt, SCRUBBED_DIRT)) * (scrubbed / seconds));
|
|
2587
|
+
return scrubbed >= seconds;
|
|
2588
|
+
};
|
|
2589
|
+
const running = waterOf(use);
|
|
2590
|
+
const rinse = (dt) => {
|
|
2591
|
+
const flow = running(dt);
|
|
2592
|
+
if (flow === null) {
|
|
2593
|
+
fail({ key: "no_water", ok: false });
|
|
2594
|
+
return true;
|
|
2595
|
+
}
|
|
2596
|
+
if (flow <= 0 || (host.rinse?.(id, flow, dt) ?? 0) > 0) return false;
|
|
2597
|
+
if (dirt > 0) host.setDirt?.(id, 0);
|
|
2598
|
+
return true;
|
|
2599
|
+
};
|
|
2600
|
+
return [scrub, rinse];
|
|
2601
|
+
};
|
|
2602
|
+
const startWash = (use, host) => {
|
|
2603
|
+
const { items } = findNeeds(use.needs ?? [], host);
|
|
2604
|
+
let end = null;
|
|
2605
|
+
const fail = (reason) => {
|
|
2606
|
+
end ?? (end = reason);
|
|
2607
|
+
};
|
|
2608
|
+
const tap = tapPhases(use);
|
|
2609
|
+
const dosed = use.dose ? items[use.dose.need] : void 0;
|
|
2610
|
+
const dose = () => {
|
|
2611
|
+
if (dosed && host.takeDose?.(dosed.objectId, use.dose?.amount).taken === 0) fail({ key: "item_spent", ok: false, vars: { item: dosed.name } });
|
|
2612
|
+
return true;
|
|
2613
|
+
};
|
|
2614
|
+
const dishes = use.dishes ? dirtyDishes(use, spec, host) : [];
|
|
2615
|
+
const rack = use.dishes?.rack ?? [];
|
|
2616
|
+
const work = use.dishes ? dishes.flatMap((dish, index) => [...scrubAndRinse(use, host, dish, fail), placePhase(host, dish, rack[Math.min(index, rack.length - 1)])]) : scrubAndRinse(use, host, use.surface, fail);
|
|
2617
|
+
const guarded = work.map((phase) => (dt) => end !== null || phase(dt));
|
|
2618
|
+
const run = runPhases([tap.open, dose, ...guarded, tap.close]);
|
|
2619
|
+
const done = use.dishes ? { key: "done_wash_dishes", ok: true, vars: { n: String(dishes.length) } } : { key: "done_wash", ok: true, vars: { surface: use.surface } };
|
|
2620
|
+
return { use: use.id, step: (dt) => run(dt) ? end ?? done : null };
|
|
2621
|
+
};
|
|
2622
|
+
const startDrink = (use, host, vessel) => {
|
|
2623
|
+
const tap = tapPhases(use);
|
|
2624
|
+
const want = Math.min(use.litres ?? DRINK_LITRES, (vessel.liquid?.capacity ?? DRINK_LITRES) * FILL_SHARE);
|
|
2625
|
+
let filled = vessel.liquid?.kind === "water" ? vessel.liquid.litres : 0;
|
|
2626
|
+
let drunk = 0;
|
|
2627
|
+
let end = null;
|
|
2628
|
+
const take = () => {
|
|
2629
|
+
if (vessel.where !== "hand" && host.holdItem?.(vessel.objectId) === false) end = { key: "needs_item", ok: false, vars: { need: vessel.itemId } };
|
|
2630
|
+
else host.playUse?.(use.fillClip ?? "fill_cup", vessel.objectId);
|
|
2631
|
+
return true;
|
|
2632
|
+
};
|
|
2633
|
+
const running = waterOf(use);
|
|
2634
|
+
const fill = (dt) => {
|
|
2635
|
+
if (end) return true;
|
|
2636
|
+
const flow = running(dt);
|
|
2637
|
+
if (flow === null) {
|
|
2638
|
+
end = { key: "no_water", ok: false };
|
|
2639
|
+
return true;
|
|
2640
|
+
}
|
|
2641
|
+
if (flow <= 0) return false;
|
|
2642
|
+
const took = host.fillItem?.(vessel.objectId, "water", Math.min(flow * dt, want - filled)) ?? 0;
|
|
2643
|
+
filled += took;
|
|
2644
|
+
return filled >= want - 1e-6 || took <= 0;
|
|
2645
|
+
};
|
|
2646
|
+
let sipping = false;
|
|
2647
|
+
const drink = (dt) => {
|
|
2648
|
+
if (end) return true;
|
|
2649
|
+
if (!sipping) sipping = host.playUse?.(use.clip, vessel.objectId) ?? true;
|
|
2650
|
+
const sip = host.drinkItem?.(vessel.objectId, Math.min(DRINK_LPS * dt, filled - drunk)) ?? 0;
|
|
2651
|
+
drunk += sip;
|
|
2652
|
+
return drunk >= filled - 1e-6 || sip <= 0;
|
|
2653
|
+
};
|
|
2654
|
+
const giveBack = vessel.where === "reach" ? placePhase(host, vessel, vessel.at) : () => true;
|
|
2655
|
+
const run = runPhases([take, tap.open, fill, tap.close, drink, wait(REACH_SECONDS), giveBack]);
|
|
2656
|
+
return { use: use.id, step: (dt) => run(dt) ? end ?? { key: "done_drink", ok: true, vars: { litres: drunk.toFixed(2) } } : null };
|
|
2657
|
+
};
|
|
2658
|
+
return {
|
|
2659
|
+
start(use, host) {
|
|
2660
|
+
if (use.do === "wash") return startWash(use, host);
|
|
2661
|
+
const vessel = findNeeds(use.needs, host).items[0];
|
|
2662
|
+
if (!vessel) return { use: use.id, step: () => ({ key: "needs_item", ok: false, vars: { need: idsOf(use.needs[0] ?? "")[0] ?? "" } }) };
|
|
2663
|
+
return startDrink(use, host, vessel);
|
|
2664
|
+
}
|
|
2665
|
+
};
|
|
2666
|
+
}
|
|
2667
|
+
|
|
2444
2668
|
// src/object-uses.ts
|
|
2445
2669
|
var OPEN = 0.5;
|
|
2446
2670
|
var PREFIX = "use.";
|
|
@@ -2450,7 +2674,7 @@ var clock = (seconds) => {
|
|
|
2450
2674
|
return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`;
|
|
2451
2675
|
};
|
|
2452
2676
|
var accepts = (bowl, hand) => (bowl.accepts ?? []).some((id) => hand.itemId === id || hand.itemId.endsWith(`_${id}`));
|
|
2453
|
-
var
|
|
2677
|
+
var YES2 = { available: true };
|
|
2454
2678
|
var no = (reason) => ({ available: false, reason });
|
|
2455
2679
|
function createUses(options) {
|
|
2456
2680
|
const { spec, world, objectId } = options;
|
|
@@ -2462,6 +2686,8 @@ function createUses(options) {
|
|
|
2462
2686
|
const cleans = new Map((spec.fixtures ?? []).flatMap((f) => f.cleans ? [[f.id, f.cleans]] : []));
|
|
2463
2687
|
let program = null;
|
|
2464
2688
|
let lastHost = null;
|
|
2689
|
+
const sinkRoutines = createSinkRoutines({ spec, world, objectId });
|
|
2690
|
+
let routine = null;
|
|
2465
2691
|
const typeKey = `type.${spec.type}`;
|
|
2466
2692
|
const name = () => {
|
|
2467
2693
|
const text = world.t(typeKey);
|
|
@@ -2473,15 +2699,15 @@ function createUses(options) {
|
|
|
2473
2699
|
switch (use.do) {
|
|
2474
2700
|
case "program":
|
|
2475
2701
|
if (!world.power.isPowered(objectId, use.device)) return no("no_power");
|
|
2476
|
-
return use.access && host.partOpening(use.access) >= OPEN ? no("needs_closed") :
|
|
2702
|
+
return use.access && host.partOpening(use.access) >= OPEN ? no("needs_closed") : YES2;
|
|
2477
2703
|
case "put_in": {
|
|
2478
2704
|
const c = containers.get(use.container);
|
|
2479
2705
|
if (!hand) return no("hand_empty");
|
|
2480
2706
|
if (!c || !accessOpen(host, c.access)) return no("requires_open");
|
|
2481
|
-
return fitsInVolume(hand.size, c.volume.half) ?
|
|
2707
|
+
return fitsInVolume(hand.size, c.volume.half) ? YES2 : no("not_fit");
|
|
2482
2708
|
}
|
|
2483
2709
|
case "empty":
|
|
2484
|
-
return accessOpen(host, containers.get(use.container)?.access) ?
|
|
2710
|
+
return accessOpen(host, containers.get(use.container)?.access) ? YES2 : no("requires_open");
|
|
2485
2711
|
case "fill": {
|
|
2486
2712
|
const bowl = bowls.get(use.bowl);
|
|
2487
2713
|
if (!bowl) return no("empty");
|
|
@@ -2489,12 +2715,23 @@ function createUses(options) {
|
|
|
2489
2715
|
if (!hand) return no("hand_empty");
|
|
2490
2716
|
if (bowl.holds === "water" && hand.liquid?.kind === "water" && hand.liquid.closed) return no("requires_open");
|
|
2491
2717
|
const fits = bowl.holds === "water" ? hand.liquid?.kind === "water" && hand.liquid.litres > 0 : accepts(bowl, hand);
|
|
2492
|
-
return fits ?
|
|
2718
|
+
return fits ? YES2 : no("not_accepted");
|
|
2493
2719
|
}
|
|
2494
2720
|
case "relieve":
|
|
2495
|
-
return
|
|
2721
|
+
return YES2;
|
|
2722
|
+
case "wash":
|
|
2723
|
+
case "drink":
|
|
2724
|
+
return routine ? no("busy") : sinkVerdict(use, spec, host, world.water.isFlowing(objectId, use.fixture));
|
|
2496
2725
|
}
|
|
2497
2726
|
};
|
|
2727
|
+
const itemName = (id) => {
|
|
2728
|
+
const text = world.t(`item.${id}`);
|
|
2729
|
+
return text === `item.${id}` ? id.replace(/_/g, " ") : text;
|
|
2730
|
+
};
|
|
2731
|
+
const reasonOf = (v, use, host) => {
|
|
2732
|
+
const words = { ...textVars(use, host), ...v.vars };
|
|
2733
|
+
return world.t(v.reason, words.need ? { ...words, need: itemName(words.need) } : words);
|
|
2734
|
+
};
|
|
2498
2735
|
const textVars = (use, host) => ({
|
|
2499
2736
|
name: name(),
|
|
2500
2737
|
item: host.hand()?.name ?? "",
|
|
@@ -2527,6 +2764,10 @@ function createUses(options) {
|
|
|
2527
2764
|
soil.set(use.basin, SOIL_RANK[use.kind] > SOIL_RANK[now] ? use.kind : now);
|
|
2528
2765
|
return { ok: true, text: world.t(`done_relieve_${use.kind}`, vars) };
|
|
2529
2766
|
}
|
|
2767
|
+
case "wash":
|
|
2768
|
+
case "drink":
|
|
2769
|
+
routine = sinkRoutines.start(use, host);
|
|
2770
|
+
return { ok: true, text: world.t(`started_${use.do}`, { ...vars, label: world.t(use.label, vars) }) };
|
|
2530
2771
|
}
|
|
2531
2772
|
};
|
|
2532
2773
|
const fill = (bowl, host, vars) => {
|
|
@@ -2541,6 +2782,13 @@ function createUses(options) {
|
|
|
2541
2782
|
program = null;
|
|
2542
2783
|
return world.t("done_program_stop", { name: name() });
|
|
2543
2784
|
};
|
|
2785
|
+
const stepRoutine = (dt) => {
|
|
2786
|
+
const end = routine?.step(dt);
|
|
2787
|
+
if (!end) return;
|
|
2788
|
+
routine = null;
|
|
2789
|
+
const words = end.vars?.need ? { ...end.vars, need: itemName(end.vars.need) } : end.vars;
|
|
2790
|
+
lastHost?.say(world.t(end.key, { name: name(), ...words }));
|
|
2791
|
+
};
|
|
2544
2792
|
const visible = (use) => use.do !== "program" || program === null;
|
|
2545
2793
|
return {
|
|
2546
2794
|
has: (id) => id.startsWith(PREFIX),
|
|
@@ -2550,7 +2798,7 @@ function createUses(options) {
|
|
|
2550
2798
|
if (program) entries.push({ id: `${PREFIX}stop`, label: world.t("use.program.stop", { name: name(), left: clock(program.left) }), available: true });
|
|
2551
2799
|
for (const use of all.filter(visible)) {
|
|
2552
2800
|
const v = verdict(use, host);
|
|
2553
|
-
entries.push({ id: `${PREFIX}${use.id}`, label: labelOf(use, host), available: v.available, ...v.available ? {} : { reason:
|
|
2801
|
+
entries.push({ id: `${PREFIX}${use.id}`, label: labelOf(use, host), available: v.available, ...v.available ? {} : { reason: reasonOf(v, use, host) } });
|
|
2554
2802
|
}
|
|
2555
2803
|
return entries;
|
|
2556
2804
|
},
|
|
@@ -2560,9 +2808,10 @@ function createUses(options) {
|
|
|
2560
2808
|
const use = all.find((u) => `${PREFIX}${u.id}` === id);
|
|
2561
2809
|
if (!use || !visible(use)) return { ok: false, text: "" };
|
|
2562
2810
|
const v = verdict(use, host);
|
|
2563
|
-
return v.available ? runUse(use, host) : { ok: false, text:
|
|
2811
|
+
return v.available ? runUse(use, host) : { ok: false, text: reasonOf(v, use, host) };
|
|
2564
2812
|
},
|
|
2565
2813
|
update(dt) {
|
|
2814
|
+
stepRoutine(dt);
|
|
2566
2815
|
if (!program) return;
|
|
2567
2816
|
program.left -= dt;
|
|
2568
2817
|
if (program.left > 0) return;
|
|
@@ -2580,7 +2829,8 @@ function createUses(options) {
|
|
|
2580
2829
|
state: () => ({
|
|
2581
2830
|
bowls: Object.fromEntries(level),
|
|
2582
2831
|
soil: Object.fromEntries(soil),
|
|
2583
|
-
program: program ? { use: program.use.id, device: program.use.device, left: program.left } : null
|
|
2832
|
+
program: program ? { use: program.use.id, device: program.use.device, left: program.left } : null,
|
|
2833
|
+
routine: routine?.use ?? null
|
|
2584
2834
|
})
|
|
2585
2835
|
};
|
|
2586
2836
|
}
|
|
@@ -2591,9 +2841,9 @@ var MAINS = "mains";
|
|
|
2591
2841
|
var MAINS_TANK = "water";
|
|
2592
2842
|
var HOST_KINDS = /* @__PURE__ */ new Set(["toggle_part", "open_container", "take", "read", "sit", "toggle_breaker"]);
|
|
2593
2843
|
var PLUG_FALLBACK = [0, 0.3, 0];
|
|
2594
|
-
function mainsSpec(spec) {
|
|
2844
|
+
function mainsSpec(spec, water) {
|
|
2595
2845
|
const plugged = (spec.devices ?? []).filter((d) => d.socket !== void 0 && !d.circuit);
|
|
2596
|
-
return { type: MAINS, sockets: plugged.map((d, i) => ({ id: `socket_${i}`, pos: d.plug ?? PLUG_FALLBACK })), tanks: [{ id: MAINS_TANK, capacity: 1e9 }] };
|
|
2846
|
+
return { type: MAINS, sockets: plugged.map((d, i) => ({ id: `socket_${i}`, pos: d.plug ?? PLUG_FALLBACK })), tanks: water ? [{ id: MAINS_TANK, capacity: 1e9 }] : [] };
|
|
2597
2847
|
}
|
|
2598
2848
|
function createObjectControls(options) {
|
|
2599
2849
|
const { spec } = options;
|
|
@@ -2616,8 +2866,9 @@ function createObjectControls(options) {
|
|
|
2616
2866
|
forwarded.set(part, open);
|
|
2617
2867
|
host?.setPart(part, open);
|
|
2618
2868
|
};
|
|
2619
|
-
|
|
2620
|
-
|
|
2869
|
+
const piped = options.mains?.water ?? true;
|
|
2870
|
+
world.add(MAINS, mainsSpec(spec, piped), { x: 0, y: 0, z: 0, ry: 0 });
|
|
2871
|
+
if (piped) world.water.setDefaultTank(`${MAINS}:${MAINS_TANK}`);
|
|
2621
2872
|
world.add(CONTROLLED_OBJECT, spec, { x: 0, y: 0, z: 0, ry: 0 });
|
|
2622
2873
|
const uses = createUses({ spec, world, objectId: CONTROLLED_OBJECT });
|
|
2623
2874
|
const programmedDevices = new Set((spec.uses ?? []).flatMap((u) => u.do === "program" ? [u.device] : []));
|
|
@@ -2664,19 +2915,34 @@ function createObjectControls(options) {
|
|
|
2664
2915
|
};
|
|
2665
2916
|
}
|
|
2666
2917
|
export {
|
|
2918
|
+
COLLAR_REACH,
|
|
2667
2919
|
CONTROLLED_OBJECT,
|
|
2920
|
+
DRINK_LITRES,
|
|
2921
|
+
DRINK_LPS,
|
|
2922
|
+
DRY_SECONDS,
|
|
2923
|
+
END_GAP,
|
|
2924
|
+
FILL_SHARE,
|
|
2925
|
+
FLOW_DEFAULTS,
|
|
2668
2926
|
FLUSH_RUN_SECONDS,
|
|
2927
|
+
REACH_SECONDS,
|
|
2928
|
+
WASH_SCRUB_SECONDS,
|
|
2669
2929
|
alignY,
|
|
2670
2930
|
buildChain,
|
|
2931
|
+
castWithMember,
|
|
2671
2932
|
chainPoints,
|
|
2672
2933
|
createEnginePartPhysics,
|
|
2673
2934
|
createFixtureEmitters,
|
|
2674
2935
|
createObjectControls,
|
|
2936
|
+
createSinkRoutines,
|
|
2675
2937
|
createWorld,
|
|
2938
|
+
dirtyDishes,
|
|
2676
2939
|
disposeChain,
|
|
2940
|
+
endsMember,
|
|
2941
|
+
findNeeds,
|
|
2677
2942
|
fitsInVolume,
|
|
2678
2943
|
fitsSize,
|
|
2679
2944
|
fitsSlot,
|
|
2945
|
+
fixtureFlowLps,
|
|
2680
2946
|
format,
|
|
2681
2947
|
generateLoot,
|
|
2682
2948
|
hangTail,
|
|
@@ -2691,9 +2957,11 @@ export {
|
|
|
2691
2957
|
rng,
|
|
2692
2958
|
rotY,
|
|
2693
2959
|
rotateAxis,
|
|
2960
|
+
sinkVerdict,
|
|
2694
2961
|
solveSpan,
|
|
2695
2962
|
spanStrength,
|
|
2696
2963
|
wireRuns,
|
|
2697
|
-
worldToLocal
|
|
2964
|
+
worldToLocal,
|
|
2965
|
+
wrapsMember
|
|
2698
2966
|
};
|
|
2699
2967
|
//# sourceMappingURL=index.js.map
|