mirror of
				https://gitgud.io/lutepickle/rjw_menstruation.git
				synced 2024-08-14 22:46:52 +00:00 
			
		
		
		
	Replace most instances of rjw part hediff lists with a simple check against the AllVaginas, etc lists
This commit is contained in:
		
							parent
							
								
									f08ff58b64
								
							
						
					
					
						commit
						5f97bd1433
					
				
					 4 changed files with 10 additions and 31 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
						 | 
					@ -22,7 +22,7 @@ namespace RJW_Menstruation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static IEnumerable<HediffComp_Menstruation> GetMenstruationComps(this Pawn pawn)
 | 
					        public static IEnumerable<HediffComp_Menstruation> GetMenstruationComps(this Pawn pawn)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            List<Hediff> hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll(h => VariousDefOf.AllVaginas.Contains(h.def));
 | 
					            List<Hediff> hedifflist = pawn.health.hediffSet.hediffs.FindAll(h => VariousDefOf.AllVaginas.Contains(h.def));
 | 
				
			||||||
            if (hedifflist == null) yield break;
 | 
					            if (hedifflist == null) yield break;
 | 
				
			||||||
            foreach (Hediff hediff in hedifflist)
 | 
					            foreach (Hediff hediff in hedifflist)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -63,17 +63,7 @@ namespace RJW_Menstruation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static HediffComp_Anus GetAnusComp(this Pawn pawn)
 | 
					        public static HediffComp_Anus GetAnusComp(this Pawn pawn)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            List<Hediff> hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn))?.FindAll((Hediff h) => h.def.defName.ToLower().Contains("anus"));
 | 
					            return pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff h) => VariousDefOf.AllAnuses.Contains(h.def))?.TryGetComp<HediffComp_Anus>();
 | 
				
			||||||
            HediffComp_Anus result;
 | 
					 | 
				
			||||||
            if (!hedifflist.NullOrEmpty())
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                foreach (Hediff h in hedifflist)
 | 
					 | 
				
			||||||
                {
 | 
					 | 
				
			||||||
                    result = h.TryGetComp<HediffComp_Anus>();
 | 
					 | 
				
			||||||
                    if (result != null) return result;
 | 
					 | 
				
			||||||
                }
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return null;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        [Obsolete("This method is obsolete and can cause ambiguity. Use GetMenstruationCompFromVagina or GetMenstruationCompFromPregnancy instead.", true)]
 | 
					        [Obsolete("This method is obsolete and can cause ambiguity. Use GetMenstruationCompFromVagina or GetMenstruationCompFromPregnancy instead.", true)]
 | 
				
			||||||
| 
						 | 
					@ -346,8 +336,8 @@ namespace RJW_Menstruation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static Texture2D GetAnalIcon(this Pawn pawn, bool drawOrigin = false)
 | 
					        public static Texture2D GetAnalIcon(this Pawn pawn, bool drawOrigin = false)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllAnuses.Contains(h.def)) ??
 | 
					            Hediff hediff = pawn.health.hediffSet.hediffs.FirstOrDefault(h => VariousDefOf.AllAnuses.Contains(h.def)) ??
 | 
				
			||||||
                Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault(h => h.def.defName.ToLower().Contains("anus"));
 | 
					                pawn.health.hediffSet.hediffs.FirstOrDefault(h => h.def.defName.ToLower().Contains("anus"));
 | 
				
			||||||
            if (hediff == null) return ContentFinder<Texture2D>.Get(("Genitals/Anal00"), true);
 | 
					            if (hediff == null) return ContentFinder<Texture2D>.Get(("Genitals/Anal00"), true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            string icon;
 | 
					            string icon;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -95,16 +95,7 @@ namespace RJW_Menstruation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static HediffComp_Breast GetBreastComp(this Pawn pawn)
 | 
					        public static HediffComp_Breast GetBreastComp(this Pawn pawn)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            List<Hediff> hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn))?.FindAll(h => VariousDefOf.AllBreasts.Contains(h.def));
 | 
					            return pawn.health.hediffSet.hediffs.FirstOrDefault((Hediff h) => VariousDefOf.AllBreasts.Contains(h.def))?.TryGetComp<HediffComp_Breast>();
 | 
				
			||||||
            if (hedifflist.NullOrEmpty()) hedifflist = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_uddersBPR(pawn))?.FindAll(h => VariousDefOf.AllBreasts.Contains(h.def));
 | 
					 | 
				
			||||||
            if (hedifflist.NullOrEmpty()) return null;
 | 
					 | 
				
			||||||
            HediffComp_Breast result;
 | 
					 | 
				
			||||||
            foreach (Hediff h in hedifflist)
 | 
					 | 
				
			||||||
            {
 | 
					 | 
				
			||||||
                result = h.TryGetComp<HediffComp_Breast>();
 | 
					 | 
				
			||||||
                if (result != null) return result;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return null;
 | 
					 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static HediffComp_Breast GetBreastComp(this Hediff hediff)
 | 
					        public static HediffComp_Breast GetBreastComp(this Hediff hediff)
 | 
				
			||||||
| 
						 | 
					@ -192,8 +183,7 @@ namespace RJW_Menstruation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static void DrawBreastIcon(this Pawn pawn, Rect rect)
 | 
					        public static void DrawBreastIcon(this Pawn pawn, Rect rect)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllBreasts.Contains(h.def)) ??
 | 
					            Hediff hediff = pawn.health.hediffSet.hediffs.FirstOrDefault(h => VariousDefOf.AllBreasts.Contains(h.def));
 | 
				
			||||||
                Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_uddersBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllBreasts.Contains(h.def));
 | 
					 | 
				
			||||||
            Texture2D breast, nipple, areola;
 | 
					            Texture2D breast, nipple, areola;
 | 
				
			||||||
            if (hediff != null)
 | 
					            if (hediff != null)
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
| 
						 | 
					@ -351,20 +341,19 @@ namespace RJW_Menstruation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        public static string GetVaginaLabel(this Pawn pawn)
 | 
					        public static string GetVaginaLabel(this Pawn pawn)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_genitalsBPR(pawn)).Find(h => VariousDefOf.AllVaginas.Contains(h.def));
 | 
					            Hediff hediff = pawn.health.hediffSet.hediffs.Find(h => VariousDefOf.AllVaginas.Contains(h.def));
 | 
				
			||||||
            return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")" + "\n" + xxx.CountOfSex.LabelCap.CapitalizeFirst() + ": " + pawn.records.GetAsInt(xxx.CountOfSex);
 | 
					            return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")" + "\n" + xxx.CountOfSex.LabelCap.CapitalizeFirst() + ": " + pawn.records.GetAsInt(xxx.CountOfSex);
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public static string GetAnusLabel(this Pawn pawn)
 | 
					        public static string GetAnusLabel(this Pawn pawn)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllAnuses.Contains(h.def)) ??
 | 
					            Hediff hediff = pawn.health.hediffSet.hediffs.FirstOrDefault(h => VariousDefOf.AllAnuses.Contains(h.def)) ??
 | 
				
			||||||
                Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault(h => h.def.defName.ToLower().Contains("anus"));
 | 
					                Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_anusBPR(pawn)).FirstOrDefault(h => h.def.defName.ToLower().Contains("anus"));
 | 
				
			||||||
            if (hediff != null) return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")";
 | 
					            if (hediff != null) return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")";
 | 
				
			||||||
            else return "";
 | 
					            else return "";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        public static string GetBreastLabel(this Pawn pawn)
 | 
					        public static string GetBreastLabel(this Pawn pawn)
 | 
				
			||||||
        {
 | 
					        {
 | 
				
			||||||
            Hediff hediff = Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_breastsBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllBreasts.Contains(h.def)) ??
 | 
					            Hediff hediff = pawn.health.hediffSet.hediffs.FirstOrDefault(h => VariousDefOf.AllBreasts.Contains(h.def));
 | 
				
			||||||
                Genital_Helper.get_PartsHediffList(pawn, Genital_Helper.get_uddersBPR(pawn)).FirstOrDefault(h => VariousDefOf.AllBreasts.Contains(h.def));
 | 
					 | 
				
			||||||
            if (hediff != null) return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")";
 | 
					            if (hediff != null) return hediff.LabelBase.CapitalizeFirst() + "\n(" + hediff.LabelInBrackets + ")";
 | 
				
			||||||
            else return "";
 | 
					            else return "";
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1,6 +1,6 @@
 | 
				
			||||||
Version 1.0.9.2
 | 
					Version 1.0.9.2
 | 
				
			||||||
 - Fixed the no bleeding gene having positive metabolic efficiency instead of negative.
 | 
					 - Fixed the no bleeding gene having positive metabolic efficiency instead of negative.
 | 
				
			||||||
 - Removed status button in health tab for non-genitals to avoid errors.
 | 
					 - Better handle wombs that are not in the genitals body part.
 | 
				
			||||||
 - Handle errors more gracefully when starting a pregnancy.
 | 
					 - Handle errors more gracefully when starting a pregnancy.
 | 
				
			||||||
 - Egglaying races no longer have a menstrual cycle, regardless of vagina type.
 | 
					 - Egglaying races no longer have a menstrual cycle, regardless of vagina type.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue