stable
This commit is contained in:
parent
fbdac9ebf1
commit
86226ccc94
97 changed files with 5790 additions and 2307 deletions
51
js/tarinai_sunbath_system.js
Normal file
51
js/tarinai_sunbath_system.js
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
"use strict";
|
||||
|
||||
// Layer: entity-runtime/tarinai/update-system
|
||||
// Owns active sunbath timer, sprite frame cycling, and recovery finish logic.
|
||||
(function (global) {
|
||||
function legacyMethod(dt) {
|
||||
if ((this.sunbathTimer || 0) <= 0) return;
|
||||
this.sunbathTimer = Math.max(0, (this.sunbathTimer || 0) - dt);
|
||||
this.sunbathFrameTimer = Math.max(0, (this.sunbathFrameTimer || 0) - dt);
|
||||
this.vx = 0;
|
||||
this.vy = 0;
|
||||
if ((this.sunbathFrameTimer || 0) <= 0) {
|
||||
const prev = this._activeSunbathSpriteId || (this.sunbathSpriteId ? this.sunbathSpriteId() : this.sunbathSpriteVariant);
|
||||
const next = this.randomSunbathSpriteId ? this.randomSunbathSpriteId(prev, { readyOnly: true }) : `sunbath_${1 + Math.floor(Math.random() * 3)}`;
|
||||
if (next && next !== prev && (!this.isSunbathSpriteReady || this.isSunbathSpriteReady(next))) {
|
||||
this._activeSunbathSpriteId = next;
|
||||
this._lastRenderableSunbathSpriteId = next;
|
||||
this.sunbathSpriteVariant = next;
|
||||
this.visibleSpriteId = next;
|
||||
this.spriteLockUntil = 0;
|
||||
} else {
|
||||
this.sunbathSpriteVariant = prev;
|
||||
this.visibleSpriteId = prev;
|
||||
}
|
||||
this.sunbathFrameTimer = 0.5;
|
||||
}
|
||||
this.energy = clamp((this.energy || 0) + dt * 0.03, 0, typeof tarinaiMaxEnergy === "function" ? tarinaiMaxEnergy(this) : (Number(this.maxEnergy) || 100));
|
||||
if (!this.isSunbathTime() || this.hunger > 82 || this.energy < 8 || this.state === "panic" || this.stuckPushpinId || this.currentLodgedPin?.()) this.sunbathTimer = 0;
|
||||
if ((this.sunbathTimer || 0) <= 0 && this.state === "sunbath") {
|
||||
this.finishSunbath?.();
|
||||
this._activeSunbathSpriteId = "";
|
||||
this.visibleSpriteId = "";
|
||||
this.spriteLockUntil = 0;
|
||||
this.sunbathAnchorX = null;
|
||||
this.sunbathAnchorY = null;
|
||||
this.goIdle("\u65e5\u5149\u6d74\u3092\u7d42\u3048\u305f");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function updateOne(tarinai, dt) {
|
||||
if (!tarinai || tarinai.dead) return false;
|
||||
legacyMethod.call(tarinai, dt);
|
||||
return true;
|
||||
}
|
||||
|
||||
global.TarinaiSunbathSystem = Object.freeze({
|
||||
legacyMethod,
|
||||
updateOne,
|
||||
});
|
||||
})(typeof window !== "undefined" ? window : globalThis);
|
||||
Loading…
Add table
Add a link
Reference in a new issue