From ede10ab87690f9d9b220b77fedb2c5129f8c0809 Mon Sep 17 00:00:00 2001 From: Stardust3D <3dstardust@gmail.com> Date: Thu, 3 Feb 2022 02:01:01 +0100 Subject: [PATCH] checking if Dyspareunia is loaded --- .../Recipe_Surgery_Sphinctoplasty.cs | 27 ++++++++++++++----- .../Recipe_Surgery_Vaginoplasty.cs | 27 ++++++++++++++----- 2 files changed, 42 insertions(+), 12 deletions(-) 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