public static float GetRandomSecondParentSkinColor(float otherParentSkin, float childSkin, float?secondChildSkin = default(float?)) { float num = 0f; num = (float)((!secondChildSkin.HasValue) ? childSkin : ((childSkin + secondChildSkin.Value) / 2.0)); float reflectedSkin = ChildRelationUtility.GetReflectedSkin(otherParentSkin, num); float num2 = childSkin; float num3 = childSkin; if (secondChildSkin.HasValue) { num2 = Mathf.Min(num2, secondChildSkin.Value); num3 = Mathf.Max(num3, secondChildSkin.Value); } float clampMin = 0f; float clampMax = 1f; if (reflectedSkin >= num3) { clampMin = num3; } else { clampMax = num2; } return(PawnSkinColors.GetRandomMelaninSimilarTo(reflectedSkin, clampMin, clampMax)); }
private static void ResolveMySkinColor(ref PawnGenerationRequest request, Pawn generated, Pawn other) { if (!request.FixedMelanin.HasValue) { request.SetFixedMelanin(PawnSkinColors.GetRandomMelaninSimilarTo(other.story.melanin, 0f, 1f)); } }
public override float GenerationChance(Pawn generated, Pawn other, PawnGenerationRequest request) { float num = 1f; float num2 = 1f; if (other.GetFather() == null && other.GetMother() == null) { num2 = ((!request.FixedMelanin.HasValue) ? PawnSkinColors.GetMelaninCommonalityFactor(other.story.melanin) : ChildRelationUtility.GetMelaninSimilarityFactor(request.FixedMelanin.Value, other.story.melanin)); } else { num = ChildRelationUtility.ChanceOfBecomingChildOf(generated, other.GetFather(), other.GetMother(), request, null, null); } float num3 = Mathf.Abs(generated.ageTracker.AgeChronologicalYearsFloat - other.ageTracker.AgeChronologicalYearsFloat); float num4 = 1f; if (num3 > 40.0) { num4 = 0.2f; } else if (num3 > 10.0) { num4 = 0.65f; } return(num * num2 * num4 * base.BaseGenerationChanceFactor(generated, other, request)); }
public static float GetRandomChildSkinColor(float fatherMelanin, float motherMelanin) { float clampMin = Mathf.Min(fatherMelanin, motherMelanin); float clampMax = Mathf.Max(fatherMelanin, motherMelanin); return(PawnSkinColors.GetRandomMelaninSimilarTo((fatherMelanin + motherMelanin) / 2f, clampMin, clampMax)); }
private static float GetNewParentSkinColorFactor(float?newParentMelanin, float?otherParentMelanin, float?childMelanin) { if (newParentMelanin.HasValue) { if (!otherParentMelanin.HasValue) { if (childMelanin.HasValue) { return(GetMelaninSimilarityFactor(newParentMelanin.Value, childMelanin.Value)); } return(PawnSkinColors.GetMelaninCommonalityFactor(newParentMelanin.Value)); } if (childMelanin.HasValue) { float reflectedSkin = GetReflectedSkin(otherParentMelanin.Value, childMelanin.Value); return(GetMelaninSimilarityFactor(newParentMelanin.Value, reflectedSkin)); } return(PawnSkinColors.GetMelaninCommonalityFactor((newParentMelanin.Value + otherParentMelanin.Value) / 2f)); } if (!otherParentMelanin.HasValue) { if (childMelanin.HasValue) { return(PawnSkinColors.GetMelaninCommonalityFactor(childMelanin.Value)); } return(1f); } if (childMelanin.HasValue) { return(PawnSkinColors.GetMelaninCommonalityFactor(GetReflectedSkin(otherParentMelanin.Value, childMelanin.Value))); } return(PawnSkinColors.GetMelaninCommonalityFactor(otherParentMelanin.Value)); }
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 static float GetRandomSecondParentSkinColor(float otherParentSkin, float childSkin, float?secondChildSkin = null) { float mirror; if (secondChildSkin != null) { mirror = (childSkin + secondChildSkin.Value) / 2f; } else { mirror = childSkin; } float reflectedSkin = ChildRelationUtility.GetReflectedSkin(otherParentSkin, mirror); float num = childSkin; float num2 = childSkin; if (secondChildSkin != null) { num = Mathf.Min(num, secondChildSkin.Value); num2 = Mathf.Max(num2, secondChildSkin.Value); } float clampMin = 0f; float clampMax = 1f; if (reflectedSkin >= num2) { clampMin = num2; } else { clampMax = num; } return(PawnSkinColors.GetRandomMelaninSimilarTo(reflectedSkin, clampMin, clampMax)); }
private 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 melanin, out string lastName) { chronologicalAge = Rand.GaussianAsymmetric(midChronologicalAge, (float)((midChronologicalAge - minChronologicalAge) / 2.0), (float)((maxChronologicalAge - midChronologicalAge) / 2.0)); chronologicalAge = Mathf.Clamp(chronologicalAge, minChronologicalAge, maxChronologicalAge); biologicalAge = Rand.Range(minBioAgeToHaveChildren, Mathf.Min(existingChild.RaceProps.lifeExpectancy, chronologicalAge)); if (existingChild.GetFather() != null) { melanin = ParentRelationUtility.GetRandomSecondParentSkinColor(existingChild.GetFather().story.melanin, existingChild.story.melanin, childRequest.FixedMelanin); } else if (existingChild.GetMother() != null) { melanin = ParentRelationUtility.GetRandomSecondParentSkinColor(existingChild.GetMother().story.melanin, existingChild.story.melanin, childRequest.FixedMelanin); } else if (!childRequest.FixedMelanin.HasValue) { melanin = PawnSkinColors.GetRandomMelaninSimilarTo(existingChild.story.melanin, 0f, 1f); } else { float num = Mathf.Min(childRequest.FixedMelanin.Value, existingChild.story.melanin); float num2 = Mathf.Max(childRequest.FixedMelanin.Value, existingChild.story.melanin); if (Rand.Value < 0.5) { melanin = PawnSkinColors.GetRandomMelaninSimilarTo(num, 0f, num); } else { melanin = PawnSkinColors.GetRandomMelaninSimilarTo(num2, num2, 1f); } } lastName = null; if (!ChildRelationUtility.DefinitelyHasNotBirthName(existingChild) && ChildRelationUtility.ChildWantsNameOfAnyParent(existingChild)) { if (existingChild.GetMother() == null && existingChild.GetFather() == null) { if (Rand.Value < 0.5) { 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; } } } }
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 GetSkinDataCommonalityFactor(int skinDataIndex) { float num = 0f; for (int i = 0; i < PawnSkinColors.SkinColors.Length; i++) { num = Mathf.Max(num, PawnSkinColors.GetTotalAreaWhereClosestToSelector(i)); } return(PawnSkinColors.GetTotalAreaWhereClosestToSelector(skinDataIndex) / num); }
public static Color GetSkinColor(float melanin) { int skinDataIndexOfMelanin = PawnSkinColors.GetSkinDataIndexOfMelanin(melanin); if (skinDataIndexOfMelanin == PawnSkinColors.SkinColors.Length - 1) { return(PawnSkinColors.SkinColors[skinDataIndexOfMelanin].color); } float t = Mathf.InverseLerp(PawnSkinColors.SkinColors[skinDataIndexOfMelanin].melanin, PawnSkinColors.SkinColors[skinDataIndexOfMelanin + 1].melanin, melanin); return(Color.Lerp(PawnSkinColors.SkinColors[skinDataIndexOfMelanin].color, PawnSkinColors.SkinColors[skinDataIndexOfMelanin + 1].color, t)); }
public static float GetMelaninCommonalityFactor(float melanin) { int skinDataIndexOfMelanin = PawnSkinColors.GetSkinDataIndexOfMelanin(melanin); if (skinDataIndexOfMelanin == PawnSkinColors.SkinColors.Length - 1) { return(PawnSkinColors.GetSkinDataCommonalityFactor(skinDataIndexOfMelanin)); } float t = Mathf.InverseLerp(PawnSkinColors.SkinColors[skinDataIndexOfMelanin].melanin, PawnSkinColors.SkinColors[skinDataIndexOfMelanin + 1].melanin, melanin); return(Mathf.Lerp(PawnSkinColors.GetSkinDataCommonalityFactor(skinDataIndexOfMelanin), PawnSkinColors.GetSkinDataCommonalityFactor(skinDataIndexOfMelanin + 1), t)); }
public static Color RandomHairColor(Color skinColor, int ageYears) { if (Rand.Value < 0.02f) { return(new Color(Rand.Value, Rand.Value, Rand.Value)); } if (ageYears > 40) { float num = GenMath.SmootherStep(40f, 75f, (float)ageYears); if (Rand.Value < num) { float num2 = Rand.Range(0.65f, 0.85f); return(new Color(num2, num2, num2)); } } if (PawnSkinColors.IsDarkSkin(skinColor) || Rand.Value < 0.5f) { float value = Rand.Value; if (value < 0.25f) { return(new Color(0.2f, 0.2f, 0.2f)); } if (value < 0.5f) { return(new Color(0.31f, 0.28f, 0.26f)); } if (value < 0.75f) { return(new Color(0.25f, 0.2f, 0.15f)); } return(new Color(0.3f, 0.2f, 0.1f)); } else { float value2 = Rand.Value; if (value2 < 0.25f) { return(new Color(0.3529412f, 0.227450982f, 0.1254902f)); } if (value2 < 0.5f) { return(new Color(0.5176471f, 0.3254902f, 0.184313729f)); } if (value2 < 0.75f) { return(new Color(0.75686276f, 0.572549045f, 0.333333343f)); } return(new Color(0.929411769f, 0.7921569f, 0.6117647f)); } }
private static void ResolveMySkinColor(ref PawnGenerationRequest request, Pawn child, Pawn otherParent) { if (!request.FixedMelanin.HasValue) { if (otherParent != null) { request.SetFixedMelanin(ParentRelationUtility.GetRandomSecondParentSkinColor(otherParent.story.melanin, child.story.melanin)); } else { request.SetFixedMelanin(PawnSkinColors.GetRandomMelaninSimilarTo(child.story.melanin)); } } }
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); }
public static Color RandomHairColor(Color skinColor, int ageYears) { if (Rand.Value < 0.02f) { return(new Color(Rand.Value, Rand.Value, Rand.Value)); } if (ageYears > 40) { float num = GenMath.SmootherStep(40f, 75f, ageYears); if (Rand.Value < num) { float num2 = Rand.Range(0.65f, 0.85f); return(new Color(num2, num2, num2)); } } if (PawnSkinColors.IsDarkSkin(skinColor) || Rand.Value < 0.5f) { float value = Rand.Value; if (value < 0.25f) { return(new Color(0.2f, 0.2f, 0.2f)); } if (value < 0.5f) { return(new Color(0.31f, 0.28f, 0.26f)); } if (value < 0.75f) { return(new Color(0.25f, 0.2f, 0.15f)); } return(new Color(0.3f, 0.2f, 0.1f)); } float value2 = Rand.Value; if (value2 < 0.25f) { return(new Color(0.3529412f, 58f / 255f, 32f / 255f)); } if (value2 < 0.5f) { return(new Color(44f / 85f, 83f / 255f, 47f / 255f)); } if (value2 < 0.75f) { return(new Color(193f / 255f, 146f / 255f, 0.333333343f)); } return(new Color(79f / 85f, 202f / 255f, 52f / 85f)); }
public static Color GetSkinColor(float melanin) { int skinDataIndexOfMelanin = PawnSkinColors.GetSkinDataIndexOfMelanin(melanin); Color result; if (skinDataIndexOfMelanin == PawnSkinColors.SkinColors.Length - 1) { result = PawnSkinColors.SkinColors[skinDataIndexOfMelanin].color; } else { float t = Mathf.InverseLerp(PawnSkinColors.SkinColors[skinDataIndexOfMelanin].melanin, PawnSkinColors.SkinColors[skinDataIndexOfMelanin + 1].melanin, melanin); result = Color.Lerp(PawnSkinColors.SkinColors[skinDataIndexOfMelanin].color, PawnSkinColors.SkinColors[skinDataIndexOfMelanin + 1].color, t); } return(result); }
private static void ResolveMySkinColor(ref PawnGenerationRequest request, Pawn generatedChild) { if (!request.FixedMelanin.HasValue) { if (generatedChild.GetFather() != null && generatedChild.GetMother() != null) { request.SetFixedMelanin(ChildRelationUtility.GetRandomChildSkinColor(generatedChild.GetFather().story.melanin, generatedChild.GetMother().story.melanin)); } else if (generatedChild.GetFather() != null) { request.SetFixedMelanin(PawnSkinColors.GetRandomMelaninSimilarTo(generatedChild.GetFather().story.melanin)); } else { request.SetFixedMelanin(PawnSkinColors.GetRandomMelaninSimilarTo(generatedChild.GetMother().story.melanin)); } } }
public static bool IsDarkSkin(Color color) { Color skinColor = PawnSkinColors.GetSkinColor(0.5f); return(color.r + color.g + color.b <= skinColor.r + skinColor.g + skinColor.b + 0.01f); }