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