暂存
This commit is contained in:
Binary file not shown.
@@ -190,6 +190,7 @@
|
||||
<Compile Include="NecroticTransformationUtility.cs" />
|
||||
<Compile Include="ProphecyGearEffect.cs" />
|
||||
<Compile Include="Hediff_ConfigurableMutant.cs" />
|
||||
<Compile Include="HediffComp_Symbiosis.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<!-- 自定义清理任务,删除obj文件夹中的临时文件 -->
|
||||
|
||||
61
Source/ArachnaeSwarm/HediffComp_Symbiosis.cs
Normal file
61
Source/ArachnaeSwarm/HediffComp_Symbiosis.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Verse;
|
||||
using RimWorld;
|
||||
|
||||
namespace ArachnaeSwarm
|
||||
{
|
||||
/// <summary>
|
||||
/// XML配置类:定义共生关系
|
||||
/// </summary>
|
||||
public class HediffCompProperties_Symbiosis : HediffCompProperties
|
||||
{
|
||||
// 实现共存所需的Hediff
|
||||
public HediffDef requiredHediff;
|
||||
|
||||
// 共存状态下的最大严重性
|
||||
public float newMaxSeverity = 0.9f;
|
||||
|
||||
public HediffCompProperties_Symbiosis()
|
||||
{
|
||||
compClass = typeof(HediffComp_Symbiosis);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// HediffComp:实现共生逻辑
|
||||
/// </summary>
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -11,28 +11,9 @@ namespace ArachnaeSwarm
|
||||
/// </summary>
|
||||
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<Hediff_DeathRefusal>();
|
||||
if (firstHediff != null && (firstHediff.InProgress || firstHediff.UsesLeft > 0))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user