@adatechnology/game-items-three 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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,425 @@ 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 storageRuleOf = (rules, storage) => {
2520
+ const rule = rules.storage[storage];
2521
+ if (!rule) throw new Error(`game-items: unknown storage "${storage}"`);
2522
+ return rule;
2523
+ };
2524
+ var accruedDays = (storage, window, options) => {
2525
+ const { powered = true, rules = DEFAULT_RULES } = options;
2526
+ const rule = storageRuleOf(rules, storage);
2527
+ const elapsed = window.to - window.from;
2528
+ if (elapsed <= 0) return 0;
2529
+ if (rule.needsPower && !powered) return elapsed;
2530
+ if (rule.limitDays === void 0) return elapsed * rule.multiplier;
2531
+ const limitEnd = window.storedAt + rule.limitDays;
2532
+ const early = Math.max(0, Math.min(window.to, limitEnd) - Math.max(window.from, window.storedAt));
2533
+ return early * rule.multiplier + (elapsed - early) * (rule.afterLimit ?? 1);
2534
+ };
2535
+ var advanceAge = (state, now, options = {}) => {
2536
+ const { powered = true, rules = DEFAULT_RULES } = options;
2537
+ const rule = storageRuleOf(rules, state.storage);
2538
+ const thawDays = rules.aging.thawShelfDays[state.storage];
2539
+ const isThawing = rule.needsPower === true && !powered && thawDays !== void 0 && state.shelfLife === void 0;
2540
+ const base2 = isThawing ? { ...state, ageDays: 0, shelfLife: thawDays } : state;
2541
+ const ageDays = base2.ageDays + accruedDays(state.storage, { storedAt: state.storedAt, from: state.since, to: now }, options);
2542
+ return { ...base2, ageDays, since: Math.max(now, state.since) };
2543
+ };
2544
+ var shelfRatio = (item, state) => {
2545
+ const shelfLife = state.shelfLife ?? item.shelfLife;
2546
+ return shelfLife === void 0 ? 0 : state.ageDays / shelfLife;
2547
+ };
2548
+ var freshness = (item, state, now, options = {}) => {
2549
+ const { rules = DEFAULT_RULES } = options;
2550
+ const ratio = shelfRatio(item, advanceAge(state, now, options));
2551
+ if (ratio >= rules.freshness.rotten) return "rotten";
2552
+ if (ratio >= rules.freshness.spoiled) return "spoiled";
2553
+ if (ratio >= rules.freshness.stale) return "stale";
2554
+ return "fresh";
2555
+ };
2556
+ var FRESH_NUTRITION = { satietyFactor: 1, poisonChance: 0, morale: 0, isEdible: true };
2557
+ var nutritionOf = (item, context, rules) => {
2558
+ const state = context.freshness ?? "fresh";
2559
+ const effect = state === "fresh" ? FRESH_NUTRITION : rules.use.freshness[state];
2560
+ const poisonShare = context.isCooked ? rules.use.cookedPoisonFactor : 1;
2561
+ return {
2562
+ satiety: (item.nutrition?.satiety ?? 0) * effect.satietyFactor,
2563
+ hydration: item.nutrition?.hydration ?? 0,
2564
+ morale: effect.morale,
2565
+ poisonChance: effect.poisonChance * poisonShare,
2566
+ isEdible: effect.isEdible
2567
+ };
2568
+ };
2569
+ var findEffect = (item, effects) => effects.find((entry2) => entry2.items?.includes(item.id)) ?? effects.find((entry2) => entry2.category?.includes(item.category));
2570
+ var resolveUse = (item, effects, context = {}, rules = DEFAULT_RULES) => {
2571
+ const def = findEffect(item, effects);
2572
+ if (!def) return void 0;
2573
+ const base2 = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
2574
+ if (def.effect !== "consume_nutrition") return base2;
2575
+ const nutrition = nutritionOf(item, context, rules);
2576
+ const blocked = item.seal && context.seal ? sealBlock(item.seal, context.seal) : void 0;
2577
+ if (blocked) return { ...base2, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
2578
+ return { ...base2, consumes: def.consumes && nutrition.isEdible, nutrition };
2579
+ };
2580
+ var countOf = (context, id) => context.inventory.get(id) ?? 0;
2581
+ var candidatesOf = (input, context) => {
2582
+ if (input.item !== void 0) return [input.item];
2583
+ if (input.any) return [...input.any];
2584
+ if (!input.match) return [];
2585
+ const { category, cookable } = input.match;
2586
+ return context.catalog.list().filter((item) => (category === void 0 || item.category === category) && (cookable === void 0 || item.cookable === cookable)).map((item) => item.id);
2587
+ };
2588
+ var describeInput = (input) => {
2589
+ if (input.item !== void 0) return `item:${input.item}`;
2590
+ if (input.any) return `any:${input.any.join("|")}`;
2591
+ if (input.match) return `match:${input.match.category ?? "cookable"}`;
2592
+ if (input.fluid !== void 0) return `fluid:${input.fluid}`;
2593
+ return `world:${(input.world ?? []).join("|")}`;
2594
+ };
2595
+ var takeUnits = (candidates, needed, context) => {
2596
+ const taken = [];
2597
+ let remaining = needed;
2598
+ for (const id of candidates) {
2599
+ if (remaining <= 0) break;
2600
+ const count = Math.min(remaining, countOf(context, id));
2601
+ if (count > 0) taken.push({ item: id, count });
2602
+ remaining -= count;
2603
+ }
2604
+ return remaining > 0 ? void 0 : taken;
2605
+ };
2606
+ var consumptionFor = (input, context) => {
2607
+ if (input.world) return input.world.some((thing) => context.world?.has(thing)) ? [] : void 0;
2608
+ if (input.fluid !== void 0) {
2609
+ const liters = input.liters ?? 1;
2610
+ return (context.fluids?.[input.fluid] ?? 0) >= liters ? [{ fluid: input.fluid, liters }] : void 0;
2611
+ }
2612
+ const taken = takeUnits(candidatesOf(input, context), input.qty ?? 1, context);
2613
+ if (!taken || input.meters === void 0) return taken;
2614
+ return taken.map((entry2) => "item" in entry2 ? { ...entry2, meters: input.meters } : entry2);
2615
+ };
2616
+ var toolMissing = (recipe, context) => recipe.tools.flatMap((tool2) => {
2617
+ const missing = [];
2618
+ if (tool2.anyOf.length > 0 && !tool2.anyOf.some((id) => countOf(context, id) > 0)) missing.push(`tool:${tool2.anyOf.join("|")}`);
2619
+ if (tool2.world && !tool2.world.some((station) => context.world?.has(station))) missing.push(`world:${tool2.world.join("|")}`);
2620
+ return missing;
2621
+ });
2622
+ var gateMissing = (recipe, context) => {
2623
+ const missing = [];
2624
+ if (context.skills && recipe.skill && (context.skills[recipe.skill.id] ?? 0) < recipe.skill.level) missing.push(`skill:${recipe.skill.id}:${recipe.skill.level}`);
2625
+ if (context.unlocked && recipe.unlockedBy !== void 0 && !context.unlocked.has(recipe.unlockedBy)) missing.push(`unlock:${recipe.unlockedBy}`);
2626
+ return missing;
2627
+ };
2628
+ var canCraft = (recipe, context) => {
2629
+ const missing = [
2630
+ ...gateMissing(recipe, context),
2631
+ ...toolMissing(recipe, context),
2632
+ ...recipe.inputs.filter((input) => consumptionFor(input, context) === void 0).map(describeInput)
2633
+ ];
2634
+ return { isPossible: missing.length === 0, missing };
2635
+ };
2636
+ var outcomeOf = (output, random) => {
2637
+ if ("effect" in output) return { effect: output.effect, params: output.params, ...output.text === void 0 ? {} : { text: output.text } };
2638
+ const [low, high] = output.qty;
2639
+ return { item: output.item, count: low + Math.floor(random() * (high - low + 1)) };
2640
+ };
2641
+ var craft = (recipe, context, random) => {
2642
+ const check = canCraft(recipe, context);
2643
+ if (!check.isPossible) return { isCrafted: false, missing: check.missing };
2644
+ const consumed = recipe.inputs.flatMap((input) => consumptionFor(input, context) ?? []);
2645
+ return { isCrafted: true, seconds: recipe.seconds, consumed, output: outcomeOf(recipe.output, random) };
2646
+ };
2647
+ var depletionFactor = (place, day, rules) => {
2648
+ if (day <= 0) return 1;
2649
+ const rule = rules.finds.depletion.find((entry2) => entry2.places.includes(place));
2650
+ return rule ? Math.max(rule.floor, 1 - rule.perDay * day) : 1;
2651
+ };
2652
+ var scaleCount = (count, scale, rules) => {
2653
+ const region = scale.region === void 0 ? 1 : rules.finds.regionMultiplier[scale.region] ?? 1;
2654
+ return Math.round(count * depletionFactor(scale.place, scale.day, rules) * region);
2655
+ };
2656
+ var rollableItems = (catalog, category, place) => {
2657
+ const { rules } = catalog;
2658
+ const rollable = catalog.byCategory(category).filter((item) => !rules.rarity.fixedOnly.includes(item.rarity) && !rules.finds.rollExcluded.includes(item.id));
2659
+ const here = rollable.filter((item) => item.finds?.places.includes(place));
2660
+ return here.length > 0 ? here : rollable;
2661
+ };
2662
+ var rarityWeight = (catalog, item) => catalog.rules.rarity.weights[item.rarity];
2663
+ var pickCategory = (weights, random) => {
2664
+ let remaining = random();
2665
+ const categories = Object.keys(weights);
2666
+ for (const category of categories) {
2667
+ remaining -= weights[category];
2668
+ if (remaining <= 0) return category;
2669
+ }
2670
+ return categories[0];
2671
+ };
2672
+ var rollByCategory = (catalog, query) => {
2673
+ const { rules } = catalog;
2674
+ const table = catalog.containers.get(query.container) ?? catalog.containers.get(rules.finds.fallbackContainer);
2675
+ if (!table) return [];
2676
+ const [low, high] = table.count ?? [0, 0];
2677
+ const drawn = low + Math.floor(query.rng() * (high - low + 1));
2678
+ const count = scaleCount(drawn, { place: query.place, day: query.day ?? 0, ...query.region === void 0 ? {} : { region: query.region } }, rules);
2679
+ const weights = table.categories ?? table.categoriesByPlace?.[query.place] ?? table.categoriesByPlace?.["*"];
2680
+ if (!weights) return [];
2681
+ const picked = [];
2682
+ for (let stack = 0; stack < count; stack++) {
2683
+ const category = pickCategory(weights, query.rng);
2684
+ const pool = category === void 0 ? [] : rollableItems(catalog, category, query.place);
2685
+ if (pool.length === 0) continue;
2686
+ const total = pool.reduce((sum, item) => sum + rarityWeight(catalog, item), 0);
2687
+ let remaining = query.rng() * total;
2688
+ for (const item of pool) {
2689
+ remaining -= rarityWeight(catalog, item);
2690
+ if (remaining <= 0) {
2691
+ picked.push(item.id);
2692
+ break;
2693
+ }
2694
+ }
2695
+ }
2696
+ return picked;
2697
+ };
2698
+ var weightedOrder = (candidates, random) => {
2699
+ const remaining = [...candidates];
2700
+ const ordered = [];
2701
+ while (remaining.length > 0) {
2702
+ const total = remaining.reduce((sum, candidate) => sum + candidate.weight, 0);
2703
+ let x = random() * total;
2704
+ let index = 0;
2705
+ for (; index < remaining.length - 1; index++) {
2706
+ x -= remaining[index].weight;
2707
+ if (x < 0) break;
2708
+ }
2709
+ ordered.push(...remaining.splice(index, 1));
2710
+ }
2711
+ return ordered;
2712
+ };
2713
+ var countFor = (pool, state, footprint, query, rules) => {
2714
+ const settings = rules.finds.pool;
2715
+ const base2 = Math.max(settings.min, Math.min(settings.max, Math.round(settings.offset + footprint * settings.perSquareMetre + query.rng() * settings.jitter)));
2716
+ if (state === "fortified") return Math.min(pool.length, base2 + settings.fortifiedExtra);
2717
+ if (state === "abandoned") return query.rng() < settings.abandonedEmptyChance ? 0 : settings.abandonedKept;
2718
+ return base2;
2719
+ };
2720
+ var rollExplicitPool = (pool, state, query, rules) => {
2721
+ const settings = rules.finds.pool;
2722
+ const n = countFor(pool, state, query.footprint ?? settings.defaultFootprint, query, rules);
2723
+ const isFortified = state === "fortified";
2724
+ const candidates = pool.map((entry2) => ({ entry: entry2, weight: isFortified && entry2.isSupply ? entry2.weight * settings.supplyWeight : entry2.weight }));
2725
+ const picks = [];
2726
+ for (const { entry: entry2 } of weightedOrder(candidates, query.rng).slice(0, n)) {
2727
+ const [low, high] = entry2.qty;
2728
+ const bonus = isFortified && entry2.isSupply ? settings.supplyExtraQty : 0;
2729
+ picks.push({ itemId: entry2.item, count: low + Math.floor(query.rng() * (high - low + 1)) + bonus, entry: entry2 });
2730
+ }
2731
+ if (state === "abandoned") {
2732
+ if (picks.length === 0 && query.rng() < settings.junkChance) picks.push({ itemId: settings.junkItem, count: 1 });
2733
+ if (settings.coldContainers.includes(query.container) || query.key !== void 0 && settings.coldContainers.includes(query.key)) picks.push({ itemId: settings.spoiledFoodItem, count: 1 });
2734
+ }
2735
+ return picks;
2736
+ };
2737
+ var WEARING_DURABILITY = ["condition", "hits", "cuts"];
2738
+ var hasCondition = (item) => item.protection !== void 0 || item.weapon !== void 0 || WEARING_DURABILITY.includes(item.durability?.kind ?? "");
2739
+ var between = (range2, random) => range2[0] + random() * (range2[1] - range2[0]);
2740
+ var spawnAgeDays = (item, outbreakDays, random, catalog) => item.shelfLife === void 0 ? void 0 : outbreakDays + between(catalog.rules.spawn.ageShare, random) * item.shelfLife;
2741
+ var isRetailStock = (query, catalog) => {
2742
+ const { spawn } = catalog.rules;
2743
+ const isRetail = spawn.retailNew && (query.day ?? 0) <= 0 && spawn.retailPlaces.includes(query.place);
2744
+ return isRetail && (spawn.retailContainers.length === 0 || spawn.retailContainers.includes(query.container));
2745
+ };
2746
+ var spawnData = (item, query, catalog) => {
2747
+ const { spawn } = catalog.rules;
2748
+ const data = {};
2749
+ const ageDays = spawnAgeDays(item, query.day ?? 0, query.rng, catalog);
2750
+ if (ageDays !== void 0) data.ageDays = ageDays;
2751
+ if (hasCondition(item)) data.condition = isRetailStock(query, catalog) ? 100 : Math.round(between(spawn.condition[item.rarity], query.rng));
2752
+ if (item.charge) data.charge = between(spawn.charge, query.rng);
2753
+ if (spawn.fillable.includes(item.id)) data.fill = between(spawn.fill, query.rng);
2754
+ return Object.keys(data).length > 0 ? data : void 0;
2755
+ };
2756
+ function createFindsProvider(catalog, options = {}) {
2757
+ const rules = options.rules ? deepMerge(catalog.rules, options.rules) : catalog.rules;
2758
+ const scoped = rules === catalog.rules ? catalog : { ...catalog, rules };
2759
+ const usesPools = (options.pools ?? "team") === "team";
2760
+ const aliases = options.placeAliases ?? {};
2761
+ const poolPlaces = options.poolPlaces;
2762
+ const passes = options.unknownContainers === "pass";
2763
+ const choose2 = (query) => {
2764
+ const pool = usesPools && (poolPlaces === void 0 || poolPlaces.includes(query.place)) ? scoped.pools.get(query.key ?? query.container) ?? scoped.pools.get(query.container) : void 0;
2765
+ if (!pool && passes && !scoped.containers.has(query.container)) return null;
2766
+ if (!pool) return rollByCategory(scoped, query).map((itemId) => ({ itemId, count: 1 }));
2767
+ return rollExplicitPool(pool, rules.finds.states[query.state] ?? "normal", query, rules).map(({ itemId, count }) => ({ itemId, count }));
2768
+ };
2769
+ return {
2770
+ findsFor(asked) {
2771
+ const query = aliases[asked.place] === void 0 ? asked : { ...asked, place: aliases[asked.place] };
2772
+ const chosen = choose2(query);
2773
+ if (chosen === null) return null;
2774
+ return chosen.filter((stack) => scoped.has(stack.itemId)).map((stack) => {
2775
+ const data = spawnData(scoped.get(stack.itemId), query, scoped);
2776
+ return data ? { ...stack, data } : stack;
2777
+ });
2778
+ }
2779
+ };
2780
+ }
2781
+ var MM = 1e-3;
2782
+ var BOX_WALL = 6 * MM;
2783
+
2368
2784
  // src/wear.ts
2785
+ var wearOfFreshness = (state) => state === "fresh" ? 0 : state === "stale" ? 1 : 2;
2786
+ var AGED_IN = "ambient";
2787
+ function wearOfAge(item, ageDays, rules) {
2788
+ if (item.shelfLife === void 0 || ageDays <= 0) return 0;
2789
+ return wearOfFreshness(freshness(item, { ageDays, since: 0, storage: AGED_IN, storedAt: 0 }, 0, rules ? { rules } : {}));
2790
+ }
2369
2791
  var WEAR_TARGET = { food: 6122286, metal: 8011293, wood: 4141862, cloth: 4866099, plastic: 7038294, paper: 9075282, glass: 5591098, rubber: 4860452 };
2370
2792
  var WEAR_AMOUNT = [0, 0.3, 0.62];
2371
2793
  var hexToRgb = (hex3) => [(hex3 >> 16 & 255) / 255, (hex3 >> 8 & 255) / 255, (hex3 & 255) / 255];
@@ -3155,6 +3577,48 @@ var GameItemsThree = (() => {
3155
3577
  tags: [
3156
3578
  "brake_fluid"
3157
3579
  ]
3580
+ },
3581
+ {
3582
+ id: "shampoo",
3583
+ color: 6069216,
3584
+ opacity: 0.75,
3585
+ stainColor: 9418462,
3586
+ viscosity: 4e3,
3587
+ density: 1020,
3588
+ dryTime: 3600,
3589
+ gloss: 0.9,
3590
+ leavesMark: true,
3591
+ drink: {
3592
+ thirst: 0,
3593
+ effects: [
3594
+ "poison"
3595
+ ]
3596
+ },
3597
+ tags: [
3598
+ "soap",
3599
+ "sticky"
3600
+ ]
3601
+ },
3602
+ {
3603
+ id: "toothpaste",
3604
+ color: 16054008,
3605
+ opacity: 1,
3606
+ stainColor: 15133935,
3607
+ viscosity: 1e5,
3608
+ density: 1300,
3609
+ dryTime: 7200,
3610
+ gloss: 0.6,
3611
+ leavesMark: true,
3612
+ drink: {
3613
+ thirst: 0,
3614
+ effects: [
3615
+ "poison"
3616
+ ]
3617
+ },
3618
+ tags: [
3619
+ "soap",
3620
+ "paste"
3621
+ ]
3158
3622
  }
3159
3623
  ];
3160
3624
  var LIQUIDS = liquids_default;
@@ -3429,7 +3893,9 @@ var GameItemsThree = (() => {
3429
3893
  "coconut_water",
3430
3894
  "cooking_oil",
3431
3895
  "alcohol_70",
3432
- "fuel_jerrycan"
3896
+ "fuel_jerrycan",
3897
+ "shampoo",
3898
+ "toothpaste"
3433
3899
  ],
3434
3900
  rule: {
3435
3901
  hollow: true,
@@ -3564,6 +4030,14 @@ var GameItemsThree = (() => {
3564
4030
  condensed_milk: {
3565
4031
  liquid: "honey",
3566
4032
  fill: 0.9
4033
+ },
4034
+ shampoo: {
4035
+ liquid: "shampoo",
4036
+ fill: 0.9
4037
+ },
4038
+ toothpaste: {
4039
+ liquid: "toothpaste",
4040
+ fill: 0.85
3567
4041
  }
3568
4042
  },
3569
4043
  shapes: {
@@ -6286,6 +6760,46 @@ var GameItemsThree = (() => {
6286
6760
  ],
6287
6761
  scale: 0.092308
6288
6762
  },
6763
+ {
6764
+ id: "soap",
6765
+ teamId: "sabonete",
6766
+ teamBox: [
6767
+ 0.9,
6768
+ 0.3,
6769
+ 0.5
6770
+ ],
6771
+ scale: 0.1
6772
+ },
6773
+ {
6774
+ id: "shampoo",
6775
+ teamId: "shampoo",
6776
+ teamBox: [
6777
+ 0.6,
6778
+ 2,
6779
+ 0.4002
6780
+ ],
6781
+ scale: 0.1
6782
+ },
6783
+ {
6784
+ id: "toothpaste",
6785
+ teamId: "pasta_dente",
6786
+ teamBox: [
6787
+ 0.4,
6788
+ 1.8,
6789
+ 0.3
6790
+ ],
6791
+ scale: 0.1
6792
+ },
6793
+ {
6794
+ id: "toothbrush",
6795
+ teamId: "escova_dente",
6796
+ teamBox: [
6797
+ 0.2,
6798
+ 1.8,
6799
+ 0.2
6800
+ ],
6801
+ scale: 0.1
6802
+ },
6289
6803
  {
6290
6804
  id: "plunger",
6291
6805
  teamId: "desentupidor",
@@ -7476,6 +7990,61 @@ var GameItemsThree = (() => {
7476
7990
  return G(bottle2, label, stripe, cap, nozzle);
7477
7991
  };
7478
7992
 
7993
+ // src/models/shampoo.ts
7994
+ var shampoo = ({ mesh: mesh2, cyl, lathe: lathe2, G, plastic, paper: paper2 }) => {
7995
+ const oval = [1, 1, 0.667];
7996
+ 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);
7997
+ const label = mesh2(cyl(0.3, 0.3, 0.8, 16), paper2(15922680), [0, -0.35, 0], [0, 0, 0], oval);
7998
+ const cap = mesh2(cyl(0.17, 0.17, 0.28, 12), plastic(15790320), [0, 0.8, 0], [0, 0, 0], oval);
7999
+ const lid = mesh2(cyl(0.12, 0.17, 0.06, 12), plastic(14869218), [0, 0.97, 0], [0, 0, 0], oval);
8000
+ return G(body, label, cap, lid);
8001
+ };
8002
+
8003
+ // src/models/soap.ts
8004
+ var roundedRect = (width, depth, corner, steps = 4) => {
8005
+ const points = [];
8006
+ const centres = [
8007
+ [width / 2 - corner, depth / 2 - corner, 0],
8008
+ [-width / 2 + corner, depth / 2 - corner, Math.PI / 2],
8009
+ [-width / 2 + corner, -depth / 2 + corner, Math.PI],
8010
+ [width / 2 - corner, -depth / 2 + corner, 3 * Math.PI / 2]
8011
+ ];
8012
+ for (const [cx, cy, start] of centres) {
8013
+ for (let step = 0; step <= steps; step++) {
8014
+ const angle = start + step / steps * (Math.PI / 2);
8015
+ points.push([cx + Math.cos(angle) * corner, cy + Math.sin(angle) * corner]);
8016
+ }
8017
+ }
8018
+ return points;
8019
+ };
8020
+ var soap = ({ mesh: mesh2, extrude: extrude2, M, G }) => {
8021
+ const edge = 0.04;
8022
+ const bar2 = extrude2(roundedRect(0.9 - 2 * edge, 0.5 - 2 * edge, 0.14), 0.3 - 2 * edge, edge);
8023
+ bar2.center();
8024
+ return G(mesh2(bar2, M(15984338, "wax", { roughness: 0.55 }), [0, 0, 0], [Math.PI / 2, 0, 0]));
8025
+ };
8026
+
8027
+ // src/models/toothbrush.ts
8028
+ var toothbrush = ({ mesh: mesh2, bx, G, plastic, M }) => {
8029
+ const handle = mesh2(bx(0.16, 0.8, 0.1), plastic(3840720), [0, 0.75, -0.05]);
8030
+ const grip = mesh2(bx(0.2, 0.35, 0.12), plastic(2912160), [0, 0.175, -0.05]);
8031
+ const neck = mesh2(bx(0.08, 0.3, 0.08), plastic(3840720), [0, 1.3, -0.05]);
8032
+ const head = mesh2(bx(0.14, 0.35, 0.06), plastic(3840720), [0, 1.625, -0.06]);
8033
+ const bristles = mesh2(bx(0.12, 0.32, 0.12), M(16054008, "plastic", { roughness: 0.9 }), [0, 1.62, 0.03]);
8034
+ return G(handle, grip, neck, head, bristles);
8035
+ };
8036
+
8037
+ // src/models/toothpaste.ts
8038
+ var toothpaste = ({ mesh: mesh2, cyl, bx, G, plastic }) => {
8039
+ const flat = [1, 1, 0.75];
8040
+ const cap = mesh2(cyl(0.11, 0.12, 0.22, 12), plastic(2056104), [0, 0.11, 0]);
8041
+ const shoulder = mesh2(cyl(0.2, 0.11, 0.08, 14), plastic(16053494), [0, 0.26, 0], [0, 0, 0], flat);
8042
+ const body = mesh2(cyl(0.2, 0.2, 0.9, 14), plastic(16053494), [0, 0.75, 0], [0, 0, 0], flat);
8043
+ const taper = mesh2(cyl(0.2, 0.2, 0.44, 14), plastic(16053494), [0, 1.41, 0], [0, 0, 0], [1, 1, 0.42]);
8044
+ const crimp = mesh2(bx(0.4, 0.17, 0.04), plastic(15132394), [0, 1.715, 0]);
8045
+ return G(cap, shoulder, body, taper, crimp);
8046
+ };
8047
+
7479
8048
  // src/models/plunger.ts
7480
8049
  var plunger = ({ mesh: mesh2, cyl, G, M, wood }) => {
7481
8050
  const rubber = M(11545120, "rubber", { roughness: 0.75 });
@@ -10163,6 +10732,10 @@ var GameItemsThree = (() => {
10163
10732
  watering_can: wateringCan,
10164
10733
  wheelbarrow,
10165
10734
  windup_alarm_clock: windupAlarmClock,
10735
+ soap,
10736
+ shampoo,
10737
+ toothpaste,
10738
+ toothbrush,
10166
10739
  plunger
10167
10740
  };
10168
10741
  var SHIPPED_MODELS = models_default.map((entry2) => {
@@ -10382,12 +10955,16 @@ var GameItemsThree = (() => {
10382
10955
 
10383
10956
  // src/contained.ts
10384
10957
  function createContainedItemModel(items, options = {}) {
10958
+ const { rules, ...build } = options;
10385
10959
  const byId = /* @__PURE__ */ new Map();
10386
10960
  for (const item of items) byId.set(item.id, item);
10387
10961
  return (stack, T2) => {
10388
10962
  const item = byId.get(stack.type);
10389
10963
  if (!item) return null;
10390
- const model = buildItem(T2, item, options);
10964
+ const ageDays = stack.data?.["ageDays"];
10965
+ const aged = typeof ageDays === "number" ? wearOfAge(item, ageDays, rules) : 0;
10966
+ const wear = Math.max(build.wear ?? 0, aged);
10967
+ const model = buildItem(T2, item, wear > 0 ? { ...build, wear } : build);
10391
10968
  model.root.userData.item = { id: item.id, kind: model.kind };
10392
10969
  const dirt = stack.data?.["dirt"];
10393
10970
  if (typeof dirt === "number" && dirt > 0) setItemDirt(T2, model.root, dirt);
@@ -10924,11 +11501,11 @@ var GameItemsThree = (() => {
10924
11501
  mergeByMaterial: () => mergeByMaterial,
10925
11502
  mix: () => mix,
10926
11503
  resolveStrings: () => resolveStrings,
10927
- rng: () => rng,
11504
+ rng: () => rng2,
10928
11505
  seedOf: () => seedOf,
10929
11506
  shade: () => shade2
10930
11507
  });
10931
- function rng(seed) {
11508
+ function rng2(seed) {
10932
11509
  let s = seed >>> 0;
10933
11510
  return () => {
10934
11511
  s = s + 1831565813 >>> 0;
@@ -10993,7 +11570,7 @@ var GameItemsThree = (() => {
10993
11570
  function floorAtlas(doc) {
10994
11571
  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
11572
  const cell = (c, seed, f) => {
10996
- const [x0, y0] = P(c), r = rng(seed);
11573
+ const [x0, y0] = P(c), r = rng2(seed);
10997
11574
  f(g, x0, y0, r);
10998
11575
  };
10999
11576
  for (const [c, seed] of [[0, 11], [1, 12]]) cell(c, seed, (g2, x0, y0, r) => {
@@ -11154,7 +11731,7 @@ var GameItemsThree = (() => {
11154
11731
  function pictureAtlas(doc, names) {
11155
11732
  const N = 256, cv = makeCanvas(doc, N * 4, N * 2), g = cv.getContext("2d");
11156
11733
  const cell = (c, seed, f) => {
11157
- const x0 = c % 4 * N, y0 = Math.floor(c / 4) * N, r = rng(seed);
11734
+ const x0 = c % 4 * N, y0 = Math.floor(c / 4) * N, r = rng2(seed);
11158
11735
  g.save();
11159
11736
  g.beginPath();
11160
11737
  g.rect(x0, y0, N, N);
@@ -11333,7 +11910,7 @@ var GameItemsThree = (() => {
11333
11910
  return { canvas: cv, n: PICTURE_CELLS - 1, uv: (c) => uvc(c), mirror: () => uvc(7), names };
11334
11911
  }
11335
11912
  function waterAtlas(doc) {
11336
- const N = 128, cv = makeCanvas(doc, N, N), g = cv.getContext("2d"), r = rng(901);
11913
+ const N = 128, cv = makeCanvas(doc, N, N), g = cv.getContext("2d"), r = rng2(901);
11337
11914
  g.fillStyle = "#e6f2f8";
11338
11915
  g.fillRect(0, 0, N, N);
11339
11916
  seamless(g, 0, 0, N, () => {
@@ -12246,7 +12823,7 @@ var GameItemsThree = (() => {
12246
12823
  const color2 = o.color != null ? hex2(o.color) : 16777215;
12247
12824
  const poly = o.poly || M.poly;
12248
12825
  const sd = seedOf(M);
12249
- const rnd = rng(sd);
12826
+ const rnd = rng2(sd);
12250
12827
  const tint = () => {
12251
12828
  const v = 0.93 + rnd() * 0.07;
12252
12829
  return mix(0, color2, v);
@@ -12298,7 +12875,7 @@ var GameItemsThree = (() => {
12298
12875
  const K = {
12299
12876
  M,
12300
12877
  api,
12301
- rnd: rng(seedOf(M)),
12878
+ rnd: rng2(seedOf(M)),
12302
12879
  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
12880
  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
12881
  leaf: (x, y, z, w, h, color2, ry, rx) => api.leaf(M, x, y, z, w, h, hex2(color2), ry || 0, rx || 0),
@@ -26246,418 +26823,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
26246
26823
  return [[mast.u, mast.v, mast.y0], [mast.u, mast.v, mast.y1], ...arc];
26247
26824
  }
26248
26825
 
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
26826
  // ../game-items-goods/dist/index.js
26662
26827
  var FLOORPLAN_POOL_KEYS = {
26663
26828
  fridge: "geladeira",
@@ -37594,6 +37759,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37594
37759
  shape: "box",
37595
37760
  color: 15790304,
37596
37761
  rarity: "common",
37762
+ model: "soap",
37597
37763
  parts: [
37598
37764
  {
37599
37765
  id: "body",
@@ -37629,6 +37795,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37629
37795
  shape: "bottle",
37630
37796
  color: 4885200,
37631
37797
  rarity: "common",
37798
+ model: "shampoo",
37632
37799
  consumable: {
37633
37800
  form: "liquid",
37634
37801
  unit: "ml",
@@ -37636,7 +37803,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37636
37803
  dose: 8,
37637
37804
  emptyKg: 0.044,
37638
37805
  density: 1.02
37639
- }
37806
+ },
37807
+ parts: [
37808
+ {
37809
+ id: "body",
37810
+ material: "plastic",
37811
+ thickness: 8e-4
37812
+ }
37813
+ ],
37814
+ estimated: [
37815
+ "parts"
37816
+ ]
37640
37817
  },
37641
37818
  {
37642
37819
  id: "toothpaste",
@@ -37655,13 +37832,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37655
37832
  shape: "tube",
37656
37833
  color: 15790320,
37657
37834
  rarity: "common",
37835
+ model: "toothpaste",
37658
37836
  consumable: {
37659
37837
  form: "paste",
37660
37838
  unit: "g",
37661
37839
  amount: 90,
37662
37840
  dose: 1,
37663
37841
  emptyKg: 0.01
37664
- }
37842
+ },
37843
+ parts: [
37844
+ {
37845
+ id: "body",
37846
+ material: "plastic",
37847
+ thickness: 8e-4
37848
+ }
37849
+ ],
37850
+ estimated: [
37851
+ "parts"
37852
+ ]
37665
37853
  },
37666
37854
  {
37667
37855
  id: "toothbrush",
@@ -37679,7 +37867,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37679
37867
  stack: 3,
37680
37868
  shape: "tool",
37681
37869
  color: 3840720,
37682
- rarity: "common"
37870
+ rarity: "common",
37871
+ model: "toothbrush",
37872
+ parts: [
37873
+ {
37874
+ id: "body",
37875
+ material: "plastic",
37876
+ thickness: 5e-3
37877
+ }
37878
+ ],
37879
+ estimated: [
37880
+ "parts"
37881
+ ]
37683
37882
  },
37684
37883
  {
37685
37884
  id: "deodorant",
@@ -49272,7 +49471,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49272
49471
  }
49273
49472
  var residentialTower = residentialTowerTemplate();
49274
49473
 
49275
- // ../game-floorplan-three/dist/chunk-KOJFBQRC.js
49474
+ // ../game-floorplan-three/dist/chunk-BTAHA26H.js
49276
49475
  var __defProp3 = Object.defineProperty;
49277
49476
  var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
49278
49477
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -50548,7 +50747,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50548
50747
  if (!shared2.ctx.visorScene) shared2.ctx.occupied.push(b2);
50549
50748
  };
50550
50749
  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 });
50750
+ 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
50751
  fb(a - jin, jy, a + jw, visH);
50553
50752
  fb(b - jw, jy, b + jin, visH);
50554
50753
  if (!cut) fb(a, dH - jw, b, dH);
@@ -56889,6 +57088,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56889
57088
  return;
56890
57089
  }
56891
57090
  n.updateMatrix();
57091
+ shared2.ctx.posePiece?.(p.name);
56892
57092
  }
56893
57093
  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
57094
  function animateInteractive(dt) {
@@ -57452,6 +57652,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57452
57652
  else g.rotation.y = fo.t * fo.rot;
57453
57653
  g.updateMatrix();
57454
57654
  }
57655
+ shared2.ctx.posePiece?.("door:" + fo.id);
57455
57656
  }
57456
57657
  const defined = { linkDoorLeaves, handleApply, toggleDoor, animateDoors, wallBlocks, doorText, applyLeaf };
57457
57658
  Object.assign(K, defined);
@@ -58703,6 +58904,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58703
58904
  K.applyPiece(def);
58704
58905
  }
58705
58906
  root.updateMatrixWorld(true);
58907
+ const rest2 = /* @__PURE__ */ new Map(), restOf = (id, node) => {
58908
+ if (node && shared2.ctx.pieceObjects.has(id)) rest2.set(id, { node, rest: shared2.ctx.unitInverse.clone().multiply(node.matrixWorld) });
58909
+ };
58910
+ for (const fo of shared2.ctx.leaves) restOf("door:" + fo.id, fo.gs[0]);
58911
+ for (const def of shared2.inter.defs.values()) if (def.outer && def.inner) restOf(def.name, def.inner);
58912
+ shared2.ctx.pieceRest = rest2;
58706
58913
  root.traverse((o0) => {
58707
58914
  const o = o0;
58708
58915
  if (o.isMesh && o.userData.ranges) {
@@ -58921,7 +59128,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58921
59128
  }
58922
59129
  });
58923
59130
  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 ?? []);
59131
+ return withWindowApertures({ ...spec, parts: spec.parts.map((sp) => walls.has(sp.id) && sp.apertures ? (({ apertures: _gone, ...rest22 }) => rest22)(sp) : sp) }, E0.openings ?? []);
58925
59132
  }
58926
59133
  };
58927
59134
  return structure;
@@ -60119,6 +60326,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60119
60326
  Object.assign(K, { createBreachView, breachPaintQueue: paintQueue, breachCutQueue: cutQueue });
60120
60327
  }
60121
60328
  var FOLLOW_FLUSH_FALLBACK_MS = 100;
60329
+ var POSE_IDENTITY = [1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1];
60122
60330
  function installDestructionWorld(K, shared2) {
60123
60331
  const { THREE, cfg, invalidateShadow, invalidate, rngString, FRAGMENT_GEO, fragmentMaterial, createBreachView } = K;
60124
60332
  function createHouseDestruction(root, house, structure, parts2, colliders, water) {
@@ -60379,8 +60587,31 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60379
60587
  if (R) R.bind(D.id, house, { parts: rangesOf(), marksOn: marksOn(), onFrame: () => breach.flush() });
60380
60588
  off = D.world.on("*", handleEvent);
60381
60589
  D.active = true;
60590
+ for (const id of shared2.ctx.pieceRest?.keys() ?? []) D.pose(id);
60382
60591
  return D;
60383
60592
  };
60593
+ 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();
60594
+ D.pose = (id) => {
60595
+ if (!D.active || !D.spec) return;
60596
+ const moving = shared2.ctx.pieceRest?.get(id), part = D.spec.parts.find((p) => p.id === id);
60597
+ if (!moving || !part) return;
60598
+ const node = moving.node;
60599
+ node.updateMatrix();
60600
+ house.updateMatrixWorld();
60601
+ poseHouse.copy(house.matrixWorld).invert();
60602
+ poseNow.copy(node.parent ? node.parent.matrixWorld : poseHouse.identity()).multiply(node.matrix);
60603
+ if (node.parent) poseNow.premultiply(poseHouse);
60604
+ poseRest.copy(moving.rest).invert();
60605
+ poseNow.multiply(poseRest);
60606
+ const still = poseNow.elements.every((v, i) => Math.abs(v - POSE_IDENTITY[i]) < 1e-9);
60607
+ if (still && !posed.has(id)) return;
60608
+ if (still) posed.delete(id);
60609
+ else posed.add(id);
60610
+ const r = part.rotation ?? [0, 0, 0];
60611
+ 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);
60612
+ poseE.setFromQuaternion(poseQ);
60613
+ D.world.setPartPose(D.id, id, [poseP.x, poseP.y, poseP.z], [poseE.x, poseE.y, poseE.z]);
60614
+ };
60384
60615
  D.deactivate = () => {
60385
60616
  if (off) off();
60386
60617
  off = null;
@@ -61667,6 +61898,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61667
61898
  markGroups(r, root, parts2);
61668
61899
  const structure = assembleStructure(r0, root), destruction = createHouseDestruction(root, house, structure, parts2, colliders, water);
61669
61900
  h.destruction = destruction;
61901
+ shared2.ctx.posePiece = (id) => destruction.pose(id);
61670
61902
  destruction.breach.setLod(h.lodCurrent);
61671
61903
  if (cs) {
61672
61904
  currentConstructionLevel = applyConstructionLevel(house, opts.constructionLevel ?? CONSTRUCTION_LEVEL_MAX);
@@ -62940,8 +63172,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62940
63172
  var stageOf = (catalog, item, base2, ageDays, storage, powered) => {
62941
63173
  if (item.shelfLife === void 0 || ageDays <= 0) return base2;
62942
63174
  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);
63175
+ return Math.max(base2, wearOfFreshness(state));
62945
63176
  };
62946
63177
  var sizeOfModel = (modelSet, id) => {
62947
63178
  const entry2 = modelSet.entry(id);
@@ -63253,7 +63484,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63253
63484
  });
63254
63485
  };
63255
63486
  const rollFinds = () => {
63256
- const query = { place: state.place, container: state.container, state: state.state, rng: rng2(state.seed), day: state.day };
63487
+ const query = { place: state.place, container: state.container, state: state.state, rng: rng(state.seed), day: state.day };
63257
63488
  stack = [...provider.findsFor(query) ?? []];
63258
63489
  showFinds();
63259
63490
  const container = label(`container.${state.container}`, humanize(state.container));
@@ -63293,7 +63524,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63293
63524
  host?.log(fill(text.craftMissing, { recipe: name, missing: check.missing.join(", ") }), { recipe: recipe.id });
63294
63525
  return { ok: false, missing: check.missing };
63295
63526
  }
63296
- const result = craft(recipe, context, rng2(state.seed));
63527
+ const result = craft(recipe, context, rng(state.seed));
63297
63528
  if (!result.isCrafted) return { ok: false, missing: result.missing };
63298
63529
  if ("item" in result.output) {
63299
63530
  stack = [{ itemId: result.output.item, count: result.output.count }];
@@ -63524,7 +63755,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63524
63755
  id: "finds",
63525
63756
  name: names.finds,
63526
63757
  run: ({ expect }) => {
63527
- const query = (seed) => ({ place: module.state.place, container: module.state.container, state: "normal", rng: rng2(seed), day: 0 });
63758
+ const query = (seed) => ({ place: module.state.place, container: module.state.container, state: "normal", rng: rng(seed), day: 0 });
63528
63759
  const a = JSON.stringify(provider.findsFor(query(7)));
63529
63760
  const b = JSON.stringify(provider.findsFor(query(7)));
63530
63761
  expect(a === b, "the same seed gives the same finds");