hm
This commit is contained in:
parent
4d3fc2cd47
commit
c9dd7182aa
35 changed files with 478 additions and 288 deletions
|
|
@ -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 = "";
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue