qqq
This commit is contained in:
parent
acf93ec6df
commit
ee22e1a929
49 changed files with 1380 additions and 338 deletions
|
|
@ -115,7 +115,21 @@
|
|||
if ((this.groundType || "soil") === "ice") temp -= 5;
|
||||
const range = Math.max(24, CONFIG.temperatureItemRange ?? 190);
|
||||
for (const it of this.nearbyItems(x, y, range + 8)) {
|
||||
if (!it || it.dead || (it.type !== "dry_ice" && it.type !== "stove")) continue;
|
||||
if (!it || it.dead || (it.type !== "dry_ice" && it.type !== "stove" && it.type !== "fan")) continue;
|
||||
if (it.type === "fan") {
|
||||
const angle = itemAngleFor(it);
|
||||
const dx = x - it.x;
|
||||
const dy = y - it.y;
|
||||
const along = dx * Math.cos(angle) + dy * Math.sin(angle);
|
||||
const fanRange = range * 1.35;
|
||||
if (along <= 8 || along > fanRange) continue;
|
||||
const lateral = Math.abs(-dx * Math.sin(angle) + dy * Math.cos(angle));
|
||||
const halfWidth = 28 + along * 0.72;
|
||||
if (lateral > halfWidth) continue;
|
||||
const edge = Math.pow(clamp(1 - along / fanRange, 0, 1), 0.62) * Math.pow(clamp(1 - lateral / Math.max(1, halfWidth), 0, 1), 0.30);
|
||||
temp -= 4 * edge;
|
||||
continue;
|
||||
}
|
||||
const d = distXY(x, y, it.x, it.y);
|
||||
if (d > range) continue;
|
||||
const edge = d <= range - 24 ? 1 : clamp((range - d) / 24, 0, 1);
|
||||
|
|
@ -136,8 +150,22 @@
|
|||
if (actor && (actor.state === "sunbath" || (actor.sunbathTimer || 0) > 0.04)) temp += 3;
|
||||
return this.temperatureNumber(temp);
|
||||
},
|
||||
pipeInteriorTemperatureFor(pipe, actor = null) {
|
||||
if (!pipe || pipe.dead || pipe.type !== "pipe") return null;
|
||||
const base = this.temperatureAt?.(pipe.x, pipe.y, null);
|
||||
const temp = this.temperatureNumber(base, this.currentTemperature ?? CONFIG.standardTemperature ?? 15);
|
||||
const toward = 20 - temp;
|
||||
return this.temperatureNumber(temp + clamp(toward, -7, 7));
|
||||
},
|
||||
feltTemperatureFor(actor, x = actor?.x, y = actor?.y) {
|
||||
if (!actor) return this.temperatureAt(x, y);
|
||||
if (actor.insideNestBoxId && this.nestBoxById) {
|
||||
const box = this.nestBoxById(actor.insideNestBoxId);
|
||||
if (box?.type === "pipe") {
|
||||
const pipeTemp = this.pipeInteriorTemperatureFor?.(box, actor);
|
||||
if (Number.isFinite(Number(pipeTemp))) return pipeTemp;
|
||||
}
|
||||
}
|
||||
return this.temperatureAt(x, y, actor);
|
||||
},
|
||||
temperatureComfortOffsetFor(actor = null) {
|
||||
|
|
@ -189,9 +217,16 @@
|
|||
}
|
||||
const itemRange = Math.max(24, CONFIG.temperatureItemRange ?? 190);
|
||||
for (const it of this.items || []) {
|
||||
if (!it || it.dead || (it.type !== "dry_ice" && it.type !== "stove")) continue;
|
||||
if (!it || it.dead || (it.type !== "dry_ice" && it.type !== "stove" && it.type !== "fan")) continue;
|
||||
if (currentStatus.direction === "cold" && it.type !== "stove") continue;
|
||||
if (currentStatus.direction === "hot" && it.type !== "dry_ice") continue;
|
||||
if (currentStatus.direction === "hot" && it.type !== "dry_ice" && it.type !== "fan") continue;
|
||||
if (it.type === "fan") {
|
||||
const a = itemAngleFor(it);
|
||||
pushCandidate(it.x + Math.cos(a) * itemRange * 0.52, it.y + Math.sin(a) * itemRange * 0.52, -50);
|
||||
pushCandidate(it.x + Math.cos(a + 0.48) * itemRange * 0.72, it.y + Math.sin(a + 0.48) * itemRange * 0.72, -28);
|
||||
pushCandidate(it.x + Math.cos(a - 0.48) * itemRange * 0.72, it.y + Math.sin(a - 0.48) * itemRange * 0.72, -28);
|
||||
continue;
|
||||
}
|
||||
const toward = Math.atan2(actor.y - it.y, actor.x - it.x);
|
||||
pushCandidate(it.x + Math.cos(toward) * itemRange * 0.45, it.y + Math.sin(toward) * itemRange * 0.45, -60);
|
||||
pushCandidate(it.x + Math.cos(toward + 0.75) * itemRange * 0.62, it.y + Math.sin(toward + 0.75) * itemRange * 0.62, -32);
|
||||
|
|
@ -225,12 +260,14 @@
|
|||
},
|
||||
sleepTargetTemperatureBlocked(actor, item) {
|
||||
if (!actor || !item || item.dead) return false;
|
||||
if (!(item.type === "grass_bed" || item.type === "bed" || item.type === "nest_box")) return false;
|
||||
if (!(item.type === "grass_bed" || item.type === "bed" || item.type === "nest_box" || item.type === "pipe")) return false;
|
||||
const current = this.feltTemperatureFor?.(actor) ?? this.temperatureAt?.(actor.x, actor.y, actor);
|
||||
const currentStatus = this.temperatureStatusFor?.(current, actor);
|
||||
if (!currentStatus || currentStatus.comfortable) return false;
|
||||
if (!this.hasReachableComfortTemperatureSpot?.(actor)) return false;
|
||||
const temp = this.temperatureAt?.(item.x, item.y, actor);
|
||||
const temp = item.type === "pipe" && this.pipeInteriorTemperatureFor
|
||||
? this.pipeInteriorTemperatureFor(item, actor)
|
||||
: this.temperatureAt?.(item.x, item.y, actor);
|
||||
const status = this.temperatureStatusFor?.(temp, actor);
|
||||
return Boolean(status && !status.comfortable);
|
||||
},
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue