Files
WulaFallenEmpireRW/Source/WulaFallenEmpire/Cinder_WeaponSwitch/CompAbilityEffect_RemoveSwitchHediff.cs
2025-08-21 15:39:46 +08:00

33 lines
1.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using RimWorld;
using Verse;
namespace WulaFallenEmpire
{
public class CompAbilityEffect_RemoveSwitchHediff : CompAbilityEffect
{
public new CompProperties_AbilityRemoveHediff Props => (CompProperties_AbilityRemoveHediff)props;
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
{
base.Apply(target, dest);
Hediff firstHediffOfDef = parent.pawn.health.hediffSet.GetFirstHediffOfDef(Props.hediffDef);
if (firstHediffOfDef != null)
{
parent.pawn.health.RemoveHediff(firstHediffOfDef);
}
}
public override bool ShouldHideGizmo
{
get
{
// 如果父级Pawn没有这个Hediff就隐藏“移除”按钮
if (!parent.pawn?.health.hediffSet.HasHediff(Props.hediffDef) ?? true)
{
return true;
}
return base.ShouldHideGizmo;
}
}
}
}