当前位置: 首页>>代码示例>>C#>>正文


C# SimDescription.AddTrait方法代码示例

本文整理汇总了C#中SimDescription.AddTrait方法的典型用法代码示例。如果您正苦于以下问题:C# SimDescription.AddTrait方法的具体用法?C# SimDescription.AddTrait怎么用?C# SimDescription.AddTrait使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SimDescription的用法示例。


在下文中一共展示了SimDescription.AddTrait方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RestoreFutureTrait

        public static void RestoreFutureTrait(SimDescription desc)
        {
            if (desc == null)
            {
                return;
            }

            if (Register.Settings.mFutureSims.Contains(desc.SimDescriptionId) && desc.TraitManager != null && !desc.HasTrait(TraitNames.FutureSim))
            {
                Trait trait = TraitManager.GetTraitFromDictionary(TraitNames.FutureSim);
                if (trait != null)
                {
                    desc.AddTrait(trait);
                }
            }
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:16,代码来源:RoleTouristEx.cs

示例2: Run

        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;
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:96,代码来源:ChangeTraits.cs

示例3: SetTraits

        protected string SetTraits(SimDescription me, IEnumerable<SimTrait.Item> choices)
        {
            string result = Name + Common.NewLine + me.FullName;

            bool success = false;

            foreach (SimTrait.Item selection in choices)
            {
                if (me.TraitManager.HasElement(selection.Value)) continue;

                Trait selected = TraitManager.GetTraitFromDictionary(selection.Value);
                if (selected != null)
                {
                    if (!selected.TraitValidForAgeSpecies(CASUtils.CASAGSAvailabilityFlagsFromCASAgeGenderFlags(CASAgeGenderFlags.Adult | me.Species))) continue;

                    if (me.mSpendableHappiness < selected.Score) continue;

                    me.mSpendableHappiness -= selected.Score;

                    result += Common.NewLine + "  " + selected.TraitName(me.IsFemale);

                    success = true;

                    if (Traits.IsObjectBaseReward(selected.Guid))
                    {
                        if (me.Household == null) continue;

                        if (me.CreatedSim == null) continue;

                        HudModel hudModel = Sims3.UI.Responder.Instance.HudModel as HudModel;
                        if (hudModel != null)
                        {
                            bool showTNS = SimTypes.IsSelectable(me);
                            bool inHouseInventory = false;
                            Sim rewardedSim = me.CreatedSim;
                            hudModel.GiveRewardObjects(me.CreatedSim, selected.Guid, selected.ProductVersion, ref showTNS, ref inHouseInventory, ref rewardedSim);
                        }
                    }
                    else
                    {
                        switch (selected.Guid)
                        {
                            case TraitNames.ForeverYoung:
                                me.AgingEnabled = false;
                                break;
                            default:
                                if (selected.Guid == TraitNames.SuperVampire)
                                {
                                    me.AgingEnabled = false;
                                }

                                if (!me.AddTrait(selected))
                                {
                                    me.mSpendableHappiness += selected.Score;
                                }
                                break;
                        }
                    }
                }
            }

            if (!success)
            {
                result += Common.NewLine + "  " + Common.Localize(GetTitlePrefix() + ":None");
            }

            return result;
        }
开发者ID:Robobeurre,项目名称:NRaas,代码行数:68,代码来源:PurchaseRewards.cs


注:本文中的SimDescription.AddTrait方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。