public static Occupation ImportJobContent(CareerManager ths, uint key, ResKeyTable resKeyTable, ObjectIdTable objIdTable, IPropertyStreamReader reader) { Occupation occupation = null; IPropertyStreamReader child = reader.GetChild(key); if (child != null) { ulong num; child.ReadUint64(0xae293ba5, out num, 0L); // Custom, EA Standard occupations are handled by EA if (Enum.IsDefined(typeof(OccupationNames), num)) return null; { OccupationNames guid = (OccupationNames)num; if (guid != OccupationNames.Undefined) { Occupation staticOccupation = CareerManager.GetStaticOccupation(guid); if (staticOccupation != null) { occupation = staticOccupation.Clone(); occupation.OwnerDescription = ths.mSimDescription; occupation.ImportContent(resKeyTable, objIdTable, child); } } } } return occupation; }
// Cutdown version of function public static bool ImportContent(CareerManager ths, ResKeyTable resKeyTable, ObjectIdTable objIdTable, IPropertyStreamReader reader) { Occupation job = ImportJobContent(ths, 0x139b80d1, resKeyTable, objIdTable, reader); if (job != null) { ths.mJob = job; } uint num; reader.ReadUint32(0xb8e5462, out num, 0); for (uint i = 0; i < num; i++) { Occupation occupation = ImportJobContent(ths, 0x1f4ce7a9 + i, resKeyTable, objIdTable, reader); if (occupation != null) { ths.QuitCareers[occupation.Guid] = occupation; } } School school = ImportJobContent(ths, 0xda42e1c9, resKeyTable, objIdTable, reader) as School; if (school != null) { ths.mSchool = school; } job = ImportJobContent(ths, 0x6b334d3d, resKeyTable, objIdTable, reader); if (job != null) { ths.mRetiredCareer = job; } return true; }
protected override bool PrivatePerform(List <SchoolFee> values) { foreach (SchoolFee fee in values) { Occupation school = CareerManager.GetStaticOccupation(fee.mSchool); if (school == null) { continue; } string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", false, new object[] { school.CareerName }), fee.mValue.ToString()); if (string.IsNullOrEmpty(text)) { continue; } int value; if (!int.TryParse(text, out value)) { continue; } fee.mValue = value; SchoolFee existing = Value.Find(item => { return(item.mSchool == fee.mSchool); }); if (existing != null) { existing.mValue = fee.mValue; } else { Value.Add(fee); } } return(true); }
// Cutdown version of function public static bool ImportContent(CareerManager ths, ResKeyTable resKeyTable, ObjectIdTable objIdTable, IPropertyStreamReader reader) { Occupation job = ImportJobContent(ths, 0x139b80d1, resKeyTable, objIdTable, reader); if (job != null) { ths.mJob = job; } uint num; reader.ReadUint32(0xb8e5462, out num, 0); for (uint i = 0; i < num; i++) { Occupation occupation = ImportJobContent(ths, 0x1f4ce7a9 + i, resKeyTable, objIdTable, reader); if (occupation != null) { ths.QuitCareers[occupation.Guid] = occupation; } } School school = ImportJobContent(ths, 0xda42e1c9, resKeyTable, objIdTable, reader) as School; if (school != null) { ths.mSchool = school; } job = ImportJobContent(ths, 0x6b334d3d, resKeyTable, objIdTable, reader); if (job != null) { ths.mRetiredCareer = job; } return(true); }
public void RevertToDefaults(OccupationNames name) { Career career = CareerManager.GetStaticCareer(name); if (career != null && mDefaults != null) { foreach (string branch in career.CareerLevels.Keys) { if (branch != mBranch) { continue; } foreach (KeyValuePair <int, CareerLevel> level in career.CareerLevels[branch]) { if (level.Key == mLevel) { level.Value.PayPerHourBase = mDefaults.mPayPerHourBase; level.Value.CarpoolType = mDefaults.mCarpoolType; } } } } }
// this could be further broken down into another class (IntegerSettingOption) but not right now protected override OptionResult Run(GameHitParameters <GameObject> parameters) { OptionResult result = base.Run(parameters); if (result != OptionResult.Failure) { string defaultPay = string.Empty; if (base.mPicks.Count == 1) { CareerLevelSettingOption.LevelData data = base.mPicks[0]; if (data.mLevel != -1) { Career career = CareerManager.GetStaticCareer(data.mCareer); if (career != null) { defaultPay = career.CareerLevels[data.mBranchName][data.mLevel].PayPerHourBase.ToString(); } } } string text = StringInputDialog.Show(Name, Common.Localize(GetTitlePrefix() + ":Prompt", false), defaultPay); // def if (string.IsNullOrEmpty(text)) { return(OptionResult.Failure); } int value; if (!int.TryParse(text, out value)) { SimpleMessageDialog.Show(Name, Common.Localize("InputError:Numeric")); return(OptionResult.Failure); } foreach (CareerLevelSettingOption.LevelData level in base.mPicks) { if (level.mLevel == -1) { foreach (Career career in CareerManager.CareerList) { foreach (string branch in career.CareerLevels.Keys) { foreach (KeyValuePair <int, Sims3.Gameplay.Careers.CareerLevel> levelData in career.CareerLevels[branch]) { PersistedSettings.CareerSettings settings = NRaas.Careers.Settings.GetCareerSettings(level.mCareer, true); PersistedSettings.CareerLevelSettings levelSettings = settings.GetSettingsForLevel(level.mBranchName, level.mLevel, true); levelSettings.mPayPerHourBase = value; levelData.Value.PayPerHourBase = value; } } } } else { PersistedSettings.CareerSettings settings = NRaas.Careers.Settings.GetCareerSettings(level.mCareer, true); PersistedSettings.CareerLevelSettings levelSettings = settings.GetSettingsForLevel(level.mBranchName, level.mLevel, true); levelSettings.mPayPerHourBase = value; NRaas.Careers.Settings.SetCareerData(settings); } } Common.Notify(Common.Localize("Generic:Success")); return(OptionResult.SuccessLevelDown); } return(result); }
/* * DebugString: "_NFixUp(): if (ListCollon.NullSimSimDescription == this)" * DebugString: "NMScript Exception Log * System.Exception: no message * #0: 0x0001f throw in Sims3.Gameplay.CAS.Sims3.Gameplay.CAS.SimDescription:Fixup () () #1: 0x00050 callvirt in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.RecoverMissingSims:PrivatePerformAction (bool) (9193E9C0 [0] ) #2: 0x00011 callvirt in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.AlarmOption:PerformAction (bool) (9193E9C0 [0] ) #3: 0x00002 call in NRaas.OverwatchSpace.Alarms.NRaas.OverwatchSpace.Alarms.AlarmOption:PerformAlarm () () #4: 0x0001b callvirt in NRaas.NRaas.Overwatch:OnTimer () () #5: 0x00000 in Sims3.Gameplay.Sims3.Gameplay.Function:Invoke () () #6: 0x00003 callvirt in NRaas.Common+FunctionTask:Simulate () () */ public void _NFixUp() { if (runI) { return; } if (ListCollon.NullSimSimDescription == this) { if (niec_native_func.cache_done_niecmod_native_debug_text_to_debugger) { niec_native_func.OutputDebugString("_NFixUp(): if (ListCollon.NullSimSimDescription == this)"); try { throw new Exception("no message"); } catch (Exception ex) { NiecException.SendTextExceptionToDebugger(ex); } } mIsValidDescription = false; NFinalizeDeath.SimDesc_NullToEmpty(this); mIsValidDescription = true; if (UnsafeFixNUllSimDESC) { var p = NFinalizeDeath.GetSafeSelectActor(); if (p != null && p.SimDescription != null) { mOutfits = p.SimDescription.Outfits; } if (!waitrunningtask01) { waitrunningtask01 = true; NiecTask.Perform(() => { for (int i = 0; i < 800; i++) { Simulator.Sleep(0); } waitrunningtask01 = false; NFinalizeDeath.SimDescCleanse(this, true, false); }); } } else if (!waitrunningtask01) { waitrunningtask01 = true; NiecTask.Perform(() => { for (int i = 0; i < 50; i++) { Simulator.Sleep(0); } waitrunningtask01 = false; NFinalizeDeath.SimDescCleanse(this, true, true); }); } return; } mIsValidDescription = true; if (base.TraitManager != null) { base.TraitManager.SetSimDescription(this); base.TraitManager.Fixup(); } if (CreatedSim != null && CreatedSim.Inventory != null) { foreach (TraitChip item in CreatedSim.Inventory.FindAll <TraitChip>(false)) { item.OnLoadFixup(); if (item.Owner == null) { item.SetOwner(this); } } } MiniSimDescription miniSimDescription = MiniSimDescription.Find(SimDescriptionId); if ((GameStates.IsTravelling || GameStates.IsEditingOtherTown) && miniSimDescription != null) { base.CASGenealogy = miniSimDescription.Genealogy; } if (GameObjectRelationships != null) { int i = 0; while (i < GameObjectRelationships.Count) { if (!Sims3.SimIFace.Objects.IsValid(GameObjectRelationships[i].GameObjectDescription.GameObject.ObjectId)) { GameObjectRelationships.RemoveAt(i); } else { i++; } } } if (mGenealogy == null) { mGenealogy = new Genealogy(this); } if (SkillManager == null) { SkillManager = new SkillManager(this); } else { SkillManager.OnLoadFixup(); } if (CareerManager == null) { CareerManager = new CareerManager(this); } else { CareerManager.OnLoadFixup(); } if (VisaManager == null) { VisaManager = new VisaManager(this); } else { VisaManager.OnLoadFixup(); } if (CelebrityManager == null) { CelebrityManager = new CelebrityManager(SimDescriptionId); } else if (CelebrityManager.Owner == null) { CelebrityManager.ResetOwnerSimDescription(SimDescriptionId); } if (LifeEventManager == null || !LifeEventManager.IsValid) { LifeEventManager = new LifeEventManager(this); } LifeEventManager.ClearInvalidActiveNodes(); if (OccultManager == null) { OccultManager = new OccultManager(this); } else { OccultManager.OnLoadFixup(); } if (IsPet) { if (PetManager == null) { PetManager = CreatePetManager(); } } else if (PetManager != null) { PetManager.Dispose(); PetManager = null; } if (IsEP11Bot) { if (TraitChipManager == null) { TraitChipManager = new TraitChipManager(this); } else if (TraitChipManager.Owner == null) { TraitChipManager.ResetOwnerSimDescription(SimDescriptionId); } TraitChipManager.OnLoadFixup(); } else if (TraitChipManager != null) { TraitChipManager.Dispose(); TraitChipManager = null; } AssignSchool(); if (mSimDescriptionId == 0) { MakeUniqueId(); } if (ReadBookDataList == null) { ReadBookDataList = new Dictionary <string, ReadBookData>(); } PushAgingEnabledToAgingManager(); if (mInitialShape.Owner == null || mCurrentShape.Owner == null || mInitialShape.Owner != this || mCurrentShape.Owner != this) { mInitialShape.Owner = (mCurrentShape.Owner = this); } if (OpportunityHistory == null) { OpportunityHistory = new OpportunityHistory(); } if (Sims3.Gameplay.Gameflow.sGameLoadedFromWorldFile && !Household.IsTravelImport && !GameStates.IsIdTravelling(SimDescriptionId)) { mDisplayedShape.Owner = mCurrentShape.Owner; mDisplayedShape.Fit = mCurrentShape.Fit; mDisplayedShape.Weight = mCurrentShape.Weight; mDisplayedShape.Pregnant = mCurrentShape.Pregnant; ResetLifetimeHappinessStatistics(); mHomeWorld = GameUtils.GetCurrentWorld(); } if (mHomeWorld == WorldName.Undefined) { mHomeWorld = GameUtils.GetCurrentWorld(); } if (RelicStats == null) { RelicStats = new RelicStatTracking(this); } RelicStats.SetSimDescription(this); if (TombStats == null) { TombStats = new TombStatTracking(this); } TombStats.SetSimDescription(this); if (Singing == null) { Singing = new SingingInfo(this); } Singing.SetSimDesctiption(this); if (AssignedRole != null) { AssignedRole.OnLoadFixUp(); } Lot lot = LotManager.GetLot(mVirtualLotId); if (lot != null) { lot.VirtualMoveIn(this); } if (Species == CASAgeGenderFlags.None) { Species = CASAgeGenderFlags.Human; } if (!CASLogic.GetSingleton().IsMusicTypeInstalled(FavoriteMusic)) { RandomizeFavoriteMusic(); } if (GetCurrentOutfits() != null) { OutfitCategories[] array = new OutfitCategories[5] { OutfitCategories.None, OutfitCategories.All, OutfitCategories.CategoryMask, OutfitCategories.PrimaryCategories, OutfitCategories.PrimaryHorseCategories }; foreach (var outfitCategories in array) { if (GetOutfitCount(outfitCategories) > 0) { RemoveOutfits(outfitCategories, false); if (base.mMaternityOutfits != null) { base.mMaternityOutfits.Remove(outfitCategories); } if (base.mOutfits != null) { base.mOutfits.Remove(outfitCategories); } } } } if (!GameUtils.IsInstalled(ProductVersion.EP4)) { Sim.PlayPretend.RemoveAllChildCostumeOutfits(this); if (CreatedSim != null && CreatedSim.CurrentOutfitCategory == OutfitCategories.ChildImagination) { CreatedSim.SwitchToOutfitWithoutSpin(OutfitCategories.Everyday); } RemoveOutfits(OutfitCategories.ChildImagination, true); base.Outfits.Remove(OutfitCategories.ChildImagination); if (SpoiledGiftHistory != null) { SpoiledGiftHistory.Clear(); SpoiledGiftHistory = null; } } if (CreatedSim != null && (OccultManager == null || !OccultManager.HasOccultType(OccultTypes.Vampire | OccultTypes.Genie | OccultTypes.Werewolf | OccultTypes.Ghost)) && mSkinToneKey.InstanceId == 15475186560318337848uL) { World.ObjectSetVisualOverride(CreatedSim.ObjectId, eVisualOverrideTypes.Genie, null); } }
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 Allow(OccupationNames value) { School school = CareerManager.GetStaticCareer(value) as School; return(school != null); }
public void LoadCareer(BooterHelper.BootFile file, XmlDbRow row) { BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile; if (dataFile == null) { return; } string careerName = row.GetString("CareerName"); if (careerName == null) { BooterLogger.AddError(file.ToString() + ": No CareerName"); } else { Type classType = row.GetClassType("FullClassName"); if (classType != null) { string key = row.GetString("TableName"); XmlDbTable levelTable = dataFile.GetTable(key); if (levelTable != null) { foreach (XmlDbRow levelRow in levelTable.Rows) { XmlDbData.XmlDbRowFast level = levelRow as XmlDbData.XmlDbRowFast; if (level == null) { continue; } if (!level.Exists("DowntownWakeupTime")) { level.mData.Add("DowntownWakeupTime", level.GetString("WakeupTime")); } if (!level.Exists("DowntownStartTime")) { level.mData.Add("DowntownStartTime", level.GetString("StartTime")); } if (!level.Exists("DowntownDayLength")) { level.mData.Add("DowntownDayLength", level.GetString("DayLength")); } } Type[] types = new Type[] { typeof(XmlDbRow), typeof(XmlDbTable), typeof(XmlDbTable) }; Career career = null; try { career = classType.GetConstructor(types).Invoke(new object[] { row, levelTable, null }) as Career; } catch (Exception e) { BooterLogger.AddError(careerName + ": Constructor Fail " + row.GetString("FullClassName")); Common.Exception(careerName + ": Constructor Fail " + row.GetString("FullClassName"), e); return; } if (career != null) { if (mCareerEventsFile.IsValid) { XmlDbTable table3 = mCareerEventsFile.GetTable(key); if (table3 != null) { LoadCareerEvents(career, mCareerEventsFile, table3); } } career.mCareerGuid = unchecked ((OccupationNames)ResourceUtils.HashString64(row.GetString("AltGuid"))); if (career.Guid == OccupationNames.Undefined) { BooterLogger.AddError(careerName + ": No AltGuid"); } else if (CareerManager.GetStaticCareer(career.mCareerGuid) != null) { BooterLogger.AddError(careerName + ": Duplicate GUID"); } else { RabbitHoleType type = RabbitHoleType.None; ParserFunctions.TryParseEnum <RabbitHoleType>(row.GetString("RabbitholeType"), out type, RabbitHoleType.None); if (type != RabbitHoleType.None) { sCareers.Add(new CareerBooterElement(career.Guid, type)); CareerManager.AddStaticOccupation(career); BooterLogger.AddTrace(careerName + ": Added to Rabbithole " + type); } else { BooterLogger.AddError(careerName + ": Unknown Rabbithole"); } } } else { BooterLogger.AddError(careerName + ": Constructor Fail " + row.GetString("FullClassName")); } } else { BooterLogger.AddError(careerName + ": No TableName"); } } else { BooterLogger.AddError(careerName + ": Invalid FullClassName " + row.GetString("FullClassName")); } } }
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 List <Opportunity> GetAllOpportunities(Sim sim, bool singleCategory, Dictionary <OpportunityNames, Opportunity> opportunityList) { //Common.StringBuilder msg = new Common.StringBuilder("GetAllOpportunities"); List <Opportunity> allOpportunities = new List <Opportunity>(); if (!GameStates.IsOnVacation) { CareerManager manager = sim.CareerManager; if (manager != null) { for (int i = 0; i < 2; i++) { Sims3.Gameplay.Careers.Career career = manager.Occupation as Sims3.Gameplay.Careers.Career; if (i == 1) { career = manager.School; } if (career == null) { continue; } foreach (Sims3.Gameplay.Careers.Career.EventDaily daily in career.CareerEventList) { Sims3.Gameplay.Careers.Career.EventOpportunity oppEvent = daily as Sims3.Gameplay.Careers.Career.EventOpportunity; if (oppEvent == null) { continue; } if (opportunityList.ContainsKey(oppEvent.mOpportunity)) { continue; } Opportunity opportunity = OpportunityManager.GetStaticOpportunity(oppEvent.mOpportunity); if (opportunity == null) { continue; } opportunityList.Add(opportunity.Guid, opportunity); } } } } foreach (Opportunity opportunity in opportunityList.Values) { //msg += Common.NewLine + "A: " + opportunity.Guid; Repeatability origRepeatability = opportunity.RepeatLevel; OpportunityNames origTriggerOpp = opportunity.SharedData.mCompletionTriggerOpportunity; WorldName targetWorldRequired = opportunity.SharedData.mTargetWorldRequired; try { if (!singleCategory) { opportunity.mSharedData.mRepeatLevel = Repeatability.Always; opportunity.mSharedData.mCompletionTriggerOpportunity = OpportunityNames.Undefined; } if (opportunity.TargetWorldRequired == WorldName.SunsetValley) { if ((singleCategory) && (Common.IsOnTrueVacation())) { if (sim.SimDescription.HomeWorld != GameUtils.GetCurrentWorld()) { continue; } } else { opportunity.SharedData.mTargetWorldRequired = WorldName.Undefined; } } else if (opportunity.TargetWorldRequired != WorldName.Undefined) { if (opportunity.TargetWorldRequired != GameUtils.GetCurrentWorld()) { continue; } } if (GameStates.IsOnVacation) { bool career = false; foreach (Opportunity.OpportunitySharedData.RequirementInfo info in opportunity.SharedData.mRequirementList) { if (info.mType == RequirementType.Career) { career = true; break; } } if (career) { continue; } } //if (IsAvailable(opportunity, sim, ref msg)) if (opportunity.IsAvailable(sim)) { allOpportunities.Add(opportunity); } } catch (Exception e) { Common.DebugException(opportunity.Guid + Common.NewLine + opportunity.Name, e); } finally { opportunity.mSharedData.mRepeatLevel = origRepeatability; opportunity.mSharedData.mCompletionTriggerOpportunity = origTriggerOpp; opportunity.SharedData.mTargetWorldRequired = targetWorldRequired; } } List <Opportunity> allPotentials = new List <Opportunity>(); foreach (Opportunity opportunity in allOpportunities) { string name = null; //msg += Common.NewLine + "B: " + opportunity.Guid; try { if (sim.OpportunityManager.HasOpportunity(opportunity.OpportunityCategory)) { continue; } Opportunity toAdd = opportunity.Clone(); toAdd.Actor = sim; // EA has coding to spawn the Time Traveler in SetupTargets(), don't do it in that case if ((toAdd.SharedData.mTargetType != OpportunityTargetTypes.Sim) || (toAdd.SharedData.mTargetData != "TimeTraveler")) { if (!sim.OpportunityManager.SetupTargets(toAdd)) { continue; } } toAdd.SetLocalizationIndex(); name = toAdd.Name; allPotentials.Add(toAdd); } catch (Exception e) { Common.DebugException(opportunity.Guid + Common.NewLine + name, e); } } //Common.DebugWriteLog(msg); return(allPotentials); }
protected override OptionResult RunAll(List <IMiniSimDescription> sims) { Dictionary <OccupationNames, Item> lookup = new Dictionary <OccupationNames, Item>(); foreach (IMiniSimDescription miniSim in sims) { SimDescription member = miniSim as SimDescription; if (member == null) { continue; } if (member.Occupation == null) { continue; } Item item; if (!lookup.TryGetValue(member.Occupation.Guid, out item)) { item = new Item(member.Occupation.Guid); lookup.Add(member.Occupation.Guid, item); } item.IncCount(); item.mSims.Add(new CareerElement(member.Occupation.CareerLevel, member, member.Occupation.Boss, StatusJobPerformance.GetPerformance(member))); } Item choice = new CommonSelection <Item>(Name, lookup.Values).SelectSingle(); if (choice == null) { return(OptionResult.Failure); } List <CareerElement> list = choice.mSims; list.Sort(new CareerElement.CompareByLevel()); string msg = null; foreach (CareerElement element in list) { if (msg != null) { msg += Common.NewLine; } msg += Common.Localize("JobsByCareer:Employee", element.mSim.IsFemale, new object[] { element.mLevel, element.mSim, element.mPerf }); if (element.mBoss != null) { msg += Common.NewLine + Common.Localize("JobsByCareer:Boss", element.mBoss.IsFemale, new object[] { element.mBoss }); } } string careerName = null; Occupation career = CareerManager.GetStaticOccupation(choice.Value); if (career != null) { careerName = career.CareerName; } Sims3.UI.SimpleMessageDialog.Show(careerName, msg); return(OptionResult.SuccessRetain); }
protected override bool Run(SimDescription me, bool singleSelection) { List <Opportunity> allOpportunities = OpportunityEx.GetAllOpportunities(me.CreatedSim, OpportunityCategory.None); if (allOpportunities.Count == 0) { SimpleMessageDialog.Show(Name, Common.Localize("Opportunity:None")); return(false); } Dictionary <string, Item> lookup = new Dictionary <string, Item>(); string all = "(" + Common.LocalizeEAString("Ui/Caption/ObjectPicker:All") + ")"; foreach (Opportunity opp in allOpportunities) { string name = null; switch (opp.OpportunityCategory) { case OpportunityCategory.Career: name = Common.LocalizeEAString("Ui/Caption/HUD/CareerPanel:Career"); break; case OpportunityCategory.Special: name = Common.Localize("Opportunity:Celebrity"); break; case OpportunityCategory.AdventureChina: case OpportunityCategory.AdventureEgypt: case OpportunityCategory.AdventureFrance: name = Common.Localize("Opportunity:Adventure"); break; case OpportunityCategory.Dare: case OpportunityCategory.DayJob: case OpportunityCategory.SocialGroup: name = Common.LocalizeEAString("Gameplay/Objects/PostBoxJobBoard:" + opp.OpportunityCategory); break; case OpportunityCategory.Skill: bool found = false; foreach (Opportunity.OpportunitySharedData.RequirementInfo info in opp.SharedData.mRequirementList) { if (info.mType == RequirementType.Skill) { SkillNames guid = (SkillNames)info.mGuid; Skill staticSkill = SkillManager.GetStaticSkill(guid); if (staticSkill.NonPersistableData != null) { name = Common.LocalizeEAString(staticSkill.NonPersistableData.Name); found = true; } if (found) { break; } } } if (opp is GigOpportunity) { Common.DebugNotify(opp.Name); Occupation band = CareerManager.GetStaticOccupation(OccupationNames.RockBand); if (band != null) { name = band.CareerName; } } break; } if (string.IsNullOrEmpty(name)) { name = Common.Localize("Opportunity:Generic"); } Item item; if (!lookup.TryGetValue(name, out item)) { item = new Item(name); lookup.Add(name, item); } item.Add(opp); if (!lookup.TryGetValue(all, out item)) { item = new Item(all); lookup.Add(all, item); } item.Add(opp); } Item choice = new CommonSelection <Item>(Name, me.FullName, lookup.Values).SelectSingle(); if (choice == null) { return(false); } return(choice.Run(me)); }
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); }
/// <summary> /// Loads GlobalB file and disassembles its blocks /// </summary> /// <param name="GlobalB_dir">Directory of the game.</param> /// <param name="db">Database of classes.</param> /// <returns>True if success.</returns> public static unsafe bool LoadGlobalB(string GlobalB_dir, Database.Underground2 db) { GlobalB_dir += @"\GLOBAL\GlobalB.lzc"; // Get everything from GlobalB.lzc try { db._GlobalBLZC = File.ReadAllBytes(GlobalB_dir); Log.Write("Reading data from GlobalB.lzc..."); } catch (Exception e) { while (e.InnerException != null) { e = e.InnerException; } if (Process.MessageShow) { MessageBox.Show($"Error occured: {e.Message}", "Failure", MessageBoxButtons.OK, MessageBoxIcon.Error); } else { Console.WriteLine(e.Message); } return(false); } // Decompress if compressed db._GlobalBLZC = JDLZ.Decompress(db._GlobalBLZC); // Use pointers to speed up process fixed(byte *byteptr_t = &db._GlobalBLZC[0]) { uint offset = 0; // to calculate current offset uint ID = 0; // to get the ID of the block being read uint size = 0; // to get the size of the block being read uint proff = 0; // offset of the preset rides block uint prsize = 0; // size of the preset rides block uint troff = 0; // offset of the tracks block uint trsize = 0; // size of the tracks block uint csoff = 0; // offset of the carskins block uint cssize = 0; // size of the carskins block uint gcoff = 0xFFFFFFFF; // offset of the gcareerinfo block while (offset < db._GlobalBLZC.Length) { ID = *(uint *)(byteptr_t + offset); // read ID size = *(uint *)(byteptr_t + offset + 4); // read size if (offset + size > db._GlobalBLZC.Length) { if (Process.MessageShow) { MessageBox.Show("GlobalB: unable to read beyond the stream.", "Failure"); } else { Console.WriteLine("GlobalB: unable to read beyond the stream."); } return(false); } switch (ID) { case Global.Materials: E_Material(byteptr_t + offset, db); break; case Global.TPKBlocks: int count = db.TPKBlocks.Length; db.TPKBlocks.Collections.Add(new TPKBlock(byteptr_t + offset, count, db)); break; case Global.CarTypeInfo: E_CarTypeInfo(byteptr_t + offset + 8, size, db); break; case Global.PresetRides: proff = offset + 8; prsize = size; break; case Global.CarParts: E_CarParts(byteptr_t + offset + 8, size, db); break; case Global.SunInfos: E_SunInfo(byteptr_t + offset + 8, size, db); break; case Global.Tracks: troff = offset + 8; trsize = size; break; case Global.CarSkins: csoff = offset + 8; cssize = size; break; case Global.SlotTypes: E_SlotType(byteptr_t + offset, size + 8, db); break; case Global.CareerInfo: if (gcoff == 0xFFFFFFFF) { gcoff = offset; } break; case Global.AcidEffects: E_AcidEffects(byteptr_t + offset + 8, size, db); break; case Global.FEngFiles: case Global.FNGCompress: E_FNGroup(byteptr_t + offset, size + 8, db); break; default: break; } offset += 8 + size; // advance in offset } // Track, Presets and CarSkins are last one to disperse E_Tracks(byteptr_t + troff, trsize, db); E_PresetRides(byteptr_t + proff, prsize, db); E_CarSkins(byteptr_t + csoff, cssize, db); CareerManager.Disassemble(byteptr_t + gcoff, db); } // Disperse spoilers across cartypeinfo E_SpoilMirrs(db); return(true); }
void Awake() { if (alPrScr == null) { alPrScr = FindObjectOfType <AllPrefsScript>(); } if (univFunc == null) { univFunc = FindObjectOfType <UniversalFunctions>(); } if (gM == null) { gM = FindObjectOfType <GameManager> (); } if (adMob == null) { adMob = FindObjectOfType <AndroidAdMob_0>(); } if (buf == null) { buf = FindObjectOfType <Buffer>(); } if (cntrL == null) { cntrL = FindObjectOfType <CountriesList>(); } if (plL == null) { plL = FindObjectOfType <PlayersList>(); } if (prMng == null) { prMng = FindObjectOfType <ProfileManager>(); } switch (SceneManager.GetActiveScene().buildIndex) { case 1: if (upgr == null) { upgr = FindObjectOfType <Upgrades>(); } if (allAw == null) { allAw = FindObjectOfType <AllAwardsScript>(); } if (topPanMng == null) { topPanMng = FindObjectOfType <TopPanelManager>(); } if (objM == null) { objM = FindObjectOfType <Objects_Menu>(); } if (currPrPan == null) { currPrPan = FindObjectOfType <CurrentProfilePanel>(); } if (everyDayReward == null) { everyDayReward = FindObjectOfType <EverydayReward>(); } if (carMng == null) { carMng = FindObjectOfType <CareerManager>(); } break; case 2: if (fwScr == null) { fwScr = FindObjectOfType <FireworkScript>(); } if (molnia == null) { molnia = FindObjectOfType <LighteningScript>(); } if (practScr == null) { practScr = FindObjectOfType <Practice>(); } if (timFr == null) { timFr = FindObjectOfType <TimeFreeze>(); } if (rainMan == null) { rainMan = FindObjectOfType <RainManager>(); } if (bonObjMan == null) { bonObjMan = FindObjectOfType <BonusObjManager>(); } if (enOrDis == null) { enOrDis = FindObjectOfType <EnableOrDisable>(); } if (monWin == null) { monWin = FindObjectOfType <MoneyWinScript>(); } if (camSize == null) { camSize = FindObjectOfType <CameraSize>(); } if (colCorr == null) { colCorr = FindObjectOfType <ColorCorrectionControl>(); } if (marks == null) { marks = FindObjectOfType <Markers>(); } if (goalPanScr == null) { goalPanScr = FindObjectOfType <GoalPanelScript>(); } if (objLev == null) { objLev = FindObjectOfType <Objects_Level>(); } if (scoreScr == null) { scoreScr = FindObjectOfType <Score>(); } if (pMov == null) { pMov = FindObjectOfType <PlayerMovement>(); } if (tM == null) { tM = FindObjectOfType <TimeManager>(); } if (ballScr == null) { ballScr = FindObjectOfType <BallScript>(); } if (grTr == null) { grTr = FindObjectOfType <GroundTrigger1>(); } if (congrPan == null) { congrPan = FindObjectOfType <CongradulationsPanel>(); } if (levAudScr == null) { levAudScr = FindObjectOfType <LevelAudioScript>(); } if (stChScr == null) { stChScr = FindObjectOfType <StadiumChooseScript>(); } if (ballTScr == null) { ballTScr = FindObjectOfType <BallTouchScript>(); } if (jScr == null) { jScr = FindObjectOfType <JumpScript>(); } if (skyScr == null) { skyScr = FindObjectOfType <SkyScript>(); } //if (enAlg == null) enAlg = FindObjectOfType<Enemy>(); break; } }
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); } }
protected override void PerformFile(BooterHelper.BootFile file) { BooterHelper.DataBootFile dataFile = file as BooterHelper.DataBootFile; if (dataFile == null) { return; } XmlDbTable table = dataFile.GetTable("SkillBasedCareers"); if (table == null) { if (file.mPrimary) { BooterLogger.AddTrace(file + ": No SkillBasedCareers table"); } else { BooterLogger.AddError(file + ": No SkillBasedCareers table"); } return; } XmlDbTable table2 = dataFile.GetTable("CareerLevels"); if (table2 == null) { BooterLogger.AddError(file + ": No CareerLevels table"); return; } BooterLogger.AddTrace(file + ": Found Setup = " + table.Rows.Count.ToString()); if (Occupation.sOccupationStaticDataMap == null) { Occupation.sOccupationStaticDataMap = new Dictionary <ulong, OccupationStaticData>(); } Dictionary <ulong, List <XmlDbRow> > dictionary = GenerateCareerToCareerLevelXmlDataMap(table2, "SkilledProfession", "SkillBasedCareers"); foreach (XmlDbRow row in table.Rows) { string guid = row.GetString("SkilledProfession"); OccupationNames names; if (!row.TryGetEnum <OccupationNames>("SkilledProfession", out names, OccupationNames.Undefined)) { names = unchecked ((OccupationNames)ResourceUtils.HashString64(guid)); } if (Occupation.sOccupationStaticDataMap.ContainsKey((ulong)names)) { BooterLogger.AddError(file + ": Exists " + guid); continue; } string str = row.GetString("Skill_Name"); SkillNames skillName = SkillNames.None; try { skillName = GenericManager <SkillNames, Skill, Skill> .ParseGuid(str); } catch { } if (skillName == SkillNames.None) { skillName = unchecked ((SkillNames)ResourceUtils.HashString64(str)); } int minimumLevel = row.GetInt("Minimum_Skill_Level", -1); float gainMultiplier = row.GetFloat("XP_Gain_Multiplier", 0f); int highestLevel = row.GetInt("Highest_Level", 0x0); string speechBalloonIcon = row.GetString("Speech_Balloon_Image"); string hudIcon = row.GetString("HUD_Icon"); string dreamsAndPromisesIcon = row.GetString("Wishes_Icon"); string careerDescriptionLocalizationKey = "Gameplay/Excel/SkillBasedCareers/SkillBasedCareers:" + row.GetString("Description_Text"); string careerOfferLocalizationKey = "Gameplay/Excel/SkillBasedCareers/SkillBasedCareers:" + row.GetString("Offer_Text"); List <string> careerResponsibilityLocalizationKeys = new List <string>(); for (int i = 0x1; i <= 0x3; i++) { string str7 = row.GetString("Career_Responsibility_" + i); if (string.IsNullOrEmpty(str7)) { break; } careerResponsibilityLocalizationKeys.Add("Gameplay/Excel/SkillBasedCareers/SkillBasedCareers:" + str7); } List <string> careerResponsibilityShortLocalizationKeys = new List <string>(); for (int i = 0x1; i <= 0x3; i++) { string str10 = row.GetString("Career_Responsibility_Short_" + i); if (string.IsNullOrEmpty(str10)) { break; } careerResponsibilityShortLocalizationKeys.Add("Gameplay/Excel/SkillBasedCareers/SkillBasedCareers:" + str10); } List <string> careerResponsibilityIcons = new List <string>(); for (int j = 0x1; j <= 0x3; j++) { string str11 = row.GetString("Career_Responsibility_Icon_" + j); if (string.IsNullOrEmpty(str11)) { break; } careerResponsibilityIcons.Add(str11); } List <XmlDbRow> list3; if (dictionary.TryGetValue((ulong)names, out list3)) { Dictionary <int, OccupationLevelStaticData> levelStaticDataMap = SkillBasedCareer.GenerateCareerLevelToStaticLevelDataMap(names, list3); Type type = row.GetClassType("FullClassName"); if (type == null) { type = Type.GetType("Sims3.Gameplay.Careers.SkillBasedCareer, Sims3GameplaySystems"); } Type[] types = new Type[] { typeof(OccupationNames) }; SkillBasedCareer career = (SkillBasedCareer)type.GetConstructor(types).Invoke(new object[] { names }); if (career == null) { BooterLogger.AddError(file.ToString() + ": Constructor Fail " + guid); continue; } Dictionary <uint, JobStaticData> jobStaticDataMap = new Dictionary <uint, JobStaticData>(); Dictionary <uint, TaskStaticData> taskStaticDataMap = new Dictionary <uint, TaskStaticData>(); Dictionary <string, TrackedAsStaticData> trackedAsMappingsStaticDataMap = new Dictionary <string, TrackedAsStaticData>(); SkillBasedCareerStaticData data2 = new SkillBasedCareerStaticData(skillName, minimumLevel, gainMultiplier, highestLevel, speechBalloonIcon, hudIcon, dreamsAndPromisesIcon, careerDescriptionLocalizationKey, careerOfferLocalizationKey, careerResponsibilityLocalizationKeys, careerResponsibilityShortLocalizationKeys, careerResponsibilityIcons, levelStaticDataMap, jobStaticDataMap, taskStaticDataMap, trackedAsMappingsStaticDataMap); if (Occupation.sOccupationStaticDataMap == null) { Occupation.sOccupationStaticDataMap = new Dictionary <ulong, OccupationStaticData>(); } Occupation.sOccupationStaticDataMap.Add((ulong)names, data2); CareerManager.AddStaticOccupation(career); } else { BooterLogger.AddError(file.ToString() + ": No Levels " + guid); } } }
protected static List <Opportunity> GetAllOpportunities(Sim sim) { List <Opportunity> allOpportunities = new List <Opportunity>(); Dictionary <OpportunityNames, Opportunity> opportunityList = null; if (GameUtils.GetCurrentWorld() == WorldName.Egypt) { opportunityList = OpportunityManager.sAdventureEgyptOpportunityList; } else if (GameUtils.GetCurrentWorld() == WorldName.China) { opportunityList = OpportunityManager.sAdventureChinaOpportunityList; } else if (GameUtils.GetCurrentWorld() == WorldName.France) { opportunityList = OpportunityManager.sAdventureFranceOpportunityList; } else { opportunityList = OpportunityManager.sSkillOpportunityList; } if (opportunityList == null) { opportunityList = new Dictionary <OpportunityNames, Opportunity>(); } foreach (Opportunity opp in OpportunityManager.sCareerPhoneCallOpportunityList.Values) { if (opportunityList.ContainsKey(opp.Guid)) { continue; } opportunityList.Add(opp.Guid, opp); } if (opportunityList != null) { foreach (Opportunity opportunity in opportunityList.Values) { if (opportunity.IsAvailable(sim)) { allOpportunities.Add(opportunity); } } } CareerManager manager = sim.CareerManager; if (manager != null) { for (int i = 0; i < 2; i++) { Career career = manager.Occupation as Career; if (i == 1) { career = manager.School; } if (career != null) { foreach (Career.EventDaily daily in career.CareerEventList) { Career.EventOpportunity oppEvent = daily as Career.EventOpportunity; if (oppEvent == null) { continue; } if (oppEvent.IsAvailable(career)) { Opportunity opportunity = null; GenericManager <OpportunityNames, Opportunity, Opportunity> .sDictionary.TryGetValue((ulong)oppEvent.mOpportunity, out opportunity); if (opportunity != null) { allOpportunities.Add(opportunity); } } } } } } List <Opportunity> allPotentials = new List <Opportunity>(); foreach (Opportunity opportunity in allOpportunities) { try { if (opportunity.IsCareer) { if (sim.OpportunityManager.HasOpportunity(OpportunityCategory.Career)) { continue; } } else if (opportunity.IsSkill) { if (sim.OpportunityManager.HasOpportunity(OpportunityCategory.Skill)) { continue; } } Opportunity toAdd = opportunity.Clone(); toAdd.Actor = sim; if (!sim.OpportunityManager.SetupTargets(toAdd)) { continue; } toAdd.SetLocalizationIndex(); string name = toAdd.Name; allPotentials.Add(toAdd); } catch (Exception e) { Exception(e); } } return(allPotentials); }
/// <summary> /// Saves database data into GlobalB file. /// </summary> /// <param name="GlobalB_dir">Game directory.</param> /// <param name="db">Database of classes.</param> /// <returns>True if success.</returns> public static bool SaveGlobalB(string GlobalB_dir, Database.Underground2 db) { GlobalB_dir += @"\GLOBAL\GlobalB.lzc"; using (var br = new BinaryReader(new MemoryStream(db._GlobalBLZC))) using (var bw = new BinaryWriter(File.Open(GlobalB_dir, FileMode.Create))) { bool careerdone = false; int tpkindex = 0; I_Materials(db, bw); while (br.BaseStream.Position < br.BaseStream.Length) { // Set Offset, ID and Size values, read starting in the beginning of the file uint WriterSlotOffset = (uint)br.BaseStream.Position; uint WriterSlotID = br.ReadUInt32(); int WriterSlotSize = br.ReadInt32(); // If one of the necessary slots is reached, replace it switch (WriterSlotID) { case 0: uint key = br.ReadUInt32(); br.BaseStream.Position -= 4; if (key == Global.GlobalLib) { br.BaseStream.Position += WriterSlotSize; break; } else { goto default; } case Global.Materials: br.BaseStream.Position += WriterSlotSize; break; case Global.TPKBlocks: while (db.TPKBlocks[tpkindex].InGlobalA) { ++tpkindex; } I_TPKBlock(db, bw, ref tpkindex); br.BaseStream.Position += WriterSlotSize; break; case Global.ELabGlobal: I_GlobalLibBlock(bw); goto default; case Global.CarTypeInfo: I_CarTypeInfo(db, bw); br.BaseStream.Position += WriterSlotSize; break; case Global.CarSkins: I_CarSkins(db, bw); br.BaseStream.Position += WriterSlotSize; break; case Global.SlotTypes: I_SlotType(db, bw); br.BaseStream.Position += WriterSlotSize; break; case Global.CarParts: I_CarParts(db, bw); br.BaseStream.Position += WriterSlotSize; break; case Global.Tracks: I_Tracks(db, bw); br.BaseStream.Position += WriterSlotSize; break; case Global.SunInfos: I_SunInfos(db, bw); br.BaseStream.Position += WriterSlotSize; break; case Global.XenonTrig: I_GlobalLibBlock(bw); goto default; case Global.AcidEffects: I_AcidEffects(db, bw); br.BaseStream.Position += WriterSlotSize; break; case Global.CareerInfo: if (careerdone) { goto default; } I_GlobalLibBlock(bw); CareerManager.Assemble(bw, db); br.BaseStream.Position += WriterSlotSize; careerdone = true; break; case Global.PresetRides: I_PresetRides(db, bw); br.BaseStream.Position += WriterSlotSize; break; case Global.FloatChunk: I_GlobalLibBlock(bw); goto default; default: bw.Write(WriterSlotID); bw.Write(WriterSlotSize); bw.Write(br.ReadBytes(WriterSlotSize)); break; } } } 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 string GetDetails(List <IMiniSimDescription> sims) { long lUnemployed = 0, lRetired = 0, lWorkingPension = 0, lTotalWorking = 0; long lDemotionPerf = 0; long lPositivePerf = 0; Dictionary <OccupationNames, long> list = new Dictionary <OccupationNames, long>(); foreach (IMiniSimDescription miniSim in sims) { SimDescription member = miniSim as SimDescription; if (member == null) { continue; } try { if (member.Occupation == null) { if ((!member.TeenOrAbove) || (!member.IsHuman)) { continue; } if (SimTypes.IsSpecial(member)) { continue; } if ((member.CareerManager != null) && (member.CareerManager.RetiredCareer != null)) { lRetired++; } else { lUnemployed++; } } else { if (list.ContainsKey(member.Occupation.Guid)) { list[member.Occupation.Guid]++; } else { list.Add(member.Occupation.Guid, 1); } float performance = StatusJobPerformance.GetPerformance(member); if (performance >= 0.0) { lPositivePerf++; } else if (performance < Sims3.Gameplay.Careers.Career.kDemotionThreshold) { lDemotionPerf++; } if (member.CareerManager.RetiredCareer != null) { lWorkingPension++; } lTotalWorking++; } } catch (Exception e) { Common.Exception(member, e); } } List <string> sorted = new List <string>(); foreach (KeyValuePair <OccupationNames, long> value in list) { Occupation career = CareerManager.GetStaticOccupation(value.Key); if (career == null) { continue; } sorted.Add(Common.Localize("JobsByCareerSummary:Element", false, new object[] { career.CareerName, value.Value })); } sorted.Sort(StringComparer.CurrentCulture); string body = null; foreach (string value in sorted) { body += value; } return(Common.Localize("JobsByCareerSummary:Body", false, new object[] { lUnemployed, lRetired, lWorkingPension, body, lTotalWorking, lPositivePerf, lDemotionPerf })); }
public static List <KnownInfo> GetKnownInfoList(HudModel ths, SimDescription otherSimDesc, InformationLearnedAboutSim learnedInfo) { List <KnownInfo> list = new List <KnownInfo>(); Common.StringBuilder msg = new Common.StringBuilder("GetKnownInfoList" + Common.NewLine); try { if (otherSimDesc != null) { bool isHuman = otherSimDesc.IsHuman; bool isTeen = (otherSimDesc.Age & CASAgeGenderFlags.Teen) != CASAgeGenderFlags.None; bool isChild = (otherSimDesc.Age & CASAgeGenderFlags.Child) != CASAgeGenderFlags.None; string str = Localization.LocalizeString("Ui/Caption/HUD/RelationshipsPanel:UnknownTrait", new object[0x0]); msg += "A"; foreach (Trait trait in otherSimDesc.TraitManager.List) { if (!trait.IsVisible || !Localization.HasLocalizationString(trait.TraitNameInfo)) { continue; } bool flag4 = false; foreach (TraitNames names in learnedInfo.Traits) { if (trait.Guid == names) { list.Add(new KnownInfo(trait.TraitName(otherSimDesc.IsFemale), trait.IconKey, KnownInfoType.Trait)); flag4 = true; break; } } if (!flag4) { list.Add(new KnownInfo(str, ResourceKey.CreatePNGKey("trait_unknown", 0x0), KnownInfoType.TraitUnknown)); } } msg += "B"; if ((isHuman && learnedInfo.CareerKnown) && !isChild) { bool flag5 = false; WorldName currentWorld = GameUtils.GetCurrentWorld(); if ((otherSimDesc.HomeWorld != currentWorld) && (GameUtils.GetWorldType(currentWorld) == WorldType.Vacation)) { MiniSimDescription description = MiniSimDescription.Find(otherSimDesc.SimDescriptionId); if (description != null) { ResourceKey iconKey = string.IsNullOrEmpty(description.JobIcon) ? ResourceKey.kInvalidResourceKey : ResourceKey.CreatePNGKey(description.JobIcon, 0x0); list.Add(new KnownInfo(Localization.LocalizeString(description.IsFemale, description.JobOrServiceName, new object[0x0]), iconKey, KnownInfoType.Career)); flag5 = true; } } msg += "C"; if (!flag5) { CareerManager careerManager = otherSimDesc.CareerManager; if ((careerManager != null) && (careerManager.Occupation != null)) { msg += "C1"; Occupation occupation = careerManager.Occupation; string careerIcon = occupation.CareerIcon; ResourceKey key2 = string.IsNullOrEmpty(careerIcon) ? ResourceKey.kInvalidResourceKey : ResourceKey.CreatePNGKey(careerIcon, 0x0); KnownInfoType type = occupation.IsAcademicCareer ? KnownInfoType.AcademicCareer : KnownInfoType.Career; list.Add(new KnownInfo(occupation.CurLevelJobTitle, key2, type)); } else if ((otherSimDesc.CreatedByService != null) && Sims3.Gameplay.Services.Services.IsSimDescriptionInAnyServicePool(otherSimDesc)) { string str4 = Localization.LocalizeString(otherSimDesc.IsFemale, "Gameplay/Services/Title:" + otherSimDesc.CreatedByService.ServiceType.ToString(), new object[0x0]); list.Add(new KnownInfo(str4, ResourceKey.kInvalidResourceKey, KnownInfoType.Career)); } else if ((otherSimDesc.AssignedRole != null) && !string.IsNullOrEmpty(otherSimDesc.AssignedRole.CareerTitleKey)) { list.Add(new KnownInfo(Localization.LocalizeString(otherSimDesc.IsFemale, otherSimDesc.AssignedRole.CareerTitleKey, new object[0x0]), ResourceKey.kInvalidResourceKey, KnownInfoType.Career)); } else if (((careerManager != null) && (careerManager.Occupation == null)) && (careerManager.RetiredCareer != null)) { list.Add(new KnownInfo(Localization.LocalizeString("Ui/Caption/HUD/Career:Retired", new object[0x0]), ResourceKey.CreatePNGKey(careerManager.RetiredCareer.CareerIcon, 0x0), KnownInfoType.Career)); } else { list.Add(new KnownInfo(Localization.LocalizeString(otherSimDesc.IsFemale, "Ui/Caption/HUD/KnownInfoDialog:Unemployed", new object[0x0]), ResourceKey.kInvalidResourceKey, KnownInfoType.Career)); } } } msg += "D"; if (learnedInfo.PartnerKnown) { string firstName = null; ResourceKey relationshipImageKey = ResourceKey.kInvalidResourceKey; if (otherSimDesc.Partner != null) { msg += "D1"; firstName = otherSimDesc.Partner.FirstName; // Custom : false -> true Relationship relationship = otherSimDesc.GetRelationship(otherSimDesc.Partner, true); if (relationship != null) { relationshipImageKey = RelationshipFunctions.GetLTRRelationshipImageKey(relationship.LTR.CurrentLTR, relationship.IsPetToPetRelationship); } } else { msg += "D2"; if (otherSimDesc.HomeWorld != GameUtils.GetCurrentWorld()) { MiniSimDescription description2 = MiniSimDescription.Find(otherSimDesc.SimDescriptionId); if ((description2 != null) && (description2.PartnerId != 0x0L)) { MiniSimDescription otherSim = MiniSimDescription.Find(description2.PartnerId); if (otherSim != null) { firstName = otherSim.FirstName; MiniRelationship miniRelationship = description2.GetMiniRelationship(otherSim) as MiniRelationship; if (miniRelationship != null) { relationshipImageKey = RelationshipFunctions.GetLTRRelationshipImageKey(miniRelationship.CurrentLTR, miniRelationship.IsPetToPetRelationship); } } } } if (string.IsNullOrEmpty(firstName)) { firstName = Localization.LocalizeString("Ui/Caption/HUD/KnownInfoDialog:None", new object[0x0]); } } list.Add(new KnownInfo(firstName, relationshipImageKey, KnownInfoType.Partner)); } msg += "E"; if ((isHuman && (isTeen || isChild)) && ((otherSimDesc.CareerManager != null) && (otherSimDesc.CareerManager.School != null))) { list.Add(new KnownInfo(otherSimDesc.CareerManager.School.Name, ResourceKey.CreatePNGKey(otherSimDesc.CareerManager.School.CareerIcon, 0x0), KnownInfoType.School)); } if (learnedInfo.IsRichAndKnownToBeRich) { list.Add(new KnownInfo(Localization.LocalizeString(otherSimDesc.IsFemale, "Ui/Caption/HUD/KnownInfoDialog:IsRich", new object[0x0]), ResourceKey.CreatePNGKey("w_simoleon_32", 0x0), KnownInfoType.Rich)); } if (isHuman && learnedInfo.SignKnown) { Zodiac zodiac = otherSimDesc.Zodiac; list.Add(new KnownInfo(Localization.LocalizeString(otherSimDesc.IsFemale, "Ui/Caption/HUD/KnownInfoDialog:" + zodiac.ToString(), new object[0x0]), ResourceKey.CreatePNGKey("sign_" + zodiac.ToString() + "_sm", 0x0), KnownInfoType.Zodiac)); } if (isHuman && learnedInfo.AlmaMaterKnown) { if (otherSimDesc.AlmaMater != AlmaMater.None) { list.Add(new KnownInfo(otherSimDesc.AlmaMaterName, ResourceKey.CreatePNGKey("w_simple_school_career_s", 0), KnownInfoType.AlmaMater)); } if (((otherSimDesc.CareerManager != null) && (otherSimDesc.CareerManager.DegreeManager != null)) && (otherSimDesc.CareerManager.DegreeManager.GetDegreeEntries().Count > 0)) { list.Add(new KnownInfo(Localization.LocalizeString("Ui/Caption/HUD/KnownInfoTooltip:UniversityAlmaMater", new object[0]), ResourceKey.CreatePNGKey("moodlet_just_graduated", ResourceUtils.ProductVersionToGroupId(ProductVersion.EP9)), KnownInfoType.AlmaMater)); } } msg += "G"; uint celebrityLevel = otherSimDesc.CelebrityLevel; if (celebrityLevel > 0x0) { KnownInfo item = new KnownInfo(otherSimDesc.CelebrityManager.LevelName, ResourceKey.CreatePNGKey("hud_i_celebrity_page", 0x0), KnownInfoType.CelebrityLevel); item.mCelebrityLevel = celebrityLevel; list.Add(item); } msg += "H"; if (learnedInfo.IsSocialGroupsKnown) { TraitManager traitManager = otherSimDesc.TraitManager; SkillManager skillManager = otherSimDesc.SkillManager; if ((traitManager != null) && (skillManager != null)) { if (traitManager.HasElement(TraitNames.InfluenceNerd)) { InfluenceSkill skill = skillManager.GetSkill <InfluenceSkill>(SkillNames.InfluenceNerd); if ((skill != null) && (skill.SkillLevel > 0)) { list.Add(new KnownInfo(string.Concat(new object[] { Localization.LocalizeString("Ui/Tooltips/SocialGroup:Nerd", new object[0]), "(", skill.SkillLevel, ")" }), ResourceKey.CreatePNGKey("trait_SocialGroup01_s", ResourceUtils.ProductVersionToGroupId(ProductVersion.EP9)), KnownInfoType.SocialGroup)); } } if (traitManager.HasElement(TraitNames.InfluenceSocialite)) { InfluenceSkill skill2 = skillManager.GetSkill <InfluenceSkill>(SkillNames.InfluenceSocialite); if ((skill2 != null) && (skill2.SkillLevel > 0)) { list.Add(new KnownInfo(string.Concat(new object[] { Localization.LocalizeString("Ui/Tooltips/SocialGroup:Jock", new object[0]), "(", skill2.SkillLevel, ")" }), ResourceKey.CreatePNGKey("trait_SocialGroup03_s", ResourceUtils.ProductVersionToGroupId(ProductVersion.EP9)), KnownInfoType.SocialGroup)); } } if (traitManager.HasElement(TraitNames.InfluenceRebel)) { InfluenceSkill skill3 = skillManager.GetSkill <InfluenceSkill>(SkillNames.InfluenceRebel); if ((skill3 != null) && (skill3.SkillLevel > 0)) { list.Add(new KnownInfo(string.Concat(new object[] { Localization.LocalizeString("Ui/Tooltips/SocialGroup:Rebel", new object[0]), "(", skill3.SkillLevel, ")" }), ResourceKey.CreatePNGKey("trait_SocialGroup02_s", ResourceUtils.ProductVersionToGroupId(ProductVersion.EP9)), KnownInfoType.SocialGroup)); } } } } msg += "I"; if (learnedInfo.NumDegreesKnown() > 0) { KnownInfo info2 = new KnownInfo("", ResourceKey.kInvalidResourceKey, KnownInfoType.Degree); otherSimDesc.CareerManager.DegreeManager.GetCompletedDegreeEntries(); foreach (AcademicDegreeNames names2 in learnedInfo.Degrees) { AcademicDegree element = otherSimDesc.CareerManager.DegreeManager.GetElement(names2); if ((element != null) && element.IsDegreeCompleted) { if (info2.mDegreeIcons.Count == 5) { list.Add(info2); info2 = new KnownInfo("", ResourceKey.kInvalidResourceKey, KnownInfoType.Degree); } ResourceKey key4 = ResourceKey.CreatePNGKey(element.DegreeIcon, 0); info2.mDegreeIcons.Add(key4); info2.mIconKey = key4; info2.mInfo = element.DegreeName; } } list.Add(info2); } } } catch (Exception e) { Common.Exception(otherSimDesc, null, msg, e); } return(list); }