Пример #1
0
        public static int CountEmptyHomes()
        {
            int count = 0;

            foreach (Lot lot in LotManager.AllLots)
            {
                if (!lot.IsResidentialLot)
                {
                    continue;
                }

                Lot.LotMetrics metrics = new Lot.LotMetrics();
                lot.GetLotMetrics(ref metrics);

                if (metrics.FridgeCount <= 0)
                {
                    continue;
                }

                if (metrics.BedCount <= 0)
                {
                    continue;
                }

                count++;
            }

            return(count);
        }
Пример #2
0
        public Lot FindLot(int funds, List <SimDescription> sims)
        {
            List <Lot> choices = new List <Lot>();

            foreach (Lot lot in LotManager.AllLots)
            {
                if (lot.Household != null)
                {
                    continue;
                }

                if (lot.IsWorldLot)
                {
                    continue;
                }

                if (!lot.IsResidentialLot)
                {
                    continue;
                }

                Lot.LotMetrics metrics = new Lot.LotMetrics();
                lot.GetLotMetrics(ref metrics);

                if (metrics.FridgeCount == 0)
                {
                    continue;
                }

                if ((funds > 0) && (lot.Cost > funds))
                {
                    continue;
                }

                if (sims != null)
                {
                    if (!Satisfies(lot, sims))
                    {
                        continue;
                    }
                }

                choices.Add(lot);
            }

            if (choices.Count == 0)
            {
                return(null);
            }

            choices.Sort(new Comparison <Lot>(SortByCost));

            return(choices[0]);
        }
Пример #3
0
        public static Lot FindLot()
        {
            for (int i = 0; i < 2; i++)
            {
                Lot choice = null;

                foreach (Lot lot in LotManager.AllLots)
                {
                    if (!lot.IsResidentialLot)
                    {
                        continue;
                    }

                    if (lot.IsWorldLot)
                    {
                        continue;
                    }

                    if (lot.Household != null)
                    {
                        continue;
                    }

                    if (i == 0)
                    {
                        if (lot.ResidentialLotSubType == ResidentialLotSubType.kEP1_PlayerOwnable)
                        {
                            continue;
                        }

                        Lot.LotMetrics metrics = new Lot.LotMetrics();
                        lot.GetLotMetrics(ref metrics);
                        if (metrics.FridgeCount == 0)
                        {
                            continue;
                        }
                    }

                    if ((choice == null) || (choice.Cost > lot.Cost))
                    {
                        choice = lot;
                    }
                }

                if (choice != null)
                {
                    return(choice);
                }
            }

            return(null);
        }
Пример #4
0
        public override void Apply()
        {
            string msg = "Apply" + Common.NewLine;

            try
            {
                try
                {
                    sbMovingCurrentlyInProgress = true;
                    ProgressDialog.Show(Common.LocalizeEAString("Ui/Caption/Global:Processing"), false);

                    Household sourceHousehold = mSourceHousehold;

                    Lot sourceLot = sourceHousehold.LotHome;

                    mTempHousehold.ClearSilent();
                    mTempHousehold.Destroy();
                    mTempHousehold = null;

                    msg += "A";

                    ParentsLeavingTownSituation situation = ParentsLeavingTownSituation.FindParentsGoneSituationForHousehold(sourceHousehold);
                    if ((situation != null) && (ParentsLeavingTownSituation.Adults != null))
                    {
                        bool freeVacation = false;
                        foreach (ISimDescription targetSim in mTargetSimList.Keys)
                        {
                            if (ParentsLeavingTownSituation.Adults.Contains(targetSim.SimDescriptionId))
                            {
                                freeVacation = true;
                                break;
                            }
                        }

                        if (!freeVacation)
                        {
                            bool flag3 = false;
                            foreach (ISimDescription iSourceSim in mSourceSimList.Keys)
                            {
                                if (iSourceSim.TeenOrAbove && !ParentsLeavingTownSituation.Adults.Contains(iSourceSim.SimDescriptionId))
                                {
                                    SimDescription sourceSim = iSourceSim as SimDescription;
                                    if ((sourceSim != null) && (sourceSim.CreatedSim != null))
                                    {
                                        flag3 = true;
                                        break;
                                    }
                                }
                            }
                            freeVacation = !flag3;
                        }

                        if (freeVacation)
                        {
                            situation.BringParentsBack();
                        }
                    }

                    msg += "B";

                    Household targetHousehold = mPreselectedHousehold;

                    // Must be ahead of check mSourceSimList
                    Lot targetLot = null;
                    if (targetHousehold != null)
                    {
                        targetLot = targetHousehold.LotHome;
                    }

                    if (targetHousehold == null)
                    {
                        if (mSourceSimList.Count == 0)
                        {
                            targetHousehold = sourceHousehold;
                        }
                    }

                    if (targetLot == null)
                    {
                        targetLot = mTargetLot;
                    }

                    if ((mMoveOut) && (targetLot == null))
                    {
                        msg += "B1";

                        List<Lot> allChoices = new List<Lot>();
                        List<Lot> affordable = new List<Lot>();
                        foreach (Lot lot in LotManager.AllLots)
                        {
                            if (!string.IsNullOrEmpty(Households.IsValidResidentialLot(lot))) continue;

                            Lot.LotMetrics metrics = new Lot.LotMetrics();
                            lot.GetLotMetrics(ref metrics);

                            if (metrics.FridgeCount == 0) continue;

                            allChoices.Add(lot);

                            if (Mover.GetLotCost(lot) < mNewTargetFunds)
                            {
                                affordable.Add(lot);
                            }
                        }

                        if (affordable.Count > 0)
                        {
                            affordable.Sort(new Comparison<Lot>(Households.SortByCost));

                            targetLot = affordable[0];
                        }
                        else if (allChoices.Count > 0)
                        {
                            if ((!Mover.Settings.mFreeRealEstate) && (!AcceptCancelDialog.Show(Common.Localize("NoAffordable:Prompt"))))
                            {
                                return;
                            }

                            allChoices.Sort(new Comparison<Lot>(Households.SortByCost));

                            targetLot = allChoices[0];
                        }

                        if (targetLot == null)
                        {
                            if (!AcceptCancelDialog.Show(Common.Localize("Homeless:Prompt")))
                            {
                                return;
                            }
                        }
                        else
                        {
                            mNewTargetFunds -= Mover.GetLotCost(targetLot);

                            if (mNewTargetFunds < 0)
                            {
                                mNewTargetFunds = 0;
                            }
                        }
                    }

                    msg += "C";

                    if (targetHousehold == null)
                    {
                        targetHousehold = Household.Create();
                    }

                    Household activeHouse = targetHousehold;
                    Household saleHouse = sourceHousehold;
                    if (mSourceHouseholdActive)
                    {
                        msg += "C1";

                        activeHouse = sourceHousehold;
                        saleHouse = targetHousehold;
                    }

                    Lot saleLot = saleHouse.LotHome;

                    Dictionary<ObjectGuid, ObjectGuid> originalsToClones = null;

                    if (mSellHome)
                    {
                        msg += "C2";

                        if ((mPackFurniture) && (saleHouse != Household.NpcHousehold))
                        {
                            PackFurnitureEx(saleHouse.LotHome, activeHouse, ref originalsToClones);
                        }

                        saleHouse.MoveOut();
                    }

                    if (targetHousehold != null)
                    {
                        msg += "C3";

                        if ((targetLot != null) && (targetHousehold.LotHome != targetLot))
                        {
                            targetHousehold.MoveOut();

                            // Perform this preior to MoveIn() to inform StoryProgresion that it does not need to adjust lot funds
                            Mover.PresetStoryProgressionLotHome(targetLot, targetHousehold);
                            targetLot.MoveIn(targetHousehold);

                            targetHousehold.AddGreetedLotToHousehold(targetLot, ObjectGuid.InvalidObjectGuid);
                        }

                        if (mTargetSimList.Count > 0)
                        {
                            if (targetHousehold != sourceHousehold)
                            {
                                targetHousehold.BioText = mTargetHouseholdDescription;
                                targetHousehold.Name = mTargetHouseholdName;
                            }

                            targetHousehold.SetFamilyFunds(mNewTargetFunds);
                        }
                    }

                    msg += "D";

                    if (sourceHousehold != null)
                    {
                        msg += "D1";

                        if ((sourceHousehold != Household.NpcHousehold) && (mSourceSimList.Count > 0))
                        {
                            msg += "D2";

                            sourceHousehold.SetFamilyFunds(mNewSourceFunds);
                            sourceHousehold.BioText = mSourceHouseholdDescription;
                            sourceHousehold.Name = mSourceHouseholdName;
                        }
                    }

                    if (mSellHome)
                    {
                        msg += "E";

                        List<SimDescription> otherSims = new List<SimDescription>();

                        List<Sim> movingSims = new List<Sim>();
                        foreach (SimDescription simDesc in Households.All(saleHouse))
                        {
                            Sim sim = simDesc.CreatedSim;
                            if (sim != null)
                            {
                                movingSims.Add(sim);

                                EventTracker.SendEvent(EventTypeId.kMovedHouses, sim);
                            }
                            else
                            {
                                otherSims.Add(simDesc);
                            }

                            MidlifeCrisisManager.OnMoved(simDesc);
                        }

                        if (saleHouse != activeHouse)
                        {
                            Households.TransferData(activeHouse, saleHouse);
                        }

                        foreach (SimDescription simDesc in otherSims)
                        {
                            if (simDesc.Household != null)
                            {
                                simDesc.Household.Remove(simDesc, false);
                            }

                            activeHouse.Add(simDesc);
                        }

                        HouseholdEx.AddSims(activeHouse, movingSims, saleHouse, (saleHouse != activeHouse), true, Mover.Settings.mDreamCatcher);

                        UpdateAttributesForNewSimsEx(true, movingSims);

                        Sim tokenSim = null;

                        for (int i = movingSims.Count - 1; i >= 0; i--)
                        {
                            Sim sim = movingSims[i];

                            if ((sim.CurrentInteraction is ICountsAsWorking) || (sim.GetSituationOfType<HostedSituation>() != null))
                            {
                                if (tokenSim == null)
                                {
                                    tokenSim = movingSims[i];
                                }

                                movingSims.RemoveAt(i);
                            }
                        }

                        if ((movingSims.Count == 0) && (tokenSim != null))
                        {
                            movingSims.Add(tokenSim);
                        }

                        if (movingSims.Count > 0)
                        {
                            MovingSituation.MoveAllActiveSimsToActiveLot(saleLot, activeHouse.LotHome, movingSims, mPackFurniture, originalsToClones);
                        }
                    }
                    else
                    {
                        msg += "F";

                        List<SimDescription> previousTarget = new List<SimDescription>(Households.All(targetHousehold));
                        List<SimDescription> previousSource = new List<SimDescription>(Households.All(sourceHousehold));

                        if (mSourceHouseholdActive)
                        {
                            msg += "F1";

                            if (mTargetSimList.Count == 0)
                            {
                                Households.TransferData(sourceHousehold, targetHousehold);
                            }
                            else if ((targetHousehold.RealEstateManager.AllProperties.Count > 0) &&
                                (Mover.Settings.mPromptTransferRealEstate) &&
                                (AcceptCancelDialog.Show(Common.Localize("TransferRealEstate:Prompt"))))
                            {
                                Households.TransferRealEstate(sourceHousehold, targetHousehold);
                            }

                            TransferSims(targetHousehold, sourceHousehold, false, (mSourceSimList.Count == 0), mTargetSimList);
                            TransferSims(sourceHousehold, targetHousehold, true, (mTargetSimList.Count == 0), mSourceSimList);
                        }
                        else
                        {
                            msg += "F2";

                            if (mSourceSimList.Count == 0)
                            {
                                Households.TransferData(targetHousehold, sourceHousehold);
                            }
                            else if ((sourceHousehold.RealEstateManager.AllProperties.Count > 0) &&
                                (Mover.Settings.mPromptTransferRealEstate) &&
                                (AcceptCancelDialog.Show(Common.Localize("TransferRealEstate:Prompt"))))
                            {
                                Households.TransferRealEstate(targetHousehold, sourceHousehold);
                            }

                            TransferSims(sourceHousehold, targetHousehold, false, (mTargetSimList.Count == 0), mSourceSimList);
                            TransferSims(targetHousehold, sourceHousehold, true, (mSourceSimList.Count == 0), mTargetSimList);
                        }

                        msg += "G";

                        if (targetHousehold.NumMembers == 0)
                        {
                            msg += "G1";

                            targetHousehold.HandleLastSimsDeath();
                        }

                        ThumbnailManager.GenerateHouseholdThumbnail(targetHousehold.HouseholdId, targetHousehold.HouseholdId, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium);

                        if (sourceHousehold.NumMembers == 0)
                        {
                            msg += "G2";

                            sourceHousehold.HandleLastSimsDeath();
                        }

                        ThumbnailManager.GenerateHouseholdThumbnail(sourceHousehold.HouseholdId, sourceHousehold.HouseholdId, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium);

                        if (GameStates.IsOnVacation)
                        {
                            using (DreamCatcher.HouseholdStore store = new DreamCatcher.HouseholdStore(activeHouse, true))
                            {
                                PlumbBob.ForceSelectActor(activeHouse.GetRandomNonRoommateSim());
                            }
                        }
                        else
                        {
                            DreamCatcher.Select(activeHouse.GetRandomNonRoommateSim(), true, Mover.Settings.mDreamCatcher, true);
                        }

                        msg += "H";

                        if ((saleHouse != null) && (saleHouse != activeHouse))
                        {
                            using (DreamCatcher.HouseholdStore store = new DreamCatcher.HouseholdStore((Household)null, Mover.Settings.mDreamCatcher))
                            {
                                foreach (Sim sim in Households.AllSims(saleHouse))
                                {
                                    msg += "H2";

                                    sim.OnBecameUnselectable();
                                }
                            }
                        }

                        foreach (Sim sim in Households.AllSims(activeHouse))
                        {
                            msg += "I2";

                            sim.ResetMapTagManager();
                        }

                        msg += "K";

                        List<Sim> sourceNewSims = new List<Sim>();
                        List<Sim> sourceMovingSims = new List<Sim>();
                        PostTransfer(sourceHousehold, targetHousehold, targetLot, previousSource, sourceMovingSims, sourceNewSims);

                        List<Sim> targetNewSims = new List<Sim>();
                        List<Sim> targetMovingSims = new List<Sim>();
                        PostTransfer(targetHousehold, sourceHousehold, sourceLot, previousTarget, targetMovingSims, targetNewSims);

                        msg += Common.NewLine + " Target Moving";
                        foreach (Sim sim in targetMovingSims)
                        {
                            msg += Common.NewLine + " " + sim.FullName;
                        }

                        msg += Common.NewLine + " Source Moving";
                        foreach (Sim sim in sourceMovingSims)
                        {
                            msg += Common.NewLine + " " + sim.FullName;
                        }

                        msg += "L";

                        if (targetHousehold == Household.ActiveHousehold)
                        {
                            msg += "L1";

                            if (targetMovingSims.Count > 0x0)
                            {
                                MovingSituation.MoveNPCsToActiveHousehold(targetHousehold.LotHome, targetMovingSims, targetNewSims);
                            }
                            else if (sourceMovingSims.Count > 0)
                            {
                                MovingSituation.MoveActiveSimsToNPCLot(sourceHousehold.LotHome, sourceMovingSims, sourceNewSims, false);
                            }
                        }
                        else
                        {
                            msg += "L2";

                            if (targetMovingSims.Count > 0x0)
                            {
                                MovingSituation.MoveActiveSimsToNPCLot(targetHousehold.LotHome, targetMovingSims, targetNewSims, false);
                            }
                            else if (sourceMovingSims.Count > 0)
                            {
                                MovingSituation.MoveNPCsToActiveHousehold(sourceHousehold.LotHome, sourceMovingSims, sourceNewSims);
                            }
                        }

                        msg += "M";

                        sbMovingCurrentlyInProgress = false;
                        TombRoomManager.OnChangeHousehold(Household.ActiveHousehold);
                    }

                    msg += "N";

                    CleanUpTempTravelHoushold();
                    CleanUpSourceTempHousehold(true);

                    mSourceSimList.Clear();
                    mTargetSimList.Clear();

                    mSourceHousehold = null;
                    mPreselectedHousehold = null;
                    if (mPreviousHouseholdSims != null)
                    {
                        mPreviousHouseholdSims.Clear();
                        mPreviousHouseholdSims = null;
                    }

                    GameEntryMovingModel.TriggerSplitMergeHouseholdsCompleteCallback();
                }
                catch (Exception e)
                {
                    Common.Exception(msg, e);
                }
                finally
                {
                    Common.DebugNotify(msg);

                    sbMovingCurrentlyInProgress = false;
                    ProgressDialog.Close();
                }
            }
            catch (ExecutionEngineException)
            { }
        }
Пример #5
0
        public override MoveValidity IsLotValid(bool isSource, ref string reason)
        {
            if (isSource)
            {
                if (mNewSourceFunds < 0)
                {
                    reason = Common.LocalizeEAString("Ui/Caption/MovingDialog:CantAfford");
                    return MoveValidity.None;
                }
            }
            else
            {
                if (mNewTargetFunds < 0)
                {
                    reason = Common.LocalizeEAString("Ui/Caption/MovingDialog:CantAfford");
                    return MoveValidity.None;
                }
            }

            if (mbForMarriage)
            {
                bool flag = mSourceSimList.ContainsKey(mMarryingSimNPC.SimDescription);
                bool flag2 = mSourceSimList.ContainsKey(mMarryingSimSelectable.SimDescription);
                if ((!flag || !flag2) && (flag || flag2))
                {
                    reason = Common.LocalizeEAString("Ui/Caption/MovingDialog:NewlywedsMustStayTogether");
                    //return MoveValidity.None;
                }
            }

            if (!isSource || !SimTypes.IsSpecial(mSourceHousehold))
            {
                if (BaseIsLotValid(this, mSourceSimList, mTargetSimList, mSourceHousehold, isSource, ref reason) == MoveValidity.None)
                {
                    return MoveValidity.None;
                }

                if (!isSource)
                {
                    bool testMetrics = !mbForMarriage;
                    if ((mPreselectedHousehold != null) && (mPreselectedHousehold.LotHome != null))
                    {
                        Lot.LotMetrics metrics = new Lot.LotMetrics();
                        mPreselectedHousehold.LotHome.GetLotMetrics(ref metrics);

                        if (metrics.BedCount < mPreselectedHousehold.NumMembers)
                        {
                            testMetrics = false;
                        }
                    }

                    int numSims = 0;
                    if ((Mover.Settings.mHomeInspection) && (testMetrics) && (mSourceHousehold.LotHome != null))
                    {
                        numSims = GameEntryMovingModel.CountSimsIncludingPregnancy(mTargetSimList, true);
                    }

                    if (mSourceHouseholdActive)
                    {
                        if (!IsLotValid(mTargetLot, mTargetHouseholdName, numSims, mSourceHouseholdActive, ref reason))
                        {
                            if (string.IsNullOrEmpty(mTargetHouseholdName))
                            {
                                return MoveValidity.None;
                            }

                            reason = Common.LocalizeEAString("Ui/Caption/MovingDialog:CantSupportPopulationOrMove");
                            if (mSourceHousehold != Household.ActiveHousehold)
                            {
                                return MoveValidity.None;
                            }

                            return MoveValidity.PlayerOnly;
                        }

                        if (mTargetLot != null)
                        {
                            return MoveValidity.All;
                        }

                        reason = Common.LocalizeEAString("Ui/Caption/MovingDialog:NeedTargetLot");
                        if (mSourceHousehold != Household.ActiveHousehold)
                        {
                            return MoveValidity.None;
                        }

                        return MoveValidity.PlayerOnly;
                    }
                    else
                    {
                        if (mTargetLot == null)
                        {
                            reason = Common.LocalizeEAString("Ui/Caption/MovingDialog:NeedTargetLot");
                            return MoveValidity.None;
                        }

                        if (mNewTargetFunds < 0x0)
                        {
                            reason = Common.LocalizeEAString("Ui/Caption/MovingDialog:CantAfford");
                            return MoveValidity.None;
                        }

                        if (!IsLotValid(mTargetLot, mTargetHouseholdName, numSims, mSourceHouseholdActive, ref reason))
                        {
                            return MoveValidity.None;
                        }
                    }
                }
                else if (mSourceSimList.Count > 0x0)
                {
                    if (mSourceHouseholdActive)
                    {
                        if (mNewSourceFunds < 0x0)
                        {
                            reason = Common.LocalizeEAString("Ui/Caption/MovingDialog:CantAfford");
                            return MoveValidity.None;
                        }
                    }
                    else
                    {
                        bool testMetrics = !mbForMarriage;
                        if ((mSourceHousehold != null) && (mSourceHousehold.LotHome != null))
                        {
                            Lot.LotMetrics metrics = new Lot.LotMetrics();
                            mSourceHousehold.LotHome.GetLotMetrics(ref metrics);

                            if (metrics.BedCount < mSourceHousehold.NumMembers)
                            {
                                testMetrics = false;
                            }
                        }

                        int numSims = 0;
                        if ((Mover.Settings.mHomeInspection) && (testMetrics))
                        {
                            numSims = GameEntryMovingModel.CountSimsIncludingPregnancy(mSourceSimList, true);
                        }

                        if ((mSourceHousehold == Household.ActiveHousehold) &&
                            (!IsLotValid(mSourceHousehold.LotHome, mSourceHouseholdName, numSims, !mSourceHouseholdActive, ref reason)))
                        {
                            reason = Common.LocalizeEAString("Ui/Caption/MovingDialog:CantSupportPopulationOrMove");
                            if (mSourceHousehold != Household.ActiveHousehold)
                            {
                                return MoveValidity.None;
                            }
                            return MoveValidity.PlayerOnly;
                        }
                    }
                }
            }
            return MoveValidity.All;
        }
Пример #6
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (mCheckRequired)
            {
                if (!mRequirement.mRequired)
                {
                    return(false);
                }
            }

            List <CASAgeGenderFlags> ageGenderRequirements = new List <CASAgeGenderFlags>();

            if ((!mRequirement.mNeedMale) && (!mRequirement.mNeedFemale))
            {
                if (BabyGenderScenario.GetGenderByFirstBorn(Manager, GetValue <GenderOption, BabyGenderScenario.FirstBornGender>(), false) == CASAgeGenderFlags.Male)
                {
                    mRequirement.mNeedMale = true;
                }
                else
                {
                    mRequirement.mNeedFemale = true;
                }
            }

            bool teenMoveIn = false;

            if (mRequirement.mMate == null)
            {
                if (RandomUtil.RandomChance(GetValue <TeenChanceOption, int>()))
                {
                    teenMoveIn = true;
                }
            }
            else if (mRequirement.mMate.Teen)
            {
                teenMoveIn = true;
            }

            if (mRequirement.mNeedMale)
            {
                CASAgeGenderFlags age = CASAgeGenderFlags.Male | CASAgeGenderFlags.Human;
                if (teenMoveIn)
                {
                    age |= CASAgeGenderFlags.Teen;
                }
                else //if ((mRequirement.CareerLevel != null) && (mRequirement.CareerLevel.Level > 5))
                {
                    age |= CASAgeGenderFlags.YoungAdult;
                    age |= CASAgeGenderFlags.Adult;
                }

                ageGenderRequirements.Add(age);
            }

            if (mRequirement.mNeedFemale)
            {
                CASAgeGenderFlags age = CASAgeGenderFlags.Female | CASAgeGenderFlags.Human;
                if (teenMoveIn)
                {
                    age |= CASAgeGenderFlags.Teen;
                }
                else if (mRequirement.mFertile)
                {
                    age |= CASAgeGenderFlags.YoungAdult;
                }
                else //((mRequirement.CareerLevel != null) && (mRequirement.CareerLevel.Level > 5) && )
                {
                    age |= CASAgeGenderFlags.YoungAdult;
                    age |= CASAgeGenderFlags.Adult;
                }

                ageGenderRequirements.Add(age);
            }

            bool singleParent = false;

            Lot familyLot = null;

            if (((mRequirement.mMate == null) || (!mCheckRequired)) && (GetValue <WholeFamilyOption, int>() > 0) && (!RandomUtil.RandomChance(GetValue <SingleSimOption, int>())))
            {
                IncStat("WholeFamily");

                familyLot = Lots.FindLot(this, null, 0, ManagerLot.FindLotFlags.CheapestHome | ManagerLot.FindLotFlags.Inspect, OnLotPriceCheck);
                if (familyLot == null)
                {
                    return(false);
                }

                if (RandomUtil.RandomChance(GetValue <ChanceOfSingleOption, int>()))
                {
                    IncStat("Single Parent");
                    singleParent = true;
                }
                else if (familyLot.CountObjects <IBedDouble>() == 0)
                {
                    if (familyLot.CountObjects <IBedSingle>() > 1)
                    {
                        IncStat("Single Parent");
                        singleParent = true;
                    }
                    else
                    {
                        IncStat("No Double Bed");
                        familyLot = null;
                    }
                }
            }

            using (SimFromBin <ManagerLot> simBin = new SimFromBin <ManagerLot>(this, Lots))
            {
                List <SimDescription> sims = new List <SimDescription>();

                CASAgeGenderFlags genders = CASAgeGenderFlags.Male | CASAgeGenderFlags.Female;

                if (familyLot != null)
                {
                    BabyGenderScenario.FirstBornGender genderPref = GetValue <GenderOption, BabyGenderScenario.FirstBornGender>();

                    bool bothGenders = true;
                    if ((genderPref == BabyGenderScenario.FirstBornGender.Male) ||
                        (genderPref == BabyGenderScenario.FirstBornGender.Female))
                    {
                        bothGenders = false;
                    }
                    else if (RandomUtil.RandomChance(GetValue <ManagerFlirt.ChanceOfGaySim, int>()))
                    {
                        bothGenders = false;
                    }

                    if (ageGenderRequirements.Count == 1)
                    {
                        if (bothGenders)
                        {
                            if ((ageGenderRequirements[0] & CASAgeGenderFlags.Male) == CASAgeGenderFlags.Male)
                            {
                                ageGenderRequirements.Add(CASAgeGenderFlags.Female | (ageGenderRequirements[0] & CASAgeGenderFlags.AgeMask));
                            }
                            else
                            {
                                ageGenderRequirements.Add(CASAgeGenderFlags.Male | (ageGenderRequirements[0] & CASAgeGenderFlags.AgeMask));
                            }
                        }
                        else
                        {
                            genders = ageGenderRequirements[0] & CASAgeGenderFlags.GenderMask;

                            ageGenderRequirements.Add(ageGenderRequirements[0]);
                        }
                    }
                }

                foreach (CASAgeGenderFlags ageGender in ageGenderRequirements)
                {
                    SimDescription sim = simBin.CreateNewSim(ageGender & CASAgeGenderFlags.AgeMask, ageGender & CASAgeGenderFlags.GenderMask, CASAgeGenderFlags.Human);
                    if (sim == null)
                    {
                        IncStat("Creation Failure");
                    }
                    else
                    {
                        sims.Add(sim);
                    }
                }

                if (familyLot == null)
                {
                    if (sims.Count > 0)
                    {
                        Add(frame, new ImmigrantMailOrderScenario(mRequirement, sims), ScenarioResult.Start);
                    }
                }
                else
                {
                    bool createChildren = true;

                    SimDescription otherParent = null;

                    List <SimDescription> parents = new List <SimDescription>(sims);
                    if (parents.Count > 1)
                    {
                        otherParent = parents[1];

                        if (parents[1].IsMale)
                        {
                            parents[0].InternalIncreaseGenderPreferenceMale();
                        }
                        else
                        {
                            parents[0].InternalIncreaseGenderPreferenceFemale();
                        }

                        if (parents[0].IsMale)
                        {
                            parents[1].InternalIncreaseGenderPreferenceMale();
                        }
                        else
                        {
                            parents[1].InternalIncreaseGenderPreferenceFemale();
                        }

                        Relationship relation = Relationship.Get(parents[0], parents[1], true);
                        if (relation != null)
                        {
                            relation.MakeAcquaintances();
                        }

                        if (GameUtils.IsUniversityWorld())
                        {
                            createChildren = true;
                            IncStat("Immigrant Friends");
                        }
                        else if (!RandomUtil.RandomChance(GetValue <ChanceOfFriendsOption, int>()))
                        {
                            Dictionary <string, List <News.NewsTuning.ArticleTuning> > namedArticles = News.sNewsTuning.mNamedArticles;

                            try
                            {
                                // Doing so stops Marriage notices of imported sims from appearing in the newspaper
                                News.sNewsTuning.mNamedArticles = new Dictionary <string, List <News.NewsTuning.ArticleTuning> >();

                                if (RandomUtil.RandomChance(GetValue <ChanceOfPartnerOption, int>()))
                                {
                                    IncStat("Immigrant Partners");

                                    while (relation.CurrentLTR != LongTermRelationshipTypes.Partner)
                                    {
                                        if (!Romances.BumpToHigherState(this, parents[0], parents[1]))
                                        {
                                            break;
                                        }
                                    }
                                }
                                else
                                {
                                    if (!Romances.BumpToHighestState(this, parents[0], parents[1]))
                                    {
                                        IncStat("Unmarriable");
                                        createChildren = false;
                                    }
                                    else
                                    {
                                        parents[1].LastName = parents[0].LastName;
                                    }
                                }
                            }
                            finally
                            {
                                News.sNewsTuning.mNamedArticles = namedArticles;
                            }
                        }
                        else
                        {
                            createChildren = false;
                            IncStat("Immigrant Friends");
                        }
                    }

                    if (createChildren)
                    {
                        Lot.LotMetrics metrics = new Lot.LotMetrics();
                        familyLot.GetLotMetrics(ref metrics);

                        int totalChildren = GetValue <WholeFamilyOption, int>();
                        if (totalChildren > Options.GetValue <MaximumSizeOption, int>())
                        {
                            totalChildren = Options.GetValue <MaximumSizeOption, int>();
                        }

                        totalChildren -= parents.Count;

                        totalChildren = RandomUtil.GetInt(totalChildren - 1) + 1;

                        AddStat("Allowed Children", totalChildren);

                        int totalBeds = metrics.BedCount - parents.Count;
                        if (totalBeds > totalChildren)
                        {
                            totalBeds = totalChildren;
                        }

                        AddStat("Available Beds", totalBeds);

                        if (!GameUtils.IsUniversityWorld())
                        {
                            int numCribs = RandomUtil.GetInt((int)familyLot.CountObjects <Sims3.Gameplay.Objects.Beds.Crib>());

                            // Create the children
                            if (numCribs > 2)
                            {
                                numCribs = 2;
                            }

                            if (numCribs > totalChildren)
                            {
                                numCribs = totalChildren;
                            }

                            AddStat("Available Cribs", numCribs);

                            for (int i = 0; i < numCribs; i++)
                            {
                                SimDescription sim = simBin.CreateNewSim(parents[0], otherParent, CASAgeGenderFlags.Toddler, genders, parents[0].Species, true);
                                if (sim == null)
                                {
                                    IncStat("Creation Failure");
                                }
                                else
                                {
                                    sims.Add(sim);

                                    totalBeds--;
                                }
                            }

                            if ((!parents[0].Teen) && ((otherParent == null) || (!otherParent.Teen)))
                            {
                                for (int i = 0; i < totalBeds; i++)
                                {
                                    SimDescription sim = simBin.CreateNewSim(parents[0], otherParent, CASAgeGenderFlags.Child | CASAgeGenderFlags.Teen, genders, parents[0].Species, true);
                                    if (sim == null)
                                    {
                                        IncStat("Creation Failure");
                                    }
                                    else
                                    {
                                        sims.Add(sim);
                                    }
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < totalBeds; i++)
                            {
                                SimDescription sim = simBin.CreateNewSim(CASAgeGenderFlags.YoungAdult | CASAgeGenderFlags.Adult, genders, parents[0].Species);
                                if (sim == null)
                                {
                                    IncStat("Creation Failure");
                                }
                                else
                                {
                                    sims.Add(sim);
                                }
                            }
                        }

                        if ((singleParent) && (otherParent != null))
                        {
                            sims.Remove(otherParent);

                            parents.Remove(otherParent);

                            if (otherParent.Partner != null)
                            {
                                otherParent.Partner.Partner = null;
                                otherParent.Partner         = null;
                            }

                            otherParent.Dispose(true, false, true);
                        }
                    }
                }

                if ((GameUtils.IsInstalled(ProductVersion.EP5)) &&
                    (RandomUtil.RandomChance(GetValue <PetChanceOption, int>())))
                {
                    List <CASAgeGenderFlags> choices = new List <CASAgeGenderFlags>();

                    foreach (SimDescription sim in sims)
                    {
                        PetAdoptionBaseScenario.GetPossibleSpecies(this, familyLot, sim, false, choices);
                    }

                    AddStat("Pet Choices", choices.Count);

                    if (choices.Count > 0)
                    {
                        int numberPets = RandomUtil.GetInt(1, GetValue <MaximumPetsOption, int>() - 1);

                        AddStat("Pet Immigrants", numberPets);

                        for (int i = 0; i < numberPets; i++)
                        {
                            CASAgeGenderFlags species = RandomUtil.GetRandomObjectFromList(choices);
                            if (Sims.HasEnough(this, species))
                            {
                                continue;
                            }

                            SimDescription pet = simBin.CreateNewSim(CASAgeGenderFlags.Child | CASAgeGenderFlags.Adult | CASAgeGenderFlags.Elder, CASAgeGenderFlags.Male | CASAgeGenderFlags.Female, species);
                            if (pet != null)
                            {
                                pet.LastName = sims[0].LastName;

                                sims.Add(pet);
                            }
                            else
                            {
                                IncStat("Pet Creation Fail");
                            }
                        }
                    }
                }

                Add(frame, new ImmigrantMoveInScenario(sims), ScenarioResult.Start);
                Add(frame, new NewImmigrantScenario(sims, mRequirement), ScenarioResult.Success);
            }

            return(true);
        }
Пример #7
0
        public static Lot PromptForLot()
        {
            Lot baseCampLot = LotManager.GetBaseCampLot();

            if (!UIUtils.IsOkayToStartModalDialog(false, true))
            {
                return(null);
            }

            List <IMapTagPickerInfo> mapTagPickerInfos = new List <IMapTagPickerInfo>();

            mapTagPickerInfos.Add(new MapTagPickerLotInfo(baseCampLot, MapTagType.BaseCamp));
            Dictionary <ulong, bool> dictionary = new Dictionary <ulong, bool>();

            foreach (Lot lot in LotManager.AllLots)
            {
                if (!lot.IsResidentialLot)
                {
                    continue;
                }

                if (lot.IsWorldLot)
                {
                    continue;
                }

                if (lot.Household != null)
                {
                    continue;
                }

                if (lot.ResidentialLotSubType == ResidentialLotSubType.kEP1_PlayerOwnable)
                {
                    continue;
                }

                Lot.LotMetrics metrics = new Lot.LotMetrics();
                lot.GetLotMetrics(ref metrics);
                if (metrics.FridgeCount == 0)
                {
                    continue;
                }

                if ((lot != null) && !dictionary.ContainsKey(lot.LotId))
                {
                    dictionary[lot.LotId] = true;
                    mapTagPickerInfos.Add(new MapTagPickerLotInfo(lot, MapTagType.AvailableHousehold));
                }
            }

            GameUtils.EnableSceneDraw(true);
            LoadingScreenController.Unload();
            while (LoadingScreenController.Instance != null)
            {
                SpeedTrap.Sleep(0);
            }

            IMapTagPickerInfo info = MapTagPickerDialog.Show(mapTagPickerInfos, TravelUtil.LocalizeString("ChooseHomeLot", new object[0]), TravelUtil.LocalizeString("Accept", new object[0]), false);

            if (info == null)
            {
                return(null);
            }

            return(LotManager.GetLot(info.LotId));
        }
Пример #8
0
        public static Lot FindLot()
        {
            for (int i = 0; i < 2; i++)
            {
                Lot choice = null;

                foreach (Lot lot in LotManager.AllLots)
                {
                    if (!lot.IsResidentialLot) continue;

                    if (lot.IsWorldLot) continue;

                    if (lot.Household != null) continue;

                    if (i == 0)
                    {
                        if (lot.ResidentialLotSubType == ResidentialLotSubType.kEP1_PlayerOwnable)
                        {
                            continue;
                        }

                        Lot.LotMetrics metrics = new Lot.LotMetrics();
                        lot.GetLotMetrics(ref metrics);
                        if (metrics.FridgeCount == 0)
                        {
                            continue;
                        }
                    }

                    if ((choice == null) || (choice.Cost > lot.Cost))
                    {
                        choice = lot;
                    }
                }

                if (choice != null) return choice;
            }

            return null;
        }
Пример #9
0
        public static Lot PromptForLot()
        {
            Lot baseCampLot = LotManager.GetBaseCampLot();
            if (!UIUtils.IsOkayToStartModalDialog(false, true))
            {
                return null;
            }

            List<IMapTagPickerInfo> mapTagPickerInfos = new List<IMapTagPickerInfo>();
            mapTagPickerInfos.Add(new MapTagPickerLotInfo(baseCampLot, MapTagType.BaseCamp));
            Dictionary<ulong, bool> dictionary = new Dictionary<ulong, bool>();

            foreach (Lot lot in LotManager.AllLots)
            {
                if (!lot.IsResidentialLot) continue;

                if (lot.IsWorldLot) continue;

                if (lot.Household != null) continue;

                if (lot.ResidentialLotSubType == ResidentialLotSubType.kEP1_PlayerOwnable)
                {
                    continue;
                }

                Lot.LotMetrics metrics = new Lot.LotMetrics();
                lot.GetLotMetrics(ref metrics);
                if (metrics.FridgeCount == 0)
                {
                    continue;
                }

                if ((lot != null) && !dictionary.ContainsKey(lot.LotId))
                {
                    dictionary[lot.LotId] = true;
                    mapTagPickerInfos.Add(new MapTagPickerLotInfo(lot, MapTagType.AvailableHousehold));
                }
            }

            GameUtils.EnableSceneDraw(true);
            LoadingScreenController.Unload();
            while (LoadingScreenController.Instance != null)
            {
                SpeedTrap.Sleep(0);
            }

            IMapTagPickerInfo info = MapTagPickerDialog.Show(mapTagPickerInfos, TravelUtil.LocalizeString("ChooseHomeLot", new object[0]), TravelUtil.LocalizeString("Accept", new object[0]), false);
            if (info == null)
            {
                return null;
            }

            return LotManager.GetLot(info.LotId);
        }
Пример #10
0
        protected bool PassesHomeInspection(Common.IStatGenerator stats, Lot lot, ICollection <HomeInspection.Reason> existingResults, IEnumerable <HomeInspection.Result> results, FindLotFlags flags)
        {
            if (lot == null)
            {
                return(false);
            }

            Lot.LotMetrics metrics = new Lot.LotMetrics();
            lot.GetLotMetrics(ref metrics);

            if (metrics.FridgeCount == 0)
            {
                stats.IncStat("Home Inspection: No Fridge");
                return(false);
            }

            if (((flags & FindLotFlags.Inspect) == FindLotFlags.Inspect) && (GetValue <RigorousNewHomeOption, bool> ()))
            {
                bool failure = false;
                foreach (HomeInspection.Result result in results)
                {
                    switch (result.mReason)
                    {
                    case HomeInspection.Reason.NoDouble:
                        continue;

                    case HomeInspection.Reason.TooFewDouble:
                        if (!GetValue <DoubleBedInspectionOption, bool>())
                        {
                            stats.IncStat("Home Inspection: " + result.mReason + " Disabled");
                            continue;
                        }
                        break;

                    case HomeInspection.Reason.TooFewCribs:
                        if ((!GetValue <CribInspectionOption, bool>()))
                        {
                            stats.IncStat("Home Inspection: " + result.mReason + " Disabled");
                            continue;
                        }
                        else if (existingResults.Contains(HomeInspection.Reason.TooFewCribs))
                        {
                            stats.IncStat("Home Inspection: " + result.mReason + " Existing Infraction");
                            continue;
                        }
                        break;

                    case HomeInspection.Reason.TooFewBeds:
                        if (GetValue <DoubleBedInspectionOption, bool>())
                        {
                            stats.IncStat("Home Inspection: " + result.mReason + " Disabled");
                            continue;
                        }
                        break;

                    case HomeInspection.Reason.TooFewStalls:
                        if (result.mExisting > 0)
                        {
                            stats.IncStat("Home Inspection: " + result.mReason + " At Least One");
                            continue;
                        }
                        // Never move horses to a lot that has no stalls
                        break;

                    case HomeInspection.Reason.TooFewPetBeds:
                        if (((flags & FindLotFlags.InspectPets) != FindLotFlags.InspectPets))
                        {
                            stats.IncStat("Home Inspection: " + result.mReason + " Not Checking");
                            continue;
                        }
                        else if (!GetValue <PetInspectionOption, bool>())
                        {
                            stats.IncStat("Home Inspection: " + result.mReason + " Disabled");
                            continue;
                        }
                        else if (existingResults.Contains(HomeInspection.Reason.TooFewPetBeds))
                        {
                            stats.IncStat("Home Inspection: " + result.mReason + " Existing Infraction");
                            continue;
                        }
                        break;
                    }

                    stats.AddStat("Home Inspection: " + result.mReason + " Existing", result.mExisting);
                    stats.AddStat("Home Inspection: " + result.mReason + " Required", result.mRequired);
                    failure = true;
                }

                if (failure)
                {
                    return(false);
                }
            }

            return(true);
        }