Example #1
0
        public void UpdateJournal(Career job)
        {
            if (!mUpdatedToday)
            {
                if (job.SharedData == null)
                {
                    return;
                }

                mUpdatedToday = true;
                OmniJournalData data = OmniJournalData.GetJournalData(job.SharedData.Name, job.CareerLevel);

                if (data != null)
                {
                    data = data.Clone();
                    if (data != null)
                    {
                        mJournalEdition = data.CurrentEdition + SimClock.ElapsedCalendarDays();
                        base.Data       = data;
                        base.Data.ID    = data.ID + mJournalEdition;
                        base.BookId     = base.Data.ID;

                        mBookCareer  = job.SharedData.Name;
                        mBookLevelId = job.CareerLevel;
                    }
                }
            }
        }
Example #2
0
        // Methods
        public static OmniJournal CreateOutOfWorld(OmniJournalData data, SimDescription Actor)
        {
            OmniJournal journal = ObjectCreation.CreateObject(0x6694B72C99D44369, ProductVersion.BaseGame, null) as OmniJournal;

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

            journal.Data            = data.Clone();
            journal.mJournalEdition = data.CurrentEdition + SimClock.ElapsedCalendarDays();
            journal.Data.ID         = data.ID + journal.mJournalEdition;

            Career career = Actor.Occupation as Career;

            if (career != null)
            {
                journal.mBookCareer = career.SharedData.Name;
            }

            journal.mBookLevelId  = Actor.Occupation.CareerLevel;
            journal.mBookId       = journal.Data.ID;
            journal.mOwner        = Actor;
            journal.mUpdatedToday = true;
            journal.SetGeometryState(journal.Data.GeometryState);
            journal.SetMaterial(journal.Data.MaterialState);
            return(journal);
        }
Example #3
0
                public override bool Test(Sim a, RabbitHole target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    HomeSchooling school = a.School as HomeSchooling;

                    if (school == null)
                    {
                        return(false);
                    }

                    if (isAutonomous)
                    {
                        if ((school.OwnersHomework != null) &&
                            (school.OwnersHomework.PercentComplete == 100f))
                        {
                            if (school.mLastHomeworkDay < SimClock.ElapsedCalendarDays())
                            {
                                return(true);
                            }
                        }
                        return(false);
                    }
                    else
                    {
                        return(true);
                    }
                }
Example #4
0
        public void AddSummaryToLog(string localizedText, string[] extended)
        {
            Common.StringBuilder extendedText = new Common.StringBuilder();

            extendedText += EAText.GetNumberString(SimClock.ElapsedCalendarDays()) + " ";
            extendedText += SimClock.CurrentTime().ToString() + ": ";
            extendedText += localizedText;

            if (extended != null)
            {
                extendedText += " (";

                bool first = true;
                foreach (string text in extended)
                {
                    if (!first)
                    {
                        extendedText += " ";
                    }

                    extendedText += text;
                    first         = false;
                }

                extendedText += ")";
            }

            AddValue <DumpStoryLogOption, string>(extendedText.ToString());
        }
Example #5
0
        public static string TimeTooltipString()
        {
            /*
             * if (GameUtils.IsOnVacation())
             * {
             *  return Localization.LocalizeString("Gameplay/Utilities/SimClock:DayOfVacation", new object[] { this.CurrentTripDay, this.MaxTripDays });
             * }
             */

            int  week = SimClock.ElapsedCalendarWeeks() + 0x1;
            int  day  = (SimClock.ElapsedCalendarDays() + 0x1) - (0x7 * (week - 0x1));
            long priorWorldTicksPlayed = GameStates.PriorWorldTicksPlayed;

            if (priorWorldTicksPlayed != 0x0L)
            {
                int num4 = (int)SimClock.ConvertFromTicks(priorWorldTicksPlayed, TimeUnit.Weeks);
                int num5 = ((int)SimClock.ConvertFromTicks(priorWorldTicksPlayed, TimeUnit.Days)) - (0x7 * num4);
                week += num4;
                day  += num5;
                if (day > 0x7)
                {
                    week++;
                    day -= 0x7;
                }
            }

            return(Localization.LocalizeString("Gameplay/Utilities/SimClock:TimePlayed", new object[] { week, day }));
        }
Example #6
0
        protected override void PrivatePerform(SimDescription sim, SimData data, ScenarioFrame frame)
        {
            PregnancySimData other = data.Get <PregnancySimData>();

            if (sim.IsPregnant)
            {
                if ((other.mLastCheckPregnancy != 0) && (other.mLastCheckPregnancy < SimClock.ElapsedCalendarDays()))
                {
                    if (!AllowProgression(sim))
                    {
                        // Delay pregnancy indefinitely
                        sim.Pregnancy.mHourOfPregnancy = other.mPregnancyHour;

                        IncStat("Pregnancy Suspended");
                    }
                    else
                    {
                        if (other.mPregnancyHour == sim.Pregnancy.mHourOfPregnancy)
                        {
                            IncStat(sim.FirstName + " " + sim.LastName + ": Stuck Pregnancy", Common.DebugLevel.High);

                            if (!SimTypes.IsSelectable(sim))
                            {
                                Sims.Reset(sim);

                                if ((sim.CreatedSim != null) && (sim.LotHome != null))
                                {
                                    SimDescription dad = ManagerSim.Find(sim.Pregnancy.DadDescriptionId);
                                    if (dad != null)
                                    {
                                        Sims.Instantiate(dad, sim.LotHome, false);
                                    }

                                    if (sim.Pregnancy.PreggersAlarm != AlarmHandle.kInvalidHandle)
                                    {
                                        AlarmManager.Global.RemoveAlarm(sim.Pregnancy.PreggersAlarm);
                                        sim.Pregnancy.PreggersAlarm = AlarmHandle.kInvalidHandle;
                                    }
                                    sim.Pregnancy.Continue(sim.CreatedSim, true);

                                    IncStat("Pregnancy Reset");
                                }
                            }
                        }
                    }
                }

                other.mPregnancyHour      = sim.Pregnancy.mHourOfPregnancy;
                other.mLastCheckPregnancy = SimClock.ElapsedCalendarDays();
            }
            else
            {
                other.mPregnancyHour      = 0;
                other.mLastCheckPregnancy = 0;
            }
        }
        private new void TriggerTravelToUniversityWorld()
        {
            RemoveTriggerAlarm();
            List <Sim> allTravelers = new List <Sim>(TravelingSims);

            allTravelers.Add(Actor);

            string reason = null;

            // Custom
            if (Helpers.TravelUtilEx.FinalBoardingCall(Actor.Household, allTravelers, WorldName.University, false, ref reason))
            {
                int travelDuration = (TravelDuration / 7) * Traveler.Settings.mUniversityTermLength;

                ForeignVisitorsSituation.ForceKillForeignVisitorsSituation();
                HolographicProjectionSituation.ForceKillHolographicVisitorsSituation();

                Camera.SetView(CameraView.MapView, false, true);
                int tripLength           = (TravelUtil.sOverriddenTripLength > 0x0) ? TravelUtil.sOverriddenTripLength : travelDuration;
                int lastTimeAtUniversity = -2147483648;
                foreach (Sim sim in allTravelers)
                {
                    if (lastTimeAtUniversity < sim.DegreeManager.LastTimeAtUniversity)
                    {
                        lastTimeAtUniversity = sim.DegreeManager.LastTimeAtUniversity;
                    }
                }

                int numDaysSinceLastInDestWorld = -1;
                if (lastTimeAtUniversity >= 0x0)
                {
                    numDaysSinceLastInDestWorld = SimClock.ElapsedCalendarDays() - lastTimeAtUniversity;
                }

                // Custom
                GameStatesEx.TravelToVacationWorld(kUniversityWorldName, mTravelingSimsGuids, tripLength, numDaysSinceLastInDestWorld);
            }
            else
            {
                Actor.ShowTNSIfSelectable(TravelUtil.LocalizeString(Actor.IsFemale, "CantTravelTNS", new object[] { TravelCost }) + Common.NewLine + Common.NewLine + reason, StyledNotification.NotificationStyle.kSystemMessage, ObjectGuid.InvalidObjectGuid);
                Actor.ModifyFunds(TravelCost);

                foreach (Sim sim2 in allTravelers)
                {
                    if (!sim2.IsDying())
                    {
                        sim2.AddExitReason(ExitReason.CanceledByScript);
                    }
                }
            }
        }
Example #8
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            Sim sim = Sim.CreatedSim;

            BandInstrument.PlayBandInstrument <TInstrument> interaction = sim.InteractionQueue.GetCurrentInteraction() as BandInstrument.PlayBandInstrument <TInstrument>;
            if (interaction != null)
            {
                int elapsedCalendarDays = SimClock.ElapsedCalendarDays();

                SimData data = GetData <SimData>(Sim);

                DateAndTime lastChange = data.mLast;
                lastChange.Ticks += SimClock.ConvertToTicks(2f, TimeUnit.Hours);

                if (lastChange > SimClock.CurrentTime())
                {
                    data.mLast = SimClock.CurrentTime();

                    interaction.TriggerAudio(false);

                    if (interaction.mInstrumentSound == null)
                    {
                        Sims3.Gameplay.Skills.Guitar.Composition PlayingComposition = null;

                        try
                        {
                            PlayingComposition = (interaction.mSkill as BandSkill).GetRandomComposition(false);
                        }
                        catch (Exception)
                        {
                            // If the known compositions is zero, GetRandom will except
                        }

                        if (PlayingComposition != null)
                        {
                            interaction.mInstrumentSound = new ObjectSound(interaction.Target.ObjectId, PlayingComposition.AudioClip);
                            interaction.mInstrumentSound.StartLoop();
                            return(true);
                        }
                    }
                }
            }

            return(false);
        }
Example #9
0
        public int GetElapsedTime <T>(SimDescription sim)
            where T : GenericOptionItem <int>, IReadSimLevelOption, IElapsedSimLevelOption, new()
        {
            if (sim == null)
            {
                return(0);
            }
            else
            {
                int value = GetValue <T, int>(sim);
                if (value < 0)
                {
                    return(int.MaxValue);
                }

                return(SimClock.ElapsedCalendarDays() - value);
            }
        }
Example #10
0
        public override string ToString()
        {
            Common.StringBuilder text = new Common.StringBuilder();

            SimDescription sim = SimDescription;

            if (sim == null)
            {
                text.AddXML("SimID", "Null");
            }
            else
            {
                text.AddXML("SimName", sim.FullName);
                text.AddXML("SimID", sim.SimDescriptionId);
            }

            foreach (string clan in mClans)
            {
                text.AddXML("Clan", clan);
            }

            text.AddXML("CurrentDay", SimClock.ElapsedCalendarDays());

            if (Other != null)
            {
                text += Common.NewLine + Other.ToString();
            }
            else
            {
                text += Common.NewLine + "<NoOther/>";
            }

            text += Common.NewLine + base.ToString();

            return(text.ToString());
        }
Example #11
0
        protected new void TriggerTravelToVacationWorld()
        {
            RemoveTriggerAlarm();

            List <Sim> allTravelers = new List <Sim>(Followers);

            allTravelers.Add(Actor);

            string reason = null;

            // Custom
            if ((TravelingSimGuids.Count == 0) || (Helpers.TravelUtilEx.FinalBoardingCall(Actor.Household, allTravelers, DestinationWorldName, false, ref reason)))
            {
                ForeignVisitorsSituation.ForceKillForeignVisitorsSituation();
                HolographicProjectionSituation.ForceKillHolographicVisitorsSituation();

                int lastTimeOnVacation = -2147483648;
                foreach (Sim sim in allTravelers)
                {
                    if (lastTimeOnVacation < sim.VisaManager.LastTimeOnVacation)
                    {
                        lastTimeOnVacation = sim.VisaManager.LastTimeOnVacation;
                    }
                }
                int numDaysSinceLastInDestWorld = -1;
                if (lastTimeOnVacation > 0)
                {
                    numDaysSinceLastInDestWorld = SimClock.ElapsedCalendarDays() - lastTimeOnVacation;
                }

                Camera.SetView(CameraView.MapView, false, true);
                int tripLength = (TravelUtil.sOverriddenTripLength > 0x0) ? TravelUtil.sOverriddenTripLength : TravelDuration;

                // Custom
                GameStatesEx.TravelToVacationWorld(DestinationWorldName, TravelingSimGuids, tripLength, numDaysSinceLastInDestWorld);

                TelemetryStats.VacationTelemetryInfo vacationTelemetryInfo = new TelemetryStats.VacationTelemetryInfo();
                vacationTelemetryInfo.LeavingHomeWorld = true;
                vacationTelemetryInfo.WorldId          = DestinationWorldName;

                int num2 = 0x0;

                if (TravelingSimGuids.Count > 0)
                {
                    vacationTelemetryInfo.NumberOfSimsInHoushold    = Households.NumSims(Actor.Household);
                    vacationTelemetryInfo.NumberOfSimsThatDidTravel = allTravelers.Count;

                    foreach (Sim sim in Households.AllSims(Actor.Household))
                    {
                        // Custom
                        if (CommonSpace.Helpers.TravelUtilEx.CheckForReasonsToFailTravel(sim.SimDescription, Traveler.Settings.mTravelFilter, DestinationWorldName, false, false) == null)
                        {
                            num2++;
                        }
                    }
                }
                else
                {
                    vacationTelemetryInfo.NumberOfSimsInHoushold    = 0;
                    vacationTelemetryInfo.NumberOfSimsThatDidTravel = 0;
                }

                vacationTelemetryInfo.NumberOfSimsAbleToTravel = num2;
                vacationTelemetryInfo.VisaLevels = new PairedListDictionary <ulong, int>();
                foreach (Sim sim2 in allTravelers)
                {
                    int visaLevel = sim2.VisaManager.GetVisaLevel(DestinationWorldName);
                    vacationTelemetryInfo.VisaLevels.Add(sim2.SimDescription.SimDescriptionId, visaLevel);
                }

                vacationTelemetryInfo.TravelDateAndTime = SimClock.CurrentTime();
                EventTracker.SendEvent(new VacationInfoEvent(EventTypeId.kVacationTelemetryInfo, vacationTelemetryInfo));
            }
            else
            {
                if (DestinationWorldName == WorldName.FutureWorld)
                {
                    Actor.ShowTNSIfSelectable(TravelUtil.LocalizeString(Actor.IsFemale, "CantTravelFutureTNS", new object[] { TravelCost }), StyledNotification.NotificationStyle.kSystemMessage, ObjectGuid.InvalidObjectGuid);
                }
                else
                {
                    Actor.ShowTNSIfSelectable(TravelUtil.LocalizeString(Actor.IsFemale, "CantTravelTNS", new object[] { TravelCost }) + Common.NewLine + Common.NewLine + reason, StyledNotification.NotificationStyle.kSystemMessage, ObjectGuid.InvalidObjectGuid);
                }

                Actor.ModifyFunds(TravelCost);

                foreach (Sim sim3 in allTravelers)
                {
                    if (!sim3.IsDying())
                    {
                        sim3.AddExitReason(ExitReason.CanceledByScript);
                    }
                }
            }
        }
Example #12
0
        protected void HandleHomework(Sim sim, bool fromRabbithole)
        {
            if (sim == null)
            {
                return;
            }

            if (sim.School == null)
            {
                return;
            }

            if ((SimTypes.IsSelectable(sim)) &&
                (sim.School.OwnersHomework != null) &&
                (sim.School.OwnersHomework.PercentComplete == 0f))
            {
                Notify(sim, Common.Localize("HomeSchooling:HaveHomework", sim.IsFemale, new object[] { sim }));
            }
            else
            {
                bool bExistingHomework = false;

                if (sim.School.OwnersHomework != null)
                {
                    float perfGain = NRaas.Careers.Settings.mPerformancePerHomework * ((sim.School.OwnersHomework.PercentComplete - 50f) / 100f);

                    sim.School.AddPerformance(perfGain);

                    if (sim.SimDescription.CareerManager != null)
                    {
                        sim.SimDescription.CareerManager.UpdatePerformanceUI(this);
                    }

                    sim.School.OwnersHomework.Dispose();

                    sim.School.OwnersHomework = null;

                    bExistingHomework = true;
                }

                if (sim.School.OwnersHomework == null)
                {
                    sim.School.OwnersHomework = GlobalFunctions.CreateObjectOutOfWorld("Homework") as Homework;
                    sim.School.OwnersHomework.OwningSimDescription = sim.SimDescription;

                    sim.Inventory.TryToAdd(sim.School.OwnersHomework, false);
                }

                sim.School.OwnersHomework.PercentComplete = 0f;
                sim.School.OwnersHomework.Cheated         = false;

                mLastHomeworkDay = SimClock.ElapsedCalendarDays();

                string suffix = null;
                if (fromRabbithole)
                {
                    suffix = "Rabbithole";
                }

                if (bExistingHomework)
                {
                    Notify(sim, Common.Localize("HomeSchooling:ExistingHomework" + suffix, sim.IsFemale, new object[] { sim }));
                }
                else
                {
                    Notify(sim, Common.Localize("HomeSchooling:NewHomework" + suffix, sim.IsFemale, new object[] { sim }));
                }

                if (SchoolTuning != null)
                {
                    if (sim.School.Performance >= SchoolTuning.GradeThresholdA)
                    {
                        sim.School.mConsecutiveDaysWithA++;
                        if (sim.School.mConsecutiveDaysWithA >= SchoolTuning.DaysWithAForHonorRoll)
                        {
                            sim.BuffManager.AddElement(BuffNames.HonorStudent, Origin.FromGoodGrades);
                        }
                    }
                    else
                    {
                        ActiveTopic.AddToSim(sim, "Complain About School");
                        sim.School.mConsecutiveDaysWithA = 0;
                        if (sim.School.Performance <= SchoolTuning.GradeThresholdF)
                        {
                            sim.BuffManager.AddElement(BuffNames.Failing, Origin.FromBadGrades);
                        }
                    }
                }

                EventTracker.SendEvent(EventTypeId.kFinishedSchool, sim);
            }
        }
Example #13
0
        protected void OnHomeworkCheck()
        {
            try
            {
                if (!(OwnerDescription.CareerManager.School is HomeSchooling))
                {
                    return;
                }

                if (SimTypes.IsSelectable(OwnerDescription))
                {
                    if (GameUtils.IsOnVacation())
                    {
                        return;
                    }
                }

                bool schoolDay = ((SimClock.CurrentDayOfWeek != DaysOfTheWeek.Saturday) && (SimClock.CurrentDayOfWeek != DaysOfTheWeek.Sunday));

                if (schoolDay)
                {
                    // Handles the Field Trip situations
                    RegularWorkDayStartAlarmHandler();

                    /*
                     * if ((sFieldTripSimDescription != null) && (sFieldTripSimDescription.Count > 0x0) && (sLocalFieldTripAlarm == AlarmHandle.kInvalidHandle))
                     * {
                     *  AlarmManager.Global.RemoveAlarm(sFieldTripAlarm);
                     *  sLocalFieldTripAlarm = AlarmManager.Global.AddAlarm(kFieldTripDelayMinutes, TimeUnit.Minutes, BeginFieldTripEx, "Field Trip Alarm", AlarmType.DeleteOnReset, null);
                     *
                     *  sFieldTripAlarm = sLocalFieldTripAlarm;
                     * }
                     */

                    // Don't call this function, it only works properly when run from an interaction
                    //StartWorking();
                }

                if (mMaxPerformance)
                {
                    mPerformance = 100;
                }
                else if ((mLastHomeworkDay + 1) < SimClock.ElapsedCalendarDays())
                {
                    if (schoolDay)
                    {
                        if (SimTypes.IsSelectable(OwnerDescription))
                        {
                            AddPerformance(-NRaas.Careers.Settings.mPerformancePerHomework);

                            if (OwnerDescription.CareerManager != null)
                            {
                                OwnerDescription.CareerManager.UpdatePerformanceUI(this);
                            }

                            Notify(OwnerDescription.CreatedSim, Common.Localize("HomeSchooling:MissHomework", OwnerDescription.IsFemale, new object[] { OwnerDescription }));

                            mLastHomeworkDay = SimClock.ElapsedCalendarDays();
                        }
                        else
                        {
                            HandleHomework(OwnerDescription.CreatedSim, false);
                        }
                    }
                }

                if (schoolDay)
                {
                    // Disables the field trip check
                    sHasAskedPermissionForFieldTrip = true;

                    FinishWorking();
                }

                StartHomeworkAlarm();
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception exception)
            {
                Common.Exception(OwnerDescription, exception);
            }
        }
Example #14
0
        protected override void PrivatePerform(SimDescription sim, SimData data, ScenarioFrame frame)
        {
            MoodSimData other = data.Get <MoodSimData>();

            Sim createdSim = sim.CreatedSim;

            if ((createdSim != null) && (createdSim.InWorld) && (createdSim.Proxy != null) && (!SimTypes.IsSelectable(sim)))
            {
                if (createdSim.BuffManager != null)
                {
                    createdSim.BuffManager.RemoveElement(BuffNames.TooMuchSun);

                    if ((createdSim.BuffManager.HasElement(BuffNames.Starving)) ||
                        (createdSim.BuffManager.HasElement(BuffNames.MadlyThirsty)))
                    {
                        IncStat("Hunger Reset");

                        IncStat(sim.FullName + ": Stuck Sim", Common.DebugLevel.High);

                        Sims.Reset(sim);

                        other.mMoodPushedHome = 0;
                    }
                }

                if ((createdSim.MoodManager != null) && (createdSim.MoodManager.MoodFlavor == MoodFlavor.Miserable))
                {
                    if (other.mMoodPushedHome == 0)
                    {
                        if ((createdSim.InteractionQueue == null) || (sim.LotHome == null))
                        {
                            IncStat("Mood Reset");

                            IncStat(sim.FullName + ": Stuck Townie", Common.DebugLevel.High);

                            Sims.Reset(sim);

                            other.mMoodPushedHome = 0;
                        }
                        else
                        {
                            IncStat("Mood Push");

                            createdSim.InteractionQueue.CancelAllInteractions();
                            createdSim.InteractionQueue.Add(GoHome.Singleton.CreateInstance(sim.LotHome, createdSim, new Sims3.Gameplay.Interactions.InteractionPriority(Sims3.Gameplay.Interactions.InteractionPriorityLevel.UserDirected), false, true));

                            other.mMoodPushedHome = SimClock.ElapsedCalendarDays();
                        }
                    }
                    else if ((other.mMoodPushedHome + 1) < SimClock.ElapsedCalendarDays())
                    {
                        IncStat("Mood Reset");

                        IncStat(sim.FullName + ": Stuck Sim", Common.DebugLevel.High);

                        Sims.Reset(sim);

                        other.mMoodPushedHome = 0;
                    }
                }
                else
                {
                    other.mMoodPushedHome = 0;
                }
            }
        }
Example #15
0
        protected static bool BumpUp(SimDescription a, SimDescription b, bool prompt, bool romantic)
        {
            Relationship relation = Relationship.Get(a, b, true);

            if (relation == null)
            {
                return(false);
            }

            LongTermRelationshipTypes currentState = relation.LTR.CurrentLTR;

            LongTermRelationshipTypes nextState = LongTermRelationshipTypes.Undefined;

            if (romantic)
            {
                nextState = NextPositiveRomanceState(currentState);
            }
            else
            {
                nextState = NextPositiveFriendState(currentState);
            }

            if (nextState == LongTermRelationshipTypes.Undefined)
            {
                if (prompt)
                {
                    SimpleMessageDialog.Show(Common.Localize("Romance:BumpUpTitle"), Common.Localize("Romance:TooHigh"));
                }
                return(false);
            }

            /*
             * if (relation.LTR.RelationshipIsInappropriate(LTRData.Get(nextState)))
             * {
             *  if (prompt)
             *  {
             *      SimpleMessageDialog.Show(Common.Localize("Romance:BumpUpTitle"), Common.Localize ("Romance:Improper", new object[] { Common.LocalizeStatus (a, b, nextState) }));
             *  }
             *  return false;
             * }
             */

            if ((romantic) && (a.Genealogy.IsBloodRelated(b.Genealogy)))
            {
                if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:BloodPrompt", a.IsFemale, new object [] { a, b }))))
                {
                    return(false);
                }
            }

            if ((currentState == LongTermRelationshipTypes.RomanticInterest) && (romantic))
            {
                if ((a.Partner != null) && (a.Partner != b))
                {
                    if ((b.Partner != null) && (b.Partner != a))
                    {
                        if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:DualPartnerPrompt", a.IsFemale, new object[] { a, b }))))
                        {
                            return(false);
                        }
                    }
                    else
                    {
                        if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:PartnerPrompt", a.IsFemale, new object[] { a }))))
                        {
                            return(false);
                        }
                    }
                }
                else if ((b.Partner != null) && (b.Partner != a))
                {
                    if ((prompt) && (!AcceptCancelDialog.Show(Common.Localize("Romance:PartnerPrompt", b.IsFemale, new object[] { b }))))
                    {
                        return(false);
                    }
                }

                if (a.Partner != null)
                {
                    BumpDown(a, a.Partner, false, true);
                }

                if (b.Partner != null)
                {
                    BumpDown(b, b.Partner, false, true);
                }

                if (a.TraitManager == null)
                {
                    a.Fixup();
                }

                if (b.TraitManager == null)
                {
                    b.Fixup();
                }

                Relationships.SetPartner(a, b);
            }

            ForceChangeState(relation, nextState);

            if (romantic)
            {
                if (prompt && relation.RomanceVisibilityState != null)
                {
                    long time = 0;
                    relation.TryGetActiveRomanceStartTime(out time);

                    int days = 0;
                    if (time != 0)
                    {
                        days = (int)SimClock.ElapsedTime(TimeUnit.Days, new DateAndTime(time));
                    }

                    string text = StringInputDialog.Show(Common.Localize("Romance:StartTime"), Common.Localize("Romance:StartPrompt", a.IsFemale, new object[] { a, b, SimClock.ElapsedCalendarDays() }), days.ToString());
                    if (string.IsNullOrEmpty(text))
                    {
                        return(false);
                    }

                    int mValue = 0;
                    if (!int.TryParse(text, out mValue) || mValue > SimClock.ElapsedCalendarDays())
                    {
                        SimpleMessageDialog.Show(Common.Localize("Romance:StartTime"), Common.Localize("Numeric:ErrorInputIgnored"));
                    }
                    else
                    {
                        relation.RomanceVisibilityState.mStartTime = SimClock.Subtract(SimClock.CurrentTime(), TimeUnit.Days, (float)mValue);
                    }
                }
            }

            if (relation.LTR.CurrentLTR == LongTermRelationshipTypes.BestFriendsForever)
            {
                bool isPetBFF = ((!a.IsHuman) || (!b.IsHuman));

                a.HasBFF = true;
                b.HasBFF = true;
                FindAndRemoveBFF(a, b, isPetBFF);
                FindAndRemoveBFF(b, a, isPetBFF);
            }

            if (currentState == relation.LTR.CurrentLTR)
            {
                return(false);
            }

            StyledNotification.Format format = new StyledNotification.Format(Common.Localize("Romance:Success", a.IsFemale, new object[] { a, b, LocalizeStatus(a, b, relation.LTR.CurrentLTR) }), StyledNotification.NotificationStyle.kGameMessagePositive);
            format.mTNSCategory = NotificationManager.TNSCategory.Lessons;
            StyledNotification.Show(format);
            return(true);
        }
Example #16
0
 public void SetElapsedTime <T>(SimDescription sim)
     where T : GenericOptionItem <int>, IElapsedSimLevelOption, IWriteSimLevelOption, new()
 {
     SetValue <T, int>(sim, SimClock.ElapsedCalendarDays());
 }
Example #17
0
        public override string ToString()
        {
            Common.StringBuilder text = new Common.StringBuilder();

            text += StoryProgression.Localize("Accounting:Header", false, new object[] { SimClock.ElapsedCalendarDays() - mStartDay });

            mValues.Sort(new Comparison <Value>(Value.SortByName));

            string result = null;

            int net = 0;

            foreach (Value value in mValues)
            {
                if (value.Amount > 0)
                {
                    result += value.ToString();

                    net += value.Amount;
                }
            }

            if (!string.IsNullOrEmpty(result))
            {
                text += Common.NewLine + Common.NewLine + StoryProgression.Localize("Accounting:Gain");
                text += result;
            }

            result = null;

            foreach (Value value in mValues)
            {
                if (value.Amount < 0)
                {
                    result += value.ToString();

                    net += value.Amount;
                }
            }

            if (!string.IsNullOrEmpty(result))
            {
                text += Common.NewLine + Common.NewLine + StoryProgression.Localize("Accounting:Loss");
                text += result;
            }

            text += Common.NewLine + Common.NewLine + StoryProgression.Localize("Accounting:Net", false, new object[] { net });

            return(text.ToString());
        }
Example #18
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (PromSituation.sInstance == null)
            {
                DateAndTime checkDay = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Days, PromSituation.kNumberOfDaysForAnnouncement);

                if (!HasValue <ValidDaysOption, DaysOfTheWeek>(checkDay.DayOfWeek))
                {
                    IncStat("Wrong Day: " + checkDay.DayOfWeek);
                    return(false);
                }

                int elapsed = (SimClock.ElapsedCalendarDays() - GetValue <DayOfLastOption, int>());
                if (elapsed < GetValue <CooldownOption, int>())
                {
                    AddStat("Cooldown", elapsed);
                    return(false);
                }

                if (!RandomUtil.RandomChance(GetValue <ChanceOption, int>()))
                {
                    IncStat("Chance Fail");
                    return(false);
                }

                if (PromSituation.HasValidConditionsToThrow())
                {
                    IncStat("Created");

                    PromSituation.Create();

                    GetOption <DayOfLastOption>().SetValue(SimClock.ElapsedCalendarDays());

                    return(true);
                }
                else
                {
                    IncStat("Not Satisfied");
                    return(false);
                }
            }
            else if (PromSituation.GetDayOfScheduledProm() == SimClock.CurrentDayOfWeek)
            {
                if (GetValue <DayOffOption, bool>())
                {
                    foreach (SimDescription sim in HouseholdsEx.All(Household.ActiveHousehold))
                    {
                        Occupation career = sim.Occupation;
                        if (career != null)
                        {
                            float endHour = career.FinishTime;
                            if (endHour != -1)
                            {
                                if (endHour > PromSituation.kTimeOfEventStart)
                                {
                                    career.TakePaidTimeOff(1);

                                    IncStat("Time Off");
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }
Example #19
0
 public AccountingData() // required for persistence
 {
     mStartDay = SimClock.ElapsedCalendarDays();
 }
Example #20
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            int elapsedCalendarDays = SimClock.ElapsedCalendarDays();

            RabbitHole.RabbitHoleInteraction <Sim, RabbitHole> work = Sim.CreatedSim.InteractionQueue.GetCurrentInteraction() as RabbitHole.RabbitHoleInteraction <Sim, RabbitHole>;
            if (work == null)
            {
                return(false);
            }

            if (work.Actor == null)
            {
                return(false);
            }

            if (work.mAvailableTones != null)
            {
                int index = 0;
                while (index < work.mAvailableTones.Count)
                {
                    if (work.mAvailableTones[index] == null)
                    {
                        work.mAvailableTones.RemoveAt(index);
                    }
                    else
                    {
                        index++;
                    }
                }
            }

            List <InteractionToneDisplay> displayTones = work.AvailableTonesForDisplay();

            if (displayTones == null)
            {
                IncStat("No Choices");
                return(false);
            }

            List <ITone> tones = new List <ITone>();

            foreach (InteractionToneDisplay tone in displayTones)
            {
                if (tone.InteractionTone == null)
                {
                    continue;
                }

                if (tone.InteractionTone.ToString() == mTone)
                {
                    continue;
                }

                if (!ManagerCareer.VerifyTone(tone.InteractionTone as CareerTone))
                {
                    continue;
                }

                tones.Add(tone.InteractionTone);
            }

            return(ConfigureInteraction(work, tones));
        }
Example #21
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            int elapsedCalendarDays = SimClock.ElapsedCalendarDays();

            RabbitHole.RabbitHoleInteraction <Sim, RabbitHole> work = Sim.CreatedSim.InteractionQueue.GetCurrentInteraction() as RabbitHole.RabbitHoleInteraction <Sim, RabbitHole>;
            if (work == null)
            {
                return(false);
            }

            if (work.Actor == null)
            {
                return(false);
            }

            if (work.mAvailableTones != null)
            {
                int index = 0;
                while (index < work.mAvailableTones.Count)
                {
                    if (work.mAvailableTones[index] == null)
                    {
                        work.mAvailableTones.RemoveAt(index);
                    }
                    else
                    {
                        index++;
                    }
                }
            }

            List <InteractionToneDisplay> displayTones = work.AvailableTonesForDisplay();

            if (displayTones == null)
            {
                IncStat("No Choices");
                return(false);
            }

            List <ITone> tones = new List <ITone>();

            foreach (InteractionToneDisplay tone in displayTones)
            {
                if (tone.InteractionTone == null)
                {
                    continue;
                }

                if (tone.InteractionTone.ToString() == mTone)
                {
                    continue;
                }

                if (!ManagerCareer.VerifyTone(tone.InteractionTone as CareerTone))
                {
                    continue;
                }

                // can't put this in VerifyTone because ActiveCareer tones aren't inherited from CareerTone
                // and that function needs that
                AcademicCourse.SuckUpToProfessorTone professorTone = tone.InteractionTone as AcademicCourse.SuckUpToProfessorTone;
                if (professorTone != null && work.Actor.CareerManager.DegreeManager != null)
                {
                    SimDescription sim = AcademicCareer.GetProfessorForMajor(work.Actor.CareerManager.DegreeManager.EnrollmentAcademicDegreeName);
                    if (sim != null && sim.SimDescriptionId == work.Actor.SimDescription.SimDescriptionId)
                    {
                        continue;
                    }
                }

                tones.Add(tone.InteractionTone);
            }

            return(ConfigureInteraction(work, tones));
        }