This commit is contained in:
33333-33333 2026-07-01 16:55:49 +09:00
commit c9dd7182aa
35 changed files with 478 additions and 288 deletions

View file

@ -115,6 +115,14 @@
target.singleUsePending = true;
target.singleUseConsumedById = this.id || target.singleUseConsumedById || "";
}
if (target && target.type !== "nest_box") {
this._sleepExternalMotionUntil = 0;
this._sleepExternalWakeSuppressUntil = Math.max(Number(this._sleepExternalWakeSuppressUntil || 0) || 0, now + 2.4);
this.vx = 0;
this.vy = 0;
this.impulseVx = 0;
this.impulseVy = 0;
}
const text = reason || (target?.type === "nest_box" ? "\u5de3\u7bb1\u306e\u4e2d\u3067\u7720\u3063\u3066\u3044\u308b" : "\u7720\u3063\u3066\u3044\u308b");
setBehaviorText(this, { need: "sleep", actionId: target ? "sleep_in_bed" : "sleep_anywhere", actionLabel: "\u7720\u3063\u3066\u3044\u308b", reasonText: text, target, phase: "perform", source: "behavior" });
return this.setActionState("sleep", { target, reason: text, sleeping: true });
@ -138,9 +146,9 @@
const sleptFor = Number.isFinite(started) ? Math.max(0, now - started) : 0;
const wasActuallySleeping = Boolean((this.state === "sleep" || this.sleeping || session) && session?.consumesGrassBedOnWake);
// Reserve-on-use must not consume the simple bed. It is consumed only by
// a real wake after sleep has started; pre-sleep wake flags just release
// the reservation and leave the bed intact.
if (!wasActuallySleeping || sleptFor < 0.75) {
// a real wake after sleep has had time to settle; immediate collision or
// movement wakeups just release the reservation and leave the bed intact.
if (!wasActuallySleeping || sleptFor < 2) {
if (bed.singleUseConsumedById === this.id) bed.singleUseConsumedById = "";
if (bed.singleUsePending && (!bed.singleUseConsumedById || bed.singleUseConsumedById === this.id)) bed.singleUsePending = false;
this.pendingGrassBedWakeId = "";