using System.Collections.Generic;
using RimWorld;
using Verse;
using static RimWorld.TraitDefOf;
namespace RJW_PlasticSurgeries
{
///
public abstract class Recipe_Surgery_Beautify : Recipe_Surgery
{
///
public override IEnumerable GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
{
if (!pawn.story.traits.HasTrait(Beauty) ||
pawn.story.traits.HasTrait(Beauty) && pawn.story.traits.GetTrait(Beauty).Degree < 2)
yield return pawn.RaceProps.body.corePart;
}
///
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List ingredients,
Bill bill)
{
if (billDoer != null)
{
TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
SurgeryResult(pawn);
}
}
///
///
///
///
public abstract void SurgeryResult(Pawn pawn);
///
/// Setts the severity of the Beautiful trait for the selected pawn.
/// If the trait doesn't exist in the pawns traits, it will be added.
///
/// the pawn to modify
/// the new severity of the pawn's Beautiful trait
protected void SurgeryX(Pawn pawn, int severity)
{
if (pawn.story.traits.HasTrait(Beauty))
{
pawn.story.traits.allTraits.FindAll(t => Beauty.ConflictsWith(t))
.ForEach(t => pawn.story.traits.RemoveTrait(t));
pawn.story.traits.RemoveTrait(pawn.story.traits.allTraits.Find(t => t.def == Beauty));
}
pawn.story.traits.GainTrait(new Trait(Beauty, severity));
}
}
///
public class Recipe_Surgery_Beautify_Beautiful : Recipe_Surgery_Beautify
{
///
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 2);
}
}