Ejemplo n.º 1
0
 private static ThingDef_AlienRace.AlienSettings GenerateHybridAlienSettings(ThingDef_AlienRace.AlienSettings human, MorphDef morph, ThingDef_AlienRace impliedRace)
 {
     return(new ThingDef_AlienRace.AlienSettings
     {
         generalSettings = GenerateHybridGeneralSettings(human.generalSettings, morph, impliedRace),
         graphicPaths = GenerateGraphicPaths(human.graphicPaths, morph),
         hairSettings = human.hairSettings,
         raceRestriction = GenerateHybridRestrictionSettings(human.raceRestriction, morph),
         relationSettings = human.relationSettings,
         thoughtSettings = morph.raceSettings.GenerateThoughtSettings(human.thoughtSettings, morph)
     });
 }
Ejemplo n.º 2
0
        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);
        }