aa
This commit is contained in:
parent
f941200504
commit
ad2cc76429
34 changed files with 616 additions and 365 deletions
|
|
@ -467,23 +467,13 @@
|
|||
|
||||
temperatureDiscomfortSprite(baseId = "") {
|
||||
const world = this.world || null;
|
||||
const felt = world?.temperatureAt?.(this.x, this.y) ?? this.feltTemperature ?? this.tempComfort ?? (CONFIG.standardTemperature ?? 15);
|
||||
const status = this.temperatureStatus || world?.temperatureStatusFor?.(felt) || null;
|
||||
const felt = world?.feltTemperatureFor?.(this) ?? world?.temperatureAt?.(this.x, this.y, this) ?? this.feltTemperature ?? this.tempComfort ?? (CONFIG.standardTemperature ?? 15);
|
||||
const status = this.temperatureStatus || world?.temperatureStatusFor?.(felt, this) || null;
|
||||
if (!status || status.comfortable || (status.discomfort || 0) < 2.5) return "";
|
||||
const pool = (status.direction === "cold" ? ["cold_1", "cold_2", "cold_3"] : ["hot_1", "hot_2", "hot_3"]).filter(id => SPRITES.some(s => s.id === id));
|
||||
if (!pool.length) return "";
|
||||
const mapped = ({
|
||||
smile: 0,
|
||||
normal_happy: 0,
|
||||
normal_tongue: 0,
|
||||
jito: 1,
|
||||
normal_smirk: 1,
|
||||
pokan: 2,
|
||||
angry: 2,
|
||||
hungry_70: 2,
|
||||
})[String(baseId || "")];
|
||||
const fallbackIndex = status.harmful ? 2 : ((status.discomfort || 0) >= 7 ? 1 : 0);
|
||||
const index = clamp(Number.isFinite(mapped) ? mapped : fallbackIndex, 0, pool.length - 1);
|
||||
const u = typeof stableUnit === "function" ? stableUnit(this.familyKey || this.id || this.birthSeed || baseId || "temperature", `temperature-sprite:${status.direction}`) : Math.random();
|
||||
const index = Math.max(0, Math.min(pool.length - 1, Math.floor(u * pool.length)));
|
||||
return pool[index] || pool[0] || "";
|
||||
},
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue