--
This commit is contained in:
parent
5ed977788c
commit
f500279abd
93 changed files with 1893 additions and 1198 deletions
|
|
@ -204,15 +204,15 @@
|
|||
const heldByPlayer = Boolean(this.playerHeld || this._heldByPlayer);
|
||||
if (!Number.isFinite(this.sleepDiseaseAnchorX)) this.sleepDiseaseAnchorX = this.x;
|
||||
if (!Number.isFinite(this.sleepDiseaseAnchorY)) this.sleepDiseaseAnchorY = this.y;
|
||||
this.startSleeping(null, beingDraggedByAnt ? "眠ったままアリに運ばれている" : "ねむり病で眠り続けている");
|
||||
// ねむり病は意識だけを固定し、物理位置は固定しない。
|
||||
// 以前は anchor に毎回スナップしていたため、外力・つまみ・機械接触を無視していた。
|
||||
this.startSleeping(null, beingDraggedByAnt ? "\u7720\u3063\u305f\u307e\u307e\u30a2\u30ea\u306b\u904b\u3070\u308c\u3066\u3044\u308b" : "\u306d\u3080\u308a\u75c5\u3067\u7720\u308a\u7d9a\u3051\u3066\u3044\u308b");
|
||||
// \u306d\u3080\u308a\u75c5\u306f\u610f\u8b58\u3060\u3051\u3092\u56fa\u5b9a\u3057\u3001\u7269\u7406\u4f4d\u7f6e\u306f\u56fa\u5b9a\u3057\u306a\u3044\u3002
|
||||
// \u4ee5\u524d\u306f anchor \u306b\u6bce\u56de\u30b9\u30ca\u30c3\u30d7\u3057\u3066\u3044\u305f\u305f\u3081\u3001\u5916\u529b\u30fb\u3064\u307e\u307f\u30fb\u6a5f\u68b0\u63a5\u89e6\u3092\u7121\u8996\u3057\u3066\u3044\u305f\u3002
|
||||
if (heldByPlayer || beingDraggedByAnt || Math.hypot(Number(this.vx || 0) + Number(this.impulseVx || 0), Number(this.vy || 0) + Number(this.impulseVy || 0)) > 0.1) {
|
||||
this.sleepDiseaseAnchorX = this.x;
|
||||
this.sleepDiseaseAnchorY = this.y;
|
||||
}
|
||||
this.wanderAngle = this.wanderAngle || 0;
|
||||
this.thought = beingDraggedByAnt ? "眠ったままアリに運ばれている" : "ねむり病で眠り続けている";
|
||||
this.thought = beingDraggedByAnt ? "\u7720\u3063\u305f\u307e\u307e\u30a2\u30ea\u306b\u904b\u3070\u308c\u3066\u3044\u308b" : "\u306d\u3080\u308a\u75c5\u3067\u7720\u308a\u7d9a\u3051\u3066\u3044\u308b";
|
||||
if (this.world && this.world.time > (this.nextSleepBubbleAt || 0)) {
|
||||
this.nextSleepBubbleAt = this.world.time + 5.0;
|
||||
this.world.spawnBubble?.(this.x, this.y - this.radius * 1.18, "Zzz...", "rgba(65,70,92,0.72)");
|
||||
|
|
@ -240,20 +240,24 @@
|
|||
if (!alreadyInside) {
|
||||
this.nestBoxEnteredAt = this.world?.time || 0;
|
||||
this.nestBoxStayUntil = Math.max(this.nestBoxStayUntil || -Infinity, (this.world?.time || 0) + 14);
|
||||
this.nestBoxSlotIndex = Math.min(occupants.length, Math.max(0, capacity - 1));
|
||||
this._nestBoxEntrySmoothUntil = (this.world?.time || 0) + 0.85;
|
||||
}
|
||||
this.insideNestBoxId = box.id;
|
||||
this.target = box;
|
||||
if (this.state === "seek_bed") this.startSleeping(box, "\u5de3\u7bb1\u306e\u4e2d\u3067\u7720\u3063\u3066\u3044\u308b");
|
||||
if (this.state === "sleep") this.sleeping = true;
|
||||
const inner = this.world?.nestBoxInnerPoint ? this.world.nestBoxInnerPoint(box, this) : { x: box.x, y: box.y };
|
||||
const pull = clamp(dt * (alreadyInside ? 10.0 : 13.5), 0, 1);
|
||||
const smoothDt = clamp(Number(dt || 0.016) || 0.016, 0.008, 0.045);
|
||||
const firstPhase = (this.world?.time || 0) < (this._nestBoxEntrySmoothUntil || -Infinity);
|
||||
const pull = clamp(smoothDt * (alreadyInside ? (firstPhase ? 5.2 : 8.5) : 7.2), 0, 0.55);
|
||||
this.x = lerp(this.x, inner.x, pull);
|
||||
this.y = lerp(this.y, inner.y, pull);
|
||||
if (this.nestFade >= 0.88 || distXY(this.x, this.y, inner.x, inner.y) < 3.5) {
|
||||
if (!firstPhase && (this.nestFade >= 0.97 || distXY(this.x, this.y, inner.x, inner.y) < 2.0)) {
|
||||
this.x = inner.x;
|
||||
this.y = inner.y;
|
||||
}
|
||||
this.nestFade = clamp((this.nestFade || 0) + dt * 5.8, 0, 1);
|
||||
this.nestFade = clamp((this.nestFade || 0) + smoothDt * 4.2, 0, 1);
|
||||
this.vx = 0;
|
||||
this.vy = 0;
|
||||
this.impulseVx = 0;
|
||||
|
|
@ -274,6 +278,8 @@
|
|||
this.nestFade = 0;
|
||||
this.nestBoxEnteredAt = -Infinity;
|
||||
this.nestBoxStayUntil = -Infinity;
|
||||
this.nestBoxSlotIndex = -1;
|
||||
this._nestBoxEntrySmoothUntil = -Infinity;
|
||||
return true;
|
||||
},
|
||||
|
||||
|
|
@ -313,8 +319,8 @@
|
|||
const entryD = distXY(this.x, this.y, entry.x, entry.y);
|
||||
const centerD = distXY(this.x, this.y, targetBox.x, targetBox.y);
|
||||
const inDoorColumn = base && this.x >= base.left + r * 0.18 && this.x <= base.right - r * 0.18 && this.y >= base.top + r * 0.06 && this.y <= base.bottom + r * 0.48;
|
||||
const captureRange = Math.max(118, r * 2.05, this.radius + 82);
|
||||
const nearEnough = entryD <= captureRange || centerD <= Math.max(104, r * 1.90) || inDoorColumn;
|
||||
const captureRange = Math.max(76, r * 1.55, this.radius + 48);
|
||||
const nearEnough = entryD <= captureRange || centerD <= Math.max(78, r * 1.38) || inDoorColumn;
|
||||
if (nearEnough) {
|
||||
this.enterNestBox(targetBox, dt || 0.016);
|
||||
return targetBox;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue