// public static string LocalizeString(string name, params object[] parameters) // { // return Localization.LocalizeString("Gameplay/Objects/Electronics/Computer/LeaveBookClub:" + name, parameters); // } public override bool Run() { base.StandardEntry(); if (!base.Target.StartComputing(this, SurfaceHeight.Table, true)) { base.StandardExit(); return(false); } base.Target.StartVideo(Computer.VideoType.Browse); base.BeginCommodityUpdates(); base.AnimateSim("WorkTyping"); if (TwoButtonDialog.Show(Localization.LocalizeString("Lyralei/Localized/LeavePatternClubDesc:InteractionName", new object[0]), Localization.LocalizeString("Lyralei/Localized/LeavePatternClubYES:InteractionName", new object[0]), Localization.LocalizeString("Lyralei/Localized/LeavePatternClubNO:InteractionName", new object[0]))) { SimDescription ActorDesc = base.Actor.SimDescription; if (GlobalOptionsSewingTable.retrieveData.whoIsInPatternClub.ContainsKey(ActorDesc.mSimDescriptionId)) { GlobalOptionsSewingTable.retrieveData.whoIsInPatternClub.Remove(ActorDesc.mSimDescriptionId); } Mailbox mailbox = Mailbox.GetMailboxOnLot(base.Actor.LotHome); mailbox.RemoveAlarm(GlobalOptionsSewingTable.mPatternClubAlarm); GlobalOptionsSewingTable.mPatternClubAlarm = AlarmHandle.kInvalidHandle; } base.Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false); base.EndCommodityUpdates(true); base.StandardExit(); return(true); }
public static void SendPatterns() { if (!Sims3.SimIFace.Environment.HasEditInGameModeSwitch && !GameUtils.IsOnVacation()) { Household activeHousehold = Household.ActiveHousehold; if (activeHousehold != null) { Mailbox mailboxOnLot = Mailbox.GetMailboxOnLot(activeHousehold.LotHome); if (mailboxOnLot != null) { foreach (Sim sim in activeHousehold.Sims) { SimDescription desc = sim.SimDescription; if (SewingSkill.isInPatternClub(desc)) { Pattern randomPattern = Pattern.DiscoverPattern(sim); if (randomPattern != null) { mailboxOnLot.AddMail(randomPattern, false); } else { randomPattern.Destroy(); } } } } } } }
public static void OnWorldQuit(object sender, EventArgs e) { Ferry <PersistedData> .LoadCargo(); foreach (KeyValuePair <ulong, bool> keyvalues in GlobalOptionsSewingTable.retrieveData.whoIsInPatternClub) { print("Re-assigned the mailbox alarm!"); SimDescription description = SimDescription.Find(keyvalues.Key); Mailbox mailbox = Mailbox.GetMailboxOnLot(description.LotHome); mailbox.RemoveAlarm(1f, DaysOfTheWeek.Thursday, GlobalOptionsSewingTable.SendPatterns, "Mailbox: Pattern club " + description.mSimDescriptionId.ToString(), AlarmType.AlwaysPersisted); } //AlarmManager.Global.RemoveAlarm(mPatternClubAlarm); //mPatternClubAlarm = AlarmHandle.kInvalidHandle; //AlarmManager.Global.RemoveAlarm(mWearClothing); //mWearClothing = AlarmHandle.kInvalidHandle; }
public static void OnWorldLoadFinished(object sender, EventArgs e) { if (alreadyParsed) { Ferry <PersistedData> .UnloadCargo(); } alreadyParsed = false; ObjectLoader.FindAndSortAllExistingSewables(); for (int i = 0; i < Sims3.Gameplay.Queries.GetObjects <PhoneSmart>().Length; i++) { if (Sims3.Gameplay.Queries.GetObjects <PhoneSmart>()[i] != null) { AddInteractionsPhone(Sims3.Gameplay.Queries.GetObjects <PhoneSmart>()[i]); } } foreach (Computer computer in Sims3.Gameplay.Queries.GetObjects <Computer>()) { if (computer != null) { AddInteractionsComputer(computer); } } // Save/cache our loaded key to make discovery quicker. Rather than always looping through it. for (int i = 0; i < ObjectLoader.sewableSettings.Count; i++) { Pattern.mStoredPatternsKeySettingsList.Add(ObjectLoader.sewableSettings[i].key); } foreach (KeyValuePair <ulong, bool> keyvalues in GlobalOptionsSewingTable.retrieveData.whoIsInPatternClub) { print("Re-assigned the mailbox alarm!"); SimDescription description = SimDescription.Find(keyvalues.Key); Mailbox mailbox = Mailbox.GetMailboxOnLot(description.LotHome); mailbox.AddAlarmDay(1f, DaysOfTheWeek.Thursday, GlobalOptionsSewingTable.SendPatterns, "Mailbox: Pattern club " + description.mSimDescriptionId.ToString(), AlarmType.AlwaysPersisted); } //mPatternClubAlarm = AlarmManager.Global.AddAlarmDay(1f, DaysOfTheWeek.Thursday, GlobalOptionsSewingTable.SendPatterns, "Mailbox: Pattern club", AlarmType.NeverPersisted, null); //mWearClothing = AlarmManager.Global.AddAlarmRepeating(24f, TimeUnit.Hours, WearGiftedClothing, 1f, TimeUnit.Days, "Wear gifted clothing", AlarmType.AlwaysPersisted, null); EventTracker.AddListener(EventTypeId.kBoughtObject, new ProcessEventDelegate(OnObjectChanged)); EventTracker.AddListener(EventTypeId.kInventoryObjectAdded, new ProcessEventDelegate(OnObjectChanged)); EventTracker.AddListener(EventTypeId.kObjectStateChanged, new ProcessEventDelegate(OnObjectChanged)); }
public override bool Run() { base.StandardEntry(); if (!base.Target.StartComputing(this, SurfaceHeight.Table, true)) { base.StandardExit(); return(false); } //mActor = Actor; base.Target.StartVideo(Computer.VideoType.Browse); base.BeginCommodityUpdates(); base.AnimateSim("WorkTyping"); bool flag = TwoButtonDialog.Show(Localization.LocalizeString("Lyralei/Localized/JoinPatternClubDesc:InteractionName", new object[0]) + kCost.ToString(), Localization.LocalizeString("Lyralei/Localized/JoinPatternClubYES:InteractionName", new object[0]), Localization.LocalizeString("Lyralei/Localized/JoinPatternClubNO:InteractionName", new object[0])); if (flag) { if (base.Actor.FamilyFunds >= kCost) { base.Actor.ModifyFunds(-kCost); } else if (!GameUtils.IsFutureWorld()) { //base.Actor.UnpaidBills += kCost; StyledNotification.Format format = new StyledNotification.Format(Localization.LocalizeString("Lyralei/Localized/NotEnoughMoney:Test", new object[0]), base.Actor.ObjectId, base.Target.ObjectId, StyledNotification.NotificationStyle.kGameMessageNegative); StyledNotification.Show(format); } Mailbox mailbox = Mailbox.GetMailboxOnLot(base.Actor.LotHome); mailbox.AddAlarmDay(1f, DaysOfTheWeek.Thursday, GlobalOptionsSewingTable.SendPatterns, "Mailbox: Pattern club " + base.Actor.mSimDescription.mSimDescriptionId.ToString(), AlarmType.AlwaysPersisted); GlobalOptionsSewingTable.retrieveData.whoIsInPatternClub.Add(Actor.SimDescription.mSimDescriptionId, true); base.Actor.ShowTNSIfSelectable(Localization.LocalizeString("Lyralei/Localized/JoinedPatternClub:InteractionName", new object[0]), StyledNotification.NotificationStyle.kGameMessagePositive); } base.Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false); base.EndCommodityUpdates(flag); base.StandardExit(); return(true); }
public static PlaceResults LocateHomeAndPlaceSimsAtVacationWorld(Household household, ref Sim simToSelect) { PlaceResults results = PlaceResults.Failure; Common.StringBuilder msg = new Common.StringBuilder("LocateHomeAndPlaceSimsAtVacationWorld" + Common.NewLine); try { if (household != null) { msg += "A"; if (GameStates.DestinationTravelWorld == WorldName.University) { Dictionary <SimDescription, AcademicDegreeManager> managers = new Dictionary <SimDescription, AcademicDegreeManager>(); try { foreach (SimDescription sim in Households.All(household)) { if (sim.CareerManager == null) { continue; } managers[sim] = sim.CareerManager.DegreeManager; if ((sim.ChildOrBelow) || (sim.IsPet)) { sim.CareerManager.mDegreeManager = null; } else if ((sim.CareerManager.DegreeManager != null) && (sim.CareerManager.DegreeManager.EnrollmentCouseLoad == 0)) { sim.CareerManager.mDegreeManager = null; } } TravelUtil.MoveIntoUniversityHousehold(household); foreach (SimDescription sim in Households.All(household)) { CustomAcademicDegrees.AdjustCustomAcademics(sim); } } finally { foreach (SimDescription sim in Households.All(household)) { if (sim.CareerManager == null) { continue; } AcademicDegreeManager manager; if (!managers.TryGetValue(sim, out manager)) { continue; } sim.CareerManager.mDegreeManager = manager; } } results = PlaceResults.BaseCamp; } else { TravelUtil.ProcessDeedsAndMoveInHousehold(household); if (household.LotHome == null) { msg += "B"; bool manual = false; Lot choice = PromptForLot(); if (choice == null) { choice = FindLot(); } else { manual = true; } if (choice != null) { msg += "C"; msg += Common.NewLine + choice.Name + Common.NewLine; choice.MoveIn(household); Mailbox mailboxOnLot = Mailbox.GetMailboxOnLot(choice); if (mailboxOnLot != null) { mailboxOnLot.ListenToReturnFromWorld(); } if (household.LotHome != null) { msg += "D"; if (manual) { results = PlaceResults.BaseCamp; } else { results = PlaceResults.Residential; } } } } else { msg += "E"; results = PlaceResults.BaseCamp; } } if (household.LotHome != null) { msg += "F"; foreach (Service service in Services.AllServices) { if (service == null) { continue; } if (service.DefaultIsRequested()) { continue; } service.MakeServiceRequest(household.LotHome, false, ObjectGuid.InvalidObjectGuid); } TravelUtil.TriggerTutorial(household); TravelUtil.PlaceSimsOnSafeSpots(household, ref simToSelect); } } } catch (Exception e) { Traveler.InsanityException(msg, e); } finally { Traveler.InsanityWriteLog(msg); } return(results); }
public static PlaceResults LocateHomeAndPlaceSimsAtVacationWorld(Household household, ref Sim simToSelect) { PlaceResults results = PlaceResults.Failure; Common.StringBuilder msg = new Common.StringBuilder("LocateHomeAndPlaceSimsAtVacationWorld" + Common.NewLine); try { if (household != null) { msg += "A"; if (GameStates.DestinationTravelWorld == WorldName.University) { Dictionary <SimDescription, AcademicDegreeManager> managers = new Dictionary <SimDescription, AcademicDegreeManager>(); try { foreach (SimDescription sim in Households.All(household)) { if (sim.CareerManager == null) { continue; } managers[sim] = sim.CareerManager.DegreeManager; if ((sim.ChildOrBelow) || (sim.IsPet)) { sim.CareerManager.mDegreeManager = null; } else if ((sim.CareerManager.DegreeManager != null) && (sim.CareerManager.DegreeManager.EnrollmentCouseLoad == 0)) { sim.CareerManager.mDegreeManager = null; } } TravelUtil.MoveIntoUniversityHousehold(household); foreach (SimDescription sim in Households.All(household)) { CustomAcademicDegrees.AdjustCustomAcademics(sim); } } finally { foreach (SimDescription sim in Households.All(household)) { if (sim.CareerManager == null) { continue; } AcademicDegreeManager manager; if (!managers.TryGetValue(sim, out manager)) { continue; } sim.CareerManager.mDegreeManager = manager; } } results = PlaceResults.BaseCamp; } else { TravelUtil.ProcessDeedsAndMoveInHousehold(household); if (household.LotHome == null) { msg += "B"; bool manual = false; Lot choice = PromptForLot(); if (choice == null) { choice = FindLot(); } else { manual = true; } if (choice != null) { msg += "C"; msg += Common.NewLine + choice.Name + Common.NewLine; choice.MoveIn(household); Mailbox mailboxOnLot = Mailbox.GetMailboxOnLot(choice); if (mailboxOnLot != null) { mailboxOnLot.ListenToReturnFromWorld(); } if (household.LotHome != null) { msg += "D"; if (manual) { results = PlaceResults.BaseCamp; } else { results = PlaceResults.Residential; } } } } else { msg += "E"; results = PlaceResults.BaseCamp; } } if (household.LotHome != null) { msg += "F"; foreach (Service service in Services.AllServices) { if (service == null) { continue; } if (service.DefaultIsRequested()) { continue; } service.MakeServiceRequest(household.LotHome, false, ObjectGuid.InvalidObjectGuid); } TravelUtil.TriggerTutorial(household); TravelUtil.PlaceSimsOnSafeSpots(household, ref simToSelect); // core block in pusharriveinteraction on ITimePortal preventing teens who travel alone from getting the arrive interaction thus // appearing invisible bool flag = true; foreach (SimDescription desc in household.SimDescriptions) { if (desc.YoungAdultOrAbove) { flag = false; break; } } ITimePortal[] portalArray; if (flag && ArriveHomeBehaviorInVacationWorld.ShouldArriveByTimePortal(household.LotHome, out portalArray)) { new Common.AlarmTask(3f, TimeUnit.Minutes, PushArriveHomeInteractionEx); } } } } catch (Exception e) { Traveler.InsanityException(msg, e); } finally { Traveler.InsanityWriteLog(msg); } return(results); }
protected override bool PrivateUpdate(ScenarioFrame frame) { SimDescription head = SimTypes.HeadOfFamily(House); Household lotOwner = Money.GetDeedOwner(House.LotHome); if ((lotOwner != null) && (lotOwner != House)) { if (Money.Allow(this, SimTypes.HeadOfFamily(lotOwner))) { int rent = (int)(ManagerLot.GetUnfurnishedLotCost(House.LotHome, 0) * GetValue <RentMultipleOption, int>(head) / 100f); if (rent != 0) { Money.AdjustFunds(House, "Rent", -rent); Money.AdjustFunds(lotOwner, "Rent", rent); } } } int owed = 0; bool shouldBill = Money.ShouldBillHouse(House); if (shouldBill) { if (House.LotHome == null) { return(false); } if (SimTypes.IsSpecial(House)) { return(false); } float standardTaxRate = GetValue <TaxRateOption, int>(head); if (!House.LotHome.IsApartmentLot) { owed += (int)(ComputeNetWorthOfObjectsInHousehold(House, true) * standardTaxRate / 100f); } int valueOfAllVacationHomes = House.RealEstateManager.GetValueOfAllVacationHomes(); owed += (int)Math.Round(valueOfAllVacationHomes * RealEstateManager.kPercentageOfVacationHomeValueBilled); Dictionary <int, List <float> > dictionary = new Dictionary <int, List <float> >(); foreach (IReduceBills bills in House.LotHome.GetObjects <IReduceBills>()) { List <float> list; int key = bills.ReductionArrayIndex(); float item = bills.PercentageReduction(); if (dictionary.TryGetValue(key, out list)) { list.Add(item); } else { List <float> list2 = new List <float>(); list2.Add((float)bills.MaxNumberContributions()); list2.Add(item); dictionary.Add(key, list2); } } foreach (KeyValuePair <int, List <float> > pair in dictionary) { int num5 = (int)pair.Value[0]; pair.Value.RemoveAt(0); pair.Value.Sort(); int count = pair.Value.Count; num5 = Math.Min(num5, count); float num7 = 0f; for (int i = 1; i <= num5; i++) { num7 += pair.Value[count - i]; } int amount = (int)(owed * num7); try { House.MoneySaved(pair.Key, (uint)amount); } catch { if ((House.mMoneySaved == null) || (House.mMoneySaved.Length != 3)) { House.mMoneySaved = new uint[3]; } } owed -= amount; } } bool debtRepayed = false; int loanPayment = 0; if ((House == Household.ActiveHousehold) && (GetValue <UnifiedBillingOption, bool>())) { int debt = GetValue <DebtOption, int>(House); if (debt > 0) { int debtPaydown = 0; float percent = GetValue <DebtPayDownScenario.ActivePercentOption, int>(); if (percent > 0) { debtPaydown = (int)(debt * (percent / 100f)); if (debtPaydown == 0) { debtPaydown = debt; } } else { debtPaydown = GetValue <DebtPayDownScenario.ActiveOption, int>(); } if (debt > debtPaydown) { AddStat("Paydown", debtPaydown); loanPayment = debtPaydown; owed += debtPaydown; AddValue <DebtOption, int>(House, -debtPaydown); } else { AddStat("Paydown", debt); loanPayment = debt; owed += debt; SetValue <DebtOption, int>(House, 0); debtRepayed = true; } } } AddStat("Owed", owed); if ((House != Household.ActiveHousehold) || ((GetValue <AutoActiveBillingOption, bool>()) && (Money.ProgressionEnabled))) { Money.AdjustFunds(House, "PayLoan", -loanPayment); Money.AdjustFunds(House, "Bills", -(owed - loanPayment)); if ((debtRepayed) && (GetValue <DebtOption, int>(House) == 0)) { Stories.PrintStory(Households, "NoMoreDebt", House, null, ManagerStory.StoryLogging.Full); } } else { if (shouldBill) { owed += (int)House.UnpaidBills; } if (owed != 0x0) { if (Sims3.SimIFace.Environment.HasEditInGameModeSwitch) { AddValue <DebtOption, int>(House, owed); House.UnpaidBills = 0; } else if (HouseholdsEx.NumSims(House) > 0x0) { Bill bill = GlobalFunctions.CreateObjectOutOfWorld("Bill") as Bill; if (bill != null) { bill.Amount = (uint)owed; House.UnpaidBills = 0; Mailbox mailboxOnLot = Mailbox.GetMailboxOnLot(House.LotHome); if (mailboxOnLot != null) { mailboxOnLot.AddMail(bill, false); bill.OriginatingHousehold = House; Mailbox.AddJunkMail(mailboxOnLot); } } } } } return(false); }