From e105938a2219074d2b3a829cd39ed371399e77c9 Mon Sep 17 00:00:00 2001 From: Leonid Pershin Date: Sun, 14 Jun 2026 14:18:35 +0300 Subject: [PATCH] =?UTF-8?q?Wire=20health=20capacities=20to=20behaviour:=20?= =?UTF-8?q?filtration=E2=86=92immunity,=20sight/hearing=E2=86=92perception?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The expanded capacities were mostly display-only; make two of them affect the simulation (Moving→speed and Consciousness→intelligence gating already existed): - Blood filtration → toxin/disease clearance: AdvanceHediffs takes an immunity scale (default 1); AnimalHealthSystem passes the BloodFiltration capacity, so damaged kidneys/liver clear Poisoned and diseases slower (RimWorld model). Ties the new capacities to the coevolution work — weak filtration makes toxic plants deadlier. - Sight/hearing → perception radius: foraging, hunting and mate search scale by Sight; threat detection (flee) scales by max(Sight, Hearing) — you see or hear a predator. Injured eyes/ears shrink awareness. Eating/Talking/Digestion remain indicators for now. Build + --check-content clean. Not GUI-verified. Co-Authored-By: Claude Opus 4.8 --- src/LittleSim/Sim/AnimalOrganism.cs | 6 ++++-- src/LittleSim/Sim/AnimalSystems.cs | 31 +++++++++++++++++++---------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/src/LittleSim/Sim/AnimalOrganism.cs b/src/LittleSim/Sim/AnimalOrganism.cs index e8a537a..1d277a9 100644 --- a/src/LittleSim/Sim/AnimalOrganism.cs +++ b/src/LittleSim/Sim/AnimalOrganism.cs @@ -224,8 +224,10 @@ public sealed class HealthState /// /// Прогрессирует болезни (тяжесть и иммунитет растут со временем); снимает выздоровевшие /// (иммунитет ≥ 1); возвращает true, если какая-то болезнь достигла летальной тяжести. + /// — множитель набора иммунитета (способность «фильтрация крови»: + /// почки/печень выводят токсины и помогают бороться с болезнью; повреждённые → медленнее). /// - public bool AdvanceHediffs(float days) + public bool AdvanceHediffs(float days, float immunityScale = 1f) { var lethal = false; for (var i = _hediffs.Count - 1; i >= 0; i--) @@ -237,7 +239,7 @@ public sealed class HealthState } h.Severity += h.Def.SeverityPerDay * days; - h.Immunity += h.Def.ImmunityPerDay * days; + h.Immunity += h.Def.ImmunityPerDay * days * immunityScale; if (h.Immunity >= 1f) { _hediffs.RemoveAt(i); // иммунитет победил — выздоровление diff --git a/src/LittleSim/Sim/AnimalSystems.cs b/src/LittleSim/Sim/AnimalSystems.cs index c7f24b2..9e4cf6e 100644 --- a/src/LittleSim/Sim/AnimalSystems.cs +++ b/src/LittleSim/Sim/AnimalSystems.cs @@ -330,20 +330,24 @@ public sealed class AnimalDecisionSystem : BaseSystem brain.DecideIn = Interval + _rng.NextSingle() * Interval; // джиттер — расфазировать скан var pos = t[i].Position; var adult = AnimalFactory.IsAdult(_animalSet[o[i].Species], gr[i].Stage); - var radius = VisionRadius(o[i].Species, o[i].Traits.Vision); var self = entities.EntityAt(i); + var health = self.GetComponent().State; // Эффективный интеллект (мозг × сознание) гейтит доступные нужды/действия (фаза A7): // больной/раненый зверь с упавшим сознанием теряет высшие нужды (сон/секс) → рефлексы. - var intelligence = AnimalFactory.Intelligence( - o[i].Traits, - self.GetComponent().State - ); + var intelligence = AnimalFactory.Intelligence(o[i].Traits, health); + // Радиус восприятия по способностям: зрение ищет корм/партнёра/добычу, угрозу замечаем + // зрением ИЛИ слухом (повреждённые глаза/уши сужают восприятие). + var baseRadius = VisionRadius(o[i].Species, o[i].Traits.Vision); + var sight = health?.Capacity(AnimalCapacities.Sight) ?? 1f; + var hearing = health?.Capacity(AnimalCapacities.Hearing) ?? 1f; + var seeRadius = baseRadius * MathF.Max(0.2f, sight); + var senseRadius = baseRadius * MathF.Max(0.2f, MathF.Max(sight, hearing)); // Настроение (A8): стресс/истощение (низкое настроение) подавляет тягу к спариванию. var mood = self.GetComponent(); // Бегство (предатор-кластер): жертва, заметившая рядом хищника, спасается — это важнее // любых нужд (инстинкт выживания). Сам хищник от добычи не бежит (см. IsThreatTo). - if (TryFindThreat(pos, radius, o[i].Species, o[i].Traits, out var threatPos)) + if (TryFindThreat(pos, senseRadius, o[i].Species, o[i].Traits, out var threatPos)) { brain.Action = AnimalActions.Flee; brain.TargetPlant = -1; @@ -352,7 +356,7 @@ public sealed class AnimalDecisionSystem : BaseSystem var len = away.Length(); brain.Target = len > 0.001f - ? pos + away / len * (radius + _cellSize) + ? pos + away / len * (senseRadius + _cellSize) : pos + new Vector2(_cellSize, 0f); continue; } @@ -372,7 +376,7 @@ public sealed class AnimalDecisionSystem : BaseSystem when eatsMeat && TryFindKill( pos, - radius, + seeRadius, o[i].Species, o[i].Traits, self.Id, @@ -390,7 +394,7 @@ public sealed class AnimalDecisionSystem : BaseSystem when eatsPlants && TryFindForage( pos, - radius, + seeRadius, intelligence, o[i].Traits.ToxinTolerance, out var plant, @@ -415,7 +419,7 @@ public sealed class AnimalDecisionSystem : BaseSystem && TryFindMate( pos, o[i].IsMale, - radius, + seeRadius, out var mateId, out var matePos ): @@ -1760,7 +1764,12 @@ public sealed class AnimalHealthSystem : BaseSystem } } - var lethal = state.AdvanceHediffs(days); + // Фильтрация крови (почки/печень) ускоряет вывод токсинов и набор иммунитета: повреждённый + // орган → медленнее выздоровление от яда/болезни (для тела без неё Capacity вернёт 1). + var lethal = state.AdvanceHediffs( + days, + state.Capacity(AnimalCapacities.BloodFiltration) + ); // Кровопотеря от ран (кровотечения), иначе — постепенное восстановление крови в покое. var bleed = 0f; foreach (var hd in state.Hediffs)