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,9 +9,21 @@ namespace ArachnaeSwarm
{
private const int EffectInterval = 600;
// 用于存储攻击者派系的字段
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)
{
base.Notify_PawnDied(dinfo, culprit);
@@ -59,7 +71,8 @@ namespace ArachnaeSwarm
return;
}
Faction faction = GetHostileFaction();
// **优先使用攻击者的派系,如果没有,则执行备用逻辑**
Faction faction = this.casterFaction ?? GetHostileFaction();
// **调用我们自己的工具方法传入从XML获取的mutantDef**
NecroticTransformationUtility.ResurrectAsCustomMutant(pawn, comp.Props.mutantDef, faction);
@@ -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");
}
}
}