lag r
This commit is contained in:
parent
d875df8600
commit
2741b93dea
31 changed files with 751 additions and 546 deletions
|
|
@ -6,8 +6,7 @@
|
|||
Object.defineProperties(Tarinai.prototype, Object.getOwnPropertyDescriptors({
|
||||
interactWithOthers(dt) {
|
||||
let closeCount = 0;
|
||||
const quality = this.world?.performanceQuality?.() || {};
|
||||
const scanLimit = Math.max(1, Number(quality.socialScanLimit || 14) || 14);
|
||||
const scanLimit = 8;
|
||||
let scanned = 0;
|
||||
for (const o of this.world.nearbyTarinai(this.x, this.y, 78)) {
|
||||
if (o === this || o.dead) continue;
|
||||
|
|
@ -191,13 +190,23 @@
|
|||
|
||||
if (this.state === "sunbath") {
|
||||
this.target = null;
|
||||
this.vx *= Math.pow(0.90, dt * 60);
|
||||
this.vy *= Math.pow(0.90, dt * 60);
|
||||
this.vx = 0;
|
||||
this.vy = 0;
|
||||
const pad = Math.max(28, CONFIG.worldPadding || 30);
|
||||
const safeW = Math.max(pad * 2 + 1, Number(this.world?.w || 1000) || 1000);
|
||||
const safeH = Math.max(pad * 2 + 1, Number(this.world?.h || 720) || 720);
|
||||
this.x = clamp((Number.isFinite(this.x) ? this.x : safeW * 0.5) + Math.sin((this.world?.time || 0) * 1.3 + this.seed) * 0.03, pad, safeW - pad);
|
||||
this.y = clamp((Number.isFinite(this.y) ? this.y : safeH * 0.5) + Math.cos((this.world?.time || 0) * 1.1 + this.seed) * 0.02, pad, safeH - pad);
|
||||
const fallbackX = Number.isFinite(this._lastSunbathDrawX) ? this._lastSunbathDrawX : (Number.isFinite(this._lastValidX) ? this._lastValidX : (Number.isFinite(this.x) ? this.x : pad));
|
||||
const fallbackY = Number.isFinite(this._lastSunbathDrawY) ? this._lastSunbathDrawY : (Number.isFinite(this._lastValidY) ? this._lastValidY : (Number.isFinite(this.y) ? this.y : pad));
|
||||
if (!Number.isFinite(this.sunbathAnchorX)) this.sunbathAnchorX = fallbackX;
|
||||
if (!Number.isFinite(this.sunbathAnchorY)) this.sunbathAnchorY = fallbackY;
|
||||
this.sunbathAnchorX = clamp(this.sunbathAnchorX, pad, safeW - pad);
|
||||
this.sunbathAnchorY = clamp(this.sunbathAnchorY, pad, safeH - pad);
|
||||
this.x = this.sunbathAnchorX;
|
||||
this.y = this.sunbathAnchorY;
|
||||
this._lastSunbathDrawX = this.x;
|
||||
this._lastSunbathDrawY = this.y;
|
||||
this._lastValidX = this.x;
|
||||
this._lastValidY = this.y;
|
||||
return;
|
||||
}
|
||||
if (this.state === "sleep") {
|
||||
|
|
@ -234,7 +243,7 @@
|
|||
}
|
||||
|
||||
if (this.birthRitualTimer > 0.04 || this.state === "birth_ritual") {
|
||||
const partner = this.world.tarinai.find(o => o.id === this.birthPartnerId && !o.dead);
|
||||
const partner = this.world.liveTarinaiById?.(this.birthPartnerId);
|
||||
if (partner) {
|
||||
const midX = (this.x + partner.x) / 2;
|
||||
const midY = (this.y + partner.y) / 2;
|
||||
|
|
@ -418,7 +427,11 @@
|
|||
this.world.addItem?.(new Item("splat", this.x, this.y), "tarinai-death-splat") || this.world.items.push(new Item("splat", this.x, this.y));
|
||||
if (Math.random() < 0.55) {
|
||||
const spot = this.world.findGrassPlantingSpot(this.x, this.y, { allowOriginal: false, minRadius: 26, maxRadius: 76 });
|
||||
if (spot) this.world.addItem?.(new Item("grass", spot.x, spot.y), "tarinai-death-grass") || this.world.items.push(new Item("grass", spot.x, spot.y));
|
||||
if (spot) {
|
||||
const deathGrass = new Item("grass", spot.x, spot.y);
|
||||
if (this.world.addItem) this.world.addItem(deathGrass, "tarinai-death-grass");
|
||||
else this.world.items.push(deathGrass);
|
||||
}
|
||||
}
|
||||
this.world.markDead(this, finalReason);
|
||||
this.releasedLiveToken = this.liveToken || 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue