@adatechnology/game-interactables-household 0.8.7 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@ var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { en
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
 
5
5
  // src/create.ts
6
- import { GOODS_ITEMS, GOODS_PROVENANCE, GOODS_STRINGS } from "@adatechnology/game-items-goods";
6
+ import { GOODS_ITEMS as GOODS_ITEMS2, GOODS_PROVENANCE, GOODS_STRINGS } from "@adatechnology/game-items-goods";
7
7
 
8
8
  // src/destruction.ts
9
9
  var door = (material, joint = "hinge", piece2 = "door") => ({ material, joint, piece: piece2 });
@@ -39,7 +39,7 @@ var DESTRUCTION = {
39
39
  },
40
40
  toilet: {
41
41
  body: { material: "ceramic", joint: "bolt" },
42
- parts: [["lid", door("plastic", "hinge", "lid")], ["flush_button", { material: "plastic", joint: "clip", piece: "button" }]]
42
+ parts: [["lid", door("plastic", "hinge", "lid")], ["seat_ring", door("plastic", "hinge", "lid")], ["flush_button", { material: "plastic", joint: "clip", piece: "button" }]]
43
43
  },
44
44
  wall_socket: { body: { material: "plastic", joint: "screw" }, parts: [] },
45
45
  wall_switch: { body: { material: "plastic", joint: "screw" }, parts: [["rocker", { material: "plastic", joint: "clip", piece: "rocker" }]] },
@@ -398,7 +398,8 @@ var Ctx = class {
398
398
  return out;
399
399
  }
400
400
  /**
401
- * Container with its inner volume given by two corners. Explicit `item.contents[id]` wins over the loot table.
401
+ * Container with its inner volume given by two corners. Explicit `item.contents[id]` wins over the loot table, slot by slot over the builder's own `contents`
402
+ * (what the piece always comes with: the soap and shampoo on a shower's shelf), which stays in every slot the explicit list leaves empty.
402
403
  * Slots are validated lazily by the tests, not here.
403
404
  */
404
405
  container(o) {
@@ -413,9 +414,9 @@ var Ctx = class {
413
414
  if (o.access) c.access = o.access;
414
415
  if (o.loot) c.loot = o.loot;
415
416
  const given = this.M.contents?.[o.id];
416
- if (given) {
417
+ if (given || o.contents) {
417
418
  c.contents = o.slots.map((_, i) => {
418
- const g = given[i];
419
+ const g = given?.[i] ?? o.contents?.[i];
419
420
  if (!g) return null;
420
421
  const s = { type: g.type, qty: g.qty };
421
422
  if (g.data) s.data = { ...g.data };
@@ -1352,6 +1353,9 @@ var en_default = {
1352
1353
  "prompt.toilet_lid": "Toilet lid",
1353
1354
  "prompt.toilet_lid.open": "Close the lid",
1354
1355
  "prompt.toilet_lid.closed": "Lift the lid",
1356
+ "prompt.toilet_seat": "Toilet seat",
1357
+ "prompt.toilet_seat.open": "Lower the seat",
1358
+ "prompt.toilet_seat.closed": "Lift the seat",
1355
1359
  "prompt.switch": "Light switch",
1356
1360
  "prompt.switch.on": "Switch off",
1357
1361
  "prompt.switch.on.verb": "Switch off",
@@ -1612,6 +1616,9 @@ var pt_BR_default = {
1612
1616
  "prompt.toilet_lid": "Tampa do vaso",
1613
1617
  "prompt.toilet_lid.open": "Fechar a tampa",
1614
1618
  "prompt.toilet_lid.closed": "Levantar a tampa",
1619
+ "prompt.toilet_seat": "Assento do vaso",
1620
+ "prompt.toilet_seat.open": "Abaixar o assento",
1621
+ "prompt.toilet_seat.closed": "Levantar o assento",
1615
1622
  "prompt.switch": "Interruptor",
1616
1623
  "prompt.switch.on": "Desligar a luz",
1617
1624
  "prompt.switch.on.verb": "Desligar",
@@ -3021,9 +3028,80 @@ function powerMeter(c) {
3021
3028
  }
3022
3029
 
3023
3030
  // src/builders/kitchen.ts
3031
+ import { handUseOf } from "@adatechnology/game-items";
3032
+ import { GOODS_ITEMS } from "@adatechnology/game-items-goods";
3024
3033
  var STOVE_WALL_GAP = 0.04;
3025
3034
  var STEEL = 11843772;
3035
+ var HAND_WASH_SOAP_GRAMS = 0.4;
3036
+ function scrubSecondsOf(clip) {
3037
+ const use = handUseOf(clip);
3038
+ if (!use) throw new Error(`No hand use for the washing clip ${clip}`);
3039
+ return use.duration;
3040
+ }
3026
3041
  var CHROME = 13817562;
3042
+ var DISHES = ["plate", "bowl", "cup", "wine_glass", "cutlery", "knife", "pot", "pan"];
3043
+ var DISH_NEEDS = ["detergent", "sponge"];
3044
+ var DIRTY_PLATE = 0.8;
3045
+ var DIRTY_CUP = 0.5;
3046
+ var DIRTY_CUTLERY = 0.6;
3047
+ function goodsSize(id) {
3048
+ const item = GOODS_ITEMS.find((candidate) => candidate.id === id);
3049
+ if (!item) throw new Error(`game-interactables-household: the sinks lay "${id}", which the goods catalogue does not have`);
3050
+ return [item.size[0], item.size[1], item.size[2]];
3051
+ }
3052
+ var laid = (type, data) => ({ stack: { type, qty: 1, ...data ? { data } : {} }, size: goodsSize(type) });
3053
+ var LAY_GAP = 5e-3;
3054
+ function layOnFloor(area, things) {
3055
+ const slots = [];
3056
+ const contents = [];
3057
+ const left = [];
3058
+ let x = area.x0;
3059
+ let z = area.z0;
3060
+ let row = 0;
3061
+ const fits = (w, d, atX, atZ) => atX + w + 2 * LAY_GAP <= area.x1 + 1e-9 && atZ + d + 2 * LAY_GAP <= area.z1 + 1e-9;
3062
+ for (const thing of things) {
3063
+ const [w, h, d] = thing.size;
3064
+ if (!fits(w, d, x, z) && fits(w, d, area.x0, z + row)) [x, z, row] = [area.x0, z + row, 0];
3065
+ if (!fits(w, d, x, z)) {
3066
+ left.push(thing);
3067
+ continue;
3068
+ }
3069
+ const { stack } = thing;
3070
+ slots.push({ pos: [round3(x + LAY_GAP + w / 2), round3(area.y), round3(z + LAY_GAP + d / 2)], max: [w, h, d] });
3071
+ contents.push(stack);
3072
+ x += w + 2 * LAY_GAP;
3073
+ row = Math.max(row, d + 2 * LAY_GAP);
3074
+ }
3075
+ return { slots, contents, left };
3076
+ }
3077
+ var DIRTY_DISHES = [
3078
+ laid("plate", { dirt: DIRTY_PLATE }),
3079
+ laid("cup", { dirt: DIRTY_CUP }),
3080
+ laid("cutlery", { dirt: DIRTY_CUTLERY })
3081
+ ];
3082
+ var WASHING_THINGS = [
3083
+ laid("detergent"),
3084
+ laid("sponge"),
3085
+ laid("cup")
3086
+ ];
3087
+ function basinContents(c, basin, groups) {
3088
+ const laid2 = groups.map(({ things, area }) => layOnFloor({ ...area ?? { x0: basin.from[0], x1: basin.to[0], z0: basin.from[2], z1: basin.to[2] }, y: basin.from[1] }, things));
3089
+ c.container({ id: "in_basin", from: [...basin.from], to: [...basin.to], slots: laid2.flatMap((l) => l.slots), contents: laid2.flatMap((l) => l.contents) });
3090
+ return laid2.flatMap((l) => l.left);
3091
+ }
3092
+ function washDishes(c, basin, rack) {
3093
+ c.add("uses", {
3094
+ id: "wash_dishes",
3095
+ do: "wash",
3096
+ fixture: "tap",
3097
+ surface: "dishes",
3098
+ clip: "wash_dishes",
3099
+ label: "use.wash_dishes",
3100
+ needs: [...DISH_NEEDS],
3101
+ dose: { need: 0 },
3102
+ dishes: { ids: [...DISHES], basin: basin.id, rack }
3103
+ });
3104
+ }
3027
3105
  function tap2(c, x, y, z, id, partId, basin) {
3028
3106
  c.cyl("metal", x, y - 2e-3, z, 0.03, 0.022, STEEL, "cyl");
3029
3107
  c.cyl("metal", x, y + 0.02, z, 0.017, 0.19, CHROME, "cyl");
@@ -3045,6 +3123,8 @@ function tap2(c, x, y, z, id, partId, basin) {
3045
3123
  c.add("fixtures", { id, kind: "tap", outlet, dir: [0, -1, 0], flow: 7, part: partId, tank: "auto" });
3046
3124
  c.add("emitters", { id: `${id}_water`, kind: "water", pos: outlet, dir: [0, -1, 0], source: id, size: 0.02, ...streamInto(basin, outlet) });
3047
3125
  c.interact(`use_${id}`, [round3(x + 0.05), round3(y + 0.126), round3(z)], { do: "toggle_fixture", fixture: id }, "prompt.tap", 1.3);
3126
+ c.add("uses", { id: `drink_${id}`, do: "drink", from: "vessel", fixture: id, clip: "drink", fillClip: "fill_cup", label: "use.drink_water" });
3127
+ c.add("uses", { id: `drink_hands_${id}`, do: "drink", from: "hands", fixture: id, clip: "drink_cupped_hands", label: "use.drink_from_hands" });
3048
3128
  return outlet;
3049
3129
  }
3050
3130
  function stove(c) {
@@ -3212,6 +3292,11 @@ function counterWithBasin(c, o) {
3212
3292
  c.add("basins", basin);
3213
3293
  return basin;
3214
3294
  }
3295
+ function drainboardSpots(x0, x1, z0, z1, y) {
3296
+ const spots = [];
3297
+ for (const k of [0.7, 0.3]) for (const j of [0.2, 0.5, 0.8]) spots.push([round3(x0 + (x1 - x0) * j), round3(y), round3(z0 + (z1 - z0) * k)]);
3298
+ return spots;
3299
+ }
3215
3300
  var KITCHEN_BASIN_DEPTH = 0.2;
3216
3301
  var BATHROOM_BASIN_DEPTH = 0.14;
3217
3302
  var TAILPIECE_GAP = 2e-3;
@@ -3240,6 +3325,11 @@ function sinkKitchen(c) {
3240
3325
  const basin = counterWithBasin(c, { top, bx0, bx1, bz0, bz1, depth: KITCHEN_BASIN_DEPTH, counter: 8157816, steel: true });
3241
3326
  for (let i = 0; i < 7; i++) c.b("metal", bx1 + 0.06, top, bz0 + 0.04 + i * 0.07, hw - 0.06, top + 4e-3, bz0 + 0.052 + i * 0.07, 10133154);
3242
3327
  tap2(c, (bx0 + bx1) / 2, top, -hd + 0.07, "tap", "tap_handle", basin);
3328
+ washDishes(c, basin, drainboardSpots(bx1 + 0.06, hw - 0.06, bz0 + 0.04, bz0 + 0.04 + 6 * 0.07 + 0.012, top + 5e-3));
3329
+ const counter = { x0: -hw, x1: round3(bx0 - 0.01), z0: -hd, z1: zf };
3330
+ const onCounter = layOnFloor({ ...counter, y: top }, WASHING_THINGS);
3331
+ c.container({ id: "counter", from: [counter.x0, top, counter.z0], to: [counter.x1, round3(top + 0.3), counter.z1], slots: onCounter.slots, contents: onCounter.contents });
3332
+ basinContents(c, basin, [{ things: [...DIRTY_DISHES, ...onCounter.left] }]);
3243
3333
  pipes(c, (bx0 + bx1) / 2, top - KITCHEN_BASIN_DEPTH, (bz0 + bz1) / 2);
3244
3334
  const mid = 15e-4;
3245
3335
  hingedDoor(c, { id: "door_1", x0: -hw + 3e-3, x1: -mid, y0: 0.103, y1: top - 0.043, zf, t, side: "left", color: front, inner: lining, handle: "bar_v", handleLen: 0.22, label: "prompt.door" });
@@ -3280,6 +3370,44 @@ function sinkBathroom(c) {
3280
3370
  slots: c.row(sh.ix0 + 0.15, sh.ix1 - 0.01, sh.iy0, (sh.iz0 + sh.iz1) / 2, 1, [0.3, 0.4, 0.3]),
3281
3371
  loot: "under_sink"
3282
3372
  });
3373
+ washbasinCounter(c, top, hw * 0.6);
3374
+ c.add("uses", { id: "wash_hands", do: "wash", fixture: "tap", surface: "hands", clip: "wash_hands", label: "use.wash_hands", needs: ["soap"], dose: { need: 0, amount: HAND_WASH_SOAP_GRAMS }, scrubSeconds: scrubSecondsOf("wash_hands") });
3375
+ c.add("uses", { id: "brush_teeth", do: "wash", fixture: "tap", surface: "mouth", clip: "brush_teeth", label: "use.brush_teeth", needs: ["toothbrush", "toothpaste"], dose: { need: 1 }, scrubSeconds: scrubSecondsOf("brush_teeth") });
3376
+ }
3377
+ function washbasinCounter(c, top, basinEdge) {
3378
+ const { hw, hd } = c;
3379
+ const side = round3((basinEdge + hw) / 2);
3380
+ c.container({
3381
+ id: "counter",
3382
+ from: [-hw, top, -hd],
3383
+ to: [hw, top + 0.12, hd],
3384
+ slots: [
3385
+ { pos: [-side, top, 0], max: [0.1, 0.04, 0.1] },
3386
+ { pos: [round3(side - 0.025), top, 0.02], max: [0.03, 0.03, 0.19], lay: "z" },
3387
+ { pos: [round3(side + 0.028), top, 0.02], max: [0.045, 0.04, 0.19], lay: "z" },
3388
+ { pos: [round3(-basinEdge + 0.01), top, round3(-hd + 0.065)], max: [0.09, 0.1, 0.09] }
3389
+ ],
3390
+ contents: [{ type: "soap", qty: 1 }, { type: "toothbrush", qty: 1 }, { type: "toothpaste", qty: 1 }, { type: "cup", qty: 1 }]
3391
+ });
3392
+ }
3393
+ function showerShelf(c) {
3394
+ const { hw, hd } = c;
3395
+ const y = 0.85;
3396
+ const x0 = -hw + 0.033;
3397
+ const x1 = round3(x0 + 0.3);
3398
+ const z0 = -hd + 0.033;
3399
+ const z1 = round3(z0 + 0.13);
3400
+ c.b("plain", x0, y - 0.025, z0, x1, y, z1, 15133162);
3401
+ c.container({
3402
+ id: "shelf",
3403
+ from: [x0, y, z0],
3404
+ to: [x1, y + 0.25, z1],
3405
+ slots: [
3406
+ { pos: [round3(x0 + 0.07), y, round3((z0 + z1) / 2)], max: [0.1, 0.04, 0.06] },
3407
+ { pos: [round3(x0 + 0.2), y, round3((z0 + z1) / 2)], max: [0.07, 0.21, 0.05] }
3408
+ ],
3409
+ contents: [{ type: "soap", qty: 1 }, { type: "shampoo", qty: 1 }]
3410
+ });
3283
3411
  }
3284
3412
  function utilitySink(c) {
3285
3413
  const { hw, hd } = c;
@@ -3303,6 +3431,13 @@ function utilitySink(c) {
3303
3431
  const tub = { id: "basin", from: [round3(x0 + 0.03), round3(tubTop - 0.276), round3(z0 + 0.03)], to: [round3(x1 - 0.03), tubTop, round3(z1 - 0.03)] };
3304
3432
  c.add("basins", tub);
3305
3433
  tap2(c, 0, tubTop + 0.08, -hd + 0.08, "tap", "tap_handle", tub);
3434
+ washDishes(c, tub, drainboardSpots(round3(x1 - 0.03 - (x1 - x0) * 0.4) + 0.01, round3(x1 - 0.05), round3(z0 + 0.05), round3(z1 - 0.23), round3(tubTop - 0.276 + 5e-3)));
3435
+ const rackX = round3(x1 - 0.03 - (x1 - x0) * 0.4);
3436
+ const washboardZ = round3(z1 - 0.2);
3437
+ basinContents(c, tub, [
3438
+ { things: DIRTY_DISHES.slice(0, 2), area: { x0: tub.from[0], x1: rackX, z0: tub.from[2], z1: washboardZ } },
3439
+ { things: WASHING_THINGS, area: { x0: round3(x0 + 0.04 + (x1 - x0) * 0.4), x1: tub.to[0], z0: washboardZ, z1: tub.to[2] } }
3440
+ ]);
3306
3441
  c.add("fixtures", { id: "basin", kind: "utility_sink", outlet: [0, round3(tubTop - 0.1), 0], dir: [0, -1, 0], flow: 12, tank: "auto" });
3307
3442
  }
3308
3443
  var SHOWER_DOOR = 0.72;
@@ -3338,6 +3473,9 @@ function shower(c) {
3338
3473
  c.add("emitters", { id: "shower_water", kind: "water", pos: outlet, dir: [0, -1, 0.15], source: "shower", size: 0.35 });
3339
3474
  c.add("emitters", { id: "shower_steam", kind: "steam", pos: [0, 1.4, 0], dir: [0, 1, 0], source: "shower", size: 0.8 });
3340
3475
  c.interact("use_shower", [0.25, 1.1, -hd + 0.08], { do: "toggle_fixture", fixture: "shower" }, "prompt.shower", 1.3);
3476
+ showerShelf(c);
3477
+ c.add("uses", { id: "lather_body", do: "wash", fixture: "shower", surface: "body", clip: "lather_body", label: "use.lather_body", needs: ["soap"], dose: { need: 0 }, opensFixture: false, requiresFlowing: true, scrubSeconds: scrubSecondsOf("lather_body") });
3478
+ c.add("uses", { id: "shampoo_hair", do: "wash", fixture: "shower", surface: "hair", clip: "shampoo_hair", label: "use.shampoo_hair", needs: ["shampoo"], dose: { need: 0 }, opensFixture: false, requiresFlowing: true, scrubSeconds: scrubSecondsOf("shampoo_hair") });
3341
3479
  const gl = 12573670;
3342
3480
  const zFront = hd - 0.015;
3343
3481
  const gh = h - 0.1;
@@ -3401,8 +3539,16 @@ function toilet(c) {
3401
3539
  c.b("plain", -0.195, ty + th, -hd - 0, 0.195, ty + th + 0.025, -hd + 0.205, sh);
3402
3540
  c.b("plain", -0.185, ty + 0.01, -hd + 0.2, 0.185, ty + 0.03, -hd + 0.215, sh);
3403
3541
  const seatY = 0.4;
3404
- c.lathe("plain", 0, 0, BOWL_Z, SEAT_PROFILE, 15659248);
3405
- c.b("plain", -0.17, seatY + 2e-3, -0.07, 0.17, seatY + 0.023, -0.03, 15659248);
3542
+ c.part(
3543
+ "seat_ring",
3544
+ [0, seatY, -0.05],
3545
+ { kind: "hinge", axis: [1, 0, 0], angle: -1.55 },
3546
+ () => {
3547
+ c.lathe("plain", 0, 0, BOWL_Z, SEAT_PROFILE, 15659248);
3548
+ c.b("plain", -0.165, seatY + 2e-3, -0.07, 0.165, seatY + 0.023, -0.03, 15659248);
3549
+ },
3550
+ { label: "prompt.toilet_seat", at: [0.16, seatY + 0.02, 0.2] }
3551
+ );
3406
3552
  c.part(
3407
3553
  "lid",
3408
3554
  [0, seatY + 0.025, -0.06],
@@ -3425,10 +3571,14 @@ function toilet(c) {
3425
3571
  { label: "prompt.flush", at: false, noSweep: true }
3426
3572
  );
3427
3573
  c.add("fixtures", { id: "flush", kind: "flush", outlet: [0, 0.36, BOWL_Z], dir: [0, -1, 0], volume: 6, part: "flush_button", tank: "auto", cleans: "bowl" });
3428
- const bowl = { id: "bowl", from: [-0.12, 0.26, BOWL_Z - 0.12], to: [0.12, 0.36, BOWL_Z + 0.12], shape: "round", soils: true };
3574
+ const drain = { weir: 0.06, trap: 0.05, carries: 0.5, siphon: 3, prime: 0.02, refill: 20 };
3575
+ const bowl = { id: "bowl", from: [-0.12, 0.26, BOWL_Z - 0.12], to: [0.12, 0.36, BOWL_Z + 0.12], shape: "round", soils: true, drain };
3429
3576
  c.add("basins", bowl);
3430
- c.add("uses", { id: "pee", do: "relieve", basin: "bowl", kind: "urine", label: "use.relieve.urine" });
3431
- c.add("uses", { id: "poo", do: "relieve", basin: "bowl", kind: "feces", label: "use.relieve.feces" });
3577
+ c.add("seats", { id: "seat", pose: "sit", pos: [0, round3(seatY + 0.025), 0.06], ry: 0, exit: [0, 0, round3(hd + 0.3)] });
3578
+ const parts = { cover: "lid", ring: "seat_ring", seat: "seat" };
3579
+ c.add("uses", { id: "pee", do: "relieve", basin: "bowl", kind: "urine", label: "use.relieve.urine", seconds: 8, ...parts, stand: [0, 0, round3(BOWL_Z + 0.5)] });
3580
+ c.add("uses", { id: "poo", do: "relieve", basin: "bowl", kind: "feces", label: "use.relieve.feces", seconds: 12, ...parts });
3581
+ c.add("uses", { id: "plunge", do: "plunge", basin: "bowl", label: "use.plunge", tool: "plunger", seconds: 4, stand: [0, 0, round3(BOWL_Z + 0.55)] });
3432
3582
  const rim = [0, 0.385, BOWL_Z];
3433
3583
  c.add("emitters", { id: "flush_water", kind: "water", pos: rim, dir: [0, -1, 0], source: "flush", size: 0.08, ...streamInto(bowl, rim) });
3434
3584
  c.interact("use_flush", [0, ty + th + 0.05, -hd + 0.1], { do: "toggle_fixture", fixture: "flush" }, "prompt.flush");
@@ -5684,7 +5834,7 @@ var BUILDERS = {
5684
5834
  camp_table: campTable
5685
5835
  };
5686
5836
  var DEFS = types_default;
5687
- var HOUSEHOLD_ITEMS = GOODS_ITEMS.filter((item) => GOODS_PROVENANCE[item.id]?.household !== void 0);
5837
+ var HOUSEHOLD_ITEMS = GOODS_ITEMS2.filter((item) => GOODS_PROVENANCE[item.id]?.household !== void 0);
5688
5838
  var itemTexts = (locale) => Object.fromEntries(HOUSEHOLD_ITEMS.map((item) => [`item.${item.id}`, GOODS_STRINGS[locale][`item.${item.id}`] ?? item.id]));
5689
5839
  var STRINGS = { en: { ...en_default, ...itemTexts("en") }, "pt-BR": { ...pt_BR_default, ...itemTexts("pt-BR") } };
5690
5840
  var REGIONS = { br: br_default, us: us_default };