示例#1
0
        protected Dictionary <BlendUnit, float> GetBlendAmounts(SimDescription sim)
        {
            Dictionary <BlendUnit, float> blends;

            if (!sValues.TryGetValue(sim.SimDescriptionId, out blends))
            {
                using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, CASParts.sPrimary))
                {
                    if (builder.OutfitValid)
                    {
                        blends = new Dictionary <BlendUnit, float>();
                        sValues.Add(sim.SimDescriptionId, blends);

                        foreach (BlendUnit blend in FacialBlends.BlendUnits)
                        {
                            FacialBlendData data = new FacialBlendData(blend);

                            blends.Add(blend, FacialBlends.GetValue(builder.Builder, data));
                        }

                        builder.Invalidate();
                    }
                }
            }

            return(blends);
        }
示例#2
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(me, CASParts.sPrimary))
            {
                if (!builder.OutfitValid)
                {
                    return(true);
                }

                if (!ApplyAll)
                {
                    float oldValue = GetValue(builder.Builder);

                    string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", me.IsFemale, new object[] { me }), oldValue.ToString(), 256, StringInputDialog.Validation.None);
                    if (string.IsNullOrEmpty(text))
                    {
                        return(false);
                    }

                    mValue = 0;
                    if (!float.TryParse(text, out mValue))
                    {
                        SimpleMessageDialog.Show(Name, Common.Localize("Numeric:Error"));
                        return(false);
                    }
                }

                ApplyValue(builder.Builder, mValue);
            }

            new SavedOutfit.Cache(me).PropagateGenetics(me, CASParts.sPrimary);

            return(true);
        }
示例#3
0
        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))
            { }
        }
示例#4
0
        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);
            }
        }
示例#5
0
        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();
            }
        }
示例#6
0
        protected void SetBustMuscleSliders(SimDescription newSim)
        {
            bool changed = false;

            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(newSim, CASParts.sPrimary))
            {
                if (!builder.OutfitValid)
                {
                    return;
                }

                if (newSim.IsFemale)
                {
                    Vector2 bustRange = Manager.GetValue <BustRangeOption <TManager>, Vector2>();
                    if (bustRange.x != bustRange.y)
                    {
                        float value = RandomUtil.GetFloat(bustRange.x, bustRange.y);

                        NormalMap.ApplyBustValue(builder.Builder, value);
                        changed = true;

                        mStats.AddScoring("Bust 100s", (int)(value * 100));
                    }
                }
                else
                {
                    Vector2 muscleRange = Manager.GetValue <MuscleRangeOption <TManager>, Vector2>();
                    if (muscleRange.x != muscleRange.y)
                    {
                        float value = RandomUtil.GetFloat(muscleRange.x, muscleRange.y);

                        NormalMap.ApplyMuscleValue(builder.Builder, value);
                        changed = true;

                        mStats.AddScoring("Muscle 100s", (int)(value * 100));
                    }
                }
            }

            if (changed)
            {
                new SavedOutfit.Cache(newSim).PropagateGenetics(newSim, CASParts.sPrimary);
            }
        }
示例#7
0
        protected override bool Run(SimDescription a, SimDescription b)
        {
            if (!ApplyAll)
            {
                if (!AcceptCancelDialog.Show(Common.Localize(GetTitlePrefix() + ":Prompt", a.IsFemale, b.IsFemale, new object[] { a, b })))
                {
                    return(false);
                }
            }

            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(b, CASParts.sPrimary))
            {
                builder.Builder.SkinTone      = a.SkinToneKey;
                builder.Builder.SkinToneIndex = a.SkinToneIndex;
            }

            new SavedOutfit.Cache(b).PropagateGenetics(b, CASParts.sPrimary);

            return(true);
        }
示例#8
0
        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);
        }
示例#9
0
            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);
                }
            }
示例#10
0
        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);
        }
示例#11
0
        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);
        }
示例#12
0
        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));
        }
示例#13
0
        protected bool PrivatePerform(SimDescription a, SimDescription b, SimDescription priorBaby)
        {
            if ((priorBaby != null) && (RandomUtil.RandomChance(GetValue <ChanceOfIdenticalTwinOption, int>())))
            {
                FacialBlends.CopyGenetics(priorBaby, Sim, false, false);

                new SavedOutfit.Cache(Sim).PropagateGenetics(Sim, CASParts.sPrimary);

                IncStat("Identical");
                return(true);
            }
            else
            {
                List <SimDescription> parents = new List <SimDescription>();

                List <WorldName> worlds = new List <WorldName>();
                if (a != null)
                {
                    SimDescription sim = Relationships.GetSim(a.Genealogy);
                    if (sim != null)
                    {
                        parents.Add(sim);

                        worlds.Add(a.HomeWorld);
                    }
                }

                if (b != null)
                {
                    SimDescription sim = Relationships.GetSim(b.Genealogy);
                    if (sim != null)
                    {
                        parents.Add(sim);

                        worlds.Add(b.HomeWorld);
                    }
                }

                if (GetValue <SkinOption, bool>())
                {
                    AlterSkinBlend(this, Sim, parents);
                }

                if (parents.Count == 2)
                {
                    List <SimDescription> allParents = new List <SimDescription>(parents);
                    foreach (SimDescription parent in parents)
                    {
                        foreach (SimDescription grandParent in Relationships.GetParents(parent))
                        {
                            allParents.Add(grandParent);
                        }
                    }

                    BlendWings(allParents);

                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(Sim, CASParts.sPrimary))
                    {
                        builder.Builder.Species        = CASAgeGenderFlags.Human;
                        builder.Builder.UseCompression = true;

                        if (!builder.OutfitValid)
                        {
                            IncStat("Skin Blend: Outfit Fail");
                            return(false);
                        }
                        else
                        {
                            InheritFacialBlends(builder.Builder, parents, new Random());

                            builder.Builder.SkinToneIndex = Sim.SkinToneIndex;
                            builder.Builder.SkinTone      = Sim.SkinToneKey;
                        }
                    }

                    new SavedOutfit.Cache(Sim).PropagateGenetics(Sim, CASParts.sPrimary);

                    IncStat("Blended");
                    return(true);
                }
                else
                {
                    IncStat("Not Two");
                    return(false);
                }
            }
        }
示例#14
0
        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();
            }
        }
示例#15
0
        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);
        }
示例#16
0
        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);
        }