protected SimDescription GetRandomSim(CASAgeGenderFlags gender, CASAgeGenderFlags species) { SimDescription result = null; if (species == CASAgeGenderFlags.Human) { SimUtils.SimCreationSpec sim = new SimUtils.SimCreationSpec(); Vector2 fatRange = Manager.GetValue <FatRangeOption <TManager>, Vector2>(); Vector2 fitRange = Manager.GetValue <FitRangeOption <TManager>, Vector2>(); WorldName worldName = GetGeneticWorld(); sim.Gender = gender; sim.Age = CASAgeGenderFlags.Adult; sim.Species = species; sim.Weight = RandomUtil.GetFloat(fatRange.x, fatRange.y); sim.Fitness = RandomUtil.GetFloat(fitRange.x, fitRange.y); sim.Description = ""; sim.GivenName = SimUtils.GetRandomFamilyName(worldName); result = sim.Instantiate(worldName, uint.MaxValue); result.VoiceVariation = (VoiceVariationType)RandomUtil.GetInt(0, 2); result.VoicePitchModifier = RandomUtil.GetFloat(0, 1f); Vector2 skintToneRange = Manager.GetValue <SkinToneRangeOption <TManager>, Vector2>(); result.SkinToneIndex = RandomUtil.GetFloat(skintToneRange.x, skintToneRange.y); } else { result = GeneticsPet.MakeRandomPet(CASAgeGenderFlags.Adult, gender, species, 1f); } SetBustMuscleSliders(result); FacialBlends.RandomizeBlends(mStats.AddStat, result, Manager.GetValue <MutationSetRangeOption <TManager>, Vector2>(), true, Manager.GetValue <MutationSetRangeOption <TManager>, Vector2>(), false, Manager.GetValue <AllowAlienHouseholdOption <TManager>, bool>()); mDispose.Add(result); mStats.IncStat("Immigrant: Random Sim"); return(result); }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me }), "0"); if (string.IsNullOrEmpty(text)) { return(false); } if (!int.TryParse(text, out mRange)) { SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error")); return(false); } if (mRange <= 0) { return(false); } mAdd = false; if (TwoButtonDialog.Show( Common.Localize(GetTitlePrefix() + ":AddPrompt", me.IsFemale, new object[] { me, mRange }), Common.Localize(GetTitlePrefix() + ":Add"), Common.Localize(GetTitlePrefix() + ":Reroll") )) { mAdd = true; } } float maximum = MasterController.Settings.mSliderMultiple; Vector2 range = new Vector2(-mRange / 256f, mRange / 256f); FacialBlends.RandomizeBlends(null, me, range, mAdd, range, true, false); return(true); }
public SimDescription CreateNewSim(SimDescription mom, SimDescription dad, CASAgeGenderFlags ages, CASAgeGenderFlags genders, CASAgeGenderFlags species, bool updateGenealogy) { if (dad == null) { dad = GetSim(CASAgeGenderFlags.Male, species, mom); if (dad == null) { dad = GetSim(CASAgeGenderFlags.Female, species, mom); if (dad == null) { return(null); } } } CASAgeGenderFlags gender = (CASAgeGenderFlags)RandomUtil.SelectOneRandomBit((uint)(genders)); CASAgeGenderFlags age = (CASAgeGenderFlags)RandomUtil.SelectOneRandomBit((uint)(ages)); if (dad.CelebrityManager == null) { dad.Fixup(); } if (mom.CelebrityManager == null) { mom.Fixup(); } SimDescription newSim = null; try { if (mom.Species == CASAgeGenderFlags.Human) { newSim = Genetics.MakeDescendant(dad, mom, age, gender, 100, new Random(), false, updateGenealogy, true, GetGeneticWorld(), false); newSim.HomeWorld = GameUtils.GetCurrentWorld(); } else { newSim = GeneticsPet.MakePetDescendant(dad, mom, age, gender, mom.Species, new Random(), updateGenealogy, GeneticsPet.SetName.SetNameNonInteractive, 0, OccultTypes.None); } } catch (Exception e) { Common.Exception(dad, mom, e); } if (newSim == null) { return(null); } if (!updateGenealogy) { FacialBlends.RandomizeBlends(mStats.AddStat, newSim, new Vector2(0f, 0f), true, Manager.GetValue <MutationUnsetRangeOption <TManager>, Vector2>(), true, Manager.GetValue <AllowAlienHouseholdOption <TManager>, bool>()); } List <OccultTypes> occults = new List <OccultTypes>(); occults.AddRange(OccultTypeHelper.CreateList(mom.OccultManager.CurrentOccultTypes, true)); occults.AddRange(OccultTypeHelper.CreateList(dad.OccultManager.CurrentOccultTypes, true)); if (updateGenealogy) { Manager.Sims.ApplyOccultChance(Manager, newSim, occults, Manager.GetValue <ChanceOfHybridOption <TManager>, int>(), Manager.GetValue <MaximumOccultOption <TManager>, int>()); } else if (species == CASAgeGenderFlags.Human) { int maxCelebrityLevel = Manager.GetValue <MaxCelebrityLevelOption <TManager>, int>(); if (maxCelebrityLevel >= 0) { newSim.CelebrityManager.mOwner = newSim; Skill scienceSkill = SkillManager.GetStaticSkill(SkillNames.Science); if (scienceSkill != null) { scienceSkill.mNonPersistableData.SkillCategory |= SkillCategory.Hidden; } try { newSim.CelebrityManager.ForceSetLevel((uint)RandomUtil.GetInt(maxCelebrityLevel)); } finally { if (scienceSkill != null) { scienceSkill.mNonPersistableData.SkillCategory &= ~SkillCategory.Hidden; } } } occults.AddRange(Manager.GetValue <ImmigrantOccultOption <TManager>, List <OccultTypes> >()); if (occults.Count > 0) { if (RandomUtil.RandomChance(Manager.GetValue <ChanceOfOccultOption <TManager>, int>())) { OccultTypeHelper.Add(newSim, RandomUtil.GetRandomObjectFromList(occults), false, false); } } } Manager.Sims.ApplyOccultChance(Manager, newSim, occults, Manager.GetValue <ChanceOfHybridOption <TManager>, int>(), Manager.GetValue <MaximumOccultOption <TManager>, int>()); OccultTypeHelper.ValidateOccult(newSim, null); OccultTypeHelper.TestAndRebuildWerewolfOutfit(newSim); newSim.FirstName = Manager.Sims.EnsureUniqueName(newSim); List <Trait> traits = new List <Trait>(newSim.TraitManager.List); foreach (Trait trait in traits) { if (trait.IsHidden) { newSim.TraitManager.RemoveElement(trait.Guid); } } List <Trait> choices = AgingManager.GetValidTraits(newSim, true, true, true); if (choices.Count > 0) { while (!newSim.TraitManager.TraitsMaxed()) { Trait choice = RandomUtil.GetRandomObjectFromList <Trait>(choices); if (!newSim.TraitManager.AddElement(choice.Guid)) { break; } } } if (SimFromBinEvents.OnGeneticSkinBlend != null) { SimFromBinEvents.OnGeneticSkinBlend(mStats, newSim, mom, dad, Manager); } FixInvisibleTask.Perform(newSim, true); if (SimFromBinEvents.OnSimFromBinUpdate != null) { SimFromBinEvents.OnSimFromBinUpdate(mStats, newSim, mom, dad, Manager); } INameTakeOption nameTake = Manager.GetOption <NameTakeOption <TManager> >(); if ((!updateGenealogy) && (nameTake != null)) { bool wasEither; newSim.LastName = Manager.Sims.HandleName(nameTake, mom, dad, out wasEither); } else if (mom != null) { newSim.LastName = mom.LastName; } else if (dad != null) { newSim.LastName = dad.LastName; } if (!updateGenealogy && Manager.GetValue <CustomNamesOnlyOption <TManager>, bool>()) { newSim.LastName = LastNameListBooter.GetRandomName(!Manager.GetValue <CustomNamesOnlyOption <TManager>, bool>(), newSim.Species, newSim.IsFemale); } return(newSim); }