protected OptionsHeadType InitializeHumanHeadTypes()
        {
            MethodInfo headGraphicsMethod = typeof(GraphicDatabaseHeadRecords).GetMethod("BuildDatabaseIfNecessary", BindingFlags.Static | BindingFlags.NonPublic);

            headGraphicsMethod.Invoke(null, null);
            string[] headsFolderPaths = new string[] {
                "Things/Pawn/Humanlike/Heads/Male",
                "Things/Pawn/Humanlike/Heads/Female"
            };
            OptionsHeadType result = new OptionsHeadType();

            for (int i = 0; i < headsFolderPaths.Length; i++)
            {
                string text = headsFolderPaths[i];
                IEnumerable <string> graphicsInFolder = GraphicDatabaseUtility.GraphicNamesInFolder(text);
                foreach (string current in GraphicDatabaseUtility.GraphicNamesInFolder(text))
                {
                    string         fullPath = text + "/" + current;
                    CustomHeadType headType = CreateHeadTypeFromGenderedGraphicPath(fullPath);
                    result.AddHeadType(headType);
                    pathDictionary.Add(fullPath, headType);
                }
            }
            return(result);
        }
Ejemplo n.º 2
0
        public CustomHeadType FindHeadType(ThingDef race, string graphicsPath)
        {
            OptionsHeadType headTypes = GetHeadTypesForRace(race);

            //Logger.Debug("headTypes: \n" + String.Join("\n", headTypes.headTypes.ToList().ConvertAll(t => t.GraphicPath)));
            return(headTypes.FindHeadTypeByGraphicsPath(graphicsPath));
        }
Ejemplo n.º 3
0
        public CustomHeadType FindHeadTypeForPawn(Pawn pawn)
        {
            OptionsHeadType headTypes = GetHeadTypesForRace(pawn.def);
            var             result    = headTypes.FindHeadTypeForPawn(pawn);

            if (result == null)
            {
                Log.Warning("Could not find a head type for the pawn: " + pawn.def.defName + ". Head type selection disabled for this pawn");
            }
            return(result);
        }
Ejemplo n.º 4
0
        protected OptionsHeadType GetHeadTypesForRace(ThingDef race)
        {
            OptionsHeadType headTypes = null;

            if (!headTypeLookup.TryGetValue(race, out headTypes))
            {
                headTypes = InitializeHeadTypes(race);
                headTypeLookup.Add(race, headTypes);
            }
            if (headTypes == null && race != ThingDefOf.Human)
            {
                return(GetHeadTypesForRace(ThingDefOf.Human));
            }
            return(headTypes);
        }
Ejemplo n.º 5
0
        protected OptionsHeadType InitializeAlienHeadTypes(ThingDef raceDef)
        {
            //Logger.Debug("InitializeAlienHeadTypes(" + raceDef.defName + ")");
            AlienRace       alienRace = AlienRaceProvider.GetAlienRace(raceDef);
            OptionsHeadType result    = new OptionsHeadType();

            if (alienRace == null)
            {
                Logger.Warning("Could not initialize head types for alien race, " + raceDef + ", because the race's thing definition was missing");
                return(result);
            }
            //Logger.Debug("alienRace.GraphicsPathForHeads = " + alienRace.GraphicsPathForHeads);
            if (alienRace.GraphicsPathForHeads == null)
            {
                Logger.Warning("Could not initialize head types for alien race, " + raceDef + ", because no path for head graphics was found.");
                return(result);
            }
            foreach (var crownType in alienRace.CrownTypes)
            {
                //Logger.Debug(" - " + crownType);
                if (alienRace.GenderSpecificHeads)
                {
                    CustomHeadType maleHead   = CreateGenderedAlienHeadTypeFromCrownType(alienRace.GraphicsPathForHeads, crownType, Gender.Male);
                    CustomHeadType femaleHead = CreateGenderedAlienHeadTypeFromCrownType(alienRace.GraphicsPathForHeads, crownType, Gender.Female);
                    if (maleHead != null)
                    {
                        //Logger.Debug("   - MALE: " + maleHead.GraphicPath);
                        result.AddHeadType(maleHead);
                    }
                    if (femaleHead != null)
                    {
                        //Logger.Debug("   - FEMALE: " + femaleHead.GraphicPath);
                        result.AddHeadType(femaleHead);
                    }
                }
                else
                {
                    CustomHeadType head = CreateMultiGenderAlienHeadTypeFromCrownType(alienRace.GraphicsPathForHeads, crownType);
                    if (head != null)
                    {
                        //Logger.Debug("   - MULTIGENDER: " + head.GraphicPath);
                        result.AddHeadType(head);
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 6
0
        protected OptionsHeadType InitializeAlienHeadTypes(ThingDef raceDef)
        {
            AlienRace       alienRace = AlienRaceProvider.GetAlienRace(raceDef);
            OptionsHeadType result    = new OptionsHeadType();

            if (alienRace == null)
            {
                Log.Warning("Prepare Carefully could not initialize head types for alien race, " + raceDef);
                return(result);
            }
            if (alienRace.GraphicsPathForHeads == null)
            {
                Log.Warning("Prepare Carefully could not initialize head types for alien race, " + raceDef + ", because no path for head graphics was found.");
                return(result);
            }
            foreach (var crownType in alienRace.CrownTypes)
            {
                if (alienRace.GenderSpecificHeads)
                {
                    CustomHeadType maleHead   = CreateGenderedAlienHeadTypeFromCrownType(alienRace.GraphicsPathForHeads, crownType, Gender.Male);
                    CustomHeadType femaleHead = CreateGenderedAlienHeadTypeFromCrownType(alienRace.GraphicsPathForHeads, crownType, Gender.Female);
                    if (maleHead != null)
                    {
                        result.AddHeadType(maleHead);
                    }
                    if (femaleHead != null)
                    {
                        result.AddHeadType(femaleHead);
                    }
                }
                else
                {
                    CustomHeadType head = CreateMultiGenderAlienHeadTypeFromCrownType(alienRace.GraphicsPathForHeads, crownType);
                    if (head != null)
                    {
                        result.AddHeadType(head);
                    }
                }
            }
            return(result);
        }
Ejemplo n.º 7
0
        protected OptionsHeadType InitializeHumanHeadTypes()
        {
            Reflection.GraphicDatabaseHeadRecords.BuildDatabaseIfNecessary();
            string[] headsFolderPaths = new string[] {
                "Things/Pawn/Humanlike/Heads/Male",
                "Things/Pawn/Humanlike/Heads/Female"
            };
            OptionsHeadType result = new OptionsHeadType();

            for (int i = 0; i < headsFolderPaths.Length; i++)
            {
                string text = headsFolderPaths[i];
                IEnumerable <string> graphicsInFolder = GraphicDatabaseUtility.GraphicNamesInFolder(text);
                foreach (string current in GraphicDatabaseUtility.GraphicNamesInFolder(text))
                {
                    string         fullPath = text + "/" + current;
                    CustomHeadType headType = CreateHumanHeadTypeFromGenderedGraphicPath(fullPath);
                    result.AddHeadType(headType);
                    pathDictionary.Add(fullPath, headType);
                }
            }
            return(result);
        }
Ejemplo n.º 8
0
        public CustomHeadType FindHeadTypeForGender(ThingDef race, CustomHeadType headType, Gender gender)
        {
            OptionsHeadType headTypes = GetHeadTypesForRace(race);

            return(headTypes.FindHeadTypeForGender(headType, gender));
        }
Ejemplo n.º 9
0
        public IEnumerable <CustomHeadType> GetHeadTypes(ThingDef race, Gender gender)
        {
            OptionsHeadType headTypes = GetHeadTypesForRace(race);

            return(headTypes.GetHeadTypesForGender(gender));
        }
Ejemplo n.º 10
0
        public CustomHeadType FindHeadType(ThingDef race, string graphicsPath)
        {
            OptionsHeadType headTypes = GetHeadTypesForRace(race);

            return(headTypes.FindHeadTypeByGraphicsPath(graphicsPath));
        }