コード例 #1
0
 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();
                         }
                     }
                 }
             }
         }
     }
 }
コード例 #2
0
        private void OnTakeMailFromParty(object sender, RoutedEventArgs e)
        {
            int numSent = 0;

            for (int i = 0; i < 6; i++)
            {
                if (i < mailbox.PartyMailCount && mailbox[i, true] != null)
                {
                    if (mailbox.HasRoomForMail)
                    {
                        mailbox.AddMail(mailbox[i, true]);
                        mailbox[i, true] = null;
                    }
                    else
                    {
                        PokeManager.ManagerGameSave.Mailbox.AddMail(mailbox[i, true]);
                        mailbox[i, true] = null;
                        numSent++;
                    }
                }
            }
            foreach (IPokemon pokemon in mailbox.GameSave.PokePC.Party)
            {
                if (pokemon.IsHoldingMail)
                {
                    pokemon.HeldItemID = 0;
                }
            }
            if (numSent > 0)
            {
                TriggerMessageBox.Show(Window.GetWindow(this), "The mailbox filled up before all the mail could be stored. The rest was sent to " + PokeManager.Settings.ManagerNickname, "Mailbox Full");
            }
            buttonTakeMail.IsEnabled = false;
        }
コード例 #3
0
        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);
        }