private static void GetRandomizedMelaninAndCuticula([NotNull] Pawn pawn, ref HairColorRequest hairColor) { hairColor.PheoMelanin = Rand.Range(0f, 1f); hairColor.EuMelanin = Rand.Range(pawn.story.melanin * 0.75f, 1f); // hairColor.Baldness.maxBaldness = (int)Rand.Range(0f, 10f); }
private static bool GetHairDNAByBlood([NotNull] Pawn pawn, ref HairColorRequest hairColor) { if (!pawn.relations.FamilyByBlood.Any()) { return(false); } Pawn relPawn = pawn.relations.FamilyByBlood.FirstOrDefault( x => x.HasPawnFace()); if (relPawn == null || !relPawn.GetPawnFace(out PawnFace pawnFace)) { return(false); } // ReSharper disable once PossibleNullReferenceException float melaninx1 = pawnFace.EuMelanin; float melaninx2 = pawnFace.PheoMelanin; // float maxbaldness = relatedPawn.PawnFace.Baldness.maxBaldness; hairColor.EuMelanin = GetRandomFloatSimilarTo(melaninx1); hairColor.PheoMelanin = GetRandomFloatSimilarTo(melaninx2); // hairColor.Baldness.maxBaldness = (int)GetRandomFloatSimilarTo(maxbaldness, 0f, 10f); // hair.Cuticula = GetRandomFloatSimilarTo(cuticulax); return(true); }
private static void GetRandomizedMelaninAndCuticula(ref HairColorRequest hairColor) { hairColor.PheoMelanin = Rand.Range(0f, 1f); hairColor.EuMelanin = Rand.Range(0f, 1f); // hairColor.Baldness.maxBaldness = (int)Rand.Range(0f, 10f); }
private static void SetInitialHairMelaninLevels( Pawn pawn, out HairColorRequest hairColor, bool ignoreRelative = false) { hairColor = new HairColorRequest(0f, 0f, 0f); bool flag = false; if (!ignoreRelative) { PawnFace motherPawnFace = GetMotherFace(pawn); bool hasMother = motherPawnFace != null; PawnFace fatherPawnFace = GetFatherFace(pawn); bool hasFather = fatherPawnFace != null; if (hasMother && hasFather) { hairColor.EuMelanin = // ReSharper disable once PossibleNullReferenceException GetRandomChildFloatValue(motherPawnFace.EuMelanin, fatherPawnFace.EuMelanin); hairColor.PheoMelanin = GetRandomChildFloatValue(motherPawnFace.PheoMelanin, fatherPawnFace.PheoMelanin); // hairColor.Baldness.maxBaldness = (int)GetRandomChildFloatValue(motherPawnFace.Baldness.maxBaldness, fatherPawnFace.Baldness.maxBaldness); flag = true; } else if (hasMother) { // ReSharper disable once PossibleNullReferenceException hairColor.EuMelanin = GetRandomFloatSimilarTo(motherPawnFace.EuMelanin); hairColor.PheoMelanin = GetRandomFloatSimilarTo(motherPawnFace.PheoMelanin); // hairColor.Baldness.maxBaldness = (int)GetRandomFloatSimilarTo(motherPawnFace.Baldness.maxBaldness, 0f, 10f); flag = true; } else if (hasFather) { hairColor.EuMelanin = GetRandomFloatSimilarTo(fatherPawnFace.EuMelanin); hairColor.PheoMelanin = GetRandomFloatSimilarTo(fatherPawnFace.PheoMelanin); // hairColor.Baldness.maxBaldness = (int)GetRandomFloatSimilarTo(fatherPawnFace.Baldness.maxBaldness, 0f, 10f); flag = true; } // Check for relatives, else randomize if (!flag && GetHairDNAByBlood(pawn, ref hairColor)) { flag = true; } } if (!flag) { GetRandomizedMelaninAndCuticula(ref hairColor); } // hairColor.Baldness.currentBaldness = Rand.Range(0, hairColor.Baldness.maxBaldness); }
public static Color GetHairColor(HairColorRequest hairColorRequest) { Color color = GradientEuMelanin.Evaluate(hairColorRequest.EuMelanin); color *= GradientPheoMelanin.Evaluate(hairColorRequest.PheoMelanin); // var cuticula = Mathf.Lerp(cuticulaRange.min, cuticulaRange.max, hairRequest.Cuticula); float greyness = Mathf.Lerp(GreyRange.min, GreyRange.max, hairColorRequest.Greyness); // Color.RGBToHSV(color, out float h, out float s, out float v); // s *= cuticula; // color = Color.HSVToRGB(h, s, v); // limit the greyness to 70 %, else it's too much color = Color.Lerp(color, GrayHair, greyness); return(color); }
public static Color GetCurrentHairColor(this PawnFace face) { HairColorRequest colorRequest = new HairColorRequest(face.PheoMelanin, face.EuMelanin, face.Greyness); return(GetHairColor(colorRequest)); }