protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            foreach (Situation situation in Situation.sAllSituations)
            {
                SocialWorkerAdoptionSituation adoption = situation as SocialWorkerAdoptionSituation;
                if (adoption == null)
                {
                    continue;
                }

                if (adoption.mAdoptingParent != Event.mActor)
                {
                    continue;
                }

                SocialWorkerAdoptionSituation.InstantiateNewKid childSit = adoption.Child as SocialWorkerAdoptionSituation.InstantiateNewKid;
                if (childSit == null)
                {
                    continue;
                }

                Sim oldChild = childSit.mAdoptedChild;

                using (SimFromBin <ManagerLot> simBin = new SimFromBin <ManagerLot>(this, Lots))
                {
                    SimDescription newChild = simBin.CreateNewSim(oldChild.SimDescription.Age, oldChild.SimDescription.Gender, CASAgeGenderFlags.Human);
                    if (newChild == null)
                    {
                        IncStat("Creation Failure");
                        return(false);
                    }

                    newChild.WasAdopted = true;

                    adoption.mAdoptingParent.Household.Remove(oldChild.SimDescription);

                    adoption.mAdoptingParent.Household.Add(newChild);
                    adoption.mAdoptingParent.Genealogy.AddChild(newChild.Genealogy);

                    newChild.FirstName = oldChild.FirstName;
                    newChild.LastName  = oldChild.LastName;

                    childSit.mAdoptedChild = newChild.Instantiate(Vector3.Zero);

                    Deaths.CleansingKill(oldChild.SimDescription, true);

                    return(true);
                }
            }

            IncStat("Situation Not Found");
            return(false);
        }
Beispiel #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);
        }
Beispiel #3
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (mNewSim != null)
            {
                mSpecies = mNewSim.Species;
            }

            if (HouseholdsEx.IsFull(this, Sim.Household, mSpecies, 0, true, true))
            {
                IncStat("Full");
                return(false);
            }

            bool created = false;

            if (mNewSim == null)
            {
                using (SimFromBin <ManagerLot> simBin = new SimFromBin <ManagerLot>(this, Lots))
                {
                    CASAgeGenderFlags gender = BabyGenderScenario.GetGenderByFirstBorn(Manager, GetValue <ImmigrateScenario.GenderOption, BabyGenderScenario.FirstBornGender>(), false);

                    mNewSim = simBin.CreateNewSim(Ages, gender, mSpecies);
                    created = true;
                }
            }

            if (mNewSim != null)
            {
                if (Households.MoveSim(mNewSim, Sim.Household))
                {
                    mNewSim.LastName   = Sim.LastName;
                    mNewSim.WasAdopted = true;

                    Relationship relation = ManagerSim.GetRelationship(Sim, mNewSim);
                    if (relation != null)
                    {
                        relation.LTR.SetLiking(Delta);
                    }

                    Relationships.CheckAddHumanParentFlagOnAdoption(Sim, mNewSim);

                    if (Sim.Partner != null)
                    {
                        Relationships.CheckAddHumanParentFlagOnAdoption(Sim.Partner, mNewSim);
                    }

                    if (SimTypes.IsEquivalentSpecies(mNewSim, Sim))
                    {
                        Sim.Genealogy.AddChild(mNewSim.Genealogy);
                    }

                    UpdateDayOfLastOption(Sim);

                    if ((Sim.Partner != null) && (Sim.IsMarried))
                    {
                        if (SimTypes.IsEquivalentSpecies(mNewSim, Sim))
                        {
                            Sim.Partner.Genealogy.AddChild(mNewSim.Genealogy);
                        }

                        UpdateDayOfLastOption(Sim.Partner);
                    }
                    return(true);
                }
                else if (created)
                {
                    mNewSim.Dispose();
                    mNewSim = null;
                }
            }

            IncStat("No New Sim");
            return(false);
        }
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (mNewSim != null)
            {
                mSpecies = mNewSim.Species;
            }

            if (HouseholdsEx.IsFull(this, Sim.Household, mSpecies, 0, true, true))
            {
                IncStat("Full");
                return false;
            }

            bool created = false;
            if (mNewSim == null)
            {
                using (SimFromBin<ManagerLot> simBin = new SimFromBin<ManagerLot>(this, Lots))
                {
                    CASAgeGenderFlags gender = BabyGenderScenario.GetGenderByFirstBorn(Manager, GetValue<ImmigrateScenario.GenderOption, BabyGenderScenario.FirstBornGender>(), false);

                    mNewSim = simBin.CreateNewSim(Ages, gender, mSpecies);
                    created = true;
                }
            }

            if (mNewSim != null)
            {
                if (Households.MoveSim(mNewSim, Sim.Household))
                {
                    mNewSim.LastName = Sim.LastName;
                    mNewSim.WasAdopted = true;

                    Relationship relation = ManagerSim.GetRelationship(Sim, mNewSim);
                    if (relation != null)
                    {
                        relation.LTR.SetLiking(Delta);
                    }

                    Relationships.CheckAddHumanParentFlagOnAdoption(Sim, mNewSim);

                    if (Sim.Partner != null)
                    {
                        Relationships.CheckAddHumanParentFlagOnAdoption(Sim.Partner, mNewSim);
                    }

                    if (SimTypes.IsEquivalentSpecies(mNewSim, Sim))
                    {
                        Sim.Genealogy.AddChild(mNewSim.Genealogy);
                    }

                    UpdateDayOfLastOption(Sim);

                    if ((Sim.Partner != null) && (Sim.IsMarried))
                    {
                        if (SimTypes.IsEquivalentSpecies(mNewSim, Sim))
                        {
                            Sim.Partner.Genealogy.AddChild(mNewSim.Genealogy);
                        }

                        UpdateDayOfLastOption(Sim.Partner);
                    }
                    return true;
                }
                else if (created)
                {
                    mNewSim.Dispose();
                    mNewSim = null;
                }
            }

            IncStat("No New Sim");
            return false;
        }
Beispiel #5
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            SimDescription newSim = null;

            using (SimFromBin <ManagerSim> bin = new SimFromBin <ManagerSim>(this, Sims))
            {
                CASAgeGenderFlags gender = Sim.Gender;

                switch (GetValue <GenderOption, BabyGenderScenario.FirstBornGender>())
                {
                case BabyGenderScenario.FirstBornGender.Male:
                    gender = CASAgeGenderFlags.Male;
                    break;

                case BabyGenderScenario.FirstBornGender.Female:
                    gender = CASAgeGenderFlags.Female;
                    break;
                }

                newSim = bin.CreateNewSim(Sim.Age, gender, CASAgeGenderFlags.Human);
                if (newSim == null)
                {
                    IncStat("Creation Fail");
                    return(false);
                }
            }

            bool genderChanged = (Sim.Gender != newSim.Gender);

            bool result = FacialBlends.CopyGenetics(newSim, Sim, false, false);

            Sim.VoiceVariation     = newSim.VoiceVariation;
            Sim.VoicePitchModifier = newSim.VoicePitchModifier;

            Sim.FirstName = newSim.FirstName;

            if (genderChanged)
            {
                Sim.Gender = newSim.Gender;

                SavedOutfit.Cache cache = new SavedOutfit.Cache(newSim);

                Dictionary <OutfitCategories, bool> replaced = new Dictionary <OutfitCategories, bool>();

                Sim.RemoveOutfits(OutfitCategories.Career, true);

                SimOutfit geneOutfit = CASParts.GetOutfit(Sim, CASParts.sPrimary, false);

                foreach (SavedOutfit.Cache.Key outfit in cache.Outfits)
                {
                    using (CASParts.OutfitBuilder builder = new CASParts.OutfitBuilder(Sim, outfit.mKey, geneOutfit))
                    {
                        builder.Builder.Gender = Sim.Gender;

                        outfit.Apply(builder, false, null, null);

                        if (!replaced.ContainsKey(outfit.Category))
                        {
                            replaced.Add(outfit.Category, true);

                            CASParts.RemoveOutfits(Sim, outfit.Category, false);
                        }
                    }
                }

                if (Sim.CreatedSim != null)
                {
                    Sim.CreatedSim.UpdateOutfitInfo();

                    Sim.CreatedSim.RefreshCurrentOutfit(true);

                    SwitchOutfits.SwitchNoSpin(Sim.CreatedSim, new CASParts.Key(OutfitCategories.Everyday, 0));
                }
            }
            else
            {
                new SavedOutfit.Cache(Sim).PropagateGenetics(Sim, CASParts.sPrimary);
            }

            if (newSim.OccultManager.CurrentOccultTypes != OccultTypes.None)
            {
                if (Instantiation.PerformOffLot(Sim, Household.ActiveHousehold.LotHome, null) != null)
                {
                    List <OccultTypes> occults = OccultTypeHelper.CreateList(newSim, true);

                    foreach (OccultTypes occult in occults)
                    {
                        switch (occult)
                        {
                        case OccultTypes.Frankenstein:
                            Sim.TraitManager.AddElement(TraitNames.Brave);
                            Sim.TraitManager.AddElement(TraitNames.Hydrophobic);
                            break;
                        }
                    }

                    Sims.ApplyOccultChance(this, Sim, occults, 100, int.MaxValue);
                }

                if (Sim.GetOutfitCount(OutfitCategories.Everyday) > 1)
                {
                    Sim.RemoveOutfit(OutfitCategories.Everyday, 1, true);
                }

                SimOutfit currentOutfit = Sim.GetOutfit(OutfitCategories.Everyday, 0);
                if (currentOutfit != null)
                {
                    try
                    {
                        ThumbnailManager.GenerateHouseholdSimThumbnail(currentOutfit.Key, currentOutfit.Key.InstanceId, 0x0, ThumbnailSizeMask.Large | ThumbnailSizeMask.ExtraLarge | ThumbnailSizeMask.Medium | ThumbnailSizeMask.Small, ThumbnailTechnique.Default, true, false, Sim.AgeGenderSpecies);
                    }
                    catch (Exception e)
                    {
                        Common.Exception(Sim, e);
                    }
                }
            }

            Deaths.CleansingKill(newSim, true);

            if (!result)
            {
                return(false);
            }

            if (Common.kDebugging)
            {
                Common.DebugNotify(GetTitlePrefix(PrefixType.Pure) + ": " + Sim.FullName, Sim.CreatedSim);
            }

            SpeedTrap.Sleep();

            return(true);
        }