Merge branch 'feature/refactoring' into develop

This commit is contained in:
Stardust3D 2022-10-19 18:51:26 +02:00
commit b6a5d1d3b5
7 changed files with 228 additions and 181 deletions

View file

@ -70,6 +70,7 @@
<ItemGroup>
<Compile Include="Mod.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Recipe_Plastic_Surgery.cs" />
<Compile Include="Recipe_Surgery_Mammoplasty.cs" />
<Compile Include="Recipe_Surgery_Penoplasty.cs" />
<Compile Include="Recipe_Surgery_Sphinctoplasty.cs" />

View file

@ -0,0 +1,55 @@
using System.Collections.Generic;
using Dyspareunia;
using RimWorld;
using rjw;
using Verse;
using DamageDefOf = Dyspareunia.DamageDefOf;
namespace RJW_PlasticSurgeries
{
public abstract class Recipe_Plastic_Surgery : Recipe_Surgery
{
protected readonly bool HasDyspareunia = ModLister.HasActiveModWithName("Dyspareunia");
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
{
var part = GetPartCandidate(pawn);
if (part != null)
{
var hediffs = Genital_Helper.get_PartsHediffList(pawn, part);
if (HasPart(pawn, hediffs)) yield return part;
}
}
protected abstract BodyPartRecord GetPartCandidate(Pawn pawn);
protected abstract bool HasPart(Pawn pawn, List<Hediff> hediffs);
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);
}
}
protected abstract void SurgeryResult(Pawn pawn);
private static void DamageHediff(Hediff hed)
{
PenetrationUtility.AddDamageHediff(DamageDefOf.SexStretch, 0.5f, hed, null);
}
protected void SurgeryX(Pawn pawn, float severity, bool useDyspareunia = false)
{
GetHediffs(pawn).ForEach(hed =>
{
hed.Severity = severity;
if (useDyspareunia && HasDyspareunia) DamageHediff(hed);
});
}
protected abstract List<Hediff> GetHediffs(Pawn pawn);
}
}

View file

@ -1,57 +1,39 @@
using System.Collections.Generic;
using System;
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 abstract class Recipe_Surgery_Mammoplasty : Recipe_Plastic_Surgery
{
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
protected override BodyPartRecord GetPartCandidate(Pawn pawn)
{
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;
}
return Genital_Helper.get_genitalsBPR(pawn);
}
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List<Thing> ingredients,
Bill bill)
protected override bool HasPart(Pawn pawn, List<Hediff> hediffs)
{
if (billDoer != null)
{
TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
SurgeryResult(pawn);
}
return Genital_Helper.has_breasts(pawn, hediffs) &&
pawn.GetBreastList().Any(hed => hed.Severity >= 0.02f);
}
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 override List<Hediff> GetHediffs(Pawn pawn)
{
throw new NotSupportedException();
}
protected void SurgeryCupX(Pawn pawn, int stage)
{
pawn.GetBreastList().ForEach(hed =>
{
float severity;
if (TryGetSeverityFromSize(hed, stage, out severity))
{
hed.Severity = severity;
}
if (TryGetSeverityFromSize(hed, stage, out severity)) hed.Severity = severity;
});
}
static bool TryGetSeverityFromSize(Hediff hediff, float cupSize, out float severity)
private static bool TryGetSeverityFromSize(Hediff hediff, float cupSize, out float severity)
{
if (!hediff.def.HasModExtension<PartSizeExtension>())
{
@ -77,91 +59,145 @@ namespace RJW_PlasticSurgeries
public class Recipe_Surgery_Mammoplasty_A : Recipe_Surgery_Mammoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryCupX(pawn, 1);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected 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);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryCupX(pawn, 31);
}
}
}

View file

@ -1,78 +1,65 @@
using System;
using System.Collections.Generic;
using Dyspareunia;
using RimWorld;
using System.Collections.Generic;
using rjw;
using Verse;
using DamageDefOf = Dyspareunia.DamageDefOf;
namespace RJW_PlasticSurgeries
{
public abstract class Recipe_Surgery_Penoplasty : Recipe_Surgery
public abstract class Recipe_Surgery_Penoplasty : Recipe_Plastic_Surgery
{
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
protected override BodyPartRecord GetPartCandidate(Pawn pawn)
{
var part = Genital_Helper.get_genitalsBPR(pawn);
if (part != null)
{
var hediffs = Genital_Helper.get_PartsHediffList(pawn, part);
if (Genital_Helper.has_penis_fertile(pawn, hediffs) ||
Genital_Helper.has_penis_infertile(pawn, hediffs)) yield return part;
}
return Genital_Helper.get_genitalsBPR(pawn);
}
/// <inheritdoc />
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List<Thing> ingredients,
Bill bill)
protected override bool HasPart(Pawn pawn, List<Hediff> hediffs)
{
if (billDoer != null)
{
TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
SurgeryResult(pawn);
}
return Genital_Helper.has_penis_fertile(pawn, hediffs) ||
Genital_Helper.has_penis_infertile(pawn, hediffs);
}
public abstract void SurgeryResult(Pawn pawn);
protected void SurgeryX(Pawn pawn, float severity)
protected override List<Hediff> GetHediffs(Pawn pawn)
{
pawn.GetGenitalsList().FindAll(Genital_Helper.is_penis).ForEach(hed =>
{
hed.Severity = severity;
try
{
PenetrationUtility.AddDamageHediff(DamageDefOf.SexStretch, 0.5f, hed, null);
}
catch (Exception e)
{
Log.Error("Try enabling Dyspareunia for sore genitals");
}
});
return pawn.GetGenitalsList().FindAll(Genital_Helper.is_penis);
}
}
public class Recipe_Surgery_Penoplasty_Micro : Recipe_Surgery_Penoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.1f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.1f, true);
}
}
public class Recipe_Surgery_Penoplasty_Small : Recipe_Surgery_Penoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.3f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.3f, true);
}
}
public class Recipe_Surgery_Penoplasty_Average : Recipe_Surgery_Penoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.5f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.5f, true);
}
}
public class Recipe_Surgery_Penoplasty_Large : Recipe_Surgery_Penoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.7f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.7f, true);
}
}
public class Recipe_Surgery_Penoplasty_Huge : Recipe_Surgery_Penoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.9f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.9f, true);
}
}
}

View file

@ -1,80 +1,64 @@
using System;
using System.Collections.Generic;
using Dyspareunia;
using RimWorld;
using System.Collections.Generic;
using rjw;
using Verse;
using DamageDefOf = Dyspareunia.DamageDefOf;
namespace RJW_PlasticSurgeries
{
public abstract class Recipe_Surgery_Sphinctoplasty : Recipe_Surgery
public abstract class Recipe_Surgery_Sphinctoplasty : Recipe_Plastic_Surgery
{
private readonly bool hasDyspareunia = ModLister.HasActiveModWithName("Dyspareunia");
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
protected override BodyPartRecord GetPartCandidate(Pawn pawn)
{
var part = Genital_Helper.get_anusBPR(pawn);
if (part != null)
{
var hediffs = Genital_Helper.get_PartsHediffList(pawn, part);
if (Genital_Helper.has_anus(pawn, hediffs)) yield return part;
}
return Genital_Helper.get_anusBPR(pawn);
}
/// <inheritdoc />
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List<Thing> ingredients,
Bill bill)
protected override bool HasPart(Pawn pawn, List<Hediff> hediffs)
{
if (billDoer != null)
{
TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
SurgeryResult(pawn);
}
return Genital_Helper.has_anus(pawn, hediffs);
}
public abstract void SurgeryResult(Pawn pawn);
protected void SurgeryX(Pawn pawn, float severity)
protected override List<Hediff> GetHediffs(Pawn pawn)
{
pawn.GetAnusList().ForEach(hed =>
{
hed.Severity = severity;
if (hasDyspareunia)
{
DamageHediff(hed);
}
});
}
private static void DamageHediff(Hediff hed)
{
PenetrationUtility.AddDamageHediff(DamageDefOf.SexStretch, 0.5f, hed, null);
return pawn.GetAnusList();
}
}
public class Recipe_Surgery_Sphinctoplasty_Micro : Recipe_Surgery_Sphinctoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.1f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.1f, true);
}
}
public class Recipe_Surgery_Sphinctoplasty_Tight : Recipe_Surgery_Sphinctoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.3f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.3f, true);
}
}
public class Recipe_Surgery_Sphinctoplasty_Average : Recipe_Surgery_Sphinctoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.5f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.5f, true);
}
}
public class Recipe_Surgery_Sphinctoplasty_Accomodating : Recipe_Surgery_Sphinctoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.7f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.7f, true);
}
}
public class Recipe_Surgery_Sphinctoplasty_Cavernous : Recipe_Surgery_Sphinctoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.9f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.9f, true);
}
}
}

View file

@ -1,80 +1,64 @@
using System;
using System.Collections.Generic;
using Dyspareunia;
using RimWorld;
using System.Collections.Generic;
using rjw;
using Verse;
using DamageDefOf = Dyspareunia.DamageDefOf;
namespace RJW_PlasticSurgeries
{
public abstract class Recipe_Surgery_Vaginoplasty : Recipe_Surgery
public abstract class Recipe_Surgery_Vaginoplasty : Recipe_Plastic_Surgery
{
private readonly bool hasDyspareunia = ModLister.HasActiveModWithName("Dyspareunia");
public override IEnumerable<BodyPartRecord> GetPartsToApplyOn(Pawn pawn, RecipeDef recipe)
protected override BodyPartRecord GetPartCandidate(Pawn pawn)
{
var part = Genital_Helper.get_genitalsBPR(pawn);
if (part != null)
{
var hediffs = Genital_Helper.get_PartsHediffList(pawn, part);
if (Genital_Helper.has_vagina(pawn, hediffs)) yield return part;
}
return Genital_Helper.get_genitalsBPR(pawn);
}
/// <inheritdoc />
public override void ApplyOnPawn(Pawn pawn, BodyPartRecord part, Pawn billDoer, List<Thing> ingredients,
Bill bill)
protected override bool HasPart(Pawn pawn, List<Hediff> hediffs)
{
if (billDoer != null)
{
TaleRecorder.RecordTale(TaleDefOf.DidSurgery, billDoer, pawn);
SurgeryResult(pawn);
}
return Genital_Helper.has_vagina(pawn, hediffs);
}
public abstract void SurgeryResult(Pawn pawn);
protected void SurgeryX(Pawn pawn, float severity)
protected override List<Hediff> GetHediffs(Pawn pawn)
{
pawn.GetGenitalsList().FindAll(Genital_Helper.is_vagina).ForEach(hed =>
{
hed.Severity = severity;
if (hasDyspareunia)
{
DamageHediff(hed);
}
});
}
private static void DamageHediff(Hediff hed)
{
PenetrationUtility.AddDamageHediff(DamageDefOf.SexStretch, 0.5f, hed, null);
return pawn.GetGenitalsList().FindAll(Genital_Helper.is_vagina);
}
}
public class Recipe_Surgery_Vaginoplasty_Micro : Recipe_Surgery_Vaginoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.1f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.1f, true);
}
}
public class Recipe_Surgery_Vaginoplasty_Tight : Recipe_Surgery_Vaginoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.3f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.3f, true);
}
}
public class Recipe_Surgery_Vaginoplasty_Average : Recipe_Surgery_Vaginoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.5f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.5f, true);
}
}
public class Recipe_Surgery_Vaginoplasty_Accomodating : Recipe_Surgery_Vaginoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.7f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.7f, true);
}
}
public class Recipe_Surgery_Vaginoplasty_Cavernous : Recipe_Surgery_Vaginoplasty
{
public override void SurgeryResult(Pawn pawn) => SurgeryX(pawn, 0.9f);
protected override void SurgeryResult(Pawn pawn)
{
SurgeryX(pawn, 0.9f, true);
}
}
}

View file

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists