Esempio n. 1
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());
        }
 public void DebugError(object sender, string msg, Exception ex)
 {
     try
     {
         if (mLogXmlWriter != null)
         {
             CustomXmlAttribute[] attributes = new CustomXmlAttribute[]
             {
                 new CustomXmlAttribute("Time", SimClock.CurrentTime().ToString()),
                 new CustomXmlAttribute("Sender", sender.GetType().Name),
                 new CustomXmlAttribute("Id", GetId(sender))
             };
             mLogXmlWriter.WriteElementString("Log", ScriptError.Escape(msg), attributes);
             if (ex != null)
             {
                 mLogXmlWriter.WriteElementString("Error", ex.Message + Message.NewLine + ex.StackTrace, attributes);
             }
             mLogXmlWriter.FlushBufferToFile();
         }
     }
     catch (Exception e)
     {
         Message.Sender.Show("Cannot write debug log");
     }
 }
Esempio n. 3
0
            private static float HowLongUntilDeliveringInvitations(float howLongUntilPreparations)
            {
                float num2;
                float num3;
                float hour = SimClock.CurrentTime().Hour;

                if (hour > PhoneService.HourItsTooLateToCall)
                {
                    num2 = (PhoneService.HourItsOkayToCall - hour) + 24f;
                    num3 = (PhoneService.HourItsTooLateToCall - hour) + 24f;
                }
                else if (hour < PhoneService.HourItsOkayToCall)
                {
                    num2 = PhoneService.HourItsOkayToCall - hour;
                    num3 = PhoneService.HourItsTooLateToCall - hour;
                }
                else
                {
                    num2 = 0f;
                    num3 = PhoneService.HourItsTooLateToCall - hour;
                }
                if (num3 > howLongUntilPreparations)
                {
                    num3 = howLongUntilPreparations;
                }
                if (num2 > howLongUntilPreparations)
                {
                    num2 = howLongUntilPreparations;
                }
                return(RandomUtil.GetFloat(num2, num3));
            }
Esempio n. 4
0
            public override void Init(HousePartySituation parent)
            {
                if (parent.Host.IsSelectable)
                {
                    string titleText = Common.LocalizeEAString(parent.Host.SimDescription.IsFemale, "Gameplay/Situations/HouseParty:GoPrepare", new object[] { parent.Host.SimDescription });
                    if (parent.Lot != parent.Host.LotHome)
                    {
                        titleText = titleText + Common.NewLine + Common.NewLine + Common.LocalizeEAString(false, "Gameplay/Situations/HouseParty:Venue", new object[] { parent.Lot.Name });
                    }
                    StyledNotification.Show(new StyledNotification.Format(titleText, ObjectGuid.InvalidObjectGuid, parent.Host.ObjectId, StyledNotification.NotificationStyle.kGameMessagePositive), "w_party");
                }
                if (!parent.Host.IsSelectable && (parent.Host.LotCurrent != parent.Lot))
                {
                    ForceSituationSpecificInteraction(parent.Lot, parent.Host, GoToLot.Singleton, null, null, null);
                }
                parent.Host.Motives.CreateMotive(parent.PreparationMotive());
                parent.OnPreparation();
                float time = SimClock.ElapsedTime(TimeUnit.Hours, SimClock.CurrentTime(), Parent.StartTime);
                float num2 = time - parent.GetParams().HoursBeforePartyToInvite;

                if (num2 <= 0f)
                {
                    TimeToInviteGuests();
                }
                else
                {
                    mAlarmGuestInvite = AlarmManager.AddAlarm(num2, TimeUnit.Hours, TimeToInviteGuests, "Invite Guests To Party", AlarmType.AlwaysPersisted, Parent.Host);
                }
                mAlarmHandle = AlarmManager.AddAlarm(time, TimeUnit.Hours, TimeToStart, "Waiting for Party to start", AlarmType.AlwaysPersisted, Parent.Host);
            }
Esempio n. 5
0
        protected override bool Allow(SimDescription me, IMiniSimDescription actor)
        {
            if (me.CareerManager != null)
            {
                DateAndTime TwoHourTime = SimClock.CurrentTime();
                TwoHourTime.Ticks += SimClock.ConvertToTicks(2f, TimeUnit.Hours);

                if (me.Occupation != null)
                {
                    if (me.Occupation.IsWorkHour(TwoHourTime))
                    {
                        return(false);
                    }
                }
                if (me.CareerManager.School != null)
                {
                    if (me.CareerManager.School.IsWorkHour(TwoHourTime))
                    {
                        return(false);
                    }
                }
            }

            return(true);
        }
Esempio n. 6
0
        protected bool PayProfessor(AcademicCareer career)
        {
            Sim createdSim = career.OwnerDescription.CreatedSim;

            if ((createdSim != null) &&
                (!career.SpecialWorkDay) &&
                (!(createdSim.CurrentInteraction is Pregnancy.GoToHospital)))
            {
                DateAndTime time = SimClock.CurrentTime();
                //AcademicCareer.CourseCreationSpec spec = career.GetNextCourse(SimClock.CurrentDayOfWeek, 0);
                // this needs more work because the above returns the first days course which the below fails to match if sim is attending later day course
                // but I'm not sure if passing the current hour would return the current course or the one after it...
                if (career.IsAtWork /*&& (spec != null && (SimClock.IsTimeBetweenTimes(time.Hour, spec.mCourseStartTime, spec.mCourseStartTime + spec.mJobCreationSpec.JobStaticData.HoursAvailable)*/ || career.IsSpecialWorkTime)//))
                {
                    int payPerHour = GetValue <ProfessorPayPerHour, int>();
                    if (payPerHour > 0)
                    {
                        payPerHour /= 6;
                        career.PayOwnerSim(payPerHour, GotPaidEvent.PayType.kCareerNormalPay);
                    }
                }

                return(true);
            }

            return(false);
        }
Esempio n. 7
0
 public void Dispose()
 {
     if ((mOpportunities != null) &&
         (mSim.OpportunityHistory != null))
     {
         mSim.OpportunityHistory.mCurrentOpportunities = mOpportunities;
         mSim.NeedsOpportunityImport = (true);
         if (mSim.CreatedSim != null)
         {
             if (mSim.CreatedSim.mOpportunityManager == null)
             {
                 mSim.CreatedSim.mOpportunityManager = new OpportunityManager(mSim.CreatedSim);
                 mSim.CreatedSim.mOpportunityManager.SetupLocationBasedOpportunities();
             }
             try{
                 //   [NRaas:]Due to an odd bit of coding at the bottom of AcceptOpportunityFromTravel(),
                 // the expiration time for non-expirying opportunities is checked
                 foreach (OpportunityHistory.OpportunityExportInfo info in mSim.OpportunityHistory.GetCurrentOpportunities())
                 {
                     if (info.ExpirationTime < SimClock.CurrentTime())
                     {
                         Opportunity opp = OpportunityManager.GetStaticOpportunity(info.Guid);
                         if (opp != null)
                         {
                             bool requiresTimeout = (false);
                             switch (opp.Timeout)
                             {
                             case Opportunity.OpportunitySharedData.TimeoutCondition.SimDays:
                             case Opportunity.OpportunitySharedData.TimeoutCondition.SimHours:
                             case Opportunity.OpportunitySharedData.TimeoutCondition.SimTime:
                             case Opportunity.OpportunitySharedData.TimeoutCondition.Gig:
                             case Opportunity.OpportunitySharedData.TimeoutCondition.AfterschoolRecitalOrAudition:
                                 requiresTimeout = (true);
                                 break;
                             }
                             if (!requiresTimeout)
                             {
                                 info.ExpirationTime = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Hours, 1);
                             }
                         }
                     }
                 }
                 mSim.CreatedSim.OpportunityManager.TravelFixup();
             }catch (Exception exception) {
                 //  Get stack trace for the exception. with source file information
                 var st = new StackTrace(exception, true);
                 //  Get the top stack frame
                 var frame = st.GetFrame(0);
                 //  Get the line number from the stack frame
                 var line = frame.GetFileLineNumber();
                 Alive.WriteLog(exception.Message + "\n\n" +
                                exception.StackTrace + "\n\n" +
                                exception.Source + "\n\n" +
                                line);
             }finally{
             }
             mSim.NeedsOpportunityImport = (false);
         }
     }
 }
Esempio n. 8
0
        protected override float GetTime()
        {
            Career job = Job;

            DateAndTime nowTime = SimClock.CurrentTime();

            AddStat("StartTime", job.CurLevel.StartTime);
            AddStat("NowTime", nowTime.Hour);
            AddStat("AvgTime", job.AverageTimeToReachWork);

            float oneHourAhead = (job.AverageTimeToReachWork + 1) + RandomUtil.GetFloat(StaggerTime);

            float time = ((job.CurLevel.StartTime - oneHourAhead) - nowTime.Hour);

            if (time < 0f)
            {
                time += 24f;
                if (time > oneHourAhead)
                {
                    time = 0f;
                }
            }

            return(time);
        }
Esempio n. 9
0
        public static bool SatisfiesCooldown(Sim actor, Sim target, bool isAutonomous, ref GreyedOutTooltipCallback callback)
        {
            if (!isAutonomous)
            {
                return(true);
            }

            DateAndTime time;

            if (Woohooer.Settings.mLastWoohoo.TryGetValue(actor.SimDescription.SimDescriptionId, out time))
            {
                if (SimClock.ElapsedTime(TimeUnit.Minutes, time, SimClock.CurrentTime()) < Woohooer.Settings.mWoohooCooldown[PersistedSettings.GetSpeciesIndex(actor)])
                {
                    callback = Common.DebugTooltip("Actor Cooldown");
                    return(false);
                }
            }

            if (Woohooer.Settings.mLastWoohoo.TryGetValue(target.SimDescription.SimDescriptionId, out time))
            {
                if (SimClock.ElapsedTime(TimeUnit.Minutes, time, SimClock.CurrentTime()) < Woohooer.Settings.mWoohooCooldown[PersistedSettings.GetSpeciesIndex(target)])
                {
                    callback = Common.DebugTooltip("Target Cooldown");
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 10
0
            protected override bool Allow(SimDescription sim)
            {
                if (sim.Household == null)
                {
                    IncStat("No Home");
                    return(false);
                }
                else if (SimTypes.IsSpecial(sim))
                {
                    IncStat("Special");
                    return(false);
                }
                else if (CommuteAlarmRunning())
                {
                    IncStat("Running");
                    return(false);
                }

                Career job = Job;

                DateAndTime queryTime = SimClock.CurrentTime();

                queryTime.Ticks += SimClock.ConvertToTicks(2f, TimeUnit.Hours);
                if (!job.IsWorkHour(queryTime))
                {
                    IncStat("Too Early");
                    return(false);
                }

                return(base.Allow(sim));
            }
Esempio n. 11
0
        protected override bool Allow(SimDescription sim)
        {
            if (sim.ChildOrBelow)
            {
                IncStat("Too Young");
                return(false);
            }
            else if (sim.LotHome == null)
            {
                IncStat("Homeless");
                return(false);
            }
            else if (sim.CreatedByService != null)
            {
                IncStat("Service");
                return(false);
            }
            else if (sim.CreatedSim == null)
            {
                IncStat("Hibernating");
                return(false);
            }
            else if (sim.AssignedRole != null)
            {
                IncStat("Role");
                return(false);
            }
            else if (!(sim.Occupation is Career))
            {
                IncStat("Not Career");
                return(false);
            }

            try
            {
                if (sim.CreatedSim.CurrentOutfitCategory != Sims3.SimIFace.CAS.OutfitCategories.Career)
                {
                    IncStat("Not Career");
                    return(false);
                }
            }
            catch (Exception e)
            {
                Common.DebugException(sim, e);

                IncStat("Exception");
                return(false);
            }

            DateAndTime queryTime = SimClock.CurrentTime();

            queryTime.Ticks += SimClock.ConvertToTicks(2f, TimeUnit.Hours);
            if (sim.Occupation.IsWorkHour(queryTime))
            {
                IncStat("Too Close");
                return(false);
            }

            return(base.Allow(sim));
        }
Esempio n. 12
0
            public override void Init(ForeignVisitorsSituation parent)
            {
                try
                {
                    if (parent.Host.IsSelectable)
                    {
                        StyledNotification.Show(new StyledNotification.Format(Localization.LocalizeString("Gameplay/Situations/InviteForeignVisitors:GoPrepare", new object[] { parent.Host }), StyledNotification.NotificationStyle.kGameMessagePositive));
                    }

                    parent.Host.Motives.CreateMotive(parent.PreparationMotive());
                    parent.OnPreparation();

                    float time = SimClock.ElapsedTime(TimeUnit.Hours, SimClock.CurrentTime(), Parent.StartTime) - parent.GetParams().HoursBeforePartyToInvite;
                    if (time <= 0f)
                    {
                        Parent.SetState(new TryInviteEx(Parent));
                    }
                    else
                    {
                        mAlarmGuestInvite = AlarmManager.AddAlarm(time, TimeUnit.Hours, TimeToInviteGuestsEx, "Invite Guests To Foreign Visitors Situation", AlarmType.AlwaysPersisted, Parent.Host);
                        AlarmManager.AlarmWillYield(mAlarmGuestInvite);
                    }
                }
                catch (Exception e)
                {
                    Common.Exception("PrepareEx:Init", e);
                }
            }
Esempio n. 13
0
        public NewBimDesc(SimOutfit defaultOutfit)
        {
            if (dontCall)
            {
                return;
            }

            var _this = (SimDescription)(object)this;

            Create.AddNiecSimDescription(_this);
            NiecException.NewSendTextExceptionToDebugger();

            _this.mSkinToneKey = default(ResourceKey);
            _this.mSecondaryNormalMapWeights = new float[2];
            _this.mFlags                           = SimDescription.FlagField.Marryable | SimDescription.FlagField.CanBeKilledOnJob | SimDescription.FlagField.ShowSocialsOnSim | SimDescription.FlagField.Contactable | SimDescription.FlagField.CanStartFires | SimDescription.FlagField.WasCasCreated;
            _this.mAlmaMaterName                   = string.Empty;
            _this.UserDaysInCurrentAge             = int.MaxValue;
            _this.CharismaStats                    = default(SimDescription.Charisma);
            _this.mShapeDeltaMultiplier            = 1f;
            _this.mPreferredVehicleGuid            = ObjectGuid.InvalidObjectGuid;
            _this.mPreferredBoatGuid               = ObjectGuid.InvalidObjectGuid;
            _this.LastMakeoverReceivedUserDirected = SimClock.CurrentTime() - new DateAndTime(4, DaysOfTheWeek.Sunday, 0, 0, 0);
            _this.mStoredSlot                      = PASSPORTSLOT.PASSPORTSLOT_NUM;
            _this.mReturnSimAlarm                  = AlarmHandle.kInvalidHandle;

            if (defaultOutfit != null && defaultOutfit.IsValid)
            {
                _this.mIsValidDescription = true;
                _this.Init(defaultOutfit);
                _this.InitHairColors(defaultOutfit);
            }
        }
Esempio n. 14
0
        public void Dispose()
        {
            if ((mOpportunities != null) && (mSim.OpportunityHistory != null))
            {
                mSim.OpportunityHistory.mCurrentOpportunities = mOpportunities;
                mSim.NeedsOpportunityImport = true;

                if (mSim.CreatedSim != null)
                {
                    if (mSim.CreatedSim.mOpportunityManager == null)
                    {
                        mSim.CreatedSim.mOpportunityManager = new OpportunityManager(mSim.CreatedSim);
                        mSim.CreatedSim.mOpportunityManager.SetupLocationBasedOpportunities();
                    }

                    try
                    {
                        // Due to an odd bit of coding at the bottom of AcceptOpportunityFromTravel(),
                        //   the expiration time for non-expirying opportunities is checked
                        foreach (OpportunityHistory.OpportunityExportInfo info in mSim.OpportunityHistory.GetCurrentOpportunities())
                        {
                            if (info.ExpirationTime < SimClock.CurrentTime())
                            {
                                Opportunity opp = OpportunityManager.GetStaticOpportunity(info.Guid);
                                if (opp != null)
                                {
                                    bool requiresTimeout = false;

                                    switch (opp.Timeout)
                                    {
                                    case Opportunity.OpportunitySharedData.TimeoutCondition.SimDays:
                                    case Opportunity.OpportunitySharedData.TimeoutCondition.SimHours:
                                    case Opportunity.OpportunitySharedData.TimeoutCondition.SimTime:
                                    case Opportunity.OpportunitySharedData.TimeoutCondition.Gig:
                                    case Opportunity.OpportunitySharedData.TimeoutCondition.AfterschoolRecitalOrAudition:
                                        requiresTimeout = true;
                                        break;
                                    }

                                    if (!requiresTimeout)
                                    {
                                        info.ExpirationTime = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Hours, 1);
                                    }
                                }
                            }
                        }

                        mSim.CreatedSim.OpportunityManager.TravelFixup();
                    }
                    catch (Exception e)
                    {
                        Common.Exception(mSim, e);
                    }

                    mSim.NeedsOpportunityImport = false;
                }
            }
        }
Esempio n. 15
0
        public override bool InRabbitHole()
        {
            try
            {
                LotManager.SetAutoGameSpeed();
                bool succeeded = false;
                BeginCommodityUpdates();

                // Custom
                if (IsAllowedToWork(mCareer) || mCareer.ShouldBeAtWork())
                {
                    DateAndTime previousDateAndTime = SimClock.CurrentTime();
                    float       num2 = SimClock.HoursUntil(mCareer.CurLevel.FinishTime()) + mCareer.OvertimeHours;
                    while (!Actor.WaitForExitReason(1f, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)) && !mCareer.IsSpecialWorkTime)
                    {
                        if (mCareer.IsRegularWorkTime())
                        {
                            break;
                        }
                    }

                    if (Actor.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)))
                    {
                        EndCommodityUpdates(false);
                        return(false);
                    }

                    mCareer.StartWorking();
                    succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), new InteractionInstance.InsideLoopFunction(LoopDelegate), null);
                    mCareer.FinishWorking();
                    if (!succeeded)
                    {
                        EventTracker.SendEvent(EventTypeId.kWorkCanceled, Actor);
                    }

                    float num3 = SimClock.ElapsedTime(TimeUnit.Hours, previousDateAndTime);
                    if ((num3 > num2) || (Math.Abs((float)(num3 - num2)) <= kStayLateThreshold))
                    {
                        EventTracker.SendEvent(EventTypeId.kCareerOpportunity_StayedLate, Actor);
                    }
                }
                EndCommodityUpdates(succeeded);

                ActiveTopic.AddToSim(Actor, "After Work");
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Esempio n. 16
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            if (Guests.Count < TargetMinimum)
            {
                return(false);
            }

            new FuneralSituation(Lot, mDeadSim, Sim.CreatedSim, Guests, PartyAttire, SimClock.CurrentTime());
            return(true);
        }
Esempio n. 17
0
        protected bool AcquireOccupation(CareerManager ths, AcquireOccupationParameters occupationParameters)
        {
            Occupation occupation;

            Sim createdSim = ths.mSimDescription.CreatedSim;

            CareerLocation  location   = occupationParameters.Location;
            OccupationNames newJobGuid = occupationParameters.TargetJob;

            if ((ths.mJob != null) && (location != null) && (ths.mJob.Guid == location.Career.Guid) && (ths.mJob.CareerLoc != location))
            {
                Career mJob = ths.mJob as Career;
                if ((mJob != null) && (mJob.TransferBetweenCareerLocations(location, false)))
                {
                    IncStat("Transferred");
                    return(true);
                }
            }

            if (!ths.TryGetNewCareer(newJobGuid, out occupation))
            {
                IncStat("TryGetNewCareer Fail");
                return(false);
            }

            if (ths.mJob != null)
            {
                if (createdSim != null)
                {
                    EventTracker.SendEvent(new TransferCareerEvent(createdSim, ths.mJob, occupation));
                }
                ths.mJob.LeaveJob(false, Career.LeaveJobReason.kTransfered);
            }

            EventTracker.SendEvent(EventTypeId.kCareerNewJob, createdSim);
            occupation.OwnerDescription        = ths.mSimDescription;
            occupation.mDateHired              = SimClock.CurrentTime();
            occupation.mAgeWhenJobFirstStarted = ths.mSimDescription.Age;
            occupation.SetAttributesForNewJob(location, occupationParameters.LotId, occupationParameters.CharacterImportRequest);
            EventTracker.SendEvent(new CareerEvent(EventTypeId.kEventCareerHired, occupation));
            EventTracker.SendEvent(new CareerEvent(EventTypeId.kEventCareerChanged, occupation));
            EventTracker.SendEvent(new CareerEvent(EventTypeId.kCareerDataChanged, occupation));
            occupation.RefreshMapTagForOccupation();
            ths.UpdateCareerUI();

            if ((createdSim != null) && createdSim.IsActiveSim)
            {
                HudController.SetInfoState(InfoState.Career);
            }

            IncStat("Job Acquired " + occupation.Guid);
            return(true);
        }
Esempio n. 18
0
        private static void CalculateDateTimeOfHoliday(HolidayManager ths, ref Season season)
        {
            DateAndTime startTime = SimClock.Subtract(SimClock.CurrentTime(), TimeUnit.Hours, SimClock.CurrentTime().Hour);

            startTime = SimClock.Subtract(startTime, TimeUnit.Days, Tempest.GetCurrentSeasonDay() - 1);

            List <Pair <Season, uint> > days = new List <Pair <Season, uint> >();

            HolidaySettings settings = Tempest.Settings.GetHolidays(season);

            Common.StringBuilder result = new Common.StringBuilder("Season: " + season);

            result += Common.NewLine + "CurrentTime: " + SimClock.CurrentTime();
            result += Common.NewLine + "StartTime: " + startTime;
            result += Common.NewLine + "ExpectedEndTime: " + SeasonsManager.ExpectedEndTime;
            result += Common.NewLine + "GetCurrentSeasonDay: " + Tempest.GetCurrentSeasonDay();
            result += Common.NewLine + SimClock.ElapsedTime(TimeUnit.Days, startTime);

            foreach (HolidaySettings.Holiday day in settings.Days)
            {
                uint actualDay = day.GetActualDay(season);
                if (actualDay == 0)
                {
                    continue;
                }

                days.Add(new Pair <Season, uint>(day.mSeason, actualDay - 1));
            }

            days.Sort(SortByDay);

            foreach (Pair <Season, uint> day in days)
            {
                ths.mStartDateTimeOfHoliday = SimClock.Add(startTime, TimeUnit.Days, day.Second);

                result += Common.NewLine + "Days: " + day.Second + " Time: " + ths.mStartDateTimeOfHoliday;

                if (ths.mStartDateTimeOfHoliday.Ticks < SimClock.CurrentTicks)
                {
                    ths.mStartDateTimeOfHoliday = DateAndTime.Invalid;
                }
                else
                {
                    result += Common.NewLine + " Success";

                    season = day.First;
                    break;
                }
            }

            Common.DebugNotify(result);
        }
Esempio n. 19
0
        private void CheckIfGuestsNeedToGoHome()
        {
            List <Sim> simsToGoHome = new List <Sim>();

            foreach (Sim sim in Guests)
            {
                bool flag = VisitSituation.IsGuestAllowedToStayOver(sim);
                if (sim.MoodManager.IsInStrongNegativeMood || (!flag && (sim.BuffManager.HasElement(BuffNames.Tired) || sim.BuffManager.HasElement(BuffNames.Exhausted))))
                {
                    AddSimToGoHome(sim, simsToGoHome);
                }

                if (sim.SimDescription.ChildOrBelow && (SimClock.Hours24 >= GetParams().HourAtWhichChildrenGoHome))
                {
                    AddSimToGoHome(sim, simsToGoHome);
                    foreach (Genealogy genealogy in sim.Genealogy.Parents)
                    {
                        SimDescription simDescription = genealogy.SimDescription;
                        if (simDescription != null)
                        {
                            Sim createdSim = simDescription.CreatedSim;
                            if ((createdSim != null) && Guests.Contains(createdSim))
                            {
                                AddSimToGoHome(createdSim, simsToGoHome);
                            }
                        }
                    }
                }

                float       delta = sim.MoodManager.MoodValue * GetParams().MoodToTimeMod;
                DateAndTime time;
                if (!flag && mTimeForSimToLeave.TryGetValue(sim.ObjectId, out time))
                {
                    time = SimClock.Add(time, TimeUnit.Minutes, delta);
                    if (time.CompareTo(SimClock.CurrentTime()) < 0x0)
                    {
                        AddSimToGoHome(sim, simsToGoHome);
                    }
                    else
                    {
                        mTimeForSimToLeave[sim.ObjectId] = time;
                    }
                }
            }
            foreach (Sim sim3 in simsToGoHome)
            {
                if (sim3.LotCurrent == Lot)
                {
                    MakeGuestGoHome(sim3);
                }
            }
        }
Esempio n. 20
0
            public override void AddInteractions(InteractionObjectPair iop, Sim actor, CityHall target, List <InteractionObjectPair> results)
            {
                string parent = Localization.LocalizeString(actor.IsFemale, "Gameplay/Objects/RabbitHoles/FutureCityHall/ScheduleFireworkShow:InteractionName", new object[] { CityHall.ScheduleFireworkShow.kCostOfFireworkShow }) + Localization.Ellipsis;
                float  hour   = SimClock.CurrentTime().Hour;

                for (int i = 0; i < CityHall.ScheduleFireworkShow.kTimeOptionsForFireworkShow.Length; i++)
                {
                    if ((CityHall.ScheduleFireworkShow.kTimeOptionsForFireworkShow[i] - 1f) > hour)
                    {
                        results.Add(new InteractionObjectPair(new ScheduleFireworkDefinition(parent, Localization.LocalizeString(actor.IsFemale, "Gameplay/Objects/RabbitHoles/FutureCityHall/ScheduleFireworkShow:Time", new object[] { SimClockUtils.GetText(CityHall.ScheduleFireworkShow.kTimeOptionsForFireworkShow[i]) }), CityHall.ScheduleFireworkShow.kTimeOptionsForFireworkShow[i]), iop.Target));
                    }
                }
            }
Esempio n. 21
0
        protected virtual ManagerStory.Story PrintDebuggingStory(object[] parameters)
        {
            if (Stories.DebuggingLevel < Common.DebugLevel.Low)
            {
                return(null);
            }

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

            return(Stories.PrintFormattedStory(Manager, "(D) " + SimClock.CurrentTime() + " : " + UnlocalizedName, UnlocalizedName, parameters, null, ManagerStory.StoryLogging.Full));
        }
Esempio n. 22
0
        protected override ManagerStory.Story PrintStory(StoryProgressionObject manager, string name, object[] parameters, string[] extended, ManagerStory.StoryLogging logging)
        {
            if (manager == null)
            {
                manager = Situations;
            }

            if (parameters == null)
            {
                parameters = new object[] { Sim, SimClock.CurrentTime() };
            }

            return(base.PrintStory(manager, name, parameters, extended, logging));
        }
Esempio n. 23
0
        public ResortManagerCareerProtection(List <Sim> sims, float days)
        {
            mStore = new List <SafeStore>();

            float num  = SimClock.ElapsedTime(TimeUnit.Hours, SimClock.CurrentTime());
            float num2 = days * 24f;

            mHours = num2 - num;

            foreach (Sim sim in sims)
            {
                mStore.Add(new SafeStore(sim.SimDescription, SafeStore.Flag.School));
            }
        }
Esempio n. 24
0
        public static int GetCurrentSeasonDay()
        {
            if (!SeasonsManager.Enabled)
            {
                return(0);
            }

            DateAndTime currentTime = SimClock.Subtract(SimClock.CurrentTime(), TimeUnit.Hours, SimClock.CurrentTime().Hour);

            // Number of remaining days
            int num = ((int)SimClock.ElapsedTime(TimeUnit.Days, currentTime, SeasonsManager.ExpectedEndTime));

            return((int)SeasonsManager.GetSeasonLength(SeasonsManager.CurrentSeason) - num);
        }
Esempio n. 25
0
        public override bool Run()
        {
            try
            {
                StandardEntry();
                if (!Target.StartComputing(this, SurfaceHeight.Table, true))
                {
                    StandardExit();
                    return(false);
                }
                DateAndTime firstDate = SimClock.CurrentTime();
                Target.StartVideo(Computer.VideoType.WordProcessor);

                StartStages();
                BeginCommodityUpdates();

                bool succeeded = false;

                try
                {
                    AnimateSim("WorkTyping");
                    succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                }

                LawEnforcement job = OmniCareer.Career <LawEnforcement>(Actor.Occupation);

                float minutes = SimClock.ElapsedTime(TimeUnit.Minutes, firstDate, SimClock.CurrentTime());
                job.UpdateTimeSpentOnForensicAnalysis(minutes);
                Target.StopComputing(this, Computer.StopComputingAction.TurnOff, false);
                if (job.IsForensicAnalysisComplete(Computer.RunForensicAnalysis.kTotalTimeToFinishAnalysis))
                {
                    job.ResetForensicAnalysisStatistics();
                    Actor.ModifyFunds(Computer.RunForensicAnalysis.kRewardOnFinishingAnalysis);
                    Actor.ShowTNSIfSelectable(LocalizeString(Actor.SimDescription, "AnalysisComplete", new object[] { Actor, Computer.RunForensicAnalysis.kRewardOnFinishingAnalysis }), StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, Actor.ObjectId);
                }

                StandardExit();
                return(true);
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Esempio n. 26
0
        protected override bool Allow()
        {
            if (SimClock.CurrentTime().Hour <= 6)
            {
                IncStat("Too Early");
                return(false);
            }
            else if (SimClock.CurrentTime().Hour >= 21)
            {
                IncStat("Too Late");
                return(false);
            }

            return(base.Allow());
        }
Esempio n. 27
0
        protected static bool TryGiveDayOffForHoliday(Career job)
        {
            DateAndTime queryTime = SimClock.CurrentTime();

            queryTime.Ticks += SimClock.ConvertToTicks(2.1f, TimeUnit.Hours);
            if (job.IsWorkHour(queryTime))
            {
                //HolidayManager instance = HolidayManager.Instance;
                //if ((instance != null) && instance.IsThisDayAHoliday(queryTime))
                {
                    job.TakePaidTimeOff(1);
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 28
0
        public bool TryCreateJobForCustomer(Occupation ths, JobCreationSpec jobCreationSpec, OccupationLevelStaticData levelStaticData, out Job job)
        {
            job = null;
            jobCreationSpec.mJobDestinationType = jobCreationSpec.JobStaticData.DestinationType;
            jobCreationSpec.mCustomerType       = JobCustomerType.Random;
            if ((jobCreationSpec.mLot == null) || !ths.TryCreateJob(jobCreationSpec, levelStaticData, out job))
            {
                IncStat("CreateJob Fail");
                return(false);
            }

            DateAndTime date = SimClock.Add(SimClock.CurrentTime(), TimeUnit.Hours, 0);

            Occupation.MarkJobForCooldown(job, date);
            return(true);
        }
Esempio n. 29
0
        public NewBimDesc(SimDescriptionCore sdCore)
        {
            if (dontCall)
            {
                return;
            }

            var _this = (SimDescription)(object)this;

            if (!NStackTrace.IsCallingMyMethedLite("CreateSimHead", true, 3))
            {
                Create.AddNiecSimDescription(_this);
                NiecException.NewSendTextExceptionToDebugger();
            }

            _this.mSkinToneKey = default(ResourceKey);
            _this.mSecondaryNormalMapWeights = new float[2];
            _this.mFlags                           = SimDescription.FlagField.Marryable | SimDescription.FlagField.CanBeKilledOnJob | SimDescription.FlagField.ShowSocialsOnSim | SimDescription.FlagField.Contactable | SimDescription.FlagField.CanStartFires | SimDescription.FlagField.WasCasCreated;
            _this.mAlmaMaterName                   = string.Empty;
            _this.UserDaysInCurrentAge             = int.MaxValue;
            _this.CharismaStats                    = default(SimDescription.Charisma);
            _this.mShapeDeltaMultiplier            = 1f;
            _this.mPreferredVehicleGuid            = ObjectGuid.InvalidObjectGuid;
            _this.mPreferredBoatGuid               = ObjectGuid.InvalidObjectGuid;
            _this.LastMakeoverReceivedUserDirected = SimClock.CurrentTime() - new DateAndTime(4, DaysOfTheWeek.Sunday, 0, 0, 0);
            _this.mStoredSlot                      = PASSPORTSLOT.PASSPORTSLOT_NUM;
            _this.mReturnSimAlarm                  = AlarmHandle.kInvalidHandle;

            _this.mIsValidDescription = true;

            if (SimDescription.sLoadedSimDescriptions != null)
            {
                SimDescription.sLoadedSimDescriptions.Add(_this);
            }
            try
            {
                _this.TraitManager = new TraitManager(sdCore.TraitManager);
                _this.TraitManager.SetSimDescription(_this);
                _this.CopyAllOutfits(sdCore);
                _this.CopyCoreFileds(sdCore);
                SimOutfit outfit = sdCore.GetOutfit(OutfitCategories.Everyday, 0);
                _this.Init(outfit);
                _this.CopyPetFields(sdCore);
            }
            catch (Exception)
            { }
        }
Esempio n. 30
0
        private static List <Sim> GetDayCareChoices()
        {
            List <Sim> actives = new List <Sim>();
            List <Sim> sims    = new List <Sim>();

            foreach (Sim sim in LotManager.Actors)
            {
                Daycare career = sim.Occupation as Daycare;
                if (career == null)
                {
                    continue;
                }

                if (sim.LotCurrent != sim.LotHome)
                {
                    continue;
                }

                if (sim.Household == Household.ActiveHousehold)
                {
                    if (!GoHere.Settings.mAllowActiveDayCare)
                    {
                        continue;
                    }

                    if (career.IsWorkHour(SimClock.CurrentTime()))
                    {
                        actives.Add(sim);
                    }
                }
                else
                {
                    sims.Add(sim);
                }
            }

            if (actives.Count > 0)
            {
                return(actives);
            }
            else
            {
                return(sims);
            }
        }