diff --git a/1.6/1.6/Assemblies/ArachnaeSwarm.dll b/1.6/1.6/Assemblies/ArachnaeSwarm.dll index eb03a52..389feb2 100644 Binary files a/1.6/1.6/Assemblies/ArachnaeSwarm.dll and b/1.6/1.6/Assemblies/ArachnaeSwarm.dll differ diff --git a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj index c6152d2..cd753c7 100644 --- a/Source/ArachnaeSwarm/ArachnaeSwarm.csproj +++ b/Source/ArachnaeSwarm/ArachnaeSwarm.csproj @@ -190,6 +190,7 @@ + diff --git a/Source/ArachnaeSwarm/HediffComp_Symbiosis.cs b/Source/ArachnaeSwarm/HediffComp_Symbiosis.cs new file mode 100644 index 0000000..3b0c5c2 --- /dev/null +++ b/Source/ArachnaeSwarm/HediffComp_Symbiosis.cs @@ -0,0 +1,61 @@ +using Verse; +using RimWorld; + +namespace ArachnaeSwarm +{ + /// + /// XML配置类:定义共生关系 + /// + public class HediffCompProperties_Symbiosis : HediffCompProperties + { + // 实现共存所需的Hediff + public HediffDef requiredHediff; + + // 共存状态下的最大严重性 + public float newMaxSeverity = 0.9f; + + public HediffCompProperties_Symbiosis() + { + compClass = typeof(HediffComp_Symbiosis); + } + } + + /// + /// HediffComp:实现共生逻辑 + /// + public class HediffComp_Symbiosis : HediffComp + { + private HediffCompProperties_Symbiosis Props => (HediffCompProperties_Symbiosis)props; + + // 重写CompPostTick,它会在游戏每一帧,在计算完严重性增量之后,应用增量之前被调用 + public override void CompPostTick(ref float severityAdjustment) + { + base.CompPostTick(ref severityAdjustment); + + // 检查宿主Pawn是否存在,以及配置是否完整 + if (this.Pawn == null || Props.requiredHediff == null) + { + return; + } + + // 检查Pawn是否拥有“共存”所需的Hediff + if (this.Pawn.health.hediffSet.HasHediff(Props.requiredHediff)) + { + // 如果当前严重性已经达到或超过上限 + if (this.parent.Severity >= Props.newMaxSeverity) + { + // 将当前严重性强制拉回到上限 + this.parent.Severity = Props.newMaxSeverity; + // 并且,阻止任何将要发生的严重性增加(将增量设为0) + severityAdjustment = 0; + } + // 如果当前严重性加上即将发生的增量会超过上限 + else if (this.parent.Severity + severityAdjustment > Props.newMaxSeverity) + { + // 重新计算增量,使其恰好达到上限 + severityAdjustment = Props.newMaxSeverity - this.parent.Severity; + } + } + } + } +} \ No newline at end of file diff --git a/Source/ArachnaeSwarm/NecroticTransformationUtility.cs b/Source/ArachnaeSwarm/NecroticTransformationUtility.cs index 5b1e79a..f3bdf0b 100644 --- a/Source/ArachnaeSwarm/NecroticTransformationUtility.cs +++ b/Source/ArachnaeSwarm/NecroticTransformationUtility.cs @@ -11,28 +11,9 @@ namespace ArachnaeSwarm /// public static bool CanResurrect(Corpse corpse, bool ignoreIndoors = false) { + // 只保留最核心、最必要的检查,移除所有可能导致不稳定的条件 if (corpse?.InnerPawn == null) return false; if (!corpse.InnerPawn.RaceProps.IsFlesh) return false; - // 我们移除了对 corpse.InnerPawn.RaceProps.canBecomeShambler 的检查 - if (corpse.InnerPawn.IsMutant) return false; - if (corpse is UnnaturalCorpse) return false; - - Room room = corpse.PositionHeld.GetRoom(corpse.MapHeld); - if (room != null && !ignoreIndoors && corpse.PositionHeld.Roofed(corpse.MapHeld) && (room.ProperRoom || room.IsDoorway)) - { - return false; - } - - if (!Find.Storyteller.difficulty.childShamblersAllowed && !corpse.InnerPawn.ageTracker.Adult) - { - return false; - } - - Hediff_DeathRefusal firstHediff = corpse.InnerPawn.health.hediffSet.GetFirstHediff(); - if (firstHediff != null && (firstHediff.InProgress || firstHediff.UsesLeft > 0)) - { - return false; - } return true; }