private static NameTriple GeneratePawnName_Shuffled(Pawn pawn, string forcedLastName = null) { PawnNameCategory pawnNameCategory = pawn.RaceProps.nameCategory; if (pawnNameCategory == PawnNameCategory.NoName) { Log.Message("ProPawnBioAndNameGenerator.GeneratePawnName_Shuddled: Can't create a name of type NoName. Defaulting to HumanStandard."); pawnNameCategory = PawnNameCategory.HumanStandard; } NameBank nameBank = PawnNameDatabaseShuffled.BankOf(pawnNameCategory); string name = nameBank.GetName(PawnNameSlot.First, pawn.gender); string text; if (forcedLastName != null) { text = forcedLastName; } else { text = nameBank.GetName(PawnNameSlot.Last, Gender.None); } int num = 0; string nick; do { num++; if (Rand.Value < 0.15f) { Gender gender = pawn.gender; if (Rand.Value < 0.5f) { gender = Gender.None; } nick = nameBank.GetName(PawnNameSlot.Nick, gender); } else if (Rand.Value < 0.5f) { nick = name; } else { nick = text; } }while (num < 50 && NameUseChecker.AllPawnsNamesEverUsed.Any(delegate(Name x) { NameTriple nameTriple = x as NameTriple; return(nameTriple != null && nameTriple.Nick == nick); })); return(new NameTriple(name, nick, text)); }
public override string Generate() { NameBank nameBank = PawnNameDatabaseShuffled.BankOf(PawnNameCategory.HumanStandard); Gender gender = this.gender; if (gender == Gender.None) { gender = ((Rand.Value < 0.5f) ? Gender.Male : Gender.Female); } return(nameBank.GetName(PawnNameSlot.First, gender, checkIfAlreadyUsed: false)); }
public override string Generate() { NameBank nameBank = PawnNameDatabaseShuffled.BankOf(PawnNameCategory.HumanStandard); Gender gender = this.gender; if (gender == Gender.None) { gender = (Gender)((Rand.Value < 0.5) ? 1 : 2); } return(nameBank.GetName(PawnNameSlot.First, gender)); }
public static void RandomColonists() { Population.Clear(); ShirtList.Clear(); CoatList.Clear(); ClothingList.Clear(); allBackstories.Clear(); NameBank nameBank = NameShuffleDatabase.BankOf((NameCategory)1); GenClothingList(); GenHairList(); //Load in Backstories from BackstoryDatabase for (int a = 0; a < BackstoryDatabase.allBackstories.Count - 1; a++) { allBackstories.Add(BackstoryDatabase.allBackstories.ElementAt(a).Value); } List <Backstory> SortedBackstories = allBackstories.OrderBy(o => o.title).ToList(); allBackstories = SortedBackstories; //Generate new random colonists for (int i = 0; i < ColonistNum.Amount; i++) { Colonist colonist = new Colonist(); //Gen random colonist basic info int gender = UnityEngine.Random.Range(1, 100); if (gender > 50) { gender = 1; int body = UnityEngine.Random.Range(1, 4); if (body == 1) { colonist.BodyType = BodyType.Male; } else if (body == 2) { colonist.BodyType = BodyType.Thin; } else if (body == 3) { colonist.BodyType = BodyType.Hulk; } else if (body == 4) { colonist.BodyType = BodyType.Fat; } } else { gender = 2; int body = UnityEngine.Random.Range(1, 4); if (body == 1) { colonist.BodyType = BodyType.Female; } else if (body == 2) { colonist.BodyType = BodyType.Thin; } else if (body == 3) { colonist.BodyType = BodyType.Hulk; } else if (body == 4) { colonist.BodyType = BodyType.Fat; } } colonist.Gender = gender; colonist.FirstName = nameBank.GetName((Gender)colonist.Gender, (NameSlot)0); colonist.NickName = nameBank.GetName((Gender)colonist.Gender, (NameSlot)2); colonist.LastName = nameBank.GetName((Gender)0, (NameSlot)1); colonist.Age = UnityEngine.Random.Range(16, 70); //Gen colonist starting skills List <Colonist_Skill> skills = new List <Colonist_Skill>(); if (ColonistDifficulty.Difficulty == "Easy") { colonist.SkillPool = 40; } else if (ColonistDifficulty.Difficulty == "Normal") { colonist.SkillPool = 20; } else { colonist.SkillPool = 0; } for (int a = 0; a < 11; a++) { Colonist_Skill skill = new Colonist_Skill(); if (a == 0) { skill.SkillName = "Construction".Translate(); skill.SkillPassion = 1; } else if (a == 1) { skill.SkillName = "Growing".Translate(); skill.SkillPassion = 2; } else if (a == 2) { skill.SkillName = "Research".Translate(); skill.SkillPassion = 3; } else if (a == 3) { skill.SkillName = "Mining".Translate(); } else if (a == 4) { skill.SkillName = "Shooting".Translate(); } else if (a == 5) { skill.SkillName = "Melee".Translate(); } else if (a == 6) { skill.SkillName = "Social".Translate(); } else if (a == 7) { skill.SkillName = "Cooking".Translate(); } else if (a == 8) { skill.SkillName = "Medicine".Translate(); } else if (a == 9) { skill.SkillName = "Artistic".Translate(); } else if (a == 10) { skill.SkillName = "Crafting".Translate(); } skill.SkillValue = 0; skills.Add(skill); } colonist.Skills = skills; //Load Backstories childstories.Clear(); adultstories.Clear(); ChildStoryIndex = 0; AdultStoryIndex = 0; List <Colonist_Backstory> ColonistStory = new List <Colonist_Backstory>(); for (int a = 0; a < allBackstories.Count - 1; a++) { bool ChildStoryFound = false; bool AdultStoryFound = false; Colonist_Backstory story = new Colonist_Backstory(); if (allBackstories[a].slot == BackstorySlot.Childhood) { story.StoryName = allBackstories[a].title; story.StoryAge = 0; story.BaseDescription = allBackstories[a].baseDesc; story.BodyTypeFemale = allBackstories[a].bodyTypeFemale; story.BodyTypeMale = allBackstories[a].bodyTypeMale; story.BodyTypeGlobal = allBackstories[a].bodyTypeGlobal; story.StoryIndex = ChildStoryIndex; List <StorySkillGain> skillGains = new List <StorySkillGain>(); for (int b = 0; b < allBackstories[a].skillGainsResolved.Count - 1; b++) { StorySkillGain skillGain = new StorySkillGain(); skillGain.SkillName = allBackstories[a].skillGainsResolved.ElementAt(b).Key.skillLabel; skillGain.SkillValue = allBackstories[a].skillGainsResolved.ElementAt(b).Value; skillGains.Add(skillGain); } story.SkillGains = skillGains; List <string> workRestrictions = new List <string>(); foreach (WorkTypeDef work in allBackstories[a].DisabledWorkTypes) { workRestrictions.Add(work.defName); } story.WorkRestrictions = workRestrictions; for (int b = 0; b < childstories.Count - 1; b++) { if (childstories[b].StoryName == story.StoryName) { ChildStoryFound = true; } } if (ChildStoryFound == false) { childstories.Add(story); ChildStoryIndex = ChildStoryIndex + 1; } } if (colonist.Gender == 1) { if (allBackstories[a].slot == BackstorySlot.Adulthood) { if (allBackstories[a].bodyTypeMale == colonist.BodyType || allBackstories[a].bodyTypeGlobal == colonist.BodyType) { story.StoryName = allBackstories[a].title; story.StoryAge = 1; story.BaseDescription = allBackstories[a].baseDesc; story.BodyTypeFemale = allBackstories[a].bodyTypeFemale; story.BodyTypeMale = allBackstories[a].bodyTypeMale; story.BodyTypeGlobal = allBackstories[a].bodyTypeGlobal; story.StoryIndex = AdultStoryIndex; List <StorySkillGain> skillGains = new List <StorySkillGain>(); for (int b = 0; b < allBackstories[a].skillGainsResolved.Count - 1; b++) { StorySkillGain skillGain = new StorySkillGain(); skillGain.SkillName = allBackstories[a].skillGainsResolved.ElementAt(b).Key.skillLabel; skillGain.SkillValue = allBackstories[a].skillGainsResolved.ElementAt(b).Value; skillGains.Add(skillGain); } story.SkillGains = skillGains; List <string> workRestrictions = new List <string>(); foreach (WorkTypeDef work in allBackstories[a].DisabledWorkTypes) { workRestrictions.Add(work.defName); } story.WorkRestrictions = workRestrictions; for (int b = 0; b < ColonistManager.AdultStories.Count - 1; b++) { if (ColonistManager.AdultStories[b].StoryName == story.StoryName) { AdultStoryFound = true; } } if (AdultStoryFound == false) { ColonistManager.AdultStories.Add(story); AdultStoryIndex = AdultStoryIndex + 1; } } } } else if (colonist.Gender == 2) { if (allBackstories[a].slot == BackstorySlot.Adulthood) { if (allBackstories[a].bodyTypeFemale == colonist.BodyType || allBackstories[a].bodyTypeGlobal == colonist.BodyType) { story.StoryName = allBackstories[a].title; story.StoryAge = 1; story.BaseDescription = allBackstories[a].baseDesc; story.BodyTypeFemale = allBackstories[a].bodyTypeFemale; story.BodyTypeMale = allBackstories[a].bodyTypeMale; story.BodyTypeGlobal = allBackstories[a].bodyTypeGlobal; story.StoryIndex = AdultStoryIndex; List <StorySkillGain> skillGains = new List <StorySkillGain>(); for (int b = 0; b < allBackstories[a].skillGainsResolved.Count - 1; b++) { StorySkillGain skillGain = new StorySkillGain(); skillGain.SkillName = allBackstories[a].skillGainsResolved.ElementAt(b).Key.skillLabel; skillGain.SkillValue = allBackstories[a].skillGainsResolved.ElementAt(b).Value; skillGains.Add(skillGain); } story.SkillGains = skillGains; List <string> workRestrictions = new List <string>(); foreach (WorkTypeDef work in allBackstories[a].DisabledWorkTypes) { workRestrictions.Add(work.defName); } story.WorkRestrictions = workRestrictions; for (int b = 0; b < ColonistManager.AdultStories.Count - 1; b++) { if (ColonistManager.AdultStories[b].StoryName == story.StoryName) { AdultStoryFound = true; } } if (AdultStoryFound == false) { ColonistManager.AdultStories.Add(story); AdultStoryIndex = AdultStoryIndex + 1; } } } } } //Gen random childhood backstory ColonistStory.Add(childstories[UnityEngine.Random.Range(0, childstories.Count - 1)]); //Gen random adulthood backstory ColonistStory.Add(adultstories[UnityEngine.Random.Range(0, adultstories.Count - 1)]); colonist.Backstory = ColonistStory; //Gen random traits int rand_trait = 0; List <StoryTrait> StoryTraits = new List <StoryTrait>(); foreach (TraitDef trait in DefDatabase <TraitDef> .AllDefsListForReading) { StoryTrait storyTrait = new StoryTrait(); storyTrait.TraitName = trait.label; storyTrait.Effect = trait.effect; StoryTraits.Add(storyTrait); } StoryTrait storytrait = new StoryTrait(); storytrait = new StoryTrait(); rand_trait = UnityEngine.Random.Range(0, StoryTraits.Count - 1); storytrait.TraitName = StoryTraits[rand_trait].TraitName; storytrait.Effect = StoryTraits[rand_trait].Effect; storytrait.TraitDescription = StoryTraits[rand_trait].TraitDescription; StoryTraits.Add(storytrait); StoryTrait storytrait2 = new StoryTrait(); int rand_trait2 = 0; rand_trait2 = UnityEngine.Random.Range(0, StoryTraits.Count - 1); storytrait2.TraitName = StoryTraits[rand_trait2].TraitName; storytrait2.Effect = StoryTraits[rand_trait].Effect; storytrait2.TraitDescription = StoryTraits[rand_trait2].TraitDescription; StoryTraits.Add(storytrait2); colonist.Traits = StoryTraits; //Gen Apparel List <Clothing> Outfit = new List <Clothing>(); Clothing clothing = new Clothing(); clothing = ShirtList.RandomListElement <Clothing>(); Outfit.Add(clothing); clothing = new Clothing(); clothing = CoatList.RandomListElement <Clothing>(); Outfit.Add(clothing); colonist.Clothing = Outfit; //Gen Body colonist.SkinColor = RandomSkinColor(); colonist.CrownType = ((UnityEngine.Random.value >= 0.5f) ? CrownType.Narrow : CrownType.Average); colonist.HeadGraphicPath = GraphicDatabase_Head.GetHeadRandom((Gender)colonist.Gender, colonist.SkinColor, colonist.CrownType).graphicPath; //Gen Hair colonist.HairColor = RandomHairColor(colonist.SkinColor); ColHairDef hairDef = new ColHairDef(); if (colonist.Gender == 1) { hairDef = MaleHairList.RandomListElement <ColHairDef>(); } else if (colonist.Gender == 2) { hairDef = FemaleHairList.RandomListElement <ColHairDef>(); } colonist.HairDef = hairDef; //Set BodyType if (colonist.Backstory[1].BodyTypeGlobal.ToString() != "Undefined") { colonist.BodyType = colonist.Backstory[1].BodyTypeGlobal; } else { if (colonist.Gender == 1 && colonist.Backstory[1].BodyTypeMale.ToString() != "Undefined") { colonist.BodyType = colonist.Backstory[1].BodyTypeMale; } else if (colonist.Gender == 1 && colonist.Backstory[1].BodyTypeMale.ToString() == "Undefined") { colonist.BodyType = BodyType.Male; } if (colonist.Gender == 2 && colonist.Backstory[1].BodyTypeFemale.ToString() != "Undefined") { colonist.BodyType = colonist.Backstory[1].BodyTypeFemale; } else if (colonist.Gender == 2 && colonist.Backstory[1].BodyTypeFemale.ToString() == "Undefined") { colonist.BodyType = BodyType.Male; } } //Gen Weapon GenWeaponList(); colonist.Weapon = WeaponList.RandomListElement <string>(); //Add colonist to total population Population.Add(colonist); } }