89 lines
3.7 KiB
C#
89 lines
3.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using RimWorld;
|
|
using Verse;
|
|
using Verse.Sound;
|
|
|
|
namespace Implants
|
|
{
|
|
|
|
public class LTS_CompProperties_CaptiveControl : CompProperties_AbilityEffect
|
|
{
|
|
public LTS_CompProperties_CaptiveControl()
|
|
{
|
|
this.compClass = typeof(LTS_CompAbilityEffect_CaptiveControl);
|
|
}
|
|
public HediffDef hediffDef;
|
|
public float StartSeverity;
|
|
public string location = null;
|
|
public int duration = 3600; // 1 hour
|
|
public bool headExploder = false;
|
|
public bool hediffToggle = false;
|
|
}
|
|
|
|
public class LTS_CompAbilityEffect_CaptiveControl : CompAbilityEffect
|
|
{
|
|
public new LTS_CompProperties_CaptiveControl Props
|
|
{
|
|
get
|
|
{
|
|
return (LTS_CompProperties_CaptiveControl)this.props;
|
|
}
|
|
}
|
|
|
|
public override void Apply(LocalTargetInfo target, LocalTargetInfo dest)
|
|
{
|
|
base.Apply(target, dest);
|
|
|
|
if (target.Pawn != null)
|
|
{
|
|
if (Props.headExploder)
|
|
{
|
|
if (EffecterDefOf.MeatExplosion != null)
|
|
{
|
|
EffecterDefOf.MeatExplosion.Spawn(parent.pawn.PositionHeld, parent.pawn.MapHeld).Cleanup();
|
|
}
|
|
SoundDefOf.CocoonDestroyed.PlayOneShot(new TargetInfo(target.Pawn.Position, target.Pawn.Map));
|
|
target.Pawn.TakeDamage(new DamageInfo(DamageDefOf.Crush, 100, 0, -1, null, target.Pawn.health.hediffSet.GetBodyPartRecord(BodyPartDefOf.Head)));
|
|
//target.Pawn.TakeDamage(new DamageInfo(DamageDefOf.Bomb, 100, 0, -1, null, target.Pawn.health.hediffSet.GetBodyPartRecord(BodyPartDefOf.Head)));
|
|
}
|
|
else if (Props.hediffToggle)
|
|
{
|
|
if (target.Pawn.health?.hediffSet?.GetFirstHediffOfDef(this.Props.hediffDef) != null)
|
|
{
|
|
target.Pawn.health.RemoveHediff(target.Pawn.health.hediffSet.GetFirstHediffOfDef(this.Props.hediffDef));
|
|
}
|
|
else
|
|
{
|
|
target.Pawn.health.AddHediff(this.Props.hediffDef, location(target));
|
|
if (target.Pawn.health.hediffSet.GetFirstHediffOfDef(this.Props.hediffDef).TryGetComp<HediffComp_Lactating>() != null)
|
|
{
|
|
target.Pawn.health.hediffSet.GetFirstHediffOfDef(this.Props.hediffDef).TryGetComp<HediffComp_Lactating>().TryCharge(-0.124f);
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
target.Pawn.health.AddHediff(this.Props.hediffDef, location(target));
|
|
if (target.Pawn.health.hediffSet.GetFirstHediffOfDef(this.Props.hediffDef).TryGetComp<HediffComp_Disappears>() != null)
|
|
{
|
|
target.Pawn.health.hediffSet.GetFirstHediffOfDef(this.Props.hediffDef).TryGetComp<HediffComp_Disappears>().ticksToDisappear = Props.duration;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public BodyPartRecord location(LocalTargetInfo target)
|
|
{
|
|
if (Props.location == null) { return null; }
|
|
|
|
//return target.Pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined).Where(part => part.def.tags.Contains(BodyPartTagDefOf.ManipulationLimbSegment)).ToList()[0];
|
|
return target.Pawn.health.hediffSet.GetNotMissingParts(BodyPartHeight.Undefined, BodyPartDepth.Undefined).Where(part => part.def.defName == Props.location).ToList()[0];
|
|
}
|
|
}
|
|
|
|
}
|