54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using RimWorld;
|
|
using RimWorld.Planet;
|
|
using Verse;
|
|
|
|
namespace ArachnaeSwarm
|
|
{
|
|
public class CompProperties_AbilityNeedCost : CompProperties_AbilityEffect
|
|
{
|
|
public NeedDef needDef;
|
|
public float needCost;
|
|
public string failMessage;
|
|
|
|
public CompProperties_AbilityNeedCost()
|
|
{
|
|
compClass = typeof(CompAbilityEffect_NeedCost);
|
|
}
|
|
}
|
|
|
|
public class CompAbilityEffect_NeedCost : CompAbilityEffect
|
|
{
|
|
public new CompProperties_AbilityNeedCost Props => (CompProperties_AbilityNeedCost)props;
|
|
|
|
public override bool GizmoDisabled(out string reason)
|
|
{
|
|
Pawn caster = parent.pawn;
|
|
if (caster != null && caster.needs != null)
|
|
{
|
|
if (caster.needs.TryGetNeed(Props.needDef, out Need need))
|
|
{
|
|
if (need.CurLevel < Props.needCost)
|
|
{
|
|
reason = Props.failMessage;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
reason = null;
|
|
return false;
|
|
}
|
|
|
|
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
|
|
{
|
|
base.Apply(target, dest);
|
|
Pawn caster = parent.pawn;
|
|
if (caster != null && caster.needs != null)
|
|
{
|
|
if (caster.needs.TryGetNeed(Props.needDef, out Need need))
|
|
{
|
|
need.CurLevel -= Props.needCost;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |