Exemple #1
0
            public static List <SkillBasedCareer.ValidSkillBasedCareerEntry> GetSkillBasedCareerList(Sim sim)
            {
                List <SkillBasedCareer.ValidSkillBasedCareerEntry> list = new List <SkillBasedCareer.ValidSkillBasedCareerEntry>();

                if (sim.SkillManager != null)
                {
                    foreach (Occupation career in CareerManager.sDictionary.Values)
                    {
                        GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                        if (!career.CanAcceptCareer(sim.ObjectId, ref greyedOutTooltipCallback))
                        {
                            continue;
                        }

                        SkillBasedCareerStaticData occupationStaticData = Occupation.GetOccupationStaticData(career.Guid) as SkillBasedCareerStaticData;
                        if (occupationStaticData != null)
                        {
                            int skillLevel = sim.SkillManager.GetSkillLevel(occupationStaticData.CorrespondingSkillName);
                            SkillBasedCareer occupationAsSkillBasedCareer = sim.OccupationAsSkillBasedCareer;
                            if ((occupationAsSkillBasedCareer == null) || (occupationAsSkillBasedCareer.Guid != career.Guid))
                            {
                                SkillBasedCareer.ValidSkillBasedCareerEntry item = new SkillBasedCareer.ValidSkillBasedCareerEntry();
                                item.Occupation        = career.Guid;
                                item.SkillLevelMet     = skillLevel >= occupationStaticData.MinimumSkillLevel;
                                item.MinimumSkillLevel = occupationStaticData.MinimumSkillLevel;
                                list.Add(item);
                            }
                        }
                    }
                }
                return(list);
            }
Exemple #2
0
        public static int GetBasePay(SkillBasedCareer career)
        {
            int level = 0;

            if (career != null)
            {
                SkillBasedCareerStaticData skillData = career.GetOccupationStaticDataForSkillBasedCareer();
                if ((skillData != null) && (skillData.CorrespondingSkillName == SkillNames.Handiness))
                {
                    level = career.CareerLevel;
                }
            }
            return(GetBasePay(level));
        }
Exemple #3
0
        public override bool IsHit(SimScoringParameters parameters)
        {
            SkillBasedCareer career = parameters.Actor.OccupationAsSkillBasedCareer;

            if (career != null)
            {
                SkillBasedCareerStaticData skillData = career.GetOccupationStaticDataForSkillBasedCareer();
                if (skillData != null)
                {
                    return(skillData.CorrespondingSkillName == mSkill);
                }
            }

            return(mSkill == SkillNames.None);
        }
Exemple #4
0
        public override bool InRabbitHole()
        {
            try
            {
                OpportunityDialog.MaptagObjectInfo info;
                if (!UIUtils.IsOkayToStartModalDialog() || !Sims3.Gameplay.ActiveCareer.ActiveCareer.CanAddActiveCareer(Actor.SimDescription, CareerToSet))
                {
                    return(false);
                }

                SkillBasedCareerStaticData occupationStaticData = Occupation.GetOccupationStaticData(CareerToSet) as SkillBasedCareerStaticData;
                Occupation staticOccupation    = CareerManager.GetStaticOccupation(CareerToSet);
                string     localizedCareerName = Occupation.GetLocalizedCareerName(CareerToSet, Actor.SimDescription);
                string     description         = Common.LocalizeEAString(Actor.IsFemale, occupationStaticData.CareerDescriptionLocalizationKey, new object[0x0]);
                string     reward = string.Empty;
                foreach (string str4 in staticOccupation.ResponsibilitiesLocalizationKeys)
                {
                    reward = reward + Common.LocalizeEAString(Actor.IsFemale, str4, new object[0x0]) + Common.NewLine;
                }
                info.mLotId          = 0x0L;
                info.mMapTag         = null;
                info.mObjectGuid     = ObjectGuid.InvalidObjectGuid;
                info.mHouseholdLotId = ulong.MaxValue;
                bool flag = OpportunityDialog.Show(ThumbnailKey.kInvalidThumbnailKey, Actor.ObjectId, ObjectGuid.InvalidObjectGuid, Actor.Name, OpportunityDialog.OpportunityType.SkillBasedCareer, localizedCareerName, description, string.Empty, reward, info, true, OpportunityDialog.DescriptionBackgroundType.NotSet, Actor.IsFemale, false);
                if (flag)
                {
                    AcquireOccupationParameters occupationParameters = new AcquireOccupationParameters(CareerToSet, true, false);

                    OmniCareer tempCareer = new OmniCareer();
                    tempCareer.mCareerGuid = staticOccupation.Guid;

                    occupationParameters.Location        = new CareerLocation();
                    occupationParameters.Location.Career = tempCareer;

                    return(Actor.AcquireOccupation(occupationParameters));
                }
                return(flag);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
        public static int GetCareerPay(Sim sim, SkillNames skill)
        {
            SkillBasedCareer career = GetSkillBasedCareer(sim, skill);

            if (career == null)
            {
                return(0);
            }

            SkillBasedCareerStaticData skillData = career.GetOccupationStaticDataForSkillBasedCareer();

            if (skillData == null)
            {
                return(0);
            }

            OccupationLevelStaticData genericData;

            if (!skillData.LevelStaticDataMap.TryGetValue(career.CareerLevel, out genericData))
            {
                return(0);
            }

            XpBasedCareerLevelStaticData data = genericData as XpBasedCareerLevelStaticData;

            if (data == null)
            {
                return(0);
            }

            if (data.Rewards.Length == 0)
            {
                return(0);
            }

            int cash = 0;

            foreach (XpBasedCareerReward reward in data.Rewards)
            {
                if (reward.Token == XpBasedCareerRewardType.Cash)
                {
                    cash += int.Parse(reward.Value);
                }
            }

            return(cash);
        }
Exemple #6
0
            public static int GetBasePay(SkillBasedCareer career)
            {
                float basePay = Sims3.Gameplay.Services.Repairman.kServiceTuning.kCost;

                if (career != null)
                {
                    SkillBasedCareerStaticData skillData = career.GetOccupationStaticDataForSkillBasedCareer();
                    if ((skillData != null) && (skillData.CorrespondingSkillName == SkillNames.Handiness))
                    {
                        for (int i = 0; i < career.CareerLevel; i++)
                        {
                            basePay *= 1.2f;
                        }
                    }
                }

                return((int)basePay);
            }
        public static SkillBasedCareer GetSkillBasedCareer(Sim sim, SkillNames skill)
        {
            SkillBasedCareer career = sim.OccupationAsSkillBasedCareer;

            if (career == null)
            {
                return(null);
            }

            SkillBasedCareerStaticData skillData = career.GetOccupationStaticDataForSkillBasedCareer();

            if (skillData == null)
            {
                return(null);
            }

            if (skillData.CorrespondingSkillName != skill)
            {
                return(null);
            }

            return(career);
        }
        protected override void PerformFile(BooterHelper.BootFile file)
        {
            BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile;
            if (dataFile == null) return;

            XmlDbTable table = dataFile.GetTable("SkillBasedCareers");
            if (table == null)
            {
                if (file.mPrimary)
                {
                    BooterLogger.AddTrace(file + ": No SkillBasedCareers table");
                }
                else
                {
                    BooterLogger.AddError(file + ": No SkillBasedCareers table");
                }
                return;
            }

            XmlDbTable table2 = dataFile.GetTable("CareerLevels");
            if (table2 == null)
            {
                BooterLogger.AddError(file + ": No CareerLevels table");
                return;
            }

            BooterLogger.AddTrace(file + ": Found Setup = " + table.Rows.Count.ToString());

            if (Occupation.sOccupationStaticDataMap == null)
            {
                Occupation.sOccupationStaticDataMap = new Dictionary<ulong, OccupationStaticData>();
            }

            Dictionary<ulong, List<XmlDbRow>> dictionary = GenerateCareerToCareerLevelXmlDataMap(table2, "SkilledProfession", "SkillBasedCareers");
            foreach (XmlDbRow row in table.Rows)
            {
                string guid = row.GetString("SkilledProfession");

                OccupationNames names;

                if (!row.TryGetEnum<OccupationNames>("SkilledProfession", out names, OccupationNames.Undefined))
                {
                    names = unchecked((OccupationNames)ResourceUtils.HashString64(guid));
                }

                if (Occupation.sOccupationStaticDataMap.ContainsKey((ulong)names))
                {
                    BooterLogger.AddError(file + ": Exists " + guid);
                    continue;
                }

                string str = row.GetString("Skill_Name");

                SkillNames skillName = SkillNames.None;

                try
                {
                    skillName = GenericManager<SkillNames, Skill, Skill>.ParseGuid(str);
                }
                catch
                { }

                if (skillName == SkillNames.None)
                {
                    skillName = unchecked((SkillNames)ResourceUtils.HashString64(str));
                }

                int minimumLevel = row.GetInt("Minimum_Skill_Level", -1);
                float gainMultiplier = row.GetFloat("XP_Gain_Multiplier", 0f);
                int highestLevel = row.GetInt("Highest_Level", 0x0);
                string speechBalloonIcon = row.GetString("Speech_Balloon_Image");
                string hudIcon = row.GetString("HUD_Icon");
                string dreamsAndPromisesIcon = row.GetString("Wishes_Icon");
                string careerDescriptionLocalizationKey = "Gameplay/Excel/SkillBasedCareers/SkillBasedCareers:" + row.GetString("Description_Text");
                string careerOfferLocalizationKey = "Gameplay/Excel/SkillBasedCareers/SkillBasedCareers:" + row.GetString("Offer_Text");
                List<string> careerResponsibilityLocalizationKeys = new List<string>();
                for (int i = 0x1; i <= 0x3; i++)
                {
                    string str7 = row.GetString("Career_Responsibility_" + i);
                    if (string.IsNullOrEmpty(str7))
                    {
                        break;
                    }
                    careerResponsibilityLocalizationKeys.Add("Gameplay/Excel/SkillBasedCareers/SkillBasedCareers:" + str7);
                }
                List<string> careerResponsibilityShortLocalizationKeys = new List<string>();
                for (int i = 0x1; i <= 0x3; i++)
                {
                    string str10 = row.GetString("Career_Responsibility_Short_" + i);
                    if (string.IsNullOrEmpty(str10))
                    {
                        break;
                    }
                    careerResponsibilityShortLocalizationKeys.Add("Gameplay/Excel/SkillBasedCareers/SkillBasedCareers:" + str10);
                }
                List<string> careerResponsibilityIcons = new List<string>();
                for (int j = 0x1; j <= 0x3; j++)
                {
                    string str11 = row.GetString("Career_Responsibility_Icon_" + j);
                    if (string.IsNullOrEmpty(str11))
                    {
                        break;
                    }
                    careerResponsibilityIcons.Add(str11);
                }

                List<XmlDbRow> list3;
                if (dictionary.TryGetValue((ulong)names, out list3))
                {
                    Dictionary<int, OccupationLevelStaticData> levelStaticDataMap = SkillBasedCareer.GenerateCareerLevelToStaticLevelDataMap(names, list3);

                    Type type = row.GetClassType("FullClassName");
                    if (type == null)
                    {
                        type = Type.GetType("Sims3.Gameplay.Careers.SkillBasedCareer, Sims3GameplaySystems");
                    }

                    Type[] types = new Type[] { typeof(OccupationNames) };
                    SkillBasedCareer career = (SkillBasedCareer)type.GetConstructor(types).Invoke(new object[] { names });
                    if (career == null)
                    {
                        BooterLogger.AddError(file.ToString() + ": Constructor Fail " + guid);
                        continue;
                    }
                    Dictionary<uint, JobStaticData> jobStaticDataMap = new Dictionary<uint, JobStaticData>();
                    Dictionary<uint, TaskStaticData> taskStaticDataMap = new Dictionary<uint, TaskStaticData>();
                    Dictionary<string, TrackedAsStaticData> trackedAsMappingsStaticDataMap = new Dictionary<string, TrackedAsStaticData>();
                    SkillBasedCareerStaticData data2 = new SkillBasedCareerStaticData(skillName, minimumLevel, gainMultiplier, highestLevel, speechBalloonIcon, hudIcon, dreamsAndPromisesIcon, careerDescriptionLocalizationKey, careerOfferLocalizationKey, careerResponsibilityLocalizationKeys, careerResponsibilityShortLocalizationKeys, careerResponsibilityIcons, levelStaticDataMap, jobStaticDataMap, taskStaticDataMap, trackedAsMappingsStaticDataMap);
                    if (Occupation.sOccupationStaticDataMap == null)
                    {
                        Occupation.sOccupationStaticDataMap = new Dictionary<ulong, OccupationStaticData>();
                    }
                    Occupation.sOccupationStaticDataMap.Add((ulong)names, data2);
                    CareerManager.AddStaticOccupation(career);
                }
                else
                {
                    BooterLogger.AddError(file.ToString() + ": No Levels " + guid);
                }
            }
        }
        protected override void PerformFile(BooterHelper.BootFile file)
        {
            BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile;
            if (dataFile == null)
            {
                return;
            }

            XmlDbTable table = dataFile.GetTable("SkillBasedCareers");

            if (table == null)
            {
                if (file.mPrimary)
                {
                    BooterLogger.AddTrace(file + ": No SkillBasedCareers table");
                }
                else
                {
                    BooterLogger.AddError(file + ": No SkillBasedCareers table");
                }
                return;
            }

            XmlDbTable table2 = dataFile.GetTable("CareerLevels");

            if (table2 == null)
            {
                BooterLogger.AddError(file + ": No CareerLevels table");
                return;
            }

            BooterLogger.AddTrace(file + ": Found Setup = " + table.Rows.Count.ToString());

            if (Occupation.sOccupationStaticDataMap == null)
            {
                Occupation.sOccupationStaticDataMap = new Dictionary <ulong, OccupationStaticData>();
            }

            Dictionary <ulong, List <XmlDbRow> > dictionary = GenerateCareerToCareerLevelXmlDataMap(table2, "SkilledProfession", "SkillBasedCareers");

            foreach (XmlDbRow row in table.Rows)
            {
                string guid = row.GetString("SkilledProfession");

                OccupationNames names;

                if (!row.TryGetEnum <OccupationNames>("SkilledProfession", out names, OccupationNames.Undefined))
                {
                    names = unchecked ((OccupationNames)ResourceUtils.HashString64(guid));
                }

                if (Occupation.sOccupationStaticDataMap.ContainsKey((ulong)names))
                {
                    BooterLogger.AddError(file + ": Exists " + guid);
                    continue;
                }

                string str = row.GetString("Skill_Name");

                SkillNames skillName = SkillNames.None;

                try
                {
                    skillName = GenericManager <SkillNames, Skill, Skill> .ParseGuid(str);
                }
                catch
                { }

                if (skillName == SkillNames.None)
                {
                    skillName = unchecked ((SkillNames)ResourceUtils.HashString64(str));
                }

                int           minimumLevel                         = row.GetInt("Minimum_Skill_Level", -1);
                float         gainMultiplier                       = row.GetFloat("XP_Gain_Multiplier", 0f);
                int           highestLevel                         = row.GetInt("Highest_Level", 0x0);
                string        speechBalloonIcon                    = row.GetString("Speech_Balloon_Image");
                string        hudIcon                              = row.GetString("HUD_Icon");
                string        dreamsAndPromisesIcon                = row.GetString("Wishes_Icon");
                string        careerDescriptionLocalizationKey     = "Gameplay/Excel/SkillBasedCareers/SkillBasedCareers:" + row.GetString("Description_Text");
                string        careerOfferLocalizationKey           = "Gameplay/Excel/SkillBasedCareers/SkillBasedCareers:" + row.GetString("Offer_Text");
                List <string> careerResponsibilityLocalizationKeys = new List <string>();
                for (int i = 0x1; i <= 0x3; i++)
                {
                    string str7 = row.GetString("Career_Responsibility_" + i);
                    if (string.IsNullOrEmpty(str7))
                    {
                        break;
                    }
                    careerResponsibilityLocalizationKeys.Add("Gameplay/Excel/SkillBasedCareers/SkillBasedCareers:" + str7);
                }
                List <string> careerResponsibilityShortLocalizationKeys = new List <string>();
                for (int i = 0x1; i <= 0x3; i++)
                {
                    string str10 = row.GetString("Career_Responsibility_Short_" + i);
                    if (string.IsNullOrEmpty(str10))
                    {
                        break;
                    }
                    careerResponsibilityShortLocalizationKeys.Add("Gameplay/Excel/SkillBasedCareers/SkillBasedCareers:" + str10);
                }
                List <string> careerResponsibilityIcons = new List <string>();
                for (int j = 0x1; j <= 0x3; j++)
                {
                    string str11 = row.GetString("Career_Responsibility_Icon_" + j);
                    if (string.IsNullOrEmpty(str11))
                    {
                        break;
                    }
                    careerResponsibilityIcons.Add(str11);
                }

                List <XmlDbRow> list3;
                if (dictionary.TryGetValue((ulong)names, out list3))
                {
                    Dictionary <int, OccupationLevelStaticData> levelStaticDataMap = SkillBasedCareer.GenerateCareerLevelToStaticLevelDataMap(names, list3);

                    Type type = row.GetClassType("FullClassName");
                    if (type == null)
                    {
                        type = Type.GetType("Sims3.Gameplay.Careers.SkillBasedCareer, Sims3GameplaySystems");
                    }

                    Type[]           types  = new Type[] { typeof(OccupationNames) };
                    SkillBasedCareer career = (SkillBasedCareer)type.GetConstructor(types).Invoke(new object[] { names });
                    if (career == null)
                    {
                        BooterLogger.AddError(file.ToString() + ": Constructor Fail " + guid);
                        continue;
                    }
                    Dictionary <uint, JobStaticData>         jobStaticDataMap  = new Dictionary <uint, JobStaticData>();
                    Dictionary <uint, TaskStaticData>        taskStaticDataMap = new Dictionary <uint, TaskStaticData>();
                    Dictionary <string, TrackedAsStaticData> trackedAsMappingsStaticDataMap = new Dictionary <string, TrackedAsStaticData>();
                    SkillBasedCareerStaticData data2 = new SkillBasedCareerStaticData(skillName, minimumLevel, gainMultiplier, highestLevel, speechBalloonIcon, hudIcon, dreamsAndPromisesIcon, careerDescriptionLocalizationKey, careerOfferLocalizationKey, careerResponsibilityLocalizationKeys, careerResponsibilityShortLocalizationKeys, careerResponsibilityIcons, levelStaticDataMap, jobStaticDataMap, taskStaticDataMap, trackedAsMappingsStaticDataMap);
                    if (Occupation.sOccupationStaticDataMap == null)
                    {
                        Occupation.sOccupationStaticDataMap = new Dictionary <ulong, OccupationStaticData>();
                    }
                    Occupation.sOccupationStaticDataMap.Add((ulong)names, data2);
                    CareerManager.AddStaticOccupation(career);
                }
                else
                {
                    BooterLogger.AddError(file.ToString() + ": No Levels " + guid);
                }
            }
        }