public override float GenerationChance(Pawn generated, Pawn other, PawnGenerationRequest request) { float num = 1f; float num2 = 1f; if (other.GetFather() != null || other.GetMother() != null) { num = ChildRelationUtility.ChanceOfBecomingChildOf(generated, other.GetFather(), other.GetMother(), new PawnGenerationRequest?(request), null, null); } else if (request.FixedMelanin.HasValue) { num2 = ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin); } else { num2 = PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin); } float num3 = Mathf.Abs(generated.ageTracker.AgeChronologicalYearsFloat - other.ageTracker.AgeChronologicalYearsFloat); float num4 = 1f; if (num3 > 40f) { num4 = 0.2f; } else if (num3 > 10f) { num4 = 0.65f; } return(num * num2 * num4 * base.BaseGenerationChanceFactor(generated, other, request)); }
public static void PsychologyFormula(ref float __result, Pawn generated, Pawn other, PawnGenerationRequest request, bool ex) { /* Throw away the existing result and substitute our own formula. */ float sexualityFactor = 1f; PsychologyPawn realGenerated = generated as PsychologyPawn; PsychologyPawn realOther = other as PsychologyPawn; if (PsychologyBase.ActivateKinsey() && realGenerated != null && realOther != null && realGenerated.sexuality != null && realOther.sexuality != null) { float kinsey = 3 - realGenerated.sexuality.kinseyRating; float kinsey2 = 3 - realOther.sexuality.kinseyRating; float h**o = (generated.gender == other.gender) ? 1f : -1f; sexualityFactor *= Mathf.InverseLerp(3f, 0f, kinsey * h**o); sexualityFactor *= Mathf.InverseLerp(3f, 0f, kinsey2 * h**o); } else { sexualityFactor = (generated.gender != other.gender) ? 1f : 0.01f; } float existingExLoverFactor = 1f; if (ex) { int exLovers = 0; List <DirectPawnRelation> directRelations = other.relations.DirectRelations; for (int i = 0; i < directRelations.Count; i++) { if (LovePartnerRelationUtility.IsExLovePartnerRelation(directRelations[i].def)) { exLovers++; } } existingExLoverFactor = Mathf.Pow(0.2f, (float)exLovers); } else if (LovePartnerRelationUtility.HasAnyLovePartner(other)) { __result = 0f; return; } float generationChanceAgeFactor = Traverse.Create(typeof(LovePartnerRelationUtility)).Method("GetGenerationChanceAgeFactor", new[] { typeof(Pawn) }).GetValue <float>(new object[] { generated }); float generationChanceAgeFactor2 = Traverse.Create(typeof(LovePartnerRelationUtility)).Method("GetGenerationChanceAgeFactor", new[] { typeof(Pawn) }).GetValue <float>(new object[] { other }); float generationChanceAgeGapFactor = Traverse.Create(typeof(LovePartnerRelationUtility)).Method("GetGenerationChanceAgeGapFactor", new[] { typeof(Pawn), typeof(Pawn), typeof(bool) }).GetValue <float>(new object[] { generated, other, ex }); float incestFactor = 1f; if (generated.GetRelations(other).Any((PawnRelationDef x) => x.familyByBloodRelation)) { incestFactor = 0.01f; } float melaninFactor; if (request.FixedMelanin.HasValue) { melaninFactor = ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin); } else { melaninFactor = PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin); } __result = existingExLoverFactor * sexualityFactor * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * incestFactor * melaninFactor; }
// Token: 0x06000CF3 RID: 3315 RVA: 0x00040C84 File Offset: 0x0003EE84 internal static void GenerateParentParams(float minChronologicalAge, float maxChronologicalAge, float midChronologicalAge, float minBioAgeToHaveChildren, Pawn generatedChild, Pawn existingChild, PawnGenerationRequest childRequest, out float biologicalAge, out float chronologicalAge, out float skinWhiteness, out string lastName) { chronologicalAge = Rand.GaussianAsymmetric(midChronologicalAge, (midChronologicalAge - minChronologicalAge) / 2f, (maxChronologicalAge - midChronologicalAge) / 2f); chronologicalAge = Mathf.Clamp(chronologicalAge, minChronologicalAge, maxChronologicalAge); biologicalAge = Rand.Range(minBioAgeToHaveChildren, Mathf.Min(existingChild.RaceProps.lifeExpectancy, chronologicalAge)); if (existingChild.GetFather() != null) { skinWhiteness = ParentRelationUtility.GetRandomSecondParentSkinColor(existingChild.GetFather().story.skinWhiteness, existingChild.story.skinWhiteness, childRequest.FixedSkinWhiteness); } else if (existingChild.GetMother() != null) { skinWhiteness = ParentRelationUtility.GetRandomSecondParentSkinColor(existingChild.GetMother().story.skinWhiteness, existingChild.story.skinWhiteness, childRequest.FixedSkinWhiteness); } else if (!childRequest.FixedSkinWhiteness.HasValue) { skinWhiteness = PawnSkinColors.GetRandomSkinColorSimilarTo(existingChild.story.skinWhiteness, 0f, 1f); } else { float num = Mathf.Min(childRequest.FixedSkinWhiteness.Value, existingChild.story.skinWhiteness); float num2 = Mathf.Max(childRequest.FixedSkinWhiteness.Value, existingChild.story.skinWhiteness); if (Rand.Value < 0.5f) { skinWhiteness = PawnSkinColors.GetRandomSkinColorSimilarTo(num, 0f, num); } else { skinWhiteness = PawnSkinColors.GetRandomSkinColorSimilarTo(num2, num2, 1f); } } lastName = null; if (!ChildRelationUtility.DefinitelyHasNotBirthName(existingChild) && ChildRelationUtility.ChildWantsNameOfAnyParent(existingChild)) { if (existingChild.GetMother() == null && existingChild.GetFather() == null) { if (Rand.Value < 0.5f) { lastName = ((NameTriple)existingChild.Name).Last; } } else { string last = ((NameTriple)existingChild.Name).Last; string b = null; if (existingChild.GetMother() != null) { b = ((NameTriple)existingChild.GetMother().Name).Last; } else if (existingChild.GetFather() != null) { b = ((NameTriple)existingChild.GetFather().Name).Last; } if (last != b) { lastName = last; } } } }
private static void ResolveMySkinColor(ref PawnGenerationRequest request, Pawn generated) { if (request.FixedMelanin.HasValue) { return; } request.SetFixedMelanin(ChildRelationUtility.GetRandomChildSkinColor(generated.GetFather().story.melanin, generated.GetMother().story.melanin)); }
// LovePartnerRelationUtility.LovePartnerRelationGenerationChance, but with the gender and sexuality code removed. public static float LovePartnerRelationGenerationChance(Pawn generated, Pawn other, PawnGenerationRequest request, bool ex) { if (generated.ageTracker.AgeBiologicalYearsFloat < 14f) { return(0f); } if (other.ageTracker.AgeBiologicalYearsFloat < 14f) { return(0f); } var num = 1f; if (ex) { var num2 = 0; var directRelations = other.relations.DirectRelations; foreach (var directPawnRelation in directRelations) { if (LovePartnerRelationUtility.IsExLovePartnerRelation(directPawnRelation.def)) { num2++; } } num = Mathf.Pow(0.2f, num2); } else if (LovePartnerRelationUtility.HasAnyLovePartner(other)) { return(0f); } var generationChanceAgeFactor = GetGenerationChanceAgeFactor(generated); var generationChanceAgeFactor2 = GetGenerationChanceAgeFactor(other); var generationChanceAgeGapFactor = GetGenerationChanceAgeGapFactor(generated, other, ex); var num3 = 1f; if (generated.GetRelations(other).Any(x => x.familyByBloodRelation)) { num3 = 0.01f; } var num4 = request.FixedMelanin.HasValue ? ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin) : PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin); return(num * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * num3 * num4); }
private static void ResolveMyName(ref PawnGenerationRequest request, Pawn generated) { if (request.FixedLastName != null) { return; } if (ChildRelationUtility.ChildWantsNameOfAnyParent(generated)) { if (Rand.Value < 0.5f) { request.SetFixedLastName(((NameTriple)generated.GetFather().Name).Last); } else { request.SetFixedLastName(((NameTriple)generated.GetMother().Name).Last); } } }
internal static float _LovePartnerRelationGenerationChance(Pawn generated, Pawn other, PawnGenerationRequest request, bool ex) { if (generated.ageTracker.AgeBiologicalYearsFloat < 14f) { return(0f); } if (other.ageTracker.AgeBiologicalYearsFloat < 14f) { return(0f); } if (!PsychologyBase.ActivateKinsey()) { if (generated.gender == other.gender && (!other.story.traits.HasTrait(TraitDefOf.Gay) || !request.AllowGay)) { return(0f); } if (generated.gender != other.gender && other.story.traits.HasTrait(TraitDefOf.Gay)) { return(0f); } } else if (generated.gender == other.gender && !request.AllowGay) { return(0f); } float num = 1f; if (ex) { int num2 = 0; List <DirectPawnRelation> directRelations = other.relations.DirectRelations; for (int i = 0; i < directRelations.Count; i++) { if (LovePartnerRelationUtility.IsExLovePartnerRelation(directRelations[i].def)) { num2++; } } num = Mathf.Pow(0.2f, (float)num2); } else if (LovePartnerRelationUtility.HasAnyLovePartner(other)) { return(0f); } float num3 = 1f; PsychologyPawn realGenerated = generated as PsychologyPawn; PsychologyPawn realOther = other as PsychologyPawn; if (PsychologyBase.ActivateKinsey() && realGenerated != null && realOther != null) { float kinsey = 3 - realGenerated.sexuality.kinseyRating; float kinsey2 = 3 - realOther.sexuality.kinseyRating; float h**o = (generated.gender == other.gender) ? 1f : -1f; num3 *= Mathf.InverseLerp(3f, 0f, kinsey * h**o); num3 *= Mathf.InverseLerp(3f, 0f, kinsey2 * h**o); } else { num3 = (generated.gender != other.gender) ? 1f : 0.01f; } var GetGenerationChanceAgeFactor = typeof(LovePartnerRelationUtility).GetMethod("GetGenerationChanceAgeFactor", BindingFlags.Static | BindingFlags.NonPublic); var GetGenerationChanceAgeGapFactor = typeof(LovePartnerRelationUtility).GetMethod("GetGenerationChanceAgeGapFactor", BindingFlags.Static | BindingFlags.NonPublic); float generationChanceAgeFactor = (float)GetGenerationChanceAgeFactor.Invoke(null, new object[] { generated }); float generationChanceAgeFactor2 = (float)GetGenerationChanceAgeFactor.Invoke(null, new object[] { other }); float generationChanceAgeGapFactor = (float)GetGenerationChanceAgeGapFactor.Invoke(null, new object[] { generated, other, ex }); float num4 = 1f; if (generated.GetRelations(other).Any((PawnRelationDef x) => x.familyByBloodRelation)) { num4 = 0.01f; } float num5; if (request.FixedMelanin.HasValue) { num5 = ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin); } else { num5 = PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin); } return(num * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * num3 * num5 * num4); }
public bool AddNewBaby(Pawn mother, Pawn father) { float melanin; string lastname; if (xxx.is_human(mother)) { if (xxx.is_human(father)) { melanin = ChildRelationUtility.GetRandomChildSkinColor(father.story?.melanin ?? 0f, mother.story?.melanin ?? 0f); //melanin = (mother.story?.melanin ?? 0f + father.story?.melanin ?? 0f) / 2; lastname = NameTriple.FromString(father.Name.ToStringFull).Last; } else { melanin = mother.story?.melanin ?? 0f; lastname = NameTriple.FromString(mother.Name.ToStringFull).Last; } } else if (xxx.is_human(father)) { melanin = father.story?.melanin ?? 0f; lastname = NameTriple.FromString(father.Name.ToStringFull).Last; } else { melanin = Rand.Range(0, 1.0f); lastname = ""; } PawnGenerationRequest request = new PawnGenerationRequest( newborn: true, allowDowned: true, faction: mother.IsPrisoner ? null : mother.Faction, canGeneratePawnRelations: false, forceGenerateNewPawn: true, colonistRelationChanceFactor: 0, allowFood: false, allowAddictions: false, relationWithExtraPawnChanceFactor: 0, fixedMelanin: melanin, fixedLastName: lastname, kind: BabyPawnKindDecider(mother, father) //fixedIdeo: mother.Ideo, //forbidAnyTitle: true, //forceNoBackstory:true ); int division = 1; HairDef firsthair = null; Color firsthaircolor = Color.white; BodyTypeDef firstbody = null; CrownType firstcrown = CrownType.Undefined; string firstheadpath = null; string firstHARcrown = null; while (Rand.Chance(Configurations.EnzygoticTwinsChance) && division < Configurations.MaxEnzygoticTwins) { division++; } for (int i = 0; i < division; i++) { Pawn baby = GenerateBaby(request, mother, father); if (division > 1) { if (i == 0 && baby.story != null) { firsthair = baby.story.hairDef; firsthaircolor = baby.story.hairColor; request.FixedGender = baby.gender; firstbody = baby.story.bodyType; firstcrown = baby.story.crownType; firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath"); if (firstheadpath == null) { Graphic_Multi head = GraphicDatabaseHeadRecords.GetHeadRandom(baby.gender, baby.story.SkinColor, baby.story.crownType, true); if (head != null) { baby.story.SetMemberValue("headGraphicPath", head.GraphicPath); } firstheadpath = (string)baby.story.GetMemberValue("headGraphicPath"); } if (Configurations.HARActivated && baby.IsHAR()) { firstHARcrown = baby.GetHARCrown(); } } else { if (baby.story != null) { baby.story.hairDef = firsthair; baby.story.hairColor = firsthaircolor; baby.story.bodyType = firstbody; baby.story.crownType = firstcrown; baby.story.SetMemberValue("headGraphicPath", firstheadpath); if (Configurations.HARActivated && baby.IsHAR()) { baby.SetHARCrown(firstHARcrown); } } } } if (baby != null) { babies.Add(baby); } } return(true); }
public static float PackmateGeneratorChance( Pawn generated, Pawn other, PawnGenerationRequest request, bool ex) { if ((double)generated.ageTracker.AgeBiologicalYearsFloat < 5.0) { if (!(generated.RaceProps.body.defName == AvaliDefs.RimValiBody.defName)) { return(0.0f); } } if (!(other.RaceProps.body.defName == AvaliDefs.RimValiBody.defName)) { return(0.0f); } float num1 = 2f; float generationChanceAgeFactor1 = PackRelationUtilityWorker.GetGenerationChanceAgeFactor(generated); float generationChanceAgeFactor2 = PackRelationUtilityWorker.GetGenerationChanceAgeFactor(other); float chanceAgeGapFactor = PackRelationUtilityWorker.GetGenerationChanceAgeGapFactor(generated, other, ex); float num4 = 2f; float num5 = !request.FixedMelanin.HasValue ? PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin) : ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin); return(num1 * generationChanceAgeFactor1 * generationChanceAgeFactor2 * chanceAgeGapFactor * num5 * num4); }
// Token: 0x06000C9A RID: 3226 RVA: 0x0003EAD8 File Offset: 0x0003CCD8 internal static float _LovePartnerRelationGenerationChance(Pawn generated, Pawn other, PawnGenerationRequest request, bool ex) { if (generated.ageTracker.AgeBiologicalYearsFloat < 14f) { return(0f); } if (other.ageTracker.AgeBiologicalYearsFloat < 14f) { return(0f); } if (generated.gender == other.gender && (!other.story.traits.HasTrait(TraitDefOf.Gay) || !other.story.traits.HasTrait(TraitDefOfPsychology.Bisexual) || !request.AllowGay)) { return(0f); } if (generated.gender != other.gender && other.story.traits.HasTrait(TraitDefOf.Gay)) { return(0f); } var GetGenerationChanceAgeFactor = typeof(LovePartnerRelationUtility).GetMethod("GetGenerationChanceAgeFactor", BindingFlags.Static | BindingFlags.NonPublic); var GetGenerationChanceAgeGapFactor = typeof(LovePartnerRelationUtility).GetMethod("GetGenerationChanceAgeGapFactor", BindingFlags.Static | BindingFlags.NonPublic); if (GetGenerationChanceAgeFactor == null) { Log.ErrorOnce("Unable to reflect LovePartnerRelationUtility.GetGenerationChanceAgeFactor!", 305432421); return(0f); } if (GetGenerationChanceAgeGapFactor == null) { Log.ErrorOnce("Unable to reflect LovePartnerRelationUtility.GetGenerationChanceAgeGapFactor!", 305432421); return(0f); } float num = 1f; if (ex) { int num2 = 0; List <DirectPawnRelation> directRelations = other.relations.DirectRelations; for (int i = 0; i < directRelations.Count; i++) { if (LovePartnerRelationUtility.IsExLovePartnerRelation(directRelations[i].def)) { num2++; } } num = Mathf.Pow(0.2f, (float)num2); } else if (LovePartnerRelationUtility.HasAnyLovePartner(other)) { return(0f); } float num3 = (generated.gender != other.gender) ? 1f : 0.01f; float generationChanceAgeFactor = (float)GetGenerationChanceAgeFactor.Invoke(null, new object[] { generated }); float generationChanceAgeFactor2 = (float)GetGenerationChanceAgeFactor.Invoke(null, new object[] { other }); float generationChanceAgeGapFactor = (float)GetGenerationChanceAgeGapFactor.Invoke(null, new object[] { generated, other, ex }); float num4 = 1f; if (generated.GetRelations(other).Any((PawnRelationDef x) => x.familyByBloodRelation)) { num4 = 0.01f; } float num5; if (request.FixedSkinWhiteness.HasValue) { num5 = ChildRelationUtility.GetSkinSimilarityFactor(request.FixedSkinWhiteness.Value, other.story.skinWhiteness); } else { num5 = PawnSkinColors.GetWhitenessCommonalityFactor(other.story.skinWhiteness); } return(num * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * num3 * num5 * num4); }
private static float LovePartnerRelationGenerationChance_Method(Pawn generated, Pawn other, PawnGenerationRequest request, bool ex) { if (generated.ageTracker.AgeBiologicalYearsFloat < 14f || other.ageTracker.AgeBiologicalYearsFloat < 14f) { return(0f); } float LoveChance = 1f; float GenderFactor = 1f; var comp = other.TryGetComp <CompIndividuality>(); if (generated.gender != other.gender && comp != null) { if (comp.sexuality == CompIndividuality.Sexuality.Straight) { GenderFactor = 1.0f; } else if (comp.sexuality == CompIndividuality.Sexuality.Bisexual) { GenderFactor = 0.75f; } else if (comp.sexuality == CompIndividuality.Sexuality.Gay) { GenderFactor = 0.05f; } } if (generated.gender == other.gender && comp != null) { if (comp.sexuality == CompIndividuality.Sexuality.Gay) { GenderFactor = 1.0f; } else if (comp.sexuality == CompIndividuality.Sexuality.Bisexual) { GenderFactor = 0.75f; } else if (comp.sexuality == CompIndividuality.Sexuality.Straight) { GenderFactor = 0.05f; } } if (ex) { int ExLovers = 0; List <DirectPawnRelation> directRelations = other.relations.DirectRelations; for (int i = 0; i < directRelations.Count; i++) { if (LovePartnerRelationUtility.IsExLovePartnerRelation(directRelations[i].def)) { ExLovers++; } } LoveChance = Mathf.Pow(0.2f, (float)ExLovers); } else if (LovePartnerRelationUtility.HasAnyLovePartner(other)) { return(0f); } float generationChanceAgeFactor = Mathf.Clamp(GenMath.LerpDouble(14f, 27f, 0f, 1f, generated.ageTracker.AgeBiologicalYearsFloat), 0f, 1f); float generationChanceAgeFactor2 = Mathf.Clamp(GenMath.LerpDouble(14f, 27f, 0f, 1f, other.ageTracker.AgeBiologicalYearsFloat), 0f, 1f); float generationChanceAgeGapFactor = (float)GetGenerationChanceAgeGapFactor.Invoke(null, new object[] { generated, other, ex }); float IncestFactor = 1f; if (generated.GetRelations(other).Any((PawnRelationDef x) => x.familyByBloodRelation)) { IncestFactor = 0.01f; } float MelaninFactor; if (request.FixedMelanin != null) { MelaninFactor = ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin); } else { MelaninFactor = PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin); } return(LoveChance * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * GenderFactor * MelaninFactor * IncestFactor); }