This commit is contained in:
33333-33333 2026-07-03 00:45:22 +09:00
commit ee22e1a929
49 changed files with 1380 additions and 338 deletions

View file

@ -4,6 +4,13 @@
(function (global) {
const Tarinai = global.Tarinai;
if (!Tarinai) throw new Error("Tarinai is not available for mixin: tarinai_disease_nest.js");
function isNestContainerItem(item) {
return Boolean(item && !item.dead && (typeof global.isNestContainerType === "function" ? global.isNestContainerType(item.type) : (item.type === "nest_box" || item.type === "pipe")));
}
function containerLabel(item) { return item?.type === "pipe" ? "\u571f\u7ba1" : "\u5de3\u7bb1"; }
function containerInsideSleepText(item, verb = "\u7720\u3063\u3066\u3044\u308b") { return `${containerLabel(item)}\u306e\u4e2d\u3067${verb}`; }
function containerFullText(item) { return `${containerLabel(item)}\u304c\u3044\u3063\u3071\u3044\u3067\u5165\u308c\u306a\u3044`; }
Object.defineProperties(Tarinai.prototype, Object.getOwnPropertyDescriptors({
infectZunchiDisease(source = null, force = false) {
if (this.dead || this.zunchiDisease) return false;
@ -193,7 +200,7 @@
nestBoxById(id) {
if (!id) return null;
return this.world?.items?.find?.(it => it && !it.dead && it.id === id && it.type === "nest_box") || null;
return this.world?.items?.find?.(it => it && !it.dead && it.id === id && isNestContainerItem(it)) || null;
},
nestBoxEntryActive() {
@ -203,7 +210,7 @@
return now < (this._nestBoxEntrySmoothUntil || -Infinity) || ((this.nestFade || 0) > 0.01 && (this.nestFade || 0) < 0.985);
},
abortNestBoxEntry(box = null, reason = "\u5DE3\u7BB1\u304C\u3044\u3063\u3071\u3044\u3067\u5165\u308C\u306A\u3044") {
abortNestBoxEntry(box = null, reason = containerFullText(box)) {
const now = this.world?.time || 0;
if (this.insideNestBoxId && (!box || this.insideNestBoxId === box.id)) this.leaveNestBox?.(box);
if (!this.insideNestBoxId) this.nestFade = 0;
@ -233,14 +240,15 @@
this.awakeLockTimer = Math.max(this.awakeLockTimer || 0, 0.7);
this._nestBoxSeekStartedAt = NaN;
this._nestBoxSeekTargetId = "";
this.goIdle?.(reason);
this.thought = reason;
const finalReason = reason || containerFullText(box);
this.goIdle?.(finalReason);
this.thought = finalReason;
this.pinchThoughtTimer = Math.max(this.pinchThoughtTimer || 0, 1.0);
return false;
},
wantsNestBox(box = null) {
if (!box || box.dead || box.type !== "nest_box") return false;
if (!isNestContainerItem(box)) return false;
const now = this.world?.time || 0;
if (this._nestBoxAvoidId === box.id && now < (this._nestBoxAvoidUntil || -Infinity)) return false;
if (this.insideNestBoxId === box.id && (this.world?.time || 0) < (this.nestBoxStayUntil || -Infinity) && (this.state === "sleep" || this.state === "seek_bed" || this.sleeping)) return true;
@ -249,7 +257,7 @@
},
enterNestBox(box, dt = 0.016, options = {}) {
if (!box || box.dead || box.type !== "nest_box" || this.dead) return false;
if (!isNestContainerItem(box) || this.dead) return false;
const capacity = this.world?.nestBoxCapacity ? this.world.nestBoxCapacity(box) : 5;
let occupants = this.world?.nestBoxOccupants ? this.world.nestBoxOccupants(box, Infinity) : [];
const alreadyInside = this.insideNestBoxId === box.id;
@ -262,13 +270,13 @@
victim.leaveNestBox?.(box);
victim.awakeLockTimer = Math.max(victim.awakeLockTimer || 0, 0.8);
victim.fearTimer = Math.max(victim.fearTimer || 0, 0.22);
victim.thought = "\u5DE3\u7BB1\u304B\u3089\u62BC\u3057\u51FA\u3055\u308C\u305F";
victim.thought = `${containerLabel(box)}\u304b\u3089\u62bc\u3057\u51fa\u3055\u308c\u305f`;
victim.pinchThoughtTimer = Math.max(victim.pinchThoughtTimer || 0, 0.65);
victim.goIdle?.("\u5DE3\u7BB1\u304B\u3089\u62BC\u3057\u51FA\u3055\u308C\u305F");
victim.goIdle?.(`${containerLabel(box)}\u304b\u3089\u62bc\u3057\u51fa\u3055\u308c\u305f`);
occupants = this.world?.nestBoxOccupants ? this.world.nestBoxOccupants(box, Infinity) : occupants.filter(t => t !== victim);
}
}
if (occupants.length >= capacity) return this.abortNestBoxEntry?.(box, "\u5DE3\u7BB1\u304C\u3044\u3063\u3071\u3044\u3067\u5165\u308C\u306A\u3044") || false;
if (occupants.length >= capacity) return this.abortNestBoxEntry?.(box, containerFullText(box)) || false;
}
if (!alreadyInside) {
this._nestBoxSeekStartedAt = NaN;
@ -286,7 +294,7 @@
}
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 === "seek_bed") this.startSleeping(box, containerInsideSleepText(box, "\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 smoothDt = clamp(Number(dt || 0.016) || 0.016, 0.008, 0.045);
@ -330,17 +338,18 @@
this._nestBoxExitDuration = 0;
return false;
}
const inner = this.world?.nestBoxInnerPoint ? this.world.nestBoxInnerPoint(b, this) : { x: b.x, y: b.y };
const door = this.world.nestBoxEntryPoint(b);
const exit = this.world.nestBoxExitPoint ? this.world.nestBoxExitPoint(b, this) : door;
const exitContainer = b.type === "pipe" && this.world?.randomPipeExitFor ? (this.world.randomPipeExitFor(b, this) || b) : b;
const inner = this.world?.nestBoxInnerPoint ? this.world.nestBoxInnerPoint(exitContainer, this) : { x: exitContainer.x, y: exitContainer.y };
const door = this.world.nestBoxEntryPoint(exitContainer);
const exit = this.world.nestBoxExitPoint ? this.world.nestBoxExitPoint(exitContainer, this) : door;
this._nestBoxExitStartX = Number.isFinite(this.x) ? this.x : inner.x;
this._nestBoxExitStartY = Number.isFinite(this.y) ? this.y : inner.y;
if ((this.nestFade || 0) > 0.82 || distXY(this._nestBoxExitStartX, this._nestBoxExitStartY, inner.x, inner.y) > (b.r || 42) * 0.7) {
if ((this.nestFade || 0) > 0.82 || distXY(this._nestBoxExitStartX, this._nestBoxExitStartY, inner.x, inner.y) > (exitContainer.r || b.r || 42) * 0.7) {
this._nestBoxExitStartX = inner.x;
this._nestBoxExitStartY = inner.y;
}
this._nestBoxExitDoorX = Number.isFinite(door.x) ? door.x : b.x;
this._nestBoxExitDoorY = Number.isFinite(door.y) ? door.y : b.y;
this._nestBoxExitDoorX = Number.isFinite(door.x) ? door.x : exitContainer.x;
this._nestBoxExitDoorY = Number.isFinite(door.y) ? door.y : exitContainer.y;
this._nestBoxExitEndX = Number.isFinite(exit.x) ? exit.x : this._nestBoxExitDoorX;
this._nestBoxExitEndY = Number.isFinite(exit.y) ? exit.y : this._nestBoxExitDoorY;
this._nestBoxExitDuration = 0.58;
@ -404,7 +413,7 @@
}
this.sleeping = false;
this.sleepSession = null;
if (this.state === "sleep" || this.state === "seek_bed") this.goIdle?.("\u5DE3\u7BB1\u304B\u3089\u51FA\u305F");
if (this.state === "sleep" || this.state === "seek_bed") this.goIdle?.(`${containerLabel(b)}\u304b\u3089\u51fa\u305f`);
this.nestBoxStayUntil = -Infinity;
this.nestBoxSlotIndex = -1;
this._nestBoxEntrySmoothUntil = -Infinity;
@ -421,7 +430,7 @@
updateNestBoxPresence(dt = 0) {
if (this.updateNestBoxExitAnimation?.(dt || 0.016)) return null;
const currentBox = this.nestBoxById(this.insideNestBoxId);
const targetBox = this.target && !this.target.dead && this.target.type === "nest_box" ? this.target : null;
const targetBox = isNestContainerItem(this.target) ? this.target : null;
const box = currentBox || targetBox;
if (!box) {
this.insideNestBoxId = null;
@ -436,7 +445,7 @@
if (currentBox) {
if ((this.world?.time || 0) < (this.nestBoxStayUntil || -Infinity) && (this.state === "sleep" || this.state === "seek_bed" || this.sleeping)) {
this.startSleeping(box, "\u5de3\u7bb1\u306e\u4e2d\u3067\u7720\u3063\u3066\u3044\u308b");
this.startSleeping(box, containerInsideSleepText(box, "\u7720\u3063\u3066\u3044\u308b"));
this.sleeping = true;
this.target = currentBox;
}
@ -462,7 +471,7 @@
this._nestBoxSeekTargetId = targetBox.id;
}
if (!this.insideNestBoxId && global.TarinaiNestSleepSystem.sleepPlaceAvailableFor && !global.TarinaiNestSleepSystem.sleepPlaceAvailableFor(this.world, this, targetBox)) {
return this.abortNestBoxEntry?.(targetBox, "\u5DE3\u7BB1\u304C\u3044\u3063\u3071\u3044\u3067\u5165\u308C\u306A\u3044") || null;
return this.abortNestBoxEntry?.(targetBox, containerFullText(targetBox || box)) || null;
}
const entry = this.world?.nestBoxEntryPoint ? this.world.nestBoxEntryPoint(targetBox) : { x: targetBox.x, y: targetBox.y };