@adatechnology/game-interactables 0.12.0 → 0.13.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/README.md +17 -0
- package/dist/index.d.ts +248 -11
- package/dist/index.global.js +732 -41
- package/dist/index.global.js.map +1 -1
- package/dist/index.js +640 -41
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.global.js
CHANGED
|
@@ -21,14 +21,18 @@ var GameInteractables = (() => {
|
|
|
21
21
|
// src/index.ts
|
|
22
22
|
var index_exports = {};
|
|
23
23
|
__export(index_exports, {
|
|
24
|
+
CLOGGED: () => CLOGGED,
|
|
24
25
|
COLLAR_REACH: () => COLLAR_REACH,
|
|
25
26
|
CONTROLLED_OBJECT: () => CONTROLLED_OBJECT,
|
|
27
|
+
DRINK_HANDS_LITRES: () => DRINK_HANDS_LITRES,
|
|
28
|
+
DRINK_HANDS_LPS: () => DRINK_HANDS_LPS,
|
|
26
29
|
DRINK_LITRES: () => DRINK_LITRES,
|
|
27
30
|
DRINK_LPS: () => DRINK_LPS,
|
|
28
31
|
DRY_SECONDS: () => DRY_SECONDS,
|
|
29
32
|
END_GAP: () => END_GAP,
|
|
30
33
|
FILL_SHARE: () => FILL_SHARE,
|
|
31
34
|
FLOW_DEFAULTS: () => FLOW_DEFAULTS,
|
|
35
|
+
FLUSH_POUR_SECONDS: () => FLUSH_POUR_SECONDS,
|
|
32
36
|
FLUSH_RUN_SECONDS: () => FLUSH_RUN_SECONDS,
|
|
33
37
|
GESTURE_OF_ACTION: () => GESTURE_OF_ACTION,
|
|
34
38
|
GESTURE_OF_USE: () => GESTURE_OF_USE,
|
|
@@ -38,10 +42,13 @@ var GameInteractables = (() => {
|
|
|
38
42
|
buildChain: () => buildChain,
|
|
39
43
|
castWithMember: () => castWithMember,
|
|
40
44
|
chainPoints: () => chainPoints,
|
|
45
|
+
createBasinDrain: () => createBasinDrain,
|
|
46
|
+
createDrainUses: () => createDrainUses,
|
|
41
47
|
createEnginePartPhysics: () => createEnginePartPhysics,
|
|
42
48
|
createFixtureEmitters: () => createFixtureEmitters,
|
|
43
49
|
createObjectControls: () => createObjectControls,
|
|
44
50
|
createSinkRoutines: () => createSinkRoutines,
|
|
51
|
+
createUseBody: () => createUseBody,
|
|
45
52
|
createWorld: () => createWorld,
|
|
46
53
|
devicePointOf: () => devicePointOf,
|
|
47
54
|
dirtyDishes: () => dirtyDishes,
|
|
@@ -74,6 +81,199 @@ var GameInteractables = (() => {
|
|
|
74
81
|
wrapsMember: () => wrapsMember
|
|
75
82
|
});
|
|
76
83
|
|
|
84
|
+
// src/basin-drain.ts
|
|
85
|
+
var FLUSH_POUR_SECONDS = 3;
|
|
86
|
+
var CLOGGED = 0.5;
|
|
87
|
+
var REFILL_RATE = 0.12;
|
|
88
|
+
var BREAK_DEPTH = 0.035;
|
|
89
|
+
var WEIR_SHARE = 0.25;
|
|
90
|
+
var SEEP = 0.04;
|
|
91
|
+
var TURN_PER_LITRE = 2.4;
|
|
92
|
+
var TRAP_LITRES = 3.5;
|
|
93
|
+
var PLUNGE_PACKED = 0.34;
|
|
94
|
+
var PLUNGE_LODGED = 0.2;
|
|
95
|
+
var PLUNGER_WATER = 0.03;
|
|
96
|
+
var SOFT_SQUEEZE = 1.6;
|
|
97
|
+
var SWIRL_SETTLED = 1e-4;
|
|
98
|
+
var clamp01 = (v) => Math.min(1, Math.max(0, v));
|
|
99
|
+
var passingSize = (size) => [...size].sort((a, b) => b - a)[1] ?? 0;
|
|
100
|
+
function createBasinDrain(basin, drain) {
|
|
101
|
+
const width = basin.to[0] - basin.from[0];
|
|
102
|
+
const deep = basin.to[2] - basin.from[2];
|
|
103
|
+
const radius = Math.min(width, deep) / 2;
|
|
104
|
+
const area = basin.shape === "round" ? Math.PI * radius * radius : width * deep;
|
|
105
|
+
const litresAt = (level) => area * level * 1e3;
|
|
106
|
+
const levelOf = (litres) => litres / (area * 1e3);
|
|
107
|
+
const capacity = litresAt(basin.to[1] - basin.from[1]);
|
|
108
|
+
const still = litresAt(drain.weir);
|
|
109
|
+
const water = { litres: still, phase: "still", swirl: 0, turned: 0, clog: 0, cause: "none", cistern: 1, pouring: 0, pourRate: 0, carried: 0 };
|
|
110
|
+
let serial = 0;
|
|
111
|
+
let contents = [];
|
|
112
|
+
let shown = null;
|
|
113
|
+
const step = { spilled: 0, swallowed: [] };
|
|
114
|
+
const open = () => Math.max(SEEP, 1 - water.clog);
|
|
115
|
+
const lodge = (c, packed) => {
|
|
116
|
+
c.stage = "lodged";
|
|
117
|
+
c.depth = 1;
|
|
118
|
+
c.radius = 0;
|
|
119
|
+
water.clog = packed ? Math.max(water.clog, Math.min(0.95, water.clog + 0.55 + 0.3 * (c.kg / drain.carries))) : 0.97;
|
|
120
|
+
water.cause = water.cause === "object" || !packed ? "object" : "packed";
|
|
121
|
+
};
|
|
122
|
+
const reachTrap = (c, swallowed) => {
|
|
123
|
+
const hard = c.kind === "object";
|
|
124
|
+
if (passingSize(c.size) > drain.trap * (hard ? 1 : SOFT_SQUEEZE) || !hard && water.carried + c.kg > drain.carries) {
|
|
125
|
+
lodge(c, !hard);
|
|
126
|
+
return false;
|
|
127
|
+
}
|
|
128
|
+
if (!hard) water.carried += c.kg;
|
|
129
|
+
c.stage = "gone";
|
|
130
|
+
if (c.objectId) swallowed.push(c.objectId);
|
|
131
|
+
return true;
|
|
132
|
+
};
|
|
133
|
+
const stepContents = (moved, pulled, swallowed) => {
|
|
134
|
+
water.turned += moved * TURN_PER_LITRE;
|
|
135
|
+
const takesUrine = water.phase === "siphon" && water.swirl > 0.3;
|
|
136
|
+
let leaving = false;
|
|
137
|
+
for (const c of contents) {
|
|
138
|
+
if (c.kind === "urine" && takesUrine) leaving = true;
|
|
139
|
+
if (c.stage === "gone" || c.stage === "lodged") continue;
|
|
140
|
+
c.angle = c.start + water.turned;
|
|
141
|
+
if (water.phase !== "siphon" || c.kind === "urine") continue;
|
|
142
|
+
c.stage = "going";
|
|
143
|
+
c.travel = clamp01(c.travel + pulled / TRAP_LITRES);
|
|
144
|
+
c.depth = Math.max(c.depth, c.travel);
|
|
145
|
+
c.radius = c.startRadius * (1 - c.travel);
|
|
146
|
+
if (c.travel >= 1 && reachTrap(c, swallowed)) leaving = true;
|
|
147
|
+
}
|
|
148
|
+
if (leaving) contents = contents.filter((c) => c.stage !== "gone" && !(c.kind === "urine" && takesUrine));
|
|
149
|
+
};
|
|
150
|
+
const outflow = (dt) => {
|
|
151
|
+
const level = levelOf(water.litres);
|
|
152
|
+
if (water.phase === "siphon") return drain.siphon * open() * dt * Math.sqrt(clamp01(level / Math.max(1e-3, drain.weir)));
|
|
153
|
+
const head = level - drain.weir;
|
|
154
|
+
if (head <= 0) return 0;
|
|
155
|
+
return drain.siphon * WEIR_SHARE * open() * dt * Math.sqrt(clamp01(head / drain.prime));
|
|
156
|
+
};
|
|
157
|
+
const stepPhase = () => {
|
|
158
|
+
const head = levelOf(water.litres) - drain.weir;
|
|
159
|
+
if (water.phase !== "siphon" && head >= drain.prime && open() > CLOGGED) {
|
|
160
|
+
water.phase = "siphon";
|
|
161
|
+
water.carried = 0;
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
if (water.phase === "siphon" && (head <= -BREAK_DEPTH || open() <= CLOGGED)) water.phase = "refill";
|
|
165
|
+
if (water.phase === "refill" && water.litres >= still - 1e-6 && water.pouring <= 0) water.phase = "still";
|
|
166
|
+
if (water.phase === "still" && water.pouring > 0) water.phase = "filling";
|
|
167
|
+
if (water.phase === "filling" && water.pouring <= 0 && head <= 1e-4) water.phase = "still";
|
|
168
|
+
};
|
|
169
|
+
const stepInflow = (dt) => {
|
|
170
|
+
const poured = water.pouring > 0 ? water.pourRate * Math.min(dt, water.pouring) : 0;
|
|
171
|
+
water.pouring = Math.max(0, water.pouring - dt);
|
|
172
|
+
water.litres += poured;
|
|
173
|
+
if ((water.phase === "refill" || water.phase === "still") && water.litres < still && water.clog < CLOGGED) water.litres = Math.min(still, water.litres + REFILL_RATE * dt);
|
|
174
|
+
return poured;
|
|
175
|
+
};
|
|
176
|
+
return {
|
|
177
|
+
flush(asked) {
|
|
178
|
+
shown = null;
|
|
179
|
+
const litresIn = asked * water.cistern;
|
|
180
|
+
water.cistern = 0;
|
|
181
|
+
if (litresIn <= 0) return 0;
|
|
182
|
+
water.pouring = FLUSH_POUR_SECONDS;
|
|
183
|
+
water.pourRate = litresIn / FLUSH_POUR_SECONDS;
|
|
184
|
+
if (water.phase === "still") water.phase = "filling";
|
|
185
|
+
return litresIn;
|
|
186
|
+
},
|
|
187
|
+
add(content) {
|
|
188
|
+
shown = null;
|
|
189
|
+
water.litres += content.litres ?? 0;
|
|
190
|
+
const k = serial++;
|
|
191
|
+
const start = k * 2.39996;
|
|
192
|
+
const startRadius = 0.25 + k * 0.37 % 0.45;
|
|
193
|
+
contents.push({
|
|
194
|
+
start,
|
|
195
|
+
startRadius,
|
|
196
|
+
travel: 0,
|
|
197
|
+
id: `c${k}`,
|
|
198
|
+
kind: content.kind,
|
|
199
|
+
kg: content.kg,
|
|
200
|
+
size: content.size,
|
|
201
|
+
...content.objectId ? { objectId: content.objectId } : {},
|
|
202
|
+
stage: "afloat",
|
|
203
|
+
angle: start + water.turned,
|
|
204
|
+
radius: startRadius,
|
|
205
|
+
depth: content.kind === "object" ? 0.5 : 0
|
|
206
|
+
});
|
|
207
|
+
},
|
|
208
|
+
plunge() {
|
|
209
|
+
shown = null;
|
|
210
|
+
if (levelOf(water.litres) < PLUNGER_WATER) return false;
|
|
211
|
+
if (water.clog <= 0) return true;
|
|
212
|
+
const lodged = contents.filter((c) => c.stage === "lodged");
|
|
213
|
+
const hard = lodged.some((c) => c.kind === "object");
|
|
214
|
+
water.clog = Math.max(0, water.clog - (hard ? PLUNGE_LODGED : PLUNGE_PACKED));
|
|
215
|
+
if (water.clog > CLOGGED * 0.4) return true;
|
|
216
|
+
water.clog = 0;
|
|
217
|
+
water.cause = "none";
|
|
218
|
+
for (const c of lodged) {
|
|
219
|
+
if (c.kind === "object") Object.assign(c, { stage: "afloat", depth: 0.6, radius: 0.3, startRadius: 0.3, travel: 0 });
|
|
220
|
+
else c.stage = "gone";
|
|
221
|
+
}
|
|
222
|
+
contents = contents.filter((c) => c.stage !== "gone");
|
|
223
|
+
return true;
|
|
224
|
+
},
|
|
225
|
+
update(dt) {
|
|
226
|
+
step.spilled = 0;
|
|
227
|
+
step.swallowed.length = 0;
|
|
228
|
+
if (dt <= 0) return step;
|
|
229
|
+
const { litres, swirl, cistern, phase, clog } = water;
|
|
230
|
+
const count = contents.length;
|
|
231
|
+
water.cistern = clamp01(water.cistern + dt / drain.refill);
|
|
232
|
+
const poured = stepInflow(dt);
|
|
233
|
+
const out = Math.min(water.litres, outflow(dt));
|
|
234
|
+
water.litres -= out;
|
|
235
|
+
stepPhase();
|
|
236
|
+
const pull = water.phase === "siphon" ? clamp01(out / (drain.siphon * dt)) : 0;
|
|
237
|
+
const jets = poured > 0 ? 0.35 : 0;
|
|
238
|
+
const swirlTo = Math.max(pull, jets);
|
|
239
|
+
water.swirl = Math.abs(swirlTo - water.swirl) < SWIRL_SETTLED ? swirlTo : water.swirl + (swirlTo - water.swirl) * clamp01(dt * 6);
|
|
240
|
+
const moved = poured + out;
|
|
241
|
+
stepContents(moved, water.phase === "siphon" ? out : 0, step.swallowed);
|
|
242
|
+
step.spilled = Math.max(0, water.litres - capacity);
|
|
243
|
+
water.litres -= step.spilled;
|
|
244
|
+
const changed = moved > 0 || water.litres !== litres || water.swirl !== swirl || water.cistern !== cistern || water.phase !== phase || water.clog !== clog || contents.length !== count;
|
|
245
|
+
if (changed) shown = null;
|
|
246
|
+
return step;
|
|
247
|
+
},
|
|
248
|
+
state() {
|
|
249
|
+
shown ?? (shown = {
|
|
250
|
+
litres: water.litres,
|
|
251
|
+
level: levelOf(water.litres),
|
|
252
|
+
phase: water.phase,
|
|
253
|
+
swirl: water.swirl,
|
|
254
|
+
turned: water.turned,
|
|
255
|
+
clog: water.clog,
|
|
256
|
+
cause: water.cause,
|
|
257
|
+
cistern: water.cistern,
|
|
258
|
+
contents: contents.map(({ start: _start, startRadius: _startRadius, travel: _travel, ...c }) => c)
|
|
259
|
+
});
|
|
260
|
+
return shown;
|
|
261
|
+
},
|
|
262
|
+
litres: () => water.litres,
|
|
263
|
+
level: () => levelOf(water.litres),
|
|
264
|
+
clog: () => water.clog,
|
|
265
|
+
cause: () => water.cause,
|
|
266
|
+
dirty: () => contents.some((c) => c.kind !== "object"),
|
|
267
|
+
save: () => ({ water: { ...water }, serial, contents: contents.map((c) => ({ ...c })) }),
|
|
268
|
+
restore(saved) {
|
|
269
|
+
shown = null;
|
|
270
|
+
Object.assign(water, saved.water);
|
|
271
|
+
serial = saved.serial;
|
|
272
|
+
contents = saved.contents.map((c) => ({ ...c }));
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
}
|
|
276
|
+
|
|
77
277
|
// src/gestures.ts
|
|
78
278
|
var GESTURE_OF_ACTION = {
|
|
79
279
|
toggle_part: null,
|
|
@@ -97,6 +297,7 @@ var GameInteractables = (() => {
|
|
|
97
297
|
empty: "tip",
|
|
98
298
|
fill: "pour",
|
|
99
299
|
relieve: null,
|
|
300
|
+
plunge: null,
|
|
100
301
|
wash: null,
|
|
101
302
|
drink: null
|
|
102
303
|
};
|
|
@@ -325,7 +526,17 @@ var GameInteractables = (() => {
|
|
|
325
526
|
done_relieve_feces: "You pooed in {name}",
|
|
326
527
|
done_clean: "{name} flushed clean",
|
|
327
528
|
"use.wash_dishes": "Wash the dishes",
|
|
328
|
-
"use.drink_water": "Drink water",
|
|
529
|
+
"use.drink_water": "Drink water from the glass",
|
|
530
|
+
"use.drink_from_hands": "Drink water from your hands",
|
|
531
|
+
needs_in_hand: "Pick up {item} first",
|
|
532
|
+
needs_vessel: "You need a glass",
|
|
533
|
+
vessel_not_empty: "Empty {item} first",
|
|
534
|
+
hands_busy: "Your hands are busy",
|
|
535
|
+
no_animation: "Cannot be done here: the body has no movement for it",
|
|
536
|
+
needs_free_hand: "You need your hands free",
|
|
537
|
+
not_drunk: "No water was drunk",
|
|
538
|
+
drink_from_vessel: "You have a glass in your hand: drink from it",
|
|
539
|
+
done_drink_hands: "You drank {litres} l of water from your hands",
|
|
329
540
|
busy: "Already in use",
|
|
330
541
|
needs_running: "Turn the water on first",
|
|
331
542
|
needs_item: "You need {need}",
|
|
@@ -335,7 +546,21 @@ var GameInteractables = (() => {
|
|
|
335
546
|
started_drink: "{label}\u2026",
|
|
336
547
|
done_wash: "Washed and rinsed",
|
|
337
548
|
done_wash_dishes: "Dishes washed: {n} on the rack",
|
|
338
|
-
done_drink: "You drank {litres} l of water"
|
|
549
|
+
done_drink: "You drank {litres} l of water",
|
|
550
|
+
"use.plunge": "Unclog {name} with the plunger",
|
|
551
|
+
needs_plunger: "Hold a plunger",
|
|
552
|
+
plunge_no_water: "No water over the trap for the plunger",
|
|
553
|
+
done_plunge: "You work the plunger in {name}",
|
|
554
|
+
plunge_cleared: "{name} unclogged: the water goes down",
|
|
555
|
+
plunge_object: "{name} unclogged: something came back up the trap",
|
|
556
|
+
plunge_still: "{name} is still clogged",
|
|
557
|
+
clogged: "{name} is clogged",
|
|
558
|
+
overflow: "{name} is overflowing",
|
|
559
|
+
needs_body: "There is no body here to use {name}",
|
|
560
|
+
host_lacks: "This place cannot run {name} (it lacks {capability})",
|
|
561
|
+
body_no_seat: "{name} has no seat to sit on",
|
|
562
|
+
body_object_gone: "{name} is not here",
|
|
563
|
+
body_busy: "You are busy with something else"
|
|
339
564
|
},
|
|
340
565
|
"pt-BR": {
|
|
341
566
|
"prompt.open": "Abrir {name}",
|
|
@@ -390,7 +615,17 @@ var GameInteractables = (() => {
|
|
|
390
615
|
done_relieve_feces: "Voc\xEA fez coc\xF4 em {name}",
|
|
391
616
|
done_clean: "Descarga dada: {name} limpo",
|
|
392
617
|
"use.wash_dishes": "Lavar a lou\xE7a",
|
|
393
|
-
"use.drink_water": "Beber \xE1gua",
|
|
618
|
+
"use.drink_water": "Beber \xE1gua no copo",
|
|
619
|
+
"use.drink_from_hands": "Beber \xE1gua com a m\xE3o",
|
|
620
|
+
needs_in_hand: "Pegue {item} antes",
|
|
621
|
+
needs_vessel: "Precisa de um copo",
|
|
622
|
+
vessel_not_empty: "Esvazie {item} antes",
|
|
623
|
+
hands_busy: "As m\xE3os est\xE3o ocupadas",
|
|
624
|
+
no_animation: "N\xE3o d\xE1 para fazer isso aqui: o corpo n\xE3o tem o movimento",
|
|
625
|
+
needs_free_hand: "Precisa das m\xE3os livres",
|
|
626
|
+
not_drunk: "Nenhuma \xE1gua foi bebida",
|
|
627
|
+
drink_from_vessel: "Voc\xEA est\xE1 com um copo na m\xE3o: beba nele",
|
|
628
|
+
done_drink_hands: "Voc\xEA bebeu {litres} l de \xE1gua com a m\xE3o",
|
|
394
629
|
busy: "J\xE1 est\xE1 em uso",
|
|
395
630
|
needs_running: "Abra a \xE1gua primeiro",
|
|
396
631
|
needs_item: "Precisa de {need}",
|
|
@@ -400,7 +635,21 @@ var GameInteractables = (() => {
|
|
|
400
635
|
started_drink: "{label}\u2026",
|
|
401
636
|
done_wash: "Lavado e enxaguado",
|
|
402
637
|
done_wash_dishes: "Lou\xE7a lavada: {n} no escorredor",
|
|
403
|
-
done_drink: "Voc\xEA bebeu {litres} l de \xE1gua"
|
|
638
|
+
done_drink: "Voc\xEA bebeu {litres} l de \xE1gua",
|
|
639
|
+
"use.plunge": "Desentupir {name} com o desentupidor",
|
|
640
|
+
needs_plunger: "Segure um desentupidor",
|
|
641
|
+
plunge_no_water: "Sem \xE1gua sobre o sif\xE3o para o desentupidor",
|
|
642
|
+
done_plunge: "Voc\xEA bombeia o desentupidor em {name}",
|
|
643
|
+
plunge_cleared: "{name} desentupido: a \xE1gua desce",
|
|
644
|
+
plunge_object: "{name} desentupido: uma coisa voltou do sif\xE3o",
|
|
645
|
+
plunge_still: "{name} ainda est\xE1 entupido",
|
|
646
|
+
clogged: "{name} entupiu",
|
|
647
|
+
overflow: "{name} est\xE1 transbordando",
|
|
648
|
+
needs_body: "N\xE3o h\xE1 corpo aqui para usar {name}",
|
|
649
|
+
host_lacks: "Este lugar n\xE3o sabe usar {name} (falta {capability})",
|
|
650
|
+
body_no_seat: "{name} n\xE3o tem assento para sentar",
|
|
651
|
+
body_object_gone: "{name} n\xE3o est\xE1 aqui",
|
|
652
|
+
body_busy: "Voc\xEA est\xE1 ocupado com outra coisa"
|
|
404
653
|
}
|
|
405
654
|
};
|
|
406
655
|
function pickLocale(locale) {
|
|
@@ -1807,6 +2056,7 @@ var GameInteractables = (() => {
|
|
|
1807
2056
|
burners: /* @__PURE__ */ new Map(),
|
|
1808
2057
|
tanks: /* @__PURE__ */ new Map(),
|
|
1809
2058
|
fixtures: /* @__PURE__ */ new Map(),
|
|
2059
|
+
drains: /* @__PURE__ */ new Map(),
|
|
1810
2060
|
soft: /* @__PURE__ */ new Map(),
|
|
1811
2061
|
hp: /* @__PURE__ */ new Map(),
|
|
1812
2062
|
interactions: spec.interactions ?? deriveInteractions(spec)
|
|
@@ -1839,6 +2089,7 @@ var GameInteractables = (() => {
|
|
|
1839
2089
|
for (const b of spec.burners ?? []) o.burners.set(b.id, { spec: b, on: false, lit: false, smoke: 0 });
|
|
1840
2090
|
for (const tk of spec.tanks ?? []) o.tanks.set(tk.id, { spec: tk, level: clamp(tk.level ?? tk.capacity, 0, tk.capacity) });
|
|
1841
2091
|
for (const f of spec.fixtures ?? []) o.fixtures.set(f.id, { spec: f, on: false, flowing: false, frac: 0, timer: 0 });
|
|
2092
|
+
for (const b of spec.basins ?? []) if (b.drain) o.drains.set(b.id, createBasinDrain(b, b.drain));
|
|
1842
2093
|
let n = 0;
|
|
1843
2094
|
for (const s of spec.soft ?? []) {
|
|
1844
2095
|
const driver = options.partPhysics?.attachSoft?.(id, s, pub.transform);
|
|
@@ -1871,7 +2122,8 @@ var GameInteractables = (() => {
|
|
|
1871
2122
|
burners: Object.fromEntries([...o.burners].map(([k, b]) => [k, { on: b.on, lit: b.lit }])),
|
|
1872
2123
|
tanks: Object.fromEntries([...o.tanks].map(([k, tk]) => [k, tk.level])),
|
|
1873
2124
|
fixtures: Object.fromEntries([...o.fixtures].map(([k, f]) => [k, f.on])),
|
|
1874
|
-
hp: Object.fromEntries([...o.hp].map(([k, h]) => [k, h.hp]))
|
|
2125
|
+
hp: Object.fromEntries([...o.hp].map(([k, h]) => [k, h.hp])),
|
|
2126
|
+
drains: Object.fromEntries([...o.drains].map(([k, d]) => [k, d.save()]))
|
|
1875
2127
|
};
|
|
1876
2128
|
}
|
|
1877
2129
|
return {
|
|
@@ -1937,6 +2189,7 @@ var GameInteractables = (() => {
|
|
|
1937
2189
|
const h = o.hp.get(k);
|
|
1938
2190
|
if (h) h.hp = v;
|
|
1939
2191
|
}
|
|
2192
|
+
for (const [k, v] of Object.entries(st.drains ?? {})) o.drains.get(k)?.restore(v);
|
|
1940
2193
|
}
|
|
1941
2194
|
grid = state.grid;
|
|
1942
2195
|
main = state.main ?? true;
|
|
@@ -2061,6 +2314,7 @@ var GameInteractables = (() => {
|
|
|
2061
2314
|
locale = l;
|
|
2062
2315
|
table = resolveStrings(locale, options.strings);
|
|
2063
2316
|
},
|
|
2317
|
+
drain: (objectId, basin) => objs.get(objectId)?.drains.get(basin),
|
|
2064
2318
|
serialize,
|
|
2065
2319
|
load
|
|
2066
2320
|
};
|
|
@@ -2585,6 +2839,270 @@ var GameInteractables = (() => {
|
|
|
2585
2839
|
return wrapsMember(member, other) || endsMember(member, other);
|
|
2586
2840
|
}
|
|
2587
2841
|
|
|
2842
|
+
// ../game-contracts/dist/index.js
|
|
2843
|
+
var DEFAULT_BLAST_IMPULSE = { bodyArea: 0.7, lift: 0.15, minSpeed: 0.3, tntPerJoule: 0.24 / 2e5 };
|
|
2844
|
+
var DEFAULT_COST_ALLOCATION_BYTES = 1024 * 1024;
|
|
2845
|
+
var DEFERRED_QUEUE_ID = {
|
|
2846
|
+
DESTRUCTION_EVENTS: "destruction.events",
|
|
2847
|
+
BREACH_PAINT: "floorplan.breach-paint",
|
|
2848
|
+
BREACH_CUT: "floorplan.breach-cut",
|
|
2849
|
+
AUDIO_VOICES: "audio.voices",
|
|
2850
|
+
VEHICLE_CREASE: "vehicles.crease",
|
|
2851
|
+
AUDIO_OCCLUSION: "audio.occlusion",
|
|
2852
|
+
FLUID_FILM: "fluids.film",
|
|
2853
|
+
VEHICLE_LOD_BATCH: "vehicles.lod-batch",
|
|
2854
|
+
SETTLED_BATCH: "destruction.settled-batch",
|
|
2855
|
+
STATIC_BATCH: "render.static-batch",
|
|
2856
|
+
ANIMALS_STATIC_BATCH: "animals.static-batch",
|
|
2857
|
+
CHARACTERS_STATIC_BATCH: "characters.static-batch",
|
|
2858
|
+
HOUSE_SHADOW_BATCH: "floorplan.shadow-batch",
|
|
2859
|
+
DESTRUCTION_PREFIT: "destruction.prefit"
|
|
2860
|
+
};
|
|
2861
|
+
var DEFERRED_PRIORITY = {
|
|
2862
|
+
[DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS]: { priority: 300, phase: "present" },
|
|
2863
|
+
// every frame: the walls cut since the last frame are painted once each, and a hole must show in the frame of the blast
|
|
2864
|
+
[DEFERRED_QUEUE_ID.BREACH_CUT]: { priority: 260, phase: "present", minEveryFrames: 1 },
|
|
2865
|
+
[DEFERRED_QUEUE_ID.BREACH_PAINT]: { priority: 250, phase: "present", minEveryFrames: 1 },
|
|
2866
|
+
[DEFERRED_QUEUE_ID.AUDIO_VOICES]: { priority: 200, phase: "idle", reserveMs: 1 },
|
|
2867
|
+
[DEFERRED_QUEUE_ID.AUDIO_OCCLUSION]: { priority: 190, phase: "idle", minEveryFrames: 8 },
|
|
2868
|
+
[DEFERRED_QUEUE_ID.FLUID_FILM]: { priority: 120, phase: "idle", minEveryFrames: 2 },
|
|
2869
|
+
[DEFERRED_QUEUE_ID.VEHICLE_CREASE]: { priority: 100, phase: "idle" },
|
|
2870
|
+
[DEFERRED_QUEUE_ID.VEHICLE_LOD_BATCH]: { priority: 90, phase: "idle", minEveryFrames: 4 },
|
|
2871
|
+
[DEFERRED_QUEUE_ID.SETTLED_BATCH]: { priority: 70, phase: "idle", minEveryFrames: 8 },
|
|
2872
|
+
[DEFERRED_QUEUE_ID.STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
2873
|
+
[DEFERRED_QUEUE_ID.ANIMALS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
2874
|
+
[DEFERRED_QUEUE_ID.CHARACTERS_STATIC_BATCH]: { priority: 60, phase: "idle", minEveryFrames: 8 },
|
|
2875
|
+
[DEFERRED_QUEUE_ID.HOUSE_SHADOW_BATCH]: { priority: 50, phase: "idle", minEveryFrames: 8 },
|
|
2876
|
+
[DEFERRED_QUEUE_ID.DESTRUCTION_PREFIT]: { priority: 40, phase: "idle", minEveryFrames: 30 }
|
|
2877
|
+
};
|
|
2878
|
+
var MUST_DRAIN_QUEUE_IDS = /* @__PURE__ */ new Set([DEFERRED_QUEUE_ID.DESTRUCTION_EVENTS, DEFERRED_QUEUE_ID.BREACH_CUT]);
|
|
2879
|
+
var PLUNGE_STROKE_SECONDS = 0.8;
|
|
2880
|
+
var SURFACE_IDS = ["concrete", "asphalt", "wood", "tile", "dirt", "grass", "gravel", "sand", "metal", "water", "glass", "carpet"];
|
|
2881
|
+
var GAIT_IDS = ["walk", "run"];
|
|
2882
|
+
var LANDING_IDS = ["light", "heavy"];
|
|
2883
|
+
var BODY_SOUND_IDS = [
|
|
2884
|
+
"jump",
|
|
2885
|
+
"cloth_rustle",
|
|
2886
|
+
"body_fall",
|
|
2887
|
+
"fall_damage",
|
|
2888
|
+
"player_hurt",
|
|
2889
|
+
"player_breath_run",
|
|
2890
|
+
"player_death",
|
|
2891
|
+
"bite",
|
|
2892
|
+
"grab",
|
|
2893
|
+
"punch_swing",
|
|
2894
|
+
"punch_hit_body",
|
|
2895
|
+
"punch_hit_face",
|
|
2896
|
+
"punch_hit_object",
|
|
2897
|
+
"kick_swing",
|
|
2898
|
+
"kick_hit",
|
|
2899
|
+
"kick_hit_object",
|
|
2900
|
+
"shove_two_hands",
|
|
2901
|
+
"knife_swing",
|
|
2902
|
+
"knife_stab",
|
|
2903
|
+
"knife_slash",
|
|
2904
|
+
"knife_hit_object",
|
|
2905
|
+
"blunt_swing",
|
|
2906
|
+
"blunt_hit",
|
|
2907
|
+
"blunt_hit_object",
|
|
2908
|
+
"axe_swing",
|
|
2909
|
+
"axe_chop",
|
|
2910
|
+
"axe_hit_object"
|
|
2911
|
+
];
|
|
2912
|
+
var footstepSoundId = (surface, gait) => `footstep_${surface}_${gait}`;
|
|
2913
|
+
var FOOTSTEP_SOUND_IDS = SURFACE_IDS.flatMap((surface) => GAIT_IDS.map((gait) => footstepSoundId(surface, gait)));
|
|
2914
|
+
var LAND_SOUND_IDS = SURFACE_IDS.flatMap((surface) => LANDING_IDS.map((landing) => `land_${surface}_${landing}`));
|
|
2915
|
+
var BODY_FOLEY_IDS = [...FOOTSTEP_SOUND_IDS, ...LAND_SOUND_IDS, ...BODY_SOUND_IDS];
|
|
2916
|
+
var WORKER_KIND_ID = {
|
|
2917
|
+
GROUND_TILES: "destruction.ground-tiles",
|
|
2918
|
+
CROWD_PHYSICS: "crowd.physics",
|
|
2919
|
+
PIECE_BOXES: "destruction.piece-boxes",
|
|
2920
|
+
STATIC_COLLIDERS: "destruction.static-colliders",
|
|
2921
|
+
SHAPES_GENERATE: "shapes.generate",
|
|
2922
|
+
WORLD_REGION: "world.region",
|
|
2923
|
+
VEHICLE_HULL_PLAN: "vehicles.hull-plan"
|
|
2924
|
+
};
|
|
2925
|
+
var WORKER_KIND_DEFAULTS = {
|
|
2926
|
+
[WORKER_KIND_ID.GROUND_TILES]: { lane: "sim", priority: 300, latencyFrames: 2, late: "sync" },
|
|
2927
|
+
[WORKER_KIND_ID.CROWD_PHYSICS]: { lane: "sim", priority: 250, latencyFrames: 1, late: "sync" },
|
|
2928
|
+
[WORKER_KIND_ID.PIECE_BOXES]: { lane: "sim", priority: 200, latencyFrames: 2, late: "sync" },
|
|
2929
|
+
[WORKER_KIND_ID.STATIC_COLLIDERS]: { lane: "build", priority: 150, late: "sync" },
|
|
2930
|
+
[WORKER_KIND_ID.SHAPES_GENERATE]: { lane: "build", priority: 100, late: "sync" },
|
|
2931
|
+
[WORKER_KIND_ID.WORLD_REGION]: { lane: "background", priority: 10, latencyFrames: 10, late: "drop" },
|
|
2932
|
+
[WORKER_KIND_ID.VEHICLE_HULL_PLAN]: { lane: "build", priority: 120, late: "keep-waiting" }
|
|
2933
|
+
};
|
|
2934
|
+
|
|
2935
|
+
// src/drain-uses.ts
|
|
2936
|
+
var RELIEVE_SECONDS = 8;
|
|
2937
|
+
var LANDS_AT = 0.7;
|
|
2938
|
+
var FLUSH_LITRES = 6;
|
|
2939
|
+
var SWALLOW_SECONDS = 0.5;
|
|
2940
|
+
var SPILL_GATHER_SECONDS = 0.25;
|
|
2941
|
+
var URINE = { kind: "urine", kg: 0.3, litres: 0.3, size: [0.02, 0.02, 0.02] };
|
|
2942
|
+
var FECES = { kind: "feces", kg: 0.2, size: [0.12, 0.035, 0.035] };
|
|
2943
|
+
var PAPER = { kind: "paper", kg: 8e-3, size: [0.06, 0.03, 0.03] };
|
|
2944
|
+
var PEE = [URINE];
|
|
2945
|
+
var POO = [FECES, PAPER, PAPER];
|
|
2946
|
+
var HOST_NEEDS = ["setBasin", "spill", "looseInside", "swallow"];
|
|
2947
|
+
function createDrainUses(options) {
|
|
2948
|
+
const { spec, t, world, objectId } = options;
|
|
2949
|
+
const basins = /* @__PURE__ */ new Map();
|
|
2950
|
+
for (const b of spec.basins ?? []) {
|
|
2951
|
+
const drain = world.drain(objectId, b.id);
|
|
2952
|
+
if (!drain) continue;
|
|
2953
|
+
const centre = [(b.from[0] + b.to[0]) / 2, b.from[1], (b.from[2] + b.to[2]) / 2];
|
|
2954
|
+
basins.set(b.id, { spec: b, drain, centre, frontRim: [centre[0], b.to[1], b.to[2]], clogged: false, overflowing: false, spill: 0, spillTime: 0 });
|
|
2955
|
+
}
|
|
2956
|
+
const flushes = new Map(
|
|
2957
|
+
(spec.fixtures ?? []).flatMap((f) => f.cleans && basins.has(f.cleans) ? [[f.id, { basin: f.cleans, litres: f.volume ?? FLUSH_LITRES }]] : [])
|
|
2958
|
+
);
|
|
2959
|
+
const list = [...basins.values()];
|
|
2960
|
+
let states = {};
|
|
2961
|
+
const pending = [];
|
|
2962
|
+
const swallowing = [];
|
|
2963
|
+
let plunging = null;
|
|
2964
|
+
const typeKey = `type.${spec.type}`;
|
|
2965
|
+
const name = () => {
|
|
2966
|
+
const text = t(typeKey);
|
|
2967
|
+
return text === typeKey ? spec.type.replace(/_/g, " ") : text.charAt(0).toLowerCase() + text.slice(1);
|
|
2968
|
+
};
|
|
2969
|
+
const takeLoose = (b, host) => {
|
|
2970
|
+
const top = [b.spec.to[0], b.spec.to[1] + 0.08, b.spec.to[2]];
|
|
2971
|
+
const inWater = new Set(b.drain.state().contents.flatMap((c) => c.objectId ? [c.objectId] : []));
|
|
2972
|
+
for (const thing of host?.looseInside?.(b.spec.from, top) ?? []) {
|
|
2973
|
+
if (inWater.has(thing.id)) continue;
|
|
2974
|
+
b.drain.add({ kind: "object", kg: thing.kg, size: thing.size, objectId: thing.id });
|
|
2975
|
+
}
|
|
2976
|
+
};
|
|
2977
|
+
const report = (b, host) => {
|
|
2978
|
+
const clogged = b.drain.clog() >= CLOGGED;
|
|
2979
|
+
if (clogged && !b.clogged) host?.say(t("clogged", { name: name() }));
|
|
2980
|
+
b.clogged = clogged;
|
|
2981
|
+
};
|
|
2982
|
+
const stepPending = (dt) => {
|
|
2983
|
+
let kept = 0;
|
|
2984
|
+
for (const p of pending) {
|
|
2985
|
+
p.left -= dt;
|
|
2986
|
+
if (p.left > 0) {
|
|
2987
|
+
pending[kept++] = p;
|
|
2988
|
+
continue;
|
|
2989
|
+
}
|
|
2990
|
+
for (const content of p.lands) basins.get(p.basin)?.drain.add(content);
|
|
2991
|
+
}
|
|
2992
|
+
pending.length = kept;
|
|
2993
|
+
};
|
|
2994
|
+
const stepPlunge = (dt, host) => {
|
|
2995
|
+
if (!plunging) return;
|
|
2996
|
+
const b = basins.get(plunging.basin);
|
|
2997
|
+
plunging.left -= dt;
|
|
2998
|
+
plunging.stroke += dt;
|
|
2999
|
+
if (b && plunging.stroke >= PLUNGE_STROKE_SECONDS) {
|
|
3000
|
+
plunging.stroke -= PLUNGE_STROKE_SECONDS;
|
|
3001
|
+
const cause = b.drain.cause();
|
|
3002
|
+
b.drain.plunge();
|
|
3003
|
+
if (cause !== "none" && b.drain.cause() === "none") {
|
|
3004
|
+
host?.say(t(cause === "object" ? "plunge_object" : "plunge_cleared", { name: name() }));
|
|
3005
|
+
b.clogged = false;
|
|
3006
|
+
}
|
|
3007
|
+
}
|
|
3008
|
+
if (plunging.left > 0) return;
|
|
3009
|
+
if (b && b.drain.clog() >= CLOGGED) host?.say(t("plunge_still", { name: name() }));
|
|
3010
|
+
plunging = null;
|
|
3011
|
+
};
|
|
3012
|
+
const stepSwallowing = (dt, host) => {
|
|
3013
|
+
let kept = 0;
|
|
3014
|
+
for (const s of swallowing) {
|
|
3015
|
+
s.time += dt;
|
|
3016
|
+
const progress = Math.min(1, s.time / SWALLOW_SECONDS);
|
|
3017
|
+
host?.swallow?.(s.id, s.point, progress);
|
|
3018
|
+
if (progress < 1) swallowing[kept++] = s;
|
|
3019
|
+
}
|
|
3020
|
+
swallowing.length = kept;
|
|
3021
|
+
};
|
|
3022
|
+
const stepSpill = (b, spilled, dt, host) => {
|
|
3023
|
+
if (spilled > 0 && !b.overflowing) host?.say(t("overflow", { name: name() }));
|
|
3024
|
+
b.overflowing = spilled > 0;
|
|
3025
|
+
b.spill += spilled;
|
|
3026
|
+
if (b.spill <= 0) return;
|
|
3027
|
+
b.spillTime += dt;
|
|
3028
|
+
if (b.spillTime < SPILL_GATHER_SECONDS) return;
|
|
3029
|
+
host?.spill?.(b.frontRim, b.spill, b.drain.dirty() ? "sewage" : "water");
|
|
3030
|
+
b.spill = 0;
|
|
3031
|
+
b.spillTime = 0;
|
|
3032
|
+
};
|
|
3033
|
+
const stepBasin = (b, dt, host) => {
|
|
3034
|
+
const step = b.drain.update(dt);
|
|
3035
|
+
for (const id of step.swallowed) swallowing.push({ id, point: b.centre, time: 0 });
|
|
3036
|
+
stepSpill(b, step.spilled, dt, host);
|
|
3037
|
+
host?.setBasin?.(b.spec.id, b.drain.litres());
|
|
3038
|
+
report(b, host);
|
|
3039
|
+
};
|
|
3040
|
+
return {
|
|
3041
|
+
has: (basin) => basins.has(basin),
|
|
3042
|
+
hostBlocked: (host) => HOST_NEEDS.find((need) => host[need] === void 0) ?? null,
|
|
3043
|
+
relieveBody(use, host) {
|
|
3044
|
+
const body = host.body?.();
|
|
3045
|
+
if (!body) return null;
|
|
3046
|
+
const seconds = use.seconds ?? RELIEVE_SECONDS;
|
|
3047
|
+
const b = basins.get(use.basin);
|
|
3048
|
+
if (use.kind === "urine" && use.stand && body.sex === "male") return { pose: "relieve_stand", seconds, at: use.stand, faces: b ? b.centre : [0, 0, 0] };
|
|
3049
|
+
return { pose: "relieve_sit", seconds, ...use.seat ? { seat: use.seat } : {} };
|
|
3050
|
+
},
|
|
3051
|
+
relieve(use, host, body) {
|
|
3052
|
+
if (use.cover) host.setPart(use.cover, true);
|
|
3053
|
+
if (use.ring) host.setPart(use.ring, body.pose === "relieve_stand");
|
|
3054
|
+
pending.push({ basin: use.basin, lands: use.kind === "urine" ? PEE : POO, left: body.seconds * LANDS_AT });
|
|
3055
|
+
return { ok: true, text: t(`done_relieve_${use.kind}`, { name: name() }), body };
|
|
3056
|
+
},
|
|
3057
|
+
plungeBlocked(use, host) {
|
|
3058
|
+
if (!host.hand()?.tools?.includes(use.tool)) return "needs_plunger";
|
|
3059
|
+
const b = basins.get(use.basin);
|
|
3060
|
+
return b && b.drain.level() < PLUNGER_WATER ? "plunge_no_water" : null;
|
|
3061
|
+
},
|
|
3062
|
+
plungeBody(use) {
|
|
3063
|
+
const b = basins.get(use.basin);
|
|
3064
|
+
return { pose: "plunge", seconds: use.seconds, at: use.stand, faces: b ? b.centre : [0, 0, 0] };
|
|
3065
|
+
},
|
|
3066
|
+
plunge(use, body) {
|
|
3067
|
+
plunging = { basin: use.basin, left: use.seconds, stroke: 0 };
|
|
3068
|
+
return { ok: true, text: t("done_plunge", { name: name() }), body };
|
|
3069
|
+
},
|
|
3070
|
+
flushed(fixture, host) {
|
|
3071
|
+
const flush = flushes.get(fixture);
|
|
3072
|
+
const b = flush ? basins.get(flush.basin) : void 0;
|
|
3073
|
+
if (!flush || !b) return false;
|
|
3074
|
+
takeLoose(b, host);
|
|
3075
|
+
b.drain.flush(flush.litres);
|
|
3076
|
+
return true;
|
|
3077
|
+
},
|
|
3078
|
+
update(dt, host) {
|
|
3079
|
+
stepPending(dt);
|
|
3080
|
+
stepPlunge(dt, host);
|
|
3081
|
+
stepSwallowing(dt, host);
|
|
3082
|
+
for (const b of list) stepBasin(b, dt, host);
|
|
3083
|
+
},
|
|
3084
|
+
dispose(host) {
|
|
3085
|
+
for (const s of swallowing) host?.swallow?.(s.id, s.point, 1);
|
|
3086
|
+
swallowing.length = 0;
|
|
3087
|
+
pending.length = 0;
|
|
3088
|
+
plunging = null;
|
|
3089
|
+
},
|
|
3090
|
+
soil(basin) {
|
|
3091
|
+
const contents = basins.get(basin)?.drain.state().contents ?? [];
|
|
3092
|
+
if (contents.some((c) => c.kind === "feces" || c.kind === "paper")) return "feces";
|
|
3093
|
+
return contents.some((c) => c.kind === "urine") ? "urine" : "clean";
|
|
3094
|
+
},
|
|
3095
|
+
state() {
|
|
3096
|
+
for (const b of list) {
|
|
3097
|
+
if (states[b.spec.id] === b.drain.state()) continue;
|
|
3098
|
+
states = Object.fromEntries(list.map((each) => [each.spec.id, each.drain.state()]));
|
|
3099
|
+
break;
|
|
3100
|
+
}
|
|
3101
|
+
return states;
|
|
3102
|
+
}
|
|
3103
|
+
};
|
|
3104
|
+
}
|
|
3105
|
+
|
|
2588
3106
|
// src/fits-volume.ts
|
|
2589
3107
|
function fitsInVolume(size, half) {
|
|
2590
3108
|
const thing = [...size].sort((a, b) => b - a);
|
|
@@ -2597,8 +3115,11 @@ var GameInteractables = (() => {
|
|
|
2597
3115
|
var DRINK_LITRES = 0.25;
|
|
2598
3116
|
var FILL_SHARE = 0.85;
|
|
2599
3117
|
var DRINK_LPS = 0.06;
|
|
3118
|
+
var DRINK_HANDS_LITRES = 0.12;
|
|
3119
|
+
var DRINK_HANDS_LPS = 0.03;
|
|
2600
3120
|
var REACH_SECONDS = 0.6;
|
|
2601
3121
|
var DRY_SECONDS = 0.5;
|
|
3122
|
+
var UNDER_STREAM = 0.14;
|
|
2602
3123
|
var SCRUBBED_DIRT = 0.15;
|
|
2603
3124
|
var YES = { available: true };
|
|
2604
3125
|
var idsOf = (need) => typeof need === "string" ? [need] : need;
|
|
@@ -2617,16 +3138,59 @@ var GameInteractables = (() => {
|
|
|
2617
3138
|
if (!dishes || !basin) return [];
|
|
2618
3139
|
return (host.itemsInside?.(dishes.ids, basin.from, basin.to) ?? []).filter((item) => (item.dirt ?? 0) > 0);
|
|
2619
3140
|
}
|
|
3141
|
+
function washBody(use, host) {
|
|
3142
|
+
const { playUse, lather, rinse, itemsInside, placeItem, setDirt, takeDose } = host;
|
|
3143
|
+
if (!playUse || !lather || !rinse) return null;
|
|
3144
|
+
if (use.dishes && (!itemsInside || !placeItem || !setDirt)) return null;
|
|
3145
|
+
if (use.dose && !takeDose) return null;
|
|
3146
|
+
return { playUse, lather, rinse, itemsInside, placeItem, setDirt, takeDose };
|
|
3147
|
+
}
|
|
3148
|
+
function vesselBody(host) {
|
|
3149
|
+
const { playUse, vesselAt, fillItem, drinkItem } = host;
|
|
3150
|
+
return playUse && vesselAt && fillItem && drinkItem ? { playUse, vesselAt, fillItem, drinkItem } : null;
|
|
3151
|
+
}
|
|
3152
|
+
function handsBody(host) {
|
|
3153
|
+
const { playUse, handsFree, drinkFromHands } = host;
|
|
3154
|
+
return playUse && handsFree && drinkFromHands ? { playUse, handsFree, drinkFromHands } : null;
|
|
3155
|
+
}
|
|
3156
|
+
var NO_BODY = { available: false, reason: "no_animation" };
|
|
3157
|
+
var NEEDS_FREE_HAND = { available: false, reason: "needs_free_hand" };
|
|
2620
3158
|
function sinkVerdict(use, spec, host, flowing) {
|
|
2621
|
-
if (use.do === "
|
|
3159
|
+
if (use.do === "drink") return drinkVerdict(use, host);
|
|
3160
|
+
if (!washBody(use, host)) return NO_BODY;
|
|
3161
|
+
if (use.requiresFlowing && !flowing) return { available: false, reason: "needs_running" };
|
|
2622
3162
|
const found = findNeeds(use.needs ?? [], host);
|
|
3163
|
+
if (!handsFreeFor(use, found.items, host)) return NEEDS_FREE_HAND;
|
|
2623
3164
|
if (found.missing) return { available: false, reason: "needs_item", vars: { need: found.missing[0] ?? "" } };
|
|
2624
|
-
if (use.do === "drink") return YES;
|
|
2625
3165
|
const dosed = use.dose ? found.items[use.dose.need] : void 0;
|
|
2626
3166
|
if (dosed && (dosed.remaining ?? 1) <= 0) return { available: false, reason: "item_spent", vars: { item: dosed.name } };
|
|
2627
3167
|
if (use.dishes && dirtyDishes(use, spec, host).length === 0) return { available: false, reason: "no_dirty_dishes" };
|
|
2628
3168
|
return YES;
|
|
2629
3169
|
}
|
|
3170
|
+
function handsAreFree(host) {
|
|
3171
|
+
return host.handsFree?.() ?? host.hand() === null;
|
|
3172
|
+
}
|
|
3173
|
+
function handsFreeFor(use, needed, host) {
|
|
3174
|
+
if (handsAreFree(host)) return true;
|
|
3175
|
+
if (host.hand() === null) return false;
|
|
3176
|
+
if (needed.some((item) => item.where === "hand")) return true;
|
|
3177
|
+
return use.dishes !== void 0 && host.itemAt?.(use.dishes.ids)?.where === "hand";
|
|
3178
|
+
}
|
|
3179
|
+
function drinkVerdict(use, host) {
|
|
3180
|
+
if (use.from === "hands") {
|
|
3181
|
+
const body2 = handsBody(host);
|
|
3182
|
+
if (!body2) return NO_BODY;
|
|
3183
|
+
if (body2.handsFree()) return YES;
|
|
3184
|
+
return host.vesselAt?.()?.where === "hand" ? { available: false, reason: "drink_from_vessel" } : NEEDS_FREE_HAND;
|
|
3185
|
+
}
|
|
3186
|
+
const body = vesselBody(host);
|
|
3187
|
+
if (!body) return NO_BODY;
|
|
3188
|
+
const vessel = body.vesselAt();
|
|
3189
|
+
if (!vessel) return { available: false, reason: "needs_vessel" };
|
|
3190
|
+
if (vessel.where !== "hand") return { available: false, reason: "needs_in_hand", vars: { item: vessel.name } };
|
|
3191
|
+
const other = vessel.liquid?.kind !== void 0 && vessel.liquid.kind !== "water" && vessel.liquid.litres > 1e-3;
|
|
3192
|
+
return other ? { available: false, reason: "vessel_not_empty", vars: { item: vessel.name } } : YES;
|
|
3193
|
+
}
|
|
2630
3194
|
var fixtureFlowLps = (fixture) => fixture ? (fixture.flow ?? FLOW_DEFAULTS[fixture.kind] ?? 6) / 60 : 0;
|
|
2631
3195
|
function runPhases(phases) {
|
|
2632
3196
|
let index = 0;
|
|
@@ -2650,6 +3214,10 @@ var GameInteractables = (() => {
|
|
|
2650
3214
|
const fixtureOf = (id) => (spec.fixtures ?? []).find((f) => f.id === id);
|
|
2651
3215
|
const flowing = (use) => world.water.isFlowing(objectId, use.fixture);
|
|
2652
3216
|
const water = (use) => flowing(use) ? fixtureFlowLps(fixtureOf(use.fixture)) : 0;
|
|
3217
|
+
const underStream = (use) => {
|
|
3218
|
+
const outlet = fixtureOf(use.fixture)?.outlet;
|
|
3219
|
+
return outlet ? [outlet[0], outlet[1] - UNDER_STREAM, outlet[2]] : void 0;
|
|
3220
|
+
};
|
|
2653
3221
|
const waterOf = (use) => {
|
|
2654
3222
|
let dry = 0;
|
|
2655
3223
|
return (dt) => {
|
|
@@ -2658,6 +3226,14 @@ var GameInteractables = (() => {
|
|
|
2658
3226
|
return dry > DRY_SECONDS ? null : flow;
|
|
2659
3227
|
};
|
|
2660
3228
|
};
|
|
3229
|
+
const approachPhase = (use, host) => {
|
|
3230
|
+
let walked = 0;
|
|
3231
|
+
const at = underStream(use);
|
|
3232
|
+
return (dt) => {
|
|
3233
|
+
walked += dt;
|
|
3234
|
+
return !at || !host.approach || walked > REACH_SECONDS * 3 || host.approach(at, dt);
|
|
3235
|
+
};
|
|
3236
|
+
};
|
|
2661
3237
|
const tapPhases = (use) => {
|
|
2662
3238
|
let opened = false;
|
|
2663
3239
|
const reach = wait(REACH_SECONDS);
|
|
@@ -2674,7 +3250,7 @@ var GameInteractables = (() => {
|
|
|
2674
3250
|
}
|
|
2675
3251
|
};
|
|
2676
3252
|
};
|
|
2677
|
-
const scrubAndRinse = (use,
|
|
3253
|
+
const scrubAndRinse = (use, body, target, fail) => {
|
|
2678
3254
|
const item = typeof target === "string" ? void 0 : target;
|
|
2679
3255
|
const id = item?.objectId ?? target;
|
|
2680
3256
|
const seconds = use.scrubSeconds ?? WASH_SCRUB_SECONDS;
|
|
@@ -2683,11 +3259,14 @@ var GameInteractables = (() => {
|
|
|
2683
3259
|
const scrub = (dt) => {
|
|
2684
3260
|
if (scrubbed < 0) {
|
|
2685
3261
|
scrubbed = 0;
|
|
2686
|
-
|
|
3262
|
+
if (!body.playUse(use.clip, item?.objectId, underStream(use))) {
|
|
3263
|
+
fail({ key: "hands_busy", ok: false });
|
|
3264
|
+
return true;
|
|
3265
|
+
}
|
|
2687
3266
|
}
|
|
2688
3267
|
scrubbed = Math.min(seconds, scrubbed + dt);
|
|
2689
|
-
|
|
2690
|
-
if (dirt > 0)
|
|
3268
|
+
body.lather(id, dt / seconds);
|
|
3269
|
+
if (dirt > 0) body.setDirt?.(id, dirt - (dirt - Math.min(dirt, SCRUBBED_DIRT)) * (scrubbed / seconds));
|
|
2691
3270
|
return scrubbed >= seconds;
|
|
2692
3271
|
};
|
|
2693
3272
|
const running = waterOf(use);
|
|
@@ -2697,13 +3276,13 @@ var GameInteractables = (() => {
|
|
|
2697
3276
|
fail({ key: "no_water", ok: false });
|
|
2698
3277
|
return true;
|
|
2699
3278
|
}
|
|
2700
|
-
if (flow <= 0 ||
|
|
2701
|
-
if (dirt > 0)
|
|
3279
|
+
if (flow <= 0 || body.rinse(id, flow, dt) > 0) return false;
|
|
3280
|
+
if (dirt > 0) body.setDirt?.(id, 0);
|
|
2702
3281
|
return true;
|
|
2703
3282
|
};
|
|
2704
3283
|
return [scrub, rinse];
|
|
2705
3284
|
};
|
|
2706
|
-
const startWash = (use, host) => {
|
|
3285
|
+
const startWash = (use, host, body) => {
|
|
2707
3286
|
const { items } = findNeeds(use.needs ?? [], host);
|
|
2708
3287
|
let end = null;
|
|
2709
3288
|
const fail = (reason) => {
|
|
@@ -2712,59 +3291,136 @@ var GameInteractables = (() => {
|
|
|
2712
3291
|
const tap = tapPhases(use);
|
|
2713
3292
|
const dosed = use.dose ? items[use.dose.need] : void 0;
|
|
2714
3293
|
const dose = () => {
|
|
2715
|
-
if (dosed &&
|
|
3294
|
+
if (dosed && body.takeDose?.(dosed.objectId, use.dose?.amount).taken === 0) fail({ key: "item_spent", ok: false, vars: { item: dosed.name } });
|
|
2716
3295
|
return true;
|
|
2717
3296
|
};
|
|
2718
3297
|
const dishes = use.dishes ? dirtyDishes(use, spec, host) : [];
|
|
2719
3298
|
const rack = use.dishes?.rack ?? [];
|
|
2720
|
-
const work = use.dishes ? dishes.flatMap((dish, index) => [...scrubAndRinse(use,
|
|
3299
|
+
const work = use.dishes ? dishes.flatMap((dish, index) => [...scrubAndRinse(use, body, dish, fail), placePhase(host, dish, rack[Math.min(index, rack.length - 1)])]) : scrubAndRinse(use, body, use.surface, fail);
|
|
2721
3300
|
const guarded = work.map((phase) => (dt) => end !== null || phase(dt));
|
|
2722
|
-
const run = runPhases([tap.open, dose, ...guarded, tap.close]);
|
|
3301
|
+
const run = runPhases([approachPhase(use, host), tap.open, dose, ...guarded, tap.close]);
|
|
2723
3302
|
const done = use.dishes ? { key: "done_wash_dishes", ok: true, vars: { n: String(dishes.length) } } : { key: "done_wash", ok: true, vars: { surface: use.surface } };
|
|
2724
3303
|
return { use: use.id, step: (dt) => run(dt) ? end ?? done : null };
|
|
2725
3304
|
};
|
|
2726
|
-
const startDrink = (use, host, vessel) => {
|
|
3305
|
+
const startDrink = (use, host, body, vessel) => {
|
|
2727
3306
|
const tap = tapPhases(use);
|
|
2728
3307
|
const want = Math.min(use.litres ?? DRINK_LITRES, (vessel.liquid?.capacity ?? DRINK_LITRES) * FILL_SHARE);
|
|
2729
3308
|
let filled = vessel.liquid?.kind === "water" ? vessel.liquid.litres : 0;
|
|
2730
3309
|
let drunk = 0;
|
|
2731
3310
|
let end = null;
|
|
2732
|
-
const take = () => {
|
|
2733
|
-
if (vessel.where !== "hand" && host.holdItem?.(vessel.objectId) === false) end = { key: "needs_item", ok: false, vars: { need: vessel.itemId } };
|
|
2734
|
-
else host.playUse?.(use.fillClip ?? "fill_cup", vessel.objectId);
|
|
2735
|
-
return true;
|
|
2736
|
-
};
|
|
2737
3311
|
const running = waterOf(use);
|
|
3312
|
+
const played = (clip, at) => {
|
|
3313
|
+
if (body.playUse(clip, vessel.objectId, at)) return true;
|
|
3314
|
+
end ?? (end = { key: "hands_busy", ok: false });
|
|
3315
|
+
return false;
|
|
3316
|
+
};
|
|
3317
|
+
let filling = false;
|
|
2738
3318
|
const fill = (dt) => {
|
|
2739
3319
|
if (end) return true;
|
|
3320
|
+
if (!filling && !(filling = played(use.fillClip ?? "fill_cup", underStream(use)))) return true;
|
|
2740
3321
|
const flow = running(dt);
|
|
2741
3322
|
if (flow === null) {
|
|
2742
3323
|
end = { key: "no_water", ok: false };
|
|
2743
3324
|
return true;
|
|
2744
3325
|
}
|
|
2745
3326
|
if (flow <= 0) return false;
|
|
2746
|
-
const took =
|
|
3327
|
+
const took = body.fillItem(vessel.objectId, "water", Math.min(flow * dt, want - filled));
|
|
2747
3328
|
filled += took;
|
|
2748
3329
|
return filled >= want - 1e-6 || took <= 0;
|
|
2749
3330
|
};
|
|
2750
3331
|
let sipping = false;
|
|
2751
3332
|
const drink = (dt) => {
|
|
2752
3333
|
if (end) return true;
|
|
2753
|
-
if (!sipping
|
|
2754
|
-
const sip =
|
|
3334
|
+
if (!sipping && !(sipping = played(use.clip))) return true;
|
|
3335
|
+
const sip = body.drinkItem(vessel.objectId, Math.min(DRINK_LPS * dt, filled - drunk));
|
|
2755
3336
|
drunk += sip;
|
|
2756
3337
|
return drunk >= filled - 1e-6 || sip <= 0;
|
|
2757
3338
|
};
|
|
2758
|
-
const
|
|
2759
|
-
const
|
|
2760
|
-
return { use: use.id, step: (dt) => run(dt) ? end ??
|
|
3339
|
+
const run = runPhases([approachPhase(use, host), tap.open, fill, tap.close, drink]);
|
|
3340
|
+
const done = () => drunk > 1e-3 ? { key: "done_drink", ok: true, vars: { litres: drunk.toFixed(2) } } : { key: "not_drunk", ok: false };
|
|
3341
|
+
return { use: use.id, step: (dt) => run(dt) ? end ?? done() : null };
|
|
2761
3342
|
};
|
|
3343
|
+
const startDrinkHands = (use, host, body) => {
|
|
3344
|
+
const tap = tapPhases(use);
|
|
3345
|
+
const want = use.litres ?? DRINK_HANDS_LITRES;
|
|
3346
|
+
let drunk = 0;
|
|
3347
|
+
let end = null;
|
|
3348
|
+
const running = waterOf(use);
|
|
3349
|
+
let bent = false;
|
|
3350
|
+
const drink = (dt) => {
|
|
3351
|
+
if (!bent) {
|
|
3352
|
+
bent = body.playUse(use.clip, void 0, underStream(use));
|
|
3353
|
+
if (!bent) {
|
|
3354
|
+
end = { key: "hands_busy", ok: false };
|
|
3355
|
+
return true;
|
|
3356
|
+
}
|
|
3357
|
+
}
|
|
3358
|
+
const flow = running(dt);
|
|
3359
|
+
if (flow === null) {
|
|
3360
|
+
end = { key: "no_water", ok: false };
|
|
3361
|
+
return true;
|
|
3362
|
+
}
|
|
3363
|
+
if (flow <= 0) return false;
|
|
3364
|
+
const sip = body.drinkFromHands("water", Math.min(DRINK_HANDS_LPS * dt, flow * dt, want - drunk));
|
|
3365
|
+
drunk += sip;
|
|
3366
|
+
return drunk >= want - 1e-6 || sip <= 0;
|
|
3367
|
+
};
|
|
3368
|
+
const run = runPhases([approachPhase(use, host), tap.open, drink, tap.close]);
|
|
3369
|
+
const done = () => drunk > 1e-3 ? { key: "done_drink_hands", ok: true, vars: { litres: drunk.toFixed(2) } } : { key: "not_drunk", ok: false };
|
|
3370
|
+
return { use: use.id, step: (dt) => run(dt) ? end ?? done() : null };
|
|
3371
|
+
};
|
|
3372
|
+
const refused = (use, key) => ({ use: use.id, step: () => ({ key, ok: false }) });
|
|
2762
3373
|
return {
|
|
2763
3374
|
start(use, host) {
|
|
2764
|
-
if (use.do === "wash")
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
3375
|
+
if (use.do === "wash") {
|
|
3376
|
+
const body2 = washBody(use, host);
|
|
3377
|
+
return body2 ? startWash(use, host, body2) : refused(use, "no_animation");
|
|
3378
|
+
}
|
|
3379
|
+
if (use.from === "hands") {
|
|
3380
|
+
const body2 = handsBody(host);
|
|
3381
|
+
return body2 ? startDrinkHands(use, host, body2) : refused(use, "no_animation");
|
|
3382
|
+
}
|
|
3383
|
+
const body = vesselBody(host);
|
|
3384
|
+
const vessel = body?.vesselAt();
|
|
3385
|
+
if (!body) return refused(use, "no_animation");
|
|
3386
|
+
return vessel ? startDrink(use, host, body, vessel) : refused(use, "needs_vessel");
|
|
3387
|
+
}
|
|
3388
|
+
};
|
|
3389
|
+
}
|
|
3390
|
+
|
|
3391
|
+
// src/use-body.ts
|
|
3392
|
+
function createUseBody() {
|
|
3393
|
+
let running = null;
|
|
3394
|
+
const end = () => {
|
|
3395
|
+
const was = running;
|
|
3396
|
+
running = null;
|
|
3397
|
+
was?.body.end();
|
|
3398
|
+
};
|
|
3399
|
+
return {
|
|
3400
|
+
blocked(action, host) {
|
|
3401
|
+
const body = host.body?.();
|
|
3402
|
+
if (!body) return "needs_body";
|
|
3403
|
+
const why = body.blocked(action);
|
|
3404
|
+
return why ? `body_${why}` : null;
|
|
3405
|
+
},
|
|
3406
|
+
begin(action, host) {
|
|
3407
|
+
const body = host.body?.();
|
|
3408
|
+
if (!body) return false;
|
|
3409
|
+
end();
|
|
3410
|
+
if (!body.begin(action)) return false;
|
|
3411
|
+
running = { action, body, time: 0 };
|
|
3412
|
+
return true;
|
|
3413
|
+
},
|
|
3414
|
+
update(dt) {
|
|
3415
|
+
if (!running) return;
|
|
3416
|
+
running.time += dt;
|
|
3417
|
+
const { action, body, time } = running;
|
|
3418
|
+
if (!body.step(time, Math.min(1, time / action.seconds))) running = null;
|
|
3419
|
+
else if (time >= action.seconds) end();
|
|
3420
|
+
},
|
|
3421
|
+
end,
|
|
3422
|
+
get pose() {
|
|
3423
|
+
return running ? { pose: running.action.pose, time: running.time, progress: Math.min(1, running.time / running.action.seconds) } : null;
|
|
2768
3424
|
}
|
|
2769
3425
|
};
|
|
2770
3426
|
}
|
|
@@ -2787,7 +3443,7 @@ var GameInteractables = (() => {
|
|
|
2787
3443
|
};
|
|
2788
3444
|
var accepts = (bowl, hand) => (bowl.accepts ?? []).some((id) => hand.itemId === id || hand.itemId.endsWith(`_${id}`));
|
|
2789
3445
|
var YES2 = { available: true };
|
|
2790
|
-
var no = (reason) => ({ available: false, reason });
|
|
3446
|
+
var no = (reason, vars) => ({ available: false, reason, ...vars ? { vars } : {} });
|
|
2791
3447
|
function createUses(options) {
|
|
2792
3448
|
const { spec, world, objectId } = options;
|
|
2793
3449
|
const all = spec.uses ?? [];
|
|
@@ -2800,6 +3456,8 @@ var GameInteractables = (() => {
|
|
|
2800
3456
|
let lastHost = null;
|
|
2801
3457
|
const sinkRoutines = createSinkRoutines({ spec, world, objectId });
|
|
2802
3458
|
let routine = null;
|
|
3459
|
+
const drains = createDrainUses({ spec, world, objectId, t: (key, vars) => world.t(key, vars) });
|
|
3460
|
+
const useBody = createUseBody();
|
|
2803
3461
|
const typeKey = `type.${spec.type}`;
|
|
2804
3462
|
const name = () => {
|
|
2805
3463
|
const text = world.t(typeKey);
|
|
@@ -2830,12 +3488,28 @@ var GameInteractables = (() => {
|
|
|
2830
3488
|
return fits ? YES2 : no("not_accepted");
|
|
2831
3489
|
}
|
|
2832
3490
|
case "relieve":
|
|
2833
|
-
return YES2;
|
|
3491
|
+
return drains.has(use.basin) ? drainVerdict(host, () => handsAreFree(host) ? null : "needs_free_hand", () => drains.relieveBody(use, host)) : YES2;
|
|
2834
3492
|
case "wash":
|
|
2835
3493
|
case "drink":
|
|
2836
3494
|
return routine ? no("busy") : sinkVerdict(use, spec, host, world.water.isFlowing(objectId, use.fixture));
|
|
3495
|
+
case "plunge":
|
|
3496
|
+
return drainVerdict(host, () => drains.plungeBlocked(use, host), () => drains.plungeBody(use));
|
|
2837
3497
|
}
|
|
2838
3498
|
};
|
|
3499
|
+
const drainVerdict = (host, rule, body) => {
|
|
3500
|
+
const missing = drains.hostBlocked(host);
|
|
3501
|
+
if (missing) return no("host_lacks", { capability: missing });
|
|
3502
|
+
const broken = rule();
|
|
3503
|
+
if (broken) return no(broken);
|
|
3504
|
+
const action = body();
|
|
3505
|
+
if (!action) return no("needs_body");
|
|
3506
|
+
const why = useBody.blocked(action, host);
|
|
3507
|
+
return why ? no(why) : YES2;
|
|
3508
|
+
};
|
|
3509
|
+
const withBody = (action, host, vars, run) => {
|
|
3510
|
+
if (!action) return { ok: false, text: world.t("needs_body", vars) };
|
|
3511
|
+
return useBody.begin(action, host) ? run(action) : { ok: false, text: world.t("body_busy", vars) };
|
|
3512
|
+
};
|
|
2839
3513
|
const itemName = (id) => {
|
|
2840
3514
|
const text = world.t(`item.${id}`);
|
|
2841
3515
|
return text === `item.${id}` ? id.replace(/_/g, " ") : text;
|
|
@@ -2871,7 +3545,10 @@ var GameInteractables = (() => {
|
|
|
2871
3545
|
}
|
|
2872
3546
|
case "fill":
|
|
2873
3547
|
return fill(bowls.get(use.bowl), host, vars);
|
|
3548
|
+
case "plunge":
|
|
3549
|
+
return withBody(drains.plungeBody(use), host, vars, (action) => drains.plunge(use, action));
|
|
2874
3550
|
case "relieve": {
|
|
3551
|
+
if (drains.has(use.basin)) return withBody(drains.relieveBody(use, host), host, vars, (action) => drains.relieve(use, host, action));
|
|
2875
3552
|
const now = soil.get(use.basin) ?? "clean";
|
|
2876
3553
|
soil.set(use.basin, SOIL_RANK[use.kind] > SOIL_RANK[now] ? use.kind : now);
|
|
2877
3554
|
return { ok: true, text: world.t(`done_relieve_${use.kind}`, vars) };
|
|
@@ -2929,7 +3606,10 @@ var GameInteractables = (() => {
|
|
|
2929
3606
|
const v = verdict(use, host);
|
|
2930
3607
|
return v.available ? runUse(use, host) : { ok: false, text: reasonOf(v, use, host) };
|
|
2931
3608
|
},
|
|
2932
|
-
update(dt) {
|
|
3609
|
+
update(dt, host) {
|
|
3610
|
+
if (host) lastHost = host;
|
|
3611
|
+
drains.update(dt, lastHost);
|
|
3612
|
+
useBody.update(dt);
|
|
2933
3613
|
stepRoutine(dt);
|
|
2934
3614
|
if (!program) return;
|
|
2935
3615
|
program.left -= dt;
|
|
@@ -2939,17 +3619,25 @@ var GameInteractables = (() => {
|
|
|
2939
3619
|
program = null;
|
|
2940
3620
|
lastHost?.say(done);
|
|
2941
3621
|
},
|
|
2942
|
-
flushed(fixture) {
|
|
3622
|
+
flushed(fixture, host) {
|
|
3623
|
+
if (host) lastHost = host;
|
|
3624
|
+
if (drains.flushed(fixture, lastHost)) return;
|
|
2943
3625
|
const basin = cleans.get(fixture);
|
|
2944
3626
|
if (!basin || soil.get(basin) === "clean") return;
|
|
2945
3627
|
soil.set(basin, "clean");
|
|
2946
3628
|
lastHost?.say(world.t("done_clean", { name: name() }));
|
|
2947
3629
|
},
|
|
3630
|
+
dispose(host) {
|
|
3631
|
+
drains.dispose(host ?? lastHost);
|
|
3632
|
+
useBody.end();
|
|
3633
|
+
},
|
|
2948
3634
|
state: () => ({
|
|
2949
3635
|
bowls: Object.fromEntries(level),
|
|
2950
|
-
soil: Object.fromEntries(soil),
|
|
3636
|
+
soil: Object.fromEntries([...soil].map(([id, now]) => [id, drains.has(id) ? drains.soil(id) : now])),
|
|
3637
|
+
drains: drains.state(),
|
|
2951
3638
|
program: program ? { use: program.use.id, device: program.use.device, left: program.left } : null,
|
|
2952
|
-
routine: routine?.use ?? null
|
|
3639
|
+
routine: routine?.use ?? null,
|
|
3640
|
+
body: useBody.pose
|
|
2953
3641
|
})
|
|
2954
3642
|
};
|
|
2955
3643
|
}
|
|
@@ -2977,7 +3665,7 @@ var GameInteractables = (() => {
|
|
|
2977
3665
|
onEvent: (event) => {
|
|
2978
3666
|
if (event.type === "message") said.push(event.text);
|
|
2979
3667
|
if (event.type === "part" && event.object === CONTROLLED_OBJECT) forwardPart(event.part, event.target >= 0.5);
|
|
2980
|
-
if (event.type === "fixture" && event.object === CONTROLLED_OBJECT && event.flowing) uses.flushed(event.fixture);
|
|
3668
|
+
if (event.type === "fixture" && event.object === CONTROLLED_OBJECT && event.flowing) uses.flushed(event.fixture, host ?? void 0);
|
|
2981
3669
|
}
|
|
2982
3670
|
});
|
|
2983
3671
|
const forwardPart = (part, open) => {
|
|
@@ -3022,14 +3710,17 @@ var GameInteractables = (() => {
|
|
|
3022
3710
|
update(dt, lent) {
|
|
3023
3711
|
lend(lent);
|
|
3024
3712
|
world.update(dt);
|
|
3025
|
-
uses.update(dt);
|
|
3713
|
+
uses.update(dt, lent);
|
|
3026
3714
|
},
|
|
3027
3715
|
state() {
|
|
3028
3716
|
const screens = (spec.devices ?? []).filter((d) => d.kind === "screen" && world.power.isOn(CONTROLLED_OBJECT, d.id) && world.power.isPowered(CONTROLLED_OBJECT, d.id)).map((d) => ({ device: d.id, channel: world.power.channel(CONTROLLED_OBJECT, d.id) }));
|
|
3029
3717
|
const emitters = world.emitters().filter((e) => e.object === CONTROLLED_OBJECT && e.kind !== "water");
|
|
3030
3718
|
return { ...uses.state(), screens, emitters };
|
|
3031
3719
|
},
|
|
3720
|
+
serialize: () => world.serialize(),
|
|
3721
|
+
load: (state) => world.load(state),
|
|
3032
3722
|
dispose() {
|
|
3723
|
+
uses.dispose(host ?? void 0);
|
|
3033
3724
|
host = null;
|
|
3034
3725
|
world.remove(CONTROLLED_OBJECT);
|
|
3035
3726
|
world.remove(MAINS);
|