protected override bool Allow(SimDescription me, IMiniSimDescription actor) { if (me.Occupation == null) { return(false); } if (me.Occupation.Guid != mCareer.Guid) { return(false); } Career rabbitHoleCareer = mCareer as Career; if (rabbitHoleCareer != null) { CareerLocation testLoc = Career.FindClosestCareerLocation(me, mCareer.Guid); if (testLoc == null) { return(false); } } return(true); }
public void OnWorldLoadFinished() { try { Managers.ManagerCareer.RetiredLocation = null; Career staticCareer = CareerManager.GetStaticCareer(CareerGuid); if (staticCareer == null) { return; } foreach (RabbitHole hole in RabbitHole.GetRabbitHolesOfType(RabbitHoleType.CityHall)) { CareerLocation location = new CareerLocation(hole, staticCareer); if (!hole.CareerLocations.ContainsKey((ulong)staticCareer.Guid)) { hole.CareerLocations.Add((ulong)staticCareer.Guid, location); if (location.Career != null) { Managers.ManagerCareer.RetiredLocation = location; } } } } catch (Exception exception) { Common.Exception("Retired WorldLoadFinished", exception); } }
public override void SetAttributesForNewJob(CareerLocation location, ulong lotId, bool bRequestFromCharacterImport) { base.SetAttributesForNewJob(location, lotId, bRequestFromCharacterImport); RemoveStipendAlarm(); SetupStipendAlarm(); }
public override bool InRabbitHole() { try { Definition definition = InteractionDefinition as Definition; CareerLocation careerLocation = definition.mLocation; if (careerLocation == null) { return(false); } TryDisablingCameraFollow(Actor); return(SchoolBooter.Enroll(Actor, definition.mName.Second, careerLocation)); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
protected bool AllowStandalone(CareerLocation location) { if (GetValue <AllowStandAloneOption, bool>()) { return(true); } RabbitHole owner = location.Owner; if ((owner == null) || (owner.CareerLocations == null)) { return(true); } foreach (CareerLocation loc in owner.CareerLocations.Values) { if (loc.Career == null) { continue; } if (!loc.Career.IsPartTime) { return(true); } } return(false); }
protected bool AcquireOccupation(CareerManager ths, AcquireOccupationParameters occupationParameters) { Occupation occupation; Sim createdSim = ths.mSimDescription.CreatedSim; CareerLocation location = occupationParameters.Location; OccupationNames newJobGuid = occupationParameters.TargetJob; if ((ths.mJob != null) && (location != null) && (ths.mJob.Guid == location.Career.Guid) && (ths.mJob.CareerLoc != location)) { Career mJob = ths.mJob as Career; if ((mJob != null) && (mJob.TransferBetweenCareerLocations(location, false))) { IncStat("Transferred"); return(true); } } if (!ths.TryGetNewCareer(newJobGuid, out occupation)) { IncStat("TryGetNewCareer Fail"); return(false); } if (ths.mJob != null) { if (createdSim != null) { EventTracker.SendEvent(new TransferCareerEvent(createdSim, ths.mJob, occupation)); } ths.mJob.LeaveJob(false, Career.LeaveJobReason.kTransfered); } EventTracker.SendEvent(EventTypeId.kCareerNewJob, createdSim); occupation.OwnerDescription = ths.mSimDescription; occupation.mDateHired = SimClock.CurrentTime(); occupation.mAgeWhenJobFirstStarted = ths.mSimDescription.Age; occupation.SetAttributesForNewJob(location, occupationParameters.LotId, occupationParameters.CharacterImportRequest); EventTracker.SendEvent(new CareerEvent(EventTypeId.kEventCareerHired, occupation)); EventTracker.SendEvent(new CareerEvent(EventTypeId.kEventCareerChanged, occupation)); EventTracker.SendEvent(new CareerEvent(EventTypeId.kCareerDataChanged, occupation)); occupation.RefreshMapTagForOccupation(); ths.UpdateCareerUI(); if ((createdSim != null) && createdSim.IsActiveSim) { HudController.SetInfoState(InfoState.Career); } IncStat("Job Acquired " + occupation.Guid); return(true); }
protected static void ChooseSchool(Sim sim) { List<ObjectPicker.HeaderInfo> headers = new List<ObjectPicker.HeaderInfo>(); headers.Add(new ObjectPicker.HeaderInfo("NRaasSchooling:OptionColumn", "NRaasSchooling:OptionColumnTooltip", 230)); List<ObjectPicker.RowInfo> rowInfo = new List<ObjectPicker.RowInfo>(); foreach (Career career in CareerManager.CareerList) { if (career is SchoolElementary) { if (!sim.SimDescription.Child) continue; } else if (career is SchoolHigh) { if (!sim.SimDescription.Teen) continue; } else if (career is School) { if ((!sim.SimDescription.Child) && (!sim.SimDescription.Teen)) continue; } else { continue; } GreyedOutTooltipCallback greyedOutTooltipCallback = null; if (!career.CanAcceptCareer(sim.ObjectId, ref greyedOutTooltipCallback)) continue; CareerLocation location = Career.FindClosestCareerLocation(sim, career.Guid); if (location == null) continue; ObjectPicker.RowInfo item = new ObjectPicker.RowInfo(location, new List<ObjectPicker.ColumnInfo>()); item.ColumnInfo.Add(new ObjectPicker.TextColumn(career.Name)); rowInfo.Add(item); } List<ObjectPicker.TabInfo> tabInfo = new List<ObjectPicker.TabInfo>(); tabInfo.Add(new ObjectPicker.TabInfo("shop_all_r2", Common.LocalizeEAString("Ui/Caption/ObjectPicker:All"), rowInfo)); string buttonTrue = Common.LocalizeEAString("Ui/Caption/Global:Accept"); string buttonFalse = Common.LocalizeEAString("Ui/Caption/ObjectPicker:Cancel"); List<ObjectPicker.RowInfo> list = ObjectPickerDialog.Show(true, ModalDialog.PauseMode.PauseSimulator, Common.LocalizeEAString("NRaasSchooling:Title"), buttonTrue, buttonFalse, tabInfo, headers, 1, new Vector2(-1f, -1f), true); if ((list == null) || (list.Count == 0)) return; CareerLocation sel = list[0].Item as CareerLocation; if (sel == null) return; SchoolBooter.Enroll(sim, null, sel); }
protected CareerLocation FindClosestCareerLocation(SimDescription s, OccupationNames careerName) { if (s.Household == null) { IncStat("No Household"); return(null); } Career staticCareer = CareerManager.GetStaticCareer(careerName); if (staticCareer == null) { IncStat("Career Fail"); return(null); } Lot lotHome = s.Household.LotHome; if (lotHome == null) { if (staticCareer.Locations.Count > 0x0) { return(RandomUtil.GetRandomObjectFromList <CareerLocation>(staticCareer.Locations)); } else { IncStat("No Lot Home"); return(null); } } CareerLocation location = null; float bestDistance = float.MaxValue; float distanceToObject = 0f; foreach (CareerLocation location2 in staticCareer.Locations) { if (!GetLotOptions(location2.Owner.LotCurrent).AllowCastes(this, s)) { continue; } distanceToObject = lotHome.GetDistanceToObject(location2.Owner.RabbitHoleProxy); if (distanceToObject < bestDistance) { location = location2; bestDistance = distanceToObject; } } return(location); }
protected override List <CareerLocation> GetPotentials() { List <CareerLocation> schools = new List <CareerLocation>(); 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 <ConsiderPublicOption, OccupationNames>(career.Guid)) { continue; } IncStat("Potential: " + career.Name); CareerLocation location = FindClosestCareerLocation(Sim, career.Guid); if (location == null) { continue; } if (location.Owner == null) { continue; } schools.Add(location); } return(schools); }
protected static bool UpdateCareer(Career career, CareerLocation location) { if (location.Career == null) { return(false); } if (location.Career.Guid != career.Guid) { return(false); } career.CareerLoc = location; if (!location.Workers.Contains(career.OwnerDescription)) { location.Workers.Add(career.OwnerDescription); } return(true); }
public void OnWorldLoadFinished() { foreach (CareerBooterElement element in sCareers) { Career staticCareer = CareerManager.GetStaticCareer(element.mCareer); if (staticCareer == null) { continue; } string lotDesignator = null; ILotDesignator lotDesignatorClass = staticCareer as ILotDesignator; if (lotDesignatorClass != null) { lotDesignator = lotDesignatorClass.LotDesignator; } foreach (RabbitHole hole in RabbitHole.GetRabbitHolesOfType(element.mType)) { if (!string.IsNullOrEmpty(lotDesignator)) { if (hole.LotCurrent == null) { continue; } if (!hole.LotCurrent.Name.Contains(lotDesignator)) { continue; } } CareerLocation location = new CareerLocation(hole, staticCareer); if (!hole.CareerLocations.ContainsKey((ulong)staticCareer.Guid)) { hole.CareerLocations.Add((ulong)staticCareer.Guid, location); } } } }
protected override bool PrivateSatisfies(ManagerCareer manager, SimDescription sim, Lot newLot, bool inspecting) { if (inspecting) { return(true); } if (sim.Occupation is Retired) { return(false); } CareerLocation location = Career.FindClosestCareerLocation(sim, mCareer); if (location == null) { return(false); } return(true); }
protected override List <CareerLocation> GetPotentials() { List <CareerLocation> schools = new List <CareerLocation>(); foreach (Career career in CareerManager.CareerList) { if (!(career is School)) { continue; } if (career.Level1 == null) { continue; } if (career.Level1.DayLength != 0) { continue; } if (!career.CareerAgeTest(Sim)) { continue; } CareerLocation location = FindClosestCareerLocation(Sim, career.Guid); if (location == null) { continue; } if (location.Owner == null) { continue; } } return(schools); }
public static bool Enroll(Sim sim, string unemployedName, CareerLocation location) { Occupation job = sim.Occupation; Occupation retiredJob = sim.CareerManager.RetiredCareer; sim.CareerManager.mRetiredCareer = null; try { if (location.Career is School) { sim.CareerManager.mJob = null; } if (!sim.AcquireOccupation(new AcquireOccupationParameters(location, true, false))) { return(false); } NRaas.Gameplay.Careers.Unemployed unemployed = sim.Occupation as NRaas.Gameplay.Careers.Unemployed; if (unemployed != null) { unemployed.UpdateName(unemployedName); } return(true); } finally { if (sim.CareerManager.mJob == null) { sim.CareerManager.mJob = job; } sim.CareerManager.mRetiredCareer = retiredJob; sim.CareerManager.UpdateCareerUI(); } }
public CareerItem(Occupation career, CareerLocation location) { mCareer = career; mLocation = location; }
public static void OnAccepted(Sim actor, Sim target, string interaction, ActiveTopic topic, InteractionInstance i) { try { OccupationNames careerName = actor.Occupation.Guid; bool success = false; if (target.Occupation == null) { Career career = CareerManager.GetStaticCareer(careerName); if (career == null) { return; } string branch = actor.Occupation.CurLevelBranchName; CareerLocation location = Career.FindClosestCareerLocation(target.SimDescription, careerName); if (location == null) { return; } if (target.SimDescription.AcquireOccupation(new AcquireOccupationParameters(location, false, false))) { success = true; } } else { int level = 1; if (target.Occupation.Guid == actor.Occupation.Guid) { Career actorCareer = actor.Occupation as Career; CareerLevel curLevel = actorCareer.CurLevel; while (curLevel.LastLevel != null) { curLevel = curLevel.LastLevel; if (curLevel.NextLevels.Count > 1) { break; } } if (curLevel != null) { level = curLevel.Level; } } Career staticCareer = CareerManager.GetStaticCareer(careerName); if ((target.Occupation != null) && (careerName != OccupationNames.Undefined) && (actor.Occupation.CurLevelBranchName != null) && (staticCareer != null)) { target.Occupation.LeaveJob(Career.LeaveJobReason.kTransfered); CareerLocation location = Career.FindClosestCareerLocation(target.SimDescription, staticCareer.Guid); if (location != null) { CareerLevel careerLevel = null; if (actor.Occupation.CurLevelBranchName != null) { Dictionary <int, CareerLevel> dictionary = null; if (staticCareer.CareerLevels.TryGetValue(actor.Occupation.CurLevelBranchName, out dictionary)) { dictionary.TryGetValue(level, out careerLevel); } } if (careerLevel == null) { foreach (Dictionary <int, CareerLevel> dictionary2 in staticCareer.CareerLevels.Values) { if (dictionary2.TryGetValue(level, out careerLevel)) { break; } } } if (careerLevel != null) { Occupation staticOccupation = CareerManager.GetStaticOccupation(actor.Occupation.Guid); if (staticOccupation != null) { staticOccupation.DoTransferOfOccupation(target.SimDescription, careerLevel.BranchName, careerLevel.Level); success = true; } } } } } if (success) { OmniCareer job = actor.Occupation as OmniCareer; if (job != null) { job.AddToRecruits(); } } } catch (Exception e) { Common.Exception(actor, target, e); } }
public void OnWorldLoadFinished() { foreach (CareerBooterElement element in sCareers) { Career staticCareer = CareerManager.GetStaticCareer(element.mCareer); if (staticCareer == null) continue; string lotDesignator = null; ILotDesignator lotDesignatorClass = staticCareer as ILotDesignator; if (lotDesignatorClass != null) { lotDesignator = lotDesignatorClass.LotDesignator; } foreach (RabbitHole hole in RabbitHole.GetRabbitHolesOfType(element.mType)) { if (!string.IsNullOrEmpty(lotDesignator)) { if (hole.LotCurrent == null) continue; if (!hole.LotCurrent.Name.Contains(lotDesignator)) continue; } CareerLocation location = new CareerLocation(hole, staticCareer); if (!hole.CareerLocations.ContainsKey((ulong)staticCareer.Guid)) { hole.CareerLocations.Add((ulong)staticCareer.Guid, location); } } } }
protected static bool AcquireOccupation(CareerManager ths, AcquireOccupationParameters occupationParameters, bool prompt) { CareerLocation location = occupationParameters.Location; OccupationNames newJobGuid = occupationParameters.TargetJob; if ((ths.mJob != null) && (location != null) && (ths.mJob.Guid == location.Career.Guid) && (ths.mJob.CareerLoc != location)) { Career mJob = ths.mJob as Career; return((mJob != null) && mJob.TransferBetweenCareerLocations(location, false)); } Occupation occupation = null; if (!ths.TryGetNewCareer(newJobGuid, out occupation)) { return(false); } if (occupation is Career) { if (location == null) { return(false); } } Sim createdSim = ths.mSimDescription.CreatedSim; if (ths.mJob != null) { if (prompt) { string newJobName = string.Empty; if (!occupation.TryDisplayingGetHiredUi(location, ref occupationParameters, out newJobName)) { return(false); } if (!Occupation.ShowYesNoCareerOptionDialog(Common.LocalizeEAString(ths.mSimDescription.IsFemale, "Gameplay/Careers/Career:ConfirmLeavingOldCareer", new object[] { ths.mSimDescription, occupation.CareerName, ths.mJob.CareerName }))) { return(false); } } if (createdSim != null) { EventTracker.SendEvent(new TransferCareerEvent(createdSim, ths.mJob, occupation)); } ths.mJob.LeaveJob(false, Career.LeaveJobReason.kTransfered); } if (newJobGuid == OccupationNames.AcademicCareer) { AcademicCareer.EnrollSimInAcademicCareer(ths.mSimDescription, ths.DegreeManager.EnrollmentAcademicDegreeName, ths.DegreeManager.EnrollmentCouseLoad); } else { EventTracker.SendEvent(EventTypeId.kCareerNewJob, createdSim); occupation.OwnerDescription = ths.mSimDescription; occupation.mDateHired = SimClock.CurrentTime(); occupation.mAgeWhenJobFirstStarted = ths.mSimDescription.Age; occupation.SetAttributesForNewJob(location, occupationParameters.LotId, occupationParameters.CharacterImportRequest); EventTracker.SendEvent(new CareerEvent(EventTypeId.kEventCareerHired, occupation)); EventTracker.SendEvent(new CareerEvent(EventTypeId.kEventCareerChanged, occupation)); EventTracker.SendEvent(new CareerEvent(EventTypeId.kCareerDataChanged, occupation)); } occupation.RefreshMapTagForOccupation(); ths.UpdateCareerUI(); if ((createdSim != null) && createdSim.IsActiveSim) { HudController.SetInfoState(InfoState.Career); } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { List <CareerLocation> schools = GetPotentials(); if (schools.Count == 0) { IncStat("No Choice"); return(false); } else { if ((Sim.CareerManager.School != null) && (schools.Contains(Sim.CareerManager.School.CareerLoc))) { IncStat("Already Has"); return(false); } CareerLocation location = RandomUtil.GetRandomObjectFromList(schools); if ((Sim.CareerManager.School != null) && (location == Sim.CareerManager.School.CareerLoc)) { IncStat("Same"); return(false); } else { Occupation job = Sim.Occupation; Occupation retiredJob = Sim.CareerManager.mRetiredCareer; Sim.CareerManager.mJob = null; Sim.CareerManager.mRetiredCareer = null; try { if (Sim.AcquireOccupation(new AcquireOccupationParameters(location, false, false))) { School school = Sim.CareerManager.School; if (school != null) { school.mWhenCurLevelStarted = SimClock.Subtract(school.mWhenCurLevelStarted, TimeUnit.Days, 1); } return(true); } else { IncStat("Core Failure"); return(false); } } catch (Exception e) { Common.DebugException(Sim, e); IncStat("Exception Failure"); return(false); } finally { Sim.CareerManager.mJob = job; Sim.CareerManager.mRetiredCareer = retiredJob; } } } }
public static void FixCareer(Occupation job, bool allowDrop) { try{ if (job == null) { return; } if (job.Coworkers != null) { for (int i = job.Coworkers.Count - 1; i >= 0; i--) { SimDescription coworker = job.Coworkers[i]; if ((!IsValidCoworker(coworker, job is School)) || (coworker == job.OwnerDescription)) { job.Coworkers.RemoveAt(i); } } } if ((allowDrop) && (job is Career)) { bool replace = (false); if (job.CareerLoc == null) { replace = (true); } else { RabbitHole hole = job.CareerLoc.Owner; if (hole == null) { replace = (true); } else { RabbitHole proxy = hole.RabbitHoleProxy; if (proxy == null) { replace = (true); } else { if ((proxy.EnterSlots == null) || (proxy.EnterSlots.Count == 0) || (proxy.ExitSlots == null) || (proxy.ExitSlots.Count == 0)) { replace = (true); } } } } if (replace) { SimDescription me = job.OwnerDescription; Occupation retiredJob = me.CareerManager.mRetiredCareer; try{ CareerLocation location = Sims3.Gameplay.Careers.Career.FindClosestCareerLocation(me, job.Guid); if (location != null) { if (job.CareerLoc != null) { job.CareerLoc.Workers.Remove(me); } job.CareerLoc = location; location.Workers.Add(me); } else { job.LeaveJobNow(Career.LeaveJobReason.kJobBecameInvalid); } }finally{ me.CareerManager.mRetiredCareer = retiredJob; } } } }catch (Exception exception) { // Get stack trace for the exception. with source file information var st = new StackTrace(exception, true); // Get the top stack frame var frame = st.GetFrame(0); // Get the line number from the stack frame var line = frame.GetFileLineNumber(); Alive.WriteLog(exception.Message + "\n\n" + exception.StackTrace + "\n\n" + exception.Source + "\n\n" + line); }finally{ } }
public void OnWorldLoadFinished() { try { Managers.ManagerCareer.RetiredLocation = null; Career staticCareer = CareerManager.GetStaticCareer(CareerGuid); if (staticCareer == null) return; foreach (RabbitHole hole in RabbitHole.GetRabbitHolesOfType(RabbitHoleType.CityHall)) { CareerLocation location = new CareerLocation(hole, staticCareer); if (!hole.CareerLocations.ContainsKey((ulong)staticCareer.Guid)) { hole.CareerLocations.Add((ulong)staticCareer.Guid, location); if (location.Career != null) { Managers.ManagerCareer.RetiredLocation = location; } } } } catch (Exception exception) { Common.Exception("Retired WorldLoadFinished", exception); } }
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 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); }
public Definition(string s, CareerLocation location) { mName = new Pair <string, string>(s, s); mLocation = location; }
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 static bool UpdateCareer(Career career, CareerLocation location) { if (location.Career == null) return false; if (location.Career.Guid != career.Guid) return false; career.CareerLoc = location; if (!location.Workers.Contains(career.OwnerDescription)) { location.Workers.Add(career.OwnerDescription); } return true; }
public Definition(Pair <string, string> s, CareerLocation location) { mName = s; mLocation = location; }
protected List <Occupation> GetChoices(bool checkQuit) { List <Occupation> allCareers = new List <Occupation>(); foreach (Occupation occupation in CareerManager.OccupationList) { if (occupation is School) { continue; } if (occupation.IsAcademicCareer) { continue; } if (!Careers.TestCareer(this, Sim, occupation.Guid)) { continue; } Career career = occupation as Career; if (career != null) { if (!career.CareerAgeTest(Sim)) { continue; } if (career.IsPartTime != Sim.Teen) { continue; } if (ManagerCareer.IsPlaceholderCareer(career)) { continue; } if (career.Level1.PayPerHourBase <= 0) { continue; } CareerLocation location = Career.FindClosestCareerLocation(Sim, career.Guid); if (location == null) { continue; } if (!AllowStandalone(location)) { continue; } } if (checkQuit) { Occupation oldCareer; if (Sim.CareerManager.QuitCareers.TryGetValue(occupation.Guid, out oldCareer)) { if (oldCareer.CareerLevel >= 5) { continue; } } } allCareers.Add(occupation); } return(allCareers); }
public static void FixCareer(Occupation job, bool allowDrop, Logger log) { if (job == null) { return; } if (job.Coworkers != null) { for (int i = job.Coworkers.Count - 1; i >= 0; i--) { SimDescription coworker = job.Coworkers[i]; if ((!IsValidCoworker(coworker, job is School)) || (coworker == job.OwnerDescription)) { job.Coworkers.RemoveAt(i); if (coworker == null) { if (log != null) { log(" Bad Coworker " + job.CareerName + " - <Invalid>"); } } else { if (log != null) { log(" Bad Coworker " + job.CareerName + " - " + coworker.FullName); } } } } } if ((allowDrop) && (job is Career)) { bool replace = false; if (job.CareerLoc == null) { if (log != null) { log(" Bad Location " + job.CareerName + " - " + job.GetType().ToString()); } replace = true; } else { RabbitHole hole = job.CareerLoc.Owner; if (hole == null) { if (log != null) { log(" Missing Rabbithole " + job.CareerName + " - " + job.GetType().ToString()); } replace = true; } else { RabbitHole proxy = hole.RabbitHoleProxy; if (proxy == null) { if (log != null) { log(" Missing Proxy " + job.CareerName + " - " + job.GetType().ToString()); } replace = true; } else { if ((proxy.EnterSlots == null) || (proxy.EnterSlots.Count == 0) || (proxy.ExitSlots == null) || (proxy.ExitSlots.Count == 0)) { if (log != null) { log(" Missing Slots " + job.CareerName + " - " + job.GetType().ToString()); } replace = true; } } } } if (replace) { SimDescription me = job.OwnerDescription; Occupation retiredJob = me.CareerManager.mRetiredCareer; try { CareerLocation location = Sims3.Gameplay.Careers.Career.FindClosestCareerLocation(me, job.Guid); if (location != null) { if (log != null) { log(" Location Replaced " + me.FullName); } if (job.CareerLoc != null) { job.CareerLoc.Workers.Remove(me); } job.CareerLoc = location; location.Workers.Add(me); } else { if (log != null) { log(" Career Dropped " + me.FullName); } job.LeaveJobNow(Career.LeaveJobReason.kJobBecameInvalid); } } finally { me.CareerManager.mRetiredCareer = retiredJob; } } } }