@adatechnology/game-items-three 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.
@@ -95,6 +95,8 @@ var GameItemsThree = (() => {
95
95
  triangleBudgetOf: () => triangleBudgetOf,
96
96
  turnItem: () => turnItem,
97
97
  unregisterItemModel: () => unregisterItemModel,
98
+ wearOfAge: () => wearOfAge,
99
+ wearOfFreshness: () => wearOfFreshness,
98
100
  wearableMaterials: () => wearableMaterials
99
101
  });
100
102
 
@@ -372,6 +374,8 @@ var GameItemsThree = (() => {
372
374
  function drainDetached(queue, budgetMs, clock = () => performance.now()) {
373
375
  return queue.run(clock() + budgetMs, clock);
374
376
  }
377
+ var BODY_FOAM_SURFACES = ["hands", "arms", "torso", "hair", "mouth"];
378
+ var WASH_SURFACES = [...BODY_FOAM_SURFACES, "brush"];
375
379
  var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
376
380
  var warnedKeys = () => {
377
381
  const holder = globalThis;
@@ -2365,7 +2369,430 @@ var GameItemsThree = (() => {
2365
2369
  };
2366
2370
  }
2367
2371
 
2372
+ // ../game-interactables/dist/index.js
2373
+ function hashString(text) {
2374
+ let h = 2166136261;
2375
+ for (let i = 0; i < text.length; i++) {
2376
+ h ^= text.charCodeAt(i);
2377
+ h = Math.imul(h, 16777619);
2378
+ }
2379
+ return h >>> 0;
2380
+ }
2381
+ function rng(seed = 1) {
2382
+ let a = (typeof seed === "number" ? Math.floor(seed) >>> 0 : hashString(seed)) || 2654435769;
2383
+ return () => {
2384
+ a = a + 1831565813 >>> 0;
2385
+ let t = a;
2386
+ t = Math.imul(t ^ t >>> 15, t | 1);
2387
+ t ^= t + Math.imul(t ^ t >>> 7, t | 61);
2388
+ return ((t ^ t >>> 14) >>> 0) / 4294967296;
2389
+ };
2390
+ }
2391
+ var pose = new Float64Array(7);
2392
+ var pose2 = new Float64Array(7);
2393
+
2394
+ // ../game-items/dist/index.js
2395
+ var DEFAULT_RULES = {
2396
+ rarity: {
2397
+ weights: { common: 60, uncommon: 28, rare: 9, very_rare: 2.5, legendary: 0.5, unique: 0 },
2398
+ fixedOnly: ["legendary", "unique"]
2399
+ },
2400
+ freshness: { stale: 0.5, spoiled: 1, rotten: 1.5 },
2401
+ storage: {
2402
+ fridge: { multiplier: 0.33, needsPower: true },
2403
+ freezer: { multiplier: 0.1, needsPower: true },
2404
+ cooler: { multiplier: 0.5, limitDays: 2, afterLimit: 1 },
2405
+ delivery_bag: { multiplier: 0.8 },
2406
+ cellar: { multiplier: 0.66 },
2407
+ ambient: { multiplier: 1 },
2408
+ hot: { multiplier: 2 }
2409
+ },
2410
+ carry: { baseKg: 8, perStrengthKg: 2.5, factor: 1.2, encumbered: 1, overloaded: 1.5 },
2411
+ protection: { cap: 0.9, wear: { bite: 8, scratch: 3 }, tornShare: 0.25, repairMargin: 10 },
2412
+ aging: { thawShelfDays: { freezer: 2 } },
2413
+ inventory: {
2414
+ defaultSlots: 10,
2415
+ encumberedRunFactor: 0.75,
2416
+ defaultLitres: 12,
2417
+ defaultInside: [0.3, 0.25, 0.16],
2418
+ bagInside: {
2419
+ shopping_bag: [0.4, 0.35, 0.15],
2420
+ trash_bag: [0.6, 0.45, 0.12],
2421
+ fanny_pack: [0.22, 0.12, 0.1],
2422
+ crossbody_bag: [0.25, 0.2, 0.12],
2423
+ backpack: [0.5, 0.3, 0.2],
2424
+ delivery_bag: [0.45, 0.45, 0.25],
2425
+ hiking_backpack_40l: [0.6, 0.35, 0.19],
2426
+ military_backpack: [0.6, 0.35, 0.21],
2427
+ trekking_backpack_70l: [0.75, 0.38, 0.25],
2428
+ rolling_suitcase: [0.6, 0.4, 0.21],
2429
+ tactical_vest: [0.3, 0.2, 0.1],
2430
+ tool_belt: [0.4, 0.2, 0.1],
2431
+ cooler_box: [0.32, 0.25, 0.23],
2432
+ shopping_cart: [0.9, 0.55, 0.16],
2433
+ wheelbarrow: [1.2, 0.6, 0.15]
2434
+ },
2435
+ bagLitres: {
2436
+ shopping_bag: 20,
2437
+ trash_bag: 30,
2438
+ fanny_pack: 3,
2439
+ crossbody_bag: 6,
2440
+ backpack: 30,
2441
+ delivery_bag: 50,
2442
+ hiking_backpack_40l: 40,
2443
+ military_backpack: 45,
2444
+ trekking_backpack_70l: 70,
2445
+ rolling_suitcase: 50,
2446
+ tactical_vest: 6,
2447
+ tool_belt: 8,
2448
+ cooler_box: 18,
2449
+ shopping_cart: 80,
2450
+ wheelbarrow: 100
2451
+ }
2452
+ },
2453
+ use: {
2454
+ freshness: {
2455
+ stale: { satietyFactor: 0.7, poisonChance: 0.1, morale: 0, isEdible: true },
2456
+ spoiled: { satietyFactor: 0.7, poisonChance: 0.5, morale: -20, isEdible: true },
2457
+ rotten: { satietyFactor: 0, poisonChance: 0, morale: 0, isEdible: false }
2458
+ },
2459
+ cookedPoisonFactor: 0.25
2460
+ },
2461
+ spawn: {
2462
+ retailNew: true,
2463
+ retailPlaces: ["supermarket", "pharmacy", "mall", "gas_station", "gun_shop"],
2464
+ retailContainers: ["store_shelf", "stockroom"],
2465
+ condition: { common: [30, 90], uncommon: [40, 90], rare: [50, 100], very_rare: [50, 100], legendary: [50, 100], unique: [50, 100] },
2466
+ ageShare: [0, 0.6],
2467
+ charge: [0.2, 1],
2468
+ fillable: ["fuel_jerrycan"],
2469
+ fill: [0, 0.6]
2470
+ },
2471
+ finds: {
2472
+ fallbackContainer: "zombie_corpse",
2473
+ rollExcluded: ["ammo_7_62x39"],
2474
+ depletion: [
2475
+ { places: ["pharmacy", "gun_shop", "police_station"], perDay: 0.05, floor: 0.3 },
2476
+ { places: ["supermarket", "gas_station"], perDay: 0.04, floor: 0.35 },
2477
+ { places: ["mall", "hospital"], perDay: 0.025, floor: 0.5 },
2478
+ { places: ["house", "apartment"], perDay: 0.01, floor: 0.7 },
2479
+ { places: ["farm", "warehouse", "mine", "dam", "lodge", "church"], perDay: 5e-3, floor: 0.85 },
2480
+ { places: ["military_base"], perDay: 0, floor: 1 }
2481
+ ],
2482
+ regionMultiplier: {},
2483
+ states: { normal: "normal", fortified: "fortified", abandoned: "abandoned" },
2484
+ pool: {
2485
+ defaultFootprint: 0.5,
2486
+ offset: 1.5,
2487
+ perSquareMetre: 3,
2488
+ jitter: 1.5,
2489
+ min: 2,
2490
+ max: 5,
2491
+ fortifiedExtra: 2,
2492
+ supplyWeight: 2.5,
2493
+ supplyExtraQty: 1,
2494
+ abandonedEmptyChance: 0.4,
2495
+ abandonedKept: 1,
2496
+ junkChance: 0.5,
2497
+ junkItem: "food_packaging",
2498
+ spoiledFoodItem: "leftover_meal",
2499
+ coldContainers: ["geladeira", "refrig_exp", "freezer"]
2500
+ }
2501
+ }
2502
+ };
2503
+ var ITEM_CATEGORIES = [
2504
+ { id: "food", name: "Food" },
2505
+ { id: "drink", name: "Drink" },
2506
+ { id: "medical", name: "Medical" },
2507
+ { id: "tools", name: "Tools" },
2508
+ { id: "melee", name: "Melee" },
2509
+ { id: "materials", name: "Materials" },
2510
+ { id: "clothing", name: "Clothing" },
2511
+ { id: "bags", name: "Bags" },
2512
+ { id: "electronics", name: "Electronics" },
2513
+ { id: "fuel", name: "Fuel" },
2514
+ { id: "outdoors", name: "Outdoors" },
2515
+ { id: "books", name: "Books" },
2516
+ { id: "collectibles", name: "Collectibles" },
2517
+ { id: "keys", name: "Keys" }
2518
+ ];
2519
+ var consumableLiters = (spec) => spec?.form === "liquid" && spec.unit === "ml" ? spec.amount / 1e3 : void 0;
2520
+ var itemFluid = (item) => {
2521
+ if (!item.fluid) return void 0;
2522
+ return { liquid: item.fluid.liquid, liters: consumableLiters(item.consumable) ?? item.fluid.liters ?? 0 };
2523
+ };
2524
+ var storageRuleOf = (rules, storage) => {
2525
+ const rule = rules.storage[storage];
2526
+ if (!rule) throw new Error(`game-items: unknown storage "${storage}"`);
2527
+ return rule;
2528
+ };
2529
+ var accruedDays = (storage, window, options) => {
2530
+ const { powered = true, rules = DEFAULT_RULES } = options;
2531
+ const rule = storageRuleOf(rules, storage);
2532
+ const elapsed = window.to - window.from;
2533
+ if (elapsed <= 0) return 0;
2534
+ if (rule.needsPower && !powered) return elapsed;
2535
+ if (rule.limitDays === void 0) return elapsed * rule.multiplier;
2536
+ const limitEnd = window.storedAt + rule.limitDays;
2537
+ const early = Math.max(0, Math.min(window.to, limitEnd) - Math.max(window.from, window.storedAt));
2538
+ return early * rule.multiplier + (elapsed - early) * (rule.afterLimit ?? 1);
2539
+ };
2540
+ var advanceAge = (state, now, options = {}) => {
2541
+ const { powered = true, rules = DEFAULT_RULES } = options;
2542
+ const rule = storageRuleOf(rules, state.storage);
2543
+ const thawDays = rules.aging.thawShelfDays[state.storage];
2544
+ const isThawing = rule.needsPower === true && !powered && thawDays !== void 0 && state.shelfLife === void 0;
2545
+ const base2 = isThawing ? { ...state, ageDays: 0, shelfLife: thawDays } : state;
2546
+ const ageDays = base2.ageDays + accruedDays(state.storage, { storedAt: state.storedAt, from: state.since, to: now }, options);
2547
+ return { ...base2, ageDays, since: Math.max(now, state.since) };
2548
+ };
2549
+ var shelfRatio = (item, state) => {
2550
+ const shelfLife = state.shelfLife ?? item.shelfLife;
2551
+ return shelfLife === void 0 ? 0 : state.ageDays / shelfLife;
2552
+ };
2553
+ var freshness = (item, state, now, options = {}) => {
2554
+ const { rules = DEFAULT_RULES } = options;
2555
+ const ratio = shelfRatio(item, advanceAge(state, now, options));
2556
+ if (ratio >= rules.freshness.rotten) return "rotten";
2557
+ if (ratio >= rules.freshness.spoiled) return "spoiled";
2558
+ if (ratio >= rules.freshness.stale) return "stale";
2559
+ return "fresh";
2560
+ };
2561
+ var FRESH_NUTRITION = { satietyFactor: 1, poisonChance: 0, morale: 0, isEdible: true };
2562
+ var nutritionOf = (item, context, rules) => {
2563
+ const state = context.freshness ?? "fresh";
2564
+ const effect = state === "fresh" ? FRESH_NUTRITION : rules.use.freshness[state];
2565
+ const poisonShare = context.isCooked ? rules.use.cookedPoisonFactor : 1;
2566
+ return {
2567
+ satiety: (item.nutrition?.satiety ?? 0) * effect.satietyFactor,
2568
+ hydration: item.nutrition?.hydration ?? 0,
2569
+ morale: effect.morale,
2570
+ poisonChance: effect.poisonChance * poisonShare,
2571
+ isEdible: effect.isEdible
2572
+ };
2573
+ };
2574
+ var findEffect = (item, effects) => effects.find((entry2) => entry2.items?.includes(item.id)) ?? effects.find((entry2) => entry2.category?.includes(item.category));
2575
+ var resolveUse = (item, effects, context = {}, rules = DEFAULT_RULES) => {
2576
+ const def = findEffect(item, effects);
2577
+ if (!def) return void 0;
2578
+ const base2 = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
2579
+ if (def.effect !== "consume_nutrition") return base2;
2580
+ const nutrition = nutritionOf(item, context, rules);
2581
+ const blocked = item.seal && context.seal ? sealBlock(item.seal, context.seal) : void 0;
2582
+ if (blocked) return { ...base2, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
2583
+ return { ...base2, consumes: def.consumes && nutrition.isEdible, nutrition };
2584
+ };
2585
+ var countOf = (context, id) => context.inventory.get(id) ?? 0;
2586
+ var candidatesOf = (input, context) => {
2587
+ if (input.item !== void 0) return [input.item];
2588
+ if (input.any) return [...input.any];
2589
+ if (!input.match) return [];
2590
+ const { category, cookable } = input.match;
2591
+ return context.catalog.list().filter((item) => (category === void 0 || item.category === category) && (cookable === void 0 || item.cookable === cookable)).map((item) => item.id);
2592
+ };
2593
+ var describeInput = (input) => {
2594
+ if (input.item !== void 0) return `item:${input.item}`;
2595
+ if (input.any) return `any:${input.any.join("|")}`;
2596
+ if (input.match) return `match:${input.match.category ?? "cookable"}`;
2597
+ if (input.fluid !== void 0) return `fluid:${input.fluid}`;
2598
+ return `world:${(input.world ?? []).join("|")}`;
2599
+ };
2600
+ var takeUnits = (candidates, needed, context) => {
2601
+ const taken = [];
2602
+ let remaining = needed;
2603
+ for (const id of candidates) {
2604
+ if (remaining <= 0) break;
2605
+ const count = Math.min(remaining, countOf(context, id));
2606
+ if (count > 0) taken.push({ item: id, count });
2607
+ remaining -= count;
2608
+ }
2609
+ return remaining > 0 ? void 0 : taken;
2610
+ };
2611
+ var consumptionFor = (input, context) => {
2612
+ if (input.world) return input.world.some((thing) => context.world?.has(thing)) ? [] : void 0;
2613
+ if (input.fluid !== void 0) {
2614
+ const liters = input.liters ?? 1;
2615
+ return (context.fluids?.[input.fluid] ?? 0) >= liters ? [{ fluid: input.fluid, liters }] : void 0;
2616
+ }
2617
+ const taken = takeUnits(candidatesOf(input, context), input.qty ?? 1, context);
2618
+ if (!taken || input.meters === void 0) return taken;
2619
+ return taken.map((entry2) => "item" in entry2 ? { ...entry2, meters: input.meters } : entry2);
2620
+ };
2621
+ var toolMissing = (recipe, context) => recipe.tools.flatMap((tool2) => {
2622
+ const missing = [];
2623
+ if (tool2.anyOf.length > 0 && !tool2.anyOf.some((id) => countOf(context, id) > 0)) missing.push(`tool:${tool2.anyOf.join("|")}`);
2624
+ if (tool2.world && !tool2.world.some((station) => context.world?.has(station))) missing.push(`world:${tool2.world.join("|")}`);
2625
+ return missing;
2626
+ });
2627
+ var gateMissing = (recipe, context) => {
2628
+ const missing = [];
2629
+ if (context.skills && recipe.skill && (context.skills[recipe.skill.id] ?? 0) < recipe.skill.level) missing.push(`skill:${recipe.skill.id}:${recipe.skill.level}`);
2630
+ if (context.unlocked && recipe.unlockedBy !== void 0 && !context.unlocked.has(recipe.unlockedBy)) missing.push(`unlock:${recipe.unlockedBy}`);
2631
+ return missing;
2632
+ };
2633
+ var canCraft = (recipe, context) => {
2634
+ const missing = [
2635
+ ...gateMissing(recipe, context),
2636
+ ...toolMissing(recipe, context),
2637
+ ...recipe.inputs.filter((input) => consumptionFor(input, context) === void 0).map(describeInput)
2638
+ ];
2639
+ return { isPossible: missing.length === 0, missing };
2640
+ };
2641
+ var outcomeOf = (output, random) => {
2642
+ if ("effect" in output) return { effect: output.effect, params: output.params, ...output.text === void 0 ? {} : { text: output.text } };
2643
+ const [low, high] = output.qty;
2644
+ return { item: output.item, count: low + Math.floor(random() * (high - low + 1)) };
2645
+ };
2646
+ var craft = (recipe, context, random) => {
2647
+ const check = canCraft(recipe, context);
2648
+ if (!check.isPossible) return { isCrafted: false, missing: check.missing };
2649
+ const consumed = recipe.inputs.flatMap((input) => consumptionFor(input, context) ?? []);
2650
+ return { isCrafted: true, seconds: recipe.seconds, consumed, output: outcomeOf(recipe.output, random) };
2651
+ };
2652
+ var depletionFactor = (place, day, rules) => {
2653
+ if (day <= 0) return 1;
2654
+ const rule = rules.finds.depletion.find((entry2) => entry2.places.includes(place));
2655
+ return rule ? Math.max(rule.floor, 1 - rule.perDay * day) : 1;
2656
+ };
2657
+ var scaleCount = (count, scale, rules) => {
2658
+ const region = scale.region === void 0 ? 1 : rules.finds.regionMultiplier[scale.region] ?? 1;
2659
+ return Math.round(count * depletionFactor(scale.place, scale.day, rules) * region);
2660
+ };
2661
+ var rollableItems = (catalog, category, place) => {
2662
+ const { rules } = catalog;
2663
+ const rollable = catalog.byCategory(category).filter((item) => !rules.rarity.fixedOnly.includes(item.rarity) && !rules.finds.rollExcluded.includes(item.id));
2664
+ const here = rollable.filter((item) => item.finds?.places.includes(place));
2665
+ return here.length > 0 ? here : rollable;
2666
+ };
2667
+ var rarityWeight = (catalog, item) => catalog.rules.rarity.weights[item.rarity];
2668
+ var pickCategory = (weights, random) => {
2669
+ let remaining = random();
2670
+ const categories = Object.keys(weights);
2671
+ for (const category of categories) {
2672
+ remaining -= weights[category];
2673
+ if (remaining <= 0) return category;
2674
+ }
2675
+ return categories[0];
2676
+ };
2677
+ var rollByCategory = (catalog, query) => {
2678
+ const { rules } = catalog;
2679
+ const table = catalog.containers.get(query.container) ?? catalog.containers.get(rules.finds.fallbackContainer);
2680
+ if (!table) return [];
2681
+ const [low, high] = table.count ?? [0, 0];
2682
+ const drawn = low + Math.floor(query.rng() * (high - low + 1));
2683
+ const count = scaleCount(drawn, { place: query.place, day: query.day ?? 0, ...query.region === void 0 ? {} : { region: query.region } }, rules);
2684
+ const weights = table.categories ?? table.categoriesByPlace?.[query.place] ?? table.categoriesByPlace?.["*"];
2685
+ if (!weights) return [];
2686
+ const picked = [];
2687
+ for (let stack = 0; stack < count; stack++) {
2688
+ const category = pickCategory(weights, query.rng);
2689
+ const pool = category === void 0 ? [] : rollableItems(catalog, category, query.place);
2690
+ if (pool.length === 0) continue;
2691
+ const total = pool.reduce((sum, item) => sum + rarityWeight(catalog, item), 0);
2692
+ let remaining = query.rng() * total;
2693
+ for (const item of pool) {
2694
+ remaining -= rarityWeight(catalog, item);
2695
+ if (remaining <= 0) {
2696
+ picked.push(item.id);
2697
+ break;
2698
+ }
2699
+ }
2700
+ }
2701
+ return picked;
2702
+ };
2703
+ var weightedOrder = (candidates, random) => {
2704
+ const remaining = [...candidates];
2705
+ const ordered = [];
2706
+ while (remaining.length > 0) {
2707
+ const total = remaining.reduce((sum, candidate) => sum + candidate.weight, 0);
2708
+ let x = random() * total;
2709
+ let index = 0;
2710
+ for (; index < remaining.length - 1; index++) {
2711
+ x -= remaining[index].weight;
2712
+ if (x < 0) break;
2713
+ }
2714
+ ordered.push(...remaining.splice(index, 1));
2715
+ }
2716
+ return ordered;
2717
+ };
2718
+ var countFor = (pool, state, footprint, query, rules) => {
2719
+ const settings = rules.finds.pool;
2720
+ const base2 = Math.max(settings.min, Math.min(settings.max, Math.round(settings.offset + footprint * settings.perSquareMetre + query.rng() * settings.jitter)));
2721
+ if (state === "fortified") return Math.min(pool.length, base2 + settings.fortifiedExtra);
2722
+ if (state === "abandoned") return query.rng() < settings.abandonedEmptyChance ? 0 : settings.abandonedKept;
2723
+ return base2;
2724
+ };
2725
+ var rollExplicitPool = (pool, state, query, rules) => {
2726
+ const settings = rules.finds.pool;
2727
+ const n = countFor(pool, state, query.footprint ?? settings.defaultFootprint, query, rules);
2728
+ const isFortified = state === "fortified";
2729
+ const candidates = pool.map((entry2) => ({ entry: entry2, weight: isFortified && entry2.isSupply ? entry2.weight * settings.supplyWeight : entry2.weight }));
2730
+ const picks = [];
2731
+ for (const { entry: entry2 } of weightedOrder(candidates, query.rng).slice(0, n)) {
2732
+ const [low, high] = entry2.qty;
2733
+ const bonus = isFortified && entry2.isSupply ? settings.supplyExtraQty : 0;
2734
+ picks.push({ itemId: entry2.item, count: low + Math.floor(query.rng() * (high - low + 1)) + bonus, entry: entry2 });
2735
+ }
2736
+ if (state === "abandoned") {
2737
+ if (picks.length === 0 && query.rng() < settings.junkChance) picks.push({ itemId: settings.junkItem, count: 1 });
2738
+ if (settings.coldContainers.includes(query.container) || query.key !== void 0 && settings.coldContainers.includes(query.key)) picks.push({ itemId: settings.spoiledFoodItem, count: 1 });
2739
+ }
2740
+ return picks;
2741
+ };
2742
+ var WEARING_DURABILITY = ["condition", "hits", "cuts"];
2743
+ var hasCondition = (item) => item.protection !== void 0 || item.weapon !== void 0 || WEARING_DURABILITY.includes(item.durability?.kind ?? "");
2744
+ var between = (range2, random) => range2[0] + random() * (range2[1] - range2[0]);
2745
+ var spawnAgeDays = (item, outbreakDays, random, catalog) => item.shelfLife === void 0 ? void 0 : outbreakDays + between(catalog.rules.spawn.ageShare, random) * item.shelfLife;
2746
+ var isRetailStock = (query, catalog) => {
2747
+ const { spawn } = catalog.rules;
2748
+ const isRetail = spawn.retailNew && (query.day ?? 0) <= 0 && spawn.retailPlaces.includes(query.place);
2749
+ return isRetail && (spawn.retailContainers.length === 0 || spawn.retailContainers.includes(query.container));
2750
+ };
2751
+ var spawnData = (item, query, catalog) => {
2752
+ const { spawn } = catalog.rules;
2753
+ const data = {};
2754
+ const ageDays = spawnAgeDays(item, query.day ?? 0, query.rng, catalog);
2755
+ if (ageDays !== void 0) data.ageDays = ageDays;
2756
+ if (hasCondition(item)) data.condition = isRetailStock(query, catalog) ? 100 : Math.round(between(spawn.condition[item.rarity], query.rng));
2757
+ if (item.charge) data.charge = between(spawn.charge, query.rng);
2758
+ if (spawn.fillable.includes(item.id)) data.fill = between(spawn.fill, query.rng);
2759
+ return Object.keys(data).length > 0 ? data : void 0;
2760
+ };
2761
+ function createFindsProvider(catalog, options = {}) {
2762
+ const rules = options.rules ? deepMerge(catalog.rules, options.rules) : catalog.rules;
2763
+ const scoped = rules === catalog.rules ? catalog : { ...catalog, rules };
2764
+ const usesPools = (options.pools ?? "team") === "team";
2765
+ const aliases = options.placeAliases ?? {};
2766
+ const poolPlaces = options.poolPlaces;
2767
+ const passes = options.unknownContainers === "pass";
2768
+ const choose2 = (query) => {
2769
+ const pool = usesPools && (poolPlaces === void 0 || poolPlaces.includes(query.place)) ? scoped.pools.get(query.key ?? query.container) ?? scoped.pools.get(query.container) : void 0;
2770
+ if (!pool && passes && !scoped.containers.has(query.container)) return null;
2771
+ if (!pool) return rollByCategory(scoped, query).map((itemId) => ({ itemId, count: 1 }));
2772
+ return rollExplicitPool(pool, rules.finds.states[query.state] ?? "normal", query, rules).map(({ itemId, count }) => ({ itemId, count }));
2773
+ };
2774
+ return {
2775
+ findsFor(asked) {
2776
+ const query = aliases[asked.place] === void 0 ? asked : { ...asked, place: aliases[asked.place] };
2777
+ const chosen = choose2(query);
2778
+ if (chosen === null) return null;
2779
+ return chosen.filter((stack) => scoped.has(stack.itemId)).map((stack) => {
2780
+ const data = spawnData(scoped.get(stack.itemId), query, scoped);
2781
+ return data ? { ...stack, data } : stack;
2782
+ });
2783
+ }
2784
+ };
2785
+ }
2786
+ var MM = 1e-3;
2787
+ var BOX_WALL = 6 * MM;
2788
+
2368
2789
  // src/wear.ts
2790
+ var wearOfFreshness = (state) => state === "fresh" ? 0 : state === "stale" ? 1 : 2;
2791
+ var AGED_IN = "ambient";
2792
+ function wearOfAge(item, ageDays, rules) {
2793
+ if (item.shelfLife === void 0 || ageDays <= 0) return 0;
2794
+ return wearOfFreshness(freshness(item, { ageDays, since: 0, storage: AGED_IN, storedAt: 0 }, 0, rules ? { rules } : {}));
2795
+ }
2369
2796
  var WEAR_TARGET = { food: 6122286, metal: 8011293, wood: 4141862, cloth: 4866099, plastic: 7038294, paper: 9075282, glass: 5591098, rubber: 4860452 };
2370
2797
  var WEAR_AMOUNT = [0, 0.3, 0.62];
2371
2798
  var hexToRgb = (hex3) => [(hex3 >> 16 & 255) / 255, (hex3 >> 8 & 255) / 255, (hex3 & 255) / 255];
@@ -3155,6 +3582,127 @@ var GameItemsThree = (() => {
3155
3582
  tags: [
3156
3583
  "brake_fluid"
3157
3584
  ]
3585
+ },
3586
+ {
3587
+ id: "detergent",
3588
+ color: 15916378,
3589
+ opacity: 0.6,
3590
+ stainColor: 14077068,
3591
+ viscosity: 400,
3592
+ density: 1030,
3593
+ dryTime: 1800,
3594
+ gloss: 0.95,
3595
+ leavesMark: true,
3596
+ drink: {
3597
+ thirst: 0,
3598
+ effects: [
3599
+ "poison"
3600
+ ]
3601
+ },
3602
+ tags: [
3603
+ "soap"
3604
+ ]
3605
+ },
3606
+ {
3607
+ id: "shampoo",
3608
+ color: 6069216,
3609
+ opacity: 0.75,
3610
+ stainColor: 9418462,
3611
+ viscosity: 4e3,
3612
+ density: 1020,
3613
+ dryTime: 3600,
3614
+ gloss: 0.9,
3615
+ leavesMark: true,
3616
+ drink: {
3617
+ thirst: 0,
3618
+ effects: [
3619
+ "poison"
3620
+ ]
3621
+ },
3622
+ tags: [
3623
+ "soap",
3624
+ "sticky"
3625
+ ]
3626
+ },
3627
+ {
3628
+ id: "fabric_softener",
3629
+ color: 9225452,
3630
+ opacity: 0.8,
3631
+ stainColor: 11061470,
3632
+ viscosity: 80,
3633
+ density: 1e3,
3634
+ dryTime: 1800,
3635
+ gloss: 0.8,
3636
+ leavesMark: true,
3637
+ drink: {
3638
+ thirst: 0,
3639
+ effects: [
3640
+ "poison"
3641
+ ]
3642
+ },
3643
+ tags: [
3644
+ "soap"
3645
+ ]
3646
+ },
3647
+ {
3648
+ id: "disinfectant",
3649
+ color: 14205040,
3650
+ opacity: 0.6,
3651
+ stainColor: 13154442,
3652
+ viscosity: 1.5,
3653
+ density: 1e3,
3654
+ dryTime: 600,
3655
+ gloss: 0.85,
3656
+ leavesMark: true,
3657
+ drink: {
3658
+ thirst: 0,
3659
+ effects: [
3660
+ "poison"
3661
+ ]
3662
+ },
3663
+ tags: [
3664
+ "corrosive"
3665
+ ]
3666
+ },
3667
+ {
3668
+ id: "yogurt",
3669
+ color: 15986404,
3670
+ opacity: 1,
3671
+ stainColor: 15130576,
3672
+ viscosity: 1500,
3673
+ density: 1040,
3674
+ dryTime: 7200,
3675
+ gloss: 0.5,
3676
+ leavesMark: true,
3677
+ drink: {
3678
+ thirst: 10,
3679
+ effects: []
3680
+ },
3681
+ tags: [
3682
+ "food",
3683
+ "sticky"
3684
+ ]
3685
+ },
3686
+ {
3687
+ id: "toothpaste",
3688
+ color: 16054008,
3689
+ opacity: 1,
3690
+ stainColor: 15133935,
3691
+ viscosity: 1e5,
3692
+ density: 1300,
3693
+ dryTime: 7200,
3694
+ gloss: 0.6,
3695
+ leavesMark: true,
3696
+ drink: {
3697
+ thirst: 0,
3698
+ effects: [
3699
+ "poison"
3700
+ ]
3701
+ },
3702
+ tags: [
3703
+ "soap",
3704
+ "paste"
3705
+ ]
3158
3706
  }
3159
3707
  ];
3160
3708
  var LIQUIDS = liquids_default;
@@ -3429,7 +3977,9 @@ var GameItemsThree = (() => {
3429
3977
  "coconut_water",
3430
3978
  "cooking_oil",
3431
3979
  "alcohol_70",
3432
- "fuel_jerrycan"
3980
+ "fuel_jerrycan",
3981
+ "shampoo",
3982
+ "toothpaste"
3433
3983
  ],
3434
3984
  rule: {
3435
3985
  hollow: true,
@@ -3564,6 +4114,14 @@ var GameItemsThree = (() => {
3564
4114
  condensed_milk: {
3565
4115
  liquid: "honey",
3566
4116
  fill: 0.9
4117
+ },
4118
+ shampoo: {
4119
+ liquid: "shampoo",
4120
+ fill: 0.9
4121
+ },
4122
+ toothpaste: {
4123
+ liquid: "toothpaste",
4124
+ fill: 0.85
3567
4125
  }
3568
4126
  },
3569
4127
  shapes: {
@@ -3641,14 +4199,15 @@ var GameItemsThree = (() => {
3641
4199
  var WALL_SHARE = 0.9;
3642
4200
  var OPENING_RADIUS = 0.012;
3643
4201
  function itemContents(subject) {
3644
- const contents = subject.model === void 0 ? void 0 : CONTENTS[subject.model];
4202
+ const known = subject.model === void 0 ? void 0 : CONTENTS[subject.model];
4203
+ const contents = known ?? (subject.fluid ? { liquid: subject.fluid.liquid, fill: 1, ...subject.box ? { box: true } : {} } : void 0);
3645
4204
  if (!contents) return void 0;
3646
4205
  const [width, height, depth] = subject.size;
3647
4206
  const radius = Math.min(width, depth) / 2;
3648
4207
  const innerLiters = (contents.box ? width * depth : Math.PI * radius * radius) * height * WALL_SHARE * 1e3;
3649
4208
  const density = LIQUIDS.find((liquid) => liquid.id === contents.liquid)?.density ?? 1e3;
3650
4209
  const heaviest = subject.weight === void 0 ? Infinity : subject.weight * 1e3 / density;
3651
- const liters = Math.min(innerLiters * contents.fill, heaviest);
4210
+ const liters = Math.min(known ? innerLiters * contents.fill : subject.fluid?.liters ?? 0, innerLiters, heaviest);
3652
4211
  const container = {
3653
4212
  capacity: innerLiters,
3654
4213
  liquid: contents.liquid,
@@ -3659,6 +4218,10 @@ var GameItemsThree = (() => {
3659
4218
  };
3660
4219
  return { container, liquid: contents.liquid, liters };
3661
4220
  }
4221
+ function containsOf(contents) {
4222
+ const viscosity = LIQUIDS.find((liquid) => liquid.id === contents.liquid)?.viscosity ?? 1;
4223
+ return { fluid: contents.liquid, liters: contents.liters, viscosity };
4224
+ }
3662
4225
  var VESSEL_FLOORS = { cup: CUP_FLOOR_SHARE };
3663
4226
  function itemVessel(subject) {
3664
4227
  const capacity = subject.capacityLiters;
@@ -3784,14 +4347,23 @@ var GameItemsThree = (() => {
3784
4347
  if (powder) mesh2.userData.destructionPowder = { color: powder.color };
3785
4348
  solid.push(mesh2);
3786
4349
  });
3787
- if (!rule?.welded || solid.length < 2) return;
3788
- const anchor = solid.reduce((largest, mesh2) => volumeOf(mesh2) > volumeOf(largest) ? mesh2 : largest);
4350
+ const largest = () => solid.reduce((big, mesh2) => volumeOf(mesh2) > volumeOf(big) ? mesh2 : big);
4351
+ if (!rule?.welded || solid.length < 2) {
4352
+ const held = options.fluid && size !== void 0 && solid.length > 0 ? itemContents({ size, ...weight === void 0 ? {} : { weight }, fluid: options.fluid }) : void 0;
4353
+ if (!held) return;
4354
+ const body2 = largest();
4355
+ body2.userData.destructionPart = { id: SHELL_PART_ID };
4356
+ body2.userData.hollow = true;
4357
+ body2.userData.destructionContains = containsOf(held);
4358
+ return;
4359
+ }
4360
+ const anchor = largest();
3789
4361
  solid.forEach((mesh2, index) => {
3790
4362
  mesh2.userData.destructionPart = mesh2 === anchor ? { id: SHELL_PART_ID } : { id: `shell_${index}`, parent: SHELL_PART_ID, kind: "weld" };
3791
4363
  if (rule.wall) mesh2.userData.destructionThickness = mesh2 === anchor ? rule.wall.body : rule.wall.ends;
3792
4364
  });
3793
4365
  const contents = size === void 0 ? void 0 : itemContents({ ...modelId === void 0 ? {} : { model: modelId }, size, ...weight === void 0 ? {} : { weight } });
3794
- if (contents) anchor.userData.destructionContains = { fluid: contents.liquid, liters: contents.liters };
4366
+ if (contents) anchor.userData.destructionContains = containsOf(contents);
3795
4367
  }
3796
4368
 
3797
4369
  // src/data/models.json
@@ -6286,6 +6858,46 @@ var GameItemsThree = (() => {
6286
6858
  ],
6287
6859
  scale: 0.092308
6288
6860
  },
6861
+ {
6862
+ id: "soap",
6863
+ teamId: "sabonete",
6864
+ teamBox: [
6865
+ 0.9,
6866
+ 0.3,
6867
+ 0.5
6868
+ ],
6869
+ scale: 0.1
6870
+ },
6871
+ {
6872
+ id: "shampoo",
6873
+ teamId: "shampoo",
6874
+ teamBox: [
6875
+ 0.6,
6876
+ 2,
6877
+ 0.4002
6878
+ ],
6879
+ scale: 0.1
6880
+ },
6881
+ {
6882
+ id: "toothpaste",
6883
+ teamId: "pasta_dente",
6884
+ teamBox: [
6885
+ 0.4,
6886
+ 1.8,
6887
+ 0.3
6888
+ ],
6889
+ scale: 0.1
6890
+ },
6891
+ {
6892
+ id: "toothbrush",
6893
+ teamId: "escova_dente",
6894
+ teamBox: [
6895
+ 0.2,
6896
+ 1.8,
6897
+ 0.2
6898
+ ],
6899
+ scale: 0.1
6900
+ },
6289
6901
  {
6290
6902
  id: "plunger",
6291
6903
  teamId: "desentupidor",
@@ -7476,6 +8088,61 @@ var GameItemsThree = (() => {
7476
8088
  return G(bottle2, label, stripe, cap, nozzle);
7477
8089
  };
7478
8090
 
8091
+ // src/models/shampoo.ts
8092
+ var shampoo = ({ mesh: mesh2, cyl, lathe: lathe2, G, plastic, paper: paper2 }) => {
8093
+ const oval = [1, 1, 0.667];
8094
+ const body = mesh2(lathe2([[0, -1], [0.24, -1], [0.28, -0.94], [0.28, 0.42], [0.25, 0.55], [0.15, 0.62], [0.15, 0.66], [0, 0.66]], 14), plastic(4885200), [0, 0, 0], [0, 0, 0], oval);
8095
+ const label = mesh2(cyl(0.3, 0.3, 0.8, 16), paper2(15922680), [0, -0.35, 0], [0, 0, 0], oval);
8096
+ const cap = mesh2(cyl(0.17, 0.17, 0.28, 12), plastic(15790320), [0, 0.8, 0], [0, 0, 0], oval);
8097
+ const lid = mesh2(cyl(0.12, 0.17, 0.06, 12), plastic(14869218), [0, 0.97, 0], [0, 0, 0], oval);
8098
+ return G(body, label, cap, lid);
8099
+ };
8100
+
8101
+ // src/models/soap.ts
8102
+ var roundedRect = (width, depth, corner, steps = 4) => {
8103
+ const points = [];
8104
+ const centres = [
8105
+ [width / 2 - corner, depth / 2 - corner, 0],
8106
+ [-width / 2 + corner, depth / 2 - corner, Math.PI / 2],
8107
+ [-width / 2 + corner, -depth / 2 + corner, Math.PI],
8108
+ [width / 2 - corner, -depth / 2 + corner, 3 * Math.PI / 2]
8109
+ ];
8110
+ for (const [cx, cy, start] of centres) {
8111
+ for (let step = 0; step <= steps; step++) {
8112
+ const angle = start + step / steps * (Math.PI / 2);
8113
+ points.push([cx + Math.cos(angle) * corner, cy + Math.sin(angle) * corner]);
8114
+ }
8115
+ }
8116
+ return points;
8117
+ };
8118
+ var soap = ({ mesh: mesh2, extrude: extrude2, M, G }) => {
8119
+ const edge = 0.04;
8120
+ const bar2 = extrude2(roundedRect(0.9 - 2 * edge, 0.5 - 2 * edge, 0.14), 0.3 - 2 * edge, edge);
8121
+ bar2.center();
8122
+ return G(mesh2(bar2, M(15984338, "wax", { roughness: 0.55 }), [0, 0, 0], [Math.PI / 2, 0, 0]));
8123
+ };
8124
+
8125
+ // src/models/toothbrush.ts
8126
+ var toothbrush = ({ mesh: mesh2, bx, G, plastic, M }) => {
8127
+ const handle = mesh2(bx(0.16, 0.8, 0.1), plastic(3840720), [0, 0.75, -0.05]);
8128
+ const grip = mesh2(bx(0.2, 0.35, 0.12), plastic(2912160), [0, 0.175, -0.05]);
8129
+ const neck = mesh2(bx(0.08, 0.3, 0.08), plastic(3840720), [0, 1.3, -0.05]);
8130
+ const head = mesh2(bx(0.14, 0.35, 0.06), plastic(3840720), [0, 1.625, -0.06]);
8131
+ const bristles = mesh2(bx(0.12, 0.32, 0.12), M(16054008, "plastic", { roughness: 0.9 }), [0, 1.62, 0.03]);
8132
+ return G(handle, grip, neck, head, bristles);
8133
+ };
8134
+
8135
+ // src/models/toothpaste.ts
8136
+ var toothpaste = ({ mesh: mesh2, cyl, bx, G, plastic }) => {
8137
+ const flat = [1, 1, 0.75];
8138
+ const cap = mesh2(cyl(0.11, 0.12, 0.22, 12), plastic(2056104), [0, 0.11, 0]);
8139
+ const shoulder = mesh2(cyl(0.2, 0.11, 0.08, 14), plastic(16053494), [0, 0.26, 0], [0, 0, 0], flat);
8140
+ const body = mesh2(cyl(0.2, 0.2, 0.9, 14), plastic(16053494), [0, 0.75, 0], [0, 0, 0], flat);
8141
+ const taper = mesh2(cyl(0.2, 0.2, 0.44, 14), plastic(16053494), [0, 1.41, 0], [0, 0, 0], [1, 1, 0.42]);
8142
+ const crimp = mesh2(bx(0.4, 0.17, 0.04), plastic(15132394), [0, 1.715, 0]);
8143
+ return G(cap, shoulder, body, taper, crimp);
8144
+ };
8145
+
7479
8146
  // src/models/plunger.ts
7480
8147
  var plunger = ({ mesh: mesh2, cyl, G, M, wood }) => {
7481
8148
  const rubber = M(11545120, "rubber", { roughness: 0.75 });
@@ -10163,6 +10830,10 @@ var GameItemsThree = (() => {
10163
10830
  watering_can: wateringCan,
10164
10831
  wheelbarrow,
10165
10832
  windup_alarm_clock: windupAlarmClock,
10833
+ soap,
10834
+ shampoo,
10835
+ toothpaste,
10836
+ toothbrush,
10166
10837
  plunger
10167
10838
  };
10168
10839
  var SHIPPED_MODELS = models_default.map((entry2) => {
@@ -10228,7 +10899,8 @@ var GameItemsThree = (() => {
10228
10899
  const materials = kit.materials.slice(first);
10229
10900
  if (options.wear) setWear(materials, options.wear);
10230
10901
  root.userData.wear = options.wear ?? 0;
10231
- if (options.destructible) tagForDestruction(root, { ...kind === "model" && item.model !== void 0 ? { modelId: item.model } : {}, ...shape === void 0 ? {} : { shapeId: shape }, ...item.weight === void 0 ? {} : { weight: item.weight }, size: item.size, ...item.powder ? { powder: item.powder } : {}, ...item.parts ? { parts: item.parts } : {}, three: T2 });
10902
+ const held = itemFluid(item);
10903
+ if (options.destructible) tagForDestruction(root, { ...kind === "model" && item.model !== void 0 ? { modelId: item.model } : {}, ...shape === void 0 ? {} : { shapeId: shape }, ...item.weight === void 0 ? {} : { weight: item.weight }, size: item.size, ...item.powder ? { powder: item.powder } : {}, ...item.parts ? { parts: item.parts } : {}, ...held ? { fluid: held } : {}, three: T2 });
10232
10904
  markKitOrigin(root, { owner: "game-items-three", kind: "item", id: item.id, ...kind === "shape" ? { standIn: true } : {} });
10233
10905
  return { root, kind, ...shape ? { shape } : {}, size: item.size, materials };
10234
10906
  }
@@ -10382,12 +11054,16 @@ var GameItemsThree = (() => {
10382
11054
 
10383
11055
  // src/contained.ts
10384
11056
  function createContainedItemModel(items, options = {}) {
11057
+ const { rules, ...build } = options;
10385
11058
  const byId = /* @__PURE__ */ new Map();
10386
11059
  for (const item of items) byId.set(item.id, item);
10387
11060
  return (stack, T2) => {
10388
11061
  const item = byId.get(stack.type);
10389
11062
  if (!item) return null;
10390
- const model = buildItem(T2, item, options);
11063
+ const ageDays = stack.data?.["ageDays"];
11064
+ const aged = typeof ageDays === "number" ? wearOfAge(item, ageDays, rules) : 0;
11065
+ const wear = Math.max(build.wear ?? 0, aged);
11066
+ const model = buildItem(T2, item, wear > 0 ? { ...build, wear } : build);
10391
11067
  model.root.userData.item = { id: item.id, kind: model.kind };
10392
11068
  const dirt = stack.data?.["dirt"];
10393
11069
  if (typeof dirt === "number" && dirt > 0) setItemDirt(T2, model.root, dirt);
@@ -10924,11 +11600,11 @@ var GameItemsThree = (() => {
10924
11600
  mergeByMaterial: () => mergeByMaterial,
10925
11601
  mix: () => mix,
10926
11602
  resolveStrings: () => resolveStrings,
10927
- rng: () => rng,
11603
+ rng: () => rng2,
10928
11604
  seedOf: () => seedOf,
10929
11605
  shade: () => shade2
10930
11606
  });
10931
- function rng(seed) {
11607
+ function rng2(seed) {
10932
11608
  let s = seed >>> 0;
10933
11609
  return () => {
10934
11610
  s = s + 1831565813 >>> 0;
@@ -10993,7 +11669,7 @@ var GameItemsThree = (() => {
10993
11669
  function floorAtlas(doc) {
10994
11670
  const N = 256, cv = makeCanvas(doc, N * 4, N * 2), g = cv.getContext("2d"), P = (c) => [c % 4 * N, Math.floor(c / 4) * N];
10995
11671
  const cell = (c, seed, f) => {
10996
- const [x0, y0] = P(c), r = rng(seed);
11672
+ const [x0, y0] = P(c), r = rng2(seed);
10997
11673
  f(g, x0, y0, r);
10998
11674
  };
10999
11675
  for (const [c, seed] of [[0, 11], [1, 12]]) cell(c, seed, (g2, x0, y0, r) => {
@@ -11154,7 +11830,7 @@ var GameItemsThree = (() => {
11154
11830
  function pictureAtlas(doc, names) {
11155
11831
  const N = 256, cv = makeCanvas(doc, N * 4, N * 2), g = cv.getContext("2d");
11156
11832
  const cell = (c, seed, f) => {
11157
- const x0 = c % 4 * N, y0 = Math.floor(c / 4) * N, r = rng(seed);
11833
+ const x0 = c % 4 * N, y0 = Math.floor(c / 4) * N, r = rng2(seed);
11158
11834
  g.save();
11159
11835
  g.beginPath();
11160
11836
  g.rect(x0, y0, N, N);
@@ -11333,7 +12009,7 @@ var GameItemsThree = (() => {
11333
12009
  return { canvas: cv, n: PICTURE_CELLS - 1, uv: (c) => uvc(c), mirror: () => uvc(7), names };
11334
12010
  }
11335
12011
  function waterAtlas(doc) {
11336
- const N = 128, cv = makeCanvas(doc, N, N), g = cv.getContext("2d"), r = rng(901);
12012
+ const N = 128, cv = makeCanvas(doc, N, N), g = cv.getContext("2d"), r = rng2(901);
11337
12013
  g.fillStyle = "#e6f2f8";
11338
12014
  g.fillRect(0, 0, N, N);
11339
12015
  seamless(g, 0, 0, N, () => {
@@ -12246,7 +12922,7 @@ var GameItemsThree = (() => {
12246
12922
  const color2 = o.color != null ? hex2(o.color) : 16777215;
12247
12923
  const poly = o.poly || M.poly;
12248
12924
  const sd = seedOf(M);
12249
- const rnd = rng(sd);
12925
+ const rnd = rng2(sd);
12250
12926
  const tint = () => {
12251
12927
  const v = 0.93 + rnd() * 0.07;
12252
12928
  return mix(0, color2, v);
@@ -12298,7 +12974,7 @@ var GameItemsThree = (() => {
12298
12974
  const K = {
12299
12975
  M,
12300
12976
  api,
12301
- rnd: rng(seedOf(M)),
12977
+ rnd: rng2(seedOf(M)),
12302
12978
  box: (material, x, y, z, w, h, d, color2, ry, rx, rz) => api.box(M, material, x, y, z, w, h, d, hex2(color2), ry || 0, rx || 0, rz || 0),
12303
12979
  cyl: (material, x, y, z, r, h, color2, rx, rz, shape) => api.cylinder(M, material, x, y, z, r, h, hex2(color2), rx || 0, rz || 0, shape),
12304
12980
  leaf: (x, y, z, w, h, color2, ry, rx) => api.leaf(M, x, y, z, w, h, hex2(color2), ry || 0, rx || 0),
@@ -17621,6 +18297,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17621
18297
  return { ...base2, mesh: { vertices, indices: piece3.mesh.indices } };
17622
18298
  };
17623
18299
  var THIN_SHEET_DISHING = 5e-3;
18300
+ var LAMINAR_VISCOSITY = 800;
17624
18301
  var TEAR_CALIBERS = 1.1;
17625
18302
  var SHELL_YIELD_SHARE = 0.5;
17626
18303
  var STEEL_YIELD_MPA = 250;
@@ -20339,7 +21016,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20339
21016
  setStage(o, p, 1, {}, src);
20340
21017
  };
20341
21018
  const debris = (o, p, kind, point, normal, count, speed, src, material) => emit({ ...base2(o, src), type: "debris", part: p.spec.id, kind, point, normal, count, speed, ...material && material !== p.spec.material ? { material } : {} });
20342
- const holeRate = (hole, pressurized) => (pressurized ? 0.5 : 0.1) * (hole.diameter / 9e-3);
21019
+ const holeRate = (hole, pressurized, viscosity = 1) => (pressurized ? 0.5 : 0.1) * (hole.diameter / 9e-3) / (1 + Math.max(0, viscosity - 1) / LAMINAR_VISCOSITY);
20343
21020
  const detachEvents = (o, opened, by, src) => {
20344
21021
  for (const j of opened) emit({ ...base2(o, src), type: "detach", joint: j.spec.id, parts: [j.spec.a, j.spec.b], by, groups: o.st.groups.map((g) => [...g]) });
20345
21022
  };
@@ -21958,7 +22635,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21958
22635
  fluid: p.spec.contains.fluid,
21959
22636
  point: entry2,
21960
22637
  direction: p.spec.contains.outflow ? vec.normalize(rotateVec(o.st.rotation, rotateVec(p.q, p.spec.contains.outflow))) : n,
21961
- rate: holeRate(hole, !!p.spec.contains.pressurized),
22638
+ rate: holeRate(hole, !!p.spec.contains.pressurized, p.spec.contains.viscosity),
21962
22639
  pressurized: !!p.spec.contains.pressurized
21963
22640
  });
21964
22641
  rollIgnition(o, p, round3);
@@ -23047,7 +23724,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23047
23724
  const cont = p.spec.contains;
23048
23725
  if (cont && (s.liters ?? 0) > 0) {
23049
23726
  let rate = 0;
23050
- for (const h of s.holes) if (h.through) rate += holeRate(h, !!cont.pressurized);
23727
+ for (const h of s.holes) if (h.through) rate += holeRate(h, !!cont.pressurized, cont.viscosity);
23051
23728
  if (rate > 0) {
23052
23729
  s.liters = Math.max(0, (s.liters ?? 0) - rate * dt);
23053
23730
  hot = true;
@@ -23636,7 +24313,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
23636
24313
  fluid: c.fluid,
23637
24314
  point: wp,
23638
24315
  direction: c.outflow ? vec.normalize(rotateVec(o.st.rotation, rotateVec(p.q, c.outflow))) : wn,
23639
- rate: holeRate(hole, !!c.pressurized),
24316
+ rate: holeRate(hole, !!c.pressurized, c.viscosity),
23640
24317
  pressurized: !!c.pressurized
23641
24318
  });
23642
24319
  return true;
@@ -26246,418 +26923,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26246
26923
  return [[mast.u, mast.v, mast.y0], [mast.u, mast.v, mast.y1], ...arc];
26247
26924
  }
26248
26925
 
26249
- // ../game-interactables/dist/index.js
26250
- function hashString(text) {
26251
- let h = 2166136261;
26252
- for (let i = 0; i < text.length; i++) {
26253
- h ^= text.charCodeAt(i);
26254
- h = Math.imul(h, 16777619);
26255
- }
26256
- return h >>> 0;
26257
- }
26258
- function rng2(seed = 1) {
26259
- let a = (typeof seed === "number" ? Math.floor(seed) >>> 0 : hashString(seed)) || 2654435769;
26260
- return () => {
26261
- a = a + 1831565813 >>> 0;
26262
- let t = a;
26263
- t = Math.imul(t ^ t >>> 15, t | 1);
26264
- t ^= t + Math.imul(t ^ t >>> 7, t | 61);
26265
- return ((t ^ t >>> 14) >>> 0) / 4294967296;
26266
- };
26267
- }
26268
- var pose = new Float64Array(7);
26269
- var pose2 = new Float64Array(7);
26270
-
26271
- // ../game-items/dist/index.js
26272
- var DEFAULT_RULES = {
26273
- rarity: {
26274
- weights: { common: 60, uncommon: 28, rare: 9, very_rare: 2.5, legendary: 0.5, unique: 0 },
26275
- fixedOnly: ["legendary", "unique"]
26276
- },
26277
- freshness: { stale: 0.5, spoiled: 1, rotten: 1.5 },
26278
- storage: {
26279
- fridge: { multiplier: 0.33, needsPower: true },
26280
- freezer: { multiplier: 0.1, needsPower: true },
26281
- cooler: { multiplier: 0.5, limitDays: 2, afterLimit: 1 },
26282
- delivery_bag: { multiplier: 0.8 },
26283
- cellar: { multiplier: 0.66 },
26284
- ambient: { multiplier: 1 },
26285
- hot: { multiplier: 2 }
26286
- },
26287
- carry: { baseKg: 8, perStrengthKg: 2.5, factor: 1.2, encumbered: 1, overloaded: 1.5 },
26288
- protection: { cap: 0.9, wear: { bite: 8, scratch: 3 }, tornShare: 0.25, repairMargin: 10 },
26289
- aging: { thawShelfDays: { freezer: 2 } },
26290
- inventory: {
26291
- defaultSlots: 10,
26292
- encumberedRunFactor: 0.75,
26293
- defaultLitres: 12,
26294
- defaultInside: [0.3, 0.25, 0.16],
26295
- bagInside: {
26296
- shopping_bag: [0.4, 0.35, 0.15],
26297
- trash_bag: [0.6, 0.45, 0.12],
26298
- fanny_pack: [0.22, 0.12, 0.1],
26299
- crossbody_bag: [0.25, 0.2, 0.12],
26300
- backpack: [0.5, 0.3, 0.2],
26301
- delivery_bag: [0.45, 0.45, 0.25],
26302
- hiking_backpack_40l: [0.6, 0.35, 0.19],
26303
- military_backpack: [0.6, 0.35, 0.21],
26304
- trekking_backpack_70l: [0.75, 0.38, 0.25],
26305
- rolling_suitcase: [0.6, 0.4, 0.21],
26306
- tactical_vest: [0.3, 0.2, 0.1],
26307
- tool_belt: [0.4, 0.2, 0.1],
26308
- cooler_box: [0.32, 0.25, 0.23],
26309
- shopping_cart: [0.9, 0.55, 0.16],
26310
- wheelbarrow: [1.2, 0.6, 0.15]
26311
- },
26312
- bagLitres: {
26313
- shopping_bag: 20,
26314
- trash_bag: 30,
26315
- fanny_pack: 3,
26316
- crossbody_bag: 6,
26317
- backpack: 30,
26318
- delivery_bag: 50,
26319
- hiking_backpack_40l: 40,
26320
- military_backpack: 45,
26321
- trekking_backpack_70l: 70,
26322
- rolling_suitcase: 50,
26323
- tactical_vest: 6,
26324
- tool_belt: 8,
26325
- cooler_box: 18,
26326
- shopping_cart: 80,
26327
- wheelbarrow: 100
26328
- }
26329
- },
26330
- use: {
26331
- freshness: {
26332
- stale: { satietyFactor: 0.7, poisonChance: 0.1, morale: 0, isEdible: true },
26333
- spoiled: { satietyFactor: 0.7, poisonChance: 0.5, morale: -20, isEdible: true },
26334
- rotten: { satietyFactor: 0, poisonChance: 0, morale: 0, isEdible: false }
26335
- },
26336
- cookedPoisonFactor: 0.25
26337
- },
26338
- spawn: {
26339
- retailNew: true,
26340
- retailPlaces: ["supermarket", "pharmacy", "mall", "gas_station", "gun_shop"],
26341
- retailContainers: ["store_shelf", "stockroom"],
26342
- condition: { common: [30, 90], uncommon: [40, 90], rare: [50, 100], very_rare: [50, 100], legendary: [50, 100], unique: [50, 100] },
26343
- ageShare: [0, 0.6],
26344
- charge: [0.2, 1],
26345
- fillable: ["fuel_jerrycan"],
26346
- fill: [0, 0.6]
26347
- },
26348
- finds: {
26349
- fallbackContainer: "zombie_corpse",
26350
- rollExcluded: ["ammo_7_62x39"],
26351
- depletion: [
26352
- { places: ["pharmacy", "gun_shop", "police_station"], perDay: 0.05, floor: 0.3 },
26353
- { places: ["supermarket", "gas_station"], perDay: 0.04, floor: 0.35 },
26354
- { places: ["mall", "hospital"], perDay: 0.025, floor: 0.5 },
26355
- { places: ["house", "apartment"], perDay: 0.01, floor: 0.7 },
26356
- { places: ["farm", "warehouse", "mine", "dam", "lodge", "church"], perDay: 5e-3, floor: 0.85 },
26357
- { places: ["military_base"], perDay: 0, floor: 1 }
26358
- ],
26359
- regionMultiplier: {},
26360
- states: { normal: "normal", fortified: "fortified", abandoned: "abandoned" },
26361
- pool: {
26362
- defaultFootprint: 0.5,
26363
- offset: 1.5,
26364
- perSquareMetre: 3,
26365
- jitter: 1.5,
26366
- min: 2,
26367
- max: 5,
26368
- fortifiedExtra: 2,
26369
- supplyWeight: 2.5,
26370
- supplyExtraQty: 1,
26371
- abandonedEmptyChance: 0.4,
26372
- abandonedKept: 1,
26373
- junkChance: 0.5,
26374
- junkItem: "food_packaging",
26375
- spoiledFoodItem: "leftover_meal",
26376
- coldContainers: ["geladeira", "refrig_exp", "freezer"]
26377
- }
26378
- }
26379
- };
26380
- var ITEM_CATEGORIES = [
26381
- { id: "food", name: "Food" },
26382
- { id: "drink", name: "Drink" },
26383
- { id: "medical", name: "Medical" },
26384
- { id: "tools", name: "Tools" },
26385
- { id: "melee", name: "Melee" },
26386
- { id: "materials", name: "Materials" },
26387
- { id: "clothing", name: "Clothing" },
26388
- { id: "bags", name: "Bags" },
26389
- { id: "electronics", name: "Electronics" },
26390
- { id: "fuel", name: "Fuel" },
26391
- { id: "outdoors", name: "Outdoors" },
26392
- { id: "books", name: "Books" },
26393
- { id: "collectibles", name: "Collectibles" },
26394
- { id: "keys", name: "Keys" }
26395
- ];
26396
- var storageRuleOf = (rules, storage) => {
26397
- const rule = rules.storage[storage];
26398
- if (!rule) throw new Error(`game-items: unknown storage "${storage}"`);
26399
- return rule;
26400
- };
26401
- var accruedDays = (storage, window, options) => {
26402
- const { powered = true, rules = DEFAULT_RULES } = options;
26403
- const rule = storageRuleOf(rules, storage);
26404
- const elapsed = window.to - window.from;
26405
- if (elapsed <= 0) return 0;
26406
- if (rule.needsPower && !powered) return elapsed;
26407
- if (rule.limitDays === void 0) return elapsed * rule.multiplier;
26408
- const limitEnd = window.storedAt + rule.limitDays;
26409
- const early = Math.max(0, Math.min(window.to, limitEnd) - Math.max(window.from, window.storedAt));
26410
- return early * rule.multiplier + (elapsed - early) * (rule.afterLimit ?? 1);
26411
- };
26412
- var advanceAge = (state, now, options = {}) => {
26413
- const { powered = true, rules = DEFAULT_RULES } = options;
26414
- const rule = storageRuleOf(rules, state.storage);
26415
- const thawDays = rules.aging.thawShelfDays[state.storage];
26416
- const isThawing = rule.needsPower === true && !powered && thawDays !== void 0 && state.shelfLife === void 0;
26417
- const base2 = isThawing ? { ...state, ageDays: 0, shelfLife: thawDays } : state;
26418
- const ageDays = base2.ageDays + accruedDays(state.storage, { storedAt: state.storedAt, from: state.since, to: now }, options);
26419
- return { ...base2, ageDays, since: Math.max(now, state.since) };
26420
- };
26421
- var shelfRatio = (item, state) => {
26422
- const shelfLife = state.shelfLife ?? item.shelfLife;
26423
- return shelfLife === void 0 ? 0 : state.ageDays / shelfLife;
26424
- };
26425
- var freshness = (item, state, now, options = {}) => {
26426
- const { rules = DEFAULT_RULES } = options;
26427
- const ratio = shelfRatio(item, advanceAge(state, now, options));
26428
- if (ratio >= rules.freshness.rotten) return "rotten";
26429
- if (ratio >= rules.freshness.spoiled) return "spoiled";
26430
- if (ratio >= rules.freshness.stale) return "stale";
26431
- return "fresh";
26432
- };
26433
- var FRESH_NUTRITION = { satietyFactor: 1, poisonChance: 0, morale: 0, isEdible: true };
26434
- var nutritionOf = (item, context, rules) => {
26435
- const state = context.freshness ?? "fresh";
26436
- const effect = state === "fresh" ? FRESH_NUTRITION : rules.use.freshness[state];
26437
- const poisonShare = context.isCooked ? rules.use.cookedPoisonFactor : 1;
26438
- return {
26439
- satiety: (item.nutrition?.satiety ?? 0) * effect.satietyFactor,
26440
- hydration: item.nutrition?.hydration ?? 0,
26441
- morale: effect.morale,
26442
- poisonChance: effect.poisonChance * poisonShare,
26443
- isEdible: effect.isEdible
26444
- };
26445
- };
26446
- var findEffect = (item, effects) => effects.find((entry2) => entry2.items?.includes(item.id)) ?? effects.find((entry2) => entry2.category?.includes(item.category));
26447
- var resolveUse = (item, effects, context = {}, rules = DEFAULT_RULES) => {
26448
- const def = findEffect(item, effects);
26449
- if (!def) return void 0;
26450
- const base2 = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
26451
- if (def.effect !== "consume_nutrition") return base2;
26452
- const nutrition = nutritionOf(item, context, rules);
26453
- const blocked = item.seal && context.seal ? sealBlock(item.seal, context.seal) : void 0;
26454
- if (blocked) return { ...base2, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
26455
- return { ...base2, consumes: def.consumes && nutrition.isEdible, nutrition };
26456
- };
26457
- var countOf = (context, id) => context.inventory.get(id) ?? 0;
26458
- var candidatesOf = (input, context) => {
26459
- if (input.item !== void 0) return [input.item];
26460
- if (input.any) return [...input.any];
26461
- if (!input.match) return [];
26462
- const { category, cookable } = input.match;
26463
- return context.catalog.list().filter((item) => (category === void 0 || item.category === category) && (cookable === void 0 || item.cookable === cookable)).map((item) => item.id);
26464
- };
26465
- var describeInput = (input) => {
26466
- if (input.item !== void 0) return `item:${input.item}`;
26467
- if (input.any) return `any:${input.any.join("|")}`;
26468
- if (input.match) return `match:${input.match.category ?? "cookable"}`;
26469
- if (input.fluid !== void 0) return `fluid:${input.fluid}`;
26470
- return `world:${(input.world ?? []).join("|")}`;
26471
- };
26472
- var takeUnits = (candidates, needed, context) => {
26473
- const taken = [];
26474
- let remaining = needed;
26475
- for (const id of candidates) {
26476
- if (remaining <= 0) break;
26477
- const count = Math.min(remaining, countOf(context, id));
26478
- if (count > 0) taken.push({ item: id, count });
26479
- remaining -= count;
26480
- }
26481
- return remaining > 0 ? void 0 : taken;
26482
- };
26483
- var consumptionFor = (input, context) => {
26484
- if (input.world) return input.world.some((thing) => context.world?.has(thing)) ? [] : void 0;
26485
- if (input.fluid !== void 0) {
26486
- const liters = input.liters ?? 1;
26487
- return (context.fluids?.[input.fluid] ?? 0) >= liters ? [{ fluid: input.fluid, liters }] : void 0;
26488
- }
26489
- const taken = takeUnits(candidatesOf(input, context), input.qty ?? 1, context);
26490
- if (!taken || input.meters === void 0) return taken;
26491
- return taken.map((entry2) => "item" in entry2 ? { ...entry2, meters: input.meters } : entry2);
26492
- };
26493
- var toolMissing = (recipe, context) => recipe.tools.flatMap((tool2) => {
26494
- const missing = [];
26495
- if (tool2.anyOf.length > 0 && !tool2.anyOf.some((id) => countOf(context, id) > 0)) missing.push(`tool:${tool2.anyOf.join("|")}`);
26496
- if (tool2.world && !tool2.world.some((station) => context.world?.has(station))) missing.push(`world:${tool2.world.join("|")}`);
26497
- return missing;
26498
- });
26499
- var gateMissing = (recipe, context) => {
26500
- const missing = [];
26501
- if (context.skills && recipe.skill && (context.skills[recipe.skill.id] ?? 0) < recipe.skill.level) missing.push(`skill:${recipe.skill.id}:${recipe.skill.level}`);
26502
- if (context.unlocked && recipe.unlockedBy !== void 0 && !context.unlocked.has(recipe.unlockedBy)) missing.push(`unlock:${recipe.unlockedBy}`);
26503
- return missing;
26504
- };
26505
- var canCraft = (recipe, context) => {
26506
- const missing = [
26507
- ...gateMissing(recipe, context),
26508
- ...toolMissing(recipe, context),
26509
- ...recipe.inputs.filter((input) => consumptionFor(input, context) === void 0).map(describeInput)
26510
- ];
26511
- return { isPossible: missing.length === 0, missing };
26512
- };
26513
- var outcomeOf = (output, random) => {
26514
- if ("effect" in output) return { effect: output.effect, params: output.params, ...output.text === void 0 ? {} : { text: output.text } };
26515
- const [low, high] = output.qty;
26516
- return { item: output.item, count: low + Math.floor(random() * (high - low + 1)) };
26517
- };
26518
- var craft = (recipe, context, random) => {
26519
- const check = canCraft(recipe, context);
26520
- if (!check.isPossible) return { isCrafted: false, missing: check.missing };
26521
- const consumed = recipe.inputs.flatMap((input) => consumptionFor(input, context) ?? []);
26522
- return { isCrafted: true, seconds: recipe.seconds, consumed, output: outcomeOf(recipe.output, random) };
26523
- };
26524
- var depletionFactor = (place, day, rules) => {
26525
- if (day <= 0) return 1;
26526
- const rule = rules.finds.depletion.find((entry2) => entry2.places.includes(place));
26527
- return rule ? Math.max(rule.floor, 1 - rule.perDay * day) : 1;
26528
- };
26529
- var scaleCount = (count, scale, rules) => {
26530
- const region = scale.region === void 0 ? 1 : rules.finds.regionMultiplier[scale.region] ?? 1;
26531
- return Math.round(count * depletionFactor(scale.place, scale.day, rules) * region);
26532
- };
26533
- var rollableItems = (catalog, category, place) => {
26534
- const { rules } = catalog;
26535
- const rollable = catalog.byCategory(category).filter((item) => !rules.rarity.fixedOnly.includes(item.rarity) && !rules.finds.rollExcluded.includes(item.id));
26536
- const here = rollable.filter((item) => item.finds?.places.includes(place));
26537
- return here.length > 0 ? here : rollable;
26538
- };
26539
- var rarityWeight = (catalog, item) => catalog.rules.rarity.weights[item.rarity];
26540
- var pickCategory = (weights, random) => {
26541
- let remaining = random();
26542
- const categories = Object.keys(weights);
26543
- for (const category of categories) {
26544
- remaining -= weights[category];
26545
- if (remaining <= 0) return category;
26546
- }
26547
- return categories[0];
26548
- };
26549
- var rollByCategory = (catalog, query) => {
26550
- const { rules } = catalog;
26551
- const table = catalog.containers.get(query.container) ?? catalog.containers.get(rules.finds.fallbackContainer);
26552
- if (!table) return [];
26553
- const [low, high] = table.count ?? [0, 0];
26554
- const drawn = low + Math.floor(query.rng() * (high - low + 1));
26555
- const count = scaleCount(drawn, { place: query.place, day: query.day ?? 0, ...query.region === void 0 ? {} : { region: query.region } }, rules);
26556
- const weights = table.categories ?? table.categoriesByPlace?.[query.place] ?? table.categoriesByPlace?.["*"];
26557
- if (!weights) return [];
26558
- const picked = [];
26559
- for (let stack = 0; stack < count; stack++) {
26560
- const category = pickCategory(weights, query.rng);
26561
- const pool = category === void 0 ? [] : rollableItems(catalog, category, query.place);
26562
- if (pool.length === 0) continue;
26563
- const total = pool.reduce((sum, item) => sum + rarityWeight(catalog, item), 0);
26564
- let remaining = query.rng() * total;
26565
- for (const item of pool) {
26566
- remaining -= rarityWeight(catalog, item);
26567
- if (remaining <= 0) {
26568
- picked.push(item.id);
26569
- break;
26570
- }
26571
- }
26572
- }
26573
- return picked;
26574
- };
26575
- var weightedOrder = (candidates, random) => {
26576
- const remaining = [...candidates];
26577
- const ordered = [];
26578
- while (remaining.length > 0) {
26579
- const total = remaining.reduce((sum, candidate) => sum + candidate.weight, 0);
26580
- let x = random() * total;
26581
- let index = 0;
26582
- for (; index < remaining.length - 1; index++) {
26583
- x -= remaining[index].weight;
26584
- if (x < 0) break;
26585
- }
26586
- ordered.push(...remaining.splice(index, 1));
26587
- }
26588
- return ordered;
26589
- };
26590
- var countFor = (pool, state, footprint, query, rules) => {
26591
- const settings = rules.finds.pool;
26592
- const base2 = Math.max(settings.min, Math.min(settings.max, Math.round(settings.offset + footprint * settings.perSquareMetre + query.rng() * settings.jitter)));
26593
- if (state === "fortified") return Math.min(pool.length, base2 + settings.fortifiedExtra);
26594
- if (state === "abandoned") return query.rng() < settings.abandonedEmptyChance ? 0 : settings.abandonedKept;
26595
- return base2;
26596
- };
26597
- var rollExplicitPool = (pool, state, query, rules) => {
26598
- const settings = rules.finds.pool;
26599
- const n = countFor(pool, state, query.footprint ?? settings.defaultFootprint, query, rules);
26600
- const isFortified = state === "fortified";
26601
- const candidates = pool.map((entry2) => ({ entry: entry2, weight: isFortified && entry2.isSupply ? entry2.weight * settings.supplyWeight : entry2.weight }));
26602
- const picks = [];
26603
- for (const { entry: entry2 } of weightedOrder(candidates, query.rng).slice(0, n)) {
26604
- const [low, high] = entry2.qty;
26605
- const bonus = isFortified && entry2.isSupply ? settings.supplyExtraQty : 0;
26606
- picks.push({ itemId: entry2.item, count: low + Math.floor(query.rng() * (high - low + 1)) + bonus, entry: entry2 });
26607
- }
26608
- if (state === "abandoned") {
26609
- if (picks.length === 0 && query.rng() < settings.junkChance) picks.push({ itemId: settings.junkItem, count: 1 });
26610
- if (settings.coldContainers.includes(query.container) || query.key !== void 0 && settings.coldContainers.includes(query.key)) picks.push({ itemId: settings.spoiledFoodItem, count: 1 });
26611
- }
26612
- return picks;
26613
- };
26614
- var WEARING_DURABILITY = ["condition", "hits", "cuts"];
26615
- var hasCondition = (item) => item.protection !== void 0 || item.weapon !== void 0 || WEARING_DURABILITY.includes(item.durability?.kind ?? "");
26616
- var between = (range2, random) => range2[0] + random() * (range2[1] - range2[0]);
26617
- var spawnAgeDays = (item, outbreakDays, random, catalog) => item.shelfLife === void 0 ? void 0 : outbreakDays + between(catalog.rules.spawn.ageShare, random) * item.shelfLife;
26618
- var isRetailStock = (query, catalog) => {
26619
- const { spawn } = catalog.rules;
26620
- const isRetail = spawn.retailNew && (query.day ?? 0) <= 0 && spawn.retailPlaces.includes(query.place);
26621
- return isRetail && (spawn.retailContainers.length === 0 || spawn.retailContainers.includes(query.container));
26622
- };
26623
- var spawnData = (item, query, catalog) => {
26624
- const { spawn } = catalog.rules;
26625
- const data = {};
26626
- const ageDays = spawnAgeDays(item, query.day ?? 0, query.rng, catalog);
26627
- if (ageDays !== void 0) data.ageDays = ageDays;
26628
- if (hasCondition(item)) data.condition = isRetailStock(query, catalog) ? 100 : Math.round(between(spawn.condition[item.rarity], query.rng));
26629
- if (item.charge) data.charge = between(spawn.charge, query.rng);
26630
- if (spawn.fillable.includes(item.id)) data.fill = between(spawn.fill, query.rng);
26631
- return Object.keys(data).length > 0 ? data : void 0;
26632
- };
26633
- function createFindsProvider(catalog, options = {}) {
26634
- const rules = options.rules ? deepMerge(catalog.rules, options.rules) : catalog.rules;
26635
- const scoped = rules === catalog.rules ? catalog : { ...catalog, rules };
26636
- const usesPools = (options.pools ?? "team") === "team";
26637
- const aliases = options.placeAliases ?? {};
26638
- const poolPlaces = options.poolPlaces;
26639
- const passes = options.unknownContainers === "pass";
26640
- const choose2 = (query) => {
26641
- const pool = usesPools && (poolPlaces === void 0 || poolPlaces.includes(query.place)) ? scoped.pools.get(query.key ?? query.container) ?? scoped.pools.get(query.container) : void 0;
26642
- if (!pool && passes && !scoped.containers.has(query.container)) return null;
26643
- if (!pool) return rollByCategory(scoped, query).map((itemId) => ({ itemId, count: 1 }));
26644
- return rollExplicitPool(pool, rules.finds.states[query.state] ?? "normal", query, rules).map(({ itemId, count }) => ({ itemId, count }));
26645
- };
26646
- return {
26647
- findsFor(asked) {
26648
- const query = aliases[asked.place] === void 0 ? asked : { ...asked, place: aliases[asked.place] };
26649
- const chosen = choose2(query);
26650
- if (chosen === null) return null;
26651
- return chosen.filter((stack) => scoped.has(stack.itemId)).map((stack) => {
26652
- const data = spawnData(scoped.get(stack.itemId), query, scoped);
26653
- return data ? { ...stack, data } : stack;
26654
- });
26655
- }
26656
- };
26657
- }
26658
- var MM = 1e-3;
26659
- var BOX_WALL = 6 * MM;
26660
-
26661
26926
  // ../game-items-goods/dist/index.js
26662
26927
  var FLOORPLAN_POOL_KEYS = {
26663
26928
  fridge: "geladeira",
@@ -27478,6 +27743,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
27478
27743
  isTakeable: true,
27479
27744
  weight: 0.7,
27480
27745
  isSupply: false
27746
+ },
27747
+ {
27748
+ type: "talheres",
27749
+ item: "cutlery",
27750
+ name: "Talheres",
27751
+ qty: [
27752
+ 1,
27753
+ 2
27754
+ ],
27755
+ viewerCategory: "utensilio",
27756
+ isTakeable: true,
27757
+ weight: 1.5,
27758
+ isSupply: false
27481
27759
  }
27482
27760
  ],
27483
27761
  aereo: [
@@ -37298,15 +37576,28 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37298
37576
  shape: "jar",
37299
37577
  color: 15786216,
37300
37578
  rarity: "common",
37579
+ parts: [
37580
+ {
37581
+ id: "body",
37582
+ material: "plastic",
37583
+ thickness: 6e-4
37584
+ }
37585
+ ],
37301
37586
  nutrition: {
37302
37587
  satiety: 10,
37303
37588
  hydration: 5
37304
37589
  },
37305
37590
  shelfLife: 28,
37306
37591
  estimated: [
37592
+ "parts",
37307
37593
  "nutrition",
37308
- "shelfLife"
37309
- ]
37594
+ "shelfLife",
37595
+ "fluid"
37596
+ ],
37597
+ fluid: {
37598
+ liquid: "yogurt",
37599
+ liters: 0.17
37600
+ }
37310
37601
  },
37311
37602
  {
37312
37603
  id: "apple",
@@ -37408,12 +37699,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37408
37699
  shape: "jar",
37409
37700
  color: 15784160,
37410
37701
  rarity: "common",
37702
+ parts: [
37703
+ {
37704
+ id: "body",
37705
+ material: "plastic",
37706
+ thickness: 6e-4
37707
+ }
37708
+ ],
37411
37709
  nutrition: {
37412
37710
  satiety: 10,
37413
37711
  hydration: 4
37414
37712
  },
37415
37713
  shelfLife: 180,
37416
37714
  estimated: [
37715
+ "parts",
37417
37716
  "nutrition",
37418
37717
  "shelfLife"
37419
37718
  ]
@@ -37594,6 +37893,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37594
37893
  shape: "box",
37595
37894
  color: 15790304,
37596
37895
  rarity: "common",
37896
+ model: "soap",
37597
37897
  parts: [
37598
37898
  {
37599
37899
  id: "body",
@@ -37629,6 +37929,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37629
37929
  shape: "bottle",
37630
37930
  color: 4885200,
37631
37931
  rarity: "common",
37932
+ model: "shampoo",
37632
37933
  consumable: {
37633
37934
  form: "liquid",
37634
37935
  unit: "ml",
@@ -37636,6 +37937,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37636
37937
  dose: 8,
37637
37938
  emptyKg: 0.044,
37638
37939
  density: 1.02
37940
+ },
37941
+ parts: [
37942
+ {
37943
+ id: "body",
37944
+ material: "plastic",
37945
+ thickness: 8e-4
37946
+ }
37947
+ ],
37948
+ estimated: [
37949
+ "fluid",
37950
+ "parts"
37951
+ ],
37952
+ fluid: {
37953
+ liquid: "shampoo"
37639
37954
  }
37640
37955
  },
37641
37956
  {
@@ -37655,13 +37970,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37655
37970
  shape: "tube",
37656
37971
  color: 15790320,
37657
37972
  rarity: "common",
37973
+ model: "toothpaste",
37658
37974
  consumable: {
37659
37975
  form: "paste",
37660
37976
  unit: "g",
37661
37977
  amount: 90,
37662
37978
  dose: 1,
37663
37979
  emptyKg: 0.01
37664
- }
37980
+ },
37981
+ parts: [
37982
+ {
37983
+ id: "body",
37984
+ material: "plastic",
37985
+ thickness: 8e-4
37986
+ }
37987
+ ],
37988
+ estimated: [
37989
+ "parts"
37990
+ ]
37665
37991
  },
37666
37992
  {
37667
37993
  id: "toothbrush",
@@ -37679,7 +38005,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37679
38005
  stack: 3,
37680
38006
  shape: "tool",
37681
38007
  color: 3840720,
37682
- rarity: "common"
38008
+ rarity: "common",
38009
+ model: "toothbrush",
38010
+ parts: [
38011
+ {
38012
+ id: "body",
38013
+ material: "plastic",
38014
+ thickness: 5e-3
38015
+ }
38016
+ ],
38017
+ estimated: [
38018
+ "parts"
38019
+ ]
37683
38020
  },
37684
38021
  {
37685
38022
  id: "deodorant",
@@ -37791,8 +38128,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37791
38128
  ],
37792
38129
  estimated: [
37793
38130
  "parts",
38131
+ "fluid",
37794
38132
  "consumable"
37795
38133
  ],
38134
+ fluid: {
38135
+ liquid: "detergent"
38136
+ },
37796
38137
  consumable: {
37797
38138
  form: "liquid",
37798
38139
  unit: "ml",
@@ -37827,8 +38168,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37827
38168
  }
37828
38169
  ],
37829
38170
  estimated: [
37830
- "parts"
37831
- ]
38171
+ "parts",
38172
+ "fluid"
38173
+ ],
38174
+ fluid: {
38175
+ liquid: "bleach",
38176
+ liters: 1
38177
+ }
37832
38178
  },
37833
38179
  {
37834
38180
  id: "sponge",
@@ -38431,7 +38777,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
38431
38777
  stack: 1,
38432
38778
  shape: "can",
38433
38779
  color: 15261904,
38434
- rarity: "common"
38780
+ rarity: "common",
38781
+ estimated: [
38782
+ "fluid"
38783
+ ],
38784
+ fluid: {
38785
+ liquid: "paint",
38786
+ liters: 3.6
38787
+ }
38435
38788
  },
38436
38789
  {
38437
38790
  id: "ice_pack",
@@ -38791,8 +39144,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
38791
39144
  }
38792
39145
  ],
38793
39146
  estimated: [
38794
- "parts"
38795
- ]
39147
+ "parts",
39148
+ "fluid"
39149
+ ],
39150
+ fluid: {
39151
+ liquid: "disinfectant",
39152
+ liters: 0.5
39153
+ }
38796
39154
  },
38797
39155
  {
38798
39156
  id: "seasoning",
@@ -39012,8 +39370,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
39012
39370
  }
39013
39371
  ],
39014
39372
  estimated: [
39015
- "parts"
39016
- ]
39373
+ "parts",
39374
+ "powder"
39375
+ ],
39376
+ powder: {
39377
+ color: 15659508
39378
+ }
39017
39379
  },
39018
39380
  {
39019
39381
  id: "broom",
@@ -39125,8 +39487,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
39125
39487
  }
39126
39488
  ],
39127
39489
  estimated: [
39128
- "parts"
39129
- ]
39490
+ "parts",
39491
+ "fluid"
39492
+ ],
39493
+ fluid: {
39494
+ liquid: "fabric_softener",
39495
+ liters: 2
39496
+ }
39130
39497
  },
39131
39498
  {
39132
39499
  id: "clothespins",
@@ -39553,9 +39920,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
39553
39920
  shed: false
39554
39921
  },
39555
39922
  use: {
39556
- clip: "open_can_eat",
39923
+ clip: "eat_food",
39557
39924
  sounds: [
39558
- "can_open",
39559
39925
  "chew"
39560
39926
  ]
39561
39927
  },
@@ -39723,9 +40089,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
39723
40089
  shed: false
39724
40090
  },
39725
40091
  use: {
39726
- clip: "open_can_drink",
40092
+ clip: "drink",
39727
40093
  sounds: [
39728
- "can_open",
39729
40094
  "gulp"
39730
40095
  ]
39731
40096
  },
@@ -44034,6 +44399,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44034
44399
  clip: "turn_key"
44035
44400
  }
44036
44401
  },
44402
+ {
44403
+ id: "eat_with_cutlery",
44404
+ effect: "eat_with",
44405
+ consumes: false,
44406
+ items: [
44407
+ "cutlery"
44408
+ ],
44409
+ params: {
44410
+ clip: "eat_with_cutlery"
44411
+ }
44412
+ },
44037
44413
  {
44038
44414
  id: "swap_bag",
44039
44415
  effect: "swap_bag",
@@ -44218,7 +44594,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44218
44594
  var liquidContainer = {
44219
44595
  id: "liquid_container",
44220
44596
  check: (item) => {
44221
- const fluid = item.fluid;
44597
+ const fluid = itemFluid(item);
44222
44598
  if (fluid) {
44223
44599
  const problems = [];
44224
44600
  if (typeof fluid.liquid !== "string" || !SNAKE_CASE.test(fluid.liquid)) problems.push("fluid.liquid must be a liquid id");
@@ -45340,7 +45716,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45340
45716
  };
45341
45717
  var GOODS_STRINGS = { en: en_default2, "pt-BR": pt_BR_default2 };
45342
45718
  var drinkHydrationOf = (item, liquids = LIQUIDS) => {
45343
- const fluid = item.fluid;
45719
+ const fluid = itemFluid(item);
45344
45720
  const drink = fluid ? liquids.find((liquid) => liquid.id === fluid.liquid)?.drink : void 0;
45345
45721
  if (!fluid || !drink) return void 0;
45346
45722
  const doses = item.durability?.kind === "doses" ? Math.max(1, item.durability.amount ?? 1) : 1;
@@ -48094,8 +48470,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
48094
48470
  { type: "tv_unit", category: "tv_unit", w: 1.6, d: 0.45, h: 0.55, opening: 0.4 },
48095
48471
  { type: "tv_unit_small", category: "tv_unit", w: 1.2, d: 0.4, h: 0.5, opening: 0.4 },
48096
48472
  { type: "tv_unit_large", category: "tv_unit", w: 1.9, d: 0.45, h: 0.6, opening: 0.4 },
48097
- { type: "tv", category: "tv", w: 0.9, d: 0.1, h: 0.55 },
48098
- { type: "tv_large", category: "tv", w: 1.2, d: 0.1, h: 0.7 },
48473
+ { type: "tv", category: "tv", w: 0.9, d: 0.1, h: 0.55, massKg: 12, partMaterials: { metal_0: "glass" } },
48474
+ { type: "tv_large", category: "tv", w: 1.2, d: 0.1, h: 0.7, massKg: 16, partMaterials: { metal_0: "glass" } },
48099
48475
  { type: "coffee_table", category: "coffee_table", w: 0.9, d: 0.55, h: 0.42 },
48100
48476
  { type: "coffee_table_round", category: "coffee_table", w: 0.6, d: 0.6, h: 0.4 },
48101
48477
  { type: "rug", category: "rug", w: 2.4, d: 1.7, h: 0.02, flat: true, color: { role: "fabric_accent" } },
@@ -48120,7 +48496,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
48120
48496
  { type: "dining_table", category: "dining_table", w: 1.1, d: 0.8, h: 0.78 },
48121
48497
  { type: "dining_table_small", category: "dining_table", w: 0.9, d: 0.7, h: 0.75 },
48122
48498
  { type: "dining_table_round", category: "dining_table", w: 0.9, d: 0.9, h: 0.75 },
48123
- { type: "microwave", category: "appliance", w: 0.5, d: 0.4, h: 0.3, color: { role: "metal" } },
48499
+ { type: "microwave", category: "appliance", w: 0.5, d: 0.4, h: 0.3, color: { role: "metal" }, material: "steel", massKg: 14 },
48124
48500
  { type: "trash_bin", category: "trash_bin", w: 0.3, d: 0.3, h: 0.6 },
48125
48501
  { type: "pantry", category: "pantry", w: 1.2, d: 0.4, h: 2, opening: 0.5 },
48126
48502
  { type: "double_bed", category: "bed", w: 1.6, d: 2.05, h: 0.62, color: { role: "fabric_main" } },
@@ -48141,7 +48517,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
48141
48517
  { type: "shower_large", category: "shower", windowHeight: 1.95, w: 1.1, d: 1.1, h: 0.1, color: { role: "ceiling" } },
48142
48518
  { type: "hamper", category: "hamper", w: 0.35, d: 0.3, h: 0.5 },
48143
48519
  { type: "laundry_tub", category: "laundry_tub", w: 0.6, d: 0.55, h: 0.9, color: { role: "metal" } },
48144
- { type: "washing_machine", category: "washing_machine", w: 0.6, d: 0.65, h: 0.9, opening: 0.5, color: { role: "metal" } },
48520
+ { type: "washing_machine", category: "washing_machine", w: 0.6, d: 0.65, h: 0.9, opening: 0.5, color: { role: "metal" }, material: "steel", massKg: 70 },
48145
48521
  { type: "laundry_cabinet", category: "laundry_cabinet", w: 0.8, d: 0.4, h: 1.8, opening: 0.45 },
48146
48522
  { type: "laundry_shelf", category: "laundry_shelf", w: 1, d: 0.35, h: 1.6 },
48147
48523
  { type: "car", category: "car", w: 1.85, d: 4.3, h: 1.5, color: { pick: [1842206, 15263974, 10132897, 8003359, 2046559, 4016698, 12103834] } },
@@ -49272,7 +49648,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49272
49648
  }
49273
49649
  var residentialTower = residentialTowerTemplate();
49274
49650
 
49275
- // ../game-floorplan-three/dist/chunk-KOJFBQRC.js
49651
+ // ../game-floorplan-three/dist/chunk-LEMQWENS.js
49276
49652
  var __defProp3 = Object.defineProperty;
49277
49653
  var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
49278
49654
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -49287,6 +49663,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49287
49663
  "what.door": "the door",
49288
49664
  "what.curtain": "the curtain",
49289
49665
  "what.mailbox": "the mailbox",
49666
+ "what.lid": "the lid",
49667
+ "what.tankLid": "the tank lid",
49290
49668
  "what.stallDoor": "the shower door",
49291
49669
  "what.pedestrianGate": "the small gate",
49292
49670
  "what.garageGate": "the garage gate",
@@ -49315,6 +49693,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49315
49693
  "what.door": "a porta",
49316
49694
  "what.curtain": "a cortina",
49317
49695
  "what.mailbox": "a caixa de correio",
49696
+ "what.lid": "a tampa",
49697
+ "what.tankLid": "a tampa da caixa d'\xE1gua",
49318
49698
  "what.stallDoor": "a porta do box",
49319
49699
  "what.pedestrianGate": "o port\xE3ozinho",
49320
49700
  "what.garageGate": "o port\xE3o da garagem",
@@ -50073,13 +50453,23 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50073
50453
  (groups[A.group] || (groups[A.group] = new THREE.Group())).add(m);
50074
50454
  }
50075
50455
  cursor.accs.clear();
50456
+ const owners = /* @__PURE__ */ new Map();
50076
50457
  for (const P of PARTS) {
50077
50458
  const g = groups[P.name] || new THREE.Group();
50078
50459
  delete groups[P.name];
50079
- g.name = P.name;
50080
- g.position.set(P.pos[0], P.pos[1], P.pos[2]);
50081
- g.rotation.y = P.ry || 0;
50460
+ const owner = owners.get(P.parent), ry = P.ry || 0;
50461
+ if (owner) {
50462
+ const dx = P.pos[0] - owner.pos[0], dz = P.pos[2] - owner.pos[2], c = Math.cos(owner.ry), s = Math.sin(owner.ry);
50463
+ g.name = P.name;
50464
+ g.position.set(dx * c - dz * s, P.pos[1] - owner.pos[1], dx * s + dz * c);
50465
+ g.rotation.y = ry - owner.ry;
50466
+ } else {
50467
+ g.name = P.name;
50468
+ g.position.set(P.pos[0], P.pos[1], P.pos[2]);
50469
+ g.rotation.y = ry;
50470
+ }
50082
50471
  g.updateMatrix();
50472
+ owners.set(P.name, { g, pos: P.pos, ry });
50083
50473
  Object.assign(g.userData, P.meta, { part: P.type, pivot: true, ...P.stage ? { constructionStage: P.stage } : {} });
50084
50474
  g.traverse((o) => {
50085
50475
  if (o !== g) o.userData.part = P.type;
@@ -50090,7 +50480,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50090
50480
  applyPart(g, 0);
50091
50481
  if (P.meta.t0) applyPart(g, P.meta.t0);
50092
50482
  }
50093
- (groups[P.parent] || (groups[P.parent] = new THREE.Group())).add(g);
50483
+ (owner ? owner.g : groups[P.parent] || (groups[P.parent] = new THREE.Group())).add(g);
50094
50484
  if (P.meta.id) (shared2.ctx.parts || (shared2.ctx.parts = {}))[P.meta.id] = g;
50095
50485
  }
50096
50486
  PARTS.length = 0;
@@ -50548,7 +50938,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50548
50938
  if (!shared2.ctx.visorScene) shared2.ctx.occupied.push(b2);
50549
50939
  };
50550
50940
  const jw = DOOR_JAMB_WIDTH, jin = shared2.ctx.visorScene ? 0 : 2e-3, jy = !shared2.ctx.visorScene && f > 0 ? 2e-3 : 0;
50551
- cursor.pc = pieceRecord("jamb:" + p.id, "wood_hard", null, { floor: f });
50941
+ cursor.pc = pieceRecord("jamb:" + p.id, "wood_hard", null, { floor: f, aperture: { alongU, a: a + jw, b: b - jw, y0: y0 + jy, y1: y0 + (cut ? visH : dH - jw) } });
50552
50942
  fb(a - jin, jy, a + jw, visH);
50553
50943
  fb(b - jw, jy, b + jin, visH);
50554
50944
  if (!cut) fb(a, dH - jw, b, dH);
@@ -55087,9 +55477,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55087
55477
  for (const sx of [-1, 1]) for (const sz of [-1, 1]) lb("wood", sx * (w / 2 - 0.06), 0, sz * (d / 2 - 0.06), 0.05, h - 0.04, 0.05, sh(wood, 0.75));
55088
55478
  }
55089
55479
  if (o.tablecloth) lb("fabric", 0, h, 0, w * 0.7, 5e-3, d * 0.95, paletteColor(M, "fabric_accent", 14207144));
55480
+ if (o.drawer && !o.round && !M.visorScene) {
55481
+ const cw = Math.min(0.42, w / 2 - 0.175), cx = w / 2 - 0.1 - cw / 2, ch = 0.14, cy = h - 0.04 - ch, back2 = -d / 2 + 0.1, front = d / 2 - 0.01;
55482
+ lb("wood", cx, cy, (back2 + front) / 2, cw, ch, front - back2, sh(wood, 0.9));
55483
+ lb("wood", cx, cy + 0.015, front + 5e-3, cw - 0.03, ch - 0.03, 0.012, sh(wood, 1.12));
55484
+ lc("metal", cx, cy + ch / 2 - 0.015, front + 0.02, 0.015, 0.02, 11575408, PE);
55485
+ }
55090
55486
  if (o.noChairs) return;
55091
55487
  const chair = (u, v, g) => {
55092
- const C = { x: M.x + u * Math.cos(M.ry) + v * Math.sin(M.ry), z: M.z - u * Math.sin(M.ry) + v * Math.cos(M.ry), ry: M.ry + g, base: M.base, palette: M.palette }, k = kk(C, A);
55488
+ const C = { x: M.x + u * Math.cos(M.ry) + v * Math.sin(M.ry), z: M.z - u * Math.sin(M.ry) + v * Math.cos(M.ry), ry: M.ry + g, base: M.base, palette: M.palette, chair: true }, k = kk(C, A);
55093
55489
  k.b("wood", 0, 0.44, 0, 0.42, 0.04, 0.42, chairColor);
55094
55490
  for (const sx of [-1, 1]) for (const sz of [-1, 1]) k.b("wood", sx * 0.18, 0, sz * 0.18, 0.035, 0.44, 0.035, sh(chairColor, 0.7));
55095
55491
  k.b("wood", 0, 0.48, -0.19, 0.42, 0.45, 0.03, chairColor);
@@ -55304,9 +55700,26 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55304
55700
  lb("plain", 0, h - 0.18, d / 2 + 5e-3, w - 0.1, 0.1, 0.01, 3816e3);
55305
55701
  },
55306
55702
  hamper(M, A) {
55307
- const { c: lc } = kk(M, A), r = M.visorScene ? M.w / 2 : Math.min(M.w, M.d) / 2;
55308
- lc("plain", 0, 0, 0, r, M.h, paletteColor(M, "fabric_accent", 10127978));
55309
- lc("plain", 0, M.h - 0.01, 0, r - 0.03, 0.02, 2763306);
55703
+ if (M.visorScene) {
55704
+ const { c: lc } = kk(M, A), r23 = M.w / 2;
55705
+ lc("plain", 0, 0, 0, r23, M.h, paletteColor(M, "fabric_accent", 10127978));
55706
+ lc("plain", 0, M.h - 0.01, 0, r23 - 0.03, 0.02, 2763306);
55707
+ return;
55708
+ }
55709
+ const K2 = kit2(M, A), r = Math.min(M.w, M.d) / 2, color2 = paletteColor(M, "fabric_accent", 10127978), rim = M.h - 0.03;
55710
+ K2.c("plain", 0, 0, 0, r, rim, color2);
55711
+ K2.c("plain", 0, rim, 0, r - 0.03, 2e-3, 2763306);
55712
+ K2.part(
55713
+ "lid",
55714
+ 0,
55715
+ rim + 5e-3,
55716
+ -r,
55717
+ () => {
55718
+ K2.c("plain", 0, rim + 5e-3, 0, r + 5e-3, 0.025, sh(color2, 0.9));
55719
+ K2.c("plain", 0, M.h, r * 0.7, 0.02, 0.012, sh(color2, 0.6));
55720
+ },
55721
+ { id: "lid_" + M.seed, lid: { hand: [0, 0.03, r * 1.7] }, opens: { type: "swing", axis: [1, 0, 0], angle: -1.75 } }
55722
+ );
55310
55723
  },
55311
55724
  // (outside the Visor's scene the round basket fits its footprint's narrow side: it stood 2.5 cm in the wall behind it)
55312
55725
  trash_bin(M, A) {
@@ -55602,9 +56015,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55602
56015
  mine("outdoor_table", (M, A) => FURNITURE.table(M, A, { headboard: true }));
55603
56016
  mine("gourmet_table", (M, A) => FURNITURE.table(M, A, { headboard: true }));
55604
56017
  mine("gourmet_table_small", (M, A) => FURNITURE.table(M, A, {}));
55605
- mine("office_desk", (M, A) => FURNITURE.table(M, A, { oneSide: true }));
55606
- mine("office_desk_large", (M, A) => FURNITURE.table(M, A, { oneSide: true }));
55607
- mine("desk", (M, A) => FURNITURE.table(M, A, { oneSide: true }));
56018
+ mine("office_desk", (M, A) => FURNITURE.table(M, A, { oneSide: true, drawer: true }));
56019
+ mine("office_desk_large", (M, A) => FURNITURE.table(M, A, { oneSide: true, drawer: true }));
56020
+ mine("desk", (M, A) => FURNITURE.table(M, A, { oneSide: true, drawer: true }));
55608
56021
  mine("double_bed", FURNITURE.bed);
55609
56022
  mine("queen_bed", FURNITURE.bed);
55610
56023
  mine("king_bed", FURNITURE.bed);
@@ -56131,8 +56544,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56131
56544
  K2.c("plain", 0, y0, 0, r, th, color2);
56132
56545
  for (const f of [0.18, 0.5, 0.82]) K2.c("plain", 0, y0 + th * f - 0.025, 0, r * 1.028, 0.05, sh(color2, 0.88));
56133
56546
  K2.e("plain", 0, y0 + th + 0.03, 0, r * 1, 0.16, sh(color2, 0.95));
56134
- K2.c("plain", 0, y0 + th + 0.09, 0, r * 0.5, 0.05, sh(color2, 0.8));
56135
- K2.c("plain", 0, y0 + th + 0.14, 0, r * 0.18, 0.035, 1916262);
56547
+ const hatch = () => {
56548
+ K2.c("plain", 0, y0 + th + 0.09, 0, r * 0.5, 0.05, sh(color2, 0.8));
56549
+ K2.c("plain", 0, y0 + th + 0.14, 0, r * 0.18, 0.035, 1916262);
56550
+ };
56551
+ if (shared2.ctx.visorScene) hatch();
56552
+ else K2.part("lid", 0, y0 + th + 0.09, -r * 0.5, hatch, { id: "lid_" + M.seed, lid: { hand: [0, 0.06, r * 0.9] }, opens: { type: "swing", axis: [1, 0, 0], angle: -1.75 } });
56136
56553
  }, { id: "tank_" + M.seed, breakable: true, fluid: "water", volume: Math.PI * r * r * th, radius: r, height: th });
56137
56554
  K2.t("metal", [r * 0.7, y0 + th * 0.25, 0], [r * 0.7, y0 + 0.03, 0], 0.02, 3159096);
56138
56555
  K2.t("metal", [r * 0.7, y0 + 0.03, 0], [r * 0.7 + 0.2, y0 + 0.03, 0], 0.02, 3159096);
@@ -56889,6 +57306,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56889
57306
  return;
56890
57307
  }
56891
57308
  n.updateMatrix();
57309
+ shared2.ctx.posePiece?.(p.name);
56892
57310
  }
56893
57311
  const DURATION = { swing: 0.55, drawer: 0.4, curtain: 0.9, gate_swing: 0.9, gate_tilt: 1.4, gate_slide: 1.6, lightSwitch: 0.12, part: 0.4 };
56894
57312
  function animateInteractive(dt) {
@@ -57041,6 +57459,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57041
57459
  sauna: ({ d }) => [{ id: "bench", pose: "sit", pos: [0, SAUNA_BENCH, -d / 4], ry: 0, exit: [0, 0, d / 2 + 0.5] }]
57042
57460
  };
57043
57461
  var planFurnitureSeats = (type, size) => PLAN_FURNITURE_SEATS[type]?.(size) ?? [];
57462
+ var PLAN_FURNITURE_HAND_PARTS = {
57463
+ desk: "drawer",
57464
+ office_desk: "drawer",
57465
+ office_desk_large: "drawer",
57466
+ vanity_table: "drawer",
57467
+ hamper: "lid",
57468
+ water_tank: "lid"
57469
+ };
57044
57470
  function installInteractionItems(K, shared2) {
57045
57471
  const { t, LIGHTS, cursor, definePiece, localOf, registerCollision, togglePiece } = K;
57046
57472
  const DOOR_ITEM = /^(tv_unit|tv_unit_small|tv_unit_large|sideboard|china_cabinet|filing_cabinet|pantry|laundry_cabinet|wardrobe|wardrobe_small|wardrobe_large|closet_wardrobe|kitchen_cabinet|kitchen_cabinet_large|kitchen_cabinet_small|fridge|fridge_large|display_fridge_medium|display_fridge)$/;
@@ -57063,7 +57489,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57063
57489
  seatItem(m, M);
57064
57490
  if (LIGHT_TYPES.has(type)) return lightItem(m, M, ent, api, parent);
57065
57491
  if (type === "curtain") return curtainItem(m, M, ent, api, parent);
57066
- if (DOOR_ITEM.test(type) || DRAWER_ITEM.test(type)) return furnitureItem(m, M, ent, api, parent, DRAWER_ITEM.test(type));
57492
+ const drawer2 = DRAWER_ITEM.test(type) || !M.visorScene && PLAN_FURNITURE_HAND_PARTS[type] === "drawer";
57493
+ if (DOOR_ITEM.test(type) || drawer2) return furnitureItem(m, M, ent, api, parent, drawer2);
57067
57494
  ent.f(M, api);
57068
57495
  }
57069
57496
  function seatItem(m, M) {
@@ -57285,6 +57712,21 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57285
57712
  applyPiece(def);
57286
57713
  }
57287
57714
  }
57715
+ function lidsInteractive() {
57716
+ const parts2 = shared2.ctx.parts;
57717
+ if (!parts2) return;
57718
+ for (const m of house().items) {
57719
+ const g = parts2["lid_" + m.id];
57720
+ if (!g) continue;
57721
+ const lid = g.userData.lid, hand = lid?.hand ?? [0, 0, 0];
57722
+ const def = definePiece("ix:lid:" + m.id, { kind: "part", pivot: [0, 0, 0], ry: 0, parent: "lot" });
57723
+ def.inner = g;
57724
+ g.updateWorldMatrix(true, false);
57725
+ const at2 = g.localToWorld(new K.THREE.Vector3(hand[0], hand[1], hand[2]));
57726
+ I().items.push({ type: "lid", id: m.id, floor: m.floor ?? 0, anchor: [at2.x, at2.y, at2.z], range: 1.6, angle: 0.9, pieces: [def], text: () => t(def.target > 0.5 ? "prompt.close" : "prompt.open", { what: t("what." + (m.type === "water_tank" ? "tankLid" : "lid")) }), action: () => togglePiece(def) });
57727
+ applyPiece(def);
57728
+ }
57729
+ }
57288
57730
  function placeSwitches() {
57289
57731
  const R = house(), used = /* @__PURE__ */ new Set();
57290
57732
  for (const c of R.rooms) {
@@ -57338,7 +57780,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57338
57780
  }
57339
57781
  return false;
57340
57782
  }
57341
- const defined = { walkInInteractive, gatesInteractive, mailboxInteractive, placeSwitches, putSwitch };
57783
+ const defined = { walkInInteractive, gatesInteractive, mailboxInteractive, lidsInteractive, placeSwitches, putSwitch };
57342
57784
  Object.assign(K, defined);
57343
57785
  }
57344
57786
  function installInteractionDoors(K, shared2) {
@@ -57452,6 +57894,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57452
57894
  else g.rotation.y = fo.t * fo.rot;
57453
57895
  g.updateMatrix();
57454
57896
  }
57897
+ shared2.ctx.posePiece?.("door:" + fo.id);
57455
57898
  }
57456
57899
  const defined = { linkDoorLeaves, handleApply, toggleDoor, animateDoors, wallBlocks, doorText, applyLeaf };
57457
57900
  Object.assign(K, defined);
@@ -58703,6 +59146,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58703
59146
  K.applyPiece(def);
58704
59147
  }
58705
59148
  root.updateMatrixWorld(true);
59149
+ const rest2 = /* @__PURE__ */ new Map(), restOf = (id, node) => {
59150
+ if (node && shared2.ctx.pieceObjects.has(id)) rest2.set(id, { node, rest: shared2.ctx.unitInverse.clone().multiply(node.matrixWorld) });
59151
+ };
59152
+ for (const fo of shared2.ctx.leaves) restOf("door:" + fo.id, fo.gs[0]);
59153
+ for (const def of shared2.inter.defs.values()) if (def.outer && def.inner) restOf(def.name, def.inner);
59154
+ shared2.ctx.pieceRest = rest2;
58706
59155
  root.traverse((o0) => {
58707
59156
  const o = o0;
58708
59157
  if (o.isMesh && o.userData.ranges) {
@@ -58921,7 +59370,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58921
59370
  }
58922
59371
  });
58923
59372
  const walls = new Set((E0.openings ?? []).map((op) => op.wall));
58924
- return withWindowApertures({ ...spec, parts: spec.parts.map((sp) => walls.has(sp.id) && sp.apertures ? (({ apertures: _gone, ...rest2 }) => rest2)(sp) : sp) }, E0.openings ?? []);
59373
+ return withWindowApertures({ ...spec, parts: spec.parts.map((sp) => walls.has(sp.id) && sp.apertures ? (({ apertures: _gone, ...rest22 }) => rest22)(sp) : sp) }, E0.openings ?? []);
58925
59374
  }
58926
59375
  };
58927
59376
  return structure;
@@ -60119,6 +60568,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60119
60568
  Object.assign(K, { createBreachView, breachPaintQueue: paintQueue, breachCutQueue: cutQueue });
60120
60569
  }
60121
60570
  var FOLLOW_FLUSH_FALLBACK_MS = 100;
60571
+ var POSE_IDENTITY = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
60122
60572
  function installDestructionWorld(K, shared2) {
60123
60573
  const { THREE, cfg, invalidateShadow, invalidate, rngString, FRAGMENT_GEO, fragmentMaterial, createBreachView } = K;
60124
60574
  function createHouseDestruction(root, house, structure, parts2, colliders, water) {
@@ -60379,8 +60829,31 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60379
60829
  if (R) R.bind(D.id, house, { parts: rangesOf(), marksOn: marksOn(), onFrame: () => breach.flush() });
60380
60830
  off = D.world.on("*", handleEvent);
60381
60831
  D.active = true;
60832
+ for (const id of shared2.ctx.pieceRest?.keys() ?? []) D.pose(id);
60382
60833
  return D;
60383
60834
  };
60835
+ const posed = /* @__PURE__ */ new Set(), poseRest = new THREE.Matrix4(), poseNow = new THREE.Matrix4(), posePart = new THREE.Matrix4(), poseP = new THREE.Vector3(), poseQ = new THREE.Quaternion(), poseS = new THREE.Vector3(), poseE = new THREE.Euler(), poseHouse = new THREE.Matrix4();
60836
+ D.pose = (id) => {
60837
+ if (!D.active || !D.spec) return;
60838
+ const moving = shared2.ctx.pieceRest?.get(id), part = D.spec.parts.find((p) => p.id === id);
60839
+ if (!moving || !part) return;
60840
+ const node = moving.node;
60841
+ node.updateMatrix();
60842
+ house.updateMatrixWorld();
60843
+ poseHouse.copy(house.matrixWorld).invert();
60844
+ poseNow.copy(node.parent ? node.parent.matrixWorld : poseHouse.identity()).multiply(node.matrix);
60845
+ if (node.parent) poseNow.premultiply(poseHouse);
60846
+ poseRest.copy(moving.rest).invert();
60847
+ poseNow.multiply(poseRest);
60848
+ const still = poseNow.elements.every((v, i) => Math.abs(v - POSE_IDENTITY[i]) < 1e-9);
60849
+ if (still && !posed.has(id)) return;
60850
+ if (still) posed.delete(id);
60851
+ else posed.add(id);
60852
+ const r = part.rotation ?? [0, 0, 0];
60853
+ posePart.compose(poseP.set(part.position[0], part.position[1], part.position[2]), poseQ.setFromEuler(poseE.set(r[0], r[1], r[2])), poseS.set(1, 1, 1)).premultiply(poseNow).decompose(poseP, poseQ, poseS);
60854
+ poseE.setFromQuaternion(poseQ);
60855
+ D.world.setPartPose(D.id, id, [poseP.x, poseP.y, poseP.z], [poseE.x, poseE.y, poseE.z]);
60856
+ };
60384
60857
  D.deactivate = () => {
60385
60858
  if (off) off();
60386
60859
  off = null;
@@ -61298,7 +61771,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61298
61771
  return { u: P.u - Math.sign(P.frontU || 0) * PANEL_RECESS, v: P.v - Math.sign(P.frontV || 0) * PANEL_RECESS, y0: P.y - h / 2 + PANEL_LIFT - BOX_CHASE_CLEAR, y1: P.y + h / 2 + PANEL_LIFT + BOX_CHASE_CLEAR, radius: w / 2, depth: 0 };
61299
61772
  }
61300
61773
  function installBuildBuild(K, shared2) {
61301
- const { THREE, cfg, rectsOf: rectsOf2, invalidateShadow, colliderChanged, VERSION: VERSION2, CARS, EPS: EPS42, LIGHTS, MIRRORS, Y0, animateClotheslines, animateDoors, animateInteractive, applyLeaf, applyOutbuildings, applyPart, applyPiece, assembleInteractive, baseboardAndSidewalk, buildStairs, building, carModel, chooseMirror, closeScene, collideAt, createWater, cursor, doorText, doors, electricalStructure, elevator, floorsAndSlabs, gatesInteractive, houseItems, ivAssemble, ivBuild, ivDispose, ivParts, ivPublish, ivUpdate, lightOn, linkDoorLeaves, mailboxInteractive, walkInInteractive, newInteractiveState, newMirrorState, outbuildings, paths, perimeter, placeSwitches, roofs, roomAt, solar, targetOf, terrain, toggleDoor, toggleLight, walls, waterPipes, drainPipes, windows, props, TYPES, IVK, VEG, vegMaterials, markGroups, assembleStructure, pieceRecord, createHouseDestruction, newState, enter, tagDamage } = K;
61774
+ const { THREE, cfg, rectsOf: rectsOf2, invalidateShadow, colliderChanged, VERSION: VERSION2, CARS, EPS: EPS42, LIGHTS, MIRRORS, Y0, animateClotheslines, animateDoors, animateInteractive, applyLeaf, applyOutbuildings, applyPart, applyPiece, assembleInteractive, baseboardAndSidewalk, buildStairs, building, carModel, chooseMirror, closeScene, collideAt, createWater, cursor, doorText, doors, electricalStructure, elevator, floorsAndSlabs, gatesInteractive, houseItems, ivAssemble, ivBuild, ivDispose, ivParts, ivPublish, ivUpdate, lightOn, linkDoorLeaves, mailboxInteractive, lidsInteractive, walkInInteractive, newInteractiveState, newMirrorState, outbuildings, paths, perimeter, placeSwitches, roofs, roomAt, solar, targetOf, terrain, toggleDoor, toggleLight, walls, waterPipes, drainPipes, windows, props, TYPES, IVK, VEG, vegMaterials, markGroups, assembleStructure, pieceRecord, createHouseDestruction, newState, enter, tagDamage } = K;
61302
61775
  function build(r0, options) {
61303
61776
  const opts = options || {};
61304
61777
  const r = withLaidConduits(applyOutbuildings(r0), !!(opts.constructionStages || opts.constructionLevel != null));
@@ -61445,6 +61918,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61445
61918
  assembleInteractive(gs);
61446
61919
  linkDoorLeaves();
61447
61920
  mailboxInteractive();
61921
+ lidsInteractive();
61448
61922
  walkInInteractive();
61449
61923
  if (cs) {
61450
61924
  for (const def of shared2.inter.defs.values()) {
@@ -61667,6 +62141,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61667
62141
  markGroups(r, root, parts2);
61668
62142
  const structure = assembleStructure(r0, root), destruction = createHouseDestruction(root, house, structure, parts2, colliders, water);
61669
62143
  h.destruction = destruction;
62144
+ shared2.ctx.posePiece = (id) => destruction.pose(id);
61670
62145
  destruction.breach.setLod(h.lodCurrent);
61671
62146
  if (cs) {
61672
62147
  currentConstructionLevel = applyConstructionLevel(house, opts.constructionLevel ?? CONSTRUCTION_LEVEL_MAX);
@@ -62107,7 +62582,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62107
62582
  }
62108
62583
  }
62109
62584
  if (!best) return null;
62110
- const [joint] = inferJoints([best.a, best.b], best.gap + 0.05);
62585
+ const [joint] = inferJoints([best.a, best.b], Infinity);
62111
62586
  return joint ? { ...joint, id: `${best.a.id}~${best.b.id}` } : null;
62112
62587
  }
62113
62588
  var FLOOR_TOUCH = 5e-3;
@@ -62572,7 +63047,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62572
63047
  return [M.x + lx * c + lz * s, M.z - lx * s + lz * c];
62573
63048
  };
62574
63049
  const record = (M, key2, shape, px, py, pz, rx, ry, rz, color2) => {
62575
- if (o.chairs === false && M !== root || key2 === "water") return;
63050
+ if (o.chairs === false && M.chair === true || key2 === "water") return;
62576
63051
  q.setFromEuler(eul.set(rx, ry, rz, "YXZ"));
62577
63052
  const turned = rx !== 0 || ry !== 0 || rz !== 0;
62578
63053
  const size = shape.kind === "box" ? shape.size : shape.kind === "cylinder" ? [shape.radius * 2, shape.height, shape.radius * 2] : [shape.radius * 2, shape.radius * 2, shape.radius * 2];
@@ -62618,7 +63093,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62618
63093
  const boardsOf = splitTopsIntoBoards(drawn, materialOf, Boolean(opts.carcass));
62619
63094
  const parts2 = drawn.map((p) => {
62620
63095
  const thin = Math.min(...p.shape.kind === "box" ? p.shape.size : p.shape.kind === "cylinder" ? [p.shape.radius * 2, p.shape.height] : [p.shape.radius * 2]);
62621
- let material = p.material ?? materialOf[p.key] ?? "plastic";
63096
+ let material = p.material ?? opts.byPart?.[p.id] ?? materialOf[p.key] ?? "plastic";
62622
63097
  if (p.material) {
62623
63098
  } else if (p.key === "wood" && material === "wood_hard" && opts.carcass && !opts.materials?.wood) material = "mdf";
62624
63099
  else if (p.key === "wood" && material === "wood_hard" && thin < WOOD_THIN) material = "wood_soft";
@@ -62741,12 +63216,25 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62741
63216
  shared2.ctx = saved.ctx;
62742
63217
  }
62743
63218
  },
62744
- { materials: { plain: plain2, ...o.materials }, chairs: o.chairs, carcass: SHELVING.test(type) }
63219
+ { materials: { plain: plain2, ...o.materials }, chairs: o.chairs, carcass: SHELVING.test(type), ...entry2?.partMaterials ? { byPart: entry2.partMaterials } : {} }
62745
63220
  );
62746
63221
  const spouts = K.PARTS.slice(before).filter((p) => p.type === "water_tap").map((p) => [p.pos[0] - root.x, p.pos[1], p.pos[2] - root.z]);
62747
63222
  K.PARTS.length = before;
63223
+ if (entry2?.massKg !== void 0) shareMass(made2.spec.parts, entry2.massKg);
62748
63224
  return { spec: made2.spec, build: made2.build, top: made2.top, size: { w, d, h }, spouts, fixed: made2.fixed };
62749
63225
  }
63226
+ function shareMass(parts2, massKg) {
63227
+ const own = parts2.map((part) => {
63228
+ const material = MATERIALS2.find((m) => m.id === part.material);
63229
+ const { mass: _drawn, ...bare } = part;
63230
+ return material ? partMass(bare, material) : 0;
63231
+ });
63232
+ const total = own.reduce((sum, kg) => sum + kg, 0);
63233
+ if (!(total > 0)) return;
63234
+ parts2.forEach((part, at2) => {
63235
+ part.mass = Math.round((own[at2] ?? 0) / total * massKg * 1e4) / 1e4;
63236
+ });
63237
+ }
62750
63238
 
62751
63239
  // src/area-layout.ts
62752
63240
  var SHELF_HEIGHT = 0.9;
@@ -62940,8 +63428,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62940
63428
  var stageOf = (catalog, item, base2, ageDays, storage, powered) => {
62941
63429
  if (item.shelfLife === void 0 || ageDays <= 0) return base2;
62942
63430
  const state = freshness(item, { ageDays: 0, since: 0, storage, storedAt: 0 }, ageDays, { powered, rules: catalog.rules });
62943
- const aged = state === "fresh" ? 0 : state === "stale" ? 1 : 2;
62944
- return Math.max(base2, aged);
63431
+ return Math.max(base2, wearOfFreshness(state));
62945
63432
  };
62946
63433
  var sizeOfModel = (modelSet, id) => {
62947
63434
  const entry2 = modelSet.entry(id);
@@ -63055,7 +63542,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63055
63542
  };
63056
63543
  const usesOf = (def) => {
63057
63544
  const use = options.itemUse?.(def);
63058
- const contents = fluidOf({ ...def.model === void 0 ? {} : { model: def.model }, size: def.size, weight: def.weight });
63545
+ const held = itemFluid(def);
63546
+ const contents = fluidOf({ ...def.model === void 0 ? {} : { model: def.model }, size: def.size, weight: def.weight, ...held ? { fluid: held } : {} });
63059
63547
  const liquid = sealOf(def, contents.fluid ? contents : vesselOf(def));
63060
63548
  if (!use) return liquid;
63061
63549
  const edible2 = def.category === "food" || def.category === "drink";
@@ -63253,7 +63741,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63253
63741
  });
63254
63742
  };
63255
63743
  const rollFinds = () => {
63256
- const query = { place: state.place, container: state.container, state: state.state, rng: rng2(state.seed), day: state.day };
63744
+ const query = { place: state.place, container: state.container, state: state.state, rng: rng(state.seed), day: state.day };
63257
63745
  stack = [...provider.findsFor(query) ?? []];
63258
63746
  showFinds();
63259
63747
  const container = label(`container.${state.container}`, humanize(state.container));
@@ -63293,7 +63781,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63293
63781
  host?.log(fill(text.craftMissing, { recipe: name, missing: check.missing.join(", ") }), { recipe: recipe.id });
63294
63782
  return { ok: false, missing: check.missing };
63295
63783
  }
63296
- const result = craft(recipe, context, rng2(state.seed));
63784
+ const result = craft(recipe, context, rng(state.seed));
63297
63785
  if (!result.isCrafted) return { ok: false, missing: result.missing };
63298
63786
  if ("item" in result.output) {
63299
63787
  stack = [{ itemId: result.output.item, count: result.output.count }];
@@ -63524,7 +64012,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63524
64012
  id: "finds",
63525
64013
  name: names.finds,
63526
64014
  run: ({ expect }) => {
63527
- const query = (seed) => ({ place: module.state.place, container: module.state.container, state: "normal", rng: rng2(seed), day: 0 });
64015
+ const query = (seed) => ({ place: module.state.place, container: module.state.container, state: "normal", rng: rng(seed), day: 0 });
63528
64016
  const a = JSON.stringify(provider.findsFor(query(7)));
63529
64017
  const b = JSON.stringify(provider.findsFor(query(7)));
63530
64018
  expect(a === b, "the same seed gives the same finds");