@adatechnology/game-interactables-household 0.8.7 → 0.9.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.global.js +177 -12
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +113 -11
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
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,73 @@ function powerMeter(c) {
|
|
|
3021
3028
|
}
|
|
3022
3029
|
|
|
3023
3030
|
// src/builders/kitchen.ts
|
|
3031
|
+
import { GOODS_ITEMS } from "@adatechnology/game-items-goods";
|
|
3024
3032
|
var STOVE_WALL_GAP = 0.04;
|
|
3025
3033
|
var STEEL = 11843772;
|
|
3026
3034
|
var CHROME = 13817562;
|
|
3035
|
+
var DISHES = ["plate", "bowl", "cup", "wine_glass", "cutlery", "knife", "pot", "pan"];
|
|
3036
|
+
var DISH_NEEDS = ["detergent", "sponge"];
|
|
3037
|
+
var DIRTY_PLATE = 0.8;
|
|
3038
|
+
var DIRTY_CUP = 0.5;
|
|
3039
|
+
var DIRTY_CUTLERY = 0.6;
|
|
3040
|
+
function goodsSize(id) {
|
|
3041
|
+
const item = GOODS_ITEMS.find((candidate) => candidate.id === id);
|
|
3042
|
+
if (!item) throw new Error(`game-interactables-household: the sinks lay "${id}", which the goods catalogue does not have`);
|
|
3043
|
+
return [item.size[0], item.size[1], item.size[2]];
|
|
3044
|
+
}
|
|
3045
|
+
var laid = (type, data) => ({ stack: { type, qty: 1, ...data ? { data } : {} }, size: goodsSize(type) });
|
|
3046
|
+
var LAY_GAP = 5e-3;
|
|
3047
|
+
function layOnFloor(area, things) {
|
|
3048
|
+
const slots = [];
|
|
3049
|
+
const contents = [];
|
|
3050
|
+
const left = [];
|
|
3051
|
+
let x = area.x0;
|
|
3052
|
+
let z = area.z0;
|
|
3053
|
+
let row = 0;
|
|
3054
|
+
const fits = (w, d, atX, atZ) => atX + w + 2 * LAY_GAP <= area.x1 + 1e-9 && atZ + d + 2 * LAY_GAP <= area.z1 + 1e-9;
|
|
3055
|
+
for (const thing of things) {
|
|
3056
|
+
const [w, h, d] = thing.size;
|
|
3057
|
+
if (!fits(w, d, x, z) && fits(w, d, area.x0, z + row)) [x, z, row] = [area.x0, z + row, 0];
|
|
3058
|
+
if (!fits(w, d, x, z)) {
|
|
3059
|
+
left.push(thing);
|
|
3060
|
+
continue;
|
|
3061
|
+
}
|
|
3062
|
+
const { stack } = thing;
|
|
3063
|
+
slots.push({ pos: [round3(x + LAY_GAP + w / 2), round3(area.y), round3(z + LAY_GAP + d / 2)], max: [w, h, d] });
|
|
3064
|
+
contents.push(stack);
|
|
3065
|
+
x += w + 2 * LAY_GAP;
|
|
3066
|
+
row = Math.max(row, d + 2 * LAY_GAP);
|
|
3067
|
+
}
|
|
3068
|
+
return { slots, contents, left };
|
|
3069
|
+
}
|
|
3070
|
+
var DIRTY_DISHES = [
|
|
3071
|
+
laid("plate", { dirt: DIRTY_PLATE }),
|
|
3072
|
+
laid("cup", { dirt: DIRTY_CUP }),
|
|
3073
|
+
laid("cutlery", { dirt: DIRTY_CUTLERY })
|
|
3074
|
+
];
|
|
3075
|
+
var WASHING_THINGS = [
|
|
3076
|
+
laid("detergent"),
|
|
3077
|
+
laid("sponge"),
|
|
3078
|
+
laid("cup")
|
|
3079
|
+
];
|
|
3080
|
+
function basinContents(c, basin, groups) {
|
|
3081
|
+
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));
|
|
3082
|
+
c.container({ id: "in_basin", from: [...basin.from], to: [...basin.to], slots: laid2.flatMap((l) => l.slots), contents: laid2.flatMap((l) => l.contents) });
|
|
3083
|
+
return laid2.flatMap((l) => l.left);
|
|
3084
|
+
}
|
|
3085
|
+
function washDishes(c, basin, rack) {
|
|
3086
|
+
c.add("uses", {
|
|
3087
|
+
id: "wash_dishes",
|
|
3088
|
+
do: "wash",
|
|
3089
|
+
fixture: "tap",
|
|
3090
|
+
surface: "dishes",
|
|
3091
|
+
clip: "wash_dishes",
|
|
3092
|
+
label: "use.wash_dishes",
|
|
3093
|
+
needs: [...DISH_NEEDS],
|
|
3094
|
+
dose: { need: 0 },
|
|
3095
|
+
dishes: { ids: [...DISHES], basin: basin.id, rack }
|
|
3096
|
+
});
|
|
3097
|
+
}
|
|
3027
3098
|
function tap2(c, x, y, z, id, partId, basin) {
|
|
3028
3099
|
c.cyl("metal", x, y - 2e-3, z, 0.03, 0.022, STEEL, "cyl");
|
|
3029
3100
|
c.cyl("metal", x, y + 0.02, z, 0.017, 0.19, CHROME, "cyl");
|
|
@@ -3045,6 +3116,8 @@ function tap2(c, x, y, z, id, partId, basin) {
|
|
|
3045
3116
|
c.add("fixtures", { id, kind: "tap", outlet, dir: [0, -1, 0], flow: 7, part: partId, tank: "auto" });
|
|
3046
3117
|
c.add("emitters", { id: `${id}_water`, kind: "water", pos: outlet, dir: [0, -1, 0], source: id, size: 0.02, ...streamInto(basin, outlet) });
|
|
3047
3118
|
c.interact(`use_${id}`, [round3(x + 0.05), round3(y + 0.126), round3(z)], { do: "toggle_fixture", fixture: id }, "prompt.tap", 1.3);
|
|
3119
|
+
c.add("uses", { id: `drink_${id}`, do: "drink", from: "vessel", fixture: id, clip: "drink", fillClip: "fill_cup", label: "use.drink_water" });
|
|
3120
|
+
c.add("uses", { id: `drink_hands_${id}`, do: "drink", from: "hands", fixture: id, clip: "drink_cupped_hands", label: "use.drink_from_hands" });
|
|
3048
3121
|
return outlet;
|
|
3049
3122
|
}
|
|
3050
3123
|
function stove(c) {
|
|
@@ -3212,6 +3285,11 @@ function counterWithBasin(c, o) {
|
|
|
3212
3285
|
c.add("basins", basin);
|
|
3213
3286
|
return basin;
|
|
3214
3287
|
}
|
|
3288
|
+
function drainboardSpots(x0, x1, z0, z1, y) {
|
|
3289
|
+
const spots = [];
|
|
3290
|
+
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)]);
|
|
3291
|
+
return spots;
|
|
3292
|
+
}
|
|
3215
3293
|
var KITCHEN_BASIN_DEPTH = 0.2;
|
|
3216
3294
|
var BATHROOM_BASIN_DEPTH = 0.14;
|
|
3217
3295
|
var TAILPIECE_GAP = 2e-3;
|
|
@@ -3240,6 +3318,11 @@ function sinkKitchen(c) {
|
|
|
3240
3318
|
const basin = counterWithBasin(c, { top, bx0, bx1, bz0, bz1, depth: KITCHEN_BASIN_DEPTH, counter: 8157816, steel: true });
|
|
3241
3319
|
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
3320
|
tap2(c, (bx0 + bx1) / 2, top, -hd + 0.07, "tap", "tap_handle", basin);
|
|
3321
|
+
washDishes(c, basin, drainboardSpots(bx1 + 0.06, hw - 0.06, bz0 + 0.04, bz0 + 0.04 + 6 * 0.07 + 0.012, top + 5e-3));
|
|
3322
|
+
const counter = { x0: -hw, x1: round3(bx0 - 0.01), z0: -hd, z1: zf };
|
|
3323
|
+
const onCounter = layOnFloor({ ...counter, y: top }, WASHING_THINGS);
|
|
3324
|
+
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 });
|
|
3325
|
+
basinContents(c, basin, [{ things: [...DIRTY_DISHES, ...onCounter.left] }]);
|
|
3243
3326
|
pipes(c, (bx0 + bx1) / 2, top - KITCHEN_BASIN_DEPTH, (bz0 + bz1) / 2);
|
|
3244
3327
|
const mid = 15e-4;
|
|
3245
3328
|
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" });
|
|
@@ -3303,6 +3386,13 @@ function utilitySink(c) {
|
|
|
3303
3386
|
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
3387
|
c.add("basins", tub);
|
|
3305
3388
|
tap2(c, 0, tubTop + 0.08, -hd + 0.08, "tap", "tap_handle", tub);
|
|
3389
|
+
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)));
|
|
3390
|
+
const rackX = round3(x1 - 0.03 - (x1 - x0) * 0.4);
|
|
3391
|
+
const washboardZ = round3(z1 - 0.2);
|
|
3392
|
+
basinContents(c, tub, [
|
|
3393
|
+
{ things: DIRTY_DISHES.slice(0, 2), area: { x0: tub.from[0], x1: rackX, z0: tub.from[2], z1: washboardZ } },
|
|
3394
|
+
{ things: WASHING_THINGS, area: { x0: round3(x0 + 0.04 + (x1 - x0) * 0.4), x1: tub.to[0], z0: washboardZ, z1: tub.to[2] } }
|
|
3395
|
+
]);
|
|
3306
3396
|
c.add("fixtures", { id: "basin", kind: "utility_sink", outlet: [0, round3(tubTop - 0.1), 0], dir: [0, -1, 0], flow: 12, tank: "auto" });
|
|
3307
3397
|
}
|
|
3308
3398
|
var SHOWER_DOOR = 0.72;
|
|
@@ -3401,8 +3491,16 @@ function toilet(c) {
|
|
|
3401
3491
|
c.b("plain", -0.195, ty + th, -hd - 0, 0.195, ty + th + 0.025, -hd + 0.205, sh);
|
|
3402
3492
|
c.b("plain", -0.185, ty + 0.01, -hd + 0.2, 0.185, ty + 0.03, -hd + 0.215, sh);
|
|
3403
3493
|
const seatY = 0.4;
|
|
3404
|
-
c.
|
|
3405
|
-
|
|
3494
|
+
c.part(
|
|
3495
|
+
"seat_ring",
|
|
3496
|
+
[0, seatY, -0.05],
|
|
3497
|
+
{ kind: "hinge", axis: [1, 0, 0], angle: -1.55 },
|
|
3498
|
+
() => {
|
|
3499
|
+
c.lathe("plain", 0, 0, BOWL_Z, SEAT_PROFILE, 15659248);
|
|
3500
|
+
c.b("plain", -0.165, seatY + 2e-3, -0.07, 0.165, seatY + 0.023, -0.03, 15659248);
|
|
3501
|
+
},
|
|
3502
|
+
{ label: "prompt.toilet_seat", at: [0.16, seatY + 0.02, 0.2] }
|
|
3503
|
+
);
|
|
3406
3504
|
c.part(
|
|
3407
3505
|
"lid",
|
|
3408
3506
|
[0, seatY + 0.025, -0.06],
|
|
@@ -3425,10 +3523,14 @@ function toilet(c) {
|
|
|
3425
3523
|
{ label: "prompt.flush", at: false, noSweep: true }
|
|
3426
3524
|
);
|
|
3427
3525
|
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
|
|
3526
|
+
const drain = { weir: 0.06, trap: 0.05, carries: 0.5, siphon: 3, prime: 0.02, refill: 20 };
|
|
3527
|
+
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
3528
|
c.add("basins", bowl);
|
|
3430
|
-
c.add("
|
|
3431
|
-
|
|
3529
|
+
c.add("seats", { id: "seat", pose: "sit", pos: [0, round3(seatY + 0.025), 0.06], ry: 0, exit: [0, 0, round3(hd + 0.3)] });
|
|
3530
|
+
const parts = { cover: "lid", ring: "seat_ring", seat: "seat" };
|
|
3531
|
+
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)] });
|
|
3532
|
+
c.add("uses", { id: "poo", do: "relieve", basin: "bowl", kind: "feces", label: "use.relieve.feces", seconds: 12, ...parts });
|
|
3533
|
+
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
3534
|
const rim = [0, 0.385, BOWL_Z];
|
|
3433
3535
|
c.add("emitters", { id: "flush_water", kind: "water", pos: rim, dir: [0, -1, 0], source: "flush", size: 0.08, ...streamInto(bowl, rim) });
|
|
3434
3536
|
c.interact("use_flush", [0, ty + th + 0.05, -hd + 0.1], { do: "toggle_fixture", fixture: "flush" }, "prompt.flush");
|
|
@@ -5684,7 +5786,7 @@ var BUILDERS = {
|
|
|
5684
5786
|
camp_table: campTable
|
|
5685
5787
|
};
|
|
5686
5788
|
var DEFS = types_default;
|
|
5687
|
-
var HOUSEHOLD_ITEMS =
|
|
5789
|
+
var HOUSEHOLD_ITEMS = GOODS_ITEMS2.filter((item) => GOODS_PROVENANCE[item.id]?.household !== void 0);
|
|
5688
5790
|
var itemTexts = (locale) => Object.fromEntries(HOUSEHOLD_ITEMS.map((item) => [`item.${item.id}`, GOODS_STRINGS[locale][`item.${item.id}`] ?? item.id]));
|
|
5689
5791
|
var STRINGS = { en: { ...en_default, ...itemTexts("en") }, "pt-BR": { ...pt_BR_default, ...itemTexts("pt-BR") } };
|
|
5690
5792
|
var REGIONS = { br: br_default, us: us_default };
|