Exemplo n.º 1
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (!Romances.BumpToHighestState(this, Sim, Target))
            {
                IncStat("Bump Failure");
                return(false);
            }
            else
            {
                SetElapsedTime <DayOfLastPartnerOption>(Sim);
                SetElapsedTime <DayOfLastPartnerOption>(Target);

                SetElapsedTime <DayOfLastRomanceOption>(Sim);
                SetElapsedTime <DayOfLastRomanceOption>(Target);

                Romances.HandleMarriageName(Sim, Target, false);

                if (OnGatheringScenario != null)
                {
                    OnGatheringScenario(this, frame);
                }
                return(true);
            }
        }
Exemplo n.º 2
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);
        }