Exemple #1
0
        public PawnFace([NotNull] CompFace face, FactionDef pawnFactionDef, bool newPawn = true)
        {
            Pawn pawn = face.Pawn;

            this.DrawMouth = true;
            if (pawnFactionDef == null)
            {
                pawnFactionDef = FactionDefOf.PlayerColony;
            }

            this.EyeDef  = PawnFaceMaker.RandomEyeDefFor(pawn, pawnFactionDef);
            this.EarDef  = PawnFaceMaker.RandomEarDefFor(pawn, pawnFactionDef);
            this.BrowDef = PawnFaceMaker.RandomBrowDefFor(pawn, pawnFactionDef);

            this.WrinkleDef = PawnFaceMaker.AssignWrinkleDefFor(pawn);

            this.HasSameBeardColor = Rand.Value > 0.3f;

            this.GenerateHairDNA(pawn, false, newPawn);

            PawnFaceMaker.RandomBeardDefFor(face, pawnFactionDef, out this._beardDef, out this._moustacheDef);

            this.WrinkleIntensity  = Mathf.InverseLerp(45f, 80f, pawn.ageTracker.AgeBiologicalYearsFloat);
            this.WrinkleIntensity -= pawn.story.melanin / 2;

            // this.MelaninOrg = pawn.story.melanin;
        }
        public static bool RandomHairDefFor_PreFix(Pawn pawn, FactionDef factionType, ref HairDef __result)
        {
            //  Log.Message("1 - " + pawn);
            if (!pawn.GetCompFace(out CompFace compFace))
            {
                return(true);
            }

            //   Log.Message("2 - " + pawn.def.defName);

            if (compFace.Props.useAlienRacesHairTags)
            {
                return(true);
            }

            FactionDef faction = factionType;

            if (faction == null)
            {
                faction = FactionDefOf.PlayerColony;
            }

            List <string> hairTags = faction.hairTags;

            if (pawn.def == ThingDefOf.Human)
            {
                List <string> vanillatags = new List <string> {
                    "Urban", "Rural", "Punk", "Tribal"
                };
                if (!hairTags.Any(x => vanillatags.Contains(x)))
                {
                    hairTags.AddRange(vanillatags);
                }
            }

            IEnumerable <HairDef> source = from hair in DefDatabase <HairDef> .AllDefs
                                           where hair.hairTags.SharesElementWith(hairTags)
                                           select hair;

            __result = source.RandomElementByWeight(hair => PawnFaceMaker.HairChoiceLikelihoodFor(hair, pawn));
            return(false);
        }