protected override bool PrivateUpdate(ScenarioFrame frame) { if (Sim.AssignedRole != null) { if (ManagerCareer.IsRegisterInstalled()) { if ((Sim.LotHome == null) && (Sim.Occupation == null)) { IncStat("Registered Retiremenet"); GetData <CareerSimData>(Sim).Retire(); } } return(true); } else if (SimTypes.IsSpecial(Sim)) { IncStat("Special"); return(false); } bool enroll = false; if (GameUtils.IsUniversityWorld()) { enroll = true; } else if (Careers.TestCareer(this, Sim, OccupationNames.AcademicCareer)) { if (Careers.AllowHomeworldUniversity(Sim)) { AcademicDegreeManager degreeManager = Sim.CareerManager.DegreeManager; if (degreeManager != null) { if (!degreeManager.HasCompletedAnyDegree()) { enroll = true; } } } } if (!mForce) { if (GetValue <ManualCareerOption, bool>(Sim)) { IncStat("Manual"); return(false); } } List <OccupationNames> careers = new List <OccupationNames>(); bool dream = Careers.GetPotentialCareers(this, Sim, careers, mCheckQuit); bool partTime = false; if (Sim.Teen) { bool scoreSuccess = true; if (mForce) { if (AddScoring("FindJob", Sim) < 0) { scoreSuccess = false; } } else { if (AddScoring("ChanceFindJob", Sim) < 0) { scoreSuccess = false; } } if ((!scoreSuccess) && (!GetValue <ForceTeensOption, bool>())) { IncStat("Score Fail"); return(false); } partTime = true; } if (partTime) { List <OccupationNames> partTimeList = new List <OccupationNames>(); AddStat(Sim.Age + ": Part-time Choices", careers.Count); foreach (OccupationNames career in careers) { Career staticCareer = CareerManager.GetStaticCareer(career); if (staticCareer == null) { continue; } if (staticCareer is School) { continue; } CareerLocation location = Career.FindClosestCareerLocation(Sim, staticCareer.Guid); if (location == null) { continue; } if (!AllowStandalone(location)) { continue; } foreach (CareerLocation loc in location.Owner.CareerLocations.Values) { Career possible = loc.Career; if (!possible.IsPartTime) { continue; } if (ManagerCareer.IsPlaceholderCareer(possible)) { continue; } partTimeList.Add(possible.Guid); } } careers = partTimeList; AddStat(Sim.Age + ": Part-time Final", careers.Count); } else { AddStat(Sim.Age + ": Full-time Final", careers.Count); } if ((!mForce) && (!dream) && (Sim.Occupation != null) && (!(Sim.Occupation is Retired))) { IncStat("Non-Dream Employed"); return(false); } if (enroll) { AcademicDegreeNames degreeName = AcademicDegreeNames.Undefined; foreach (DreamJob job in ManagerCareer.GetDreamJob(Sim)) { if (job == null) { continue; } foreach (AcademicDegreeStaticData data in AcademicDegreeManager.sDictionary.Values) { if (data.AssociatedOccupations.Contains(job.mCareer)) { degreeName = data.AcademicDegreeName; break; } } } if (degreeName == AcademicDegreeNames.Undefined) { degreeName = AcademicDegreeManager.ChooseWeightRandomSuitableDegree(Sim); } if (!Careers.IsDegreeAllowed(Manager, Sim, degreeName)) { degreeName = Careers.GetAllowedDegree(Manager, Sim); } if (degreeName != AcademicDegreeNames.Undefined) { if (AcademicCareer.GlobalTermLength == AcademicCareer.TermLength.kInvalid) { AcademicCareer.GlobalTermLength = AcademicCareer.TermLength.kOneWeek; } AcademicCareer.EnrollSimInAcademicCareer(Sim, degreeName, AcademicCareer.ChooseRandomCoursesPerDay()); return(true); } } bool promptForJob = GetValue <ChooseCareerOption, bool>(); if ((promptForJob) && (!Careers.MatchesAlertLevel(Sim))) { promptForJob = false; } if (careers.Count > 0) { if ((Sim.Occupation != null) && (careers.Contains(Sim.Occupation.Guid))) { IncStat("Already Has Choice"); return(false); } if (!promptForJob) { if (AskForJob(Sim, RandomUtil.GetRandomObjectFromList(careers))) { return(true); } } } if ((!mForce) && (Sim.Occupation != null)) { IncStat("Already Employed"); return(false); } List <Occupation> allCareers = null; if (careers.Count > 0) { allCareers = new List <Occupation>(); foreach (Career career in CareerManager.CareerList) { if (careers.Contains(career.Guid)) { allCareers.Add(career); } } } if ((allCareers == null) || (allCareers.Count == 0)) { if (Sim.LifetimeWish == (uint)LifetimeWant.JackOfAllTrades) { allCareers = GetChoices(true); } } if ((allCareers == null) || (allCareers.Count == 0)) { allCareers = GetChoices(false); } if (allCareers.Count > 0) { AddStat("Random Choices", allCareers.Count); if ((promptForJob) && (AcceptCancelDialog.Show(ManagerSim.GetPersonalInfo(Sim, Common.Localize("ChooseCareer:Prompt", Sim.IsFemale))))) { List <JobItem> jobs = new List <JobItem>(); foreach (Occupation career in GetChoices(false)) { jobs.Add(new JobItem(career, allCareers.Contains(career))); } bool okayed; JobItem choice = new CommonSelection <JobItem>(Common.Localize("ChooseCareer:Header", Sim.IsFemale), Sim.FullName, jobs, new JobPreferenceColumn()).SelectSingle(out okayed); if (!okayed) { return(false); } if (choice != null) { allCareers.Clear(); allCareers.Add(choice.Value); SetValue <ManualCareerOption, bool>(Sim, true); } } while (allCareers.Count > 0) { Occupation choice = RandomUtil.GetRandomObjectFromList(allCareers); allCareers.Remove(choice); if (choice != null) { if (AskForJob(Sim, choice)) { return(true); } } } IncStat("Ask Failure"); return(false); } else { if (promptForJob) { Common.Notify(Common.Localize("ChooseCareer:PromptFailure", Sim.IsFemale, new object[] { Sim })); } IncStat("No Applicable"); return(false); } }
protected bool PrivatePerform() { if (!Sims.Instantiate(Sim, null, false)) { return(false); } if (Sim.CreatedSim == null) { return(false); } bool DnP = (Sim.CreatedSim.DreamsAndPromisesManager != null); bool success = false; if (!DnP) { bool hadWish = Sim.HasLifetimeWish; try { DreamsAndPromisesManager.CreateAndIntitForSim(Sim.CreatedSim); } catch (Exception e) { Common.DebugException(Sim, e); } if (!hadWish) { Sim.LifetimeWish = ChooseRandomLifetimeWish(Sim.CreatedSim.DreamsAndPromisesManager); if (Sim.HasLifetimeWish) { Sim.CreatedSim.DreamsAndPromisesManager.TryAddLifetimeWish(); } success = true; } } if ((Sims.MatchesAlertLevel(Sim)) && (GetValue <PromptOption, bool>())) { if ((AcceptCancelDialog.Show(ManagerSim.GetPersonalInfo(Sim, Common.Localize("ChooseLifetimeWish:Prompt", Sim.IsFemale)))) && (LifetimeWants.SetLifetimeWant(Sim))) { success = true; } } if (!success) { Sim.LifetimeWish = ChooseRandomLifetimeWish(Sim.CreatedSim.DreamsAndPromisesManager); if (Sim.HasLifetimeWish) { Sim.CreatedSim.DreamsAndPromisesManager.TryAddLifetimeWish(); } } IncStat("Set"); if (!DnP) { Sim.CreatedSim.NullDnPManager(); } return(true); }
protected override List <CareerLocation> GetPotentials() { List <OccupationNames> careers = new List <OccupationNames>(); bool dream = Careers.GetPotentialCareers(this, Sim, careers, false); List <CareerLocation> dreamSchools = new List <CareerLocation>(); foreach (OccupationNames career in careers) { Career staticJob = CareerManager.GetStaticCareer(career); if (staticJob == null) { continue; } CareerLocation jobLocation = FindClosestCareerLocation(Sim, staticJob.Guid); if (jobLocation == null) { continue; } if (jobLocation.Owner == null) { continue; } if (jobLocation.Owner.CareerLocations == null) { continue; } foreach (CareerLocation schoolLoc in jobLocation.Owner.CareerLocations.Values) { School staticSchool = schoolLoc.Career as School; if (staticSchool == null) { continue; } if (HasValue <DisallowCareerOption, OccupationNames>(Sim, staticSchool.Guid)) { continue; } if (HasValue <PublicAssignSchoolScenario.ConsiderPublicOption, OccupationNames>(staticSchool.Guid)) { continue; } // Disallow home schooling at this point if ((staticSchool.Level1 == null) || (staticSchool.Level1.DayLength == 0)) { continue; } if (staticSchool is SchoolHigh) { if (career == OccupationNames.SchoolHigh) { continue; } if (!Sim.Teen) { continue; } } else if (staticSchool is SchoolElementary) { if (career == OccupationNames.SchoolElementary) { continue; } if (!Sim.Child) { continue; } } else { if (!staticJob.CareerAgeTest(Sim)) { continue; } } CareerLocation location = FindClosestCareerLocation(Sim, staticSchool.Guid); if (location == null) { continue; } dreamSchools.Add(location); } } AddStat("Dream Schools", dreamSchools.Count); if ((GetValue <PromptToAssignSchoolOption, bool>()) && (Careers.MatchesAlertLevel(Sim))) { List <FindJobScenario.JobItem> items = new List <FindJobScenario.JobItem>(); bool found = false; foreach (Career career in CareerManager.CareerList) { if (career is SchoolHigh) { if (!Sim.Teen) { continue; } if (career.Guid != OccupationNames.SchoolHigh) { found = true; } } else if (career is SchoolElementary) { if (!Sim.Child) { continue; } if (career.Guid != OccupationNames.SchoolElementary) { found = true; } } else if (career is School) { if (!career.CareerAgeTest(Sim)) { continue; } if ((career.Level1 != null) && (career.Level1.DayLength != 0)) { found = true; } } else { continue; } if (HasValue <DisallowCareerOption, OccupationNames>(Sim, career.Guid)) { continue; } if (HasValue <PublicAssignSchoolScenario.ConsiderPublicOption, OccupationNames>(career.Guid)) { continue; } CareerLocation location = FindClosestCareerLocation(Sim, career.Guid); if (location == null) { continue; } items.Add(new FindJobScenario.JobItem(location.Career, dreamSchools.Contains(location))); } FindJobScenario.JobItem choice = null; if ((items.Count > 1) && (found)) { if (AcceptCancelDialog.Show(ManagerSim.GetPersonalInfo(Sim, Common.Localize("RichAssignSchool:Prompt", Sim.IsFemale)))) { choice = new CommonSelection <FindJobScenario.JobItem>(Common.Localize("ChooseCareer:Header", Sim.IsFemale), Sim.FullName, items, new FindJobScenario.JobPreferenceColumn()).SelectSingle(); } } else if (items.Count == 1) { Career career = items[0].Value as Career; // Do not auto-enroll sims in home-schooling if ((career.Level1 != null) && (career.Level1.DayLength != 0)) { choice = items[0]; } } if (choice != null) { SetValue <ManualSchoolOption, bool>(Sim, true); dreamSchools.Clear(); CareerLocation location = FindClosestCareerLocation(Sim, choice.Value.Guid); if (location != null) { dreamSchools.Add(location); } } } if (dreamSchools.Count == 0) { IncStat("Random"); foreach (Career career in CareerManager.CareerList) { if (career is SchoolHigh) { if (!Sim.Teen) { continue; } } else if (career is SchoolElementary) { if (!Sim.Child) { continue; } } else { continue; } if (HasValue <DisallowCareerOption, OccupationNames>(Sim, career.Guid)) { continue; } if (HasValue <PublicAssignSchoolScenario.ConsiderPublicOption, OccupationNames>(career.Guid)) { continue; } CareerLocation location = FindClosestCareerLocation(Sim, career.Guid); if (location == null) { continue; } if (location.Owner == null) { continue; } dreamSchools.Add(location); } /* * if (dreamSchools.Count < 4) * { * IncStat("Too Few"); * * dreamSchools.Clear(); * }*/ } return(dreamSchools); }
protected override bool PrivateUpdate(ScenarioFrame frame) { LifetimeWant lifetimeWant = (LifetimeWant)Sim.LifetimeWish; bool prompt = (GetValue <PromptOption, bool>()) && (Careers.MatchesAlertLevel(Sim)); DreamNodeInstance instance = null; DreamsAndPromisesManager.sMajorWishes.TryGetValue(Sim.LifetimeWish, out instance); if (instance == null) { if (!prompt) { IncStat("No LTW"); return(false); } } else if (instance.InputSubject == null) { IncStat("No InputSubject"); return(false); } Career career = Sim.Occupation as Career; CareerLevel prior = career.CurLevel.LastLevel; if (prior == null) { IncStat("No Prior"); return(false); } if (prior.NextLevels.Count != 2) { IncStat("Not Branch"); return(false); } CareerLevel newLevel = null; if (prompt) { bool flag = TwoButtonDialog.Show( ManagerSim.GetPersonalInfo(Sim, Common.LocalizeEAString(Sim.IsFemale, career.SharedData.Text_BranchOffer, new object[] { Sim })), Common.LocalizeEAString(Sim.IsFemale, career.SharedData.Text_Branch1, new object[0]), Common.LocalizeEAString(Sim.IsFemale, career.SharedData.Text_Branch2, new object[0]) ); if (flag) { if (prior.NextLevels[0] == career.CurLevel) { return(false); } newLevel = prior.NextLevels[0]; } else { if (prior.NextLevels[1] == career.CurLevel) { return(false); } newLevel = prior.NextLevels[1]; } } else if (instance.InputSubject != null) { if (instance.InputSubject.mType != DreamNodePrimitive.InputSubjectType.Career) { IncStat("Not Career LTW"); return(false); } switch (career.Guid) { case OccupationNames.Music: if (lifetimeWant == LifetimeWant.RockStar) { if (career.CurLevelBranchName == "ElectricRock") { IncStat("ElectricRock"); return(false); } } else { if (career.CurLevelBranchName != "ElectricRock") { IncStat("Not ElectricRock"); return(false); } } break; case OccupationNames.Criminal: if (lifetimeWant == LifetimeWant.TheEmperorOfEvil) { if (career.CurLevelBranchName == "Evil") { IncStat("Evil"); return(false); } } else { if (career.CurLevelBranchName != "Evil") { IncStat("Not Evil"); return(false); } } break; case OccupationNames.LawEnforcement: if (lifetimeWant == LifetimeWant.ForensicSpecialistDynamicDNAProfiler) { if (career.CurLevelBranchName == "ForensicAnalyst") { IncStat("Forensic"); return(false); } } else { if (career.CurLevelBranchName != "ForensicAnalyst") { IncStat("Not Forensic"); return(false); } } break; case OccupationNames.Film: if (lifetimeWant == LifetimeWant.FileActor) { if (career.CurLevelBranchName == "Acting") { IncStat("Acting"); return(false); } } else { if (career.CurLevelBranchName != "Acting") { IncStat("Not Acting"); return(false); } } break; default: return(false); } foreach (CareerLevel level in prior.NextLevels) { if (career.CurLevel == level) { continue; } newLevel = level; break; } } if (newLevel == null) { return(false); } CareerLevel curLevel = career.CurLevel.LastLevel; career.GivePromotionRewardObjectsIfShould(newLevel); career.SetLevel(newLevel); try { PromotedScenario.AddSuppressed(Sim); career.OnPromoteDemote(curLevel, newLevel); } finally { PromotedScenario.RemoveSuppressed(Sim); } if (Sim.CreatedSim != null) { career.SetTones(Sim.CreatedSim.CurrentInteraction); } return(true); }