This commit is contained in:
33333-33333 2026-07-18 22:15:26 +09:00
commit d163ceb291
76 changed files with 1385 additions and 524 deletions

View file

@ -78,11 +78,19 @@
syncGrowthScale() {
if (!Number.isFinite(this.adultScale)) this.adultScale = adultScaleFromGenetics(this.familyKey || this.id, this.genetics);
const nextScale = this.generation > 1 ? scaleForGrowth(this.adultScale, this.growth) : this.adultScale;
const currentGrowth = this.growth;
const isJuvenileNow = this.generation > 1 && currentGrowth < 1;
if (this.generation > 1) {
if (this._growthWasJuvenile === true && !isJuvenileNow) {
this.world?.log?.(`${this.name}\u304c\u6210\u9577\u3057\u3066\u6210\u4f53\u306b\u306a\u3063\u305f\u3002`, "birth", { participants: [this] });
}
this._growthWasJuvenile = isJuvenileNow;
}
const nextScale = this.generation > 1 ? scaleForGrowth(this.adultScale, currentGrowth) : this.adultScale;
this.scale = clamp(nextScale, 0.10, 0.42);
if (this.refreshEffectiveSize) this.refreshEffectiveSize();
else this.radius = 56 * this.scale;
const growthBucket = Math.floor(clamp(this.growth || 0, 0, 1) * 20);
const growthBucket = Math.floor(clamp(currentGrowth || 0, 0, 1) * 20);
if (this.generation > 1 && this.world?.recordFamily && this.familyJoined?.() && this.familyGrowthBucket !== growthBucket) {
this.familyGrowthBucket = growthBucket;
this.world.recordFamily(this);
@ -257,13 +265,15 @@
adjustRelation(other, affinityDelta = 0, fearDelta = 0, event = "") {
if (!other || !other.id || other === this) return;
const rel = this.relationTo(other.id);
const threshold = typeof FRIEND_AFFINITY_THRESHOLD === "number" ? FRIEND_AFFINITY_THRESHOLD : 14;
const reverseBefore = other.relationships?.[this.id] || null;
const wasFriend = Math.max(rel.affinity || 0, reverseBefore?.affinity || 0) >= threshold;
rel.affinity = clamp((rel.affinity || 0) + affinityDelta, -24, 40);
rel.fear = clamp((rel.fear || 0) + fearDelta, 0, 40);
rel.fightsWon = rel.fightsWon || 0;
rel.fightsLost = rel.fightsLost || 0;
if (event) { rel.lastEvent = event; rel.lastTime = this.world.time; }
this.relationCache = null;
const threshold = typeof FRIEND_AFFINITY_THRESHOLD === "number" ? FRIEND_AFFINITY_THRESHOLD : 14;
if (affinityDelta > 0 && rel.affinity >= threshold && other.relationTo) {
const reverse = other.relationTo(this.id);
const mirrored = Math.max(reverse.affinity || 0, threshold + 0.25, Math.min(rel.affinity, rel.affinity * 0.78));
@ -272,6 +282,11 @@
if (event && !reverse.lastEvent) { reverse.lastEvent = event; reverse.lastTime = this.world?.time || other.world?.time || 0; }
other.relationCache = null;
}
const reverseAfter = other.relationships?.[this.id] || null;
const isFriend = Math.max(rel.affinity || 0, reverseAfter?.affinity || 0) >= threshold;
if (!wasFriend && isFriend) {
this.world?.log?.(`${this.name}\u3068${other.name}\u306f\u53cb\u9054\u306b\u306a\u3063\u305f\u3002`, "relation", { participants: [this, other] });
}
},
strongestRelation(kind = "friend", liveOnly = true) {