protected OptionsHair InitializeHumanlikeHairs() { HashSet <string> nonHumanHairTags = new HashSet <string>(); IEnumerable <ThingDef> alienRaces = DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => { return(def.race != null && ProviderAlienRaces.IsAlienRace(def)); }); foreach (var alienRaceDef in alienRaces) { AlienRace alienRace = AlienRaceProvider.GetAlienRace(alienRaceDef); if (alienRace == null) { continue; } if (alienRace.HairTags != null) { foreach (var tag in alienRace.HairTags) { nonHumanHairTags.Add(tag); } } } OptionsHair result = new OptionsHair(); foreach (HairDef hairDef in DefDatabase <HairDef> .AllDefs.Where((HairDef def) => { foreach (var tag in def.hairTags) { if (nonHumanHairTags.Contains(tag)) { return(false); } } return(true); })) { result.AddHair(hairDef); } result.Sort(); // Set up default hair colors result.Colors.Add(new Color(0.2f, 0.2f, 0.2f)); result.Colors.Add(new Color(0.31f, 0.28f, 0.26f)); result.Colors.Add(new Color(0.25f, 0.2f, 0.15f)); result.Colors.Add(new Color(0.3f, 0.2f, 0.1f)); result.Colors.Add(new Color(0.3529412f, 0.227451f, 0.1254902f)); result.Colors.Add(new Color(0.5176471f, 0.3254902f, 0.1843137f)); result.Colors.Add(new Color(0.7568628f, 0.572549f, 0.3333333f)); result.Colors.Add(new Color(0.9294118f, 0.7921569f, 0.6117647f)); return(result); }
protected OptionsBodyType InitializeBodyTypes(ThingDef def) { if (!ProviderAlienRaces.IsAlienRace(def)) { return(InitializeHumanlikeBodyTypes()); } else { OptionsBodyType result = InitializeAlienRaceBodyTypes(def); if (result == null) { Logger.Warning("Could not initialize body types for alien race, " + def.defName + ". Defaulting to humanlike body types."); return(InitializeHumanlikeBodyTypes()); } return(result); } }
protected OptionsApparel InitializeHumanlikeApparel() { HashSet <string> nonHumanApparel = new HashSet <string>(); IEnumerable <ThingDef> alienRaces = DefDatabase <ThingDef> .AllDefs.Where((ThingDef def) => { return(def.race != null && ProviderAlienRaces.IsAlienRace(def)); }); foreach (var alienRaceDef in alienRaces) { AlienRace alienRace = AlienRaceProvider.GetAlienRace(alienRaceDef); if (alienRace == null) { continue; } if (alienRace.RestrictedApparel != null) { foreach (var defName in alienRace.RestrictedApparel) { nonHumanApparel.Add(defName); } } } OptionsApparel result = new OptionsApparel(); foreach (ThingDef apparelDef in DefDatabase <ThingDef> .AllDefs) { if (apparelDef.apparel == null) { continue; } if (!nonHumanApparel.Contains(apparelDef.defName)) { AddApparel(result, apparelDef); } } result.Sort(); return(result); }
protected OptionsBodyType InitializeBodyTypes(ThingDef def) { if (!ProviderAlienRaces.IsAlienRace(def)) { return(InitializeHumanlikeBodyTypes()); } else { OptionsBodyType result = InitializeAlienRaceBodyTypes(def); if (result == null) { Log.Warning("Prepare Carefully could not initialize body types for alien race, " + def.defName + ". Defaulting to humanlike body types."); return(InitializeHumanlikeBodyTypes()); } if (result.MaleBodyTypes.Count == 0 || result.FemaleBodyTypes.Count == 0) { return(InitializeHumanlikeBodyTypes()); } else { return(result); } } }