diff --git a/1.4/Assemblies/RJW_Menstruation.dll b/1.4/Assemblies/RJW_Menstruation.dll index 274ae52..9933165 100644 Binary files a/1.4/Assemblies/RJW_Menstruation.dll and b/1.4/Assemblies/RJW_Menstruation.dll differ diff --git a/1.4/MilkModule/Assemblies/MilkModule.dll b/1.4/MilkModule/Assemblies/MilkModule.dll index f652412..66a2076 100644 Binary files a/1.4/MilkModule/Assemblies/MilkModule.dll and b/1.4/MilkModule/Assemblies/MilkModule.dll differ diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Breast.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Breast.cs index 1d5eb60..71e930c 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Breast.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/HediffComps/HediffComp_Breast.cs @@ -356,7 +356,7 @@ namespace RJW_Menstruation { baseAreola = Mathf.Clamp01(baseAreola + amount); UpdateNipples(); - } + } public void UpdateNipples() { @@ -365,7 +365,7 @@ namespace RJW_Menstruation cachedNipple = baseNipple + nippleProgress * nippleChange; // For some reason, Props can go null when RJW relocates the chest (e.g. some animals), so catch that - cachedColor = Colors.CMYKLerp(Pawn.story?.SkinColor ?? Color.white, (Props?.BlackNippleColor ?? CompProperties_Breast.DefaultBlacknippleColor.ToColor), Alpha); + cachedColor = Colors.CMYKLerp(Utility.SafeSkinColor(Pawn), (Props?.BlackNippleColor ?? CompProperties_Breast.DefaultBlacknippleColor.ToColor), Alpha); } public void CopyBreastProperties(HediffComp_Breast original) diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs index 2d802d6..8e3f4e9 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Biotech_Patch.cs @@ -192,6 +192,20 @@ namespace RJW_Menstruation } } + [HarmonyPatch(typeof(Pawn_GeneTracker), "AddGene", new Type[] {typeof(Gene), typeof(bool)})] + public class AddGene_Patch + { + public static bool Prefix(ref Gene __result, Gene gene, Pawn ___pawn) + { + if(VariousDefOf.WombGenes.Contains(gene.def) && !___pawn.GetMenstruationComps().Any()) + { + __result = null; + return false; + } + else return true; + } + } + [HarmonyPatch(typeof(Pawn_GeneTracker), "Notify_GenesChanged")] public class Notify_GenesChanged_Patch { diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/UI/Dialog_WombStatus.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/UI/Dialog_WombStatus.cs index 82b3ced..4d428a9 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/UI/Dialog_WombStatus.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/UI/Dialog_WombStatus.cs @@ -394,7 +394,7 @@ namespace RJW_Menstruation anal = pawn.GetAnalIcon(showOrigin); GUI.color = new Color(1.00f, 0.47f, 0.47f, 1); GUI.Box(rect, "", boxstyle); - GUI.color = pawn.story.SkinColor; + GUI.color = Utility.SafeSkinColor(pawn); //Widgets.DrawTextureFitted(genitalIconRect, anal, 1.0f); //Widgets.DrawTextureFitted(genitalIconRect, vagina, 1.0f); GUI.DrawTexture(genitalIconRect, anal, ScaleMode.ScaleToFit); diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/Utility.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/Utility.cs index 29ffb97..406a54c 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/Utility.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/Utility.cs @@ -209,7 +209,7 @@ namespace RJW_Menstruation nipple = ContentFinder.Get("Breasts/Breast_Breast00_Nipple00", false); areola = ContentFinder.Get("Breasts/Breast_Breast00_Areola00", false); - GUI.color = pawn.story?.SkinColor ?? Color.white; + GUI.color = SafeSkinColor(pawn); GUI.DrawTexture(rect, breast, ScaleMode.ScaleToFit); GUI.color = Color.white; GUI.DrawTexture(rect, areola, ScaleMode.ScaleToFit); @@ -236,7 +236,7 @@ namespace RJW_Menstruation breast = ContentFinder.Get(icon, false); areola = ContentFinder.Get(areolaicon, false); nipple = ContentFinder.Get(nippleicon, false); - GUI.color = pawn.story.SkinColor; + GUI.color = SafeSkinColor(pawn); GUI.DrawTexture(rect, breast, ScaleMode.ScaleToFit); GUI.color = comp.NippleColor; @@ -255,7 +255,7 @@ namespace RJW_Menstruation nipple = ContentFinder.Get("Breasts/Breast_Breast00_Nipple00", false); areola = ContentFinder.Get("Breasts/Breast_Breast00_Areola00", false); - GUI.color = pawn.story.SkinColor; + GUI.color = SafeSkinColor(pawn); GUI.DrawTexture(rect, breast, ScaleMode.ScaleToFit); GUI.color = Color.white; GUI.DrawTexture(rect, areola, ScaleMode.ScaleToFit); @@ -454,5 +454,18 @@ namespace RJW_Menstruation if (pawn.IsAnimal() && !Configurations.EnableAnimalCycle) return false; return true; } + + // Apparently with some mods, even doing pawn.story?.SkinColor can throw a null reference, so we're stuck doing this + public static Color SafeSkinColor(Pawn pawn) + { + try + { + return pawn.story?.SkinColor ?? Color.white; + } + catch (NullReferenceException) + { + return Color.white; + } + } } } diff --git a/1.4/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs b/1.4/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs index 9917653..7f368cc 100644 --- a/1.4/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs +++ b/1.4/source/RJW_Menstruation/RJW_Menstruation/VariousDefOf.cs @@ -53,6 +53,16 @@ namespace RJW_Menstruation public static readonly GeneDef QuadOvulation = DefDatabase.GetNamed("Menstruation_QuadOvulation"); public static readonly GeneDef NoBleeding = DefDatabase.GetNamed("Menstruation_NoBleeding"); + public static readonly HashSet WombGenes = new HashSet() { + ShortEggLifetime, + DoubleEggLifetime, + QuadEggLifetime, + NeverEstrus, + FullEstrus, + DoubleOvulation, + QuadOvulation, + NoBleeding }; + private static List allraces = null; private static List allkinds = null; private static HashSet allvaginas = null;