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; }
// 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); }
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); }
// 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); }