public static void GenerateCrossWorldThumbnail(MiniSimDescription miniSim, SimDescription sim, bool forceGeneration) { if (forceGeneration || (sim.HomeWorld == GameUtils.GetCurrentWorld())) { ThumbnailTechnique technique = sim.IsDead ? ThumbnailTechnique.Sepia : ThumbnailTechnique.Default; ResourceKey travelThumbnailOutfitForSim = MiniSimDescription.GetTravelThumbnailOutfitForSim(sim); if (travelThumbnailOutfitForSim.InstanceId != 0x0L) { ThumbnailManager.GenerateHouseholdSimThumbnail(travelThumbnailOutfitForSim, travelThumbnailOutfitForSim.InstanceId, 0x0, ThumbnailSizeMask.Large, technique, false, true, sim.AgeGenderSpecies); ThumbnailManager.GenerateTravelSimThumbnail(travelThumbnailOutfitForSim, miniSim.mThumbKey.mDescKey.InstanceId, ThumbnailSizeMask.Large, technique); } else { SimOutfit outfit = sim.GetOutfit(OutfitCategories.Everyday, 0); if ((outfit != null) && (outfit.IsValid)) { sim.mDefaultOutfitKey = outfit.Key; ThumbnailManager.GenerateHouseholdSimThumbnail(sim.DefaultOutfitKey, sim.DefaultOutfitKey.InstanceId, 0, ThumbnailSizeMask.Large, technique, false, true, sim.AgeGenderSpecies); ThumbnailManager.GenerateTravelSimThumbnail(sim.DefaultOutfitKey, miniSim.mThumbKey.mDescKey.InstanceId, ThumbnailSizeMask.Large, technique); } } } }
private static void OnAcceptButtonClick(WindowBase sender, UIButtonClickEventArgs args) { try { CASGenetics ths = CASGenetics.gSingleton; if (ths == null) { return; } if (!ths.mHourglassVisible) { args.Handled = true; if (ths.mSelectedOffspring != null) { if (CASPuck.Instance != null) { ths.mReturnState = ths.mSelectedOffspring.IsPet ? CASState.PetSummary : CASState.Summary; CASPuck.Instance.AttemptingToAdd = true; CASPuck.ShowInputBlocker(); Responder.Instance.CASModel.RequestLoadSim(ths.mSelectedOffspring, false); Responder.Instance.CASModel.RequestAddSimToHousehold(false); Responder.Instance.CASModel.RequestClearStack(); CASController.Singleton.SetCurrentState(ths.mReturnState); } else { FacialBlends.CopyGenetics(ths.mSelectedOffspring as SimDescription, sChoice, false, false); new SavedOutfit.Cache(sChoice).PropagateGenetics(sChoice, CASParts.sPrimary); SimOutfit currentOutfit = sChoice.CreatedSim.CurrentOutfit; if (currentOutfit != null) { ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, sChoice.AgeGenderSpecies); } DestroyHousehold(); CASGenetics.Unload(); } } } } catch (Exception e) { Common.Exception("OnAcceptButtonClick", e); } }
protected override void OnPerform() { try { if ((mCurrentOnly) && (mSim.CreatedSim != null)) { using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(mSim, new CASParts.Key(mSim.CreatedSim))) { builder.Builder.RemoveParts(mTypes); } } else { ProgressDialog.Show(Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/Global:Processing", new object[0x0]), false); SavedOutfit.Cache cache = new SavedOutfit.Cache(mSim); foreach (SavedOutfit.Cache.Key outfit in cache.Outfits) { using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(mSim, outfit.mKey)) { builder.Builder.RemoveParts(mTypes); } } } if (mSim.CreatedSim != null) { SimOutfit currentOutfit = mSim.CreatedSim.CurrentOutfit; if (currentOutfit != null) { ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, mSim.AgeGenderSpecies); } } if (mPostPerform != null) { mPostPerform(); } } finally { ProgressDialog.Close(); } }
public static void MakeupManagement(Sim sim, bool addRemove) { try { SimBuilder builder = new SimBuilder(); SimDescription simDescription = sim.SimDescription; OutfitCategories currentOutfitCategory = sim.CurrentOutfitCategory; int currentOutfitIndex = sim.CurrentOutfitIndex; builder.Clear(false); SimOutfit currentOutfit = sim.CurrentOutfit; OutfitUtils.SetOutfit(builder, currentOutfit, simDescription); if (addRemove) { sendDebugMsg(sim.FullName + "\nAdding eyes."); string designPreset = CASUtils.PartDataGetPreset(VTThirstMaskPart, uint.Parse(kMaskPresetIndex)); builder.AddPart(ThirstMask); if (sim.SimDescription.YoungAdultOrAbove) { sim.BuffManager.AddElement(0xB110CC43B0C44B1C, (Origin)ResourceUtils.HashString64("ByAppearanceOfRedEyes")); } CASUtils.ApplyPresetToPart(builder, ThirstMask, designPreset); builder.SetPartPreset(VTThirstMaskPart, uint.Parse(kMaskPresetIndex), designPreset); } else { builder.RemovePart(ThirstMask); sim.BuffManager.RemoveElement(0xB110CC43B0C44B1C); } SimOutfit outfit = new SimOutfit(builder.CacheOutfit(simDescription.FullName + currentOutfitCategory.ToString() + currentOutfitIndex.ToString())); if (simDescription.GetOutfitCount(currentOutfitCategory) > currentOutfitIndex) { simDescription.RemoveOutfit(currentOutfitCategory, currentOutfitIndex, true); } simDescription.AddOutfit(outfit, currentOutfitCategory, currentOutfitIndex); if (simDescription.CreatedSim != null) { sendDebugMsg("Updated: " + currentOutfitCategory.ToString() + "-" + currentOutfitIndex.ToString()); simDescription.CreatedSim.RefreshCurrentOutfit(false); } foreach (OutfitCategories categories2 in Enum.GetValues(typeof(OutfitCategories))) { if (categories2 != OutfitCategories.Special) { ArrayList list = simDescription.GetCurrentOutfits()[categories2] as ArrayList; if (list != null) { int count = list.Count; for (int i = 0; i < count; i++) { if ((categories2 != currentOutfitCategory) || (i != currentOutfitIndex)) { builder.Clear(false); SimOutfit outfit3 = list[i] as SimOutfit; OutfitUtils.SetOutfit(builder, outfit3, simDescription); if (addRemove) { string str2 = CASUtils.PartDataGetPreset(VTThirstMaskPart, uint.Parse(kMaskPresetIndex)); builder.AddPart(ThirstMask); sim.BuffManager.AddElement(0xB110CC43B0C44B1C, (Origin)ResourceUtils.HashString64("ByAppearanceOfRedEyes")); CASUtils.ApplyPresetToPart(builder, ThirstMask, str2); builder.SetPartPreset(VTThirstMaskPart, uint.Parse(kMaskPresetIndex), str2); } else { builder.RemovePart(ThirstMask); sim.BuffManager.RemoveElement(0xB110CC43B0C44B1C); } SimOutfit outfit4 = new SimOutfit(builder.CacheOutfit(simDescription.FullName + categories2.ToString() + i.ToString())); if (simDescription.GetOutfitCount(categories2) > i) { simDescription.RemoveOutfit(categories2, i, true); } simDescription.AddOutfit(outfit4, categories2, i); sendDebugMsg("Updated: " + categories2.ToString() + "-" + i.ToString()); Sleep(0); } } } } } SimOutfit outfit5 = simDescription.GetOutfit(OutfitCategories.Everyday, 0); if (outfit5 != null) { ThumbnailManager.GenerateHouseholdSimThumbnail(outfit5.Key, outfit5.Key.InstanceId, 0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, simDescription.AgeGenderSpecies); } } catch (Exception exception) { SimpleMessageDialog.Show("Vampire Tweaker - Thirst Effect", sim.Name + "\nApply makeup failed!\n" + exception); } }
public static void SetFeet(Sim sim, bool addRemove) { try { SimBuilder builder = new SimBuilder(); SimDescription simDescription = sim.SimDescription; OutfitCategories currentOutfitCategory = sim.CurrentOutfitCategory; int currentOutfitIndex = sim.CurrentOutfitIndex; builder.Clear(false); SimOutfit currentOutfit = sim.CurrentOutfit; OutfitUtils.SetOutfit(builder, currentOutfit, simDescription); if (addRemove) { sendDebugMsg(sim.FullName + "\nAdding feets."); simDescription.AddOutfit(currentOutfit, OutfitCategories.Naked); if (simDescription.Child) { builder.AddPart(WolfFeetMaskChildUnisex); } if (simDescription.Teen && simDescription.IsFemale) { builder.AddPart(WolfFeetMaskTeenFemale); } if (simDescription.Teen && simDescription.IsMale) { builder.AddPart(WolfFeetMaskTeenMale); } if (simDescription.Adult && simDescription.YoungAdult && simDescription.IsFemale) { builder.AddPart(WolfFeetMaskAdultFemale); } if (simDescription.Adult && simDescription.YoungAdult && simDescription.IsMale) { builder.AddPart(WolfFeetMaskAdultMale); } if (simDescription.Elder && simDescription.IsFemale) { builder.AddPart(WolfFeetMaskElderFemale); } if (simDescription.Elder && simDescription.IsMale) { builder.AddPart(WolfFeetMaskElderMale); } } else { if (simDescription.Child) { builder.RemovePart(WolfFeetMaskChildUnisex); } if (simDescription.Teen && simDescription.IsFemale) { builder.RemovePart(WolfFeetMaskChildUnisex); } if (simDescription.Teen && simDescription.IsMale) { builder.RemovePart(WolfFeetMaskTeenMale); } if (simDescription.YoungAdult && simDescription.Adult && simDescription.IsMale) { builder.RemovePart(WolfFeetMaskAdultMale); } if (simDescription.YoungAdult && simDescription.Adult && simDescription.IsFemale) { builder.RemovePart(WolfFeetMaskAdultFemale); } if (simDescription.Elder && simDescription.IsFemale) { builder.RemovePart(WolfFeetMaskElderFemale); } if (simDescription.Elder && simDescription.IsMale) { builder.RemovePart(WolfFeetMaskElderMale); } } SimOutfit outfit = new SimOutfit(builder.CacheOutfit(simDescription.FullName + currentOutfitCategory.ToString() + currentOutfitIndex.ToString())); if (simDescription.GetOutfitCount(currentOutfitCategory) > currentOutfitIndex) { simDescription.RemoveOutfit(currentOutfitCategory, currentOutfitIndex, true); } simDescription.AddOutfit(outfit, currentOutfitCategory, currentOutfitIndex); if (simDescription.CreatedSim != null) { sendDebugMsg("Updated: " + currentOutfitCategory.ToString() + "-" + currentOutfitIndex.ToString()); simDescription.CreatedSim.RefreshCurrentOutfit(false); } foreach (OutfitCategories categories2 in Enum.GetValues(typeof(OutfitCategories))) { if (categories2 != OutfitCategories.Special) { ArrayList list = simDescription.GetCurrentOutfits()[categories2] as ArrayList; if (list != null) { int count = list.Count; for (int i = 0; i < count; i++) { if ((categories2 != currentOutfitCategory) || (i != currentOutfitIndex)) { builder.Clear(false); SimOutfit outfit3 = list[i] as SimOutfit; OutfitUtils.SetOutfit(builder, outfit3, simDescription); if (addRemove) { simDescription.AddOutfit(currentOutfit, OutfitCategories.Naked); if (simDescription.Child) { builder.AddPart(WolfFeetMaskChildUnisex); } if (simDescription.Teen && simDescription.IsFemale) { builder.AddPart(WolfFeetMaskTeenFemale); } if (simDescription.Teen && simDescription.IsMale) { builder.AddPart(WolfFeetMaskTeenMale); } if (simDescription.Adult && simDescription.YoungAdult && simDescription.IsFemale) { builder.AddPart(WolfFeetMaskAdultFemale); } if (simDescription.Adult && simDescription.YoungAdult && simDescription.IsMale) { builder.AddPart(WolfFeetMaskAdultMale); } if (simDescription.Elder && simDescription.IsFemale) { builder.AddPart(WolfFeetMaskElderFemale); } if (simDescription.Elder && simDescription.IsMale) { builder.AddPart(WolfFeetMaskElderMale); } } else { if (simDescription.Child) { builder.RemovePart(WolfFeetMaskChildUnisex); } if (simDescription.Teen && simDescription.IsFemale) { builder.RemovePart(WolfFeetMaskChildUnisex); } if (simDescription.Teen && simDescription.IsMale) { builder.RemovePart(WolfFeetMaskTeenMale); } if (simDescription.YoungAdult && simDescription.Adult && simDescription.IsMale) { builder.RemovePart(WolfFeetMaskAdultMale); } if (simDescription.YoungAdult && simDescription.Adult && simDescription.IsFemale) { builder.RemovePart(WolfFeetMaskAdultFemale); } if (simDescription.Elder && simDescription.IsFemale) { builder.RemovePart(WolfFeetMaskElderFemale); } if (simDescription.Elder && simDescription.IsMale) { builder.RemovePart(WolfFeetMaskElderMale); } } SimOutfit outfit4 = new SimOutfit(builder.CacheOutfit(simDescription.FullName + categories2.ToString() + i.ToString())); if (simDescription.GetOutfitCount(categories2) > i) { simDescription.RemoveOutfit(categories2, i, true); } simDescription.AddOutfit(outfit4, categories2, i); sendDebugMsg("Updated: " + categories2.ToString() + "-" + i.ToString()); Sleep(0); } } } } } SimOutfit outfit5 = simDescription.GetOutfit(OutfitCategories.Everyday, 0); if (outfit5 != null) { ThumbnailManager.GenerateHouseholdSimThumbnail(outfit5.Key, outfit5.Key.InstanceId, 0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, simDescription.AgeGenderSpecies); } } catch (Exception exception) { SimpleMessageDialog.Show("Werewolf Tweaker - Wolf Feet", sim.Name + "\nApply feet failed!\n" + exception); } }
protected List <Sim> GenerateHumanChildren(SimDescription woman, SimDescription man, int numChildren) { Random pregoRandom = new Random(); List <Sim> babies = new List <Sim>(); for (int i = 0; i < numChildren; i++) { try { SimDescription newBaby = Genetics.MakeBaby(woman, man, NRaas.MasterControllerSpace.Helpers.Baby.InterpretGender(mGender), 100, pregoRandom, false); woman.Household.Add(newBaby); string name = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":NamePrompt", newBaby.IsFemale, new object[0]), newBaby.FirstName); if (!string.IsNullOrEmpty(name)) { newBaby.FirstName = name; } Sim babySim = Instantiation.Perform(newBaby, null); if (babySim != null) { babies.Add(babySim); SimOutfit currentOutfit = babySim.CurrentOutfit; if (currentOutfit != null) { ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, newBaby.AgeGenderSpecies); } Pregnancy.MakeBabyVisible(babySim); if (i == 0) { EventTracker.SendEvent(new SimDescriptionEvent(EventTypeId.kNewBaby, newBaby)); } if (woman != null) { MidlifeCrisisManager.OnHadChild(woman); if (woman.CreatedSim != null) { EventTracker.SendEvent(EventTypeId.kNewOffspring, woman.CreatedSim, babySim); EventTracker.SendEvent(EventTypeId.kParentAdded, babySim, woman.CreatedSim); } } if (man != null) { MidlifeCrisisManager.OnHadChild(man); if (man.CreatedSim != null) { EventTracker.SendEvent(EventTypeId.kNewOffspring, man.CreatedSim, babySim); EventTracker.SendEvent(EventTypeId.kParentAdded, babySim, man.CreatedSim); } } EventTracker.SendEvent(EventTypeId.kChildBornOrAdopted, null, babySim); if (newBaby.IsHuman) { OccultImaginaryFriend.DeliverDollToHousehold(new List <Sim> { newBaby.CreatedSim }); } } } catch (Exception e) { Common.Exception(woman, man, e); } } if (babies.Count > 0) { if (woman.CreatedSim != null) { EventTracker.SendEvent(new PregnancyEvent(EventTypeId.kHadBaby, woman.CreatedSim, man.CreatedSim, null, babies)); } if (man.CreatedSim != null) { EventTracker.SendEvent(new PregnancyEvent(EventTypeId.kHadBaby, man.CreatedSim, woman.CreatedSim, null, babies)); } } return(babies); }
public static void FixInvisibleSim(SimDescription sim, bool force = false, bool reset = false) { try{ OutfitCategories[] categoriesArray = null; switch (sim.Species) { case CASAgeGenderFlags.Human: categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday, OutfitCategories.Naked, OutfitCategories.Athletic, OutfitCategories.Formalwear, OutfitCategories.Sleepwear, OutfitCategories.Swimwear }; break; case CASAgeGenderFlags.Horse: categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday, OutfitCategories.Naked, OutfitCategories.Racing, OutfitCategories.Bridle, OutfitCategories.Jumping }; break; default: categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday, OutfitCategories.Naked }; break; } bool necessary = force; if (!necessary) { foreach (OutfitCategories category in categoriesArray) { if (sim.IsHuman) { if (category == OutfitCategories.Naked) { continue; } } SimOutfit outfit2 = sim.GetOutfit(category, 0); if ((outfit2 == null) || (!outfit2.IsValid)) { necessary = true; } } } if (!necessary) { return; } SimOutfit sourceOutfit = null; for (int i = 0; i < 2; i++) { OutfitCategoryMap map = null; if (i == 0) { map = sim.mOutfits; } else { map = sim.mMaternityOutfits; } if (map == null) { continue; } foreach (OutfitCategories category in Enum.GetValues(typeof(OutfitCategories))) { if (category == OutfitCategories.Supernatural) { continue; } ArrayList outfits = map[category] as ArrayList; if (outfits == null) { continue; } foreach (SimOutfit anyOutfit in outfits) { if ((anyOutfit != null) && (anyOutfit.IsValid)) { sourceOutfit = anyOutfit; break; } } } } SimBuilder builder = new SimBuilder(); builder.UseCompression = true; var simTone = sim.SkinToneKey; List <ResourceKey> choiceTones = new List <ResourceKey>(); KeySearch tones = new KeySearch(0x0354796a); foreach (ResourceKey tone in tones) { choiceTones.Add(tone); } tones.Reset(); if ((simTone.InstanceId == 0) || (!choiceTones.Contains(simTone))) { simTone = RandomUtil.GetRandomObjectFromList(choiceTones); } ResourceKey newTone = simTone; builder.Age = sim.Age; builder.Gender = sim.Gender; builder.Species = sim.Species; builder.SkinTone = newTone; builder.SkinToneIndex = sim.SkinToneIndex; builder.MorphFat = sim.mCurrentShape.Fat; builder.MorphFit = sim.mCurrentShape.Fit; builder.MorphThin = sim.mCurrentShape.Thin; GeneticsPet.SpeciesSpecificData speciesData = OutfitUtils.GetSpeciesSpecificData(sim); try{ if (sourceOutfit != null) { foreach (SimOutfit.BlendInfo blend in sourceOutfit.Blends) { builder.SetFacialBlend(blend.key, blend.amount); } CASParts.OutfitBuilder.CopyGeneticParts(builder, sourceOutfit); } else { if (sim.Genealogy != null) { List <SimDescription> parents = new List <SimDescription>(); List <SimDescription> grandParents = new List <SimDescription>(); if (sim.Genealogy.Parents != null) { foreach (Genealogy gene in sim.Genealogy.Parents) { SimDescription relative = gene.SimDescription; if (relative == null) { continue; } parents.Add(relative); if (relative.Genealogy != null) { if (relative.Genealogy.Parents != null) { foreach (Genealogy grandGene in relative.Genealogy.Parents) { var grandRelative = grandGene.SimDescription; if (grandRelative == null) { continue; } grandParents.Add(grandRelative); } } } } } if (parents.Count > 0) { if (sim.IsHuman) { Genetics.InheritFacialBlends(builder, parents.ToArray(), new Random()); } else { GeneticsPet.InheritBodyShape(builder, parents, grandParents, new Random()); GeneticsPet.InheritBasePeltLayer(builder, parents, grandParents, new Random()); GeneticsPet.InheritPeltLayers(builder, parents, grandParents, new Random()); } } } } }catch (Exception exception) { Alive.WriteLog(exception.Message + "\n\n" + exception.StackTrace + "\n\n" + exception.Source); } if (sim.IsRobot) { OutfitUtils.AddMissingPartsBots(builder, (OutfitCategories)0x200002, true, sim); Sleep(); OutfitUtils.AddMissingPartsBots(builder, OutfitCategories.Everyday, true, sim); Sleep(); } else if (sim.IsHuman) { OutfitUtils.AddMissingParts(builder, (OutfitCategories)0x200002, true, sim, sim.IsAlien); Sleep(); OutfitUtils.AddMissingParts(builder, OutfitCategories.Everyday, true, sim, sim.IsAlien); Sleep(); } else { OutfitUtils.AddMissingPartsPet(builder, OutfitCategories.Everyday | (OutfitCategories)0x200000, true, sim, speciesData); Sleep(); OutfitUtils.AddMissingPartsPet(builder, OutfitCategories.Everyday, true, sim, speciesData); Sleep(); } ResourceKey uniformKey = new ResourceKey(); if (sim.IsHuman) { if (LocaleConstraints.GetUniform(ref uniformKey, sim.HomeWorld, builder.Age, builder.Gender, OutfitCategories.Everyday)) { OutfitUtils.SetOutfit(builder, new SimOutfit(uniformKey), sim); } } OutfitUtils.SetAutomaticModifiers(builder); sim.ClearOutfits(OutfitCategories.Career, false); sim.ClearOutfits(OutfitCategories.MartialArts, false); sim.ClearOutfits(OutfitCategories.Special, false); foreach (OutfitCategories category in categoriesArray) { ArrayList outfits = null; if (!force) { outfits = sim.Outfits[category] as ArrayList; if (outfits != null) { int index = 0; while (index < outfits.Count) { SimOutfit anyOutfit = outfits[index] as SimOutfit; if (anyOutfit == null) { outfits.RemoveAt(index); } else if (!anyOutfit.IsValid) { outfits.RemoveAt(index); } else { index++; } } } } if ((outfits == null) || (outfits.Count == 0)) { OutfitUtils.MakeCategoryAppropriate(builder, category, sim); if (sim.IsHuman) { if (LocaleConstraints.GetUniform(ref uniformKey, sim.HomeWorld, builder.Age, builder.Gender, category)) { OutfitUtils.SetOutfit(builder, new SimOutfit(uniformKey), sim); } } sim.RemoveOutfits(category, false); CASParts.AddOutfit(sim, category, builder, true); } if (sim.IsUsingMaternityOutfits) { sim.BuildPregnantOutfit(category); } } if (sim.IsMummy) { OccultMummy .OnMerge(sim); } else if (sim.IsFrankenstein) { OccultFrankenstein .OnMerge(sim, sim.OccultManager.mIsLifetimeReward); } else if (sim.IsGenie) { OccultGenie .OverlayUniform(sim, OccultGenie.CreateUniformName(sim.Age, sim.Gender), ProductVersion.EP6, OutfitCategories.Everyday, CASSkinTones.BlueSkinTone, 0.68f); } else if (sim.IsImaginaryFriend) { OccultImaginaryFriend friend = sim.OccultManager.GetOccultType(Sims3.UI.Hud.OccultTypes.ImaginaryFriend) as OccultImaginaryFriend; OccultBaseClass .OverlayUniform(sim, OccultImaginaryFriend.CreateUniformName(sim.Age, friend.Pattern), ProductVersion.EP4, OutfitCategories.Special, CASSkinTones.NoSkinTone, 0f); } if (sim.IsMermaid) { OccultMermaid .AddOutfits(sim, null); } if (sim.IsWerewolf) { if (sim.ChildOrAbove) { SimOutfit newWerewolfOutfit = OccultWerewolf .GetNewWerewolfOutfit(sim.Age, sim.Gender); if (newWerewolfOutfit != null) { sim.AddOutfit(newWerewolfOutfit, OutfitCategories.Supernatural, 0x0); } } } SimOutfit currentOutfit = null; if (sim.CreatedSim != null) { if (reset) { StuckSimData stuckSim; if (!StuckSims.TryGetValue(sim.SimDescriptionId, out stuckSim)) { stuckSim = new StuckSimData(); StuckSims.Add(sim.SimDescriptionId, stuckSim); } if (!stuckSim.Resetting) { stuckSim.Detections++; Vector3 destination = Vector3.Invalid; if (sim.CreatedSim.RoutingComponent != null) { sim.CreatedSim.RoutingComponent.GetDestination(out destination); } if (stuckSim.resetTask == null) { stuckSim.resetTask = new ResetStuckSimTask(sim.CreatedSim, destination, "Invisible"); } else { stuckSim.resetTask.Renew(); } } } try{ sim.CreatedSim.SwitchToOutfitWithoutSpin(Sim.ClothesChangeReason.GoingOutside, OutfitCategories.Everyday, true); }catch (Exception exception) { Alive.WriteLog(exception.Message + "\n\n" + exception.StackTrace + "\n\n" + exception.Source); } currentOutfit = sim.CreatedSim.CurrentOutfit; } else { currentOutfit = sim.GetOutfit(OutfitCategories.Everyday, 0); } if (currentOutfit != null) { ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, sim.AgeGenderSpecies); } }catch (Exception exception) { Alive.WriteLog(exception.Message + "\n\n" + exception.StackTrace + "\n\n" + exception.Source + "\n\n" + "FixInvisibleSim"); }finally{ } }
protected override void OnPerform() { try { ProgressDialog.Show(Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/Global:Processing", new object[0x0]), false); SimOutfit sourceOutfit = CASParts.GetOutfit(mSim.SimDescription, mSourceKey, false); List <CASParts.PartPreset> presets = new List <CASParts.PartPreset>(); foreach (CASPart part in sourceOutfit.Parts) { if (!mTypes.Contains(part.BodyType)) { continue; } presets.Add(CASParts.OutfitBuilder.GetPartPreset(part, sourceOutfit)); } SavedOutfit.Cache cache = new SavedOutfit.Cache(mSim.SimDescription); foreach (SavedOutfit.Cache.Key outfit in cache.Outfits) { if (outfit.Category == OutfitCategories.Special) { continue; } if ((mIgnore != null) && (mIgnore.Contains(outfit.Category))) { continue; } if (outfit.mKey == mSourceKey) { continue; } using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(mSim.SimDescription, outfit.mKey)) { builder.Builder.RemoveParts(mTypes.ToArray()); foreach (CASParts.PartPreset preset in presets) { builder.ApplyPartPreset(preset); } } } SimOutfit currentOutfit = mSim.CurrentOutfit; if (currentOutfit != null) { ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, mSim.SimDescription.AgeGenderSpecies); } } finally { ProgressDialog.Close(); } }
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); }
public static Approach Perform(SimDescription sim, bool force, bool reset) { try { OutfitCategories[] categoriesArray = null; switch (sim.Species) { case CASAgeGenderFlags.Human: categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday, OutfitCategories.Naked, OutfitCategories.Athletic, OutfitCategories.Formalwear, OutfitCategories.Sleepwear, OutfitCategories.Swimwear }; break; case CASAgeGenderFlags.Horse: categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday, OutfitCategories.Naked, OutfitCategories.Racing, OutfitCategories.Bridle, OutfitCategories.Jumping }; break; default: categoriesArray = new OutfitCategories[] { OutfitCategories.Everyday, OutfitCategories.Naked }; break; } bool necessary = force; if (!necessary) { foreach (OutfitCategories category in categoriesArray) { if (sim.IsHuman) { if (category == OutfitCategories.Naked) { continue; } } SimOutfit outfit2 = sim.GetOutfit(category, 0); if ((outfit2 == null) || (!outfit2.IsValid)) { necessary = true; } } } if (!necessary) { return(Approach.None); } SimOutfit sourceOutfit = null; for (int i = 0; i < 2; i++) { OutfitCategoryMap map = null; if (i == 0) { map = sim.mOutfits; } else { map = sim.mMaternityOutfits; } if (map == null) { continue; } foreach (OutfitCategories category in Enum.GetValues(typeof(OutfitCategories))) { if (category == OutfitCategories.Supernatural) { continue; } ArrayList outfits = map[category] as ArrayList; if (outfits == null) { continue; } foreach (SimOutfit anyOutfit in outfits) { if ((anyOutfit != null) && (anyOutfit.IsValid)) { sourceOutfit = anyOutfit; break; } } } } SimBuilder builder = new SimBuilder(); builder.UseCompression = true; ResourceKey newTone = ValidateSkinTone(sim.SkinToneKey); builder.Age = sim.Age; builder.Gender = sim.Gender; builder.Species = sim.Species; builder.SkinTone = newTone; builder.SkinToneIndex = sim.SkinToneIndex; builder.MorphFat = sim.mCurrentShape.Fat; builder.MorphFit = sim.mCurrentShape.Fit; builder.MorphThin = sim.mCurrentShape.Thin; Approach approach = Approach.Rerolled; GeneticsPet.SpeciesSpecificData speciesData = OutfitUtils.GetSpeciesSpecificData(sim); try { if (sourceOutfit != null) { foreach (SimOutfit.BlendInfo blend in sourceOutfit.Blends) { builder.SetFacialBlend(blend.key, blend.amount); } CASParts.OutfitBuilder.CopyGeneticParts(builder, sourceOutfit); approach = Approach.Recovered; } else { if (sim.Genealogy != null) { List <SimDescription> parents = new List <SimDescription>(); List <SimDescription> grandParents = new List <SimDescription>(); foreach (SimDescription parent in Relationships.GetParents(sim)) { parents.Add(parent); foreach (SimDescription grandParent in Relationships.GetParents(parent)) { grandParents.Add(grandParent); } } if (parents.Count > 0) { if (sim.IsHuman) { Genetics.InheritFacialBlends(builder, parents.ToArray(), new Random()); } else { GeneticsPet.InheritBodyShape(builder, parents, grandParents, new Random()); GeneticsPet.InheritBasePeltLayer(builder, parents, grandParents, new Random()); GeneticsPet.InheritPeltLayers(builder, parents, grandParents, new Random()); } approach = Approach.Reinherited; } } } } catch (Exception e) { Common.Exception(sim, null, "Primary Outfit Creation", e); return(Approach.None); } if (sim.IsRobot) { OutfitUtils.AddMissingPartsBots(builder, (OutfitCategories)0x200002, true, sim); Common.Sleep(); OutfitUtils.AddMissingPartsBots(builder, OutfitCategories.Everyday, true, sim); Common.Sleep(); } else if (sim.IsHuman) { OutfitUtils.AddMissingParts(builder, (OutfitCategories)0x200002, true, sim, sim.IsAlien); Common.Sleep(); OutfitUtils.AddMissingParts(builder, OutfitCategories.Everyday, true, sim, sim.IsAlien); Common.Sleep(); } else { OutfitUtils.AddMissingPartsPet(builder, OutfitCategories.Everyday | (OutfitCategories)0x200000, true, sim, speciesData); Common.Sleep(); OutfitUtils.AddMissingPartsPet(builder, OutfitCategories.Everyday, true, sim, speciesData); Common.Sleep(); } ResourceKey uniformKey = new ResourceKey(); if (sim.IsHuman) { if (LocaleConstraints.GetUniform(ref uniformKey, sim.HomeWorld, builder.Age, builder.Gender, OutfitCategories.Everyday)) { OutfitUtils.SetOutfit(builder, new SimOutfit(uniformKey), sim); } } OutfitUtils.SetAutomaticModifiers(builder); sim.ClearOutfits(OutfitCategories.Career, false); sim.ClearOutfits(OutfitCategories.MartialArts, false); sim.ClearOutfits(OutfitCategories.Special, false); foreach (OutfitCategories category in categoriesArray) { ArrayList outfits = null; if (!force) { outfits = sim.Outfits[category] as ArrayList; if (outfits != null) { int index = 0; while (index < outfits.Count) { SimOutfit anyOutfit = outfits[index] as SimOutfit; if (anyOutfit == null) { outfits.RemoveAt(index); } else if (!anyOutfit.IsValid) { outfits.RemoveAt(index); } else { index++; } } } } if ((outfits == null) || (outfits.Count == 0)) { OutfitUtils.MakeCategoryAppropriate(builder, category, sim); if (sim.IsHuman) { if (LocaleConstraints.GetUniform(ref uniformKey, sim.HomeWorld, builder.Age, builder.Gender, category)) { OutfitUtils.SetOutfit(builder, new SimOutfit(uniformKey), sim); } } sim.RemoveOutfits(category, false); CASParts.AddOutfit(sim, category, builder, true); } if (sim.IsUsingMaternityOutfits) { sim.BuildPregnantOutfit(category); } } if (sim.IsMummy) { OccultMummy.OnMerge(sim); } else if (sim.IsFrankenstein) { OccultFrankenstein.OnMerge(sim, sim.OccultManager.mIsLifetimeReward); } else if (sim.IsGenie) { OccultGenie.OverlayUniform(sim, OccultGenie.CreateUniformName(sim.Age, sim.Gender), ProductVersion.EP6, OutfitCategories.Everyday, CASSkinTones.BlueSkinTone, 0.68f); } else if (sim.IsImaginaryFriend) { OccultImaginaryFriend friend = sim.OccultManager.GetOccultType(Sims3.UI.Hud.OccultTypes.ImaginaryFriend) as OccultImaginaryFriend; OccultBaseClass.OverlayUniform(sim, OccultImaginaryFriend.CreateUniformName(sim.Age, friend.Pattern), ProductVersion.EP4, OutfitCategories.Special, CASSkinTones.NoSkinTone, 0f); } if (sim.IsMermaid) { OccultMermaid.AddOutfits(sim, null); } if (sim.IsWerewolf) { if (sim.ChildOrAbove) { SimOutfit newWerewolfOutfit = OccultWerewolf.GetNewWerewolfOutfit(sim.Age, sim.Gender); if (newWerewolfOutfit != null) { sim.AddOutfit(newWerewolfOutfit, OutfitCategories.Supernatural, 0x0); } } } SimOutfit currentOutfit = null; if (sim.CreatedSim != null) { if (reset) { ResetSimTask.Perform(sim.CreatedSim, false); } try { sim.CreatedSim.SwitchToOutfitWithoutSpin(Sim.ClothesChangeReason.GoingOutside, OutfitCategories.Everyday, true); } catch (Exception e) { Common.DebugException(sim, e); } currentOutfit = sim.CreatedSim.CurrentOutfit; } else { currentOutfit = sim.GetOutfit(OutfitCategories.Everyday, 0); } if (currentOutfit != null) { ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, sim.AgeGenderSpecies); } return(approach); } catch (Exception e) { Common.Exception(sim, e); return(Approach.None); } }