Example #1
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            List <SimTrait.Item> allOptions = new List <SimTrait.Item>();

            foreach (Sims3.Gameplay.ActorSystems.Trait trait in TraitManager.GetDictionaryTraits)
            {
                if (trait.IsReward)
                {
                    continue;
                }

                if (!trait.TraitValidForAgeSpecies(me.GetCASAGSAvailabilityFlags()))
                {
                    continue;
                }

                int count = 0;
                if (me.TraitManager.mSocialGroupTraitGuid == trait.Guid)
                {
                    count = 1;
                }
                else if (me.HasTrait(trait.Guid))
                {
                    continue;
                }

                allOptions.Add(new SimTrait.Item(trait.Guid, count));
            }

            SimTrait.Item selection = new CommonSelection <SimTrait.Item>(Name, me.FullName, allOptions, new SimTrait.AuxillaryColumn()).SelectSingle();
            if (selection == null)
            {
                return(false);
            }

            TraitNames traitName = selection.Value;

            me.RemoveSocialGroupTrait();

            if (traitName != me.TraitManager.mSocialGroupTraitGuid)
            {
                Sims3.Gameplay.ActorSystems.Trait selTrait = TraitManager.GetTraitFromDictionary(traitName);
                if (selTrait != null)
                {
                    me.TraitManager.mSocialGroupTraitEnabled = true;
                    me.AddSocialGroupTrait(selTrait);
                }
            }

            if ((me.CreatedSim != null) && (me.CreatedSim.SocialComponent != null))
            {
                me.CreatedSim.SocialComponent.UpdateTraits();
            }

            return(true);
        }
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            List<SimTrait.Item> allOptions = new List<SimTrait.Item>();
            foreach (Sims3.Gameplay.ActorSystems.Trait trait in TraitManager.GetDictionaryTraits)
            {
                if (trait.IsReward) continue;

                if (!trait.TraitValidForAgeSpecies(me.GetCASAGSAvailabilityFlags())) continue;

                int count = 0;
                if (me.TraitManager.mUniversityGraduateTraitGuid == trait.Guid)
                {
                    count = 1;
                }
                else if (me.HasTrait(trait.Guid))
                {
                    continue;
                }

                allOptions.Add(new SimTrait.Item (trait.Guid, count));
            }

            SimTrait.Item selection = new CommonSelection<SimTrait.Item>(Name, me.FullName, allOptions, new SimTrait.AuxillaryColumn()).SelectSingle();
            if (selection == null) return false;

            TraitNames traitName = selection.Value;

            me.RemoveUniversityGraduateTrait();

            if (traitName != me.TraitManager.mUniversityGraduateTraitGuid)
            {
                Sims3.Gameplay.ActorSystems.Trait selTrait = TraitManager.GetTraitFromDictionary(traitName);
                if (selTrait != null)
                {
                    me.TraitManager.mUniversityGraduateTraitEnabled = true;
                    me.AddUniversityGraduateTrait(selTrait);
                }
            }

            if ((me.CreatedSim != null) && (me.CreatedSim.SocialComponent != null))
            {
                me.CreatedSim.SocialComponent.UpdateTraits();
            }

            return true;
        }
Example #3
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (!ApplyAll)
            {
                List <Moodlet.Item> options = new List <Moodlet.Item>();
                foreach (BuffInstance instance in GetBuffChoices())
                {
                    int value = 0;
                    if (me.CreatedSim.BuffManager.HasElement(instance.mBuffGuid))
                    {
                        value = 1;
                    }

                    if (singleSelection)
                    {
                        if ((me.GetCASAGSAvailabilityFlags() & instance.mBuff.AvailabilityFlags) == CASAGSAvailabilityFlags.None)
                        {
                            continue;
                        }
                    }

                    options.Add(new Moodlet.Item(instance, value));
                }

                CommonSelection <Moodlet.Item> .Results choices = new CommonSelection <Moodlet.Item>(Name, me.FullName, options).SelectMultiple();
                if ((choices == null) || (choices.Count == 0))
                {
                    return(false);
                }

                mBuffs.Clear();
                foreach (Moodlet.Item item in choices)
                {
                    mBuffs.Add(item.Value);
                }
            }

            foreach (BuffNames buff in mBuffs)
            {
                me.CreatedSim.BuffManager.AddElement(buff, Origin.None);
            }
            return(true);
        }
Example #4
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            List<SimTrait.Item> allOptions = new List<SimTrait.Item>();
            foreach (Sims3.Gameplay.ActorSystems.Trait trait in TraitManager.GetDictionaryTraits)
            {
                if (trait.IsReward) continue;

                if (trait.Guid == TraitNames.DescendantHiddenTrait) continue;

                if (!trait.TraitValidForAgeSpecies(me.GetCASAGSAvailabilityFlags())) continue;

                if (trait.RobotOnly) continue;                

                int count = 0;
                if (me.TraitManager.HasElement(trait.Guid))
                {
                    count = 1;
                }

                allOptions.Add(new SimTrait.Item (trait.Guid, count));
            }

            CommonSelection<SimTrait.Item>.Results selection = new CommonSelection<SimTrait.Item>(Name, me.FullName, allOptions, new SimTrait.AuxillaryColumn()).SelectMultiple();
            if (selection.Count == 0) return false;

            foreach (SimTrait.Item item in selection)
            {
                if (item == null) continue;

                TraitNames traitName = item.Value;

                Sims3.Gameplay.ActorSystems.Trait trait = TraitManager.GetTraitFromDictionary(traitName);
                if (trait != null)
                {
                    if (me.TraitManager.HasElement(traitName))
                    {
                        if (me.TraitManager.mSocialGroupTraitGuid == traitName)
                        {
                            me.RemoveSocialGroupTrait();
                        }
                        else if (me.TraitManager.mUniversityGraduateTraitGuid == traitName)
                        {
                            me.RemoveUniversityGraduateTrait();
                        }
                        else
                        {
                            me.RemoveTrait(trait);
                        }
                    }
                    else
                    {
                        int iTraitsForBabiesAndToddlers = TraitManager.kTraitsForBabiesAndToddlers;
                        int iTraitsForChildren = TraitManager.kTraitsForChildren;
                        int iTraitsForTeens = TraitManager.kTraitsForTeens;
                        int iTraitsForYoungAdultAndOlder = TraitManager.kTraitsForYoungAdultAndOlder;

                        try
                        {
                            // Don't use MaxValue as EA adds to this number for [[University]] purposes
                            TraitManager.kTraitsForBabiesAndToddlers = 10000000;
                            TraitManager.kTraitsForChildren = 10000000;
                            TraitManager.kTraitsForTeens = 10000000;
                            TraitManager.kTraitsForYoungAdultAndOlder = 10000000;

                            if (trait.IsHidden)
                            {
                                me.TraitManager.AddHiddenElement(traitName);
                            }
                            else
                            {
                                me.AddTrait(trait);
                            }
                        }
                        finally
                        {
                            TraitManager.kTraitsForBabiesAndToddlers = iTraitsForBabiesAndToddlers;
                            TraitManager.kTraitsForChildren = iTraitsForChildren;
                            TraitManager.kTraitsForTeens = iTraitsForTeens;
                            TraitManager.kTraitsForYoungAdultAndOlder = iTraitsForYoungAdultAndOlder;
                        }
                    }
                }
            }

            if ((me.CreatedSim != null) && (me.CreatedSim.SocialComponent != null))
            {
                me.CreatedSim.SocialComponent.UpdateTraits();
            }

            if (me.TraitManager.CountVisibleTraits() > me.TraitManager.NumTraitsForAge())
            {
                Common.Notify(Common.Localize("ChangeTraits:MaxExceeded", me.IsFemale, new object[] { me, me.TraitManager.CountVisibleTraits(), me.TraitManager.NumTraitsForAge() }));
            }

            return true;
        }
Example #5
0
        public static SimDescription DGSMakeSSimDescription(SimBuilder builder, CASAgeGenderFlags age, CASAgeGenderFlags gender, ResourceKey skinTone, float skinToneIndex, Color[] hairColors, WorldName homeWorld, uint outfitCategoriesToBuild, bool isAlien)
        {
            if (age == CASAgeGenderFlags.None)
            {
                return(null);
            }
            if (builder == null)
            {
                builder                = new SimBuilder();
                builder.Age            = age;
                builder.Gender         = gender;
                builder.Species        = CASAgeGenderFlags.Human;
                builder.SkinTone       = skinTone;
                builder.SkinToneIndex  = skinToneIndex;
                builder.TextureSize    = 1024u;
                builder.UseCompression = true;
            }
            if (hairColors.Length == 9)
            {
                Color[] array = new Color[10];
                hairColors.CopyTo(array, 0);
                array[9]   = hairColors[0];
                hairColors = array;
            }
            if (hairColors.Length != 10)
            {
                hairColors = Genetics.Black1;
            }
            Color[] array2 = new Color[4];
            Array.Copy(hairColors, 5, array2, 0, 4);
            Color activeEyebrowColor = hairColors[4];
            SimDescriptionCore simDescriptionCore = new SimDescriptionCore();

            simDescriptionCore.HomeWorld = homeWorld;
            bool useDyeColor = age == CASAgeGenderFlags.Elder;

            GeneticColor[] hairColors2 = simDescriptionCore.HairColors;
            for (int i = 0; i < 4; i++)
            {
                hairColors2[i].UseDyeColor = useDyeColor;
            }
            simDescriptionCore.HairColors                = hairColors2;
            simDescriptionCore.ActiveHairColors          = hairColors;
            simDescriptionCore.EyebrowColor.UseDyeColor  = useDyeColor;
            simDescriptionCore.ActiveEyebrowColor        = activeEyebrowColor;
            simDescriptionCore.BodyHairColor.UseDyeColor = useDyeColor;
            simDescriptionCore.ActiveBodyHairColor       = hairColors[9];
            GeneticColor[] facialHairColors = simDescriptionCore.FacialHairColors;
            for (int j = 0; j < 4; j++)
            {
                facialHairColors[j].UseDyeColor = useDyeColor;
            }
            simDescriptionCore.FacialHairColors       = facialHairColors;
            simDescriptionCore.ActiveFacialHairColors = array2;
            Dictionary <ResourceKey, float> dictionary = new Dictionary <ResourceKey, float>();

            if (LocaleConstraints.GetFacialShape(ref dictionary, homeWorld))
            {
                foreach (KeyValuePair <ResourceKey, float> keyValuePair in dictionary)
                {
                    builder.SetFacialBlend(keyValuePair.Key, keyValuePair.Value);
                }
            }
            OutfitUtils.AddMissingParts(builder, (OutfitCategories)2097154u, true, simDescriptionCore, isAlien);
            Genetics.SleepIfPossible();
            OutfitUtils.AddMissingParts(builder, OutfitCategories.Everyday, true, simDescriptionCore, isAlien);
            Genetics.SleepIfPossible();
            ResourceKey key = default(ResourceKey);

            if (LocaleConstraints.GetUniform(ref key, homeWorld, age, gender, OutfitCategories.Everyday))
            {
                OutfitUtils.SetOutfit(builder, new SimOutfit(key), simDescriptionCore);
            }
            OutfitUtils.SetAutomaticModifiers(builder);
            ResourceKey key2 = builder.CacheOutfit(string.Format("Genetics.MakeSim_{0}_{1}_{2}", builder.Age, Simulator.TicksElapsed(), OutfitCategories.Everyday));

            if (key2.InstanceId == 0UL)
            {
                return(null);
            }
            OutfitCategories[] array3 = new OutfitCategories[]
            {
                OutfitCategories.Naked,
                OutfitCategories.Athletic,
                OutfitCategories.Formalwear,
                OutfitCategories.Sleepwear,
                OutfitCategories.Swimwear
            };
            SimOutfit      simOutfit      = new SimOutfit(key2);
            SimDescription simDescription = new SimDescription(simOutfit);

            simDescription.HairColors       = simDescriptionCore.HairColors;
            simDescription.FacialHairColors = simDescriptionCore.FacialHairColors;
            simDescription.EyebrowColor     = simDescriptionCore.EyebrowColor;
            simDescription.BodyHairColor    = simDescriptionCore.BodyHairColor;
            simDescription.AddOutfit(simOutfit, OutfitCategories.Everyday, true);
            foreach (OutfitCategories outfitCategories in array3)
            {
                if ((outfitCategoriesToBuild & (uint)outfitCategories) != 0u)
                {
                    OutfitUtils.MakeCategoryAppropriate(builder, outfitCategories, simDescription);
                    if (LocaleConstraints.GetUniform(ref key, homeWorld, age, gender, outfitCategories))
                    {
                        OutfitUtils.SetOutfit(builder, new SimOutfit(key), simDescriptionCore);
                    }
                    ResourceKey key3 = builder.CacheOutfit(string.Format("Genetics.MakeSim_{0}_{1}_{2}", builder.Age, Simulator.TicksElapsed(), outfitCategories));
                    simDescription.AddOutfit(new SimOutfit(key3), outfitCategories);
                    Genetics.SleepIfPossible();
                }
            }
            simDescription.RandomizePreferences();
            TraitNames cultureSpecificTrait = Genetics.GetCultureSpecificTrait(homeWorld);

            if (cultureSpecificTrait == TraitNames.FutureSim)
            {
                simDescription.TraitManager.AddHiddenElement(cultureSpecificTrait);
                Skill skill = simDescription.SkillManager.AddElement(SkillNames.Future);
                if ((skill.AvailableAgeSpecies & simDescription.GetCASAGSAvailabilityFlags()) != CASAGSAvailabilityFlags.None)
                {
                    while (simDescription.SkillManager.GetSkillLevel(SkillNames.Future) < skill.MaxSkillLevel)
                    {
                        simDescription.SkillManager.ForceGainPointsForLevelUp(SkillNames.Future);
                    }
                }
            }
            else if (cultureSpecificTrait != TraitNames.Unknown)
            {
                simDescription.TraitManager.AddHiddenElement(cultureSpecificTrait);
            }
            builder.Dispose();
            builder = null;
            simDescription.HomeWorld = GameUtils.GetCurrentWorld();
            return(simDescription);
        }
Example #6
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            List <SimTrait.Item> allOptions = new List <SimTrait.Item>();

            foreach (Sims3.Gameplay.ActorSystems.Trait trait in TraitManager.GetDictionaryTraits)
            {
                if (trait.IsReward)
                {
                    continue;
                }

                if (trait.Guid == TraitNames.DescendantHiddenTrait)
                {
                    continue;
                }

                if (!trait.TraitValidForAgeSpecies(me.GetCASAGSAvailabilityFlags()))
                {
                    continue;
                }

                if (trait.RobotOnly)
                {
                    continue;
                }

                int count = 0;
                if (me.TraitManager.HasElement(trait.Guid))
                {
                    count = 1;
                }

                allOptions.Add(new SimTrait.Item(trait.Guid, count));
            }

            CommonSelection <SimTrait.Item> .Results selection = new CommonSelection <SimTrait.Item>(Name, me.FullName, allOptions, new SimTrait.AuxillaryColumn()).SelectMultiple();
            if (selection.Count == 0)
            {
                return(false);
            }

            foreach (SimTrait.Item item in selection)
            {
                if (item == null)
                {
                    continue;
                }

                TraitNames traitName = item.Value;

                Sims3.Gameplay.ActorSystems.Trait trait = TraitManager.GetTraitFromDictionary(traitName);
                if (trait != null)
                {
                    if (me.TraitManager.HasElement(traitName))
                    {
                        if (me.TraitManager.mSocialGroupTraitGuid == traitName)
                        {
                            me.RemoveSocialGroupTrait();
                        }
                        else if (me.TraitManager.mUniversityGraduateTraitGuid == traitName)
                        {
                            me.RemoveUniversityGraduateTrait();
                        }
                        else
                        {
                            me.RemoveTrait(trait);
                        }
                    }
                    else
                    {
                        int iTraitsForBabiesAndToddlers  = TraitManager.kTraitsForBabiesAndToddlers;
                        int iTraitsForChildren           = TraitManager.kTraitsForChildren;
                        int iTraitsForTeens              = TraitManager.kTraitsForTeens;
                        int iTraitsForYoungAdultAndOlder = TraitManager.kTraitsForYoungAdultAndOlder;

                        try
                        {
                            // Don't use MaxValue as EA adds to this number for [[University]] purposes
                            TraitManager.kTraitsForBabiesAndToddlers  = 10000000;
                            TraitManager.kTraitsForChildren           = 10000000;
                            TraitManager.kTraitsForTeens              = 10000000;
                            TraitManager.kTraitsForYoungAdultAndOlder = 10000000;

                            if (trait.IsHidden)
                            {
                                me.TraitManager.AddHiddenElement(traitName);
                            }
                            else
                            {
                                me.AddTrait(trait);
                            }
                        }
                        finally
                        {
                            TraitManager.kTraitsForBabiesAndToddlers  = iTraitsForBabiesAndToddlers;
                            TraitManager.kTraitsForChildren           = iTraitsForChildren;
                            TraitManager.kTraitsForTeens              = iTraitsForTeens;
                            TraitManager.kTraitsForYoungAdultAndOlder = iTraitsForYoungAdultAndOlder;
                        }
                    }
                }
            }

            if ((me.CreatedSim != null) && (me.CreatedSim.SocialComponent != null))
            {
                me.CreatedSim.SocialComponent.UpdateTraits();
            }

            if (me.TraitManager.CountVisibleTraits() > me.TraitManager.NumTraitsForAge())
            {
                Common.Notify(Common.Localize("ChangeTraits:MaxExceeded", me.IsFemale, new object[] { me, me.TraitManager.CountVisibleTraits(), me.TraitManager.NumTraitsForAge() }));
            }

            return(true);
        }