コード例 #1
0
        protected static bool ApplyOccupationUniform(SimDescription ths, SimOutfit uniform)
        {
            if (((uniform != null) && uniform.IsValid) && !ths.OccultManager.DisallowClothesChange())
            {
                SimOutfit source = CASParts.GetOutfit(ths, CASParts.sPrimary, false);
                if (source == null)
                {
                    return(false);
                }

                CASParts.Key schoolKey = new CASParts.Key("NRaasSchoolOutfit");

                SimOutfit schoolOutfit = CASParts.GetOutfit(ths, schoolKey, false);
                if (schoolOutfit == null)
                {
                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(ths, schoolKey, source))
                    {
                        new SavedOutfit(uniform).Apply(builder, true);
                    }
                }

                schoolOutfit = CASParts.GetOutfit(ths, schoolKey, false);
                if (schoolOutfit != null)
                {
                    Sim createdSim = ths.CreatedSim;
                    if (createdSim != null)
                    {
                        SwitchOutfits.SwitchNoSpin(createdSim, schoolKey);
                        return(true);
                    }
                }
            }

            return(false);
        }
コード例 #2
0
ファイル: OccultUnicornEx.cs プロジェクト: yakoder/NRaas
        public static void OnRemoval(SimDescription sim)
        {
            foreach (OutfitCategories category in sim.ListOfCategories)
            {
                switch (category)
                {
                case OutfitCategories.All:
                case OutfitCategories.CategoryMask:
                case OutfitCategories.None:
                case OutfitCategories.PrimaryCategories:
                case OutfitCategories.PrimaryHorseCategories:
                case OutfitCategories.Special:
                    continue;

                default:
                    for (int i = 0x0; i < sim.GetOutfitCount(category); i++)
                    {
                        using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(category, i)))
                        {
                            builder.Builder.RemoveParts(new BodyTypes[] { BodyTypes.PetBeard });
                            builder.Builder.RemoveParts(new BodyTypes[] { BodyTypes.PetHorn });
                        }
                    }
                    break;
                }
            }

            if (sim.CreatedSim != null)
            {
                sim.CreatedSim.UpdateOutfitInfo();
                sim.CreatedSim.RefreshCurrentOutfit(false);
            }
        }
コード例 #3
0
        protected static bool ApplyOccupationUniform(SimDescription ths, SimOutfit uniform)
        {
            if (((uniform != null) && uniform.IsValid) && !ths.OccultManager.DisallowClothesChange())
            {
                SimOutfit source = CASParts.GetOutfit(ths, CASParts.sPrimary, false); 
                if (source == null) return false;

                CASParts.Key schoolKey = new CASParts.Key("NRaasSchoolOutfit");

                SimOutfit schoolOutfit = CASParts.GetOutfit(ths, schoolKey, false);
                if (schoolOutfit == null)
                {
                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(ths, schoolKey, source))
                    {
                        new SavedOutfit(uniform).Apply(builder, true);
                    }
                }

                schoolOutfit = CASParts.GetOutfit(ths, schoolKey, false);
                if (schoolOutfit != null)
                {
                    Sim createdSim = ths.CreatedSim;
                    if (createdSim != null)
                    {
                        SwitchOutfits.SwitchNoSpin(createdSim, schoolKey);
                        return true;
                    }
                }
            }

            return false;
        }
コード例 #4
0
ファイル: StoreOutfit.cs プロジェクト: Robobeurre/NRaas
        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))
            { }
        }
コード例 #5
0
ファイル: NormalMapValue.cs プロジェクト: Robobeurre/NRaas
        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;
        }
コード例 #6
0
ファイル: LoadOutfit.cs プロジェクト: Robobeurre/NRaas
        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);
            }
        }
コード例 #7
0
ファイル: SavedOutfit.cs プロジェクト: yakoder/NRaas
            public bool PropagateGenetics(SimDescriptionCore sim, CASParts.Key geneKey)
            {
                SimOutfit origOutfit = CASParts.GetOutfit(sim, geneKey, false);

                if (origOutfit == null)
                {
                    return(false);
                }

                foreach (Key outfit in Outfits)
                {
                    if (outfit.mKey == geneKey)
                    {
                        continue;
                    }

                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, outfit.mKey, origOutfit))
                    {
                        outfit.Apply(builder, true, null, CASParts.GeneticBodyTypes);
                    }
                }

                if (mAltOutfits != null)
                {
                    foreach (Key outfit in mAltOutfits.Outfits)
                    {
                        if (outfit.mKey == geneKey)
                        {
                            continue;
                        }

                        using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, outfit.mKey, origOutfit))
                        {
                            outfit.Apply(builder, true, null, CASParts.GeneticBodyTypes);
                        }
                    }
                }

                SimDescription simDesc = sim as SimDescription;

                if ((simDesc != null) && (simDesc.CreatedSim != null))
                {
                    simDesc.CreatedSim.RefreshCurrentOutfit(false);
                }

                Common.Sleep();

                return(true);
            }
コード例 #8
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();
            }
        }
コード例 #9
0
ファイル: CopySkinTone.cs プロジェクト: Robobeurre/NRaas
        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;
        }
コード例 #10
0
ファイル: OccultTypeHelper.cs プロジェクト: yakoder/NRaas
        public static void RebuildWerewolfOutfit(SimDescription sim)
        {
            if (!sim.IsWerewolf)
            {
                return;
            }

            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(OutfitCategories.Supernatural, 0)))
            {
                if (builder.OutfitValid)
                {
                    if (builder.Outfit.SkinToneKey.InstanceId == 0x0)
                    {
                        builder.Builder.SkinTone      = sim.SkinToneKey;
                        builder.Builder.SkinToneIndex = sim.SkinToneIndex;
                    }

                    // 0xbfffffffe7ffffffL : CASLogic.sWerewolfPreserveComponents
                    // 0x4000000000000000L : Skin Tone
                    builder.Components = CASLogic.sWerewolfPreserveComponents | 0x4000000000000000L;
                }
            }
        }
コード例 #11
0
ファイル: OccultTypeHelper.cs プロジェクト: Robobeurre/NRaas
        public static bool Remove(SimDescription sim, OccultTypes type, bool alterOutfit)
        {
            if (sim.OccultManager == null) return false;

            if (sim.CreatedSim != null)
            {
                try
                {
                    if (sim.CreatedSim.CurrentOutfitCategory == OutfitCategories.Special)
                    {
                        sim.CreatedSim.SwitchToOutfitWithoutSpin(OutfitCategories.Everyday);
                    }
                }
                catch
                { }
            }

            OccultVampire vampire = sim.OccultManager.GetOccultType(type) as OccultVampire;
            if (vampire != null)
            {
                if ((vampire.mOwningSim == null) || (vampire.mOwningSim.MapTagManager == null))
                {
                    vampire.mPreyMapTag = null;
                }
            }

            if (sim.GetOutfitCount(OutfitCategories.Everyday) == 1)
            {
                SimOutfit outfit = sim.GetOutfit(OutfitCategories.Everyday, 0);

                using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(OutfitCategories.Everyday, 1), outfit))
                { }
            }

            if (type == OccultTypes.Unicorn)
            {
                OccultUnicornEx.OnRemoval(sim);
            }

            bool success = false;

            OccultManager occultManager = sim.OccultManager;

            try
            {
                if (occultManager.HasOccultType(type))
                {
                    occultManager.mCurrentOccultTypes ^= type;
                    foreach (OccultBaseClass occultClass in occultManager.mOccultList)
                    {
                        if (type == occultClass.ClassOccultType)
                        {
                            if ((occultManager.mOwnerDescription.SupernaturalData != null) && (occultManager.mOwnerDescription.SupernaturalData.OccultType == type))
                            {
                                occultManager.mOwnerDescription.RemoveSupernaturalData();
                            }

                            OccultGenie genie = occultClass as OccultGenie;
                            if (genie != null)
                            {
                                OccultGenieEx.OnRemoval(genie, occultManager.mOwnerDescription, alterOutfit);
                            }
                            else
                            {
                                OccultPlantSim plantSim = occultClass as OccultPlantSim;
                                if (plantSim != null)
                                {
                                    OccultPlantSimEx.OnRemoval(plantSim, occultManager.mOwnerDescription, alterOutfit);
                                }
                                else
                                {
                                    occultClass.OnRemoval(occultManager.mOwnerDescription);
                                }
                            }

                            occultManager.mOccultList.Remove(occultClass);
                            occultManager.mIsLifetimeReward = false;
                            if (occultManager.mOccultList.Count == 0x0)
                            {
                                occultManager.mOccultList = null;
                            }
                            break;
                        }
                    }

                    (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged();

                    occultManager.UpdateOccultUI();

                    EventTracker.SendEvent(EventTypeId.kLostOccult, occultManager.mOwnerDescription.CreatedSim);
                }

                //occultManager.RemoveOccultType(type);
                success = true;
            }
            catch (Exception e)
            {
                bool showError = true;
                switch (type)
                {
                    case OccultTypes.Genie:
                    case OccultTypes.ImaginaryFriend:
                        if (sim.CreatedSim == null)
                        {
                            showError = false;
                        }
                        break;
                }

                if (showError)
                {
                    Common.Exception(sim, e);
                }
            }

            if (!success)
            {
                for (int i = occultManager.mOccultList.Count - 1; i >= 0; i--)
                {
                    if (type == occultManager.mOccultList[i].ClassOccultType)
                    {
                        occultManager.mOccultList.RemoveAt(i);
                    }

                    (Sims3.UI.Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged();
                    sim.OccultManager.UpdateOccultUI();
                }
            }

            TraitNames trait = TraitFromOccult(type);
            if (trait != TraitNames.Unknown)
            {
                sim.TraitManager.RemoveElement(trait);
            }

            return success;
        }
コード例 #12
0
ファイル: FacialBlends.cs プロジェクト: Chain-Reaction/NRaas
        public static void RandomizeBlends(Logger log, SimDescription me, Vector2 rangeIfSet, bool addToExisting, Vector2 rangeIfUnset, bool propagate, bool disallowAlien)
        {
            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(me, CASParts.sPrimary))
            {
                if (!builder.OutfitValid) return;

                foreach (BlendUnit blend in BlendUnits)
                {
                    switch (me.Species)
                    {
                        case CASAgeGenderFlags.Human:
                            switch (blend.Category)
                            {
                                case FacialBlendCategories.Dog:
                                case FacialBlendCategories.LittleDog:
                                case FacialBlendCategories.Cat:
                                case FacialBlendCategories.PetCommon:
                                case FacialBlendCategories.Horse:
                                    continue;
                            }
                            break;
                        case CASAgeGenderFlags.Cat:
                            if ((blend.Category != FacialBlendCategories.PetCommon) && (blend.Category != FacialBlendCategories.Cat)) continue;
                            break;
                        case CASAgeGenderFlags.LittleDog:
                            if ((blend.Category != FacialBlendCategories.PetCommon) && (blend.Category != FacialBlendCategories.LittleDog)) continue;
                            break;
                        case CASAgeGenderFlags.Dog:
                            if ((blend.Category != FacialBlendCategories.PetCommon) && (blend.Category != FacialBlendCategories.Dog)) continue;
                            break;
                        case CASAgeGenderFlags.Horse:
                            if ((blend.Category != FacialBlendCategories.PetCommon) && (blend.Category != FacialBlendCategories.Horse)) continue;
                            break;
                    }

                    if (disallowAlien)
                    {
                        ResourceKey alienEyeCKey = new ResourceKey(ResourceUtils.HashString64("EyeAlienCorrector"), 0x358b08a, 0);
                        if (blend.mKey == alienEyeCKey)
                        {
                            continue;
                        }

                        ResourceKey alienEyeKey = new ResourceKey(ResourceUtils.HashString64("EyeAlien"), 0x358b08a, 0);
                        if (blend.mKey == alienEyeKey)
                        {
                            continue;
                        }

                        ResourceKey alienEarKey = new ResourceKey(ResourceUtils.HashString64("EarPoint"), 0x358b08a, 0);
                        if (blend.mKey == alienEarKey)
                        {
                            continue;
                        }
                    }

                    float value = GetValue(builder.Builder, blend);

                    if (value == 0)
                    {
                        value = RandomUtil.GetFloat(rangeIfUnset.x, rangeIfUnset.y);

                        if (value > 1)
                        {
                            value = 1;
                        }
                        else if (value < -1)
                        {
                            value = -1;
                        }

                        if (log != null)
                        {
                            log("Unset Final 100s", (int)(value * 100));
                        }
                    }
                    else
                    {
                        if (!addToExisting)
                        {
                            value = 0;
                        }

                        float newValue = RandomUtil.GetFloat(rangeIfSet.x, rangeIfSet.y);

                        if (log != null)
                        {
                            log("Set Delta 100s", (int)(newValue * 100));
                        }

                        value += newValue;

                        if (value > 1)
                        {
                            value = 1;
                        }
                        else if (value < -1)
                        {
                            value = -1;
                        }

                        if (log != null)
                        {
                            log("Set Final 100s", (int)(value * 100));
                        }
                    }

                    SetValue(builder.Builder, blend, value);
                }
            }

            if (propagate)
            {
                new SavedOutfit.Cache(me).PropagateGenetics(me, CASParts.sPrimary);
            }
        }
コード例 #13
0
ファイル: FacialBlends.cs プロジェクト: Chain-Reaction/NRaas
        public static bool CopyGenetics(SimDescriptionCore source, SimDescriptionCore destination, bool onlyNonZero, bool onlySliders)
        {
            SimOutfit sourceOutfit = CASParts.GetOutfit(source, CASParts.sPrimary, false);
            if (sourceOutfit == null) return false;

            SimOutfit sourceWerewolfOutfit = CASParts.GetOutfit(source, new CASParts.Key(OutfitCategories.Supernatural, 0), false);

            SimDescription sourceDesc = source as SimDescription;
            SimDescription destDesc = destination as SimDescription;

            if ((!onlySliders) && (!SimTypes.IsSkinJob(sourceDesc)) && (!SimTypes.IsSkinJob(destDesc)))
            {
                destDesc.SkinToneKey = sourceDesc.SkinToneKey;
                destDesc.SkinToneIndex = sourceDesc.SkinToneIndex;
            }

            destDesc.SecondaryNormalMapWeights = sourceDesc.SecondaryNormalMapWeights.Clone() as float[];

            using (SimBuilder sourceBuilder = new SimBuilder())
            {
                OutfitUtils.SetOutfit(sourceBuilder, sourceOutfit, source);

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

                    if ((!onlySliders) && (destDesc != null))
                    {
                        builder.Builder.SkinTone = destDesc.SkinToneKey;
                        builder.Builder.SkinToneIndex = destDesc.SkinToneIndex;
                    }

                    foreach (FacialBlend blend in FaceBlends)
                    {
                        float amount = GetBlendAmount(sourceBuilder, blend);

                        if (onlyNonZero)
                        {
                            if (amount == 0.0) continue;
                        }

                        SetBlendAmount(builder.Builder, blend, amount);
                    }

                    foreach (FacialBlend blend in FurBlends)
                    {
                        float amount = GetBlendAmount(sourceBuilder, blend);

                        if (onlyNonZero)
                        {
                            if (amount == 0.0) continue;
                        }

                        SetBlendAmount(builder.Builder, blend, amount);
                    }

                    if (!onlySliders)
                    {
                        builder.CopyGeneticParts(sourceOutfit);
                    }
                }

                sourceBuilder.Clear();

                if ((sourceWerewolfOutfit != null) && (destDesc.IsWerewolf))
                {
                    OutfitUtils.SetOutfit(sourceBuilder, sourceWerewolfOutfit, source);

                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(destination, new CASParts.Key(OutfitCategories.Supernatural, 0)))
                    {
                        if ((!onlySliders) && (destDesc != null))
                        {
                            builder.Builder.SkinTone = destDesc.SkinToneKey;
                            builder.Builder.SkinToneIndex = destDesc.SkinToneIndex;
                        }

                        foreach (FacialBlend blend in FaceBlends)
                        {
                            float amount = GetBlendAmount(sourceBuilder, blend);

                            if (onlyNonZero)
                            {
                                if (amount == 0.0) continue;
                            }

                            SetBlendAmount(builder.Builder, blend, amount);
                        }

                        builder.Components = CASLogic.sWerewolfPreserveComponents;
                    }
                }
            }

            return true;
        }
コード例 #14
0
ファイル: FacialBlends.cs プロジェクト: pepoluan/NRaas
        public static bool CopyGenetics(SimDescriptionCore source, SimDescriptionCore destination, bool onlyNonZero, bool onlySliders)
        {
            SimOutfit sourceOutfit = CASParts.GetOutfit(source, CASParts.sPrimary, false);

            if (sourceOutfit == null)
            {
                return(false);
            }

            SimOutfit sourceWerewolfOutfit = CASParts.GetOutfit(source, new CASParts.Key(OutfitCategories.Supernatural, 0), false);

            SimDescription sourceDesc = source as SimDescription;
            SimDescription destDesc   = destination as SimDescription;

            if ((!onlySliders) && (!SimTypes.IsSkinJob(sourceDesc)) && (!SimTypes.IsSkinJob(destDesc)))
            {
                destDesc.SkinToneKey   = sourceDesc.SkinToneKey;
                destDesc.SkinToneIndex = sourceDesc.SkinToneIndex;
            }

            destDesc.SecondaryNormalMapWeights = sourceDesc.SecondaryNormalMapWeights.Clone() as float[];

            using (SimBuilder sourceBuilder = new SimBuilder())
            {
                OutfitUtils.SetOutfit(sourceBuilder, sourceOutfit, source);

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

                    if ((!onlySliders) && (destDesc != null))
                    {
                        builder.Builder.SkinTone      = destDesc.SkinToneKey;
                        builder.Builder.SkinToneIndex = destDesc.SkinToneIndex;
                    }

                    foreach (FacialBlend blend in FaceBlends)
                    {
                        float amount = GetBlendAmount(sourceBuilder, blend);

                        if (onlyNonZero)
                        {
                            if (amount == 0.0)
                            {
                                continue;
                            }
                        }

                        SetBlendAmount(builder.Builder, blend, amount);
                    }

                    foreach (FacialBlend blend in FurBlends)
                    {
                        float amount = GetBlendAmount(sourceBuilder, blend);

                        if (onlyNonZero)
                        {
                            if (amount == 0.0)
                            {
                                continue;
                            }
                        }

                        SetBlendAmount(builder.Builder, blend, amount);
                    }

                    if (!onlySliders)
                    {
                        builder.CopyGeneticParts(sourceOutfit);
                    }
                }

                sourceBuilder.Clear();

                if ((sourceWerewolfOutfit != null) && (destDesc.IsWerewolf))
                {
                    OutfitUtils.SetOutfit(sourceBuilder, sourceWerewolfOutfit, source);

                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(destination, new CASParts.Key(OutfitCategories.Supernatural, 0)))
                    {
                        if ((!onlySliders) && (destDesc != null))
                        {
                            builder.Builder.SkinTone      = destDesc.SkinToneKey;
                            builder.Builder.SkinToneIndex = destDesc.SkinToneIndex;
                        }

                        foreach (FacialBlend blend in FaceBlends)
                        {
                            float amount = GetBlendAmount(sourceBuilder, blend);

                            if (onlyNonZero)
                            {
                                if (amount == 0.0)
                                {
                                    continue;
                                }
                            }

                            SetBlendAmount(builder.Builder, blend, amount);
                        }

                        builder.Components = CASLogic.sWerewolfPreserveComponents;
                    }
                }
            }

            return(true);
        }
コード例 #15
0
ファイル: FacialBlends.cs プロジェクト: pepoluan/NRaas
        public static void RandomizeBlends(Logger log, SimDescription me, Vector2 rangeIfSet, bool addToExisting, Vector2 rangeIfUnset, bool propagate, bool disallowAlien)
        {
            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(me, CASParts.sPrimary))
            {
                if (!builder.OutfitValid)
                {
                    return;
                }

                foreach (BlendUnit blend in BlendUnits)
                {
                    switch (me.Species)
                    {
                    case CASAgeGenderFlags.Human:
                        switch (blend.Category)
                        {
                        case FacialBlendCategories.Dog:
                        case FacialBlendCategories.LittleDog:
                        case FacialBlendCategories.Cat:
                        case FacialBlendCategories.PetCommon:
                        case FacialBlendCategories.Horse:
                            continue;
                        }
                        break;

                    case CASAgeGenderFlags.Cat:
                        if ((blend.Category != FacialBlendCategories.PetCommon) && (blend.Category != FacialBlendCategories.Cat))
                        {
                            continue;
                        }
                        break;

                    case CASAgeGenderFlags.LittleDog:
                        if ((blend.Category != FacialBlendCategories.PetCommon) && (blend.Category != FacialBlendCategories.LittleDog))
                        {
                            continue;
                        }
                        break;

                    case CASAgeGenderFlags.Dog:
                        if ((blend.Category != FacialBlendCategories.PetCommon) && (blend.Category != FacialBlendCategories.Dog))
                        {
                            continue;
                        }
                        break;

                    case CASAgeGenderFlags.Horse:
                        if ((blend.Category != FacialBlendCategories.PetCommon) && (blend.Category != FacialBlendCategories.Horse))
                        {
                            continue;
                        }
                        break;
                    }

                    if (disallowAlien)
                    {
                        ResourceKey alienEyeCKey = new ResourceKey(ResourceUtils.HashString64("EyeAlienCorrector"), 0x358b08a, 0);
                        if (blend.mKey == alienEyeCKey)
                        {
                            continue;
                        }

                        ResourceKey alienEyeKey = new ResourceKey(ResourceUtils.HashString64("EyeAlien"), 0x358b08a, 0);
                        if (blend.mKey == alienEyeKey)
                        {
                            continue;
                        }

                        ResourceKey alienEarKey = new ResourceKey(ResourceUtils.HashString64("EarPoint"), 0x358b08a, 0);
                        if (blend.mKey == alienEarKey)
                        {
                            continue;
                        }
                    }

                    float value = GetValue(builder.Builder, blend);

                    if (value == 0)
                    {
                        value = RandomUtil.GetFloat(rangeIfUnset.x, rangeIfUnset.y);

                        if (value > 1)
                        {
                            value = 1;
                        }
                        else if (value < -1)
                        {
                            value = -1;
                        }

                        if (log != null)
                        {
                            log("Unset Final 100s", (int)(value * 100));
                        }
                    }
                    else
                    {
                        if (!addToExisting)
                        {
                            value = 0;
                        }

                        float newValue = RandomUtil.GetFloat(rangeIfSet.x, rangeIfSet.y);

                        if (log != null)
                        {
                            log("Set Delta 100s", (int)(newValue * 100));
                        }

                        value += newValue;

                        if (value > 1)
                        {
                            value = 1;
                        }
                        else if (value < -1)
                        {
                            value = -1;
                        }

                        if (log != null)
                        {
                            log("Set Final 100s", (int)(value * 100));
                        }
                    }

                    SetValue(builder.Builder, blend, value);
                }
            }

            if (propagate)
            {
                new SavedOutfit.Cache(me).PropagateGenetics(me, CASParts.sPrimary);
            }
        }
コード例 #16
0
ファイル: OccultUnicornEx.cs プロジェクト: Robobeurre/NRaas
        public static void OnAddition(OccultUnicorn ths, SimDescription simDes, bool alterOutfit)
        {
            if (alterOutfit)
            {
                if (simDes.HorseManager == null)
                {
                    return;
                }

                Color[] maneColors = simDes.HorseManager.ActiveManeHairColors;
                simDes.HorseManager.ActiveUnicornBeardHairColors = maneColors;

                if (sParts == null)
                {
                    sParts = CASParts.GetParts(PartMatches);
                }

                List<CASParts.PartPreset> parts = new List<CASParts.PartPreset>();
                foreach (CASParts.Wrapper part in sParts)
                {
                    if (!part.ValidFor(simDes)) continue;

                    CASParts.PartPreset preset = part.GetRandomPreset();
                    if (preset == null) continue;

                    parts.Add(preset);
                }

                if (parts.Count > 0)
                {
                    GeneticsPet.SpeciesSpecificData speciesData = new GeneticsPet.SpeciesSpecificData();
                    speciesData.UnicornBeardHairColors = simDes.HorseManager.ActiveUnicornBeardHairColors;

                    foreach (OutfitCategories category in simDes.ListOfCategories)
                    {
                        switch (category)
                        {
                            case OutfitCategories.All:
                            case OutfitCategories.CategoryMask:
                            case OutfitCategories.None:
                            case OutfitCategories.PrimaryCategories:
                            case OutfitCategories.PrimaryHorseCategories:
                            case OutfitCategories.Special:
                                continue;
                            default:
                                for (int i = 0x0; i < simDes.GetOutfitCount(category); i++)
                                {
                                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(simDes, new CASParts.Key(category, i)))
                                    {
                                        foreach (CASParts.PartPreset part in parts)
                                        {
                                            builder.Builder.RemoveParts(new BodyTypes[] { part.mPart.BodyType });
                                            builder.ApplyPartPreset(part);
                                            if (part.mPart.BodyType == BodyTypes.PetBeard)
                                            {
                                                OutfitUtils.AdjustPresetForHorseHairColor(builder.Builder, part.mPart, speciesData);
                                            }
                                        }
                                    }
                                }
                                break;
                        }
                    }

                    if (simDes.CreatedSim != null)
                    {
                        simDes.CreatedSim.UpdateOutfitInfo();
                        simDes.CreatedSim.RefreshCurrentOutfit(false);
                    }
                }
            }
        }
コード例 #17
0
ファイル: CopyClothing.cs プロジェクト: Robobeurre/NRaas
        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;
        }
コード例 #18
0
ファイル: SavedOutfit.cs プロジェクト: yakoder/NRaas
 /*
  * public void Apply(SimBuilder builder, bool applyHairColor)
  * {
  *  List<BodyTypes> types = new List<BodyTypes>();
  *
  *  foreach (SavedPart part in mParts)
  *  {
  *      if (types.Contains(part.mPart.BodyType)) continue;
  *
  *      types.Add(part.mPart.BodyType);
  *  }
  *
  *  Apply(builder, applyHairColor, types, null);
  * }
  */
 public void Apply(CASParts.OutfitBuilder builder, bool applyHairColor)
 {
     Apply(builder, applyHairColor, UsedSingleBodyTypes, null);
 }
コード例 #19
0
ファイル: SavedOutfit.cs プロジェクト: Robobeurre/NRaas
            public bool PropagateGenetics(SimDescriptionCore sim, CASParts.Key geneKey)
            {
                SimOutfit origOutfit = CASParts.GetOutfit(sim, geneKey, false);
                if (origOutfit == null) return false;

                foreach (Key outfit in Outfits)
                {
                    if (outfit.mKey == geneKey) continue;

                    using(CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, outfit.mKey, origOutfit))
                    {
                        outfit.Apply(builder, true, null, CASParts.GeneticBodyTypes);
                    }
                }

                if (mAltOutfits != null)
                {
                    foreach (Key outfit in mAltOutfits.Outfits)
                    {
                        if (outfit.mKey == geneKey) continue;

                        using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, outfit.mKey, origOutfit))
                        {
                            outfit.Apply(builder, true, null, CASParts.GeneticBodyTypes);
                        }
                    }
                }

                SimDescription simDesc = sim as SimDescription;
                if ((simDesc != null) && (simDesc.CreatedSim != null))
                {
                    simDesc.CreatedSim.RefreshCurrentOutfit(false);
                }

                Common.Sleep();

                return true;
            }
コード例 #20
0
ファイル: OccultUnicornEx.cs プロジェクト: Robobeurre/NRaas
        public static void OnRemoval(SimDescription sim)
        {
            foreach (OutfitCategories category in sim.ListOfCategories)
            {
                switch (category)
                {
                    case OutfitCategories.All:
                    case OutfitCategories.CategoryMask:
                    case OutfitCategories.None:
                    case OutfitCategories.PrimaryCategories:
                    case OutfitCategories.PrimaryHorseCategories:
                    case OutfitCategories.Special:
                        continue;
                    default:
                        for (int i = 0x0; i < sim.GetOutfitCount(category); i++)
                        {
                            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(category, i)))
                            {
                                builder.Builder.RemoveParts(new BodyTypes[] { BodyTypes.PetBeard });
                                builder.Builder.RemoveParts(new BodyTypes[] { BodyTypes.PetHorn });   
                            }
                        }
                        break;
                }
            }

            if (sim.CreatedSim != null)
            {
                sim.CreatedSim.UpdateOutfitInfo();
                sim.CreatedSim.RefreshCurrentOutfit(false);
            }
        }
コード例 #21
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;

                        if (mSubjectRecords != null)
                        {
                            photography.mSubjectRecords = mSubjectRecords;
                        }
                    }

                    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();
                        }
                    }

                    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);
                }
            }
コード例 #22
0
ファイル: SavedOutfit.cs プロジェクト: yakoder/NRaas
 /*
  * public bool Apply(SimBuilder builder, OutfitCategories category, int index, bool applyHairColor)
  * {
  *  return Apply(builder, category, index, applyHairColor, null, null);
  * }
  */
 public bool Apply(CASParts.OutfitBuilder builder, CASParts.Key key, bool applyHairColor, IEnumerable <BodyTypes> types, IEnumerable <BodyTypes> notTypes)
 {
     return(Apply(builder.Builder, key, applyHairColor, types, notTypes));
 }
コード例 #23
0
ファイル: OccultTypeHelper.cs プロジェクト: yakoder/NRaas
        public static bool Remove(SimDescription sim, OccultTypes type, bool alterOutfit)
        {
            if (sim.OccultManager == null)
            {
                return(false);
            }

            if (sim.CreatedSim != null)
            {
                try
                {
                    if (sim.CreatedSim.CurrentOutfitCategory == OutfitCategories.Special)
                    {
                        sim.CreatedSim.SwitchToOutfitWithoutSpin(OutfitCategories.Everyday);
                    }
                }
                catch
                { }
            }

            OccultVampire vampire = sim.OccultManager.GetOccultType(type) as OccultVampire;

            if (vampire != null)
            {
                if ((vampire.mOwningSim == null) || (vampire.mOwningSim.MapTagManager == null))
                {
                    vampire.mPreyMapTag = null;
                }
            }

            if (sim.GetOutfitCount(OutfitCategories.Everyday) == 1)
            {
                SimOutfit outfit = sim.GetOutfit(OutfitCategories.Everyday, 0);

                using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(OutfitCategories.Everyday, 1), outfit))
                { }
            }

            if (type == OccultTypes.Unicorn)
            {
                OccultUnicornEx.OnRemoval(sim);
            }

            bool success = false;

            OccultManager occultManager = sim.OccultManager;

            try
            {
                if (occultManager.HasOccultType(type))
                {
                    occultManager.mCurrentOccultTypes ^= type;
                    foreach (OccultBaseClass occultClass in occultManager.mOccultList)
                    {
                        if (type == occultClass.ClassOccultType)
                        {
                            if ((occultManager.mOwnerDescription.SupernaturalData != null) && (occultManager.mOwnerDescription.SupernaturalData.OccultType == type))
                            {
                                occultManager.mOwnerDescription.RemoveSupernaturalData();
                            }

                            OccultGenie genie = occultClass as OccultGenie;
                            if (genie != null)
                            {
                                OccultGenieEx.OnRemoval(genie, occultManager.mOwnerDescription, alterOutfit);
                            }
                            else
                            {
                                OccultPlantSim plantSim = occultClass as OccultPlantSim;
                                if (plantSim != null)
                                {
                                    OccultPlantSimEx.OnRemoval(plantSim, occultManager.mOwnerDescription, alterOutfit);
                                }
                                else
                                {
                                    occultClass.OnRemoval(occultManager.mOwnerDescription);
                                }
                            }

                            occultManager.mOccultList.Remove(occultClass);
                            occultManager.mIsLifetimeReward = false;
                            if (occultManager.mOccultList.Count == 0x0)
                            {
                                occultManager.mOccultList = null;
                            }
                            break;
                        }
                    }

                    (Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged();

                    occultManager.UpdateOccultUI();

                    EventTracker.SendEvent(EventTypeId.kLostOccult, occultManager.mOwnerDescription.CreatedSim);
                }

                //occultManager.RemoveOccultType(type);
                success = true;
            }
            catch (Exception e)
            {
                bool showError = true;
                switch (type)
                {
                case OccultTypes.Genie:
                case OccultTypes.ImaginaryFriend:
                    if (sim.CreatedSim == null)
                    {
                        showError = false;
                    }
                    break;
                }

                if (showError)
                {
                    Common.Exception(sim, e);
                }
            }

            if (!success)
            {
                for (int i = occultManager.mOccultList.Count - 1; i >= 0; i--)
                {
                    if (type == occultManager.mOccultList[i].ClassOccultType)
                    {
                        occultManager.mOccultList.RemoveAt(i);
                    }

                    (Sims3.UI.Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel).OnSimDaysPerAgingYearChanged();
                    sim.OccultManager.UpdateOccultUI();
                }
            }

            TraitNames trait = TraitFromOccult(type);

            if (trait != TraitNames.Unknown)
            {
                sim.TraitManager.RemoveElement(trait);
            }

            return(success);
        }
コード例 #24
0
ファイル: SavedOutfit.cs プロジェクト: yakoder/NRaas
 public void Apply(CASParts.OutfitBuilder builder, bool applyHairColor, IEnumerable <BodyTypes> argTypes, IEnumerable <BodyTypes> argNotTypes)
 {
     mOutfit.Apply(builder, applyHairColor, argTypes, argNotTypes);
 }
コード例 #25
0
ファイル: OccultUnicornEx.cs プロジェクト: yakoder/NRaas
        public static void OnAddition(OccultUnicorn ths, SimDescription simDes, bool alterOutfit)
        {
            if (alterOutfit)
            {
                if (simDes.HorseManager == null)
                {
                    return;
                }

                Color[] maneColors = simDes.HorseManager.ActiveManeHairColors;
                simDes.HorseManager.ActiveUnicornBeardHairColors = maneColors;

                if (sParts == null)
                {
                    sParts = CASParts.GetParts(PartMatches);
                }

                List <CASParts.PartPreset> parts = new List <CASParts.PartPreset>();
                foreach (CASParts.Wrapper part in sParts)
                {
                    if (!part.ValidFor(simDes))
                    {
                        continue;
                    }

                    CASParts.PartPreset preset = part.GetRandomPreset();
                    if (preset == null)
                    {
                        continue;
                    }

                    parts.Add(preset);
                }

                if (parts.Count > 0)
                {
                    GeneticsPet.SpeciesSpecificData speciesData = new GeneticsPet.SpeciesSpecificData();
                    speciesData.UnicornBeardHairColors = simDes.HorseManager.ActiveUnicornBeardHairColors;

                    foreach (OutfitCategories category in simDes.ListOfCategories)
                    {
                        switch (category)
                        {
                        case OutfitCategories.All:
                        case OutfitCategories.CategoryMask:
                        case OutfitCategories.None:
                        case OutfitCategories.PrimaryCategories:
                        case OutfitCategories.PrimaryHorseCategories:
                        case OutfitCategories.Special:
                            continue;

                        default:
                            for (int i = 0x0; i < simDes.GetOutfitCount(category); i++)
                            {
                                using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(simDes, new CASParts.Key(category, i)))
                                {
                                    foreach (CASParts.PartPreset part in parts)
                                    {
                                        builder.Builder.RemoveParts(new BodyTypes[] { part.mPart.BodyType });
                                        builder.ApplyPartPreset(part);
                                        if (part.mPart.BodyType == BodyTypes.PetBeard)
                                        {
                                            OutfitUtils.AdjustPresetForHorseHairColor(builder.Builder, part.mPart, speciesData);
                                        }
                                    }
                                }
                            }
                            break;
                        }
                    }

                    if (simDes.CreatedSim != null)
                    {
                        simDes.CreatedSim.UpdateOutfitInfo();
                        simDes.CreatedSim.RefreshCurrentOutfit(false);
                    }
                }
            }
        }
コード例 #26
0
ファイル: OccultTypeHelper.cs プロジェクト: Robobeurre/NRaas
        public static void RebuildWerewolfOutfit(SimDescription sim)
        {
            if (!sim.IsWerewolf) return;

            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(sim, new CASParts.Key(OutfitCategories.Supernatural, 0)))
            {
                if (builder.OutfitValid)
                {
                    if (builder.Outfit.SkinToneKey.InstanceId == 0x0)
                    {
                        builder.Builder.SkinTone = sim.SkinToneKey;
                        builder.Builder.SkinToneIndex = sim.SkinToneIndex;
                    }

                    // 0xbfffffffe7ffffffL : CASLogic.sWerewolfPreserveComponents
                    // 0x4000000000000000L : Skin Tone
                    builder.Components = CASLogic.sWerewolfPreserveComponents | 0x4000000000000000L;
                }
            }
        }
コード例 #27
0
ファイル: CheckOutfitTask.cs プロジェクト: Robobeurre/NRaas
        protected override void OnPerform()
        {
            StringBuilder replacementLog = new StringBuilder();
            
            replacementLog.Append("Replacement Log");

            try
            {
                replacementLog.Append(Common.NewLine + "Options: " + ConvertToString(mOptions));
                replacementLog.Append(Common.NewLine + "Name: " + mSim.FullName);
                replacementLog.Append(Common.NewLine + "Age: " + mSim.Age);
                replacementLog.Append(Common.NewLine + "Gender: " + mSim.Gender);
                replacementLog.Append(Common.NewLine + "Species: " + mSim.Species);

                if (!mSim.IsValidDescription)
                {
                    replacementLog.Append(Common.NewLine + "Invalid");
                    return;
                }
                else if (SimTypes.IsSkinJob(mSim))
                {
                    replacementLog.Append(Common.NewLine + "Skin Job");
                    return;
                }

                OutfitCategories currentCategory = OutfitCategories.None;
                int currentIndex = 0;

                try
                {
                    if (mSim.CreatedSim != null)
                    {
                        currentCategory = mSim.CreatedSim.CurrentOutfitCategory;
                        currentIndex = mSim.CreatedSim.CurrentOutfitIndex;
                    }
                }
                catch
                { }

                Dictionary<SimOutfit, List<BodyTypes>> replaceOutfits = new Dictionary<SimOutfit, List<BodyTypes>>();

                bool testExisted = false;
                ProcessOptions testResults = ProcessOptions.None;

                if ((mOptions & ProcessOptions.CurrentOutfit) == ProcessOptions.None)
                {
                    testResults = Dresser.Settings.GetTested(mSim, out testExisted);
                }

                bool processBeard = false, processBodyHair = false, processAccessories = false;

                foreach (OutfitCategories category in sCategories)
                {
                    if ((mOptions & ProcessOptions.CurrentOutfit) != ProcessOptions.None)
                    {
                        if (category != currentCategory) continue;
                    }

                    ArrayList outfits = mSim.GetCurrentOutfits()[category] as ArrayList;
                    if (outfits == null) continue;

                    for (int i = 0; i < outfits.Count; i++)
                    {
                        if ((mOptions & ProcessOptions.CurrentOutfit) != ProcessOptions.None)
                        {
                            if (i != currentIndex) continue;
                        }

                        SimOutfit outfit = outfits[i] as SimOutfit;

                        List<BodyTypes> replace = new List<BodyTypes>();

                        if (!testExisted)
                        {
                            testResults |= GetCheck(outfit);
                        }

                        bool lowerBodyFound = false, upperBodyFound = false;

                        foreach (CASParts.Wrapper part in CASParts.Wrapper.CreateList(outfit.Parts))
                        {
                            switch (part.BodyType)
                            {
                                case BodyTypes.PeltLayer:
                                    continue;
                                case BodyTypes.FullBody:
                                case BodyTypes.PetBody:
                                    lowerBodyFound = true;
                                    upperBodyFound = true;
                                    break;
                                case BodyTypes.LowerBody:
                                    lowerBodyFound = true;
                                    break;
                                case BodyTypes.UpperBody:
                                    upperBodyFound = true;
                                    break;
                            }

                            if ((mOptions & ProcessOptions.Reroll) != ProcessOptions.None)
                            {
                                switch (GetType(part.BodyType))
                                {
                                    case ProcessOptions.Beard:
                                    case ProcessOptions.BodyHair:
                                    case ProcessOptions.Hair:
                                    case ProcessOptions.Accessories:
                                    case ProcessOptions.Makeup:
                                        break;
                                    default:
                                        switch (part.BodyType)
                                        {
                                            case BodyTypes.BirthMark:
                                            case BodyTypes.Dental:
                                            case BodyTypes.Eyebrows:
                                            case BodyTypes.Face:
                                            case BodyTypes.FirstFace:
                                            case BodyTypes.Freckles:
                                            case BodyTypes.EyeColor:
                                            case BodyTypes.Moles:
                                            case BodyTypes.Scalp:
                                            case BodyTypes.Tattoo:
                                            case BodyTypes.TattooTemplate:
                                            case BodyTypes.WeddingRing:                                           
                                                break;
                                            case BodyTypes.UpperBody:
                                            case BodyTypes.LowerBody:
                                            case BodyTypes.FullBody:
                                                if (RandomUtil.CoinFlip())
                                                {
                                                    if (!replace.Contains(BodyTypes.UpperBody))
                                                    {
                                                        replace.Add(BodyTypes.FullBody);
                                                    }
                                                }
                                                else
                                                {
                                                    if (!replace.Contains(BodyTypes.FullBody))
                                                    {
                                                        replace.Add(BodyTypes.UpperBody);
                                                        replace.Add(BodyTypes.LowerBody);
                                                    }
                                                }
                                                replacementLog.Append(Common.NewLine + part.Key + " : BodyType reroll For " + part.BodyType);
                                                break;
                                            default:
                                                replace.Add(part.BodyType);
                                                replacementLog.Append(Common.NewLine + part.Key + " : BodyType reroll For " + part.BodyType);
                                                break;
                                        }                                        
                                        break;
                                }
                            }
                            else
                            {
                                Dictionary<ResourceKey, CASParts.Wrapper> parts;
                                if (!AllParts.TryGetValue(part.BodyType, out parts))
                                {
                                    replace.Add(part.BodyType);

                                    replacementLog.Append(Common.NewLine + part.Key + " : BodyType not found For " + part.BodyType);
                                }
                                else if (!parts.ContainsKey(part.Key))
                                {
                                    replace.Add(part.BodyType);

                                    replacementLog.Append(Common.NewLine + part.Key + " : Key not found For " + part.BodyType);
                                }
                                else if ((GetType(part.BodyType) == ProcessOptions.Accessories) && (!Dresser.Settings.AllowAccessories(mSim)))
                                {
                                    replace.Add(part.BodyType);

                                    replacementLog.Append(Common.NewLine + part.Key + " : Accessories Denied For " + part.BodyType);
                                }
                                else
                                {
                                    string reason = null;
                                    if (!Allow(part, mSim.Age, mSim.Gender, mSim.Species, mSim.IsUsingMaternityOutfits, category, out reason))
                                    {
                                        replace.Add(part.BodyType);

                                        replacementLog.Append(Common.NewLine + part.Key + " : Invalid Part For " + category);
                                        replacementLog.Append(Common.NewLine + "  " + part.BodyType);
                                        replacementLog.Append(Common.NewLine + "  " + reason);
                                        replacementLog.Append(Common.NewLine + "  " + ConvertToString(part.AgeGenderSpecies));
                                        replacementLog.Append(Common.NewLine + "  " + ConvertToString(part.Category));
                                    }
                                }
                            }
                        }

                        if ((!upperBodyFound) && (!lowerBodyFound))
                        {
                            replace.Add(BodyTypes.FullBody);

                            replacementLog.Append(Common.NewLine + " UpperLower Missing For " + category);
                        }
                        else if (!upperBodyFound)
                        {
                            replace.Add(BodyTypes.UpperBody);

                            replacementLog.Append(Common.NewLine + " Upper Body Missing For " + category);
                        }
                        else if (!lowerBodyFound)
                        {
                            replace.Add(BodyTypes.LowerBody);

                            replacementLog.Append(Common.NewLine + " Lower Body Missing For " + category);
                        }

                        if (replace.Count > 0)
                        {
                            foreach(BodyTypes type in replace)
                            {
                                switch (GetType(type))
                                {
                                    case ProcessOptions.BodyHair:
                                        processBodyHair = true;
                                        break;
                                    case ProcessOptions.Accessories:
                                        processAccessories = true;
                                        break;
                                    case ProcessOptions.Beard:
                                        processBeard = true;
                                        break;
                                }
                            }

                            if (!replaceOutfits.ContainsKey(outfit))
                            {
                                replaceOutfits.Add(outfit, replace);
                            }
                        }
                    }
                }

                if (((mOptions & ProcessOptions.BodyHair) != ProcessOptions.None) && ((testResults & ProcessOptions.BodyHair) == ProcessOptions.None))
                {
                    processBodyHair = true;
                }

                replacementLog.Append(Common.NewLine + " Test Results: " + ConvertToString(testResults));

                bool process = ((mOptions & ProcessOptions.Reroll) != ProcessOptions.None);

                bool processHair = ((mOptions & ProcessOptions.Hair) != ProcessOptions.None);

                if (((mOptions & ProcessOptions.Accessories) != ProcessOptions.None) && ((testResults & ProcessOptions.Accessories) == ProcessOptions.None))
                {
                    process = true;

                    processAccessories = true;
                }
                else if (processBodyHair)
                {
                    mSim.BeardUsesHairColor = true;
                    mSim.BodyHairUsesHairColor = true;
                    mSim.EyebrowsUseHairColor = true;

                    process = true;
                }
                else if (((mOptions & ProcessOptions.Makeup) != ProcessOptions.None) && ((testResults & ProcessOptions.Makeup) == ProcessOptions.None))
                {
                    process = true;
                }
                else if (((mOptions & ProcessOptions.Invalid) != ProcessOptions.None) && (replaceOutfits.Count > 0))
                {
                    process = true;
                }
                else if (processHair)
                {
                    process = true;
                }

                if (!Dresser.Settings.AllowAccessories(mSim))
                {
                    processAccessories = false;
                }

                List<CASParts.PartPreset> bodyHair = new List<CASParts.PartPreset>();

                CASParts.PartPreset beardPart = null;
                if (mSim.IsHuman)
                {
                    if (((mOptions & ProcessOptions.Beard) != ProcessOptions.None) && ((testResults & ProcessOptions.Beard) == ProcessOptions.None))
                    {
                        if (RandomUtil.RandomChance(Dresser.Settings.mRandomBeardChance))
                        {
                            beardPart = GetRandomPreset(BodyTypes.Beard, OutfitCategories.Everyday, mSim.Age, mSim.Gender, mSim.Species, mSim.IsUsingMaternityOutfits, replacementLog);
                            processBeard = true;

                            replacementLog.Append(Common.NewLine + " Beard Chance Success");
                        }
                        else
                        {
                            replacementLog.Append(Common.NewLine + " Beard Chance Fail");
                        }

                        process = true;
                    }

                    if (processBodyHair)
                    {
                        List<Pair<BodyTypes,CASParts.Wrapper>> bodyHairs = new List<Pair<BodyTypes,CASParts.Wrapper>>();

                        int numBodyHairs = 0;

                        if (Dresser.Settings.mInheritBodyHair)
                        {
                            Dictionary<BodyTypes,CASParts.Wrapper> parts = new Dictionary<BodyTypes,CASParts.Wrapper>();
                            foreach (SimDescription parent in Relationships.GetParents(mSim))
                            {
                                if (parent.Gender != mSim.Gender) continue;

                                SimOutfit outfit = parent.GetOutfit(OutfitCategories.Everyday, 0);
                                if (outfit != null)
                                {
                                    foreach (CASPart part in outfit.Parts)
                                    {
                                        if (GetType(part.BodyType) == ProcessOptions.BodyHair)
                                        {
                                            bodyHairs.Add(new Pair<BodyTypes,CASParts.Wrapper>(part.BodyType, new CASParts.Wrapper(part)));
                                        }
                                    }
                                }
                            }

                            numBodyHairs = bodyHairs.Count;

                            replacementLog.Append(Common.NewLine + " Inherited Body Hair Count " + numBodyHairs);
                        }

                        if (bodyHairs.Count == 0)
                        {
                            StringBuilder testLog = new StringBuilder();
                            foreach (BodyTypes type in CASParts.BodyHairTypes)
                            {
                                if (GetRandomPreset(type, OutfitCategories.Everyday, mSim.Age, mSim.Gender, mSim.Species, mSim.IsUsingMaternityOutfits, testLog) == null) continue;

                                bodyHairs.Add(new Pair<BodyTypes,CASParts.Wrapper>(type, null));
                            }
                        
                            numBodyHairs = Dresser.Settings.mRandomBodyHair.GetRandomAmount(mSim.IsFemale, mSim.Age);
                            if (numBodyHairs > bodyHairs.Count)
                            {
                                numBodyHairs = bodyHairs.Count;
                            }

                            replacementLog.Append(Common.NewLine + " Random Body Hair Count " + numBodyHairs);
                        }

                        Dictionary<BodyTypes, bool> choices = new Dictionary<BodyTypes, bool>();

                        RandomUtil.RandomizeListOfObjects(bodyHairs);

                        for (int j = 0; j < numBodyHairs; j++)
                        {
                            Pair<BodyTypes,CASParts.Wrapper> pair = bodyHairs[j];

                            if (choices.ContainsKey(pair.First)) continue;
                            choices.Add(pair.First, true);

                            CASParts.Wrapper part = pair.Second;
                            if (part != null)
                            {
                                if ((part.mPart.Age & mSim.Age) == mSim.Age)
                                {
                                    bodyHair.Add(part.GetRandomPreset());

                                    replacementLog.Append(Common.NewLine + " Inherited Part " + pair.First);
                                }
                                else
                                {
                                    bodyHair.Add(GetRandomPreset(pair.First, OutfitCategories.Everyday, mSim.Age, mSim.Gender, mSim.Species, mSim.IsUsingMaternityOutfits, replacementLog));

                                    replacementLog.Append(Common.NewLine + " Inherited Position " + pair.First);
                                }
                            }
                            else
                            {
                                if (pair.First == BodyTypes.BodyHairFullBack)
                                {
                                    if (RandomUtil.CoinFlip())
                                    {
                                        bodyHair.Add(GetRandomPreset(BodyTypes.BodyHairUpperBack, OutfitCategories.Everyday, mSim.Age, mSim.Gender, mSim.Species, mSim.IsUsingMaternityOutfits, replacementLog));
                                        bodyHair.Add(GetRandomPreset(BodyTypes.BodyHairLowerBack, OutfitCategories.Everyday, mSim.Age, mSim.Gender, mSim.Species, mSim.IsUsingMaternityOutfits, replacementLog));
                                    }
                                    else
                                    {
                                        bodyHair.Add(GetRandomPreset(BodyTypes.BodyHairFullBack, OutfitCategories.Everyday, mSim.Age, mSim.Gender, mSim.Species, mSim.IsUsingMaternityOutfits, replacementLog));
                                    }
                                }
                                else
                                {
                                    bodyHair.Add(GetRandomPreset(pair.First, OutfitCategories.Everyday, mSim.Age, mSim.Gender, mSim.Species, mSim.IsUsingMaternityOutfits, replacementLog));
                                }
                            }
                        }

                        process = true;
                    }
                }

                CASParts.PartPreset hair = null;
                if ((processHair) && (Dresser.Settings.mSameHairForAllCategories))
                {
                    hair = GetRandomPreset(BodyTypes.Hair, OutfitCategories.Everyday, mSim.Age, mSim.Gender, mSim.Species, mSim.IsUsingMaternityOutfits, replacementLog);

                    replacementLog.Append(Common.NewLine + " Same Hair");
                }

                List<CASParts.PartPreset> makeup = new List<CASParts.PartPreset>();

                bool processIndividualMakeup = false;
                if (((mOptions & ProcessOptions.Makeup) != ProcessOptions.None) && ((testResults & ProcessOptions.Makeup) == ProcessOptions.None))
                {
                    if (Dresser.Settings.mSameMakeupForAllCategories)
                    {
                        int processMakeup = Dresser.Settings.mRandomMakeup.GetRandomAmount(mSim.IsFemale, mSim.Age);

                        replacementLog.Append(Common.NewLine + " Makeup Count " + processMakeup);

                        List<BodyTypes> selection = new List<BodyTypes>(CASParts.sMakeup);
                        selection.Remove(BodyTypes.CostumeMakeup);

                        while ((selection.Count > 0) && (makeup.Count < processMakeup))
                        {
                            BodyTypes type = RandomUtil.GetRandomObjectFromList(selection);
                            selection.Remove(type);

                            CASParts.PartPreset part = GetRandomPreset(type, OutfitCategories.Everyday, mSim.Age, mSim.Gender, mSim.Species, mSim.IsUsingMaternityOutfits, replacementLog);
                            if (part == null) continue;

                            makeup.Add(part);
                        }
                    }
                    else
                    {
                        processIndividualMakeup = true;
                    }
                }

                if (process)
                {
                    int replaced = 0, accessoriesAdded = 0, bodyHairAdded = 0, makeupAdded = 0;

                    foreach (OutfitCategories category in Enum.GetValues(typeof(OutfitCategories)))
                    {
                        switch (category)
                        {
                            case OutfitCategories.All:
                            case OutfitCategories.None:
                            case OutfitCategories.Special:
                            case OutfitCategories.Supernatural:
                            case OutfitCategories.PrimaryCategories:
                            case OutfitCategories.PrimaryHorseCategories:
                            case OutfitCategories.CategoryMask:
                                continue;
                        }

                        if ((mOptions & ProcessOptions.CurrentOutfit) != ProcessOptions.None)
                        {
                            if (category != currentCategory) continue;
                        }

                        bool primary = sCategories.Contains(category);
                        if ((!primary) && (!processHair) && (!processBeard) && (bodyHair.Count == 0)) continue;

                        replacementLog.Append(Common.NewLine + "Category: " + category);

                        for (int i = 0x0; i < mSim.GetOutfitCount(category); i++)
                        {
                            if ((mOptions & ProcessOptions.CurrentOutfit) != ProcessOptions.None)
                            {
                                if (i != currentIndex) continue;
                            }

                            using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(mSim, new CASParts.Key(category, i)))
                            {
                                List<BodyTypes> replace;
                                if (!replaceOutfits.TryGetValue(builder.Outfit, out replace))
                                {
                                    replace = new List<BodyTypes>();
                                }

                                if (processHair)
                                {
                                    if (!replace.Contains(BodyTypes.Hair))
                                    {
                                        replace.Add(BodyTypes.Hair);
                                    }
                                }

                                if (processBeard)
                                {
                                    replace.Add(BodyTypes.Beard);
                                }

                                foreach (CASParts.PartPreset preset in bodyHair)
                                {
                                    if (preset == null) continue;

                                    replace.Add(preset.mPart.BodyType);
                                }

                                if ((primary) && (category != OutfitCategories.Naked))
                                {
                                    if (processAccessories)
                                    {
                                        if ((category != OutfitCategories.MartialArts) || (Dresser.Settings.mMartialArtsAccessories))
                                        {
                                            Dictionary<BodyTypes, bool> choices = new Dictionary<BodyTypes, bool>();

                                            int numAccessories = Dresser.Settings.mRandomAccessories.GetRandomAmount(mSim.IsFemale, mSim.Age);

                                            replacementLog.Append(Common.NewLine + " Accessories Count " + numAccessories);

                                            List<BodyTypes> selection = new List<BodyTypes>(CASParts.sAccessories);
                                            while ((selection.Count > 0) && (choices.Count < numAccessories))
                                            {
                                                BodyTypes type = RandomUtil.GetRandomObjectFromList(selection);
                                                selection.Remove(type);

                                                if (GetRandomPreset(type, category, mSim.Age, mSim.Gender, mSim.Species, mSim.IsUsingMaternityOutfits, replacementLog) == null)
                                                {
                                                    continue;
                                                }

                                                choices[type] = true;
                                            }

                                            replace.AddRange(choices.Keys);
                                        }
                                    }

                                    if (makeup != null)
                                    {
                                        foreach (CASParts.PartPreset preset in makeup)
                                        {
                                            if (preset == null) continue;

                                            replace.Add(preset.mPart.BodyType);
                                        }
                                    }
                                    else if (processIndividualMakeup)
                                    {
                                        Dictionary<BodyTypes, bool> choices = new Dictionary<BodyTypes, bool>();

                                        int processMakeup = Dresser.Settings.mRandomMakeup.GetRandomAmount(mSim.IsFemale, mSim.Age);

                                        replacementLog.Append(Common.NewLine + " Makeup Count " + processMakeup);

                                        List<BodyTypes> selection = new List<BodyTypes>(CASParts.sMakeup);
                                        selection.Remove(BodyTypes.CostumeMakeup);

                                        while ((selection.Count > 0) && (choices.Count < processMakeup))
                                        {
                                            BodyTypes type = RandomUtil.GetRandomObjectFromList(selection);
                                            selection.Remove(type);

                                            if (GetRandomPreset(type, category, mSim.Age, mSim.Gender, mSim.Species, mSim.IsUsingMaternityOutfits, replacementLog) == null)
                                            {
                                                continue;
                                            }

                                            choices[type] = true;
                                        }

                                        replace.AddRange(choices.Keys);
                                    }
                                }

                                replacementLog.Append(Common.NewLine + "Index: " + i + " " + replace.Count);

                                bool changed = false;

                                if (replace.Count > 0)
                                {
                                    Dictionary<ResourceKey, bool> existing = new Dictionary<ResourceKey, bool>();
                                    foreach (CASPart part in builder.Outfit.Parts)
                                    {
                                        existing[part.Key] = true;
                                    }

                                    OutfitUtils.ExtractOutfitHairColorAndDyeUsage(mSim, builder.Builder);

                                    foreach (BodyTypes location in replace)
                                    {
                                        List<CASParts.PartPreset> randomParts = new List<CASParts.PartPreset>();

                                        bool allowEmpty = false;

                                        bool randomProcess = true;

                                        switch(GetType(location))
                                        {
                                            case ProcessOptions.Accessories:
                                                if (!Dresser.Settings.AllowAccessories(mSim))
                                                {
                                                    allowEmpty = true;
                                                    randomProcess = false;
                                                }

                                                break;
                                            case ProcessOptions.Beard:
                                                if (beardPart != null)
                                                {
                                                    replacementLog.Append(Common.NewLine + " Same Beard");

                                                    randomParts.Add(beardPart);
                                                }

                                                allowEmpty = true;

                                                randomProcess = false;
                                                break;
                                            case ProcessOptions.Hair:
                                                if (hair != null)
                                                {
                                                    replacementLog.Append(Common.NewLine + " Same Hair");

                                                    randomParts.Add(hair);

                                                    randomProcess = false;
                                                }
                                                break;
                                            case ProcessOptions.Makeup:
                                                if (makeup.Count > 0)
                                                {
                                                    foreach (CASParts.PartPreset preset in makeup)
                                                    {
                                                        if (preset == null) continue;

                                                        if (preset.mPart.BodyType == location)
                                                        {
                                                            replacementLog.Append(Common.NewLine + " Same Makeup");

                                                            randomParts.Add(preset);

                                                            break;
                                                        }
                                                    }

                                                    randomProcess = false;
                                                }
                                                break;
                                            case ProcessOptions.BodyHair:
                                                foreach (CASParts.PartPreset preset in bodyHair)
                                                {
                                                    if (preset == null) continue;

                                                    if (preset.mPart.BodyType == location)
                                                    {
                                                        replacementLog.Append(Common.NewLine + " Same BodyHair");

                                                        randomParts.Add(preset);

                                                        break;
                                                    }
                                                }

                                                allowEmpty = true;

                                                randomProcess = false;
                                                break;
                                        }

                                        if (randomProcess)
                                        {
                                            bool naked = true;

                                            bool[] maternityChoices = null;
                                            if (mSim.IsUsingMaternityOutfits)
                                            {
                                                maternityChoices = new bool[] { mSim.IsUsingMaternityOutfits, false };
                                            }
                                            else
                                            {
                                                maternityChoices = new bool[] { false };
                                            }

                                            foreach (bool maternity in maternityChoices)
                                            {
                                                CASParts.PartPreset randomPart = GetRandomPreset(location, category, mSim.Age, mSim.Gender, mSim.Species, maternity, replacementLog);
                                                if (randomPart != null)
                                                {
                                                    replacementLog.Append(Common.NewLine + " RandomPart For " + location);

                                                    randomParts.Add(randomPart);
                                                    naked = false;
                                                }
                                                else if (location == BodyTypes.FullBody)
                                                {
                                                    CASParts.PartPreset upperPart = GetRandomPreset(BodyTypes.UpperBody, category, mSim.Age, mSim.Gender, mSim.Species, maternity, replacementLog);
                                                    CASParts.PartPreset lowerPart = GetRandomPreset(BodyTypes.LowerBody, category, mSim.Age, mSim.Gender, mSim.Species, maternity, replacementLog);
                                                    if ((upperPart != null) && (lowerPart != null))
                                                    {
                                                        replacementLog.Append(Common.NewLine + " UpperLower For " + location);

                                                        randomParts.Add(upperPart);
                                                        randomParts.Add(lowerPart);

                                                        naked = false;
                                                    }
                                                }

                                                if (!naked) break;
                                            }

                                            if (naked)
                                            {
                                                switch (location)
                                                {
                                                    case BodyTypes.FullBody:
                                                    case BodyTypes.LowerBody:
                                                    case BodyTypes.UpperBody:
                                                    case BodyTypes.Shoes:
                                                        replacementLog.Append(Common.NewLine + " NakedPart For " + location);

                                                        randomParts.AddRange(GetFromNakedOutfit(mSim, location));
                                                        break;
                                                    default:
                                                        allowEmpty = ((CASParts.sAccessories.Contains(location)) || (location == BodyTypes.Beard) || (CASParts.sMakeup.Contains(location)) || (CASParts.BodyHairTypes.Contains(location)));
                                                        break;
                                                }
                                            }
                                        }

                                        if (randomParts.Count > 0)
                                        {
                                            foreach (CASParts.PartPreset newPart in randomParts)
                                            {
                                                if (existing.ContainsKey(newPart.mPart.Key)) continue;

                                                switch(GetType(newPart.mPart.BodyType))
                                                {
                                                    case ProcessOptions.Accessories:
                                                        accessoriesAdded++;
                                                        break;
                                                    case ProcessOptions.Beard:
                                                    case ProcessOptions.BodyHair:
                                                        bodyHairAdded++;
                                                        break;
                                                    case ProcessOptions.Makeup:
                                                        makeupAdded++;
                                                        break;
                                                    default:
                                                        replaced++;
                                                        break;
                                                }

                                                switch (newPart.mPart.BodyType)
                                                {
                                                    case BodyTypes.UpperBody:
                                                    case BodyTypes.LowerBody:
                                                        builder.Builder.RemoveParts(BodyTypes.FullBody);
                                                        break;
                                                    case BodyTypes.FullBody:
                                                        builder.Builder.RemoveParts(BodyTypes.LowerBody);
                                                        builder.Builder.RemoveParts(BodyTypes.UpperBody);
                                                        break;
                                                    case BodyTypes.BodyHairFullBack:
                                                        builder.Builder.RemoveParts(BodyTypes.BodyHairUpperBack);
                                                        builder.Builder.RemoveParts(BodyTypes.BodyHairLowerBack);
                                                        break;
                                                    case BodyTypes.BodyHairUpperBack:
                                                    case BodyTypes.BodyHairLowerBack:
                                                        builder.Builder.RemoveParts(BodyTypes.BodyHairFullBack);
                                                        break;
                                                    case BodyTypes.Earrings:
                                                        builder.Builder.RemoveParts(BodyTypes.LeftEarring);
                                                        builder.Builder.RemoveParts(BodyTypes.RightEarring);
                                                        break;
                                                    case BodyTypes.LeftEarring:
                                                    case BodyTypes.RightEarring:
                                                        builder.Builder.RemoveParts(BodyTypes.Earrings);
                                                        break;
                                                }

                                                replacementLog.Append(Common.NewLine + " Parts Removed: " + newPart.mPart.BodyType);

                                                builder.Builder.RemoveParts(newPart.mPart.BodyType);

                                                replacementLog.Append(Common.NewLine + " Parts Added: " + newPart.mPart.Key);

                                                builder.ApplyPartPreset(newPart);

                                                OutfitUtils.AdjustPresetForHairColor(builder.Builder, newPart.mPart, mSim);

                                                changed = true;
                                            }
                                        }
                                        else if (allowEmpty)
                                        {
                                            bool found = false;
                                            foreach (CASPart part in builder.Outfit.Parts)
                                            {
                                                if (part.BodyType == location)
                                                {
                                                    found = true;
                                                    break;
                                                }
                                            }

                                            if (found)
                                            {
                                                replacementLog.Append(Common.NewLine + " Parts Removed: " + location);

                                                builder.Builder.RemoveParts(location);
                                                replaced++;

                                                changed = true;
                                            }
                                        }
                                    }
                                }

                                if (!changed)
                                {
                                    builder.Invalidate();
                                }
                            }
                        }
                    }

                    if ((replaced + accessoriesAdded + bodyHairAdded + makeupAdded) > 0)
                    {
                        if (mSim.CreatedSim != null)
                        {
                            mSim.CreatedSim.UpdateOutfitInfo();

                            mSim.CreatedSim.RefreshCurrentOutfit(false);
                        }

                        SimOutfit currentOutfit = mSim.GetOutfit(OutfitCategories.Everyday, 0);
                        if (currentOutfit != null)
                        {
                            mSim.mDefaultOutfitKey = currentOutfit.Key;

                            ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, mSim.AgeGenderSpecies);
                        }

                        if (((mOptions & ProcessOptions.WriteLog) == ProcessOptions.WriteLog) ||
                            (((Common.kDebugging) || (mSim.LotHome != null)) && (Dresser.Settings.mNotifyOnCheckOutfits)))
                        {
                            Common.Notify(mSim, Common.Localize("CheckOutfit:Success", mSim.IsFemale, new object[] { mSim, replaced, accessoriesAdded, bodyHairAdded, makeupAdded }));
                        }
                    }
                }
                else
                {
                    replacementLog.Append(Common.NewLine + " No Change");
                }

                Dresser.Settings.AddTested(mSim, testResults | mOptions);
            }
            catch (Exception e)
            {
                Common.Exception(mSim, null, replacementLog.ToString(), e);
            }
            finally
            {
                if (((mOptions & ProcessOptions.WriteLog) == ProcessOptions.WriteLog) || ((Common.kDebugging) && (Dresser.Settings.mNotifyOnCheckOutfits)))
                {
                    Common.WriteLog(replacementLog.ToString());
                }

                Controller.SetToCompleted();
            }
        }
コード例 #28
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));
        }