Exemplo n.º 1
0
        protected override ManagerStory.Story PrintFormattedStory(StoryProgressionObject manager, string text, string summaryKey, object[] parameters, string[] extended, ManagerStory.StoryLogging logging)
        {
            if (Sim.Species == CASAgeGenderFlags.Human)
            {
                text = AgingManager.LocalizeString(Sim.IsFemale, "AgeTo" + Sim.Age, new object[] { Sim });
            }
            else if (Sim.IsADogSpecies)
            {
                text = Common.Localize("AgeUpDog:" + Sim.Age, Sim.IsFemale, new object[] { Sim });
            }
            else
            {
                text = Common.Localize("AgeUp" + Sim.Species + ":" + Sim.Age, Sim.IsFemale, new object[] { Sim });
            }

            if (string.IsNullOrEmpty(text))
            {
                return(null);
            }

            if (parameters == null)
            {
                parameters = new object[] { Sim };
            }

            if (extended == null)
            {
                extended = new string[] { Common.LocalizeEAString("UI/Feedback/CAS:" + Sim.Age) };
            }

            logging |= ManagerStory.StoryLogging.Full;

            return(base.PrintFormattedStory(manager, text, summaryKey, parameters, extended, logging));
        }
Exemplo n.º 2
0
        public static CASAgeGenderFlags GetDaysGoneAges(float daysGone)
        {
            float childAge = AgingManager.GetAgingStageLength(CASAgeGenderFlags.Human, CASAgeGenderFlags.Child);
            float teenAge  = childAge + AgingManager.GetAgingStageLength(CASAgeGenderFlags.Human, CASAgeGenderFlags.Teen);
            float youngAge = teenAge + AgingManager.GetAgingStageLength(CASAgeGenderFlags.Human, CASAgeGenderFlags.YoungAdult);
            float adultAge = youngAge + AgingManager.GetAgingStageLength(CASAgeGenderFlags.Human, CASAgeGenderFlags.Adult);

            CASAgeGenderFlags age = CASAgeGenderFlags.None;

            if (daysGone > childAge)
            {
                age |= CASAgeGenderFlags.Teen;
            }
            if (daysGone > teenAge)
            {
                age |= CASAgeGenderFlags.YoungAdult;
            }
            if (daysGone > youngAge)
            {
                age |= CASAgeGenderFlags.Adult;
            }
            if (daysGone > adultAge)
            {
                age |= CASAgeGenderFlags.Elder;
            }

            return(age);
        }
Exemplo n.º 3
0
        public static int GetHumanAgeSpanLength()
        {
            float agingYears = 0f;

            foreach (CASAgeGenderFlags age in sAges)
            {
                agingYears += AgingManager.GetAgingStageLength(CASAgeGenderFlags.Human, age);
            }

            return((int)AgingManager.Singleton.AgingYearsToSimDays(agingYears));
        }
Exemplo n.º 4
0
        private static void CommonDayPassedUpdates(AgingManager ths, AgingState state, List<AgingState> statesToGraduate, ref bool silentGraduation, bool noSchools)
        {
            try
            {
                SimDescription simDescription = state.SimDescription;
                if (simDescription.UserDaysInCurrentAge < 0x7fffffff)
                {
                    simDescription.UserDaysInCurrentAge++;
                }

                // Custom
                //   Fix for midlife crisis moodlets left running on inactives
                if ((simDescription.CreatedSim != null) && (simDescription.CreatedSim.DreamsAndPromisesManager == null))
                {
                    BuffManager buffManager = simDescription.CreatedSim.BuffManager;
                    if (buffManager != null)
                    {
                        buffManager.RemoveElement(BuffNames.HavingAMidlifeCrisis);
                        buffManager.RemoveElement(BuffNames.HavingAMidlifeCrisisWithPromise);
                    }
                }

                MidlifeCrisisManager.OnDayPassed(simDescription);

                if (GameUtils.IsInstalled(ProductVersion.EP4))
                {
                    if ((simDescription.YoungAdult && (simDescription.UserDaysInCurrentAge == AgingManager.kDaysBeforeGraduation)) && (simDescription.GraduationType == GraduationType.None))
                    {
                        if (noSchools)
                        {
                            state.SimDescription.GraduationType = GraduationType.NoSchool;
                        }
                        else
                        {
                            state.ShouldBeGraduating = true;
                        }
                    }

                    if ((statesToGraduate != null) && state.ShouldBeGraduating)
                    {
                        statesToGraduate.Add(state);
                        if ((simDescription.CreatedSim != null) && simDescription.CreatedSim.IsSelectable)
                        {
                            silentGraduation = false;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(state.SimDescription, e);
            }
        }
Exemplo n.º 5
0
        private static void CommonDayPassedUpdates(AgingManager ths, AgingState state, List <AgingState> statesToGraduate, ref bool silentGraduation, bool noSchools)
        {
            try
            {
                SimDescription simDescription = state.SimDescription;
                if (simDescription.UserDaysInCurrentAge < 0x7fffffff)
                {
                    simDescription.UserDaysInCurrentAge++;
                }

                // Custom
                //   Fix for midlife crisis moodlets left running on inactives
                if ((simDescription.CreatedSim != null) && (simDescription.CreatedSim.DreamsAndPromisesManager == null))
                {
                    BuffManager buffManager = simDescription.CreatedSim.BuffManager;
                    if (buffManager != null)
                    {
                        buffManager.RemoveElement(BuffNames.HavingAMidlifeCrisis);
                        buffManager.RemoveElement(BuffNames.HavingAMidlifeCrisisWithPromise);
                    }
                }

                MidlifeCrisisManager.OnDayPassed(simDescription);

                if (GameUtils.IsInstalled(ProductVersion.EP4))
                {
                    if ((simDescription.YoungAdult && (simDescription.UserDaysInCurrentAge == AgingManager.kDaysBeforeGraduation)) && (simDescription.GraduationType == GraduationType.None))
                    {
                        if (noSchools)
                        {
                            state.SimDescription.GraduationType = GraduationType.NoSchool;
                        }
                        else
                        {
                            state.ShouldBeGraduating = true;
                        }
                    }

                    if ((statesToGraduate != null) && state.ShouldBeGraduating)
                    {
                        statesToGraduate.Add(state);
                        if ((simDescription.CreatedSim != null) && simDescription.CreatedSim.IsSelectable)
                        {
                            silentGraduation = false;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(state.SimDescription, e);
            }
        }
Exemplo n.º 6
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            float age = Sim.YearsSinceLastAgeTransition - AgingManager.GetAgingStageLength(Sim.Species, Sim.Age);

            if (age >= 0)
            {
                bool kill = false;

                age = AgingManager.Singleton.AgingYearsToSimDays(age);
                if (age >= GetValue <MaximumAgeOption, int>(Sim))
                {
                    kill = true;

                    IncStat("Beyond Maximum");
                }
                else
                {
                    int cumulChance = GetValue <CumulativeAgeChanceOption, int>(Sim);
                    if (cumulChance > 0)
                    {
                        float chance = AgingManager.Singleton.GetChancePerDayElderWillDie(Sim.Species, false, Sim.IsFrankenstein);

                        chance += cumulChance * age;

                        if (RandomUtil.RandomChance(chance))
                        {
                            kill = true;

                            AddStat("Cumul Success", chance);
                        }
                    }
                    else
                    {
                        AddStat("Too Young", age);
                    }
                }

                if (kill)
                {
                    EventTracker.SendEvent(new MiniSimDescriptionEvent(EventTypeId.kSimGettingOld, Sim));
                    Sim.AgingState.AgeTransitionWithoutCakeAlarm = AlarmManager.Global.AddAlarm(RandomUtil.GetFloat(12f, 24f), TimeUnit.Hours, Sim.AgingState.AgeTransitionWithoutCakeCallback, "The Cake is a Lie and Then You Die", AlarmType.AlwaysPersisted, Sim);
                    AlarmManager.Global.AlarmWillYield(Sim.AgingState.AgeTransitionWithoutCakeAlarm);

                    IncStat("Aging Initiated");
                }
            }
            else
            {
                AddStat("Still Under Age", age);
            }

            return(false);
        }
Exemplo n.º 7
0
        public static string GetHeader(IMiniSimDescription me)
        {
            SimDescription     simDesc  = me as SimDescription;
            MiniSimDescription miniDesc = me as MiniSimDescription;

            float agingYearsSinceLastAgeTransition = 0;

            if (simDesc != null)
            {
                agingYearsSinceLastAgeTransition = simDesc.AgingYearsSinceLastAgeTransition;
            }
            else if (miniDesc != null)
            {
                agingYearsSinceLastAgeTransition = miniDesc.AgingYearsSinceLastAgeTransition;
            }

            int trueAge          = (int)Aging.GetCurrentAgeInDays(me);
            int daysToTransition = (int)(AgingManager.Singleton.AgingYearsToSimDays(AgingManager.GetMaximumAgingStageLength(me)) - AgingManager.Singleton.AgingYearsToSimDays(agingYearsSinceLastAgeTransition));

            string simName = me.FullName.Trim();

            if (string.IsNullOrEmpty(simName))
            {
                Genealogy genealogy = me.CASGenealogy as Genealogy;
                if (genealogy != null)
                {
                    simName = genealogy.Name + Common.NewLine + me.SimDescriptionId;
                }
            }

            string header = Common.Localize("Status:NameAge", me.IsFemale, new object[] { simName, SelectionCriteria.Age.Item.GetName(me.Age), trueAge, daysToTransition });

            if (me.IsFemale)
            {
                header += Common.NewLine + Common.Localize("Criteria.GenderFemale:MenuName");
            }
            else
            {
                header += Common.NewLine + Common.Localize("Criteria.GenderMale:MenuName");
            }

            if (me.IsAlien)
            {
                header += " " + Common.Localize("Species:Alien");
            }
            else
            {
                header += " " + Common.Localize("Species:" + me.Species);
            }
            return(header);
        }
Exemplo n.º 8
0
        public static bool IsOldEnoughToAge(AgingManager manager, AgingState state)
        {
            if (state == null) return true;

            if (state.SimDescription.Elder)
            {
                if (state.AgingYearsPassedSinceLastTransition >= manager.SimDaysToAgingYears(state.MinimumElderLifeSpanInSimDays)) return true;
            }
            else
            {
                if (manager.SimIsCloseToAging(state, 0)) return true;
            }

            return false;
        }
Exemplo n.º 9
0
        protected static void OnCheckAging()
        {
            AgingManager manager = AgingManager.Singleton;

            Dictionary <ulong, SimDescription> sims = SimListing.GetResidents(false);

            foreach (SimDescription sim in sims.Values)
            {
                if (IsOldEnoughToAge(manager, sim.AgingState))
                {
                    continue;
                }

                manager.CancelAgingAlarmsForSim(sim.AgingState);
            }
        }
Exemplo n.º 10
0
        protected static bool TestAging(SimDescription sim, StuckSimData data)
        {
            if (!ValidAger(sim))
            {
                data.mAgingSituation = false;
                data.mWasNegative    = false;
                return(false);
            }

            Sim createdSim = sim.CreatedSim;

            if ((createdSim != null) && (createdSim.GetSituationOfType <AgeUpNpcSituation>() != null))
            {
                if (data.mAgingSituation)
                {
                    return(true);
                }

                data.mAgingSituation = true;
            }
            else
            {
                data.mAgingSituation = false;
            }

            int daysToTransition = (int)AgingManager.Singleton.AgingYearsToSimDays(AgingManager.GetMaximumAgingStageLength(sim));

            daysToTransition -= (int)AgingManager.Singleton.AgingYearsToSimDays(sim.AgingYearsSinceLastAgeTransition);

            if (daysToTransition < -1)
            {
                if (data.mWasNegative)
                {
                    return(true);
                }

                data.mWasNegative = true;
            }
            else
            {
                data.mWasNegative = false;
            }

            return(false);
        }
Exemplo n.º 11
0
        public static float GetCurrentAgeInDays(IMiniSimDescription sim)
        {
            float agingYears = 0;

            foreach (CASAgeGenderFlags age in GetAges(sim.Species))
            {
                if (age >= sim.Age)
                {
                    continue;
                }

                agingYears += AgingManager.GetAgingStageLength(sim.Species, age);
            }

            agingYears += sim.YearsSinceLastAgeTransition;

            return(AgingManager.Singleton.AgingYearsToSimDays(agingYears));
        }
Exemplo n.º 12
0
        protected override OptionResult Run(Lot myLot, Household house)
        {
            try
            {
                AgingManager singleton = AgingManager.Singleton;

                string msg = null;

                foreach (SimDescription sim in Household.AllSimsLivingInWorld())
                {
                    msg += Common.NewLine + sim.FullName;
                    msg += Common.NewLine + " Aging Enabled: " + sim.AgingEnabled;

                    if (sim.AgingState == null)
                    {
                        msg += Common.NewLine + " No State";
                    }
                    else
                    {
                        msg += Common.NewLine + " Old Enough: " + singleton.SimIsOldEnoughToTransition(sim.AgingState);
                        msg += Common.NewLine + " DayPassed: " + sim.AgingState.DayPassedSinceLastTransition;
                        msg += Common.NewLine + " Stage: " + sim.Age;
                        msg += Common.NewLine + " Current: " + singleton.AgingYearsToSimDays(sim.AgingState.AgingYearsPassedSinceLastTransition);
                        msg += Common.NewLine + " Maximum: " + singleton.AgingYearsToSimDays(AgingManager.GetMaximumAgingStageLength(sim));

                        msg += Common.NewLine + " WithoutCake Alarm: " + sim.AgingState.AgeTransitionWithoutCakeAlarm;
                        msg += Common.NewLine + " EarlyMessage Alarm: " + sim.AgingState.AgeTransitionEarlyMessageAlarm;
                        msg += Common.NewLine + " EarlyMessage: " + sim.AgingState.AgeTransitionEarlyMessagesGiven;
                        msg += Common.NewLine + " Message Alarm: " + sim.AgingState.AgeTransitionMessageAlarm;
                        msg += Common.NewLine + " Message: " + sim.AgingState.AgeTransitionMessagesGiven;
                    }

                    msg += Common.NewLine;
                }

                Common.WriteLog(msg);
            }
            catch (Exception e)
            {
                Common.Exception(myLot, e);
            }
            return(OptionResult.SuccessClose);
        }
Exemplo n.º 13
0
        protected void GetAge(IMiniSimDescription me, out int age, out int maxAge)
        {
            SimDescription     simDesc  = me as SimDescription;
            MiniSimDescription miniDesc = me as MiniSimDescription;

            float agingYearsSinceLastAgeTransition = 0;

            if (simDesc != null)
            {
                agingYearsSinceLastAgeTransition = simDesc.AgingYearsSinceLastAgeTransition;
            }
            else if (miniDesc != null)
            {
                agingYearsSinceLastAgeTransition = miniDesc.AgingYearsSinceLastAgeTransition;
            }

            maxAge = (int)AgingManager.Singleton.AgingYearsToSimDays(AgingManager.GetMaximumAgingStageLength(me));

            age = (int)AgingManager.Singleton.AgingYearsToSimDays(agingYearsSinceLastAgeTransition);
        }
Exemplo n.º 14
0
        public static bool IsOldEnoughToAge(AgingManager manager, AgingState state)
        {
            if (state == null)
            {
                return(true);
            }

            if (state.SimDescription.Elder)
            {
                if (state.AgingYearsPassedSinceLastTransition >= manager.SimDaysToAgingYears(state.MinimumElderLifeSpanInSimDays))
                {
                    return(true);
                }
            }
            else
            {
                if (manager.SimIsCloseToAging(state, 0))
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 15
0
        public static bool TestNearElderLimit(Common.IStatGenerator stats, SimDescription sim, int limit)
        {
            if ((sim.AdultOrAbove) && (limit > 0))
            {
                int daysToTransition = (int)(AgingManager.Singleton.AgingYearsToSimDays(AgingManager.GetMaximumAgingStageLength(sim)) - AgingManager.Singleton.AgingYearsToSimDays(sim.AgingYearsSinceLastAgeTransition));

                if (daysToTransition < limit)
                {
                    stats.IncStat("Near Elder Denied");
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 16
0
        public static string GetStatus(SimDescription sim)
        {
            string str = sim.FullName;

            bool serviceOrRole = false;

            if (sim.AssignedRole != null)
            {
                serviceOrRole = true;
                ShoppingRegister register = sim.AssignedRole.RoleGivingObject as ShoppingRegister;
                if (register != null)
                {
                    str += ", " + register.RegisterRoleName(sim.IsFemale);
                }
                else
                {
                    string roleName;
                    if (Localization.GetLocalizedString(sim.AssignedRole.CareerTitleKey, out roleName))
                    {
                        str += ", " + roleName;
                    }
                }

                string hours = GetRoleHours(sim);
                if (!string.IsNullOrEmpty(hours))
                {
                    str += Common.NewLine + hours;
                }
            }
            else if (SimTypes.InServicePool(sim))
            {
                serviceOrRole = true;

                string serviceName;
                if (Localization.GetLocalizedString("Ui/Caption/Services/Service:" + sim.CreatedByService.ServiceType.ToString(), out serviceName))
                {
                    str += ", " + serviceName;
                }
            }

            if ((serviceOrRole) || (Tagger.Settings.mTagDataSettings[TagDataType.Orientation] && Tagger.Settings.mTagDataSettings[TagDataType.LifeStage] && (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays] || (Tagger.Settings.mTagDataSettings[TagDataType.DaysTillNextStage] && sim.AgingEnabled))))
            {
                str += Common.NewLine;
            }
            else
            {
                str += " - ";
            }

            if (sim.TeenOrAbove && !sim.IsPet && Tagger.Settings.mTagDataSettings[TagDataType.Orientation])
            {
                str += Common.Localize("SimType:" + TagDataHelper.GetOrientation(sim).ToString());
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.LifeStage])
            {
                if (Tagger.Settings.mTagDataSettings[TagDataType.Orientation])
                {
                    str += " ";
                }

                str += sim.AgeLocalizedText;
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays] || Tagger.Settings.mTagDataSettings[TagDataType.DaysTillNextStage])
            {
                str += " (";
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays])
            {
                str += Common.Localize("TagData:Age", sim.IsFemale, new object[] { Math.Round(Aging.GetCurrentAgeInDays(sim as IMiniSimDescription)) });
            }

            if (sim.AgingEnabled)
            {
                if (Tagger.Settings.mTagDataSettings[TagDataType.DaysTillNextStage])
                {
                    str += ", " + Common.Localize("TagData:Birthday", sim.IsFemale, new object[] { (int)(AgingManager.Singleton.AgingYearsToSimDays(AgingManager.GetMaximumAgingStageLength(sim)) - AgingManager.Singleton.AgingYearsToSimDays(sim.AgingYearsSinceLastAgeTransition)) });
                }
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays] || Tagger.Settings.mTagDataSettings[TagDataType.DaysTillNextStage])
            {
                str += ")";
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.Occult] && sim.OccultManager != null)
            {
                List <OccultTypes> types = OccultTypeHelper.CreateList(sim, false);

                if (types.Count > 0)
                {
                    str += Common.NewLine;

                    string occultString = "";
                    foreach (OccultTypes type in types)
                    {
                        occultString += ", " + OccultTypeHelper.GetLocalizedName(type);
                    }

                    str += Common.Localize("TagData:OccultTag", sim.IsFemale, new object[] { occultString.Remove(0, 2) });
                }
            }

            Sim createdSim = sim.CreatedSim;

            if (Tagger.Settings.Debugging)
            {
                if (createdSim != null)
                {
                    str += Common.NewLine + "Autonomy: ";
                    if (createdSim.Autonomy == null)
                    {
                        str += "None";
                    }
                    else
                    {
                        if (createdSim.Autonomy.AutonomyDisabled)
                        {
                            str += "Disabled";
                        }
                        else if (!AutonomyRestrictions.IsAnyAutonomyEnabled(createdSim))
                        {
                            str += "User Disabled";
                        }
                        else if (createdSim.Autonomy.IsRunningHighLODSimulation)
                        {
                            str += "High";
                        }
                        else
                        {
                            str += "Low";
                        }

                        if (createdSim.Autonomy.ShouldRunLocalAutonomy)
                        {
                            str += " Local";
                        }

                        if (createdSim.CanRunAutonomyImmediately())
                        {
                            str += " Ready";
                        }
                        else if (!createdSim.mLastInteractionWasAutonomous)
                        {
                            str += " Push";
                        }
                        else if (!createdSim.mLastInteractionSucceeded)
                        {
                            str += " Fail";
                        }

                        if (createdSim.Autonomy.InAutonomyManagerQueue)
                        {
                            str += " Queued";
                        }
                    }
                }
            }

            if (createdSim != null)
            {
                if (Tagger.Settings.mTagDataSettings[TagDataType.Mood])
                {
                    str += Common.NewLine;
                    int flavour = (int)createdSim.MoodManager.MoodFlavor;

                    str += Common.Localize("TagData:MoodTag", sim.IsFemale, new object[] { Common.LocalizeEAString(false, "Ui/Tooltip/HUD/SimDisplay:MoodFlavor" + flavour.ToString()) }) + " ";
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.MotiveInfo])
                {
                    if (!Tagger.Settings.mTagDataSettings[TagDataType.Mood])
                    {
                        str += Common.NewLine;
                    }

                    string motives = ", ";
                    int    num     = 0;
                    foreach (CommodityKind kind in (Sims3.UI.Responder.Instance.HudModel as HudModel).GetMotives(sim.CreatedSim))
                    {
                        if (sim.CreatedSim.Motives.HasMotive(kind))
                        {
                            if (num >= 6)
                            {
                                break;
                            }

                            motives += FetchMotiveLocalization(sim.Species, kind) + ": " + "(" + sim.CreatedSim.Motives.GetValue(kind).ToString("0.") + ") ";
                        }

                        num++;
                    }

                    str += Common.Localize("TagData:Motives", sim.IsFemale, new object[] { motives.Remove(0, 2) });
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.CurrentInteraction] && createdSim.CurrentInteraction != null)
                {
                    str += Common.NewLine;

                    try
                    {
                        str += createdSim.CurrentInteraction.ToString();
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(createdSim, e);

                        str += createdSim.CurrentInteraction.GetType();
                    }

                    Tone tone = createdSim.CurrentInteraction.CurrentTone;
                    if (tone != null)
                    {
                        str += Common.NewLine + tone.ToString();
                    }

                    SocialInteractionBase social = createdSim.CurrentInteraction as SocialInteractionBase;
                    if ((social != null) && (social.Target != null))
                    {
                        str += " " + Common.Localize("TagData:With", sim.IsFemale, new object[] { social.Target.Name });
                    }

                    if (createdSim.CurrentInteraction is Terrain.GoHereWith)
                    {
                        InviteToLotSituation situtation = InviteToLotSituation.FindInviteToLotSituationInvolving(createdSim);
                        if (situtation != null)
                        {
                            if (situtation.SimA != createdSim)
                            {
                                str += " " + situtation.SimA.Name;
                            }
                            else if (situtation.SimB != createdSim)
                            {
                                str += situtation.SimB.Name;
                            }
                        }
                    }
                }
            }

            if (!SimTypes.IsSpecial(sim))
            {
                str += Common.NewLine + Common.Localize("TagData:CashTag", sim.IsFemale, new object[] { sim.FamilyFunds });

                if ((Tagger.Settings.mTagDataSettings[TagDataType.Debt] || Tagger.Settings.mTagDataSettings[TagDataType.NetWorth]) && sGetDebtAndNetworth.Valid)
                {
                    int bit = 0;
                    if (Tagger.Settings.mTagDataSettings[TagDataType.Debt])
                    {
                        bit = bit + 1;
                    }
                    if (Tagger.Settings.mTagDataSettings[TagDataType.NetWorth])
                    {
                        bit = bit + 4;
                    }

                    str += sGetDebtAndNetworth.Invoke <string>(new object[] { sim, bit });
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.Job])
                {
                    if (sim.Occupation != null)
                    {
                        str += Common.NewLine;
                        if (sim.Occupation.OfficeLocation != null)
                        {
                            str += Common.Localize("TagData:JobAt", sim.IsFemale, new object[] { sim.Occupation.CurLevelJobTitle, sim.Occupation.OfficeLocation.GetLocalizedName() });
                        }
                        else
                        {
                            str += Common.Localize("TagData:JobTag", sim.IsFemale, new object[] { sim.Occupation.CurLevelJobTitle });
                        }
                    }
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.PartnerInfo])
                {
                    if (sim.Partner != null)
                    {
                        Relationship rel    = sim.GetRelationship(sim.Partner, false);
                        string       status = "Happily";
                        if (rel != null)
                        {
                            if (rel.CurrentLTRLiking < -15)
                            {
                                status = "Unhappily";
                            }
                        }

                        str += Common.NewLine;

                        if (sim.IsMarried)
                        {
                            str += Common.Localize("TagData:Spouse", sim.IsFemale, new object[] { Common.Localize("TagData:" + status), sim.Partner });
                        }
                        else
                        {
                            str += Common.Localize("TagData:Partner", sim.IsFemale, new object[] { sim.Partner });
                        }
                    }
                }
            }

            if (sim.IsPregnant && Tagger.Settings.mTagDataSettings[TagDataType.PregnancyInfo])
            {
                IMiniSimDescription father = SimDescription.Find(sim.Pregnancy.DadDescriptionId);
                if (father == null)
                {
                    father = MiniSimDescription.Find(sim.Pregnancy.DadDescriptionId);
                }

                str += Common.NewLine;

                if (father != null)
                {
                    if (sim.Partner != null && father != sim.Partner && !sim.IsPet)
                    {
                        string uhoh = Common.Localize("TagData:Uhoh");
                        str += Common.Localize("TagData:Pregnancy", sim.IsFemale, new object[] { father, uhoh });
                    }
                    else
                    {
                        str += Common.Localize("TagData:Pregnancy", sim.IsFemale, new object[] { father });
                    }
                }
                else
                {
                    str += Common.Localize("TagData:PregnancyUnknown", sim.IsFemale);
                }
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.PersonalityInfo] && sGetClanInfo.Valid)
            {
                List <string> info = sGetClanInfo.Invoke <List <string> >(new object [] { sim });
                foreach (string personality in info)
                {
                    str += Common.NewLine + personality;
                }
            }

            return(str);
        }
Exemplo n.º 17
0
        public static void DayPassedCallback(AgingManager ths)
        {
            List <AgingState> statesToGraduate = new List <AgingState>();
            bool silentGraduation = true;
            bool noSchools        = Sims3.Gameplay.Queries.CountObjects <ISchoolRabbitHole>() == 0x0;

            if (ths.Enabled)
            {
                float hoursPassedOfDay = SimClock.HoursPassedOfDay;
                float agingYearsPassed = 1f / ths.SimDaysPerAgingYear;
                if (hoursPassedOfDay > AgingManager.kHourToShowBirthdayMessage)
                {
                    foreach (AgingState state in ths.AgingStates)
                    {
                        if (state != null)
                        {
                            state.AgingYearsPassedSinceLastTransition += agingYearsPassed;
                        }
                    }
                    return;
                }

                if (!GameUtils.IsFutureWorld())
                {
                    ths.AgeVacationWorldSims(agingYearsPassed);
                }

                foreach (AgingState state in ths.AgingStates)
                {
                    try
                    {
                        if (ths.IsAgingStateValid(state))
                        {
                            state.AgingYearsPassedSinceLastTransition += agingYearsPassed;
                            state.DayPassedSinceLastTransition         = true;
                            Sim createdSim = state.SimDescription.CreatedSim;
                            if (createdSim != null)
                            {
                                Sims3.Gameplay.UI.HudModel hudModel = Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel;
                                if (hudModel != null)
                                {
                                    hudModel.OnSimAgeChanged(createdSim.ObjectId);
                                }
                            }

                            // Custom
                            CommonDayPassedUpdates(ths, state, statesToGraduate, ref silentGraduation, noSchools);

                            if (((state.AgeTransitionEarlyMessageAlarm != AlarmHandle.kInvalidHandle) || (state.AgeTransitionWithoutCakeAlarm != AlarmHandle.kInvalidHandle)) || (state.AgeTransitionMessageAlarm != AlarmHandle.kInvalidHandle))
                            {
                                float timeLeft = AlarmManager.Global.GetTimeLeft(state.AgeTransitionWithoutCakeAlarm, TimeUnit.Hours);
                                if ((timeLeft > 0f) && (timeLeft <= 24f))
                                {
                                    continue;
                                }
                                ths.CancelAgingAlarmsForSim(state);
                            }

                            IAlarmOwner simDescription = state.SimDescription;
                            if (ths.SimIsOldEnoughToTransition(state))
                            {
                                if (state.SimDescription.Age == CASAgeGenderFlags.Elder)
                                {
                                    EventTracker.SendEvent(new MiniSimDescriptionEvent(EventTypeId.kSimGettingOld, state.SimDescription));

                                    if (AgingStateEx.IsInactiveActive(state))
                                    {
                                        AgingStateEx.AgeTransitionWithoutCakeTask.Perform(state);
                                    }
                                    else
                                    {
                                        state.AgeTransitionWithoutCakeAlarm = AlarmManager.Global.AddAlarm(RandomUtil.GetFloat(12f, 24f), TimeUnit.Hours, state.AgeTransitionWithoutCakeCallback, "The Cake is a Lie and Then You Die", AlarmType.AlwaysPersisted, simDescription);
                                        AlarmManager.Global.AlarmWillYield(state.AgeTransitionWithoutCakeAlarm);
                                    }
                                }
                                else
                                {
                                    if (AgingStateEx.IsInactiveActive(state))
                                    {
                                        AgingStateEx.AgeTransitionWithoutCakeTask.Perform(state);
                                    }
                                    else
                                    {
                                        float time     = AgingManager.kHourToShowBirthdayMessage - hoursPassedOfDay;
                                        float maxValue = float.MaxValue;
                                        if (createdSim != null)
                                        {
                                            maxValue = (24f + createdSim.HoursUntilWakeupTime) - AgingManager.kHourToAgeWithoutCake;
                                        }

                                        maxValue = Math.Min(maxValue, AgingManager.kLatestHourToAgeWithoutCake - hoursPassedOfDay);

                                        state.AgeTransitionWithoutCakeAlarm = AlarmManager.Global.AddAlarmRepeating(maxValue, TimeUnit.Hours, state.AgeTransitionWithoutCakeCallback, 15f, TimeUnit.Minutes, "The Cake is a Lie", AlarmType.AlwaysPersisted, simDescription);
                                        AlarmManager.Global.AlarmWillYield(state.AgeTransitionWithoutCakeAlarm);

                                        if (!state.SimDescription.IsEnrolledInBoardingSchool())
                                        {
                                            state.AgeTransitionMessageAlarm = AlarmManager.Global.AddAlarm(time, TimeUnit.Hours, state.ShowAgeTransitionMessageCallback, "Tell Player that the Cake is a Lie", AlarmType.AlwaysPersisted, simDescription);
                                            AlarmManager.Global.AlarmWillYield(state.AgeTransitionMessageAlarm);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (!state.SimDescription.Elder && ths.SimIsCloseToAging(state, AgingManager.kDaysEarlyToShowBirthdayMessage))
                                {
                                    float num6 = AgingManager.kHourToShowBirthdayMessage - hoursPassedOfDay;
                                    state.AgeTransitionEarlyMessageAlarm = AlarmManager.Global.AddAlarm(num6, TimeUnit.Hours, state.ShowAgeTransitionEarlyMessageCallback, "Tell player that the cake will be a lie in a few days", AlarmType.AlwaysPersisted, simDescription);
                                    AlarmManager.Global.AlarmWillYield(state.AgeTransitionEarlyMessageAlarm);
                                }

                                if (state.SimDescription.Teen && ths.SimIsCloseToAging(state, AgingManager.kDaysEarlyToShowGraduationMessage))
                                {
                                    float num7 = AgingManager.kHourToShowGraduationMessage - hoursPassedOfDay;
                                    state.GraduationEarlyMessageAlarm = AlarmManager.Global.AddAlarm(num7, TimeUnit.Hours, state.ShowGraduationEarlyMessageCallback, "Tell player that graduation will be in a few days", AlarmType.AlwaysPersisted, simDescription);
                                    AlarmManager.Global.AlarmWillYield(state.GraduationEarlyMessageAlarm);
                                }
                            }

                            if (((createdSim != null) && createdSim.IsSelectable) && (state.SimDescription.Teen && ths.SimIsCloseToAging(state, AgingManager.kDaysBeforeAgingToDelayGraduation)))
                            {
                                statesToGraduate = null;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(state.SimDescription, e);
                    }
                }
            }
            else
            {
                foreach (AgingState state3 in ths.AgingStates)
                {
                    if (ths.IsAgingStateValid(state3))
                    {
                        state3.DayPassedSinceLastTransition = true;

                        // Custom
                        CommonDayPassedUpdates(ths, state3, statesToGraduate, ref silentGraduation, noSchools);
                    }
                }
            }

            if ((statesToGraduate != null) && (statesToGraduate.Count > 0x0))
            {
                foreach (AgingState state4 in statesToGraduate)
                {
                    try
                    {
                        if (noSchools)
                        {
                            state4.SimDescription.GraduationType = GraduationType.NoSchool;
                        }
                        else if (silentGraduation)
                        {
                            state4.SimDescription.GraduationType = GraduationType.Graduate;
                            Sim sim2 = state4.SimDescription.CreatedSim;
                            if (sim2 != null)
                            {
                                sim2.SetDefaultGraduatedStateIfNeccessary();
                            }
                        }
                        else
                        {
                            School.GraduateSim(state4.SimDescription);
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(state4.SimDescription, e);
                    }
                    finally
                    {
                        state4.ShouldBeGraduating = false;
                    }
                }
            }
        }
Exemplo n.º 18
0
        public static bool MeetsCommonAfterschoolActivityRequirements(SimDescription actor, AfterschoolActivityType activityToCheck, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
        {
            bool teen = actor.Teen;

            if (!actor.Child && !teen)
            {
                return(false);
            }

            School school = actor.CareerManager.School;

            if (school == null)
            {
                return(false);
            }
            else if (actor.IsEnrolledInBoardingSchool())
            {
                return(false);
            }

            /*
             * else if (!AfterschoolActivity.WorldHasSchoolRabbitHole())
             * {
             *  return false;
             * }
             */
            else if (HasAfterschoolActivityOfType(actor, activityToCheck))
            {
                return(false);
            }
            else if (HasAfterschoolActivityOnDays(actor, GetDaysForActivityType(activityToCheck)))
            {
                greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(AfterschoolActivity.LocalizeString(actor.IsFemale, "DayConflict", new object[0x0]));
                return(false);
            }
            else if (DoesActivityConflictWithJob(actor, activityToCheck))
            {
                return(false);
            }
            else if (teen && school.HasCompletedTeenAfterschoolActivityRecital)
            {
                return(false);
            }
            else if (HasCompletedRecitalForType(school, activityToCheck))
            {
                return(false);
            }
            else if (IsChildActivity(activityToCheck) && AlreadyHasChildActivity(actor))
            {
                return(false);
            }

            AgingManager singleton = AgingManager.Singleton;
            float        num       = singleton.AgingYearsToSimDays(singleton.GetCurrentAgingStageLength(actor));
            float        num2      = singleton.AgingYearsToSimDays(actor.AgingYearsSinceLastAgeTransition);
            float        num3      = num - num2;

            if (num3 <= AfterschoolActivity.kDaysBeforeAgingTrigger)
            {
                greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback(AfterschoolActivity.LocalizeString(actor.IsFemale, "AboutToAgeUp", new object[] { actor }));
                return(false);
            }

            return(true);
        }
Exemplo n.º 19
0
            public override bool Get(MiniSimDescription me, IMiniSimDescription actor, Dictionary <int, int> results)
            {
                try
                {
                    float agingYearsSinceLastAgeTransition = me.AgingYearsSinceLastAgeTransition;

                    int daysToTransition = (int)(AgingManager.Singleton.AgingYearsToSimDays(AgingManager.GetMaximumAgingStageLength(me)) - AgingManager.Singleton.AgingYearsToSimDays(agingYearsSinceLastAgeTransition));

                    results[daysToTransition] = daysToTransition;
                    return(true);
                }
                catch
                {
                    return(false);
                }
            }
Exemplo n.º 20
0
        protected string GetDetails(List <IMiniSimDescription> sims)
        {
            int npcs = 0, homeless = 0, tourists = 0, residents = 0;

            Dictionary <CASAgeGenderFlags, GenderItem> ages = new Dictionary <CASAgeGenderFlags, GenderItem>();

            Dictionary <OccultTypes, GenderItem> occults = new Dictionary <OccultTypes, GenderItem>();

            GenderItem childless = new GenderItem();
            GenderItem married   = new GenderItem();

            GenderItem fertile = new GenderItem();

            int malePregnancies = 0, femalePregnancies = 0, unknownPregnancies = 0;

            int   totalParents  = 0;
            float totalChildren = 0;

            bool includesHuman = false;

            Dictionary <Household, bool> houses = new Dictionary <Household, bool>();

            Dictionary <CASAgeGenderFlags, bool> species = new Dictionary <CASAgeGenderFlags, bool>();

            foreach (IMiniSimDescription miniSim in sims)
            {
                SimDescription member = miniSim as SimDescription;
                if (member == null)
                {
                    continue;
                }

                Household household = member.Household;
                if (household == null)
                {
                    continue;
                }

                if (!household.IsSpecialHousehold)
                {
                    houses[household] = true;
                }

                species[member.Species] = true;

                if (member.IsHuman)
                {
                    includesHuman = true;
                }

                if (member.OccultManager != null)
                {
                    foreach (OccultTypes type in Enum.GetValues(typeof(OccultTypes)))
                    {
                        if (member.OccultManager.HasOccultType(type))
                        {
                            GenderItem item;
                            if (!occults.TryGetValue(type, out item))
                            {
                                item = new GenderItem();
                                occults.Add(type, item);
                            }

                            item.Inc(member.IsFemale);
                        }
                    }
                }

                if (SimTypes.IsService(household))
                {
                    npcs++;
                }
                else if (household.IsTouristHousehold)
                {
                    tourists++;
                }
                else if (household.LotHome == null)
                {
                    homeless++;
                }
                else
                {
                    residents++;

                    if (member.IsPregnant)
                    {
                        if (member.Pregnancy.mGender == CASAgeGenderFlags.Male)
                        {
                            malePregnancies++;
                        }
                        else if (member.Pregnancy.mGender == CASAgeGenderFlags.Female)
                        {
                            femalePregnancies++;
                        }
                        else
                        {
                            unknownPregnancies++;
                        }

                        residents++;
                    }

                    int numChildren = NRaas.CommonSpace.Helpers.Relationships.GetChildren(member).Count;
                    if (numChildren > 0)
                    {
                        totalChildren += numChildren;
                        totalParents++;
                    }
                    else
                    {
                        if ((member.YoungAdult) || (member.Adult))
                        {
                            childless.Inc(member.IsFemale);
                        }
                    }

                    if ((member.Partner != null) && (member.Partner.CreatedSim != null))
                    {
                        married.Inc(member.IsFemale);
                    }

                    GenderItem age;
                    if (!ages.TryGetValue(member.Age, out age))
                    {
                        age = new GenderItem();
                        ages.Add(member.Age, age);
                    }

                    age.Inc(member.IsFemale);

                    if ((member.YoungAdult) || (member.Adult))
                    {
                        fertile.Inc(member.IsFemale);
                    }

                    if (member.Pregnancy != null)
                    {
                        totalChildren++;
                    }
                }
            }

            long males   = malePregnancies;
            long females = femalePregnancies;

            float adults   = 0;
            float children = 0;

            foreach (KeyValuePair <CASAgeGenderFlags, GenderItem> item in ages)
            {
                males   += item.Value.mMale;
                females += item.Value.mFemale;

                if ((item.Key == CASAgeGenderFlags.YoungAdult) || (item.Key == CASAgeGenderFlags.Adult))
                {
                    adults += item.Value.mMale + item.Value.mFemale;
                }
                else if (item.Key != CASAgeGenderFlags.Elder)
                {
                    children += item.Value.mMale + item.Value.mFemale;
                }
            }

            string msg = null;

            List <object> objects = new List <object>();

            objects.Add(houses.Count);
            objects.Add(residents);
            objects.Add(npcs);
            objects.Add(homeless);
            objects.Add(tourists);
            objects.Add(males);
            objects.Add(females);

            msg += Common.Localize("Population:General", false, objects.ToArray());

            msg += Common.Localize("Population:Pregnancies", false, new object[] { malePregnancies, femalePregnancies, unknownPregnancies });

            objects.Clear();

            CASAgeGenderFlags[] ageFlags = null;

            if (includesHuman)
            {
                ageFlags = new CASAgeGenderFlags[] { CASAgeGenderFlags.Baby, CASAgeGenderFlags.Toddler, CASAgeGenderFlags.Child, CASAgeGenderFlags.Teen, CASAgeGenderFlags.YoungAdult, CASAgeGenderFlags.Adult, CASAgeGenderFlags.Elder };
            }
            else
            {
                ageFlags = new CASAgeGenderFlags[] { CASAgeGenderFlags.Child, CASAgeGenderFlags.Adult, CASAgeGenderFlags.Elder };
            }

            foreach (CASAgeGenderFlags age in ageFlags)
            {
                GenderItem item;
                if (ages.TryGetValue(age, out item))
                {
                    objects.Add(item.mMale);
                    objects.Add(item.mFemale);
                }
                else
                {
                    objects.Add(0);
                    objects.Add(0);
                }
            }

            if (includesHuman)
            {
                msg += Common.Localize("Population:AgeBreakdown", false, objects.ToArray());
            }
            else
            {
                msg += Common.Localize("Population:PetAgeBreakdown", false, objects.ToArray());
            }

            objects.Clear();
            objects.Add(married.mMale);
            objects.Add(married.mFemale);
            objects.Add(childless.mMale);
            objects.Add(childless.mFemale);

            msg += Common.Localize("Population:FamilyBreakdown", false, objects.ToArray());

            if (species.Count == 1)
            {
                if (totalParents > 0)
                {
                    msg += Common.Localize("Population:ChildToParent", false, new object[] { (totalChildren / totalParents) });
                }
            }

            string occultText = null;

            foreach (KeyValuePair <OccultTypes, GenderItem> occult in occults)
            {
                occultText += Common.Localize("Population:Occult", false, new object[] { OccultTypeHelper.GetLocalizedName(occult.Key), occult.Value.mMale, occult.Value.mFemale });
            }

            if (!string.IsNullOrEmpty(occultText))
            {
                msg += Common.NewLine + occultText;
            }

            if (species.Count == 1)
            {
                if (children > 0f)
                {
                    msg += Common.Localize("Population:AdultToChild", false, new object[] { adults, children, (adults / children) });
                }

                if (includesHuman)
                {
                    float adultLength = AgingManager.GetAgingStageLength(CASAgeGenderFlags.Human, CASAgeGenderFlags.YoungAdult);
                    adultLength += AgingManager.GetAgingStageLength(CASAgeGenderFlags.Human, CASAgeGenderFlags.Adult);

                    float childLength = AgingManager.GetAgingStageLength(CASAgeGenderFlags.Human, CASAgeGenderFlags.Baby);
                    childLength += AgingManager.GetAgingStageLength(CASAgeGenderFlags.Human, CASAgeGenderFlags.Toddler);
                    childLength += AgingManager.GetAgingStageLength(CASAgeGenderFlags.Human, CASAgeGenderFlags.Child);
                    childLength += AgingManager.GetAgingStageLength(CASAgeGenderFlags.Human, CASAgeGenderFlags.Teen);

                    if (childLength > 0f)
                    {
                        msg += Common.Localize("Population:PopGrowth", false, new object[] { adultLength, childLength, (adultLength / childLength) });
                    }
                }
            }

            return(msg);
        }
Exemplo n.º 21
0
        public static void DayPassedCallback(AgingManager ths)
        {
            List<AgingState> statesToGraduate = new List<AgingState>();
            bool silentGraduation = true;
            bool noSchools = Sims3.Gameplay.Queries.CountObjects<ISchoolRabbitHole>() == 0x0;
            if (ths.Enabled)
            {
                float hoursPassedOfDay = SimClock.HoursPassedOfDay;
                float agingYearsPassed = 1f / ths.SimDaysPerAgingYear;
                if (hoursPassedOfDay > AgingManager.kHourToShowBirthdayMessage)
                {
                    foreach (AgingState state in ths.AgingStates)
                    {
                        if (state != null)
                        {
                            state.AgingYearsPassedSinceLastTransition += agingYearsPassed;
                        }
                    }
                    return;
                }

                if (!GameUtils.IsFutureWorld())
                {
                    ths.AgeVacationWorldSims(agingYearsPassed);
                }

                foreach (AgingState state in ths.AgingStates)
                {
                    try
                    {
                        if (ths.IsAgingStateValid(state))
                        {
                            state.AgingYearsPassedSinceLastTransition += agingYearsPassed;
                            state.DayPassedSinceLastTransition = true;
                            Sim createdSim = state.SimDescription.CreatedSim;
                            if (createdSim != null)
                            {
                                Sims3.Gameplay.UI.HudModel hudModel = Responder.Instance.HudModel as Sims3.Gameplay.UI.HudModel;
                                if (hudModel != null)
                                {
                                    hudModel.OnSimAgeChanged(createdSim.ObjectId);
                                }
                            }

                            // Custom
                            CommonDayPassedUpdates(ths, state, statesToGraduate, ref silentGraduation, noSchools);

                            if (((state.AgeTransitionEarlyMessageAlarm != AlarmHandle.kInvalidHandle) || (state.AgeTransitionWithoutCakeAlarm != AlarmHandle.kInvalidHandle)) || (state.AgeTransitionMessageAlarm != AlarmHandle.kInvalidHandle))
                            {
                                float timeLeft = AlarmManager.Global.GetTimeLeft(state.AgeTransitionWithoutCakeAlarm, TimeUnit.Hours);
                                if ((timeLeft > 0f) && (timeLeft <= 24f))
                                {
                                    continue;
                                }
                                ths.CancelAgingAlarmsForSim(state);
                            }

                            IAlarmOwner simDescription = state.SimDescription;
                            if (ths.SimIsOldEnoughToTransition(state))
                            {
                                if (state.SimDescription.Age == CASAgeGenderFlags.Elder)
                                {
                                    EventTracker.SendEvent(new MiniSimDescriptionEvent(EventTypeId.kSimGettingOld, state.SimDescription));

                                    if (AgingStateEx.IsInactiveActive(state))
                                    {
                                        AgingStateEx.AgeTransitionWithoutCakeTask.Perform(state);
                                    }
                                    else
                                    {
                                        state.AgeTransitionWithoutCakeAlarm = AlarmManager.Global.AddAlarm(RandomUtil.GetFloat(12f, 24f), TimeUnit.Hours, state.AgeTransitionWithoutCakeCallback, "The Cake is a Lie and Then You Die", AlarmType.AlwaysPersisted, simDescription);
                                        AlarmManager.Global.AlarmWillYield(state.AgeTransitionWithoutCakeAlarm);
                                    }
                                }
                                else
                                {
                                    if (AgingStateEx.IsInactiveActive(state))
                                    {
                                        AgingStateEx.AgeTransitionWithoutCakeTask.Perform(state);
                                    }
                                    else
                                    {
                                        float time = AgingManager.kHourToShowBirthdayMessage - hoursPassedOfDay;
                                        float maxValue = float.MaxValue;
                                        if (createdSim != null)
                                        {
                                            maxValue = (24f + createdSim.HoursUntilWakeupTime) - AgingManager.kHourToAgeWithoutCake;
                                        }

                                        maxValue = Math.Min(maxValue, AgingManager.kLatestHourToAgeWithoutCake - hoursPassedOfDay);

                                        state.AgeTransitionWithoutCakeAlarm = AlarmManager.Global.AddAlarmRepeating(maxValue, TimeUnit.Hours, state.AgeTransitionWithoutCakeCallback, 15f, TimeUnit.Minutes, "The Cake is a Lie", AlarmType.AlwaysPersisted, simDescription);
                                        AlarmManager.Global.AlarmWillYield(state.AgeTransitionWithoutCakeAlarm);

                                        if (!state.SimDescription.IsEnrolledInBoardingSchool())
                                        {
                                            state.AgeTransitionMessageAlarm = AlarmManager.Global.AddAlarm(time, TimeUnit.Hours, state.ShowAgeTransitionMessageCallback, "Tell Player that the Cake is a Lie", AlarmType.AlwaysPersisted, simDescription);
                                            AlarmManager.Global.AlarmWillYield(state.AgeTransitionMessageAlarm);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                if (!state.SimDescription.Elder && ths.SimIsCloseToAging(state, AgingManager.kDaysEarlyToShowBirthdayMessage))
                                {
                                    float num6 = AgingManager.kHourToShowBirthdayMessage - hoursPassedOfDay;
                                    state.AgeTransitionEarlyMessageAlarm = AlarmManager.Global.AddAlarm(num6, TimeUnit.Hours, state.ShowAgeTransitionEarlyMessageCallback, "Tell player that the cake will be a lie in a few days", AlarmType.AlwaysPersisted, simDescription);
                                    AlarmManager.Global.AlarmWillYield(state.AgeTransitionEarlyMessageAlarm);
                                }

                                if (state.SimDescription.Teen && ths.SimIsCloseToAging(state, AgingManager.kDaysEarlyToShowGraduationMessage))
                                {
                                    float num7 = AgingManager.kHourToShowGraduationMessage - hoursPassedOfDay;
                                    state.GraduationEarlyMessageAlarm = AlarmManager.Global.AddAlarm(num7, TimeUnit.Hours, state.ShowGraduationEarlyMessageCallback, "Tell player that graduation will be in a few days", AlarmType.AlwaysPersisted, simDescription);
                                    AlarmManager.Global.AlarmWillYield(state.GraduationEarlyMessageAlarm);
                                }
                            }

                            if (((createdSim != null) && createdSim.IsSelectable) && (state.SimDescription.Teen && ths.SimIsCloseToAging(state, AgingManager.kDaysBeforeAgingToDelayGraduation)))
                            {
                                statesToGraduate = null;
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(state.SimDescription, e);
                    }
                }
            }
            else
            {
                foreach (AgingState state3 in ths.AgingStates)
                {
                    if (ths.IsAgingStateValid(state3))
                    {
                        state3.DayPassedSinceLastTransition = true;

                        // Custom
                        CommonDayPassedUpdates(ths, state3, statesToGraduate, ref silentGraduation, noSchools);
                    }
                }
            }

            if ((statesToGraduate != null) && (statesToGraduate.Count > 0x0))
            {
                foreach (AgingState state4 in statesToGraduate)
                {
                    try
                    {
                        if (noSchools)
                        {
                            state4.SimDescription.GraduationType = GraduationType.NoSchool;
                        }
                        else if (silentGraduation)
                        {
                            state4.SimDescription.GraduationType = GraduationType.Graduate;
                            Sim sim2 = state4.SimDescription.CreatedSim;
                            if (sim2 != null)
                            {
                                sim2.SetDefaultGraduatedStateIfNeccessary();
                            }
                        }
                        else
                        {
                            School.GraduateSim(state4.SimDescription);
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(state4.SimDescription, e);
                    }
                    finally
                    {
                        state4.ShouldBeGraduating = false;
                    }
                }
            }
        }
Exemplo n.º 22
0
        public SimDescription CreateNewSim(SimDescription mom, SimDescription dad, CASAgeGenderFlags ages, CASAgeGenderFlags genders, CASAgeGenderFlags species, bool updateGenealogy)
        {
            if (dad == null)
            {
                dad = GetSim(CASAgeGenderFlags.Male, species, mom);
                if (dad == null)
                {
                    dad = GetSim(CASAgeGenderFlags.Female, species, mom);
                    if (dad == null)
                    {
                        return(null);
                    }
                }
            }

            CASAgeGenderFlags gender = (CASAgeGenderFlags)RandomUtil.SelectOneRandomBit((uint)(genders));
            CASAgeGenderFlags age    = (CASAgeGenderFlags)RandomUtil.SelectOneRandomBit((uint)(ages));

            if (dad.CelebrityManager == null)
            {
                dad.Fixup();
            }

            if (mom.CelebrityManager == null)
            {
                mom.Fixup();
            }

            SimDescription newSim = null;

            try
            {
                if (mom.Species == CASAgeGenderFlags.Human)
                {
                    newSim = Genetics.MakeDescendant(dad, mom, age, gender, 100, new Random(), false, updateGenealogy, true, GetGeneticWorld(), false);

                    newSim.HomeWorld = GameUtils.GetCurrentWorld();
                }
                else
                {
                    newSim = GeneticsPet.MakePetDescendant(dad, mom, age, gender, mom.Species, new Random(), updateGenealogy, GeneticsPet.SetName.SetNameNonInteractive, 0, OccultTypes.None);
                }
            }
            catch (Exception e)
            {
                Common.Exception(dad, mom, e);
            }

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

            if (!updateGenealogy)
            {
                FacialBlends.RandomizeBlends(mStats.AddStat, newSim, new Vector2(0f, 0f), true, Manager.GetValue <MutationUnsetRangeOption <TManager>, Vector2>(), true, Manager.GetValue <AllowAlienHouseholdOption <TManager>, bool>());
            }

            List <OccultTypes> occults = new List <OccultTypes>();

            occults.AddRange(OccultTypeHelper.CreateList(mom.OccultManager.CurrentOccultTypes, true));
            occults.AddRange(OccultTypeHelper.CreateList(dad.OccultManager.CurrentOccultTypes, true));

            if (updateGenealogy)
            {
                Manager.Sims.ApplyOccultChance(Manager, newSim, occults, Manager.GetValue <ChanceOfHybridOption <TManager>, int>(), Manager.GetValue <MaximumOccultOption <TManager>, int>());
            }
            else if (species == CASAgeGenderFlags.Human)
            {
                int maxCelebrityLevel = Manager.GetValue <MaxCelebrityLevelOption <TManager>, int>();

                if (maxCelebrityLevel >= 0)
                {
                    newSim.CelebrityManager.mOwner = newSim;

                    Skill scienceSkill = SkillManager.GetStaticSkill(SkillNames.Science);
                    if (scienceSkill != null)
                    {
                        scienceSkill.mNonPersistableData.SkillCategory |= SkillCategory.Hidden;
                    }

                    try
                    {
                        newSim.CelebrityManager.ForceSetLevel((uint)RandomUtil.GetInt(maxCelebrityLevel));
                    }
                    finally
                    {
                        if (scienceSkill != null)
                        {
                            scienceSkill.mNonPersistableData.SkillCategory &= ~SkillCategory.Hidden;
                        }
                    }
                }

                occults.AddRange(Manager.GetValue <ImmigrantOccultOption <TManager>, List <OccultTypes> >());
                if (occults.Count > 0)
                {
                    if (RandomUtil.RandomChance(Manager.GetValue <ChanceOfOccultOption <TManager>, int>()))
                    {
                        OccultTypeHelper.Add(newSim, RandomUtil.GetRandomObjectFromList(occults), false, false);
                    }
                }
            }

            Manager.Sims.ApplyOccultChance(Manager, newSim, occults, Manager.GetValue <ChanceOfHybridOption <TManager>, int>(), Manager.GetValue <MaximumOccultOption <TManager>, int>());

            OccultTypeHelper.ValidateOccult(newSim, null);

            OccultTypeHelper.TestAndRebuildWerewolfOutfit(newSim);

            newSim.FirstName = Manager.Sims.EnsureUniqueName(newSim);

            List <Trait> traits = new List <Trait>(newSim.TraitManager.List);

            foreach (Trait trait in traits)
            {
                if (trait.IsHidden)
                {
                    newSim.TraitManager.RemoveElement(trait.Guid);
                }
            }

            List <Trait> choices = AgingManager.GetValidTraits(newSim, true, true, true);

            if (choices.Count > 0)
            {
                while (!newSim.TraitManager.TraitsMaxed())
                {
                    Trait choice = RandomUtil.GetRandomObjectFromList <Trait>(choices);
                    if (!newSim.TraitManager.AddElement(choice.Guid))
                    {
                        break;
                    }
                }
            }

            if (SimFromBinEvents.OnGeneticSkinBlend != null)
            {
                SimFromBinEvents.OnGeneticSkinBlend(mStats, newSim, mom, dad, Manager);
            }

            FixInvisibleTask.Perform(newSim, true);

            if (SimFromBinEvents.OnSimFromBinUpdate != null)
            {
                SimFromBinEvents.OnSimFromBinUpdate(mStats, newSim, mom, dad, Manager);
            }

            INameTakeOption nameTake = Manager.GetOption <NameTakeOption <TManager> >();

            if ((!updateGenealogy) && (nameTake != null))
            {
                bool wasEither;
                newSim.LastName = Manager.Sims.HandleName(nameTake, mom, dad, out wasEither);
            }
            else if (mom != null)
            {
                newSim.LastName = mom.LastName;
            }
            else if (dad != null)
            {
                newSim.LastName = dad.LastName;
            }

            if (!updateGenealogy && Manager.GetValue <CustomNamesOnlyOption <TManager>, bool>())
            {
                newSim.LastName = LastNameListBooter.GetRandomName(!Manager.GetValue <CustomNamesOnlyOption <TManager>, bool>(), newSim.Species, newSim.IsFemale);
            }

            return(newSim);
        }