public static SimDescription GenerateOffspring(List <SimDescription> potentialParents, out bool noParents) { SimDescription choiceMom; SimDescription choiceDad; SimUtils.SimCreationSpec.ChooseParents(potentialParents, out choiceDad, out choiceMom); noParents = ((choiceMom == null) || (choiceDad == null) || (choiceMom == choiceDad)); if (noParents) { return(null); } CASAgeGenderFlags age = CASAgeGenderFlags.Teen | CASAgeGenderFlags.Child; if ((choiceMom.AdultOrAbove) && (choiceDad.AdultOrAbove)) { age |= CASAgeGenderFlags.YoungAdult; } float weight, fitness; WeightAndFitness(choiceMom, choiceDad, out weight, out fitness); SimUtils.SimCreationSpec spec3 = new SimUtils.SimCreationSpec(); spec3.Age = age; spec3.Weight = weight; spec3.Fitness = fitness; spec3.Normalize(); SimDescription child = spec3.Instantiate(choiceDad, choiceMom, true); if (child != null) { child.TraitManager.AddHiddenElement(TraitNames.DescendantHiddenTrait); if ((choiceMom != null) && (choiceDad != null)) { SimUtils.HouseholdCreationSpec.InitializeRomance(choiceMom, choiceDad, child, choiceMom.LastName); } else if (choiceMom != null) { child.LastName = choiceMom.LastName; } else if (choiceDad != null) { child.LastName = choiceDad.LastName; } } return(child); }
public void Execute() { Household household = Household.Find(mHouseholdId); SimDescription mom = SimDescription.Find(mMom); SimDescription dad = SimDescription.Find(mDad); SimDescription simDescription = mSim.Instantiate(dad, mom); if (simDescription != null) { household.Add(simDescription); simDescription.SendSimHome(); if (((mom != null) && (dad != null)) && (mom.Partner != dad)) { SimUtils.HouseholdCreationSpec.InitializeRomance(mom, dad, simDescription, simDescription.LastName); } } }
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 static SimDescription CreateDescendant(ulong momID, ulong dadID, Household household, CASAgeGenderFlags age, CASAgeGenderFlags gender) { bool momUnpacked; SimDescription mom = CreateProgenitor(momID, out momUnpacked); if (mom == null) { return(null); } bool dadUnpacked; SimDescription dad = CreateProgenitor(dadID, out dadUnpacked); if (dad == null) { return(null); } float weight, fitness; WeightAndFitness(mom, dad, out weight, out fitness); SimDescription sim = null; try { SimUtils.SimCreationSpec spec = new SimUtils.SimCreationSpec(); spec.Weight = weight; spec.Fitness = fitness; spec.Age = age; spec.Gender = gender; spec.Normalize(); sim = spec.Instantiate(mom, dad, false, WorldName.FutureWorld); } catch (Exception e) { Common.Exception("CreateDescendant", e); } /* * if (dadUnpacked && (dad != null)) * { * dad.PackUpToMiniSimDescription(); * } * * if (momUnpacked && (mom != null)) * { * mom.PackUpToMiniSimDescription(); * } * */ if (sim != null) { sim.TraitManager.AddHiddenElement(TraitNames.DescendantHiddenTrait); household.Add(sim); return(sim); } else { return(null); } }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { mAdoptionParams = AdoptionDialog.Show(Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me })); if (mAdoptionParams.mCancelled) return false; } List<SimDescription> residents = new List<SimDescription>(); foreach (SimDescription sim in SimListing.GetResidents(true).Values) { if (!sim.IsHuman) continue; residents.Add(sim); } SimDescription dad = RandomUtil.GetRandomObjectFromList(residents); SimDescription mom = RandomUtil.GetRandomObjectFromList(residents); SimDescription newKid = null; if ((dad != null) && (mom != null)) { if (dad.CelebrityManager == null) { dad.Fixup(); } if (mom.CelebrityManager == null) { mom.Fixup(); } newKid = Genetics.MakeDescendant(dad, mom, mAdoptionParams.mAge, mAdoptionParams.mIsFemale ? CASAgeGenderFlags.Female : CASAgeGenderFlags.Male, 100, new Random(), false, false, true); } else { SimUtils.SimCreationSpec spec = new SimUtils.SimCreationSpec(); spec.Gender = mAdoptionParams.mIsFemale ? CASAgeGenderFlags.Female : CASAgeGenderFlags.Male; spec.Age = mAdoptionParams.mAge; spec.Normalize(); newKid = spec.Instantiate(); } if (newKid == null) { Common.Notify(Common.Localize(GetTitlePrefix() + ":Failure")); return false; } string genderName = null; if (newKid.IsFemale) { genderName = Common.Localize("BabyGender:Female"); } else { genderName = Common.Localize("BabyGender:Male"); } string name = StringInputDialog.Show(Name, Common.Localize("InstaBaby:NamePrompt", newKid.IsFemale, new object[0]), newKid.FirstName); if (!string.IsNullOrEmpty(name)) { newKid.FirstName = name; } newKid.LastName = me.LastName; me.Household.Add(newKid); newKid.WasAdopted = true; Sim adoptedChild = Instantiation.Perform(newKid, null); if (adoptedChild != null) { ResetSimTask.UpdateInterface(adoptedChild); SocialWorkerAdoptionSituation.InstantiateNewKid instantiateNewKid = new SocialWorkerAdoptionSituation.InstantiateNewKid(); instantiateNewKid.AssignTraits(adoptedChild); instantiateNewKid.GiveImaginaryFriendDoll(newKid); me.Genealogy.AddChild(newKid.Genealogy); if (me.CreatedSim != null) { ActiveTopic.AddToSim(me.CreatedSim, "Recently Had Baby"); EventTracker.SendEvent(EventTypeId.kAdoptedChild, me.CreatedSim, adoptedChild); EventTracker.SendEvent(EventTypeId.kNewOffspring, me.CreatedSim, adoptedChild); EventTracker.SendEvent(EventTypeId.kParentAdded, adoptedChild, me.CreatedSim); } MidlifeCrisisManager.OnHadChild(me); Genealogy spouse = me.Genealogy.Spouse; if (spouse != null) { spouse.AddChild(newKid.Genealogy); SimDescription spouseDesc = spouse.SimDescription; if (spouseDesc != null) { MidlifeCrisisManager.OnHadChild(spouseDesc); if (spouseDesc.CreatedSim != null) { ActiveTopic.AddToSim(spouseDesc.CreatedSim, "Recently Had Baby"); EventTracker.SendEvent(EventTypeId.kAdoptedChild, spouseDesc.CreatedSim, adoptedChild); EventTracker.SendEvent(EventTypeId.kNewOffspring, spouseDesc.CreatedSim, adoptedChild); EventTracker.SendEvent(EventTypeId.kParentAdded, adoptedChild, spouseDesc.CreatedSim); } } } EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, adoptedChild); } return true; }
protected override bool Run(SimDescription me, bool singleSelection) { if (!ApplyAll) { mAdoptionParams = AdoptionDialog.Show(Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me })); if (mAdoptionParams.mCancelled) { return(false); } } List <SimDescription> residents = new List <SimDescription>(); foreach (SimDescription sim in SimListing.GetResidents(true).Values) { if (!sim.IsHuman) { continue; } residents.Add(sim); } SimDescription dad = RandomUtil.GetRandomObjectFromList(residents); SimDescription mom = RandomUtil.GetRandomObjectFromList(residents); SimDescription newKid = null; if ((dad != null) && (mom != null)) { if (dad.CelebrityManager == null) { dad.Fixup(); } if (mom.CelebrityManager == null) { mom.Fixup(); } newKid = Genetics.MakeDescendant(dad, mom, mAdoptionParams.mAge, mAdoptionParams.mIsFemale ? CASAgeGenderFlags.Female : CASAgeGenderFlags.Male, 100, new Random(), false, false, true); } else { SimUtils.SimCreationSpec spec = new SimUtils.SimCreationSpec(); spec.Gender = mAdoptionParams.mIsFemale ? CASAgeGenderFlags.Female : CASAgeGenderFlags.Male; spec.Age = mAdoptionParams.mAge; spec.Normalize(); newKid = spec.Instantiate(); } if (newKid == null) { Common.Notify(Common.Localize(GetTitlePrefix() + ":Failure")); return(false); } string genderName = null; if (newKid.IsFemale) { genderName = Common.Localize("BabyGender:Female"); } else { genderName = Common.Localize("BabyGender:Male"); } string name = StringInputDialog.Show(Name, Common.Localize("InstaBaby:NamePrompt", newKid.IsFemale, new object[0]), newKid.FirstName); if (!string.IsNullOrEmpty(name)) { newKid.FirstName = name; } newKid.LastName = me.LastName; me.Household.Add(newKid); newKid.WasAdopted = true; Sim adoptedChild = Instantiation.Perform(newKid, null); if (adoptedChild != null) { ResetSimTask.UpdateInterface(adoptedChild); SocialWorkerAdoptionSituation.InstantiateNewKid instantiateNewKid = new SocialWorkerAdoptionSituation.InstantiateNewKid(); instantiateNewKid.AssignTraits(adoptedChild); instantiateNewKid.GiveImaginaryFriendDoll(newKid); me.Genealogy.AddChild(newKid.Genealogy); if (me.CreatedSim != null) { ActiveTopic.AddToSim(me.CreatedSim, "Recently Had Baby"); EventTracker.SendEvent(EventTypeId.kAdoptedChild, me.CreatedSim, adoptedChild); EventTracker.SendEvent(EventTypeId.kNewOffspring, me.CreatedSim, adoptedChild); EventTracker.SendEvent(EventTypeId.kParentAdded, adoptedChild, me.CreatedSim); } MidlifeCrisisManager.OnHadChild(me); Genealogy spouse = me.Genealogy.Spouse; if (spouse != null) { spouse.AddChild(newKid.Genealogy); SimDescription spouseDesc = spouse.SimDescription; if (spouseDesc != null) { MidlifeCrisisManager.OnHadChild(spouseDesc); if (spouseDesc.CreatedSim != null) { ActiveTopic.AddToSim(spouseDesc.CreatedSim, "Recently Had Baby"); EventTracker.SendEvent(EventTypeId.kAdoptedChild, spouseDesc.CreatedSim, adoptedChild); EventTracker.SendEvent(EventTypeId.kNewOffspring, spouseDesc.CreatedSim, adoptedChild); EventTracker.SendEvent(EventTypeId.kParentAdded, adoptedChild, spouseDesc.CreatedSim); } } } EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, adoptedChild); } return(true); }
public static SimDescription GenerateOffspring(List<SimDescription> potentialParents, out bool noParents) { SimDescription choiceMom; SimDescription choiceDad; SimUtils.SimCreationSpec.ChooseParents(potentialParents, out choiceDad, out choiceMom); noParents = ((choiceMom == null) || (choiceDad == null) || (choiceMom == choiceDad)); if (noParents) { return null; } CASAgeGenderFlags age = CASAgeGenderFlags.Teen | CASAgeGenderFlags.Child; if ((choiceMom.AdultOrAbove) && (choiceDad.AdultOrAbove)) { age |= CASAgeGenderFlags.YoungAdult; } float weight, fitness; WeightAndFitness(choiceMom, choiceDad, out weight, out fitness); SimUtils.SimCreationSpec spec3 = new SimUtils.SimCreationSpec(); spec3.Age = age; spec3.Weight = weight; spec3.Fitness = fitness; spec3.Normalize(); SimDescription child = spec3.Instantiate(choiceDad, choiceMom, true); if (child != null) { child.TraitManager.AddHiddenElement(TraitNames.DescendantHiddenTrait); if ((choiceMom != null) && (choiceDad != null)) { SimUtils.HouseholdCreationSpec.InitializeRomance(choiceMom, choiceDad, child, choiceMom.LastName); } else if (choiceMom != null) { child.LastName = choiceMom.LastName; } else if (choiceDad != null) { child.LastName = choiceDad.LastName; } } return child; }
protected static SimDescription CreateDescendant(ulong momID, ulong dadID, Household household, CASAgeGenderFlags age, CASAgeGenderFlags gender) { bool momUnpacked; SimDescription mom = CreateProgenitor(momID, out momUnpacked); if (mom == null) return null; bool dadUnpacked; SimDescription dad = CreateProgenitor(dadID, out dadUnpacked); if (dad == null) return null; float weight, fitness; WeightAndFitness(mom, dad, out weight, out fitness); SimDescription sim = null; try { SimUtils.SimCreationSpec spec = new SimUtils.SimCreationSpec(); spec.Weight = weight; spec.Fitness = fitness; spec.Age = age; spec.Gender = gender; spec.Normalize(); sim = spec.Instantiate(mom, dad, false, WorldName.FutureWorld); } catch (Exception e) { Common.Exception("CreateDescendant", e); } /* if (dadUnpacked && (dad != null)) { dad.PackUpToMiniSimDescription(); } if (momUnpacked && (mom != null)) { mom.PackUpToMiniSimDescription(); } * */ if (sim != null) { sim.TraitManager.AddHiddenElement(TraitNames.DescendantHiddenTrait); household.Add(sim); return sim; } else { return null; } }