protected override bool PrivateUpdate(ScenarioFrame frame) { Common.StringBuilder msg = new Common.StringBuilder("PrivateUpdate"); try { bool fullList = !GetValue <CustomNamesOnlyOption <ManagerLot>, bool>(); foreach (SimDescription baby in mBabies) { msg += Common.NewLine + baby.FullName; if (!SimTypes.IsSelectable(baby)) { baby.FirstName = Sims.EnsureUniqueName(baby); } List <SimDescription> parents = Relationships.GetParents(baby); parents.Remove(Sim); if ((mDad == null) && (parents.Count > 0)) { mDad = parents[0]; } msg += Common.NewLine + "A"; List <OccultTypes> choices = OccultTypeHelper.CreateList(Sim.OccultManager.CurrentOccultTypes, true); // Grandparent occult inheritance foreach (SimDescription parent in Relationships.GetParents(Sim)) { if (parent.OccultManager == null) { continue; } choices.AddRange(OccultTypeHelper.CreateList(parent.OccultManager.CurrentOccultTypes, true)); } msg += Common.NewLine + "B"; if ((mDad != null) && (mDad.OccultManager != null)) { choices.AddRange(OccultTypeHelper.CreateList(mDad.OccultManager.CurrentOccultTypes, true)); // Grandparent occult inheritance foreach (SimDescription parent in Relationships.GetParents(mDad)) { if (parent.OccultManager == null) { continue; } choices.AddRange(OccultTypeHelper.CreateList(parent.OccultManager.CurrentOccultTypes, true)); } } msg += Common.NewLine + "C"; Sims.ApplyOccultChance(this, baby, choices, GetValue <ChanceOfOccultBabyOptionV2, int>(), GetValue <MaximumNewbornOccultOption, int>()); msg += Common.NewLine + "D"; if ((SimTypes.IsServiceAlien(mDad)) || (SimTypes.IsServiceAlien(Sim))) { baby.SetAlienDNAPercentage(1f); } else { baby.SetAlienDNAPercentage(SimDescription.GetAlienDNAPercentage(mDad, Sim, true)); } } msg += Common.NewLine + "E"; if (OnRenameNewbornsScenario != null) { OnRenameNewbornsScenario(this, frame); } if (!SimTypes.IsSelectable(Sim)) { ManagerSim.IncrementLifetimeHappiness(Sim, Sims3.Gameplay.Rewards.LifeEventRewards.kLifetimeHappinessRewardForBaby); } SetElapsedTime <DayOfLastBabyOption>(Sim); msg += Common.NewLine + "F"; if (mDad != null) { if (!SimTypes.IsSelectable(mDad)) { ManagerSim.IncrementLifetimeHappiness(mDad, Sims3.Gameplay.Rewards.LifeEventRewards.kLifetimeHappinessRewardForBaby); } SetElapsedTime <DayOfLastBabyOption>(mDad); } msg += Common.NewLine + "G"; foreach (SimDescription baby in mBabies) { Manager.AddAlarm(new NormalBabyAgingScenario(baby)); } msg += Common.NewLine + "H"; if (OnBirthScenario != null) { OnBirthScenario(this, frame); } msg += Common.NewLine + "I"; // Do this at the end once everything else has done its thing foreach (SimDescription baby in mBabies) { msg += Common.NewLine + baby.FullName; HouseholdOptions houseData = GetHouseOptions(baby.Household); if (houseData != null) { int netWorth = houseData.GetValue <NetWorthOption, int>(); foreach (SimDescription parent in Relationships.GetParents(baby)) { SimData parentData = GetData(parent); if (parentData != null) { foreach (CasteOptions caste in parentData.Castes) { if (!caste.GetValue <CasteInheritedOption, bool>()) { continue; } if (!caste.Matches(baby, netWorth)) { continue; } SimData babyData = GetData(baby); if (babyData != null) { babyData.AddValue <ManualCasteOption, CasteOptions>(caste); } } } } } } msg += Common.NewLine + "J"; Add(frame, new SuccessScenario(), ScenarioResult.Start); } catch (Exception e) { Common.Exception(ToString() + Common.NewLine + msg.ToString(), e); } return(false); }
protected override bool PrivateUpdate(ScenarioFrame frame) { SimDescription newSim = null; using (SimFromBin <ManagerSim> bin = new SimFromBin <ManagerSim>(this, Sims)) { CASAgeGenderFlags gender = Sim.Gender; switch (GetValue <GenderOption, BabyGenderScenario.FirstBornGender>()) { case BabyGenderScenario.FirstBornGender.Male: gender = CASAgeGenderFlags.Male; break; case BabyGenderScenario.FirstBornGender.Female: gender = CASAgeGenderFlags.Female; break; } newSim = bin.CreateNewSim(Sim.Age, gender, CASAgeGenderFlags.Human); if (newSim == null) { IncStat("Creation Fail"); return(false); } } bool genderChanged = (Sim.Gender != newSim.Gender); bool result = FacialBlends.CopyGenetics(newSim, Sim, false, false); Sim.VoiceVariation = newSim.VoiceVariation; Sim.VoicePitchModifier = newSim.VoicePitchModifier; Sim.FirstName = newSim.FirstName; if (genderChanged) { Sim.Gender = newSim.Gender; SavedOutfit.Cache cache = new SavedOutfit.Cache(newSim); Dictionary <OutfitCategories, bool> replaced = new Dictionary <OutfitCategories, bool>(); Sim.RemoveOutfits(OutfitCategories.Career, true); SimOutfit geneOutfit = CASParts.GetOutfit(Sim, CASParts.sPrimary, false); foreach (SavedOutfit.Cache.Key outfit in cache.Outfits) { using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(Sim, outfit.mKey, geneOutfit)) { builder.Builder.Gender = Sim.Gender; outfit.Apply(builder, false, null, null); if (!replaced.ContainsKey(outfit.Category)) { replaced.Add(outfit.Category, true); CASParts.RemoveOutfits(Sim, outfit.Category, false); } } } if (Sim.CreatedSim != null) { Sim.CreatedSim.UpdateOutfitInfo(); Sim.CreatedSim.RefreshCurrentOutfit(true); SwitchOutfits.SwitchNoSpin(Sim.CreatedSim, new CASParts.Key(OutfitCategories.Everyday, 0)); } } else { new SavedOutfit.Cache(Sim).PropagateGenetics(Sim, CASParts.sPrimary); } if (newSim.OccultManager.CurrentOccultTypes != OccultTypes.None) { if (Instantiation.PerformOffLot(Sim, Household.ActiveHousehold.LotHome, null) != null) { List <OccultTypes> occults = OccultTypeHelper.CreateList(newSim, true); foreach (OccultTypes occult in occults) { switch (occult) { case OccultTypes.Frankenstein: Sim.TraitManager.AddElement(TraitNames.Brave); Sim.TraitManager.AddElement(TraitNames.Hydrophobic); break; } } Sims.ApplyOccultChance(this, Sim, occults, 100, int.MaxValue); } if (Sim.GetOutfitCount(OutfitCategories.Everyday) > 1) { Sim.RemoveOutfit(OutfitCategories.Everyday, 1, true); } SimOutfit currentOutfit = Sim.GetOutfit(OutfitCategories.Everyday, 0); if (currentOutfit != null) { try { ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, Sim.AgeGenderSpecies); } catch (Exception e) { Common.Exception(Sim, e); } } } Deaths.CleansingKill(newSim, true); if (!result) { return(false); } if (Common.kDebugging) { Common.DebugNotify(GetTitlePrefix(PrefixType.Pure) + ": " + Sim.FullName, Sim.CreatedSim); } SpeedTrap.Sleep(); return(true); }