diff --git a/Source/RJW_PlasticSurgeries/Recipe_Surgery_Sphinctoplasty.cs b/Source/RJW_PlasticSurgeries/Recipe_Surgery_Sphinctoplasty.cs index c2f1e83..09c6092 100644 --- a/Source/RJW_PlasticSurgeries/Recipe_Surgery_Sphinctoplasty.cs +++ b/Source/RJW_PlasticSurgeries/Recipe_Surgery_Sphinctoplasty.cs @@ -10,6 +10,20 @@ namespace RJW_PlasticSurgeries { public abstract class Recipe_Surgery_Sphinctoplasty : Recipe_Surgery { + private readonly bool hasDyspareunia; + + public Recipe_Surgery_Sphinctoplasty() + { + try + { + hasDyspareunia = Type.GetType("Dyspareunia.PenetrationUtility").ToString() != null; + } + catch (Exception e) + { + hasDyspareunia = false; + } + } + public override IEnumerable GetPartsToApplyOn(Pawn pawn, RecipeDef recipe) { var part = Genital_Helper.get_anusBPR(pawn); @@ -38,16 +52,17 @@ namespace RJW_PlasticSurgeries pawn.GetAnusList().ForEach(hed => { hed.Severity = severity; - try + if (hasDyspareunia) { - PenetrationUtility.AddDamageHediff(DamageDefOf.SexStretch, 0.5f, hed, null); - } - catch (Exception e) - { - Log.Error("Try enabling Dyspareunia for sore genitals"); + DamageHediff(hed); } }); } + + private static void DamageHediff(Hediff hed) + { + PenetrationUtility.AddDamageHediff(DamageDefOf.SexStretch, 0.5f, hed, null); + } } public class Recipe_Surgery_Sphinctoplasty_Micro : Recipe_Surgery_Sphinctoplasty diff --git a/Source/RJW_PlasticSurgeries/Recipe_Surgery_Vaginoplasty.cs b/Source/RJW_PlasticSurgeries/Recipe_Surgery_Vaginoplasty.cs index 14938c5..dae54f3 100644 --- a/Source/RJW_PlasticSurgeries/Recipe_Surgery_Vaginoplasty.cs +++ b/Source/RJW_PlasticSurgeries/Recipe_Surgery_Vaginoplasty.cs @@ -10,6 +10,20 @@ namespace RJW_PlasticSurgeries { public abstract class Recipe_Surgery_Vaginoplasty : Recipe_Surgery { + private readonly bool hasDyspareunia; + + public Recipe_Surgery_Vaginoplasty() + { + try + { + hasDyspareunia = Type.GetType("Dyspareunia.PenetrationUtility").ToString() != null; + } + catch (Exception e) + { + hasDyspareunia = false; + } + } + public override IEnumerable GetPartsToApplyOn(Pawn pawn, RecipeDef recipe) { var part = Genital_Helper.get_genitalsBPR(pawn); @@ -38,16 +52,17 @@ namespace RJW_PlasticSurgeries pawn.GetGenitalsList().FindAll(Genital_Helper.is_vagina).ForEach(hed => { hed.Severity = severity; - try + if (hasDyspareunia) { - PenetrationUtility.AddDamageHediff(DamageDefOf.SexStretch, 0.5f, hed, null); - } - catch (Exception e) - { - Log.Error("Try enabling Dyspareunia for sore genitals"); + DamageHediff(hed); } }); } + + private static void DamageHediff(Hediff hed) + { + PenetrationUtility.AddDamageHediff(DamageDefOf.SexStretch, 0.5f, hed, null); + } } public class Recipe_Surgery_Vaginoplasty_Micro : Recipe_Surgery_Vaginoplasty