예제 #1
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            foreach (SimDescription sim in CommonSpace.Helpers.Households.All(mLot.Household))
            {
                SimData data = GetData(sim);
                if (data == null)
                {
                    continue;
                }

                data.InvalidateCache();
            }

            HouseholdOptions houseData = GetHouseOptions(mLot.Household);

            if (houseData != null)
            {
                houseData.InvalidateCache();
            }

            return(false);
        }
예제 #2
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Common.StringBuilder msg = new Common.StringBuilder("PrivateUpdate");

            try
            {
                bool fullList = !GetValue <CustomNamesOnlyOption <ManagerLot>, bool>();

                foreach (SimDescription baby in mBabies)
                {
                    msg += Common.NewLine + baby.FullName;

                    if (!SimTypes.IsSelectable(baby))
                    {
                        baby.FirstName = Sims.EnsureUniqueName(baby);
                    }

                    List <SimDescription> parents = Relationships.GetParents(baby);

                    parents.Remove(Sim);
                    if ((mDad == null) && (parents.Count > 0))
                    {
                        mDad = parents[0];
                    }

                    msg += Common.NewLine + "A";

                    List <OccultTypes> choices = OccultTypeHelper.CreateList(Sim.OccultManager.CurrentOccultTypes, true);

                    // Grandparent occult inheritance
                    foreach (SimDescription parent in Relationships.GetParents(Sim))
                    {
                        if (parent.OccultManager == null)
                        {
                            continue;
                        }

                        choices.AddRange(OccultTypeHelper.CreateList(parent.OccultManager.CurrentOccultTypes, true));
                    }

                    msg += Common.NewLine + "B";

                    if ((mDad != null) && (mDad.OccultManager != null))
                    {
                        choices.AddRange(OccultTypeHelper.CreateList(mDad.OccultManager.CurrentOccultTypes, true));

                        // Grandparent occult inheritance
                        foreach (SimDescription parent in Relationships.GetParents(mDad))
                        {
                            if (parent.OccultManager == null)
                            {
                                continue;
                            }

                            choices.AddRange(OccultTypeHelper.CreateList(parent.OccultManager.CurrentOccultTypes, true));
                        }
                    }

                    msg += Common.NewLine + "C";

                    Sims.ApplyOccultChance(this, baby, choices, GetValue <ChanceOfOccultBabyOptionV2, int>(), GetValue <MaximumNewbornOccultOption, int>());

                    msg += Common.NewLine + "D";

                    if ((SimTypes.IsServiceAlien(mDad)) || (SimTypes.IsServiceAlien(Sim)))
                    {
                        baby.SetAlienDNAPercentage(1f);
                    }
                    else
                    {
                        baby.SetAlienDNAPercentage(SimDescription.GetAlienDNAPercentage(mDad, Sim, true));
                    }
                }

                msg += Common.NewLine + "E";

                if (OnRenameNewbornsScenario != null)
                {
                    OnRenameNewbornsScenario(this, frame);
                }

                if (!SimTypes.IsSelectable(Sim))
                {
                    ManagerSim.IncrementLifetimeHappiness(Sim, Sims3.Gameplay.Rewards.LifeEventRewards.kLifetimeHappinessRewardForBaby);
                }

                SetElapsedTime <DayOfLastBabyOption>(Sim);

                msg += Common.NewLine + "F";

                if (mDad != null)
                {
                    if (!SimTypes.IsSelectable(mDad))
                    {
                        ManagerSim.IncrementLifetimeHappiness(mDad, Sims3.Gameplay.Rewards.LifeEventRewards.kLifetimeHappinessRewardForBaby);
                    }

                    SetElapsedTime <DayOfLastBabyOption>(mDad);
                }

                msg += Common.NewLine + "G";

                foreach (SimDescription baby in mBabies)
                {
                    Manager.AddAlarm(new NormalBabyAgingScenario(baby));
                }

                msg += Common.NewLine + "H";

                if (OnBirthScenario != null)
                {
                    OnBirthScenario(this, frame);
                }

                msg += Common.NewLine + "I";

                // Do this at the end once everything else has done its thing
                foreach (SimDescription baby in mBabies)
                {
                    msg += Common.NewLine + baby.FullName;

                    HouseholdOptions houseData = GetHouseOptions(baby.Household);
                    if (houseData != null)
                    {
                        int netWorth = houseData.GetValue <NetWorthOption, int>();

                        foreach (SimDescription parent in Relationships.GetParents(baby))
                        {
                            SimData parentData = GetData(parent);
                            if (parentData != null)
                            {
                                foreach (CasteOptions caste in parentData.Castes)
                                {
                                    if (!caste.GetValue <CasteInheritedOption, bool>())
                                    {
                                        continue;
                                    }

                                    if (!caste.Matches(baby, netWorth))
                                    {
                                        continue;
                                    }

                                    SimData babyData = GetData(baby);
                                    if (babyData != null)
                                    {
                                        babyData.AddValue <ManualCasteOption, CasteOptions>(caste);
                                    }
                                }
                            }
                        }
                    }
                }

                msg += Common.NewLine + "J";

                Add(frame, new SuccessScenario(), ScenarioResult.Start);
            }
            catch (Exception e)
            {
                Common.Exception(ToString() + Common.NewLine + msg.ToString(), e);
            }
            return(false);
        }