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 static void ResetCareer(SimDescription sim) { try { Sims3.Gameplay.Careers.Career career = sim.Occupation as Sims3.Gameplay.Careers.Career; if (career != null) { if (career.HighestCareerLevelAchieved == null) { if ((career.mHighestLevelAchievedBranchName != null) && (career.mHighestLevelAchievedVal != -1)) { career.HighestCareerLevelAchieved = career.SharedData.CareerLevels[career.mHighestLevelAchievedBranchName][career.mHighestLevelAchievedVal]; } else { career.HighestCareerLevelAchieved = career.CurLevel; } } } } catch (Exception e) { Common.Exception(sim, null, "HighestLevelAchieved", e); } }
protected override bool PrivateAllow(SimDescription me) { if (!base.PrivateAllow(me)) { return(false); } if (me.CreatedSim == null) { return(false); } if (me.CareerManager == null) { return(false); } Sims3.Gameplay.Careers.Career career = me.Occupation as Sims3.Gameplay.Careers.Career; if ((career == null) && (me.CareerManager.School == null)) { return(false); } return(true); }
public static List <CareerLevel> AllLevels(Sims3.Gameplay.Careers.Career job) { List <CareerLevel> list = new List <CareerLevel>(); if (job != null) { CareerLevel level1 = job.Level1; if (level1 != null) { list.Add(level1); int index = 0; while (index < list.Count) { CareerLevel level = list[index]; index++; foreach (CareerLevel next in level.NextLevels) { list.Add(next); } } } } return(list); }
public static void Promote(Sims3.Gameplay.Careers.Career job, CareerLevel newLevel) { CareerLevel curLevel = job.CurLevel; int bonusAmount = job.GivePromotionBonus(); job.GivePromotionRewardObjectsIfShould(newLevel); job.SetLevel(newLevel); job.OnPromoteDemote(curLevel, newLevel); if (job.OwnerDescription.CreatedSim != null) { job.SetTones(job.OwnerDescription.CreatedSim.CurrentInteraction); } job.ShowOccupationTNS(job.GeneratePromotionText(bonusAmount)); }
protected override bool Run(SimDescription me, bool singleSelection) { try { List <Item> allOptions = new List <Item>(); Sims3.Gameplay.Careers.Career career = me.Occupation as Sims3.Gameplay.Careers.Career; if (career != null) { foreach (Sims3.Gameplay.Careers.Career.EventDaily item in career.CareerEventManager.Events) { if (item is Sims3.Gameplay.Careers.Career.EventOpportunity) { continue; } if (!item.IsAvailable(career)) { continue; } allOptions.Add(new Item(item, career, item.EventType.ToString())); } } if (me.CareerManager.School != null) { foreach (Sims3.Gameplay.Careers.Career.EventDaily item in me.CareerManager.School.CareerEventManager.Events) { if (item is Sims3.Gameplay.Careers.Career.EventOpportunity) { continue; } if (!item.IsAvailable(me.CareerManager.School)) { continue; } allOptions.Add(new Item(item, me.CareerManager.School, item.EventType.ToString())); } } if (allOptions.Count == 0) { SimpleMessageDialog.Show(Name, Common.Localize("CareerEvent:None")); return(false); } Item selection = new CommonSelection <Item>(Name, me.FullName, allOptions).SelectSingle(); if (selection == null) { return(false); } selection.mEvent.RunEvent(selection.mCareer); } catch (Exception e) { Common.Exception(me, e); } return(true); }
public Item(Sims3.Gameplay.Careers.Career.EventDaily item, Sims3.Gameplay.Careers.Career career, string name) : base(name, 0) { mEvent = item; mCareer = career; }
protected override bool Run(SimDescription me, bool singleSelection) { Sims3.Gameplay.Careers.Career career = me.Occupation as Sims3.Gameplay.Careers.Career; if (career != null) { List <CareerLevel> levels = AllLevels(career); if ((levels == null) || (levels.Count == 0)) { return(false); } List <Item> allOptions = new List <Item>(); foreach (CareerLevel level in levels) { allOptions.Add(new Item(me, level)); } Item choice = new CommonSelection <Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) { return(false); } List <CareerLevel> order = null; if (choice.mLevel.Level < me.Occupation.CareerLevel) { order = LevelsBetween(choice.mLevel, career.CurLevel, true); } else { order = LevelsBetween(career.CurLevel, choice.mLevel, false); } if (order.Count == 0) { List <CareerLevel> oldBranches = AllBranches(career.CurLevel); List <CareerLevel> newBranches = AllBranches(choice.mLevel); CareerLevel common = null; foreach (CareerLevel branch in newBranches) { if (oldBranches.Contains(branch)) { common = branch; break; } } if (common != null) { order.AddRange(LevelsBetween(common, career.CurLevel, true)); order.AddRange(LevelsBetween(common, choice.mLevel, false)); } } foreach (CareerLevel level in order) { if (career.CurLevel == level) { continue; } if (career.CurLevel.LastLevel == level) { career.DemoteSim(); } else { Promote(career, level); } } return(true); } else { XpBasedCareer xpCareer = me.Occupation as XpBasedCareer; if (xpCareer != null) { List <Item> allOptions = new List <Item>(); for (int level = 1; level <= xpCareer.HighestLevel; level++) { allOptions.Add(new Item(xpCareer.LevelJobTitle(level), level)); } Item choice = new CommonSelection <Item>(Name, me.FullName, allOptions).SelectSingle(); if (choice == null) { return(false); } if (choice.mXPLevel < me.Occupation.CareerLevel) { xpCareer.mLevel = choice.mXPLevel; xpCareer.mXp = 0; } else { Dictionary <DelegateListener, ProcessEventDelegate> retain = new Dictionary <DelegateListener, ProcessEventDelegate>(); Dictionary <ulong, List <EventListener> > dictionary; EventTracker.Instance.mListeners.TryGetValue((ulong)EventTypeId.kActiveCareerAdvanceLevel, out dictionary); // Required to stop a hang when an inactive firefighter is promoted to level 10 if (me.Household != Household.ActiveHousehold) { foreach (List <EventListener> list in dictionary.Values) { foreach (EventListener listener in list) { DelegateListener delListener = listener as DelegateListener; if (delListener != null) { RewardsManager.OccupationRewardInfo target = delListener.mProcessEvent.Target as RewardsManager.OccupationRewardInfo; if (target != null) { retain.Add(delListener, delListener.mProcessEvent); delListener.mProcessEvent = OnStub; } } } } } xpCareer.ForcePromoteToLevel(choice.mXPLevel); if (me.Household != Household.ActiveHousehold) { foreach (List <EventListener> list in dictionary.Values) { foreach (EventListener listener in list) { DelegateListener delListener = listener as DelegateListener; if (delListener != null) { RewardsManager.OccupationRewardInfo target = delListener.mProcessEvent.Target as RewardsManager.OccupationRewardInfo; if (target != null) { delListener.mProcessEvent = retain[delListener]; } } } } } } return(true); } } return(false); }
public Item(Sims3.Gameplay.Careers.Career.EventDaily item, Sims3.Gameplay.Careers.Career career, string name) : base (name, 0) { mEvent = item; mCareer = career; }
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 static string GetJob(SimDescription me) { bool bSeparator = true; string msg = null; try { if (me.AssignedRole != null) { msg += Common.Localize("Status:Role", me.IsFemale, new object[] { Roles.GetLocalizedName(me.AssignedRole) }); DateAndTime start = DateAndTime.Invalid; DateAndTime end = DateAndTime.Invalid; if (Roles.GetRoleHours(me, ref start, ref end)) { msg += Common.Localize("Status:CareerHours", me.IsFemale, new object[] { start.ToString(), end.ToString() }); } } if (SimTypes.InServicePool(me)) { msg += Common.Localize("Status:TypeService", me.IsFemale, new object[] { Common.LocalizeEAString("Ui/Caption/Services/Service:" + me.CreatedByService.ServiceType.ToString()) }); } NpcDriversManager.NpcDrivers driverType; if (SimTypes.InCarPool(me, out driverType)) { msg += Common.Localize("Status:TypeService", me.IsFemale, new object[] { Common.Localize("CarpoolType:" + driverType.ToString()) }); } PetPoolType pool = SimTypes.GetPetPool(me); if (pool != PetPoolType.None) { msg += Common.NewLine + Common.Localize("Status:PetPool", me.IsFemale, new object[] { Common.Localize("PetPool:" + pool) }); } if (me.Occupation != null) { msg += Common.Localize("Status:Career", me.IsFemale, new object[] { me.Occupation.CareerName }); bSeparator = false; msg += Common.Localize("Status:CareerLevel", me.IsFemale, new object[] { me.Occupation.CurLevelJobTitle, me.Occupation.CareerLevel }); int payPerHourBase = 0; int payPerHourExtra = 0; Sims3.Gameplay.Careers.Career career = me.Occupation as Sims3.Gameplay.Careers.Career; if (career != null) { if (career.CurLevel != null) { payPerHourBase = (int)career.CurLevel.PayPerHourBase; } payPerHourExtra = (int)(career.mPayPerHourExtra + career.mBonusPayFromDegreePerHour); } else { payPerHourBase = (int)me.Occupation.PayPerHourOrStipend; } msg += Common.Localize("Status:CareerExtra", me.IsFemale, new object[] { payPerHourBase, payPerHourExtra, me.Occupation.AverageTimeToReachWork }); string days = DaysToString(me.Occupation.DaysOfWeekToWork); msg += Common.Localize("Status:CareerDays", me.IsFemale, new object[] { days }); msg += Common.Localize("Status:CareerHours", me.IsFemale, new object[] { me.Occupation.StartTimeText, me.Occupation.FinishTimeText }); msg += Common.Localize("Status:CareerDaysOff", me.IsFemale, new object[] { me.Occupation.PaidDaysOff, me.Occupation.mUnpaidDaysOff }); float performance = StatusJobPerformance.GetPerformance(me); if (performance != 0f) { msg += Common.Localize("Status:Performance", me.IsFemale, new object[] { (int)performance }); } if (me.Occupation.Boss != null) { msg += Common.Localize("Status:Boss", me.IsFemale, new object[] { me.Occupation.Boss }); } if (me.Occupation.Coworkers != null) { msg += Common.Localize("Status:Coworkers", me.IsFemale, new object[] { me.Occupation.Coworkers.Count }); foreach (SimDescription sim in me.Occupation.Coworkers) { if (sim == null) { continue; } msg += Common.NewLine + sim.FullName; } } } else if (me.TeenOrAbove) { msg += Common.Localize("Status:Career", me.IsFemale, new object[] { Common.Localize("Status:Notemployed") }); bSeparator = false; } if (me.CareerManager != null) { if (me.CareerManager.RetiredCareer != null) { if (bSeparator) { msg += Common.NewLine; } msg += Common.Localize("Status:Retired", me.IsFemale, new object[] { me.CareerManager.RetiredCareer.CurLevelJobTitle }); msg += Common.Localize("Status:Pension", me.IsFemale, new object[] { me.CareerManager.RetiredCareer.PensionAmount() }); } } } catch (Exception e) { msg += "EXCEPTION"; Common.Exception(me, null, msg, e); } return(msg); }