@adatechnology/game-items-three 0.12.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.
@@ -21,6 +21,7 @@ var GameItemsThree = (() => {
21
21
  // src/index.ts
22
22
  var index_exports = {};
23
23
  __export(index_exports, {
24
+ CUP_FLOOR_SHARE: () => CUP_FLOOR_SHARE,
24
25
  DESTRUCTION_MATERIAL_BY_TAG: () => DESTRUCTION_MATERIAL_BY_TAG,
25
26
  FINDS_TABLE_ID: () => FINDS_TABLE_ID,
26
27
  HUMAN_HEIGHT: () => HUMAN_HEIGHT,
@@ -40,6 +41,7 @@ var GameItemsThree = (() => {
40
41
  SHIPPED_MODELS: () => SHIPPED_MODELS,
41
42
  SHOWCASE_PREFIX: () => SHOWCASE_PREFIX,
42
43
  SHOWCASE_STAND_ID: () => SHOWCASE_STAND_ID,
44
+ WASH_NAME: () => WASH_NAME,
43
45
  WEAR_AMOUNT: () => WEAR_AMOUNT,
44
46
  WEAR_TAGS: () => WEAR_TAGS,
45
47
  WEAR_TARGET: () => WEAR_TARGET,
@@ -70,12 +72,15 @@ var GameItemsThree = (() => {
70
72
  itemOpening: () => itemOpening,
71
73
  itemThumbnail: () => itemThumbnail,
72
74
  itemThumbnailSvg: () => itemThumbnailSvg,
75
+ itemVessel: () => itemVessel,
73
76
  listItemModels: () => listItemModels,
74
77
  makeupSpec: () => makeupSpec,
75
78
  mergeItem: () => mergeItem,
76
79
  openItem: () => openItem,
77
80
  registerItemModel: () => registerItemModel,
78
81
  renderItemThumbnail: () => renderItemThumbnail,
82
+ setItemDirt: () => setItemDirt,
83
+ setItemFoam: () => setItemFoam,
79
84
  setOpeningContents: () => setOpeningContents,
80
85
  setWear: () => setWear,
81
86
  shade: () => shade,
@@ -90,6 +95,8 @@ var GameItemsThree = (() => {
90
95
  triangleBudgetOf: () => triangleBudgetOf,
91
96
  turnItem: () => turnItem,
92
97
  unregisterItemModel: () => unregisterItemModel,
98
+ wearOfAge: () => wearOfAge,
99
+ wearOfFreshness: () => wearOfFreshness,
93
100
  wearableMaterials: () => wearableMaterials
94
101
  });
95
102
 
@@ -367,6 +374,8 @@ var GameItemsThree = (() => {
367
374
  function drainDetached(queue, budgetMs, clock = () => performance.now()) {
368
375
  return queue.run(clock() + budgetMs, clock);
369
376
  }
377
+ var BODY_FOAM_SURFACES = ["hands", "arms", "torso", "hair", "mouth"];
378
+ var WASH_SURFACES = [...BODY_FOAM_SURFACES, "brush"];
370
379
  var WARNED_KEY = /* @__PURE__ */ Symbol.for("@adatechnology/game-contracts.warned");
371
380
  var warnedKeys = () => {
372
381
  const holder = globalThis;
@@ -2201,13 +2210,16 @@ var GameItemsThree = (() => {
2201
2210
  for (const u of Object.values(uniforms)) if (isTexture(u?.value)) out.add(u.value);
2202
2211
  }
2203
2212
  }
2213
+ var isInstanced = (o) => o.isInstancedMesh === true;
2204
2214
  function collect(roots) {
2205
2215
  const geometries = /* @__PURE__ */ new Set();
2206
2216
  const materials = /* @__PURE__ */ new Set();
2207
2217
  const textures = /* @__PURE__ */ new Set();
2208
2218
  const skeletons = /* @__PURE__ */ new Set();
2219
+ const instanced = /* @__PURE__ */ new Set();
2209
2220
  for (const root of roots) {
2210
2221
  root.traverse((object2) => {
2222
+ if (isInstanced(object2)) instanced.add(object2);
2211
2223
  const o = object2;
2212
2224
  if (o.geometry && typeof o.geometry.dispose === "function") geometries.add(o.geometry);
2213
2225
  if (o.skeleton && typeof o.skeleton.dispose === "function") skeletons.add(o.skeleton);
@@ -2219,7 +2231,7 @@ var GameItemsThree = (() => {
2219
2231
  }
2220
2232
  });
2221
2233
  }
2222
- return { geometries, materials, textures, skeletons };
2234
+ return { geometries, materials, textures, skeletons, instanced };
2223
2235
  }
2224
2236
  var marked = /* @__PURE__ */ new WeakSet();
2225
2237
  function markShared(...resources) {
@@ -2268,6 +2280,7 @@ var GameItemsThree = (() => {
2268
2280
  report.textures++;
2269
2281
  }
2270
2282
  for (const s of found.skeletons) s.dispose();
2283
+ for (const mesh2 of found.instanced) mesh2.dispose();
2271
2284
  return report;
2272
2285
  }
2273
2286
  function discardObject3D(objects, options = {}) {
@@ -2356,8 +2369,426 @@ var GameItemsThree = (() => {
2356
2369
  };
2357
2370
  }
2358
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
+
2359
2784
  // src/wear.ts
2360
- var WEAR_TARGET = { food: 6122286, metal: 8011293, wood: 4141862, cloth: 4866099, plastic: 7038294, paper: 9075282, glass: 5591098 };
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
+ }
2791
+ var WEAR_TARGET = { food: 6122286, metal: 8011293, wood: 4141862, cloth: 4866099, plastic: 7038294, paper: 9075282, glass: 5591098, rubber: 4860452 };
2361
2792
  var WEAR_AMOUNT = [0, 0.3, 0.62];
2362
2793
  var hexToRgb = (hex3) => [(hex3 >> 16 & 255) / 255, (hex3 >> 8 & 255) / 255, (hex3 & 255) / 255];
2363
2794
  var dataOf = (material) => {
@@ -2490,9 +2921,11 @@ var GameItemsThree = (() => {
2490
2921
  const { k, w, h, d } = c;
2491
2922
  return k.G(k.mesh(k.cyl(0.5, 0.35, h, seg(c, 16)), k.plastic(c.color), [0, 0, 0], [0, 0, 0], [w, 1, d]));
2492
2923
  };
2924
+ var CUP_FLOOR_SHARE = 0.06;
2493
2925
  var cup = (c) => {
2494
2926
  const { k, w, h, d } = c;
2495
- const profile = [[0, -h / 2], [0.38, -h / 2], [0.5, h / 2], [0.44, h / 2], [0.33, -h / 2 + h * 0.06], [0, -h / 2 + h * 0.06]];
2927
+ const floor = -h / 2 + h * CUP_FLOOR_SHARE;
2928
+ const profile = [[0, -h / 2], [0.38, -h / 2], [0.5, h / 2], [0.44, h / 2], [0.33, floor], [0, floor]];
2496
2929
  return k.G(k.mesh(k.lathe(profile, seg(c, 14)), k.plastic(c.color), [0, 0, 0], [0, 0, 0], [w, 1, d]));
2497
2930
  };
2498
2931
  var tube = (c) => {
@@ -3144,6 +3577,48 @@ var GameItemsThree = (() => {
3144
3577
  tags: [
3145
3578
  "brake_fluid"
3146
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
+ ]
3147
3622
  }
3148
3623
  ];
3149
3624
  var LIQUIDS = liquids_default;
@@ -3418,7 +3893,9 @@ var GameItemsThree = (() => {
3418
3893
  "coconut_water",
3419
3894
  "cooking_oil",
3420
3895
  "alcohol_70",
3421
- "fuel_jerrycan"
3896
+ "fuel_jerrycan",
3897
+ "shampoo",
3898
+ "toothpaste"
3422
3899
  ],
3423
3900
  rule: {
3424
3901
  hollow: true,
@@ -3553,6 +4030,14 @@ var GameItemsThree = (() => {
3553
4030
  condensed_milk: {
3554
4031
  liquid: "honey",
3555
4032
  fill: 0.9
4033
+ },
4034
+ shampoo: {
4035
+ liquid: "shampoo",
4036
+ fill: 0.9
4037
+ },
4038
+ toothpaste: {
4039
+ liquid: "toothpaste",
4040
+ fill: 0.85
3556
4041
  }
3557
4042
  },
3558
4043
  shapes: {
@@ -3612,6 +4097,7 @@ var GameItemsThree = (() => {
3612
4097
  paper: "paper",
3613
4098
  plastic: "plastic",
3614
4099
  cloth: "fabric",
4100
+ rubber: "rubber",
3615
4101
  food: "flesh_fruit"
3616
4102
  };
3617
4103
  var FAMILIES = destruction_default.families;
@@ -3647,6 +4133,16 @@ var GameItemsThree = (() => {
3647
4133
  };
3648
4134
  return { container, liquid: contents.liquid, liters };
3649
4135
  }
4136
+ var VESSEL_FLOORS = { cup: CUP_FLOOR_SHARE };
4137
+ function itemVessel(subject) {
4138
+ const capacity = subject.capacityLiters;
4139
+ const floor = subject.shape === void 0 ? void 0 : VESSEL_FLOORS[subject.shape];
4140
+ if (capacity === void 0 || !(capacity > 0) || floor === void 0) return void 0;
4141
+ const [width, height, depth] = subject.size;
4142
+ const radius = Math.min(width, depth) / 2 * WALL_SHARE;
4143
+ const container = { capacity, liters: 0, shape: { kind: "cylinder", radius, height: height * WALL_SHARE }, opening: radius, closed: false };
4144
+ return { container, offset: [0, height * floor, 0] };
4145
+ }
3650
4146
  function tagOf(mesh2) {
3651
4147
  const material = Array.isArray(mesh2.material) ? mesh2.material[0] : mesh2.material;
3652
4148
  const tag = material?.userData?.tag;
@@ -6263,6 +6759,56 @@ var GameItemsThree = (() => {
6263
6759
  0.553
6264
6760
  ],
6265
6761
  scale: 0.092308
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
+ },
6803
+ {
6804
+ id: "plunger",
6805
+ teamId: "desentupidor",
6806
+ teamBox: [
6807
+ 1.4,
6808
+ 5.5,
6809
+ 1.4
6810
+ ],
6811
+ scale: 0.1
6266
6812
  }
6267
6813
  ];
6268
6814
 
@@ -7444,6 +7990,71 @@ var GameItemsThree = (() => {
7444
7990
  return G(bottle2, label, stripe, cap, nozzle);
7445
7991
  };
7446
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
+
8048
+ // src/models/plunger.ts
8049
+ var plunger = ({ mesh: mesh2, cyl, G, M, wood }) => {
8050
+ const rubber = M(11545120, "rubber", { roughness: 0.75 });
8051
+ const cup2 = mesh2(cyl(0.3, 0.7, 0.75, 16), rubber, [0, 0.455, 0]);
8052
+ const lip = mesh2(cyl(0.7, 0.7, 0.08, 16), M(9314841, "rubber", { roughness: 0.8 }), [0, 0.04, 0]);
8053
+ const neck = mesh2(cyl(0.2, 0.3, 0.3, 12), rubber, [0, 0.98, 0]);
8054
+ const handle = mesh2(cyl(0.15, 0.15, 4.4, 10), wood(10122312), [0, 3.3, 0]);
8055
+ return G(cup2, lip, neck, handle);
8056
+ };
8057
+
7447
8058
  // src/models/can-opener.ts
7448
8059
  var canOpener = ({ mesh: mesh2, bx, cyl, G, metal, plastic }) => {
7449
8060
  const steel = metal(11120050);
@@ -10120,7 +10731,12 @@ var GameItemsThree = (() => {
10120
10731
  tshirt,
10121
10732
  watering_can: wateringCan,
10122
10733
  wheelbarrow,
10123
- windup_alarm_clock: windupAlarmClock
10734
+ windup_alarm_clock: windupAlarmClock,
10735
+ soap,
10736
+ shampoo,
10737
+ toothpaste,
10738
+ toothbrush,
10739
+ plunger
10124
10740
  };
10125
10741
  var SHIPPED_MODELS = models_default.map((entry2) => {
10126
10742
  const builder = BUILDERS[entry2.id];
@@ -10190,15 +10806,168 @@ var GameItemsThree = (() => {
10190
10806
  return { root, kind, ...shape ? { shape } : {}, size: item.size, materials };
10191
10807
  }
10192
10808
 
10809
+ // src/wash.ts
10810
+ var WASH_NAME = "item_wash";
10811
+ var STAIN_LIFT = 15e-4;
10812
+ var SPOTS = [
10813
+ [0, 0],
10814
+ [0.5, 0],
10815
+ [0.155, 0.476],
10816
+ [-0.405, 0.294],
10817
+ [-0.405, -0.294],
10818
+ [0.155, -0.476]
10819
+ ];
10820
+ var STAIN_RADIUS = 0.12;
10821
+ var BUBBLE_RADIUS = 0.1;
10822
+ var BUBBLE_CLUSTER = [
10823
+ [0, 0, 1],
10824
+ [1.1, 0.3, 0.7],
10825
+ [-0.6, 0.9, 0.6]
10826
+ ];
10827
+ var STAIN_COLORS = [8014370, 10903070, 6175260, 12088362, 9067050, 10243866];
10828
+ var FOAM_COLOR = 16054008;
10829
+ var overlays = /* @__PURE__ */ new WeakMap();
10830
+ var isOwnMesh = (mesh2) => !mesh2.userData.destructionDebris && mesh2.parent?.name !== WASH_NAME;
10831
+ function localBox2(T2, root) {
10832
+ root.updateMatrixWorld(true);
10833
+ const toRoot = new T2.Matrix4().copy(root.matrixWorld).invert();
10834
+ const box4 = new T2.Box3();
10835
+ const part = new T2.Box3();
10836
+ const m = new T2.Matrix4();
10837
+ root.traverse((o) => {
10838
+ const mesh2 = o;
10839
+ if (!mesh2.isMesh || !isOwnMesh(mesh2)) return;
10840
+ if (!mesh2.geometry.boundingBox) mesh2.geometry.computeBoundingBox();
10841
+ const bounds = mesh2.geometry.boundingBox;
10842
+ if (!bounds) return;
10843
+ part.copy(bounds).applyMatrix4(m.multiplyMatrices(toRoot, mesh2.matrixWorld));
10844
+ box4.union(part);
10845
+ });
10846
+ return box4;
10847
+ }
10848
+ function spotsOn(T2, root, box4) {
10849
+ const meshes = [];
10850
+ root.traverse((o) => {
10851
+ const mesh2 = o;
10852
+ if (mesh2.isMesh && isOwnMesh(mesh2)) meshes.push(mesh2);
10853
+ });
10854
+ const toRoot = new T2.Matrix4().copy(root.matrixWorld).invert();
10855
+ const down2 = new T2.Vector3(0, -1, 0).transformDirection(root.matrixWorld);
10856
+ const ray = new T2.Raycaster();
10857
+ const centre = box4.getCenter(new T2.Vector3());
10858
+ const half = box4.getSize(new T2.Vector3()).multiplyScalar(0.5);
10859
+ const above = box4.max.y + half.y + 0.01;
10860
+ const spots = [];
10861
+ for (const [x, z] of SPOTS) {
10862
+ const origin = new T2.Vector3(centre.x + x * half.x, above, centre.z + z * half.z).applyMatrix4(root.matrixWorld);
10863
+ ray.set(origin, down2);
10864
+ const hit = ray.intersectObjects(meshes, false)[0];
10865
+ if (!hit?.face) continue;
10866
+ const normal = hit.face.normal.clone().transformDirection(hit.object.matrixWorld);
10867
+ if (normal.dot(down2) > 0) normal.negate();
10868
+ const point = hit.point.clone().addScaledVector(normal, STAIN_LIFT).applyMatrix4(toRoot);
10869
+ spots.push({ point, normal: normal.transformDirection(toRoot) });
10870
+ }
10871
+ return spots;
10872
+ }
10873
+ function layerOf(T2, geometry, material, bases, name) {
10874
+ const mesh2 = new T2.InstancedMesh(geometry, material, bases.length);
10875
+ mesh2.name = name;
10876
+ bases.forEach((base2, i) => mesh2.setMatrixAt(i, base2));
10877
+ mesh2.computeBoundingSphere();
10878
+ mesh2.visible = false;
10879
+ mesh2.userData.destructionDebris = true;
10880
+ mesh2.raycast = () => {
10881
+ };
10882
+ return { mesh: mesh2, bases, value: 0 };
10883
+ }
10884
+ function blotGeometry(T2) {
10885
+ const geometry = new T2.CircleGeometry(1, 9);
10886
+ const position = geometry.getAttribute("position");
10887
+ for (let i = 1; i < position.count; i++) {
10888
+ const wobble = 0.75 + 0.25 * Math.abs(Math.sin(i * 2.3));
10889
+ position.setXY(i, position.getX(i) * wobble, position.getY(i) * wobble);
10890
+ }
10891
+ return geometry.rotateX(-Math.PI / 2);
10892
+ }
10893
+ function createOverlay(T2, root) {
10894
+ const scratch = { matrix: new T2.Matrix4(), scale: new T2.Matrix4() };
10895
+ const box4 = localBox2(T2, root);
10896
+ const spots = box4.isEmpty() ? [] : spotsOn(T2, root, box4);
10897
+ if (spots.length === 0) return { dirt: void 0, foam: void 0, scratch };
10898
+ const size = box4.getSize(new T2.Vector3());
10899
+ const small = Math.min(size.x, size.z) / 2;
10900
+ const up = new T2.Vector3(0, 1, 0);
10901
+ const turn = (normal, spin) => new T2.Quaternion().setFromUnitVectors(up, normal).multiply(new T2.Quaternion().setFromAxisAngle(up, spin));
10902
+ const stains = spots.map((spot, i) => {
10903
+ const r = small * STAIN_RADIUS;
10904
+ return new T2.Matrix4().compose(spot.point, turn(spot.normal, i * 1.7), new T2.Vector3(r, 1, r * (0.65 + 0.35 * (i * 0.37 % 1))));
10905
+ });
10906
+ const bubbleRadius = small * BUBBLE_RADIUS;
10907
+ const bubbles = spots.flatMap((spot, i) => {
10908
+ const q = turn(spot.normal, i * 1.1);
10909
+ return BUBBLE_CLUSTER.map(([along2, across2, share]) => {
10910
+ const r = bubbleRadius * share;
10911
+ const at2 = new T2.Vector3(along2 * bubbleRadius, r * 0.4 - STAIN_LIFT, across2 * bubbleRadius).applyQuaternion(q).add(spot.point);
10912
+ return new T2.Matrix4().compose(at2, q, new T2.Vector3(r, r, r));
10913
+ });
10914
+ });
10915
+ const group = new T2.Group();
10916
+ group.name = WASH_NAME;
10917
+ group.userData.destructionIgnore = true;
10918
+ const dirt = layerOf(T2, blotGeometry(T2), new T2.MeshStandardMaterial({ roughness: 0.95, metalness: 0 }), stains, "item_dirt");
10919
+ stains.forEach((_, i) => dirt.mesh.setColorAt(i, new T2.Color(STAIN_COLORS[i % STAIN_COLORS.length])));
10920
+ const foam = layerOf(T2, new T2.SphereGeometry(1, 8, 6), new T2.MeshStandardMaterial({ color: FOAM_COLOR, roughness: 0.55, metalness: 0 }), bubbles, "item_foam");
10921
+ group.add(dirt.mesh, foam.mesh);
10922
+ root.add(group);
10923
+ return { dirt, foam, scratch };
10924
+ }
10925
+ function overlayOf(T2, root) {
10926
+ const found = overlays.get(root);
10927
+ if (found) return found;
10928
+ const created = createOverlay(T2, root);
10929
+ overlays.set(root, created);
10930
+ return created;
10931
+ }
10932
+ function showLayer(layer, value, scratch) {
10933
+ if (!layer) return;
10934
+ const share = Math.max(0, Math.min(1, value));
10935
+ if (share === layer.value) return;
10936
+ layer.value = share;
10937
+ layer.mesh.visible = share > 0;
10938
+ if (share === 0) return;
10939
+ const grow = 0.45 + 0.55 * share;
10940
+ scratch.scale.makeScale(grow, grow, grow);
10941
+ layer.bases.forEach((base2, i) => {
10942
+ scratch.matrix.copy(base2).multiply(scratch.scale);
10943
+ layer.mesh.setMatrixAt(i, scratch.matrix);
10944
+ });
10945
+ layer.mesh.instanceMatrix.needsUpdate = true;
10946
+ }
10947
+ function setItemDirt(T2, root, dirt) {
10948
+ const overlay = overlayOf(T2, root);
10949
+ showLayer(overlay.dirt, dirt, overlay.scratch);
10950
+ }
10951
+ function setItemFoam(T2, root, amount) {
10952
+ const overlay = overlayOf(T2, root);
10953
+ showLayer(overlay.foam, amount, overlay.scratch);
10954
+ }
10955
+
10193
10956
  // src/contained.ts
10194
10957
  function createContainedItemModel(items, options = {}) {
10958
+ const { rules, ...build } = options;
10195
10959
  const byId = /* @__PURE__ */ new Map();
10196
10960
  for (const item of items) byId.set(item.id, item);
10197
10961
  return (stack, T2) => {
10198
10962
  const item = byId.get(stack.type);
10199
10963
  if (!item) return null;
10200
- 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);
10201
10968
  model.root.userData.item = { id: item.id, kind: model.kind };
10969
+ const dirt = stack.data?.["dirt"];
10970
+ if (typeof dirt === "number" && dirt > 0) setItemDirt(T2, model.root, dirt);
10202
10971
  return model.root;
10203
10972
  };
10204
10973
  }
@@ -10732,11 +11501,11 @@ var GameItemsThree = (() => {
10732
11501
  mergeByMaterial: () => mergeByMaterial,
10733
11502
  mix: () => mix,
10734
11503
  resolveStrings: () => resolveStrings,
10735
- rng: () => rng,
11504
+ rng: () => rng2,
10736
11505
  seedOf: () => seedOf,
10737
11506
  shade: () => shade2
10738
11507
  });
10739
- function rng(seed) {
11508
+ function rng2(seed) {
10740
11509
  let s = seed >>> 0;
10741
11510
  return () => {
10742
11511
  s = s + 1831565813 >>> 0;
@@ -10801,7 +11570,7 @@ var GameItemsThree = (() => {
10801
11570
  function floorAtlas(doc) {
10802
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];
10803
11572
  const cell = (c, seed, f) => {
10804
- const [x0, y0] = P(c), r = rng(seed);
11573
+ const [x0, y0] = P(c), r = rng2(seed);
10805
11574
  f(g, x0, y0, r);
10806
11575
  };
10807
11576
  for (const [c, seed] of [[0, 11], [1, 12]]) cell(c, seed, (g2, x0, y0, r) => {
@@ -10962,7 +11731,7 @@ var GameItemsThree = (() => {
10962
11731
  function pictureAtlas(doc, names) {
10963
11732
  const N = 256, cv = makeCanvas(doc, N * 4, N * 2), g = cv.getContext("2d");
10964
11733
  const cell = (c, seed, f) => {
10965
- 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);
10966
11735
  g.save();
10967
11736
  g.beginPath();
10968
11737
  g.rect(x0, y0, N, N);
@@ -11141,7 +11910,7 @@ var GameItemsThree = (() => {
11141
11910
  return { canvas: cv, n: PICTURE_CELLS - 1, uv: (c) => uvc(c), mirror: () => uvc(7), names };
11142
11911
  }
11143
11912
  function waterAtlas(doc) {
11144
- 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);
11145
11914
  g.fillStyle = "#e6f2f8";
11146
11915
  g.fillRect(0, 0, N, N);
11147
11916
  seamless(g, 0, 0, N, () => {
@@ -12054,7 +12823,7 @@ var GameItemsThree = (() => {
12054
12823
  const color2 = o.color != null ? hex2(o.color) : 16777215;
12055
12824
  const poly = o.poly || M.poly;
12056
12825
  const sd = seedOf(M);
12057
- const rnd = rng(sd);
12826
+ const rnd = rng2(sd);
12058
12827
  const tint = () => {
12059
12828
  const v = 0.93 + rnd() * 0.07;
12060
12829
  return mix(0, color2, v);
@@ -12106,7 +12875,7 @@ var GameItemsThree = (() => {
12106
12875
  const K = {
12107
12876
  M,
12108
12877
  api,
12109
- rnd: rng(seedOf(M)),
12878
+ rnd: rng2(seedOf(M)),
12110
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),
12111
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),
12112
12881
  leaf: (x, y, z, w, h, color2, ry, rx) => api.leaf(M, x, y, z, w, h, hex2(color2), ry || 0, rx || 0),
@@ -13062,7 +13831,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13062
13831
  };
13063
13832
  var JOINT_GAP = 1e-4;
13064
13833
  var MIN_BEARING_SHARE = 0.25;
13065
- var unsupportedCells = (cells, thin, dims, standing) => {
13834
+ var unsupportedCells = (cells, thin, dims, standing, bears) => {
13066
13835
  if (thin === 1) return unheldSlabCells(cells, dims, standing);
13067
13836
  const [u, v] = planeAxes(thin);
13068
13837
  const bottom = -dims[v] / 2;
@@ -13080,6 +13849,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
13080
13849
  const held = /* @__PURE__ */ new Set();
13081
13850
  const queue = [];
13082
13851
  for (const i of rows.get(0) ?? []) {
13852
+ if (bears && !bears(i)) continue;
13083
13853
  held.add(i);
13084
13854
  queue.push(i);
13085
13855
  }
@@ -14434,19 +15204,31 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
14434
15204
  var clampNumber = (v, a, b) => Math.max(a, Math.min(b, v));
14435
15205
  var settlementAt = (settlement, point) => {
14436
15206
  const d = [settlement.to[0] - settlement.from[0], settlement.to[1] - settlement.from[1], settlement.to[2] - settlement.from[2]];
15207
+ const px = point[0] - settlement.from[0];
15208
+ const py = point[1] - settlement.from[1];
15209
+ const pz = point[2] - settlement.from[2];
14437
15210
  const length2 = d[0] * d[0] + d[1] * d[1] + d[2] * d[2];
14438
- const t = length2 > 0 ? clampNumber(((point[0] - settlement.from[0]) * d[0] + (point[1] - settlement.from[1]) * d[1] + (point[2] - settlement.from[2]) * d[2]) / length2, 0, 1) : 0;
15211
+ const along2 = length2 > 0 ? (px * d[0] + py * d[1] + pz * d[2]) / length2 : 0;
15212
+ const t = clampNumber(along2, 0, 1);
14439
15213
  const drops = settlement.drop;
14440
15214
  if (drops.length === 0) return 0;
14441
15215
  const at2 = t * (drops.length - 1);
14442
15216
  const i = Math.floor(at2);
14443
15217
  const j = Math.min(drops.length - 1, i + 1);
14444
- return drops[i] + (drops[j] - drops[i]) * (at2 - i);
15218
+ const f = at2 - i;
15219
+ const drop = drops[i] + (drops[j] - drops[i]) * f;
15220
+ const turn = settlement.turn;
15221
+ if (!turn || turn.length !== drops.length) return drop;
15222
+ const a = turn[i];
15223
+ const b = turn[j];
15224
+ const armX = px - d[0] * along2;
15225
+ const armZ = pz - d[2] * along2;
15226
+ return drop - ((a[2] + (b[2] - a[2]) * f) * armX - (a[0] + (b[0] - a[0]) * f) * armZ);
14445
15227
  };
14446
15228
  var mergeSettlement = (old, next) => {
14447
15229
  if (!old) return next;
14448
15230
  const same = old.from.every((v, k) => Math.abs(v - next.from[k]) < 1e-6) && old.to.every((v, k) => Math.abs(v - next.to[k]) < 1e-6);
14449
- if (same && old.drop.length === next.drop.length) return { from: old.from, to: old.to, drop: old.drop.map((v, k) => Math.max(v, next.drop[k])) };
15231
+ if (same && old.drop.length === next.drop.length && !old.turn && !next.turn) return { from: old.from, to: old.to, drop: old.drop.map((v, k) => Math.max(v, next.drop[k])) };
14450
15232
  const mean = (line) => line.drop.reduce((sum, v) => sum + v, 0) / Math.max(1, line.drop.length);
14451
15233
  return mean(old) >= mean(next) ? old : next;
14452
15234
  };
@@ -15178,7 +15960,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15178
15960
  tearJoules: 80
15179
15961
  }
15180
15962
  },
15181
- failureMPa: 40
15963
+ failureMPa: 40,
15964
+ elastic: {
15965
+ alongGPa: 6.96,
15966
+ shearGPa: 0.44
15967
+ }
15182
15968
  },
15183
15969
  {
15184
15970
  id: "mdf",
@@ -15225,7 +16011,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
15225
16011
  tearJoules: 20
15226
16012
  }
15227
16013
  },
15228
- failureMPa: 25
16014
+ failureMPa: 25,
16015
+ elastic: {
16016
+ alongGPa: 3,
16017
+ shearGPa: 0.8
16018
+ }
15229
16019
  },
15230
16020
  {
15231
16021
  id: "glass",
@@ -16766,17 +17556,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16766
17556
  const index = shape.placeOf(i, j);
16767
17557
  k[index] = k[index] + value;
16768
17558
  }
16769
- function halfQuadratic(shape, k, x) {
17559
+ function multiply2(shape, k, x, out) {
16770
17560
  const { n, start, rows } = shape;
16771
- let total = 0;
17561
+ for (let j = 0; j < n; j++) out[j] = k[j] * x[j];
16772
17562
  for (let j = 0; j < n; j++) {
16773
17563
  const xj = x[j];
16774
- if (xj === 0) continue;
16775
- let column = 0.5 * k[j] * xj;
16776
- for (let p = start[j]; p < start[j + 1]; p++) column += k[n + p] * x[rows[p]];
16777
- total += xj * column;
17564
+ for (let p = start[j]; p < start[j + 1]; p++) {
17565
+ const i = rows[p];
17566
+ const value = k[n + p];
17567
+ out[i] = out[i] + value * xj;
17568
+ out[j] = out[j] + value * x[i];
17569
+ }
16778
17570
  }
16779
- return total;
16780
17571
  }
16781
17572
  function factor(shape, k, from, to) {
16782
17573
  const { n, start, rows, beforeStart, before } = shape;
@@ -16830,7 +17621,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
16830
17621
  placeOf: (i, j) => placeOf(shape, i, j),
16831
17622
  factor: (k, from, to) => factor(shape, k, from, to),
16832
17623
  substitute: (k, f) => substitute(shape, k, f),
16833
- halfQuadratic: (k, x) => halfQuadratic(shape, k, x)
17624
+ multiply: (k, x, out) => multiply2(shape, k, x, out)
16834
17625
  };
16835
17626
  };
16836
17627
  function hullOf(points) {
@@ -17018,14 +17809,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17018
17809
  const delta = new Float64Array(n);
17019
17810
  for (let i = 0; i < n; i++) delta[i] = after.u[i] - before.u[i];
17020
17811
  for (const beam of beams.values()) if (!after.standing.has(beam.part.id)) for (const node of beam.nodes) for (const dof of dofsOf(node)) delta[dof] = 0;
17021
- const potential = (x) => {
17022
- let height = 0;
17023
- for (let i = 0; i < n; i++) height += after.load[i] * x[i];
17024
- return frame2.shape.halfQuadratic(after.structure, x) - height;
17025
- };
17026
- const had = new Float64Array(n);
17027
- for (let i = 0; i < n; i++) had[i] = after.u[i] - delta[i];
17028
- released = Math.max(0, potential(had) - potential(after.u));
17812
+ const d = new Float64Array(n);
17813
+ for (let i = 0; i < n; i++) d[i] = -delta[i];
17814
+ const kd = new Float64Array(n);
17815
+ frame2.shape.multiply(after.structure, d, kd);
17816
+ const ku = new Float64Array(n);
17817
+ frame2.shape.multiply(after.structure, after.u, ku);
17818
+ let change = 0;
17819
+ for (let i = 0; i < n; i++) change += d[i] * (0.5 * kd[i] + (ku[i] - after.load[i]));
17820
+ released = Math.max(0, change);
17029
17821
  spin = spinOf({ frame: frame2, after, delta, released, centre: allCentre, mass: all, floor, g });
17030
17822
  }
17031
17823
  return {
@@ -17049,12 +17841,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
17049
17841
  const from = vec.madd(beam.part.position, beam.axis, -beam.length / 2);
17050
17842
  const to = vec.madd(beam.part.position, beam.axis, beam.length / 2);
17051
17843
  const drop = [];
17844
+ const turn = [];
17052
17845
  for (let i = 0; i < SAG_STATIONS; i++) {
17053
17846
  const point = vec.madd(from, beam.axis, beam.length * i / (SAG_STATIONS - 1));
17054
17847
  const node = carrier ? carrier.node : nearest(beam, point);
17055
17848
  drop.push(-moved(after, { part: id, node, arm: vec.sub(point, nodes[node].at), mass: 0 })[1]);
17849
+ const base2 = order2[node] * 6;
17850
+ turn.push([after.u[base2 + 3], after.u[base2 + 4], after.u[base2 + 5]]);
17056
17851
  }
17057
- return { from, to, drop };
17852
+ return { from, to, drop, turn };
17058
17853
  }
17059
17854
  };
17060
17855
  }
@@ -19253,6 +20048,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
19253
20048
  } else emit({ ...base2(o, src), type: "stage", part: p.spec.id, stage: 2, opening: { center: worldCenter, radius: hole.radius }, fragments });
19254
20049
  debris(o, p, p.mat.breakDebris, worldCenter, [0, 1, 0], 14, 2, src);
19255
20050
  if (p.spec.reinforcement) exposeRebar(o, p, src);
20051
+ dropOverOpening(o, p, src);
19256
20052
  };
19257
20053
  const distort = (o, q, beta, at2, toward, src) => {
19258
20054
  const prior = q.rt.distortion ?? 0;
@@ -20494,7 +21290,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20494
21290
  const faceArea = (cell) => cell.size[u] * cell.size[v];
20495
21291
  const total = cells.reduce((sum, cell) => sum + faceArea(cell), 0) || 1;
20496
21292
  const shape = p.spec.units ? "chunk" : FRAGMENT_SHAPE[p.mat.fracture] ?? "chunk";
20497
- const laid = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
21293
+ const laid2 = !!p.spec.units && p.spec.units.mortar !== p.spec.material;
20498
21294
  const pieces = shape === "shard" && bondedPlate(o, p) ? cells.flatMap((cell) => shardsOfCell(cell, u, v)) : cells;
20499
21295
  return pieces.map((cell, i) => {
20500
21296
  const cw = toWorld(c, q, cell.center);
@@ -20503,7 +21299,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20503
21299
  const k = speed * (0.6 + 0.8 * rnd());
20504
21300
  const marks = marksInBox(cell.center, cell.size, void 0, holes);
20505
21301
  const size = [cell.size[0], cell.size[1], cell.size[2]];
20506
- if (laid) for (const a of [u, v]) size[a] = Math.max(size[a] * MIN_UNIT_SHARE, size[a] - MORTAR_JOINT);
21302
+ if (laid2) for (const a of [u, v]) size[a] = Math.max(size[a] * MIN_UNIT_SHARE, size[a] - MORTAR_JOINT);
20507
21303
  return {
20508
21304
  id: `${p.spec.id}#${tag}${i}`,
20509
21305
  part: p.spec.id,
@@ -20516,7 +21312,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20516
21312
  angularVelocity: bornSpin(cell.size, 8, rnd),
20517
21313
  mass: mass * faceArea(cell) / total,
20518
21314
  ...marks.length > 0 ? { marks } : {},
20519
- ...inner && laid ? { unit: true } : inner ? { inner } : {}
21315
+ ...inner && laid2 ? { unit: true } : inner ? { inner } : {}
20520
21316
  };
20521
21317
  });
20522
21318
  };
@@ -20927,7 +21723,19 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20927
21723
  if (p.st.stripped) bars = [...bars, ...stirrups];
20928
21724
  else for (const box4 of [...p.st.chipped ?? [], ...p.rt.bared ?? []]) bars.push(...clipBarsToVolume(stirrups, box4.center, box4.size));
20929
21725
  }
20930
- emit({ ...base2(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, bars) });
21726
+ emit({ ...base2(o, src), type: "expose", part: p.spec.id, bars: worldBars(o, p, belowCut(p, bars)) });
21727
+ };
21728
+ const belowCut = (p, bars) => {
21729
+ const cut = p.rt.cutThrough;
21730
+ if (cut === void 0) return bars.map(([a, b]) => [a, b]);
21731
+ const height = (x) => p.pos[1] + rotateVec(p.q, x)[1];
21732
+ return bars.flatMap(([a, b]) => {
21733
+ const ha = height(a) - cut, hb = height(b) - cut;
21734
+ if (ha <= 0 && hb <= 0) return [[a, b]];
21735
+ if (ha > 0 && hb > 0) return [];
21736
+ const at2 = vec.add(a, vec.scale(vec.sub(b, a), ha / (ha - hb)));
21737
+ return [ha <= 0 ? [a, at2] : [at2, b]];
21738
+ });
20931
21739
  };
20932
21740
  const openBreach = (o, p, center, total, energy, dir, src) => {
20933
21741
  const [u, v] = planeAxes(p.thin);
@@ -20956,6 +21764,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
20956
21764
  setStage(o, p, 2, { opening: { center: worldCenter, radius }, fragments }, src);
20957
21765
  debris(o, p, p.mat.breakDebris, worldCenter, vec.scale(dir ?? [0, 1, 0], -1), 14, 3, src);
20958
21766
  dropUnsupported(o, p, src);
21767
+ dropOverOpening(o, p, src);
20959
21768
  const reinforcement = p.spec.reinforcement;
20960
21769
  if (reinforcement) exposeRebar(o, p, src);
20961
21770
  if (p.structural) solveStructure(o);
@@ -21181,6 +21990,28 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21181
21990
  }
21182
21991
  return false;
21183
21992
  };
21993
+ const bedOverHoles = (o, p, grid) => {
21994
+ const bases = (o.byPart.get(p.spec.id) ?? []).filter((j) => j.bears === "a_on_b" && j.spec.a === p.spec.id && !j.st.open).map((j) => o.parts[j.ib]).filter((q) => !!q.st.opening);
21995
+ if (bases.length === 0) return void 0;
21996
+ const [, v] = planeAxes(p.thin);
21997
+ const bed = [0, 0, 0];
21998
+ return (i) => {
21999
+ const cell = grid[i];
22000
+ bed[0] = cell.center[0];
22001
+ bed[1] = cell.center[1];
22002
+ bed[2] = cell.center[2];
22003
+ bed[v] = cell.center[v] - cell.size[v] / 2;
22004
+ const at2 = toWorld(p.pos, p.q, bed);
22005
+ return !bases.some((q) => insideOpening(o, q, at2));
22006
+ };
22007
+ };
22008
+ const dropOverOpening = (o, q, src) => {
22009
+ for (const j of o.byPart.get(q.spec.id) ?? []) {
22010
+ if (j.bears !== "a_on_b" || j.spec.b !== q.spec.id || j.st.open) continue;
22011
+ const p = o.parts[j.ia];
22012
+ if (p.spec.units && !isLost(p)) dropUnsupported(o, p, src);
22013
+ }
22014
+ };
21184
22015
  const dropUnsupported = (o, p, src) => {
21185
22016
  var _a, _b;
21186
22017
  if (!p.spec.units || p.spec.units.mortar === p.spec.material || p.st.stripped || isLost(p)) return 0;
@@ -21190,7 +22021,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21190
22021
  const op = p.st.opening ? toLocal(p.pos, p.q, p.st.opening.center) : null;
21191
22022
  const opened = (cell) => !!op && !!p.st.opening && Math.hypot(cell.center[u] - op[u], cell.center[v] - op[v]) <= p.st.opening.radius;
21192
22023
  const castHere = castCells(p);
21193
- const loose = wedgedUnder(o, p, unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !opened(grid[i]))).filter((i) => !castHere.has(i));
22024
+ const loose = wedgedUnder(o, p, unsupportedCells(grid, p.thin, p.dims, (i) => worn[i] !== -1 && !opened(grid[i]), bedOverHoles(o, p, grid))).filter((i) => !castHere.has(i));
21194
22025
  if (loose.length === 0) return 0;
21195
22026
  for (const i of loose) worn[i] = -1;
21196
22027
  const fallen = loose.map((i) => grid[i]);
@@ -21356,7 +22187,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
21356
22187
  const cell = grid[i];
21357
22188
  return vec.add(p.pos, rotateVec(p.q, cell.center))[1] - (Math.abs(ax[0]) * cell.size[0] + Math.abs(ax[1]) * cell.size[1] + Math.abs(ax[2]) * cell.size[2]) / 2;
21358
22189
  }));
21359
- knockOutUnits(o, p, wp, 0, above, src, [0, -1, 0], 0, { point: [p.pos[0], floor, p.pos[2]], normal: [0, 1, 0] });
22190
+ p.rt.cutThrough = floor;
22191
+ const severed = { point: toWorld(o.st.position, o.st.rotation, [p.pos[0], floor, p.pos[2]]), normal: rotateVec(o.st.rotation, [0, 1, 0]) };
22192
+ knockOutUnits(o, p, wp, 0, above, src, [0, -1, 0], 0, severed);
22193
+ exposeRebar(o, p, src);
21360
22194
  };
21361
22195
  const giveAtCut = (o, p, src, cut) => {
21362
22196
  if (!p.spec.reinforcement || !p.spec.units || !p.st.chipped?.length || sectionLoss(p) <= 0) return false;
@@ -25989,418 +26823,6 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
25989
26823
  return [[mast.u, mast.v, mast.y0], [mast.u, mast.v, mast.y1], ...arc];
25990
26824
  }
25991
26825
 
25992
- // ../game-interactables/dist/index.js
25993
- function hashString(text) {
25994
- let h = 2166136261;
25995
- for (let i = 0; i < text.length; i++) {
25996
- h ^= text.charCodeAt(i);
25997
- h = Math.imul(h, 16777619);
25998
- }
25999
- return h >>> 0;
26000
- }
26001
- function rng2(seed = 1) {
26002
- let a = (typeof seed === "number" ? Math.floor(seed) >>> 0 : hashString(seed)) || 2654435769;
26003
- return () => {
26004
- a = a + 1831565813 >>> 0;
26005
- let t = a;
26006
- t = Math.imul(t ^ t >>> 15, t | 1);
26007
- t ^= t + Math.imul(t ^ t >>> 7, t | 61);
26008
- return ((t ^ t >>> 14) >>> 0) / 4294967296;
26009
- };
26010
- }
26011
- var pose = new Float64Array(7);
26012
- var pose2 = new Float64Array(7);
26013
-
26014
- // ../game-items/dist/index.js
26015
- var DEFAULT_RULES = {
26016
- rarity: {
26017
- weights: { common: 60, uncommon: 28, rare: 9, very_rare: 2.5, legendary: 0.5, unique: 0 },
26018
- fixedOnly: ["legendary", "unique"]
26019
- },
26020
- freshness: { stale: 0.5, spoiled: 1, rotten: 1.5 },
26021
- storage: {
26022
- fridge: { multiplier: 0.33, needsPower: true },
26023
- freezer: { multiplier: 0.1, needsPower: true },
26024
- cooler: { multiplier: 0.5, limitDays: 2, afterLimit: 1 },
26025
- delivery_bag: { multiplier: 0.8 },
26026
- cellar: { multiplier: 0.66 },
26027
- ambient: { multiplier: 1 },
26028
- hot: { multiplier: 2 }
26029
- },
26030
- carry: { baseKg: 8, perStrengthKg: 2.5, factor: 1.2, encumbered: 1, overloaded: 1.5 },
26031
- protection: { cap: 0.9, wear: { bite: 8, scratch: 3 }, tornShare: 0.25, repairMargin: 10 },
26032
- aging: { thawShelfDays: { freezer: 2 } },
26033
- inventory: {
26034
- defaultSlots: 10,
26035
- encumberedRunFactor: 0.75,
26036
- defaultLitres: 12,
26037
- defaultInside: [0.3, 0.25, 0.16],
26038
- bagInside: {
26039
- shopping_bag: [0.4, 0.35, 0.15],
26040
- trash_bag: [0.6, 0.45, 0.12],
26041
- fanny_pack: [0.22, 0.12, 0.1],
26042
- crossbody_bag: [0.25, 0.2, 0.12],
26043
- backpack: [0.5, 0.3, 0.2],
26044
- delivery_bag: [0.45, 0.45, 0.25],
26045
- hiking_backpack_40l: [0.6, 0.35, 0.19],
26046
- military_backpack: [0.6, 0.35, 0.21],
26047
- trekking_backpack_70l: [0.75, 0.38, 0.25],
26048
- rolling_suitcase: [0.6, 0.4, 0.21],
26049
- tactical_vest: [0.3, 0.2, 0.1],
26050
- tool_belt: [0.4, 0.2, 0.1],
26051
- cooler_box: [0.32, 0.25, 0.23],
26052
- shopping_cart: [0.9, 0.55, 0.16],
26053
- wheelbarrow: [1.2, 0.6, 0.15]
26054
- },
26055
- bagLitres: {
26056
- shopping_bag: 20,
26057
- trash_bag: 30,
26058
- fanny_pack: 3,
26059
- crossbody_bag: 6,
26060
- backpack: 30,
26061
- delivery_bag: 50,
26062
- hiking_backpack_40l: 40,
26063
- military_backpack: 45,
26064
- trekking_backpack_70l: 70,
26065
- rolling_suitcase: 50,
26066
- tactical_vest: 6,
26067
- tool_belt: 8,
26068
- cooler_box: 18,
26069
- shopping_cart: 80,
26070
- wheelbarrow: 100
26071
- }
26072
- },
26073
- use: {
26074
- freshness: {
26075
- stale: { satietyFactor: 0.7, poisonChance: 0.1, morale: 0, isEdible: true },
26076
- spoiled: { satietyFactor: 0.7, poisonChance: 0.5, morale: -20, isEdible: true },
26077
- rotten: { satietyFactor: 0, poisonChance: 0, morale: 0, isEdible: false }
26078
- },
26079
- cookedPoisonFactor: 0.25
26080
- },
26081
- spawn: {
26082
- retailNew: true,
26083
- retailPlaces: ["supermarket", "pharmacy", "mall", "gas_station", "gun_shop"],
26084
- retailContainers: ["store_shelf", "stockroom"],
26085
- condition: { common: [30, 90], uncommon: [40, 90], rare: [50, 100], very_rare: [50, 100], legendary: [50, 100], unique: [50, 100] },
26086
- ageShare: [0, 0.6],
26087
- charge: [0.2, 1],
26088
- fillable: ["fuel_jerrycan"],
26089
- fill: [0, 0.6]
26090
- },
26091
- finds: {
26092
- fallbackContainer: "zombie_corpse",
26093
- rollExcluded: ["ammo_7_62x39"],
26094
- depletion: [
26095
- { places: ["pharmacy", "gun_shop", "police_station"], perDay: 0.05, floor: 0.3 },
26096
- { places: ["supermarket", "gas_station"], perDay: 0.04, floor: 0.35 },
26097
- { places: ["mall", "hospital"], perDay: 0.025, floor: 0.5 },
26098
- { places: ["house", "apartment"], perDay: 0.01, floor: 0.7 },
26099
- { places: ["farm", "warehouse", "mine", "dam", "lodge", "church"], perDay: 5e-3, floor: 0.85 },
26100
- { places: ["military_base"], perDay: 0, floor: 1 }
26101
- ],
26102
- regionMultiplier: {},
26103
- states: { normal: "normal", fortified: "fortified", abandoned: "abandoned" },
26104
- pool: {
26105
- defaultFootprint: 0.5,
26106
- offset: 1.5,
26107
- perSquareMetre: 3,
26108
- jitter: 1.5,
26109
- min: 2,
26110
- max: 5,
26111
- fortifiedExtra: 2,
26112
- supplyWeight: 2.5,
26113
- supplyExtraQty: 1,
26114
- abandonedEmptyChance: 0.4,
26115
- abandonedKept: 1,
26116
- junkChance: 0.5,
26117
- junkItem: "food_packaging",
26118
- spoiledFoodItem: "leftover_meal",
26119
- coldContainers: ["geladeira", "refrig_exp", "freezer"]
26120
- }
26121
- }
26122
- };
26123
- var ITEM_CATEGORIES = [
26124
- { id: "food", name: "Food" },
26125
- { id: "drink", name: "Drink" },
26126
- { id: "medical", name: "Medical" },
26127
- { id: "tools", name: "Tools" },
26128
- { id: "melee", name: "Melee" },
26129
- { id: "materials", name: "Materials" },
26130
- { id: "clothing", name: "Clothing" },
26131
- { id: "bags", name: "Bags" },
26132
- { id: "electronics", name: "Electronics" },
26133
- { id: "fuel", name: "Fuel" },
26134
- { id: "outdoors", name: "Outdoors" },
26135
- { id: "books", name: "Books" },
26136
- { id: "collectibles", name: "Collectibles" },
26137
- { id: "keys", name: "Keys" }
26138
- ];
26139
- var storageRuleOf = (rules, storage) => {
26140
- const rule = rules.storage[storage];
26141
- if (!rule) throw new Error(`game-items: unknown storage "${storage}"`);
26142
- return rule;
26143
- };
26144
- var accruedDays = (storage, window, options) => {
26145
- const { powered = true, rules = DEFAULT_RULES } = options;
26146
- const rule = storageRuleOf(rules, storage);
26147
- const elapsed = window.to - window.from;
26148
- if (elapsed <= 0) return 0;
26149
- if (rule.needsPower && !powered) return elapsed;
26150
- if (rule.limitDays === void 0) return elapsed * rule.multiplier;
26151
- const limitEnd = window.storedAt + rule.limitDays;
26152
- const early = Math.max(0, Math.min(window.to, limitEnd) - Math.max(window.from, window.storedAt));
26153
- return early * rule.multiplier + (elapsed - early) * (rule.afterLimit ?? 1);
26154
- };
26155
- var advanceAge = (state, now, options = {}) => {
26156
- const { powered = true, rules = DEFAULT_RULES } = options;
26157
- const rule = storageRuleOf(rules, state.storage);
26158
- const thawDays = rules.aging.thawShelfDays[state.storage];
26159
- const isThawing = rule.needsPower === true && !powered && thawDays !== void 0 && state.shelfLife === void 0;
26160
- const base2 = isThawing ? { ...state, ageDays: 0, shelfLife: thawDays } : state;
26161
- const ageDays = base2.ageDays + accruedDays(state.storage, { storedAt: state.storedAt, from: state.since, to: now }, options);
26162
- return { ...base2, ageDays, since: Math.max(now, state.since) };
26163
- };
26164
- var shelfRatio = (item, state) => {
26165
- const shelfLife = state.shelfLife ?? item.shelfLife;
26166
- return shelfLife === void 0 ? 0 : state.ageDays / shelfLife;
26167
- };
26168
- var freshness = (item, state, now, options = {}) => {
26169
- const { rules = DEFAULT_RULES } = options;
26170
- const ratio = shelfRatio(item, advanceAge(state, now, options));
26171
- if (ratio >= rules.freshness.rotten) return "rotten";
26172
- if (ratio >= rules.freshness.spoiled) return "spoiled";
26173
- if (ratio >= rules.freshness.stale) return "stale";
26174
- return "fresh";
26175
- };
26176
- var FRESH_NUTRITION = { satietyFactor: 1, poisonChance: 0, morale: 0, isEdible: true };
26177
- var nutritionOf = (item, context, rules) => {
26178
- const state = context.freshness ?? "fresh";
26179
- const effect = state === "fresh" ? FRESH_NUTRITION : rules.use.freshness[state];
26180
- const poisonShare = context.isCooked ? rules.use.cookedPoisonFactor : 1;
26181
- return {
26182
- satiety: (item.nutrition?.satiety ?? 0) * effect.satietyFactor,
26183
- hydration: item.nutrition?.hydration ?? 0,
26184
- morale: effect.morale,
26185
- poisonChance: effect.poisonChance * poisonShare,
26186
- isEdible: effect.isEdible
26187
- };
26188
- };
26189
- var findEffect = (item, effects) => effects.find((entry2) => entry2.items?.includes(item.id)) ?? effects.find((entry2) => entry2.category?.includes(item.category));
26190
- var resolveUse = (item, effects, context = {}, rules = DEFAULT_RULES) => {
26191
- const def = findEffect(item, effects);
26192
- if (!def) return void 0;
26193
- const base2 = { useId: def.id, effect: def.effect, params: def.params ?? {}, consumes: def.consumes };
26194
- if (def.effect !== "consume_nutrition") return base2;
26195
- const nutrition = nutritionOf(item, context, rules);
26196
- const blocked = item.seal && context.seal ? sealBlock(item.seal, context.seal) : void 0;
26197
- if (blocked) return { ...base2, consumes: false, nutrition: { ...nutrition, isEdible: false }, blocked };
26198
- return { ...base2, consumes: def.consumes && nutrition.isEdible, nutrition };
26199
- };
26200
- var countOf = (context, id) => context.inventory.get(id) ?? 0;
26201
- var candidatesOf = (input, context) => {
26202
- if (input.item !== void 0) return [input.item];
26203
- if (input.any) return [...input.any];
26204
- if (!input.match) return [];
26205
- const { category, cookable } = input.match;
26206
- return context.catalog.list().filter((item) => (category === void 0 || item.category === category) && (cookable === void 0 || item.cookable === cookable)).map((item) => item.id);
26207
- };
26208
- var describeInput = (input) => {
26209
- if (input.item !== void 0) return `item:${input.item}`;
26210
- if (input.any) return `any:${input.any.join("|")}`;
26211
- if (input.match) return `match:${input.match.category ?? "cookable"}`;
26212
- if (input.fluid !== void 0) return `fluid:${input.fluid}`;
26213
- return `world:${(input.world ?? []).join("|")}`;
26214
- };
26215
- var takeUnits = (candidates, needed, context) => {
26216
- const taken = [];
26217
- let remaining = needed;
26218
- for (const id of candidates) {
26219
- if (remaining <= 0) break;
26220
- const count = Math.min(remaining, countOf(context, id));
26221
- if (count > 0) taken.push({ item: id, count });
26222
- remaining -= count;
26223
- }
26224
- return remaining > 0 ? void 0 : taken;
26225
- };
26226
- var consumptionFor = (input, context) => {
26227
- if (input.world) return input.world.some((thing) => context.world?.has(thing)) ? [] : void 0;
26228
- if (input.fluid !== void 0) {
26229
- const liters = input.liters ?? 1;
26230
- return (context.fluids?.[input.fluid] ?? 0) >= liters ? [{ fluid: input.fluid, liters }] : void 0;
26231
- }
26232
- const taken = takeUnits(candidatesOf(input, context), input.qty ?? 1, context);
26233
- if (!taken || input.meters === void 0) return taken;
26234
- return taken.map((entry2) => "item" in entry2 ? { ...entry2, meters: input.meters } : entry2);
26235
- };
26236
- var toolMissing = (recipe, context) => recipe.tools.flatMap((tool2) => {
26237
- const missing = [];
26238
- if (tool2.anyOf.length > 0 && !tool2.anyOf.some((id) => countOf(context, id) > 0)) missing.push(`tool:${tool2.anyOf.join("|")}`);
26239
- if (tool2.world && !tool2.world.some((station) => context.world?.has(station))) missing.push(`world:${tool2.world.join("|")}`);
26240
- return missing;
26241
- });
26242
- var gateMissing = (recipe, context) => {
26243
- const missing = [];
26244
- if (context.skills && recipe.skill && (context.skills[recipe.skill.id] ?? 0) < recipe.skill.level) missing.push(`skill:${recipe.skill.id}:${recipe.skill.level}`);
26245
- if (context.unlocked && recipe.unlockedBy !== void 0 && !context.unlocked.has(recipe.unlockedBy)) missing.push(`unlock:${recipe.unlockedBy}`);
26246
- return missing;
26247
- };
26248
- var canCraft = (recipe, context) => {
26249
- const missing = [
26250
- ...gateMissing(recipe, context),
26251
- ...toolMissing(recipe, context),
26252
- ...recipe.inputs.filter((input) => consumptionFor(input, context) === void 0).map(describeInput)
26253
- ];
26254
- return { isPossible: missing.length === 0, missing };
26255
- };
26256
- var outcomeOf = (output, random) => {
26257
- if ("effect" in output) return { effect: output.effect, params: output.params, ...output.text === void 0 ? {} : { text: output.text } };
26258
- const [low, high] = output.qty;
26259
- return { item: output.item, count: low + Math.floor(random() * (high - low + 1)) };
26260
- };
26261
- var craft = (recipe, context, random) => {
26262
- const check = canCraft(recipe, context);
26263
- if (!check.isPossible) return { isCrafted: false, missing: check.missing };
26264
- const consumed = recipe.inputs.flatMap((input) => consumptionFor(input, context) ?? []);
26265
- return { isCrafted: true, seconds: recipe.seconds, consumed, output: outcomeOf(recipe.output, random) };
26266
- };
26267
- var depletionFactor = (place, day, rules) => {
26268
- if (day <= 0) return 1;
26269
- const rule = rules.finds.depletion.find((entry2) => entry2.places.includes(place));
26270
- return rule ? Math.max(rule.floor, 1 - rule.perDay * day) : 1;
26271
- };
26272
- var scaleCount = (count, scale, rules) => {
26273
- const region = scale.region === void 0 ? 1 : rules.finds.regionMultiplier[scale.region] ?? 1;
26274
- return Math.round(count * depletionFactor(scale.place, scale.day, rules) * region);
26275
- };
26276
- var rollableItems = (catalog, category, place) => {
26277
- const { rules } = catalog;
26278
- const rollable = catalog.byCategory(category).filter((item) => !rules.rarity.fixedOnly.includes(item.rarity) && !rules.finds.rollExcluded.includes(item.id));
26279
- const here = rollable.filter((item) => item.finds?.places.includes(place));
26280
- return here.length > 0 ? here : rollable;
26281
- };
26282
- var rarityWeight = (catalog, item) => catalog.rules.rarity.weights[item.rarity];
26283
- var pickCategory = (weights, random) => {
26284
- let remaining = random();
26285
- const categories = Object.keys(weights);
26286
- for (const category of categories) {
26287
- remaining -= weights[category];
26288
- if (remaining <= 0) return category;
26289
- }
26290
- return categories[0];
26291
- };
26292
- var rollByCategory = (catalog, query) => {
26293
- const { rules } = catalog;
26294
- const table = catalog.containers.get(query.container) ?? catalog.containers.get(rules.finds.fallbackContainer);
26295
- if (!table) return [];
26296
- const [low, high] = table.count ?? [0, 0];
26297
- const drawn = low + Math.floor(query.rng() * (high - low + 1));
26298
- const count = scaleCount(drawn, { place: query.place, day: query.day ?? 0, ...query.region === void 0 ? {} : { region: query.region } }, rules);
26299
- const weights = table.categories ?? table.categoriesByPlace?.[query.place] ?? table.categoriesByPlace?.["*"];
26300
- if (!weights) return [];
26301
- const picked = [];
26302
- for (let stack = 0; stack < count; stack++) {
26303
- const category = pickCategory(weights, query.rng);
26304
- const pool = category === void 0 ? [] : rollableItems(catalog, category, query.place);
26305
- if (pool.length === 0) continue;
26306
- const total = pool.reduce((sum, item) => sum + rarityWeight(catalog, item), 0);
26307
- let remaining = query.rng() * total;
26308
- for (const item of pool) {
26309
- remaining -= rarityWeight(catalog, item);
26310
- if (remaining <= 0) {
26311
- picked.push(item.id);
26312
- break;
26313
- }
26314
- }
26315
- }
26316
- return picked;
26317
- };
26318
- var weightedOrder = (candidates, random) => {
26319
- const remaining = [...candidates];
26320
- const ordered = [];
26321
- while (remaining.length > 0) {
26322
- const total = remaining.reduce((sum, candidate) => sum + candidate.weight, 0);
26323
- let x = random() * total;
26324
- let index = 0;
26325
- for (; index < remaining.length - 1; index++) {
26326
- x -= remaining[index].weight;
26327
- if (x < 0) break;
26328
- }
26329
- ordered.push(...remaining.splice(index, 1));
26330
- }
26331
- return ordered;
26332
- };
26333
- var countFor = (pool, state, footprint, query, rules) => {
26334
- const settings = rules.finds.pool;
26335
- const base2 = Math.max(settings.min, Math.min(settings.max, Math.round(settings.offset + footprint * settings.perSquareMetre + query.rng() * settings.jitter)));
26336
- if (state === "fortified") return Math.min(pool.length, base2 + settings.fortifiedExtra);
26337
- if (state === "abandoned") return query.rng() < settings.abandonedEmptyChance ? 0 : settings.abandonedKept;
26338
- return base2;
26339
- };
26340
- var rollExplicitPool = (pool, state, query, rules) => {
26341
- const settings = rules.finds.pool;
26342
- const n = countFor(pool, state, query.footprint ?? settings.defaultFootprint, query, rules);
26343
- const isFortified = state === "fortified";
26344
- const candidates = pool.map((entry2) => ({ entry: entry2, weight: isFortified && entry2.isSupply ? entry2.weight * settings.supplyWeight : entry2.weight }));
26345
- const picks = [];
26346
- for (const { entry: entry2 } of weightedOrder(candidates, query.rng).slice(0, n)) {
26347
- const [low, high] = entry2.qty;
26348
- const bonus = isFortified && entry2.isSupply ? settings.supplyExtraQty : 0;
26349
- picks.push({ itemId: entry2.item, count: low + Math.floor(query.rng() * (high - low + 1)) + bonus, entry: entry2 });
26350
- }
26351
- if (state === "abandoned") {
26352
- if (picks.length === 0 && query.rng() < settings.junkChance) picks.push({ itemId: settings.junkItem, count: 1 });
26353
- if (settings.coldContainers.includes(query.container) || query.key !== void 0 && settings.coldContainers.includes(query.key)) picks.push({ itemId: settings.spoiledFoodItem, count: 1 });
26354
- }
26355
- return picks;
26356
- };
26357
- var WEARING_DURABILITY = ["condition", "hits", "cuts"];
26358
- var hasCondition = (item) => item.protection !== void 0 || item.weapon !== void 0 || WEARING_DURABILITY.includes(item.durability?.kind ?? "");
26359
- var between = (range2, random) => range2[0] + random() * (range2[1] - range2[0]);
26360
- var spawnAgeDays = (item, outbreakDays, random, catalog) => item.shelfLife === void 0 ? void 0 : outbreakDays + between(catalog.rules.spawn.ageShare, random) * item.shelfLife;
26361
- var isRetailStock = (query, catalog) => {
26362
- const { spawn } = catalog.rules;
26363
- const isRetail = spawn.retailNew && (query.day ?? 0) <= 0 && spawn.retailPlaces.includes(query.place);
26364
- return isRetail && (spawn.retailContainers.length === 0 || spawn.retailContainers.includes(query.container));
26365
- };
26366
- var spawnData = (item, query, catalog) => {
26367
- const { spawn } = catalog.rules;
26368
- const data = {};
26369
- const ageDays = spawnAgeDays(item, query.day ?? 0, query.rng, catalog);
26370
- if (ageDays !== void 0) data.ageDays = ageDays;
26371
- if (hasCondition(item)) data.condition = isRetailStock(query, catalog) ? 100 : Math.round(between(spawn.condition[item.rarity], query.rng));
26372
- if (item.charge) data.charge = between(spawn.charge, query.rng);
26373
- if (spawn.fillable.includes(item.id)) data.fill = between(spawn.fill, query.rng);
26374
- return Object.keys(data).length > 0 ? data : void 0;
26375
- };
26376
- function createFindsProvider(catalog, options = {}) {
26377
- const rules = options.rules ? deepMerge(catalog.rules, options.rules) : catalog.rules;
26378
- const scoped = rules === catalog.rules ? catalog : { ...catalog, rules };
26379
- const usesPools = (options.pools ?? "team") === "team";
26380
- const aliases = options.placeAliases ?? {};
26381
- const poolPlaces = options.poolPlaces;
26382
- const passes = options.unknownContainers === "pass";
26383
- const choose2 = (query) => {
26384
- const pool = usesPools && (poolPlaces === void 0 || poolPlaces.includes(query.place)) ? scoped.pools.get(query.key ?? query.container) ?? scoped.pools.get(query.container) : void 0;
26385
- if (!pool && passes && !scoped.containers.has(query.container)) return null;
26386
- if (!pool) return rollByCategory(scoped, query).map((itemId) => ({ itemId, count: 1 }));
26387
- return rollExplicitPool(pool, rules.finds.states[query.state] ?? "normal", query, rules).map(({ itemId, count }) => ({ itemId, count }));
26388
- };
26389
- return {
26390
- findsFor(asked) {
26391
- const query = aliases[asked.place] === void 0 ? asked : { ...asked, place: aliases[asked.place] };
26392
- const chosen = choose2(query);
26393
- if (chosen === null) return null;
26394
- return chosen.filter((stack) => scoped.has(stack.itemId)).map((stack) => {
26395
- const data = spawnData(scoped.get(stack.itemId), query, scoped);
26396
- return data ? { ...stack, data } : stack;
26397
- });
26398
- }
26399
- };
26400
- }
26401
- var MM = 1e-3;
26402
- var BOX_WALL = 6 * MM;
26403
-
26404
26826
  // ../game-items-goods/dist/index.js
26405
26827
  var FLOORPLAN_POOL_KEYS = {
26406
26828
  fridge: "geladeira",
@@ -37276,6 +37698,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37276
37698
  material: "glass",
37277
37699
  thickness: 3e-3
37278
37700
  }
37701
+ ],
37702
+ container: {
37703
+ capacityLiters: 0.3
37704
+ },
37705
+ estimated: [
37706
+ "container"
37279
37707
  ]
37280
37708
  },
37281
37709
  {
@@ -37331,6 +37759,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37331
37759
  shape: "box",
37332
37760
  color: 15790304,
37333
37761
  rarity: "common",
37762
+ model: "soap",
37334
37763
  parts: [
37335
37764
  {
37336
37765
  id: "body",
@@ -37366,6 +37795,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37366
37795
  shape: "bottle",
37367
37796
  color: 4885200,
37368
37797
  rarity: "common",
37798
+ model: "shampoo",
37369
37799
  consumable: {
37370
37800
  form: "liquid",
37371
37801
  unit: "ml",
@@ -37373,7 +37803,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37373
37803
  dose: 8,
37374
37804
  emptyKg: 0.044,
37375
37805
  density: 1.02
37376
- }
37806
+ },
37807
+ parts: [
37808
+ {
37809
+ id: "body",
37810
+ material: "plastic",
37811
+ thickness: 8e-4
37812
+ }
37813
+ ],
37814
+ estimated: [
37815
+ "parts"
37816
+ ]
37377
37817
  },
37378
37818
  {
37379
37819
  id: "toothpaste",
@@ -37392,13 +37832,24 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37392
37832
  shape: "tube",
37393
37833
  color: 15790320,
37394
37834
  rarity: "common",
37835
+ model: "toothpaste",
37395
37836
  consumable: {
37396
37837
  form: "paste",
37397
37838
  unit: "g",
37398
37839
  amount: 90,
37399
37840
  dose: 1,
37400
37841
  emptyKg: 0.01
37401
- }
37842
+ },
37843
+ parts: [
37844
+ {
37845
+ id: "body",
37846
+ material: "plastic",
37847
+ thickness: 8e-4
37848
+ }
37849
+ ],
37850
+ estimated: [
37851
+ "parts"
37852
+ ]
37402
37853
  },
37403
37854
  {
37404
37855
  id: "toothbrush",
@@ -37416,7 +37867,18 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37416
37867
  stack: 3,
37417
37868
  shape: "tool",
37418
37869
  color: 3840720,
37419
- 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
+ ]
37420
37882
  },
37421
37883
  {
37422
37884
  id: "deodorant",
@@ -37527,8 +37989,17 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
37527
37989
  }
37528
37990
  ],
37529
37991
  estimated: [
37530
- "parts"
37531
- ]
37992
+ "parts",
37993
+ "consumable"
37994
+ ],
37995
+ consumable: {
37996
+ form: "liquid",
37997
+ unit: "ml",
37998
+ amount: 450,
37999
+ dose: 5,
38000
+ emptyKg: 0.03,
38001
+ density: 1.03
38002
+ }
37532
38003
  },
37533
38004
  {
37534
38005
  id: "bleach",
@@ -39018,8 +39489,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
39018
39489
  thickness: 2e-3
39019
39490
  }
39020
39491
  ],
39492
+ container: {
39493
+ capacityLiters: 0.35
39494
+ },
39021
39495
  estimated: [
39022
- "parts"
39496
+ "parts",
39497
+ "container"
39023
39498
  ]
39024
39499
  },
39025
39500
  {
@@ -39166,6 +39641,41 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
39166
39641
  },
39167
39642
  weapon: "brass_knuckles",
39168
39643
  model: "brass_knuckles"
39644
+ },
39645
+ {
39646
+ id: "plunger",
39647
+ category: "tools",
39648
+ kind: "tool",
39649
+ tags: [
39650
+ "cleaning"
39651
+ ],
39652
+ tools: [
39653
+ "plunger"
39654
+ ],
39655
+ size: [
39656
+ 0.14,
39657
+ 0.55,
39658
+ 0.14
39659
+ ],
39660
+ weight: 0.45,
39661
+ stack: 1,
39662
+ shape: "tool",
39663
+ color: 11545120,
39664
+ rarity: "common",
39665
+ finds: {
39666
+ places: [
39667
+ "house",
39668
+ "apartment"
39669
+ ]
39670
+ },
39671
+ parts: [
39672
+ {
39673
+ id: "body",
39674
+ material: "rubber",
39675
+ thickness: 4e-3
39676
+ }
39677
+ ],
39678
+ model: "plunger"
39169
39679
  }
39170
39680
  ];
39171
39681
  var kinds_default = [
@@ -40849,6 +41359,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
40849
41359
  "alicate"
40850
41360
  ]
40851
41361
  },
41362
+ plunger: {
41363
+ created: true,
41364
+ idSource: "decision",
41365
+ sizeSource: "REF",
41366
+ vc3: [
41367
+ "desentupidor"
41368
+ ]
41369
+ },
40852
41370
  adjustable_wrench: {
40853
41371
  ite: "chave_inglesa",
40854
41372
  idSource: "decision",
@@ -44268,6 +44786,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44268
44786
  "item.toothbrush": "Toothbrush",
44269
44787
  "item.deodorant": "Deodorant",
44270
44788
  "item.toilet_paper": "Toilet paper",
44789
+ "item.plunger": "Toilet plunger",
44271
44790
  "item.towel": "Towel",
44272
44791
  "item.detergent": "Detergent",
44273
44792
  "item.bleach": "Bleach",
@@ -44776,6 +45295,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
44776
45295
  "item.toothbrush": "Escova de dente",
44777
45296
  "item.deodorant": "Desodorante",
44778
45297
  "item.toilet_paper": "Papel higi\xEAnico",
45298
+ "item.plunger": "Desentupidor",
44779
45299
  "item.towel": "Toalha",
44780
45300
  "item.detergent": "Detergente",
44781
45301
  "item.bleach": "\xC1gua sanit\xE1ria",
@@ -45076,7 +45596,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45076
45596
  },
45077
45597
  toilet: {
45078
45598
  body: { material: "ceramic", joint: "bolt" },
45079
- parts: [["lid", door("plastic", "hinge", "lid")], ["flush_button", { material: "plastic", joint: "clip", piece: "button" }]]
45599
+ parts: [["lid", door("plastic", "hinge", "lid")], ["seat_ring", door("plastic", "hinge", "lid")], ["flush_button", { material: "plastic", joint: "clip", piece: "button" }]]
45080
45600
  },
45081
45601
  wall_socket: { body: { material: "plastic", joint: "screw" }, parts: [] },
45082
45602
  wall_switch: { body: { material: "plastic", joint: "screw" }, parts: [["rocker", { material: "plastic", joint: "clip", piece: "rocker" }]] },
@@ -45245,6 +45765,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45245
45765
  "prompt.toilet_lid": "Toilet lid",
45246
45766
  "prompt.toilet_lid.open": "Close the lid",
45247
45767
  "prompt.toilet_lid.closed": "Lift the lid",
45768
+ "prompt.toilet_seat": "Toilet seat",
45769
+ "prompt.toilet_seat.open": "Lower the seat",
45770
+ "prompt.toilet_seat.closed": "Lift the seat",
45248
45771
  "prompt.switch": "Light switch",
45249
45772
  "prompt.switch.on": "Switch off",
45250
45773
  "prompt.switch.on.verb": "Switch off",
@@ -45503,6 +46026,9 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
45503
46026
  "prompt.toilet_lid": "Tampa do vaso",
45504
46027
  "prompt.toilet_lid.open": "Fechar a tampa",
45505
46028
  "prompt.toilet_lid.closed": "Levantar a tampa",
46029
+ "prompt.toilet_seat": "Assento do vaso",
46030
+ "prompt.toilet_seat.open": "Abaixar o assento",
46031
+ "prompt.toilet_seat.closed": "Levantar o assento",
45506
46032
  "prompt.switch": "Interruptor",
45507
46033
  "prompt.switch.on": "Desligar a luz",
45508
46034
  "prompt.switch.on.verb": "Desligar",
@@ -46323,6 +46849,25 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
46323
46849
  }
46324
46850
  ];
46325
46851
  var WALL_PLATE = { width: 0.075, height: 0.12, thickness: 0.012, sink: 5e-3 };
46852
+ var DIRTY_PLATE = 0.8;
46853
+ var DIRTY_CUP = 0.5;
46854
+ var DIRTY_CUTLERY = 0.6;
46855
+ function goodsSize(id) {
46856
+ const item = GOODS_ITEMS.find((candidate) => candidate.id === id);
46857
+ if (!item) throw new Error(`game-interactables-household: the sinks lay "${id}", which the goods catalogue does not have`);
46858
+ return [item.size[0], item.size[1], item.size[2]];
46859
+ }
46860
+ var laid = (type, data) => ({ stack: { type, qty: 1, ...data ? { data } : {} }, size: goodsSize(type) });
46861
+ var DIRTY_DISHES = [
46862
+ laid("plate", { dirt: DIRTY_PLATE }),
46863
+ laid("cup", { dirt: DIRTY_CUP }),
46864
+ laid("cutlery", { dirt: DIRTY_CUTLERY })
46865
+ ];
46866
+ var WASHING_THINGS = [
46867
+ laid("detergent"),
46868
+ laid("sponge"),
46869
+ laid("cup")
46870
+ ];
46326
46871
  var DEFS2 = types_default;
46327
46872
  var HOUSEHOLD_ITEMS = GOODS_ITEMS.filter((item) => GOODS_PROVENANCE[item.id]?.household !== void 0);
46328
46873
  var itemTexts = (locale) => Object.fromEntries(HOUSEHOLD_ITEMS.map((item) => [`item.${item.id}`, GOODS_STRINGS[locale][`item.${item.id}`] ?? item.id]));
@@ -48926,7 +49471,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
48926
49471
  }
48927
49472
  var residentialTower = residentialTowerTemplate();
48928
49473
 
48929
- // ../game-floorplan-three/dist/chunk-3EJGIA6V.js
49474
+ // ../game-floorplan-three/dist/chunk-BTAHA26H.js
48930
49475
  var __defProp3 = Object.defineProperty;
48931
49476
  var __defNormalProp = (obj, key2, value) => key2 in obj ? __defProp3(obj, key2, { enumerable: true, configurable: true, writable: true, value }) : obj[key2] = value;
48932
49477
  var __publicField = (obj, key2, value) => __defNormalProp(obj, typeof key2 !== "symbol" ? key2 + "" : key2, value);
@@ -49020,13 +49565,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
49020
49565
  return out;
49021
49566
  }
49022
49567
  function exclusiveBoxes(solids) {
49023
- const laid = [];
49568
+ const laid2 = [];
49024
49569
  for (const solid of solids) {
49025
49570
  let pieces = [solid.box];
49026
- for (const before of laid) pieces = pieces.flatMap((piece22) => subtractBox(piece22, before.box));
49027
- for (const box4 of pieces) laid.push({ ...solid, box: box4 });
49571
+ for (const before of laid2) pieces = pieces.flatMap((piece22) => subtractBox(piece22, before.box));
49572
+ for (const box4 of pieces) laid2.push({ ...solid, box: box4 });
49028
49573
  }
49029
- return laid;
49574
+ return laid2;
49030
49575
  }
49031
49576
  function outsideBoxes(box4, taken) {
49032
49577
  let pieces = [box4];
@@ -50202,7 +50747,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
50202
50747
  if (!shared2.ctx.visorScene) shared2.ctx.occupied.push(b2);
50203
50748
  };
50204
50749
  const jw = DOOR_JAMB_WIDTH, jin = shared2.ctx.visorScene ? 0 : 2e-3, jy = !shared2.ctx.visorScene && f > 0 ? 2e-3 : 0;
50205
- 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) } });
50206
50751
  fb(a - jin, jy, a + jw, visH);
50207
50752
  fb(b - jw, jy, b + jin, visH);
50208
50753
  if (!cut) fb(a, dH - jw, b, dH);
@@ -52724,7 +53269,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52724
53269
  function addSpoil(THREE, parent, trenches, material, site) {
52725
53270
  const heap = new BoxBatch();
52726
53271
  const rects = trenches.map((t) => t.rect);
52727
- const laid = [];
53272
+ const laid2 = [];
52728
53273
  trenches.forEach(({ rect: r }, i) => {
52729
53274
  const others = rects.filter((_, k) => k !== i);
52730
53275
  for (const e of openEdges(r, others, site.solids)) {
@@ -52733,10 +53278,10 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
52733
53278
  const w = TRENCH.berm.width;
52734
53279
  const heapAt = ox ? [ox > 0 ? x1 + SPOIL_CLEAR : x0 - SPOIL_CLEAR - w, z0, ox > 0 ? x1 + SPOIL_CLEAR + w : x0 - SPOIL_CLEAR, z1] : [x0, oz > 0 ? z1 + SPOIL_CLEAR : z0 - SPOIL_CLEAR - w, x1, oz > 0 ? z1 + SPOIL_CLEAR + w : z0 - SPOIL_CLEAR];
52735
53280
  const onBuilding = [site.footprint, ...site.buildings].some(([bx0, bz0, bx1, bz1]) => heapAt[2] > bx0 - 0.4 && heapAt[0] < bx1 + 0.4 && heapAt[3] > bz0 - 0.4 && heapAt[1] < bz1 + 0.4);
52736
- if (!onBuilding) for (const piece22 of rectMinus(heapAt, [...rects.map((t) => [t[0] - SPOIL_CLEAR, t[1] - SPOIL_CLEAR, t[2] + SPOIL_CLEAR, t[3] + SPOIL_CLEAR]), ...laid])) {
53281
+ if (!onBuilding) for (const piece22 of rectMinus(heapAt, [...rects.map((t) => [t[0] - SPOIL_CLEAR, t[1] - SPOIL_CLEAR, t[2] + SPOIL_CLEAR, t[3] + SPOIL_CLEAR]), ...laid2])) {
52737
53282
  if (Math.min(piece22[2] - piece22[0], piece22[3] - piece22[1]) < TRENCH.berm.crest * 2) continue;
52738
53283
  addHumps(heap, piece22);
52739
- laid.push(piece22);
53284
+ laid2.push(piece22);
52740
53285
  }
52741
53286
  }
52742
53287
  });
@@ -53578,8 +54123,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53578
54123
  const isBlock = part.assembly === "concrete_block_wall" || part.material === "concrete";
53579
54124
  const coreTh = coreWidthOf(th, unitId);
53580
54125
  for (const r of slivers) chased(batches.mortar, r.a0 + SLIVER_CLEAR, r.y0 + SLIVER_CLEAR, r.a1 - SLIVER_CLEAR, r.y1 - SLIVER_CLEAR, coreTh * 0.98, MORTAR_CHASE_INSET);
53581
- const laid = coursingOf(unitId, getAssembly(part.assembly ?? (isBlock ? "concrete_block_wall" : "brick_wall_plastered"))?.units);
53582
- const coursing = { courseH: laid.courseHeight, unitLen: laid.unitLength, joint: 0.012, courseBase };
54126
+ const laid2 = coursingOf(unitId, getAssembly(part.assembly ?? (isBlock ? "concrete_block_wall" : "brick_wall_plastered"))?.units);
54127
+ const coursing = { courseH: laid2.courseHeight, unitLen: laid2.unitLength, joint: 0.012, courseBase };
53583
54128
  const unit = isBlock ? batches.block : batches.brick;
53584
54129
  for (const r of pieces) {
53585
54130
  unitEnds.length = 0;
@@ -53898,13 +54443,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53898
54443
  const lintels = beamParts.filter((p) => isLintel(p.id)).map(solidOf).map(toCoreWidth).map(inWall).map((l) => fitLintel(l, beams, columns, wallCores.filter((w) => wallLineOf(w.aabb).alongU !== wallLineOf(l.aabb).alongU))).filter((l) => l !== null);
53899
54444
  for (const l of lintels) addStageBox(THREE, masonry, l.aabb[0], l.y0, l.aabb[1], l.aabb[2], l.y1, l.aabb[3], mats.lintel, l.id);
53900
54445
  const batches = createMasonryBatches();
53901
- const laid = [];
54446
+ const laid2 = [];
53902
54447
  const solids = [...foundations, ...columns, ...beams, ...slabs, ...lintels];
53903
54448
  for (const run of wallRuns(wallParts)) {
53904
54449
  const p = run.part;
53905
54450
  const wall = wallLineOf(p.aabb);
53906
54451
  const cuts = [...run.gaps];
53907
- for (const s of [...solids, ...laid]) {
54452
+ for (const s of [...solids, ...laid2]) {
53908
54453
  const top = columns.includes(s) ? s.y1 + 0.3 : s.y1;
53909
54454
  const cut = cutOf(wall, s.aabb, s.y0, top);
53910
54455
  if (cut) cuts.push(cut);
@@ -53917,7 +54462,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
53917
54462
  const coreLine = coreLineOf(wall, p, columns, coreWidth);
53918
54463
  const filled = buildMasonryPanel(batches, p, { cuts, courseBase: (p.floor ?? 0) === 0 ? FOUNDATION_TOP : p.y0, unitId: unit, coreLine, chases: chasesIn(wall, { line: coreLine, width: coreWidth, y0: p.y0, y1: p.y1 }, runs) });
53919
54464
  const half = coreWidth / 2;
53920
- for (const r of filled) laid.push({ id: p.id, aabb: wall.alongU ? [r.a0, coreLine - half, r.a1, coreLine + half] : [coreLine - half, r.a0, coreLine + half, r.a1], y0: r.y0, y1: r.y1, floor: p.floor ?? 0 });
54465
+ for (const r of filled) laid2.push({ id: p.id, aabb: wall.alongU ? [r.a0, coreLine - half, r.a1, coreLine + half] : [coreLine - half, r.a0, coreLine + half, r.a1], y0: r.y0, y1: r.y1, floor: p.floor ?? 0 });
53921
54466
  }
53922
54467
  for (const mesh2 of masonryMeshes(THREE, batches, mats, "masonry")) masonry.add(mesh2);
53923
54468
  return groups;
@@ -54366,7 +54911,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54366
54911
  };
54367
54912
  for (const A of ws) for (const [side, sd] of [[A.w.sides[0], -1], [A.w.sides[1], 1]]) {
54368
54913
  if (!sideOf(side, false).exterior) continue;
54369
- const strip = (k, y1, y2, o0, o1, mat, c, piece22, laid = BASEBOARD_TILES) => {
54914
+ const strip = (k, y1, y2, o0, o1, mat, c, piece22, laid2 = BASEBOARD_TILES) => {
54370
54915
  const ea = junction(A, A.a, sd) > 0 ? A.th / 2 + k : junction(A, A.a, sd) < 0 ? -A.th / 2 : 0, eb = junction(A, A.b, sd) > 0 ? A.th / 2 + k : junction(A, A.b, sd) < 0 ? -A.th / 2 : 0;
54371
54916
  const s0 = A.a - ea, s1 = A.b + eb, f0 = A.L + sd * (A.th / 2 + o0), f1 = A.L + sd * (A.th / 2 + o1), lo = Math.min(f0, f1), hi = Math.max(f0, f1);
54372
54917
  if (s1 - s0 < 1e-3) return;
@@ -54376,14 +54921,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54376
54921
  if (!shared2.ctx.visorScene) (mat === "sidewalk" ? shared2.ctx.paving : shared2.ctx.baseboards)?.push(p);
54377
54922
  }
54378
54923
  };
54379
- const tag = laid === BASEBOARD_TILES ? "baseboard" : "sidewalk";
54924
+ const tag = laid2 === BASEBOARD_TILES ? "baseboard" : "sidewalk";
54380
54925
  const tile = (id, a, b) => {
54381
- cursor.pc = pieceRecord(id, laid.material, null, { floor: 0, mass: Math.round((b - a) * (y2 - y1) * (hi - lo) * laid.density * 100) / 100, tags: [tag] });
54926
+ cursor.pc = pieceRecord(id, laid2.material, null, { floor: 0, mass: Math.round((b - a) * (y2 - y1) * (hi - lo) * laid2.density * 100) / 100, tags: [tag] });
54382
54927
  box4(a, b);
54383
54928
  };
54384
54929
  const runs = [];
54385
54930
  let from = s0;
54386
- if (laid === BASEBOARD_TILES) for (const d of doorsInWall(R.doors, A.w, A.L, A.a, A.b).sort((p, q) => p.at - q.at)) {
54931
+ if (laid2 === BASEBOARD_TILES) for (const d of doorsInWall(R.doors, A.w, A.L, A.a, A.b).sort((p, q) => p.at - q.at)) {
54387
54932
  runs.push([from, d.at - d.width / 2]);
54388
54933
  from = d.at + d.width / 2;
54389
54934
  }
@@ -54394,7 +54939,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
54394
54939
  if (!id) box4(r0, r1);
54395
54940
  else if (shared2.ctx.baseboardBand) tile(id, r0, r1);
54396
54941
  else {
54397
- const n = Math.max(1, Math.round((r1 - r0) / laid.length)), w = (r1 - r0) / n, j = laid.joint / 2;
54942
+ const n = Math.max(1, Math.round((r1 - r0) / laid2.length)), w = (r1 - r0) / n, j = laid2.joint / 2;
54398
54943
  for (let i = 0; i < n; i++) tile(`${id}:${i}`, r0 + i * w + (i > 0 ? j : 0), r0 + (i + 1) * w - (i < n - 1 ? j : 0));
54399
54944
  }
54400
54945
  });
@@ -55509,8 +56054,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55509
56054
  }
55510
56055
  var BLOB_LEANS = [[0.06, 0], [-0.06, 0], [0, 0.06], [0, -0.06], [0.06, 0.06], [-0.06, -0.06], [0.06, -0.06], [-0.06, 0.06], [0.12, 0], [0, 0.12]];
55511
56056
  var BLOB_CROSSING = Math.cos(20 * Math.PI / 180);
55512
- function grazes(laid, x, y, z, r) {
55513
- return laid.some(([x0, y0, z0, r0]) => {
56057
+ function grazes(laid2, x, y, z, r) {
56058
+ return laid2.some(([x0, y0, z0, r0]) => {
55514
56059
  const d = Math.hypot(x - x0, y - y0, z - z0);
55515
56060
  if (d <= Math.abs(r - r0) || d >= r + r0) return false;
55516
56061
  return (r * r + r0 * r0 - d * d) / (2 * r * r0) > BLOB_CROSSING;
@@ -55523,14 +56068,14 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
55523
56068
  const GREENS2 = [4160058, 3107376, 5212738, 5936200, 3832396];
55524
56069
  const FLOWERS = [14700682, 15909424, 16118506, 14168874, 9067216, 15764026];
55525
56070
  function blobs(K2, cx, cy, cz, R, n, green2, rnd, o = {}) {
55526
- const laid = [];
56071
+ const laid2 = [];
55527
56072
  for (let i = 0; i < n; i++) {
55528
56073
  const a = rnd() * 6.283, u = Math.sqrt(rnd()), ph = (rnd() - 0.2) * 1.2, dx = Math.cos(a) * u * R * 0.75, dz = Math.sin(a) * u * R * 0.75, dy = (o.flatten ? 0.35 : 0.55) * R * (Math.sin(ph) * 0.5 + 0.5) * 1.5 - R * 0.15;
55529
56074
  const r = R * (0.34 + rnd() * 0.22) * (1 - u * 0.25), alt = r * 2 * (o.flatten ? 0.75 : 0.95), f = 0.72 + Math.min(1, (dy + R * 0.2) / (R * 1.2)) * 0.32 + rnd() * 0.12;
55530
- const shown2 = shared2.ctx.visorScene || !grazes(laid, cx + dx, cy + dy + r * 0.5, cz + dz, r);
56075
+ const shown2 = shared2.ctx.visorScene || !grazes(laid2, cx + dx, cy + dy + r * 0.5, cz + dz, r);
55531
56076
  if (shared2.ctx.visorScene) K2.e("plant", cx + dx, cy + dy + r * 0.5, cz + dz, r, alt, sh(green2, f));
55532
56077
  else if (shown2) {
55533
- laid.push([cx + dx, cy + dy + r * 0.5, cz + dz, r]);
56078
+ laid2.push([cx + dx, cy + dy + r * 0.5, cz + dz, r]);
55534
56079
  const [wx, , wz] = K2.W(cx + dx, 0, cz + dz), lean = BLOB_LEANS[i % BLOB_LEANS.length];
55535
56080
  K2.A.cylinder({ ...K2.M, x: wx, z: wz, ry: K2.M.ry + i / n * (Math.PI / 5) }, "plant", 0, K2.y0 + cy + dy + r * 0.5, 0, r, alt, sh(green2, f), lean[0], lean[1], "sphere");
55536
56081
  }
@@ -56543,6 +57088,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
56543
57088
  return;
56544
57089
  }
56545
57090
  n.updateMatrix();
57091
+ shared2.ctx.posePiece?.(p.name);
56546
57092
  }
56547
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 };
56548
57094
  function animateInteractive(dt) {
@@ -57106,6 +57652,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
57106
57652
  else g.rotation.y = fo.t * fo.rot;
57107
57653
  g.updateMatrix();
57108
57654
  }
57655
+ shared2.ctx.posePiece?.("door:" + fo.id);
57109
57656
  }
57110
57657
  const defined = { linkDoorLeaves, handleApply, toggleDoor, animateDoors, wallBlocks, doorText, applyLeaf };
57111
57658
  Object.assign(K, defined);
@@ -58357,6 +58904,12 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58357
58904
  K.applyPiece(def);
58358
58905
  }
58359
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;
58360
58913
  root.traverse((o0) => {
58361
58914
  const o = o0;
58362
58915
  if (o.isMesh && o.userData.ranges) {
@@ -58575,7 +59128,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58575
59128
  }
58576
59129
  });
58577
59130
  const walls = new Set((E0.openings ?? []).map((op) => op.wall));
58578
- 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 ?? []);
58579
59132
  }
58580
59133
  };
58581
59134
  return structure;
@@ -58834,6 +59387,13 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58834
59387
  return { x: (lo[0] + hi[0]) / 2, y: (lo[1] + hi[1]) / 2, z: (lo[2] + hi[2]) / 2, sx: hi[0] - lo[0], sy: hi[1] - lo[1], sz: hi[2] - lo[2], colour: unit.colour };
58835
59388
  }
58836
59389
  var axisVector = (axis) => [axis === 0 ? 1 : 0, axis === 1 ? 1 : 0, axis === 2 ? 1 : 0];
59390
+ function isSliver(unit, size) {
59391
+ return Math.min(unit.sx, unit.sy, unit.sz) < 0.5 * Math.min(...size);
59392
+ }
59393
+ function overlapsStone(a, b) {
59394
+ const reach2 = 0.62 * (Math.max(a.sx, a.sy, a.sz) + Math.max(b.sx, b.sy, b.sz));
59395
+ return Math.hypot(a.x - b.x, a.y - b.y, a.z - b.z) < reach2;
59396
+ }
58837
59397
  function unitBoxOf(axes, centre, size, colour) {
58838
59398
  const [x, y, z] = pointOf2(axes, centre[0], centre[1], centre[2]), [sx, sy, sz] = pointOf2(axes, size[0], size[1], size[2]);
58839
59399
  return { x, y, z, sx, sy, sz, colour };
@@ -58844,6 +59404,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
58844
59404
  inner[axes.along + 3] = bounds2[axes.along + 3] - COVER2;
58845
59405
  inner[axes.up + 3] = bounds2[axes.up + 3] - COVER2;
58846
59406
  if (axes.up !== 1) inner[axes.up] = bounds2[axes.up] + COVER2;
59407
+ inner[axes.across] = bounds2[axes.across] + COVER2;
59408
+ inner[axes.across + 3] = bounds2[axes.across + 3] - COVER2;
58847
59409
  return inner;
58848
59410
  }
58849
59411
  function installDestructionBreach(K, _shared) {
@@ -59450,7 +60012,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59450
60012
  const stone = (s, y, d, size, r) => {
59451
60013
  const centre = mask.start + s;
59452
60014
  const unit = clipToBox(unitBoxOf(mask.axes, [centre, y, d], size, tmp.c.setHex(grey).multiplyScalar(0.85 + 0.2 * r(7)).getHex()), bounds2);
59453
- if (unit) out.push(unit);
60015
+ if (unit && !isSliver(unit, size) && !out.some((k) => overlapsStone(k, unit))) out.push(unit);
59454
60016
  };
59455
60017
  for (const { c, part, thick, mid } of gone) {
59456
60018
  const [from, to] = extentOf(part, mask.axes.along), [up0, up1] = extentOf(part, mask.axes.up);
@@ -59764,6 +60326,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
59764
60326
  Object.assign(K, { createBreachView, breachPaintQueue: paintQueue, breachCutQueue: cutQueue });
59765
60327
  }
59766
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];
59767
60330
  function installDestructionWorld(K, shared2) {
59768
60331
  const { THREE, cfg, invalidateShadow, invalidate, rngString, FRAGMENT_GEO, fragmentMaterial, createBreachView } = K;
59769
60332
  function createHouseDestruction(root, house, structure, parts2, colliders, water) {
@@ -60024,8 +60587,31 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
60024
60587
  if (R) R.bind(D.id, house, { parts: rangesOf(), marksOn: marksOn(), onFrame: () => breach.flush() });
60025
60588
  off = D.world.on("*", handleEvent);
60026
60589
  D.active = true;
60590
+ for (const id of shared2.ctx.pieceRest?.keys() ?? []) D.pose(id);
60027
60591
  return D;
60028
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
+ };
60029
60615
  D.deactivate = () => {
60030
60616
  if (off) off();
60031
60617
  off = null;
@@ -61312,6 +61898,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
61312
61898
  markGroups(r, root, parts2);
61313
61899
  const structure = assembleStructure(r0, root), destruction = createHouseDestruction(root, house, structure, parts2, colliders, water);
61314
61900
  h.destruction = destruction;
61901
+ shared2.ctx.posePiece = (id) => destruction.pose(id);
61315
61902
  destruction.breach.setLod(h.lodCurrent);
61316
61903
  if (cs) {
61317
61904
  currentConstructionLevel = applyConstructionLevel(house, opts.constructionLevel ?? CONSTRUCTION_LEVEL_MAX);
@@ -62585,8 +63172,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62585
63172
  var stageOf = (catalog, item, base2, ageDays, storage, powered) => {
62586
63173
  if (item.shelfLife === void 0 || ageDays <= 0) return base2;
62587
63174
  const state = freshness(item, { ageDays: 0, since: 0, storage, storedAt: 0 }, ageDays, { powered, rules: catalog.rules });
62588
- const aged = state === "fresh" ? 0 : state === "stale" ? 1 : 2;
62589
- return Math.max(base2, aged);
63175
+ return Math.max(base2, wearOfFreshness(state));
62590
63176
  };
62591
63177
  var sizeOfModel = (modelSet, id) => {
62592
63178
  const entry2 = modelSet.entry(id);
@@ -62610,11 +63196,11 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62610
63196
  const id = item.seal?.openWith?.find((tool2) => catalog.has(tool2));
62611
63197
  return id === void 0 ? void 0 : catalog.get(id);
62612
63198
  };
62613
- const laid = items.flatMap((item) => {
63199
+ const laid2 = items.flatMap((item) => {
62614
63200
  const opener = openerOf(item);
62615
63201
  return opener ? [item, { id: opener.id, category: item.category, size: opener.size }] : [item];
62616
63202
  });
62617
- const shelves = shelvesLayout(laid, categories);
63203
+ const shelves = shelvesLayout(laid2, categories);
62618
63204
  const showcase = modelSet.list().map((id) => ({ id, size: sizeOfModel(modelSet, id), def: catalog.has(id) ? catalog.get(id) : void 0 }));
62619
63205
  const state = {
62620
63206
  category: CATEGORY_ALL,
@@ -62665,6 +63251,20 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62665
63251
  const contents = itemContents(subject);
62666
63252
  return contents ? { fluid: { container: contents.container, part: SHELL_PART_ID } } : {};
62667
63253
  };
63254
+ const vesselOf = (def) => {
63255
+ const shape = def.model !== void 0 && modelSet.builder(def.model) ? void 0 : shapeOf(def);
63256
+ const vessel = itemVessel({ size: def.size, ...def.container?.capacityLiters === void 0 ? {} : { capacityLiters: def.container.capacityLiters }, ...shape === void 0 ? {} : { shape } });
63257
+ return vessel ? { fluid: { container: vessel.container, uses: ["drink", "sip", "pour", "pour_out"], offset: vessel.offset } } : {};
63258
+ };
63259
+ const washable = options.washable ?? ((def) => def.category !== "food" && (def.tags?.includes("kitchen") ?? false));
63260
+ const washOf = (def) => {
63261
+ if (!washable(def)) return {};
63262
+ const wash = {
63263
+ dirt: (root, dirt) => void (latestTHREE && setItemDirt(latestTHREE, root, dirt)),
63264
+ foam: (root, amount) => void (latestTHREE && setItemFoam(latestTHREE, root, amount))
63265
+ };
63266
+ return { wash };
63267
+ };
62668
63268
  const sealOf = (def, fluid) => {
62669
63269
  const model = def.model;
62670
63270
  if (!def.seal || model === void 0 || !itemOpening(model)) return fluid;
@@ -62686,7 +63286,8 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62686
63286
  };
62687
63287
  const usesOf = (def) => {
62688
63288
  const use = options.itemUse?.(def);
62689
- const liquid = sealOf(def, fluidOf({ ...def.model === void 0 ? {} : { model: def.model }, size: def.size, weight: def.weight }));
63289
+ const contents = fluidOf({ ...def.model === void 0 ? {} : { model: def.model }, size: def.size, weight: def.weight });
63290
+ const liquid = sealOf(def, contents.fluid ? contents : vesselOf(def));
62690
63291
  if (!use) return liquid;
62691
63292
  const edible2 = def.category === "food" || def.category === "drink";
62692
63293
  return { ...liquid, ...liquid.fluid && !edible2 ? { fluid: { ...liquid.fluid, uses: ["pour", "pour_out"] } } : {}, use };
@@ -62697,10 +63298,15 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62697
63298
  movable: true,
62698
63299
  thumbnail: itemThumbnailSvg(drawable(def)),
62699
63300
  ...usesOf(def),
63301
+ ...washOf(def),
63302
+ catalogId: def.id,
63303
+ // what the item spends at each use (detergent, soap): the room takes its doses and shows what is left
63304
+ ...def.consumable ? { consumable: def.consumable } : {},
62700
63305
  // an item with a make-up (a shovel: ash handle riveted to a steel blade) is that spec, not the parts guessed from its meshes
62701
63306
  ...makeupSpecOf(def.model),
62702
63307
  // an item that is also a tool of the arsenal (a shovel) is picked up as that tool
62703
63308
  ...def.weapon ? { weapon: def.weapon } : {},
63309
+ ...def.tools ? { tools: def.tools } : {},
62704
63310
  physical: { weightKg: def.weight, size: def.size, ...def.volume === void 0 ? {} : { litres: def.volume } },
62705
63311
  build: (THREE) => {
62706
63312
  const T2 = THREE;
@@ -62878,7 +63484,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62878
63484
  });
62879
63485
  };
62880
63486
  const rollFinds = () => {
62881
- 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 };
62882
63488
  stack = [...provider.findsFor(query) ?? []];
62883
63489
  showFinds();
62884
63490
  const container = label(`container.${state.container}`, humanize(state.container));
@@ -62918,7 +63524,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
62918
63524
  host?.log(fill(text.craftMissing, { recipe: name, missing: check.missing.join(", ") }), { recipe: recipe.id });
62919
63525
  return { ok: false, missing: check.missing };
62920
63526
  }
62921
- const result = craft(recipe, context, rng2(state.seed));
63527
+ const result = craft(recipe, context, rng(state.seed));
62922
63528
  if (!result.isCrafted) return { ok: false, missing: result.missing };
62923
63529
  if ("item" in result.output) {
62924
63530
  stack = [{ itemId: result.output.item, count: result.output.count }];
@@ -63149,7 +63755,7 @@ uniform mat4 uNodes[${nodes.length}]; attribute float aNodeIndex; attribute vec3
63149
63755
  id: "finds",
63150
63756
  name: names.finds,
63151
63757
  run: ({ expect }) => {
63152
- 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 });
63153
63759
  const a = JSON.stringify(provider.findsFor(query(7)));
63154
63760
  const b = JSON.stringify(provider.findsFor(query(7)));
63155
63761
  expect(a === b, "the same seed gives the same finds");