예제 #1
0
        protected OptionsHair InitializeHairs(ThingDef raceDef)
        {
            AlienRace alienRace = AlienRaceProvider.GetAlienRace(raceDef);

            if (alienRace == null)
            {
                return(HumanlikeHairs);
            }
            if (!alienRace.HasHair)
            {
                return(noHair);
            }
            // If the alien race does not have a limited set of hairs, then we'll try to re-use the humanlike hair options.
            if (alienRace.HairTags == null)
            {
                // If the selection of hairs is the same and the alien race has no custom color generator, then
                // we can just re-use the humanlike hair options.
                if (alienRace.HairColors == null)
                {
                    return(HumanlikeHairs);
                }
                // If there is a custom color generator, then we make a copy of the humanlike hair options--preserving
                // the HairDef lists--but we replace the color list.
                else
                {
                    OptionsHair humanHairs           = HumanlikeHairs;
                    OptionsHair humanHairsWithColors = new OptionsHair();
                    humanHairsWithColors.MaleHairs     = humanHairs.MaleHairs;
                    humanHairsWithColors.FemaleHairs   = humanHairs.FemaleHairs;
                    humanHairsWithColors.NoGenderHairs = humanHairs.NoGenderHairs;
                    humanHairsWithColors.Colors        = alienRace.HairColors.ToList();
                    return(humanHairsWithColors);
                }
            }
            OptionsHair result = new OptionsHair();

            foreach (HairDef hairDef in DefDatabase <HairDef> .AllDefs.Where((HairDef def) => {
                foreach (var tag in def.hairTags)
                {
                    if (alienRace.HairTags.Contains(tag))
                    {
                        return(true);
                    }
                }
                return(false);
            }))
            {
                result.AddHair(hairDef);
            }

            if (alienRace.HairColors != null)
            {
                result.Colors = alienRace.HairColors.ToList();
            }

            result.Sort();
            return(result);
        }
예제 #2
0
        protected OptionsApparel InitializeApparel(ThingDef raceDef)
        {
            AlienRace alienRace = AlienRaceProvider.GetAlienRace(raceDef);

            if (alienRace == null)
            {
                return(HumanlikeApparel);
            }
            // If the alien race does not have a restricted set of apparel, then we'll re-use the
            // humanlike apparel options.
            if (!alienRace.RestrictedApparelOnly && alienRace.RestrictedApparel == null)
            {
                return(HumanlikeApparel);
            }
            OptionsApparel   result       = new OptionsApparel();
            HashSet <string> addedAlready = new HashSet <string>();

            if (alienRace.RestrictedApparel != null)
            {
                foreach (var defName in alienRace.RestrictedApparel)
                {
                    AddApparel(result, defName);
                    addedAlready.Add(defName);
                }
            }
            if (!alienRace.RestrictedApparelOnly)
            {
                OptionsApparel humanApparel = HumanlikeApparel;
                foreach (var def in humanApparel.AllApparel)
                {
                    if (!addedAlready.Contains(def.defName))
                    {
                        AddApparel(result, def);
                        addedAlready.Add(def.defName);
                    }
                }
            }
            result.Sort();
            return(result);
        }