protected override void Perform(SimDescription sim, CASParts.Key outfitKey, CASParts.Key displayKey) { SimOutfit source = CASParts.GetOutfit(sim, outfitKey, false); using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(Dresser.GetStoreOutfitKey(outfitKey.mCategory, sim.IsUsingMaternityOutfits)), source, true)) { } }
public override void RequestAddCASPart(CASPart part, bool randomizeDesign) { if (MasterController.Settings.mAllowMultipleAccessories) { CASClothingCategory clothingCategory = CASClothingCategory.gSingleton; if (clothingCategory != null) { if (clothingCategory.IsAccessoryType(part.BodyType)) { CASLogic.GetSingleton().mRequestModelDirty = true; CASLogic.CASOperationStack.Instance.Push(new AddCASPartOperationEx(part, randomizeDesign)); return; } } } if (MasterController.Settings.mAllowMultipleMakeup) { CASMakeup makeup = CASMakeup.gSingleton; if (makeup != null) { if (CASParts.IsMakeup(part.BodyType)) { CASLogic.GetSingleton().mRequestModelDirty = true; CASLogic.CASOperationStack.Instance.Push(new AddCASPartOperationEx(part, randomizeDesign)); return; } } } base.RequestAddCASPart(part, randomizeDesign); }
protected override void Perform(SimDescription sim, CASParts.Key outfitKey, CASParts.Key displayKey) { CASParts.Key currentKey = new CASParts.Key(sim.CreatedSim); if (outfitKey == currentKey) { return; } switch (outfitKey.mCategory) { case OutfitCategories.Everyday: case OutfitCategories.Athletic: case OutfitCategories.Formalwear: case OutfitCategories.Swimwear: case OutfitCategories.Sleepwear: case OutfitCategories.Career: case OutfitCategories.Outerwear: // Don't allow the user to remove the last of a category if (sim.GetOutfitCount(outfitKey.mCategory) == 1) { return; } break; } CASParts.RemoveOutfit(sim, outfitKey, false); }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Dictionary <ResourceKey, CASParts.Wrapper> lookup = new Dictionary <ResourceKey, CASParts.Wrapper>(); foreach (CASParts.Wrapper part in CASParts.GetParts(null)) { if (lookup.ContainsKey(part.mPart.Key)) { continue; } lookup.Add(part.mPart.Key, part); } List <RemoveBlacklistPart.Item> choices = new List <RemoveBlacklistPart.Item>(); foreach (ResourceKey key in InvalidPartBooter.InvalidPartKeys) { CASParts.Wrapper part; if (lookup.TryGetValue(key, out part)) { choices.Add(new RemoveBlacklistPart.Item(part)); } else { choices.Add(new RemoveBlacklistPart.Item(key)); } } new CommonSelection <RemoveBlacklistPart.Item>(Name, choices).SelectMultiple(); return(OptionResult.Failure); }
protected override bool Allow(GameHitParameters <Sim> parameters) { if (!parameters.mTarget.SimDescription.IsUsingMaternityOutfits) { return(false); } bool found = false; foreach (OutfitCategories category in LoadOutfit.sCategories) { if (CASParts.GetOutfit(parameters.mTarget.SimDescription, new CASParts.Key(Dresser.GetStoreOutfitKey(category, parameters.mTarget.SimDescription.IsUsingMaternityOutfits)), true) != null) { found = true; break; } } if (!found) { return(false); } return(base.Allow(parameters)); }
public override void OnDelayedWorldLoadFinished() { Overwatch.Log("CleanupCareerOutfitIndices"); foreach (SimDescription sim in Household.EverySimDescription()) { CASParts.CheckIndex(sim, Overwatch.Log); } }
protected override void Perform(SimDescription sim, CASParts.Key outfitKey, CASParts.Key displayKey) { SimOutfit geneOutfit = CASParts.GetOutfit(sim, CASParts.sPrimary, false); SimOutfit source = CASParts.GetOutfit(sim, outfitKey, true); using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(displayKey.mCategory, sim), geneOutfit)) { new SavedOutfit(source).Apply(builder, false, null, CASParts.GeneticBodyTypes); } }
public Item(CASParts.Key key, SimDescriptionCore sim) : this(key) { if (sim != null) { SimOutfit outfit = CASParts.GetOutfit(sim, key, false); if (outfit != null) { mThumbnail = new ThumbnailKey(outfit, 0x0, ThumbnailSize.Medium, ThumbnailCamera.Body); } } }
protected override bool Allow(GameHitParameters <Sim> parameters) { if (parameters.mTarget.SimDescription.IsUsingMaternityOutfits) { return(false); } if (CASParts.GetOutfit(parameters.mTarget.SimDescription, new CASParts.Key(Dresser.GetStoreOutfitKey(OutfitCategories.Career, parameters.mTarget.SimDescription.IsUsingMaternityOutfits)), true) == null) { return(false); } return(base.Allow(parameters)); }
protected override bool Allow(SimDescription sim, ref CASParts.Key outfitKey, ref bool alternate, ref CASParts.Key displayKey) { displayKey = new CASParts.Key(sCategories[outfitKey.GetIndex()], 0); outfitKey = new CASParts.Key(Dresser.GetStoreOutfitKey(sCategories[outfitKey.GetIndex()], sim.IsUsingMaternityOutfits)); alternate = true; if (CASParts.GetOutfit(sim, outfitKey, true) == null) { return(false); } return(true); }
protected override OptionResult Run(GameHitParameters <Sim> parameters) { SimOutfit outfit = new SimOutfit(CASUtils.GetOutfitInGameObject(parameters.mTarget.Proxy.ObjectId)); string msg = ""; foreach (CASPart part in outfit.Parts) { msg += CASParts.PartToString(part); } Common.WriteLog(msg); SimpleMessageDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Success", parameters.mTarget.IsFemale, new object[] { parameters.mTarget })); return(OptionResult.SuccessClose); }
public Item(CASParts.Key outfitKey, bool alternate, SimDescription sim, CASParts.Key displayKey) : base(outfitKey, displayKey.GetLocalizedName(sim, false), 0) { mDisplayKey = displayKey; if (mValue.mCategory == OutfitCategories.None) { SetThumbnail("shop_all_r2", ProductVersion.BaseGame); } else { SimOutfit outfit = CASParts.GetOutfit(sim, mValue, alternate); if (outfit != null) { mThumbnail = new ThumbnailKey(outfit, 0x0, ThumbnailSize.Medium, ThumbnailCamera.Body); } } }
protected override OptionResult Run(GameHitParameters <GameObject> parameters) { Dictionary <ResourceKey, CASParts.Wrapper> lookup = new Dictionary <ResourceKey, CASParts.Wrapper>(); foreach (CASParts.Wrapper part in CASParts.GetParts(null)) { if (lookup.ContainsKey(part.mPart.Key)) { continue; } lookup.Add(part.mPart.Key, part); } List <Item> choices = new List <Item>(); foreach (ResourceKey key in MasterController.Settings.BlacklistKeys) { CASParts.Wrapper part; if (lookup.TryGetValue(key, out part)) { choices.Add(new Item(part)); } else { choices.Add(new Item(key)); } } CommonSelection <Item> .Results results = new CommonSelection <Item>(Name, choices).SelectMultiple(); if ((results == null) || (results.Count == 0)) { return(OptionResult.Failure); } foreach (Item item in results) { MasterController.Settings.RemoveBlacklistKey(item.Value); } MasterController.Settings.ApplyBlacklistParts(); return(OptionResult.SuccessClose); }
protected override OptionResult Run(GameHitParameters <Sim> parameters) { if (!AcceptCancelDialog.Show(Common.Localize(GetTitlePrefix() + ":Prompt", parameters.mTarget.IsFemale, new object[] { parameters.mTarget }))) { return(OptionResult.Failure); } SimDescription sim = parameters.mTarget.SimDescription; SimOutfit geneOutfit = CASParts.GetOutfit(sim, CASParts.sPrimary, false); foreach (OutfitCategories category in LoadOutfit.sCategories) { CASParts.Key outfitKey = new CASParts.Key(Dresser.GetStoreOutfitKey(category, sim.IsUsingMaternityOutfits)); SimOutfit source = CASParts.GetOutfit(sim, outfitKey, true); if (source == null) { continue; } int index = 0; if (category == OutfitCategories.Career) { index = 1; } using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(category, index), geneOutfit)) { new SavedOutfit(source).Apply(builder, false, null, CASParts.GeneticBodyTypes); } if (category == OutfitCategories.Career) { sim.CareerOutfitIndex = index; } } return(OptionResult.SuccessRetain); }
protected override bool PrivateUpdate(ScenarioFrame frame) { base.PrivateUpdate(frame); List <CASParts.PartPreset> parts = new List <CASParts.PartPreset>(); foreach (SimDescription parent in Relationships.GetParents(Sim)) { SimOutfit outfit = CASParts.GetOutfit(parent, new CASParts.Key(OutfitCategories.Everyday, 0), false); foreach (CASPart part in outfit.Parts) { if (CASParts.GeneticBodyTypes.Contains(part.BodyType)) { CASAgeGenderFlags ages = part.Age; if ((ages & Sim.Age) == CASAgeGenderFlags.None) { continue; } IncStat("Found: " + part.BodyType); bool found = false; foreach (CASAgeGenderFlags priorAge in sAges) { if (priorAge >= Sim.Age) { break; } if ((ages & priorAge) == priorAge) { found = true; break; } } // This part would have been inherited in an earlier age-up if (found) { continue; } parts.Add(new CASParts.PartPreset(part, outfit)); } } } AddStat("Choices", parts.Count); bool adjusted = false; using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(Sim, new CASParts.Key(OutfitCategories.Everyday, 0))) { foreach (CASParts.PartPreset part in parts) { if (RandomUtil.RandomChance(GetValue <Option, int>())) { builder.ApplyPartPreset(part); adjusted = true; IncStat("Inherited: " + part.mPart.BodyType); } } } if (adjusted) { SavedOutfit.Cache cache = new SavedOutfit.Cache(Sim); cache.PropagateGenetics(Sim, new CASParts.Key(OutfitCategories.Everyday, 0)); } return(false); }
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(); } }
public static void Transform(SimDescription sim) { if (!Hybrid.Settings.mSpecialWerewolfOutfit) { return; } SimOutfit outfit = sim.GetSpecialOutfit(sWerewolfOutfitKey); if (outfit == null) { SimOutfit sourceOutfit = sim.GetOutfit(OutfitCategories.Everyday, 0); foreach (CASPart part in sourceOutfit.Parts) { if (part.BodyType == BodyTypes.FullBody) { return; } } if (sParts == null) { sParts = CASParts.GetParts(PartMatches); } List <CASParts.PartPreset> parts = new List <CASParts.PartPreset>(); foreach (CASParts.Wrapper part in sParts) { if (!part.ValidFor(sim)) { continue; } if (RandomUtil.CoinFlip()) { continue; } CASParts.PartPreset preset = part.GetRandomPreset(); if (preset == null) { continue; } parts.Add(preset); } if (parts.Count > 0) { using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(sWerewolfOutfitKey), sourceOutfit)) { foreach (CASParts.PartPreset part in parts) { builder.Builder.RemoveParts(new BodyTypes[] { part.mPart.BodyType }); builder.ApplyPartPreset(part); } } } outfit = sim.GetSpecialOutfit(sWerewolfOutfitKey); if (outfit == null) { return; } } SwitchOutfits.SwitchNoSpin(sim.CreatedSim, new CASParts.Key(sWerewolfOutfitKey)); }
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 void Restore(SimDescription sim) { try { sim.mGenderPreferenceMale = mMalePreference; sim.mGenderPreferenceFemale = mFemalePreference; if (sim.Pregnancy != null) { sim.Pregnancy.mGender = mPregnantGender; } if (sim.CreatedSim != null) { if (mPreviousOutfitCategory != OutfitCategories.None) { SimOutfit outfit = sim.GetOutfit(mPreviousOutfitCategory, mPreviousOutfitIndex); if (outfit != null) { sim.CreatedSim.mPreviousOutfitKey = outfit.Key; } } if (sim.CreatedSim.DreamsAndPromisesManager != null) { ActiveDreamNode node = sim.CreatedSim.DreamsAndPromisesManager.LifetimeWishNode; if (node != null) { node.InternalCount = mLifetimeWishTally; } } } foreach (TraitNames trait in mTraits) { if (sim.TraitManager.HasElement(trait)) { continue; } sim.TraitManager.AddElement(trait); } SocialNetworkingSkill networkSkill = sim.SkillManager.GetSkill <SocialNetworkingSkill>(SkillNames.SocialNetworking); if (networkSkill != null) { networkSkill.mNumberOfFollowers = mNumberOfFollowers; networkSkill.mBlogsCreated = mBlogsCreated; } RockBand bandSkill = sim.SkillManager.GetSkill <RockBand>(SkillNames.RockBand); if (bandSkill != null) { bandSkill.mBandInfo = mBandInfo; } Collecting collecting = sim.SkillManager.GetSkill <Collecting>(SkillNames.Collecting); if (collecting != null) { collecting.mGlowBugData = mGlowBugData; collecting.mMushroomsCollected = mMushroomsCollected; } NectarSkill nectar = sim.SkillManager.GetSkill <NectarSkill>(SkillNames.Nectar); if (nectar != null) { nectar.mHashesMade = mNectarHashesMade; } Photography photography = sim.SkillManager.GetSkill <Photography>(SkillNames.Photography); if (photography != null) { // Forces a recalculation of the completion count // photography.mCollectionsCompleted = uint.MaxValue; photography.mCollectionsCompleted = mCollectionsCompleted; if (mSubjectRecords != null) { photography.mSubjectRecords = mSubjectRecords; } if (mStyleRecords != null) { photography.mStyleRecords = mStyleRecords; } if (mSizeRecords != null) { photography.mSizeRecords = mSizeRecords; } } RidingSkill riding = sim.SkillManager.GetSkill <RidingSkill>(SkillNames.Riding); if (riding != null) { if (mCrossCountryCompetitionsWon != null) { riding.mCrossCountryCompetitionsWon = mCrossCountryCompetitionsWon.ToArray(); } if (mJumpCompetitionsWon != null) { riding.mJumpCompetitionsWon = mJumpCompetitionsWon.ToArray(); } } Bartending mixology = sim.SkillManager.GetSkill <Bartending>(SkillNames.Bartending); if (mixology != null) { if (mCustomDrinks != null) { mixology.mUniqueDrinks = mCustomDrinks; } } if (mOccult != null) { foreach (OccultBaseClass occult in mOccult) { if (OccultTypeHelper.Add(sim, occult.ClassOccultType, false, false)) { OccultTransfer transfer = OccultTransfer.Get(occult.ClassOccultType); if (transfer != null) { transfer.Perform(sim, occult); } } } } mOccult = null; if (mOutfitCache != null) { foreach (SavedOutfit.Cache.Key outfit in mOutfitCache.Outfits) { using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, outfit.mKey, false)) { builder.Builder.SkinTone = mSkinToneKey; builder.Builder.SkinToneIndex = mSkinToneIndex; outfit.Apply(builder, true, null, null); } } foreach (SavedOutfit.Cache.Key outfit in mOutfitCache.AltOutfits) { using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, outfit.mKey, true)) { builder.Builder.SkinTone = mSkinToneKey; builder.Builder.SkinToneIndex = mSkinToneIndex; outfit.Apply(builder, true, null, null); } } int count = 0; int originalCount = mOutfitCache.GetOutfitCount(OutfitCategories.Everyday, false); while ((originalCount > 0) && (originalCount < sim.GetOutfitCount(OutfitCategories.Everyday)) && (count < originalCount)) { CASParts.RemoveOutfit(sim, new CASParts.Key(OutfitCategories.Everyday, sim.GetOutfitCount(OutfitCategories.Everyday) - 1), false); count++; } } } catch (Exception e) { Common.Exception(sim, e); } }
protected override bool Run(SimDescription me, bool singleSelection) { List <ChangeOutfit.Item> allOptions = new List <ChangeOutfit.Item>(); SavedOutfit.Cache cache = new SavedOutfit.Cache(me); foreach (SavedOutfit.Cache.Key outfit in cache.Outfits) { switch (outfit.Category) { case OutfitCategories.Everyday: case OutfitCategories.Formalwear: case OutfitCategories.Sleepwear: case OutfitCategories.Swimwear: case OutfitCategories.Athletic: case OutfitCategories.Career: case OutfitCategories.Outerwear: case OutfitCategories.MartialArts: allOptions.Add(new ChangeOutfit.Item(outfit.mKey, me)); break; } } CommonSelection <ChangeOutfit.Item> .Results sourceList = new CommonSelection <ChangeOutfit.Item>(Name, allOptions).SelectMultiple(); if ((sourceList == null) || (sourceList.Count == 0)) { return(false); } List <CategoryItem> allCategories = new List <CategoryItem>(); foreach (OutfitCategories category in Enum.GetValues(typeof(OutfitCategories))) { switch (category) { case OutfitCategories.Everyday: case OutfitCategories.Formalwear: case OutfitCategories.Sleepwear: case OutfitCategories.Swimwear: case OutfitCategories.Athletic: case OutfitCategories.Career: case OutfitCategories.Outerwear: case OutfitCategories.MartialArts: allCategories.Add(new CategoryItem(category)); break; } } CommonSelection <CategoryItem> .Results destination = new CommonSelection <CategoryItem>(Name, allCategories).SelectMultiple(); if ((destination == null) || (destination.Count == 0)) { return(false); } foreach (ChangeOutfit.Item source in sourceList) { SimOutfit sourceOutfit = CASParts.GetOutfit(me, source.Value, false); foreach (CategoryItem item in destination) { using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(me, new CASParts.Key(item.Value, -1), sourceOutfit)) { } SpeedTrap.Sleep(); } } if (me.CreatedSim != null) { me.CreatedSim.RefreshCurrentOutfit(false); } return(true); }
protected static OptionResult ApplyOutfit(SimDescription sim, OutfitCategories category) { ResourceKey newOutfitKey = ResourceKey.kInvalidResourceKey; if (sim.IsMummy) { newOutfitKey = OccultMummy.CreateMummyUniform(sim.Age, sim.Gender).Key; } else if (sim.IsFrankenstein) { newOutfitKey = OccultBaseClass.CreateUniform(OccultFrankenstein.CreateUniformName(sim, sim.OccultManager.mIsLifetimeReward), sim.Age, ProductVersion.EP2, CASSkinTones.NoSkinTone, 0f).Key; } else if (sim.IsImaginaryFriend) { OccultImaginaryFriend friend = sim.OccultManager.GetOccultType(OccultTypes.ImaginaryFriend) as OccultImaginaryFriend; string name; newOutfitKey = OccultImaginaryFriend.CreateImaginaryFriendUniform(sim.Age, friend.Pattern, out name).Key; } else { SimOutfit source = null; if (sim.GetOutfitCount(OutfitCategories.Naked) > 0) { source = sim.GetOutfit(OutfitCategories.Naked, 0); } else if (sim.GetOutfitCount(category) > 0) { source = sim.GetOutfit(category, 0); } if (source != null) { using (SimBuilder builder = new SimBuilder()) { OutfitUtils.SetOutfit(builder, source, sim); OutfitUtils.MakeCategoryAppropriate(builder, category, sim); newOutfitKey = builder.CacheOutfit(CASParts.GetOutfitName(sim, category, sim.IsUsingMaternityOutfits)); } } } if (newOutfitKey == ResourceKey.kInvalidResourceKey) { return(OptionResult.Failure); } sim.AddOutfit(new SimOutfit(newOutfitKey), category, false); int index = sim.GetOutfitCount(category) - 1; ArrayList list = sim.GetCurrentOutfits()[category] as ArrayList; object a = list[0]; object b = list[index]; list[0] = b; list[index] = a; return(OptionResult.SuccessClose); }
protected override void PrivatePerformAction(bool prompt) { try { Overwatch.Log("Cleanup Singed"); int count = 0; foreach (SimDescription sim in Household.EverySimDescription()) { int protection = 0; while ((sim.GetOutfitCount(OutfitCategories.Singed) > 1) && (protection < 100)) { sim.RemoveOutfit(OutfitCategories.Singed, sim.GetOutfitCount(OutfitCategories.Singed) - 1, true); protection++; count++; Overwatch.Log("Singed Removed " + sim.FullName); } protection = 0; while ((sim.GetOutfitCount(OutfitCategories.Career) > 3) && (protection < 100)) { // this handles the out of control lab coat's from the generation table sim.RemoveOutfit(OutfitCategories.Career, sim.GetOutfitCount(OutfitCategories.Career) - 1, true); protection++; count++; Overwatch.Log("Career Removed " + sim.FullName); } if (sim.IsBonehilda) { protection = 0; while ((sim.GetOutfitCount(OutfitCategories.Everyday) > 1) && (protection < 100)) { sim.RemoveOutfit(OutfitCategories.Everyday, sim.GetOutfitCount(OutfitCategories.Everyday) - 1, true); protection++; count++; Overwatch.Log("Bonehilda Removed " + sim.FullName); } } // fix corrupt generations outfits ArrayList outfits = sim.GetOutfits(OutfitCategories.ChildImagination); if (outfits != null) { int index = 0; while (index < outfits.Count) { SimOutfit simOutfit = outfits[index] as SimOutfit; if (simOutfit == null) { outfits.RemoveAt(index); } else if (!simOutfit.IsValid) { outfits.RemoveAt(index); } else { index++; } } } // fix corrupt diving outfits ArrayList specialOutfits = sim.GetOutfits(OutfitCategories.Special); if (specialOutfits != null) { int index = 0; while (index < specialOutfits.Count) { SimOutfit simOutfit = specialOutfits[index] as SimOutfit; if (simOutfit == null) { sim.RemoveSpecialOutfitAtIndex(index); } else if (!simOutfit.IsValid) { sim.RemoveSpecialOutfitAtIndex(index); } else { index++; } } } CASParts.CheckIndex(sim, Overwatch.Log); } if ((prompt) && (count > 0)) { Overwatch.AlarmNotify(Common.Localize("CleanupOutfits:Complete", false, new object[] { count })); } } catch (Exception e) { Common.Exception(Name, e); } }
protected override bool Run(SimDescription a, SimDescription b) { SavedOutfit.Cache cache = new SavedOutfit.Cache(a); if (!ApplyAll) { mAdd = false; List <ChangeOutfit.Item> allOptions = new List <ChangeOutfit.Item>(); allOptions.Add(new ChangeOutfit.Item(new CASParts.Key(OutfitCategories.None, 0))); foreach (SavedOutfit.Cache.Key outfit in cache.Outfits) { switch (outfit.Category) { case OutfitCategories.Everyday: case OutfitCategories.Formalwear: case OutfitCategories.Sleepwear: case OutfitCategories.Swimwear: case OutfitCategories.Athletic: case OutfitCategories.Career: case OutfitCategories.Outerwear: case OutfitCategories.MartialArts: allOptions.Add(new ChangeOutfit.Item(outfit.mKey, a)); break; } } CommonSelection <ChangeOutfit.Item> .Results choices = new CommonSelection <ChangeOutfit.Item>(Name, allOptions).SelectMultiple(); if ((choices == null) || (choices.Count == 0)) { return(false); } mTransfers.Clear(); foreach (ChangeOutfit.Item choice in choices) { if (choice.Category == OutfitCategories.None) { mTransfers.Clear(); break; } Dictionary <int, bool> indices; if (!mTransfers.TryGetValue(choice.Category, out indices)) { indices = new Dictionary <int, bool>(); mTransfers.Add(choice.Category, indices); } indices.Add(choice.Index, true); } if (TwoButtonDialog.Show( Common.Localize(GetTitlePrefix() + ":Prompt", a.IsFemale, b.IsFemale, new object[] { a, b }), Common.Localize(GetTitlePrefix() + ":Add"), Common.Localize(GetTitlePrefix() + ":Replace") )) { mAdd = true; } } SimOutfit geneOutfit = CASParts.GetOutfit(b, CASParts.sPrimary, false); foreach (SavedOutfit.Cache.Key outfit in cache.Outfits) { bool transfer = false; if (mTransfers.Count == 0) { transfer = true; } else { Dictionary <int, bool> indices; if (mTransfers.TryGetValue(outfit.Category, out indices)) { if (indices.ContainsKey(outfit.Index)) { transfer = true; } } } if (!transfer) { continue; } int newIndex = -1; if (!mAdd) { newIndex = outfit.Index; } using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(b, new CASParts.Key(outfit.Category, newIndex), geneOutfit)) { outfit.Apply(builder, false, sTypes, null); } } SpeedTrap.Sleep(); if (b.CreatedSim != null) { b.CreatedSim.RefreshCurrentOutfit(false); } 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); } }