This commit is contained in:
2025-09-10 17:41:53 +08:00
parent 12e860d637
commit d18f489113
2 changed files with 26 additions and 7 deletions

Binary file not shown.

View File

@@ -9,10 +9,22 @@ namespace ArachnaeSwarm
{
private const int EffectInterval = 600;
// 属性来获取我们的自定义Comp
private HediffComp_NecroticTransformation PropsComp => this.TryGetComp<HediffComp_NecroticTransformation>();
// 用于存储攻击者派系的字段
private Faction casterFaction;
// 属性来获取我们的自定义Comp
private HediffComp_NecroticTransformation PropsComp => this.TryGetComp<HediffComp_NecroticTransformation>();
public override void PostAdd(DamageInfo? dinfo)
{
base.PostAdd(dinfo);
if (dinfo.HasValue && dinfo.Value.Instigator != null)
{
this.casterFaction = dinfo.Value.Instigator.Faction;
}
}
public override void Notify_PawnDied(DamageInfo? dinfo, Hediff culprit = null)
public override void Notify_PawnDied(DamageInfo? dinfo, Hediff culprit = null)
{
base.Notify_PawnDied(dinfo, culprit);
TransformToMutant();
@@ -59,10 +71,11 @@ namespace ArachnaeSwarm
return;
}
Faction faction = GetHostileFaction();
// **调用我们自己的工具方法传入从XML获取的mutantDef**
NecroticTransformationUtility.ResurrectAsCustomMutant(pawn, comp.Props.mutantDef, faction);
// **优先使用攻击者的派系,如果没有,则执行备用逻辑**
Faction faction = this.casterFaction ?? GetHostileFaction();
// **调用我们自己的工具方法传入从XML获取的mutantDef**
NecroticTransformationUtility.ResurrectAsCustomMutant(pawn, comp.Props.mutantDef, faction);
// **关键修复在成功转化后立即移除导致转化的Hediff本身防止其残留**
pawn.health.RemoveHediff(this);
@@ -124,5 +137,11 @@ namespace ArachnaeSwarm
return base.TipStringExtra + "\n" + "NecroticVirus_EffectTip".Translate();
}
}
public override void ExposeData()
{
base.ExposeData();
Scribe_References.Look(ref this.casterFaction, "casterFaction");
}
}
}