mirror of
				https://gitgud.io/lutepickle/rjw_menstruation.git
				synced 2024-08-14 22:46:52 +00:00 
			
		
		
		
	Simplify a bunch of for loops into functions
This commit is contained in:
		
							parent
							
								
									aa81fae8bd
								
							
						
					
					
						commit
						92fab44764
					
				
					 3 changed files with 12 additions and 51 deletions
				
			
		
										
											Binary file not shown.
										
									
								
							| 
						 | 
				
			
			@ -136,39 +136,24 @@ namespace RJW_Menstruation
 | 
			
		|||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                float res = 0;
 | 
			
		||||
                if (cums.NullOrEmpty()) return 0;
 | 
			
		||||
                foreach (Cum cum in cums)
 | 
			
		||||
                {
 | 
			
		||||
                    res += cum.Volume;
 | 
			
		||||
                }
 | 
			
		||||
                return res;
 | 
			
		||||
                return cums.Sum(cum => cum.Volume);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public float TotalFertCum
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                float res = 0;
 | 
			
		||||
                if (cums.NullOrEmpty()) return 0;
 | 
			
		||||
                foreach (Cum cum in cums)
 | 
			
		||||
                {
 | 
			
		||||
                    if (!cum.notcum) res += cum.FertVolume;
 | 
			
		||||
                }
 | 
			
		||||
                return res;
 | 
			
		||||
                return cums.Sum(cum => cum.FertVolume);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public float TotalCumPercent
 | 
			
		||||
        {
 | 
			
		||||
            get
 | 
			
		||||
            {
 | 
			
		||||
                float res = 0;
 | 
			
		||||
                if (cums.NullOrEmpty()) return 0;
 | 
			
		||||
                foreach (Cum cum in cums)
 | 
			
		||||
                {
 | 
			
		||||
                    res += cum.Volume;
 | 
			
		||||
                }
 | 
			
		||||
                return res / Props.maxCumCapacity;
 | 
			
		||||
                return cums.Sum(cum => cum.Volume) / Props.maxCumCapacity;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        public float CumCapacity
 | 
			
		||||
| 
						 | 
				
			
			@ -372,11 +357,7 @@ namespace RJW_Menstruation
 | 
			
		|||
            get
 | 
			
		||||
            {
 | 
			
		||||
                if (eggs.NullOrEmpty() || cums.NullOrEmpty()) return false;
 | 
			
		||||
                foreach (Cum cum in cums)
 | 
			
		||||
                {
 | 
			
		||||
                    if (cum.FertVolume > 0) return true;
 | 
			
		||||
                }
 | 
			
		||||
                return false;
 | 
			
		||||
                return cums.Any(cum => cum.FertVolume > 0);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -573,11 +554,8 @@ namespace RJW_Menstruation
 | 
			
		|||
        /// <returns></returns>
 | 
			
		||||
        public Cum GetCum(Pawn pawn)
 | 
			
		||||
        {
 | 
			
		||||
            if (!cums.NullOrEmpty()) foreach (Cum cum in cums)
 | 
			
		||||
                {
 | 
			
		||||
                    if (!cum.notcum && cum.pawn.Equals(pawn)) return cum;
 | 
			
		||||
                }
 | 
			
		||||
            return null;
 | 
			
		||||
            if (cums.NullOrEmpty()) return null;
 | 
			
		||||
            return cums.Find(cum => !cum.notcum && cum.pawn == pawn);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			@ -1076,10 +1054,8 @@ namespace RJW_Menstruation
 | 
			
		|||
            List<Cum> eligibleCum = cums.FindAll(cum => !cum.notcum && cum.FertVolume > 0 && cum.pawn != null && (RJWPregnancySettings.bestial_pregnancy_enabled || xxx.is_animal(parent.pawn) == xxx.is_animal(cum.pawn)));
 | 
			
		||||
            if (eligibleCum.Count == 0) return null;
 | 
			
		||||
 | 
			
		||||
            float totalFertPower = 0;
 | 
			
		||||
            foreach (Cum cum in eligibleCum)
 | 
			
		||||
                totalFertPower += cum.FertVolume;
 | 
			
		||||
 | 
			
		||||
            float totalFertPower = eligibleCum.Sum(cum => cum.FertVolume);
 | 
			
		||||
            
 | 
			
		||||
            if (Rand.Range(0.0f, 1.0f) > 1.0f - Mathf.Pow(1.0f - Configurations.FertilizeChance, totalFertPower * Props.basefertilizationChanceFactor))
 | 
			
		||||
                return null;
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -1093,20 +1069,7 @@ namespace RJW_Menstruation
 | 
			
		|||
            }
 | 
			
		||||
 | 
			
		||||
            // We shouldn't reach here, but floating point errors exist, so just to be sure, select whomever came the most
 | 
			
		||||
 | 
			
		||||
            float mostCum = 0;
 | 
			
		||||
            Pawn mostCummer = null;
 | 
			
		||||
 | 
			
		||||
            foreach (Cum cum in eligibleCum)
 | 
			
		||||
            {
 | 
			
		||||
                if (cum.FertVolume > mostCum)
 | 
			
		||||
                {
 | 
			
		||||
                    mostCum = cum.FertVolume;
 | 
			
		||||
                    mostCummer = cum.pawn;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return mostCummer;
 | 
			
		||||
            return eligibleCum.MaxBy(cum => cum.FertVolume).pawn;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -59,11 +59,9 @@ namespace RJW_Menstruation
 | 
			
		|||
            Pawn pawn = props.partner;
 | 
			
		||||
            Hediff_BasePregnancy newestPregnancy = pawn.health.hediffSet.GetHediffs<Hediff_BasePregnancy>().MaxBy(hediff => hediff.loadID);
 | 
			
		||||
            if (newestPregnancy == null) return;
 | 
			
		||||
            foreach (HediffComp_Menstruation comp in pawn.GetMenstruationComps())
 | 
			
		||||
            {
 | 
			
		||||
                if (comp.Pregnancy == newestPregnancy) return;  // One of the wombs did get it
 | 
			
		||||
            }
 | 
			
		||||
            __state.Pregnancy = newestPregnancy;
 | 
			
		||||
 | 
			
		||||
            if (pawn.GetMenstruationComps().Any(comp => comp.Pregnancy == newestPregnancy)) return; // One of the wombs did get it
 | 
			
		||||
            else __state.Pregnancy = newestPregnancy;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        /// <summary>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue