rjw-plasticsurgeries/Source/RJW_PlasticSurgeries/Recipe_Surgery_Mammoplasty.cs
2022-01-15 22:54:53 +01:00

167 lines
No EOL
5.5 KiB
C#

using System.Collections.Generic;
using System.Linq;
using RimWorld;
using rjw;
using Verse;
namespace RJW_PlasticSurgeries
{
public abstract class Recipe_Surgery_Mammoplasty : Recipe_Surgery
{
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
{
var part = Genital_Helper.get_genitalsBPR(pawn);
if (part != null)
{
var hediffs = Genital_Helper.get_PartsHediffList(pawn, part);
if (Genital_Helper.has_breasts(pawn, hediffs) && pawn.GetBreastList().Any(hed => hed.Severity >= 0.02f))
yield return part;
}
}
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List<Thing> ingredients,
Bill bill)
{
if (billDoer != null)
{
TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
SurgeryResult(pawn);
}
}
public abstract void SurgeryResult(Pawn pawn);
/*{
pawn.GetBreastList().ForEach(hed => hed.Severity = Math.Min(1.0f, hed.Severity * 1.25f));
//Log.Message($"Cup sizes: {pawn.GetBreastList().SelectMany(hed => hed.def.GetModExtension<PartSizeExtension>().cupSizes.Join()).Join(delimiter: ";")}");
float val = 0;
PartSizeExtension.TryGetCupSize(pawn.GetBreastList().First(), out val);
pawn.GetBreastList().First().def.stages.First();
Log.Message($"Cup size: {val}");
}*/
protected void SurgeryCupX(Pawn pawn, int stage)
{
pawn.GetBreastList().ForEach(hed =>
{
float severity;
if (TryGetSeverityFromSize(hed, stage, out severity))
{
hed.Severity = severity;
}
});
}
static bool TryGetSeverityFromSize(Hediff hediff, float cupSize, out float severity)
{
if (!hediff.def.HasModExtension<PartSizeExtension>())
{
severity = 0f;
return false;
}
var extension = hediff.def.GetModExtension<PartSizeExtension>();
var list = extension.cupSizes;
if (list == null)
{
severity = 0f;
return false;
}
var curve = new SimpleCurve(hediff.def.stages.Zip(list,
(stage, s) => new CurvePoint(s, stage.minSeverity)));
severity = curve.Evaluate(cupSize);
return true;
}
}
public class Recipe_Surgery_Mammoplasty_A : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 1);
}
public class Recipe_Surgery_Mammoplasty_B : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 2);
}
public class Recipe_Surgery_Mammoplasty_C : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 3);
}
public class Recipe_Surgery_Mammoplasty_D : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 4);
}
public class Recipe_Surgery_Mammoplasty_E : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 6);
}
public class Recipe_Surgery_Mammoplasty_F : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 7);
}
public class Recipe_Surgery_Mammoplasty_G : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 9);
}
public class Recipe_Surgery_Mammoplasty_H : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 11);
}
public class Recipe_Surgery_Mammoplasty_J : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 13);
}
public class Recipe_Surgery_Mammoplasty_K : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 15);
}
public class Recipe_Surgery_Mammoplasty_L : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 17);
}
public class Recipe_Surgery_Mammoplasty_M : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 19);
}
public class Recipe_Surgery_Mammoplasty_N : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 21);
}
public class Recipe_Surgery_Mammoplasty_O : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 23);
}
public class Recipe_Surgery_Mammoplasty_P : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 25);
}
public class Recipe_Surgery_Mammoplasty_Q : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 27);
}
public class Recipe_Surgery_Mammoplasty_R : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 29);
}
public class Recipe_Surgery_Mammoplasty_Unknown : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 31);
}
}