public override void OnDelayedWorldLoadFinished() { Overwatch.Log("CleanupOccult"); foreach (SimDescription sim in Household.AllSimsLivingInWorld()) { OccultTypeHelper.ValidateOccult(sim, Overwatch.Log); OccultTypeHelper.TestAndRebuildWerewolfOutfit(sim); // Compensate for a missing line in OccultWerewolf:FixupOccult if ((sim.CreatedSim != null) && (sim.ToddlerOrAbove) && (OccultTypeHelper.HasType(sim, OccultTypes.Werewolf))) { World.ObjectSetVisualOverride(sim.CreatedSim.ObjectId, eVisualOverrideTypes.Werewolf, null); } } }
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); }
protected override void OnPerform() { OccultTypeHelper.ValidateOccult(mSim, null); OccultTypeHelper.TestAndRebuildWerewolfOutfit(mSim); }