Compare commits

...

2 commits

7 changed files with 43 additions and 6 deletions

Binary file not shown.

View file

@ -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)

View file

@ -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
{

View file

@ -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);

View file

@ -209,7 +209,7 @@ namespace RJW_Menstruation
nipple = ContentFinder<Texture2D>.Get("Breasts/Breast_Breast00_Nipple00", false);
areola = ContentFinder<Texture2D>.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<Texture2D>.Get(icon, false);
areola = ContentFinder<Texture2D>.Get(areolaicon, false);
nipple = ContentFinder<Texture2D>.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<Texture2D>.Get("Breasts/Breast_Breast00_Nipple00", false);
areola = ContentFinder<Texture2D>.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;
}
}
}
}

View file

@ -53,6 +53,16 @@ namespace RJW_Menstruation
public static readonly GeneDef QuadOvulation = DefDatabase<GeneDef>.GetNamed("Menstruation_QuadOvulation");
public static readonly GeneDef NoBleeding = DefDatabase<GeneDef>.GetNamed("Menstruation_NoBleeding");
public static readonly HashSet<GeneDef> WombGenes = new HashSet<GeneDef>() {
ShortEggLifetime,
DoubleEggLifetime,
QuadEggLifetime,
NeverEstrus,
FullEstrus,
DoubleOvulation,
QuadOvulation,
NoBleeding };
private static List<ThingDef> allraces = null;
private static List<PawnKindDef> allkinds = null;
private static HashSet<HediffDef> allvaginas = null;