private static void AddAllParts(this RacePubertySetting that, Pawn pawn) { foreach (var config in that.list.Where(x => x.IsAssigned() && x.IsAll())) { pawn.health.AddHediff(config.Which(), pawn.Where(config.Where())); } }
public static Gender WhatGender(Pawn pawn) { RacePubertySetting pubertySettings = pawn.RacePubertySetting(); var intersex = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.LifeStages_Infertile_BirthDefect) != null || pubertySettings.AnyTestes(pawn) && pubertySettings.AnyWomb(pawn); if (intersex) { return(Gender.None); } var sex = pawn.gender; var cis = pawn.health.hediffSet.GetFirstHediffOfDef(HediffDefOf.LifeStages_Transgendered) == null; if (cis) { return(sex); } switch (sex) { case Gender.Male: return(Gender.Female); case Gender.Female: return(Gender.Male); default: return(Gender.None); } }
public static void pubertyChest(Pawn pawn, float severity, RacePubertySetting pubertySettings) { intialChest(pawn); if (Rand.Value > .1f) { return; } if (pawn.health.hediffSet.hediffs.Any(pubertySettings.hasTestes)) { //more pec MoreChest(pawn, HediffDefOf.LifeStages_Pecs); } else { float boobGrowthChance = 0.05f; if (PubertyHelper.RelaventHeDiffs(pubertySettings, pawn.health.hediffSet).Any()) { //ovaries keep pumping boobGrowthChance = .5f; } if (Rand.Value < boobGrowthChance) { //more boob MoreChest(pawn, HediffDefOf.LifeStages_Breasts); } } }
public static IEnumerable <Hediff> RelaventHeDiffs(this RacePubertySetting that, HediffSet diffSet) { var heDiffs = diffSet.pawn.health.hediffSet.hediffs.Where(x => that.hasBioOrgan(x) || x.def?.defName?.Contains("Womb") == true); return(heDiffs); }
public static void AddHair(this RacePubertySetting pubertySettings, Pawn pawn) { IEnumerable <PubertySetting> settings = pubertySettings.list.Where(x => x.IsSecondaryAssigned() && (x.IsSecondaryAll() || x.GetSecondaryGender() == pawn.gender) && x.Where() != BodyPartDefOf.Chest); //HediffDef bodyHair = PubertyHelper.First(hediffDefs); foreach (PubertySetting bodyHair in settings) { BodyPartRecord whereHair = pawn.Where(bodyHair.Where()); var which = bodyHair.Which(); #if DEBUG Log.Message("Adding hair to " + pawn?.Name + " of " + pawn?.Faction?.Name + " AT " + whereHair + " of type " + which); #endif var hediff = PawnHelper.GetHediff(pawn, which, whereHair, false); if (hediff == null) { hediff = pawn.health.AddHediff(which, whereHair); hediff.Severity = 0.05f; } else { hediff.Severity = Math.Min(hediff.Severity + 0.05f, 1f); } } }
private static void AddOtherParts(this RacePubertySetting that, Pawn pawn) { foreach (var config in that.list.Where(x => x.genderRoleIndex == BodyPartsByRace.Other)) { pawn.health.AddHediff(config.Which(), pawn.Where(config.Where())); } }
public static void DecideTooAddHair(this RacePubertySetting pubertySettings, Pawn pawn) { var forHair = pubertySettings.ChanceForHair(pawn); if (Rand.Value < forHair * 2) { pubertySettings.AddHair(pawn); } }
public override float CalculateCapacityLevel(HediffSet diffSet, List <PawnCapacityUtility.CapacityImpactor> impactors = null) { var basis = PawnCapacityUtility.CalculateTagEfficiency(diffSet, BodyPartTagDefOf.FertilitySource, 3.40282347E+38f, default(FloatRange), impactors); RacePubertySetting pubertySettings = SettingHelper.latest.GetPubertySettingsFor(diffSet.pawn.def); return(PubertyHelper.getFactorFertility(pubertySettings, diffSet) * basis * PubertyHelper.isPostPubescence(diffSet)); }
private static void RenderOptions(int listCount, RacePubertySetting settings, Rect[] splits) { for (int i = 0; i < listCount; i++) { var setting = settings.list[i]; var myRect = splits[i + 1]; setting.WidgetDraw(myRect); } }
public static float getFactorFertility(this RacePubertySetting that, HediffSet diffSet) { //look for wombs var heDiffs = that.RelaventHeDiffs(diffSet); if (!heDiffs.Any()) { return(0f); } return(1f); }
public static List <HediffDef> Organs(this RacePubertySetting that, int?genderRoleIndex = null, int?where = null) { List <HediffDef> list = new List <HediffDef>(); foreach (var x in that.list) { if ((genderRoleIndex == null && x.genderRoleIndex != BodyPartsByRace.Off || genderRoleIndex == x.genderRoleIndex) && (@where == null || @where == x.@where)) { list.Add(x.Which()); } } return(list); }
private static void roleOrganMaturity(this RacePubertySetting that, Pawn pawn, float severity) { //delay puberty onset if (Rand.Value < SettingHelper.latest.EarlyPubertyChance || severity < (1f - SettingHelper.latest.PubertyDelay)) { if (Rand.Value < SettingHelper.latest.IntersexInfertileChance) { pawn.health.AddHediff(HediffDefOf.LifeStages_Infertile_BirthDefect, null); } bool intersex = Rand.Value < SettingHelper.latest.IntersexChance; bool cis = Rand.Value > SettingHelper.latest.TransgenderChance; if (!cis) { pawn.health.AddHediff(HediffDefOf.LifeStages_Transgendered, null); } that.AddAllParts(pawn); if (intersex) { that.AddParts(pawn); } else { switch (pawn.gender) { case Gender.Male: that.AddMaleParts(pawn); break; case Gender.Female: that.AddFemaleParts(pawn); break; default: that.AddOtherParts(pawn); break; } } } }
public static void applyPubertyDay(Pawn pawn, float severity) { if (!Recipe_Neuter.PartsToApplyOn(pawn).Any()) { return; } RacePubertySetting pubertySettings = pawn.RacePubertySetting(); var sexOrgans = pubertySettings.RelaventHeDiffs(pawn.health.hediffSet); if (sexOrgans.Any()) { ChestManager.pubertyChest(pawn, severity, pubertySettings); pubertySettings.DecideTooAddHair(pawn); } else { pubertySettings.roleOrganMaturity(pawn, severity); } }
/***** MOD INTEGRATION ****/ public static RacePubertySetting GetPubertySettingsFor(this ModSettings that, ThingDef currentDef) { //that.racialSettings = new List<RacePubertySetting>(); RacePubertySetting mine = null; if (that.racialSettings.NullOrEmpty()) { Log.Warning("Initial Settings Loaded!"); that.racialSettings = new List <RacePubertySetting>(); } try { that.racialSettings = that.racialSettings.ToList(); } catch (Exception e) { Log.Error("Cleared your settings, sorry!\nDev Reason : " + e); that.racialSettings = new List <RacePubertySetting>(); } foreach (RacePubertySetting x in that.racialSettings) { if (x.IsThatDef(currentDef)) { mine = x; break; } } if (mine == null) { Log.Message("Building new setting for " + currentDef.defName); mine = BuildPubertySettings(currentDef); that.racialSettings.Add(mine); } return(mine); }
private static void RenderTopPart(Rect rect, RacePubertySetting settings) { var topPart = new Rect(rect.x, rect.y, rect.width, rect.height / 10f); var labelArea = SplitX(topPart, 10).ToArray(); Widgets.Label(labelArea[0], "Organ"); Widgets.Label(labelArea[1], "Secondary"); Widgets.Label(labelArea[2], "Where"); if (settings.instantPubertySetting == null) { settings.instantPubertySetting = false; } Widgets.CheckboxLabeled(labelArea[labelArea.Length - 2], "Born Adult?", ref settings.instantPubertySetting.value); }
private static bool IsThatDef(this RacePubertySetting x, ThingDef currentDef) { return(x != null && (x.appliedTo?.value?.EqualsIgnoreCase(currentDef.defName) ?? false)); }
public static bool hasBioOrgan(this RacePubertySetting that, Hediff x) { return(First(that.Organs(), y => y == x.def) != null); }
private static float ChanceForHair(this RacePubertySetting pubertySettings, Pawn pawn) { return(pubertySettings.AnyTestes(pawn) ? SettingHelper.latest.maleHairGrowthRate : SettingHelper.latest.otherHairGrowthRate); }
public static bool hasTestes(this RacePubertySetting that, Hediff x) { return(First(that.Organs(BodyPartsByRace.Male), y => y == x.def) != null); }
public static bool AnyWomb(this RacePubertySetting that, Pawn pawn) { return(pawn.health.hediffSet.hediffs.Any(that.hasWomb)); }
private static void AddParts(this RacePubertySetting that, Pawn pawn) { that.AddOtherParts(pawn); that.AddMaleParts(pawn); that.AddFemaleParts(pawn); }