public Dialog_AlienFaceStyling(CompFace face, ThingDef_AlienRace alienProp) : base(face)
        {
            Pawn = face.Pawn;
            PawnColorUtils.InitializeColors();
            this.alienRace = ProviderAlienRaces.GetAlienRace(alienProp, Pawn);
            AlienRace race = this.alienRace;

            if (race != null && race.HasHair)
            {
                HairDefs = DefDatabase <HairDef> .AllDefsListForReading.FindAll(
                    x =>
                    x.hairTags
                    .SharesElementWith(this.alienRace
                                       .HairTags) && !x.IsBeardNotHair());

                CurrentFilter = race.HairTags;
            }

            this.useSkincolorForHair = ((ThingDef_AlienRace)this.CompFace.Pawn.def)
                                       .alienRace.generalSettings.alienPartGenerator
                                       .useSkincolorForHair;
            this.genderTab = GenderTab.All;
        }
        public static AlienRace InitializeAlienRace(ThingDef_AlienRace raceDef, Pawn p)
        {
            ThingDef_AlienRace.AlienSettings race = raceDef.alienRace;
            GeneralSettings    generalSettings    = race?.generalSettings;
            AlienPartGenerator alienPartGenerator = generalSettings?.alienPartGenerator;

            if (alienPartGenerator == null)
            {
                return(null);
            }

            List <GraphicPaths> graphicsPaths = race.graphicPaths;

            if (graphicsPaths == null)
            {
                return(null);
            }

            // We have enough to start putting together the result object, so we instantiate it now.
            AlienRace result = new AlienRace();

            // Get the list of body types.
            List <BodyTypeDef> alienbodytypes = alienPartGenerator.alienbodytypes;

            if (alienbodytypes == null)
            {
                return(null);
            }

            List <BodyTypeDef> bodyTypes = new List <BodyTypeDef>();

            if (alienbodytypes.Count > 0)
            {
                foreach (BodyTypeDef o in alienbodytypes)
                {
                    bodyTypes.Add(o);
                }
            }

            result.BodyTypes = bodyTypes;

            // Determine if the alien races uses gender-specific heads.
            result.GenderSpecificHeads = alienPartGenerator.useGenderedHeads;

            result.CrownTypes = alienPartGenerator.aliencrowntypes;

            // Go through the graphics paths and find the heads path.
            string graphicsPathForHeads = null;

            foreach (GraphicPaths graphicsPath in graphicsPaths)
            {
                ICollection lifeStageCollection = GetFieldValueAsCollection(raceDef, graphicsPath, "lifeStageDefs");
                if (lifeStageCollection == null || lifeStageCollection.Count == 0)
                {
                    string path = GetFieldValueAsString(raceDef, graphicsPath, "head");
                    if (path != null)
                    {
                        graphicsPathForHeads = path;
                        break;
                    }
                }
            }

            result.GraphicsPathForHeads = graphicsPathForHeads;

            // Figure out colors.
            ColorGenerator primaryGenerator = alienPartGenerator.alienskincolorgen;

            result.UseMelaninLevels = true;
            if (primaryGenerator != null)
            {
                result.UseMelaninLevels = false;
                result.PrimaryColors    = primaryGenerator.GetColorList();
            }
            else
            {
                result.PrimaryColors = new List <Color>();
            }

            ColorGenerator secondaryGenerator = alienPartGenerator.alienskinsecondcolorgen;

            result.HasSecondaryColor = false;
            if (secondaryGenerator != null)
            {
                result.HasSecondaryColor = true;
                result.SecondaryColors   = secondaryGenerator.GetColorList();
            }
            else
            {
                result.SecondaryColors = new List <Color>();
            }

            // Hair properties.
            HairSettings hairSettings = race.hairSettings;

            result.HasHair = false;
            if (hairSettings != null)
            {
                result.HasHair = hairSettings.hasHair;

                if (hairSettings.hairTags.NullOrEmpty())
                {
                    result.HairTags = p.kindDef.defaultFactionType.hairTags;
                }
                else
                {
                    result.HairTags = hairSettings.hairTags;
                }
            }

            ColorGenerator hairColorGenerator = alienPartGenerator.alienhaircolorgen;

            if (hairColorGenerator != null)
            {
                result.HairColors = primaryGenerator.GetColorList();
            }
            else
            {
                result.HairColors = null;
            }

            return(result);
        }