private static float GetNewParentSkinColorFactor(float?newParentMelanin, float?otherParentMelanin, float?childMelanin) { if (newParentMelanin.HasValue) { if (!otherParentMelanin.HasValue) { if (childMelanin.HasValue) { return(ChildRelationUtility.GetMelaninSimilarityFactor(newParentMelanin.Value, childMelanin.Value)); } return(PawnSkinColors.GetMelaninCommonalityFactor(newParentMelanin.Value)); } if (childMelanin.HasValue) { float reflectedSkin = ChildRelationUtility.GetReflectedSkin(otherParentMelanin.Value, childMelanin.Value); return(ChildRelationUtility.GetMelaninSimilarityFactor(newParentMelanin.Value, reflectedSkin)); } float melanin = (float)((newParentMelanin.Value + otherParentMelanin.Value) / 2.0); return(PawnSkinColors.GetMelaninCommonalityFactor(melanin)); } if (!otherParentMelanin.HasValue) { if (childMelanin.HasValue) { return(PawnSkinColors.GetMelaninCommonalityFactor(childMelanin.Value)); } return(1f); } if (childMelanin.HasValue) { float reflectedSkin2 = ChildRelationUtility.GetReflectedSkin(otherParentMelanin.Value, childMelanin.Value); return(PawnSkinColors.GetMelaninCommonalityFactor(reflectedSkin2)); } return(PawnSkinColors.GetMelaninCommonalityFactor(otherParentMelanin.Value)); }
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 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) || !request.AllowGay)) { return(0f); } if (generated.gender != other.gender && other.story.traits.HasTrait(TraitDefOf.Gay)) { 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 = LovePartnerRelationUtility.GetGenerationChanceAgeFactor(generated); float generationChanceAgeFactor2 = LovePartnerRelationUtility.GetGenerationChanceAgeFactor(other); float generationChanceAgeGapFactor = LovePartnerRelationUtility.GetGenerationChanceAgeGapFactor(generated, other, ex); float num4 = 1f; if (generated.GetRelations(other).Any((PawnRelationDef x) => x.familyByBloodRelation)) { num4 = 0.01f; } float num5; if (request.FixedMelanin != null) { num5 = ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin); } else { num5 = PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin); } return(num * generationChanceAgeFactor * generationChanceAgeFactor2 * generationChanceAgeGapFactor * num3 * num5 * num4); }
private static float GetNewParentSkinColorFactor(float?newParentMelanin, float?otherParentMelanin, float?childMelanin) { float result; if (newParentMelanin != null) { if (otherParentMelanin == null) { if (childMelanin != null) { result = ChildRelationUtility.GetMelaninSimilarityFactor(newParentMelanin.Value, childMelanin.Value); } else { result = PawnSkinColors.GetMelaninCommonalityFactor(newParentMelanin.Value); } } else if (childMelanin != null) { float reflectedSkin = ChildRelationUtility.GetReflectedSkin(otherParentMelanin.Value, childMelanin.Value); result = ChildRelationUtility.GetMelaninSimilarityFactor(newParentMelanin.Value, reflectedSkin); } else { float melanin = (newParentMelanin.Value + otherParentMelanin.Value) / 2f; result = PawnSkinColors.GetMelaninCommonalityFactor(melanin); } } else if (otherParentMelanin == null) { if (childMelanin != null) { result = PawnSkinColors.GetMelaninCommonalityFactor(childMelanin.Value); } else { result = 1f; } } else if (childMelanin != null) { float reflectedSkin2 = ChildRelationUtility.GetReflectedSkin(otherParentMelanin.Value, childMelanin.Value); result = PawnSkinColors.GetMelaninCommonalityFactor(reflectedSkin2); } else { result = PawnSkinColors.GetMelaninCommonalityFactor(otherParentMelanin.Value); } return(result); }