public static float GetPerformance(SimDescription me) { if (me.Occupation == null) { return(0); } AcademicCareer academic = me.Occupation as AcademicCareer; if (academic != null) { return(me.Occupation.Performance); } else { XpBasedCareer xpCareer = me.Occupation as XpBasedCareer; if (xpCareer != null) { return(me.Occupation.Performance * 100); } else { return(me.Occupation.Performance); } } }
public static void OnTermCompleted(AcademicCareer ths, float gradeAsPercentage) { if (ths.OwnerDescription == null) { throw new NullReferenceException("OwnerDescription"); } else if (ths.OwnerDescription.CareerManager == null) { throw new NullReferenceException("CareerManager"); } else if (ths.OwnerDescription.CareerManager.DegreeManager == null) { throw new NullReferenceException("DegreeManager"); } else if (ths.DegreeInformation == null) { throw new NullReferenceException("DegreeInformation"); } if (ths.OwnerDescription.CareerManager.DegreeManager.CommitAcademicProgressToDegree(ths.OwnerDescription, ths.DegreeInformation.AcademicDegreeName, (int)ths.mNumberOfCoursesPerDay, gradeAsPercentage, (uint)AcademicCareer.sTermLengthEx)) { CollegeGraduationEx.GraduateSim(ths.OwnerDescription, ths.mDegree); } ActiveTopic.RemoveTopicFromSim(ths.OwnerSim, "During University"); ths.LeaveJob(false, Career.LeaveJobReason.kNone); }
protected override void SetValue(SimDescription me, float value) { Sims3.Gameplay.Careers.Career career = me.Occupation as Sims3.Gameplay.Careers.Career; if (career != null) { career.mPerformance = value; } else { AcademicCareer academicCareer = me.OccupationAsAcademicCareer; if (academicCareer != null) { if (me.CreatedSim != null) { me.CreatedSim.Motives.SetValue(CommodityKind.AcademicPerformance, value); } } else { XpBasedCareer xpCareer = me.Occupation as XpBasedCareer; if (xpCareer != null) { xpCareer.mXp = (value / 100f) * xpCareer.GetCurrentLevelGoalXp(); } } } }
protected bool PayProfessor(AcademicCareer career) { Sim createdSim = career.OwnerDescription.CreatedSim; if ((createdSim != null) && (!career.SpecialWorkDay) && (!(createdSim.CurrentInteraction is Pregnancy.GoToHospital))) { DateAndTime time = SimClock.CurrentTime(); //AcademicCareer.CourseCreationSpec spec = career.GetNextCourse(SimClock.CurrentDayOfWeek, 0); // this needs more work because the above returns the first days course which the below fails to match if sim is attending later day course // but I'm not sure if passing the current hour would return the current course or the one after it... if (career.IsAtWork /*&& (spec != null && (SimClock.IsTimeBetweenTimes(time.Hour, spec.mCourseStartTime, spec.mCourseStartTime + spec.mJobCreationSpec.JobStaticData.HoursAvailable)*/ || career.IsSpecialWorkTime)//)) { int payPerHour = GetValue <ProfessorPayPerHour, int>(); if (payPerHour > 0) { payPerHour /= 6; career.PayOwnerSim(payPerHour, GotPaidEvent.PayType.kCareerNormalPay); } } return(true); } return(false); }
public static void Enroll(List <SimDescription> sims) { bool promptShown = false; foreach (SimDescription sim in sims) { if (sim.Occupation != null) { sim.Occupation.LeaveJob(false, Career.LeaveJobReason.kJobBecameInvalid); } AcademicCareer.EnrollSimInAcademicCareer(sim, sim.CareerManager.DegreeManager.EnrollmentAcademicDegreeName, sim.CareerManager.DegreeManager.EnrollmentCouseLoad); if (!promptShown) { string becameAStudentTnsText = sim.OccupationAsAcademicCareer.GetBecameAStudentTnsText(); if (!string.IsNullOrEmpty(becameAStudentTnsText)) { sim.Occupation.ShowOccupationTNS(becameAStudentTnsText, false); } promptShown = true; } CustomAcademicDegrees.AdjustCustomAcademics(sim); } }
public bool IncrementOneDay(SimDescription sim, ref Household.ReportCardHelper reportCardHelper) { try { mCurrentDay++; // Set for possible use in sub-routines AcademicCareer.GlobalTermLength = mLength; int length = (int)mLength * NRaas.Careers.Settings.mHomeworldUniversityTermLength; Common.DebugNotify("Increment One Day\n" + mCurrentDay + "\n" + length, sim); AcademicCareer academicCareer = sim.OccupationAsAcademicCareer; if (academicCareer == null) { return(false); } if (mCurrentDay >= length) { if (SimTypes.IsSelectable(sim)) { if (reportCardHelper == null) { reportCardHelper = new Household.ReportCardHelper(); } reportCardHelper.AddGPA(sim.SimDescriptionId, academicCareer.GetGradeAsLetter()); } AcademicCareerEx.OnTermCompleted(academicCareer); return(false); } else if (mCurrentDay == (length - 0x1)) { if (SimTypes.IsSelectable(sim)) { float num2 = SimClock.HoursUntil(Household.kWhenOneDayLeftTNSAppears); AlarmManager.Global.RemoveAlarm(sim.Household.mLastDayAlarm); sim.Household.mLastDayAlarm = AlarmManager.Global.AddAlarm(num2, TimeUnit.Hours, sim.Household.OneDayLeft, "One Day left TNS", AlarmType.AlwaysPersisted, sim); } } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(sim, e); } return(true); }
protected override bool PrivateUpdate(ScenarioFrame frame) { AcademicCareer career = Sim.OccupationAsAcademicCareer; if (Careers.Allow(this, Sim)) { PayProfessor(career); } return(true); }
public static void AdjustCustomAcademics(SimDescription sim) { AcademicCareer academicCareer = sim.OccupationAsAcademicCareer; if (academicCareer == null) { return; } string progressStr = null; int progressKey = 0; float progress = academicCareer.mDegree.Progress; if (progress <= 0.25f) { progressStr = AcademicCareer.LocalizeString("FreshmanCourseLevelKey", new object[0x0]); } else if (progress <= 0.5f) { progressKey = 1; progressStr = AcademicCareer.LocalizeString("SophomoreCourseLevelKey", new object[0x0]); } else if (progress <= 0.75f) { progressKey = 2; progressStr = AcademicCareer.LocalizeString("JuniorCourseLevelKey", new object[0x0]); } else { progressKey = 3; progressStr = AcademicCareer.LocalizeString("SeniorCourseLevelKey", new object[0x0]); } AcademicDegreeStaticData staticData = academicCareer.mDegree.AcademicDegreeStaticData; foreach (AcademicCareer.CourseCreationSpec spec in academicCareer.mCourseSchedule) { string key = JobToString(spec.mJobCreationSpec.mJobId); if (string.IsNullOrEmpty(key)) { continue; } key = staticData.mDegreeDescKey + ":" + key + progressKey; spec.mCourseLocalizedName = Common.LocalizeEAString(sim.IsFemale, key, new object[] { progressStr }); } }
protected override OptionResult RunAll(List <IMiniSimDescription> sims) { List <SimDescription> trueSims = new List <SimDescription>(); foreach (IMiniSimDescription miniSim in sims) { SimDescription trueSim = miniSim as SimDescription; if (trueSim == null) { continue; } trueSims.Add(trueSim); } int termLen = 0; int totalCost = 0; List <IEnrollmentData> list = EnrollmentDialogEx.Show(trueSims[0], trueSims, true, out termLen, out totalCost); if ((list != null) && (list.Count > 0)) { AcademicCareer.GlobalTermLength = (AcademicCareer.TermLength)termLen; foreach (IEnrollmentData data in list) { SimDescription enrollingSimDesc = data.EnrollingSimDesc as SimDescription; if ((enrollingSimDesc != null) && (enrollingSimDesc.CareerManager != null) && (enrollingSimDesc.CareerManager.DegreeManager != null)) { enrollingSimDesc.CareerManager.DegreeManager.SetEnrollmentData(data); if (enrollingSimDesc.CreatedSim != null) { EventTracker.SendEvent(new AcademicEvent(EventTypeId.kEnrolledInUniversity, enrollingSimDesc.CreatedSim, (AcademicDegreeNames)data.AcademicDegreeName)); } AcademicCareer.EnrollSimInAcademicCareer(enrollingSimDesc, (AcademicDegreeNames)data.AcademicDegreeName, data.CourseLoad); CustomAcademicDegrees.AdjustCustomAcademics(enrollingSimDesc); } } } return(OptionResult.SuccessRetain); }
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); }
private static void OneDayPassedUniversityUpdates(Household ths) { try { if (GameStates.CurrentDayOfTrip == GameStates.TripLength) { Household.ReportCardHelper helper = null; foreach (SimDescription description in Households.All(ths)) { if (description == null) { continue; } if (description.OccupationAsAcademicCareer == null) { continue; } if (helper == null) { helper = new Household.ReportCardHelper(); } helper.AddGPA(description.SimDescriptionId, description.OccupationAsAcademicCareer.GetGradeAsLetter()); } if (helper != null) { AlarmManager.Global.AddAlarm(SimClock.HoursUntil(Household.kWhenReportCardArrives), TimeUnit.Hours, helper.ReportCardArrives, "Report Card Arrives", AlarmType.AlwaysPersisted, ths); } // Correction for potential error in OnTermCompleted() Corrections.CleanupAcademics(null); foreach (Household household in Household.sHouseholdList) { if (household == null) { continue; } if (household.IsPreviousTravelerHousehold) { continue; } foreach (SimDescription sim in household.SimDescriptions) { if (sim == null) { continue; } try { AcademicCareer occupationAsAcademicCareer = sim.OccupationAsAcademicCareer; if (occupationAsAcademicCareer != null) { AcademicCareerEx.OnTermCompleted(occupationAsAcademicCareer); } } catch (Exception e) { Common.Exception(sim, e); } } } AlarmManager.Global.RemoveAlarm(ths.mLastDayAlarm); ths.mLastDayAlarm = AlarmManager.Global.AddAlarm(SimClock.HoursUntil(Household.kWhenOneHourLeftTNSAppears), TimeUnit.Hours, ths.OneHourLeft, "One Hour left TNS", AlarmType.AlwaysPersisted, ths); AlarmManager.Global.RemoveAlarm(ths.mTriggerUniversityReturnFlowAlarm); ths.mTriggerUniversityReturnFlowAlarm = AlarmManager.Global.AddAlarm(SimClock.HoursUntil(Household.kWhenSimsStartLeaving), TimeUnit.Hours, BeginReturnFromUniversityFlow, "Start University Return Home Flow Alarm", AlarmType.AlwaysPersisted, ths); } else if (GameStates.CurrentDayOfTrip > GameStates.TripLength) { bool denyTravel = false; if (!GameStates.IsTravelling) { foreach (Sim sim in ths.AllActors) { if ((sim != null) && sim.IsDying()) { denyTravel = true; } } } GameStates.StopSnappingPicturesIfNeccessary(); if (Sims3.Gameplay.UI.Responder.Instance.HudModel is HudModel) { Common.FunctionTask.Perform(ths.ShowTripOverDialog); } if (!denyTravel) { Traveler.SaveGame(); TravelUtil.PlayerMadeTravelRequest = true; // Custom GameStatesEx.UpdateTelemetryAndTriggerTravelBackToHomeWorld(); } } else if (GameStates.CurrentDayOfTrip <= 0x1) { AlarmManager.Global.RemoveAlarm(Household.mAtUnivTutorialAlarm); Household.mAtUnivTutorialAlarm = AlarmHandle.kInvalidHandle; AlarmManager.Global.RemoveAlarm(Household.mDormsTutorialAlarm); Household.mDormsTutorialAlarm = AlarmHandle.kInvalidHandle; Household.mAtUnivTutorialAlarm = AlarmManager.Global.AddAlarmDay(Household.kTimeAtUnivTutorial, ~DaysOfTheWeek.None, Household.TriggerAtUniversityTutorial, "At University Lesson", AlarmType.AlwaysPersisted, null); Household.mDormsTutorialAlarm = AlarmManager.Global.AddAlarmDay(Household.kTimeDormsTutorial, ~DaysOfTheWeek.None, Household.TriggerDormsTutorial, "Dorms Lesson", AlarmType.AlwaysPersisted, null); } else if (GameStates.CurrentDayOfTrip == (GameStates.TripLength - 0x1)) { float num2 = SimClock.HoursUntil(Household.kWhenOneDayLeftTNSAppears); ths.mLastDayAlarm = AlarmManager.Global.AddAlarm(num2, TimeUnit.Hours, ths.OneDayLeft, "One Day left TNS", AlarmType.AlwaysPersisted, ths); } } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(ths, e); } }
protected override bool PrivateUpdate(ScenarioFrame frame) { Common.StringBuilder msg = new Common.StringBuilder(); List <AcademicDegreeNames> degreesThatNeedProfessors = new List <AcademicDegreeNames>(); foreach (AcademicDegreeNames degree in Enum.GetValues(typeof(AcademicDegreeNames))) { if (degree == AcademicDegreeNames.Undefined || degree == AcademicDegreeNames.MaxDegreeNames) { continue; } if (AcademicCareer.sProfessors != null) { if (AcademicCareer.sProfessors.ContainsKey(degree) && SimDescription.Find(AcademicCareer.sProfessors[degree]) != null) { continue; } } msg += "DegreesThatNeedProfessors: " + degree + Common.NewLine; degreesThatNeedProfessors.Add(degree); } if (degreesThatNeedProfessors.Count == 0) { Common.DebugNotify("No professors needed"); return(false); } List <SimDescription> possibleProfessors = new List <SimDescription>(); List <AcademicDegreeNames> degreesWithEnrollment = new List <AcademicDegreeNames>(); // Sims who have completed X degree foreach (SimDescription sim in Sims.Humans) { msg += Common.NewLine + "Sim: " + sim.FullName; if (sim.CareerManager == null) { msg += Common.NewLine + "CareerManager null"; continue; } if (sim.ChildOrBelow) { msg += Common.NewLine + "ChildOrBelow"; continue; } if (SimTypes.IsSpecial(sim)) { msg += Common.NewLine + "IsSpecial"; continue; } if (sim.Occupation != null) { msg += Common.NewLine + "Employed"; if (sim.CareerManager.Occupation is StoryProgressionSpace.Careers.Retired && !GetValue <AllowRetiredElder, bool>()) { msg += Common.NewLine + "Retire skip"; continue; } if (sim.OccupationAsAcademicCareer == null && !GetValue <AllowQuitOccupation, bool>()) { msg += Common.NewLine + "AllowQuitOccupation skip"; continue; } AcademicCareer career = sim.OccupationAsAcademicCareer; if (career != null && career.Level == 2) { msg += Common.NewLine + "AlreadyProfessor"; continue; } if (career != null && career.DegreeInformation != null && degreesThatNeedProfessors.Contains(career.DegreeInformation.AcademicDegreeName)) { if (!degreesWithEnrollment.Contains(career.DegreeInformation.AcademicDegreeName)) { // note this isn't added to unless it needs a professor msg += Common.NewLine + "DegreesWithEnrollment: " + career.DegreeInformation.AcademicDegreeName; degreesWithEnrollment.Add(career.DegreeInformation.AcademicDegreeName); } } } else { msg += Common.NewLine + "Unemployed"; } if (sim.Teen || !GetValue <AllowBeProfessorOption, bool>(sim)) { msg += Common.NewLine + "Teen or !AllowBeProfessor"; continue; } if (!Careers.AllowFindJob(this, sim)) { msg += Common.NewLine + "!AllowFindJob"; continue; } if (!Careers.TestCareer(this, sim, OccupationNames.AcademicCareer)) { msg += Common.NewLine + "!TestCareer"; continue; } if (sim.Household != null && sim.Household != Household.ActiveHousehold) { msg += Common.NewLine + "PossibleProfessor: " + sim.FullName; possibleProfessors.Add(sim); } } RandomUtil.RandomizeListOfObjects <SimDescription>(possibleProfessors); if (degreesWithEnrollment.Count == 0) { msg += Common.NewLine + "degreesWithEnrollment = 0"; Common.DebugWriteLog(msg); return(false); } if (possibleProfessors.Count == 0) { msg += Common.NewLine + "possibleProfessors = 0"; Common.DebugWriteLog(msg); return(false); } List <SimDescription> preferredProfessors = new List <SimDescription>(); foreach (SimDescription pSim in new List <SimDescription>(possibleProfessors)) { msg += Common.NewLine + "Promote loop: " + pSim.FullName; foreach (AcademicDegreeNames name in new List <AcademicDegreeNames>(degreesWithEnrollment)) { // checked because it can get removed if (degreesWithEnrollment.Contains(name)) { msg += Common.NewLine + "Degree: " + name; if (pSim.OccupationAsAcademicCareer != null) { msg += Common.NewLine + "University Student"; // actively enrolled but has completed the degree we need? if (pSim.CareerManager.DegreeManager != null && pSim.CareerManager.DegreeManager.HasCompletedDegree(name)) { msg += Common.NewLine + "HCD: " + name; if (pSim.OccupationAsAcademicCareer.DegreeInformation != null) { // quit university for professor, use existing degree if (pSim.OccupationAsAcademicCareer.DegreeInformation.AcademicDegreeName != name) { pSim.Occupation.LeaveJobNow(Career.LeaveJobReason.kQuit); if (pSim.CreatedSim != null) { pSim.CreatedSim.InteractionQueue.CancelAllInteractionsByType(WorkInRabbitHole.Singleton); } while (pSim.Occupation != null) { Common.Sleep(5); } } AcademicCareer.EnrollSimInAcademicCareer(pSim, name, AcademicCareer.ChooseRandomCoursesPerDay()); degreesWithEnrollment.Remove(name); pSim.Occupation.PromoteSim(); possibleProfessors.Remove(pSim); msg += Common.NewLine + "Re-enrolling"; break; } } } else { // not active university Sim, have they completed this degree? if (pSim.CareerManager.DegreeManager != null && pSim.CareerManager.DegreeManager.HasCompletedDegree(name)) { // they have... if (pSim.Occupation != null) { msg += Common.NewLine + "Quit job"; pSim.Occupation.LeaveJobNow(Career.LeaveJobReason.kQuit); if (pSim.CreatedSim != null) { pSim.CreatedSim.InteractionQueue.CancelAllInteractionsByType(WorkInRabbitHole.Singleton); } while (pSim.Occupation != null) { Common.Sleep(5); } } bool yes = AcademicCareer.EnrollSimInAcademicCareer(pSim, name, AcademicCareer.ChooseRandomCoursesPerDay()); Common.Notify("Success? " + yes); degreesWithEnrollment.Remove(name); pSim.OccupationAsAcademicCareer.PromoteSim(); possibleProfessors.Remove(pSim); msg += Common.NewLine + "Enrolling"; break; } } } } // if we got this far they aren't in uni and haven't completed any degrees... if (pSim.Elder && (pSim.Occupation == null || pSim.Occupation is StoryProgressionSpace.Careers.Retired)) { preferredProfessors.Add(pSim); } } if (degreesWithEnrollment.Count == 0) { Common.DebugWriteLog(msg); return(false); } if (possibleProfessors.Count == 0) { Common.DebugWriteLog(msg); return(false); } int loop = 1; int count = degreesWithEnrollment.Count; msg += Common.NewLine + "Count: " + count; while (loop <= count) { msg += Common.NewLine + "Loop: " + loop; if (degreesWithEnrollment.Count == 0 || possibleProfessors.Count == 0) { break; } SimDescription newP; if (preferredProfessors.Count > 0) { newP = RandomUtil.GetRandomObjectFromList <SimDescription>(preferredProfessors); preferredProfessors.Remove(newP); } else { newP = RandomUtil.GetRandomObjectFromList <SimDescription>(possibleProfessors); } AcademicDegreeNames enroll = RandomUtil.GetRandomObjectFromList <AcademicDegreeNames>(degreesWithEnrollment); msg += Common.NewLine + "Professor: " + newP.FullName; msg += Common.NewLine + "Degree: " + enroll; if (newP.Occupation != null) { msg += Common.NewLine + "Quit Job"; newP.Occupation.LeaveJobNow(Career.LeaveJobReason.kQuit); if (newP.CreatedSim != null) { newP.CreatedSim.InteractionQueue.CancelAllInteractionsByType(WorkInRabbitHole.Singleton); } while (newP.Occupation != null) { Common.Sleep(5); } } bool su = AcademicCareer.EnrollSimInAcademicCareer(newP, enroll, AcademicCareer.ChooseRandomCoursesPerDay()); degreesWithEnrollment.Remove(enroll); newP.OccupationAsAcademicCareer.PromoteSim(); loop++; possibleProfessors.Remove(newP); msg += Common.NewLine + "Success ? " + su; } Common.DebugWriteLog(msg); return(false); }
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); } }
public override bool Run() { try { Definition interactionDefinition = InteractionDefinition as Definition; if (interactionDefinition == null) { return(false); } if (Autonomous && (interactionDefinition.mUsageType == BusinessPlanning.None)) { interactionDefinition.mUsageType = (BusinessPlanning)RandomUtil.GetInt(0, 1); } IInteractionNameCanBeOverriden overriden = this; if (overriden != null) { overriden.SetInteractionName(interactionDefinition.GetAutonomousInteractionName()); UpdateCaption = true; } if (this.mRunFromInventory && Actor.Inventory.Contains(Target)) { Vector3 vector; Vector3 vector2; FindGoodLocationBooleans constraints = FindGoodLocationBooleans.Routable | FindGoodLocationBooleans.PreferEmptyTiles; World.FindGoodLocationParams fglParams = new World.FindGoodLocationParams(Actor.Position, constraints); if (!GlobalFunctions.FindGoodLocation(Target, fglParams, out vector, out vector2)) { return(false); } Actor.Inventory.TryToRemove(Target); Target.SetPosition(vector); Target.SetForward(vector2); Target.AddToWorld(); Target.SetOpacity(0f, 0f); } if (!Target.Line.WaitForTurn(this, SimQueue.WaitBehavior.Default, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), AcademicBusinessPlanner.kTimeToWaitInLine)) { Actor.Inventory.TryToAdd(Target); return(false); } if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0)) { Actor.Inventory.TryToAdd(Target); return(false); } StandardEntry(); Target.EnableFootprintAndPushSims(AcademicBusinessPlanner.sFootprintHash, Actor); if (this.mRunFromInventory) { Actor.PlaySoloAnimation("a2o_object_genericSwipe_x", true); Target.SetOpacityTransition(0f, 1f, 1f); } AcquireStateMachine("BusinessPlanner"); SetActor("x", Actor); SetActor("planner", Target); List <AcademicDegreeNames> namesNeeded = new List <AcademicDegreeNames>(); namesNeeded.Add(AcademicDegreeNames.Business); BeginCommodityUpdatesAccountingForAcademicPerformance(namesNeeded); Target.mCurrentBusinessPlanningType = interactionDefinition.mUsageType; mCurrentStateMachine.EnterState("x", "Enter"); if (!Target.PlannerIsOpen) { AnimateSim("Open"); Target.PlannerIsOpen = true; } float kXPIncreasePerWorking = 0f; ReactionBroadcaster broadcaster = null; if (interactionDefinition.mUsageType == BusinessPlanning.WorkOnBusinessPlan) { AnimateSim("Work"); this.mWaitTime = RandomUtil.GetFloat(kMinWorkLength, kMaxWorkLength); kXPIncreasePerWorking = AcademicBusinessPlanner.UseBusinessPlanner.kXPIncreasePerWorking; } else { AnimateSim("Practice"); this.mWaitTime = RandomUtil.GetFloat(kMinPresentationLength, kMaxPresentationLength); kXPIncreasePerWorking = kXPIncreasePerPresentation; broadcaster = new ReactionBroadcaster(Target, kPresentationBroadcastParams, new ReactionBroadcaster.BroadcastCallback(this.BroadcastCallback)); } DoTimedLoop(this.mWaitTime, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)); bool flag2 = false; foreach (InteractionInstance instance in Actor.InteractionQueue.InteractionList) { if ((instance != this) && (instance is AcademicBusinessPlanner.UseBusinessPlanner)) { flag2 = true; break; } } if (!flag2 && Target.PlannerIsOpen) { AnimateSim("Close"); Target.PlannerIsOpen = false; } AnimateSim("Exit"); Target.DisableFootprint(AcademicBusinessPlanner.sFootprintHash); EndCommodityUpdates(true); StandardExit(); if (!Actor.HasExitReason(ExitReason.Canceled)) { if (interactionDefinition.mUsageType == BusinessPlanning.PresentBusinessPlan) { EventTracker.SendEvent(EventTypeId.kPresentedBusinessPlan, Actor, Target.LotCurrent); } else if (interactionDefinition.mUsageType == BusinessPlanning.WorkOnBusinessPlan) { EventTracker.SendEvent(EventTypeId.kWorkedOnBusinessPlan, Actor, Target.LotCurrent); } } if (broadcaster != null) { broadcaster.EndBroadcast(); broadcaster.Dispose(); broadcaster = null; } // Custom, removed IsUniversityWorld() check Business occupationAsCareer = Actor.OccupationAsCareer as Business; if (occupationAsCareer != null) { occupationAsCareer.UpdatePerformanceOrExperience(kXPIncreasePerWorking); } AcademicCareer occupationAsAcademicCareer = Actor.OccupationAsAcademicCareer; if (((occupationAsAcademicCareer != null) && (occupationAsAcademicCareer.DegreeInformation != null)) && (occupationAsAcademicCareer.DegreeInformation.AcademicDegreeName == AcademicDegreeNames.Business)) { occupationAsAcademicCareer.UpdatePerformanceOrExperience(kXPIncreasePerWorking); } if (!Target.PlannerIsOpen) { Actor.WaitForExitReason(2f, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)); if (!Actor.Inventory.Contains(Target)) { Actor.PlaySoloAnimation("a2o_object_genericSwipe_x", true); Actor.Inventory.TryToAdd(Target); } } return(true); } catch (ResetException) { throw; } catch (Exception e) { Common.Exception(Actor, Target, e); return(false); } }
public static void AddAcademic(SimDescription sim, AcademicCareer.TermLength length) { sControllers[sim.SimDescriptionId] = new AcademicController(length); Common.DebugNotify("Academic Added", sim); }
public static void OnTermCompleted(AcademicCareer ths) { float gradeAsPercentage = ths.GetGradeAsPercentage(); OnTermCompleted(ths, gradeAsPercentage); }
public static void CleanupAcademics(Logger log) { Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(false); foreach (SimDescription sim in sims.Values) { if (sim.CareerManager == null) { continue; } AcademicCareer career = sim.OccupationAsAcademicCareer; if (career != null) { if ((career.mDegree == null) || (AcademicDegreeManager.GetStaticElement(career.mDegree.AcademicDegreeName) == null)) { career.LeaveJobNow(Career.LeaveJobReason.kJobBecameInvalid); } } AcademicDegreeManager manager = sim.CareerManager.DegreeManager; if (manager == null) { continue; } List <AcademicDegreeNames> remove = new List <AcademicDegreeNames>(); foreach (AcademicDegree degree in manager.List) { if (AcademicDegreeManager.GetStaticElement(degree.AcademicDegreeName) == null) { remove.Add(degree.AcademicDegreeName); } } foreach (AcademicDegreeNames degree in remove) { manager.RemoveElement((ulong)degree); if (log != null) { log("Remove Corrupt Degree: " + sim.FullName); } } } if (AcademicCareer.sAcademicSims != null) { for (int i = AcademicCareer.sAcademicSims.Count - 1; i >= 0; i--) { bool remove = false; SimDescription sim; if (!sims.TryGetValue(AcademicCareer.sAcademicSims[i], out sim)) { remove = true; } else { AcademicCareer career = sim.OccupationAsAcademicCareer; if (career == null) { remove = true; } else if (career.mDegree == null) { remove = true; } else if (career.Coworkers == null) { remove = true; } } if (remove) { if (log != null) { if (sim != null) { log(" Removed: " + sim.FullName); } else { log(" Removed: " + AcademicCareer.sAcademicSims[i]); } } AcademicCareer.sAcademicSims.RemoveAt(i); } } } }
public AcademicController(AcademicCareer.TermLength length) { mLength = length; }
protected override bool PrivateUpdate(ScenarioFrame frame) { int elapsedCalendarDays = SimClock.ElapsedCalendarDays(); RabbitHole.RabbitHoleInteraction <Sim, RabbitHole> work = Sim.CreatedSim.InteractionQueue.GetCurrentInteraction() as RabbitHole.RabbitHoleInteraction <Sim, RabbitHole>; if (work == null) { return(false); } if (work.Actor == null) { return(false); } if (work.mAvailableTones != null) { int index = 0; while (index < work.mAvailableTones.Count) { if (work.mAvailableTones[index] == null) { work.mAvailableTones.RemoveAt(index); } else { index++; } } } List <InteractionToneDisplay> displayTones = work.AvailableTonesForDisplay(); if (displayTones == null) { IncStat("No Choices"); return(false); } List <ITone> tones = new List <ITone>(); foreach (InteractionToneDisplay tone in displayTones) { if (tone.InteractionTone == null) { continue; } if (tone.InteractionTone.ToString() == mTone) { continue; } if (!ManagerCareer.VerifyTone(tone.InteractionTone as CareerTone)) { continue; } // can't put this in VerifyTone because ActiveCareer tones aren't inherited from CareerTone // and that function needs that AcademicCourse.SuckUpToProfessorTone professorTone = tone.InteractionTone as AcademicCourse.SuckUpToProfessorTone; if (professorTone != null && work.Actor.CareerManager.DegreeManager != null) { SimDescription sim = AcademicCareer.GetProfessorForMajor(work.Actor.CareerManager.DegreeManager.EnrollmentAcademicDegreeName); if (sim != null && sim.SimDescriptionId == work.Actor.SimDescription.SimDescriptionId) { continue; } } tones.Add(tone.InteractionTone); } return(ConfigureInteraction(work, tones)); }