protected override bool PrivateUpdate(ScenarioFrame frame) { Sim.CareerManager.FixRetirementPension(); ActiveCareer retired = Sim.CareerManager.RetiredCareer as ActiveCareer; if (retired == null) { IncStat("Unneeded"); return(false); } float optimal = retired.HighestLevel * GetValue <Option, int>(); if (retired.PensionAmount() < optimal) { IncStat("Underscore"); return(false); } float ratio = optimal / retired.PensionAmount(); retired.mLifetimeEarningsForPensionCalculation = (int)(retired.mLifetimeEarningsForPensionCalculation * ratio); AddStat("Ratio", ratio); return(true); }
public override bool Perform(SimDescription me, bool applyAll) { Occupation job = me.Occupation; Occupation retiredJob = me.CareerManager.mRetiredCareer; me.CareerManager.mRetiredCareer = null; Occupation staticCareer = CareerManager.GetStaticOccupation(mCareer.Guid); if (staticCareer is School) { me.CareerManager.mJob = null; } int originaHighest = 0; try { if (mLocation != null) { AcquireOccupationParameters parameters = new AcquireOccupationParameters(mLocation, false, false); parameters.ForceAutomaticChange = applyAll; me.CareerManager.AcquireOccupation(parameters); } else { if (mCareer.Guid == OccupationNames.Firefighter) { ActiveCareerStaticData activeCareerStaticData = ActiveCareer.GetActiveCareerStaticData(OccupationNames.Firefighter); originaHighest = activeCareerStaticData.HighestLevel; // Required to bypass auto promotion in SetAttributesForNewJob activeCareerStaticData.HighestLevel = 1; } AcquireOccupation(me.CareerManager, new AcquireOccupationParameters(mCareer.Guid, false, false), !applyAll); } } finally { me.CareerManager.mRetiredCareer = retiredJob; if (me.CareerManager.mJob == null) { me.CareerManager.mJob = job; } if (mCareer.Guid == OccupationNames.Firefighter) { ActiveCareerStaticData activeCareerStaticData = ActiveCareer.GetActiveCareerStaticData(OccupationNames.Firefighter); activeCareerStaticData.HighestLevel = originaHighest; } } return(true); }
protected bool AskForJob(SimDescription sim, Occupation occupation) { if ((sim.Occupation != null) && (sim.Occupation.Guid == occupation.Guid)) { IncStat("Same Job"); return(false); } Career career = occupation as Career; if (career != null) { if (!career.CareerAgeTest(sim)) { IncStat("Wrong Age"); return(false); } } if (!Careers.TestCareer(this, Sim, occupation.Guid)) { IncStat("User Disallow " + occupation.CareerName); return(false); } AcquireOccupationParameters parameters; if (occupation is Career) { CareerLocation location = Career.FindClosestCareerLocation(sim, occupation.Guid); if (location == null) { IncStat("No Location " + occupation.CareerName); return(false); } else if (!AllowStandalone(location)) { IncStat("Standalone " + occupation.CareerName); return(false); } else { parameters = new AcquireOccupationParameters(location, false, false); } } else { parameters = new AcquireOccupationParameters(occupation.Guid, false, false); } try { if (sim.Occupation != null) { if (sim.Occupation.Guid == occupation.Guid) { IncStat("Already In Job"); return(true); } if (sim.Occupation.CareerLoc != null) { foreach (SimDescription worker in sim.Occupation.CareerLoc.Workers) { if (worker.Occupation == null) { continue; } if (worker.Occupation.Coworkers == null) { worker.Occupation.Coworkers = new List <SimDescription>(); } } } sim.Occupation.LeaveJobNow(Career.LeaveJobReason.kQuit); } Occupation retiredCareer = sim.CareerManager.mRetiredCareer; sim.CareerManager.mRetiredCareer = null; int originaHighest = 0; try { if (occupation is ActiveFireFighter) { ActiveCareerStaticData activeCareerStaticData = ActiveCareer.GetActiveCareerStaticData(OccupationNames.Firefighter); originaHighest = activeCareerStaticData.HighestLevel; // Required to bypass auto promotion in SetAttributesForNewJob activeCareerStaticData.HighestLevel = 1; } if (occupation is XpBasedCareer) { // Required by Stylist.GetOccupationJoiningTnsTextPrefix() if (!Sims.Instantiate(sim, sim.LotHome, false)) { IncStat("Hibernating"); return(false); } } if (AcquireOccupation(sim.CareerManager, parameters)) { IncStat(occupation.Guid.ToString()); return(true); } } finally { sim.CareerManager.mRetiredCareer = retiredCareer; if (occupation is ActiveFireFighter) { ActiveCareerStaticData activeCareerStaticData = ActiveCareer.GetActiveCareerStaticData(OccupationNames.Firefighter); activeCareerStaticData.HighestLevel = originaHighest; } } } catch (Exception e) { Common.DebugException(sim, e); } IncStat("Core Failure"); return(false); }
// 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); }
protected bool ProgressJobBased(ActiveCareer occupation) { List <InteractionDefinition> interactions = new List <InteractionDefinition>(); Job job = GetExistingJob(occupation); if (job != null) { InteractionDefinition definition; GameObject target; job.GetInteractionDefinitionAndTargetToGoToWork(out definition, out target); interactions.Add(definition); } if (!Test(Sim.CreatedSim, interactions)) { return(false); } if (occupation.HasJobAtLot(Sim.CreatedSim.LotCurrent)) { IncStat("Already On Site"); return(false); } if (job == null) { List <JobId> choices = new List <JobId>(); foreach (JobId id in occupation.GetCurrentLevelStaticData().RandomCustomerJobIds) { if (IsValidJobId(id)) { choices.Add(id); } } if (choices.Count == 0) { IncStat("No Choices"); return(false); } JobId jobId = RandomUtil.GetRandomObjectFromList(choices); JobCreationSpec jobCreationSpec; if (!occupation.TryCreateJobCreationSpec(jobId, out jobCreationSpec)) { IncStat("Creation Fail"); return(false); } if (!GetValue <AllowGhostHunterOnActiveOptionV2, bool>()) { if ((Household.ActiveHousehold == null) || (jobCreationSpec.mLot.CanSimTreatAsHome(Sims3.Gameplay.Actors.Sim.ActiveActor))) { IncStat("Active Lot Fail"); return(false); } } jobCreationSpec.mStartTime = SimClock.CurrentTime(); if (!TryCreateJobForCustomer(occupation, jobCreationSpec, occupation.GetCurrentLevelStaticData(), out job)) { IncStat("CreateJob Fail"); return(false); } if (job == null) { IncStat("No Job"); return(false); } job.SetTimeoutAlarm((float)job.Specification.mHoursAvailable); } job.MapTagEnabled = true; job.SetCurrentJobLocation(); if (!Situations.PushInteraction(this, Sim, Managers.Manager.AllowCheck.None, occupation.CreateGoToActiveCareerJobInteraction(job))) { IncStat("Push Fail"); return(false); } IncStat("Pushed"); return(true); }