예제 #1
0
        public static RabbitHole FindRabbitHole(RabbitHoleType type)
        {
            List<RabbitHole> holes = new List<RabbitHole>();
            foreach (RabbitHole hole in Sims3.Gameplay.Queries.GetObjects<RabbitHole>())
            {
                if (hole.Guid != type) continue;

                holes.Add(hole);
            }

            if (holes.Count == 0) return null;

            return RandomUtil.GetRandomObjectFromList(holes);
        }
예제 #2
0
        public static RabbitHole FindRabbitHole(RabbitHoleType type)
        {
            List <RabbitHole> holes = new List <RabbitHole>();

            foreach (RabbitHole hole in Sims3.Gameplay.Queries.GetObjects <RabbitHole>())
            {
                if (hole.Guid != type)
                {
                    continue;
                }

                holes.Add(hole);
            }

            if (holes.Count == 0)
            {
                return(null);
            }

            return(RandomUtil.GetRandomObjectFromList(holes));
        }
예제 #3
0
 public CareerBooterElement(OccupationNames career, RabbitHoleType type)
 {
     mCareer = career;
     mType = type;
 }
예제 #4
0
 public CareerRabbitHoleScoring(int hit, int miss, RabbitHoleType type)
     : base(hit, miss)
 {
     mType = type;
 }
예제 #5
0
 public CareerBooterElement(OccupationNames career, RabbitHoleType type)
 {
     mCareer = career;
     mType   = type;
 }
예제 #6
0
            public void LoadCareer(BooterHelper.BootFile file, XmlDbRow row)
            {
                BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile;
                if (dataFile == null)
                {
                    return;
                }

                string careerName = row.GetString("CareerName");

                if (careerName == null)
                {
                    BooterLogger.AddError(file.ToString() + ": No CareerName");
                }
                else
                {
                    Type classType = row.GetClassType("FullClassName");
                    if (classType != null)
                    {
                        string key = row.GetString("TableName");

                        XmlDbTable levelTable = dataFile.GetTable(key);
                        if (levelTable != null)
                        {
                            foreach (XmlDbRow levelRow in levelTable.Rows)
                            {
                                XmlDbData.XmlDbRowFast level = levelRow as XmlDbData.XmlDbRowFast;
                                if (level == null)
                                {
                                    continue;
                                }

                                if (!level.Exists("DowntownWakeupTime"))
                                {
                                    level.mData.Add("DowntownWakeupTime", level.GetString("WakeupTime"));
                                }

                                if (!level.Exists("DowntownStartTime"))
                                {
                                    level.mData.Add("DowntownStartTime", level.GetString("StartTime"));
                                }

                                if (!level.Exists("DowntownDayLength"))
                                {
                                    level.mData.Add("DowntownDayLength", level.GetString("DayLength"));
                                }
                            }

                            Type[] types  = new Type[] { typeof(XmlDbRow), typeof(XmlDbTable), typeof(XmlDbTable) };
                            Career career = null;

                            try
                            {
                                career = classType.GetConstructor(types).Invoke(new object[] { row, levelTable, null }) as Career;
                            }
                            catch (Exception e)
                            {
                                BooterLogger.AddError(careerName + ": Constructor Fail " + row.GetString("FullClassName"));

                                Common.Exception(careerName + ": Constructor Fail " + row.GetString("FullClassName"), e);
                                return;
                            }

                            if (career != null)
                            {
                                if (mCareerEventsFile.IsValid)
                                {
                                    XmlDbTable table3 = mCareerEventsFile.GetTable(key);
                                    if (table3 != null)
                                    {
                                        LoadCareerEvents(career, mCareerEventsFile, table3);
                                    }
                                }

                                career.mCareerGuid = unchecked ((OccupationNames)ResourceUtils.HashString64(row.GetString("AltGuid")));

                                if (career.Guid == OccupationNames.Undefined)
                                {
                                    BooterLogger.AddError(careerName + ": No AltGuid");
                                }
                                else if (CareerManager.GetStaticCareer(career.mCareerGuid) != null)
                                {
                                    BooterLogger.AddError(careerName + ": Duplicate GUID");
                                }
                                else
                                {
                                    RabbitHoleType type = RabbitHoleType.None;
                                    ParserFunctions.TryParseEnum <RabbitHoleType>(row.GetString("RabbitholeType"), out type, RabbitHoleType.None);
                                    if (type != RabbitHoleType.None)
                                    {
                                        sCareers.Add(new CareerBooterElement(career.Guid, type));

                                        CareerManager.AddStaticOccupation(career);

                                        BooterLogger.AddTrace(careerName + ": Added to Rabbithole " + type);
                                    }
                                    else
                                    {
                                        BooterLogger.AddError(careerName + ": Unknown Rabbithole");
                                    }
                                }
                            }
                            else
                            {
                                BooterLogger.AddError(careerName + ": Constructor Fail " + row.GetString("FullClassName"));
                            }
                        }
                        else
                        {
                            BooterLogger.AddError(careerName + ": No TableName");
                        }
                    }
                    else
                    {
                        BooterLogger.AddError(careerName + ": Invalid FullClassName " + row.GetString("FullClassName"));
                    }
                }
            }
예제 #7
0
        // From ActiveCareer::GenerateOccupationToJobStaticDataMap
        private static Dictionary <ulong, Dictionary <uint, JobStaticData> > GenerateOccupationToJobStaticDataMap(XmlDbTable jobsTable)
        {
            Dictionary <ulong, Dictionary <uint, JobStaticData> > careerToJobStaticDataMap = new Dictionary <ulong, Dictionary <uint, JobStaticData> >();

            bool          flag                      = true;
            bool          hasActiveCareer           = false;
            string        jobTitle                  = string.Empty;
            int           hoursAvailable            = 0x0;
            DaysOfTheWeek daysAvailable             = ~DaysOfTheWeek.None;
            float         jobStartTime              = -1f;
            int           budget                    = 0x0;
            int           cash                      = 0x0;
            float         experience                = 0f;
            List <JobId>  parents                   = null;
            List <TaskCreationStaticData> tasks     = null;
            string             mapTagText           = null;
            string             mapTagIcon           = null;
            bool               mapTagShowInOffHours = false;
            JobId              jobId                = JobId.Invalid;
            JobDestinaitonType destinationType      = JobDestinaitonType.Invalid;

            CommercialLotSubType[] commercialLotSubTypes = null;
            RabbitHoleType         none = RabbitHoleType.None;

            RabbitHoleType[] rabbitholeTypes = null;
            int[]            durationMinMax  = null;
            OccupationNames  activeCareer    = OccupationNames.Undefined;

            JobCooldownDefinition[] jobCooldownDefinitions = null;
            string        jobInteractionName        = null;
            string        jobIntroductionKey        = null;
            string        jobIntroductionWithSimKey = null;
            TNSNames      tnsID              = TNSNames.Invalid;
            string        musicClipName      = null;
            List <string> list3              = new List <string>();
            List <CooldownSpecificity> list4 = new List <CooldownSpecificity>();

            foreach (string str8 in jobsTable.DefaultRow.ColumnNames)
            {
                if (str8.StartsWith("Cooldown_"))
                {
                    CooldownSpecificity specificity;
                    if (!ParserFunctions.TryParseEnum <CooldownSpecificity>(str8.Substring(0x9).Replace('_', ','), out specificity, CooldownSpecificity.None))
                    {
                        return(careerToJobStaticDataMap);
                    }
                    list3.Add(str8);
                    list4.Add(specificity);
                }
            }

            int count = list3.Count;

            foreach (XmlDbRow row in jobsTable.Rows)
            {
                List <string> stringList;

                OccupationNames undefined = OccupationNames.Undefined;
                if (!row.TryGetEnum <OccupationNames>("ActiveCareer", out undefined, OccupationNames.Undefined))
                {
                    undefined = unchecked ((OccupationNames)ResourceUtils.HashString64(row.GetString("ActiveCareer")));
                }

                BooterLogger.AddTrace("ActiveCareer: " + row.GetString("ActiveCareer"));

                if (undefined != OccupationNames.Undefined)
                {
                    hasActiveCareer = true;
                    OccupationNames names4 = undefined;
                    if (undefined != activeCareer)
                    {
                        names4 = activeCareer;
                    }
                    activeCareer = undefined;
                    if (flag)
                    {
                        flag = false;
                    }
                    else
                    {
                        ActiveCareer.AddNewJob(careerToJobStaticDataMap, ref hoursAvailable, ref daysAvailable, ref jobStartTime, ref budget, ref cash, ref experience, ref parents, ref tasks, ref mapTagText, ref mapTagIcon, ref mapTagShowInOffHours, jobId, names4, ref destinationType, ref commercialLotSubTypes, ref none, ref durationMinMax, ref rabbitholeTypes, ref jobTitle, jobCooldownDefinitions, ref jobInteractionName, ref jobIntroductionKey, ref jobIntroductionWithSimKey, ref tnsID, ref musicClipName);
                    }
                }
                else if (hasActiveCareer)
                {
                    hasActiveCareer = false;
                }
                else if (!string.IsNullOrEmpty(row.GetString("ActiveCareer")))
                {
                    return(careerToJobStaticDataMap);
                }

                if (hasActiveCareer)
                {
                    if (!row.TryGetEnum <JobId>("Job_Id", out jobId, JobId.Invalid))
                    {
                        jobId = unchecked ((JobId)ResourceUtils.HashString64(row.GetString("Job_Id")));

                        sIdToJobs[jobId] = row.GetString("Job_Id");
                    }

                    BooterLogger.AddTrace("Job_Id: " + row.GetString("Job_Id"));

                    if (!row.IsInstalled("SKU_Installed") || !row.IsRegistered("SKU_Registered"))
                    {
                        if (Occupation.sValidJobsNotInstalled == null)
                        {
                            Occupation.sValidJobsNotInstalled = new List <KeyValuePair <OccupationNames, JobId> >();
                        }
                        Occupation.sValidJobsNotInstalled.Add(new KeyValuePair <OccupationNames, JobId>(undefined, jobId));
                        continue;
                    }

                    jobTitle                  = row.GetString("Job_Title");
                    hoursAvailable            = row.GetInt("Hours_Available", 0x0);
                    daysAvailable             = ParserFunctions.ParseDayListToEnum(row.GetString("Days_Available"));
                    jobStartTime              = row.GetFloat("Start_Time", -1f);
                    budget                    = row.GetInt("Budget", 0x0);
                    cash                      = row.GetInt("Payout_Cash", 0x0);
                    experience                = row.GetInt("Payout_XP", 0x0);
                    mapTagText                = row.GetString("Map_Tag_Text");
                    mapTagIcon                = row.GetString("Map_Tag_Icon");
                    mapTagShowInOffHours      = row.GetString("Show_Map_Tag_In_Off_Hours") == "x";
                    jobInteractionName        = row.GetString("Job_InteractionName");
                    jobIntroductionKey        = row.GetString("Job_IntroductionKey");
                    jobIntroductionWithSimKey = row.GetString("Job_IntroductionWithSimKey");
                    row.TryGetEnum <TNSNames>("Job_CompletionTNS", out tnsID, TNSNames.Invalid);
                    musicClipName = row.GetString("Music");
                    string str11 = row.GetString("Valid_Destination");
                    bool   flag4 = false;
                    if (!string.IsNullOrEmpty(str11))
                    {
                        if (!row.TryGetEnum <JobDestinaitonType>("Valid_Destination", out destinationType, JobDestinaitonType.Invalid))
                        {
                            flag4 = true;
                        }

                        switch (destinationType)
                        {
                        case JobDestinaitonType.Commercial:
                        case JobDestinaitonType.ResidentialAndCommercial:
                            string str12 = row.GetString("Destination_Arguments");
                            if (!string.IsNullOrEmpty(str12))
                            {
                                List <CommercialLotSubType> list5;
                                if (!ParserFunctions.TryParseCommaSeparatedList <CommercialLotSubType>(str12, out list5, CommercialLotSubType.kCommercialUndefined))
                                {
                                    flag4 = true;
                                }
                                else
                                {
                                    commercialLotSubTypes = list5.ToArray();
                                }
                            }
                            break;

                        case JobDestinaitonType.RabbitHole:
                            stringList = row.GetStringList("Destination_Arguments", ',');
                            if ((stringList != null) && (stringList.Count == 0x3))
                            {
                                if (ParserFunctions.TryParseEnum <RabbitHoleType>(stringList[0x0], out none, RabbitHoleType.None))
                                {
                                    int num7 = ParserFunctions.ParseInt(stringList[0x1], -1);
                                    int num8 = ParserFunctions.ParseInt(stringList[0x2], -1);
                                    durationMinMax = new int[] { num7, num8 };
                                }
                                else
                                {
                                    flag4 = true;
                                }
                            }
                            else
                            {
                                flag4 = true;
                            }
                            break;

                        case JobDestinaitonType.RabbitHoleLot:
                            string str13 = row.GetString("Destination_Arguments");
                            if (!string.IsNullOrEmpty(str13))
                            {
                                List <RabbitHoleType> list7;
                                if (!ParserFunctions.TryParseCommaSeparatedList <RabbitHoleType>(str13, out list7, RabbitHoleType.None))
                                {
                                    flag4 = true;
                                }
                                else
                                {
                                    rabbitholeTypes = list7.ToArray();
                                }
                            }
                            break;
                        }
                    }

                    jobCooldownDefinitions = null;
                    List <JobCooldownDefinition> list8 = new List <JobCooldownDefinition>(count);
                    for (int i = 0x0; i < count; i++)
                    {
                        int @int = row.GetInt(list3[i]);
                        if (@int != 0x0)
                        {
                            list8.Add(new JobCooldownDefinition(list4[i], (float)@int));
                        }
                    }

                    if (list8.Count > 0x0)
                    {
                        jobCooldownDefinitions = list8.ToArray();
                    }

                    if (flag4)
                    {
                        continue;
                    }
                }

                if (!string.IsNullOrEmpty(row.GetString("Parent_Job_Ids")))
                {
                    JobId id2;
                    if (!row.TryGetEnum <JobId>("Parent_Job_Ids", out id2, JobId.Invalid))
                    {
                        id2 = unchecked ((JobId)ResourceUtils.HashString64(row.GetString("Parent_Job_Ids")));

                        sIdToJobs[id2] = row.GetString("Parent_Job_Ids");
                    }

                    if (parents == null)
                    {
                        parents = new List <JobId>();
                    }
                    parents.Add(id2);
                }

                if (!string.IsNullOrEmpty(row.GetString("Task_Id")))
                {
                    TaskId id3;
                    if (!row.TryGetEnum <TaskId>("Task_Id", out id3, TaskId.Invalid))
                    {
                        id3 = unchecked ((TaskId)ResourceUtils.HashString64(row.GetString("Task_Id")));
                    }

                    if (tasks == null)
                    {
                        tasks = new List <TaskCreationStaticData>();
                    }
                    int lowerBound = row.GetInt("Task_Lower_Bound");
                    int upperBound = row.GetInt("Task_Upper_Bound");
                    TaskCreationStaticData item = new TaskCreationStaticData(id3, lowerBound, upperBound);
                    tasks.Add(item);
                }
            }

            ActiveCareer.AddNewJob(careerToJobStaticDataMap, ref hoursAvailable, ref daysAvailable, ref jobStartTime, ref budget, ref cash, ref experience, ref parents, ref tasks, ref mapTagText, ref mapTagIcon, ref mapTagShowInOffHours, jobId, activeCareer, ref destinationType, ref commercialLotSubTypes, ref none, ref durationMinMax, ref rabbitholeTypes, ref jobTitle, jobCooldownDefinitions, ref jobInteractionName, ref jobIntroductionKey, ref jobIntroductionWithSimKey, ref tnsID, ref musicClipName);

            return(careerToJobStaticDataMap);
        }
예제 #8
0
 public bool IsAvailableFor(RabbitHoleType rabbitHoleType)
 {
     return(rabbitHoleType == RabbitHoleType.Hospital);
 }