示例#1
0
            public override bool Test(Sim a, ShowVenue target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (!(a.Occupation is OmniCareer))
                {
                    return(false);
                }

                if ((!isAutonomous || !a.IsSelectable) || (AutonomyRestrictions.GetLevel() >= AutonomyLevel.Max))
                {
                    if (a.IsInGroupingSituation())
                    {
                        return(false);
                    }

                    Journalism journalism = OmniCareer.Career <Journalism>(a.Occupation);

                    int num = CalculateShowPriceEx(a, target);
                    if (((target.ShowType != ShowVenue.ShowTypes.kNoShow) && target.DoorsOpen) && ((a.FamilyFunds >= num) && ((journalism == null) || !journalism.BadReviewWrittenOnRabbitHole(target))))
                    {
                        return(true);
                    }

                    greyedOutTooltipCallback = delegate
                    {
                        if ((journalism != null) && journalism.BadReviewWrittenOnRabbitHole(target))
                        {
                            return(LocalizeString("NotWelcomeFromBadReview", new object[0x0]));
                        }

                        if (target.ShowType != ShowVenue.ShowTypes.kNoShow)
                        {
                            if (target.DoorsOpen)
                            {
                                return(LocalizeString("InsufficientFunds", new object[0x0]));
                            }
                            if (target.ShowInProgress)
                            {
                                return(LocalizeString("DoorsClosed", new object[0x0]));
                            }
                        }
                        return(ShowVenue.AttendShow.LocalizeString(target.NoShowTooltip, new object[0]));
                    };
                }
                return(false);
            }
示例#2
0
            public override bool Test(Sim a, Stadium target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (!(a.Occupation is OmniCareer))
                {
                    if (FamilyMemberOfSportsPlayer(a, true) == null)
                    {
                        return(false);
                    }
                }

                GreyedOutTooltipCallback callback = null;

                if ((!isAutonomous || !a.IsSelectable) || (AutonomyRestrictions.GetLevel() >= AutonomyLevel.Max))
                {
                    ProSports job = OmniCareer.Career <ProSports>(a.Occupation);
                    if (((job != null) && job.HasWinLossRecordMetric()) && !job.IsDayOff)
                    {
                        return(false);
                    }
                    bool hasMoney = FamilyMemberOfSportsPlayer(a, false) != null;
                    if (!hasMoney)
                    {
                        hasMoney = a.FamilyFunds >= Stadium.AttendGame.kCostToAttendGame;
                    }
                    if (target.mGameForced)
                    {
                        return(true);
                    }

                    Journalism journalism = OmniCareer.Career <Journalism>(a.Occupation);

                    if ((ProSports.IsTodayGameDay() && SimClock.IsTimeBetweenTimes(SimClock.HoursPassedOfDay, ProSports.GameStartTime - Stadium.AttendGame.kDoorsOpenTime, ProSports.GameStartTime + Stadium.AttendGame.kDoorsCloseTime)) && (hasMoney && ((journalism == null) || !journalism.BadReviewWrittenOnRabbitHole(target))))
                    {
                        return(true);
                    }
                    if (callback == null)
                    {
                        callback = delegate
                        {
                            if ((journalism != null) && journalism.BadReviewWrittenOnRabbitHole(target))
                            {
                                return(LocalizeString(a.SimDescription, "NotWelcomeFromBadReview", new object[0x0]));
                            }
                            if (!ProSports.IsTodayGameDay() || !SimClock.IsTimeBetweenTimes(SimClock.HoursPassedOfDay, ProSports.GameStartTime, ProSports.GameEndTime))
                            {
                                int num = ProSports.DaysUntilNextGame();
                                if (num == 0x0)
                                {
                                    return(LocalizeString(a.SimDescription, "DoorsOpenTodayTooltip", new object[] { SimClockUtils.GetText(ProSports.GameStartTime) }));
                                }
                                return(LocalizeString(a.SimDescription, "DoorsOpenLaterTooltip", new object[] { num, SimClockUtils.GetText(ProSports.GameStartTime) }));
                            }
                            if (!hasMoney)
                            {
                                return(LocalizeString(a.SimDescription, "NeedMoneyTooltip", new object[0x0]));
                            }
                            return(LocalizeString(a.SimDescription, "DoorsClosedTooltip", new object[0x0]));
                        };
                    }
                    greyedOutTooltipCallback = callback;
                }
                return(false);
            }
示例#3
0
        public static void OnAlarm()
        {
            if (sFirstAlarm)
            {
                sFirstAlarm = false;
                StyledNotification.Show(new StyledNotification.Format("Work Pusher Activated", ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kSystemMessage));
            }

            int iJobSync = 0, iSchoolSync = 0;
            int iJobTwoHourPush = 0, iSchoolTwoHourPush = 0;

            string sJobNames = null, sSchoolNames = null;

            DateAndTime NowTime     = SimClock.CurrentTime();
            DateAndTime TwoHourTime = SimClock.CurrentTime();

            TwoHourTime.Ticks += SimClock.ConvertToTicks(2f, TimeUnit.Hours);

            List <Sim> sims = new List <Sim>(Sims3.Gameplay.Queries.GetObjects <Sim>());

            foreach (Sim sim in sims)
            {
                if (sim.CareerManager == null)
                {
                    continue;
                }

                if (sim.Household == null)
                {
                    continue;
                }

                if (sim.Household.IsServiceNpcHousehold)
                {
                    continue;
                }

                {
                    Career job = sim.Job;
                    if (job != null)
                    {
                        float fPrevValue = job.HoursUntilWork;

                        job.SetHoursUntilWork();

                        if (fPrevValue > job.HoursUntilWork + 1f)
                        {
                            iJobSync++;
                        }

                        if (job.ShouldBeAtWork(NowTime))
                        {
                            sCarPoolers.Remove(sim);

                            InteractionInstance instance = job.CreateWorkInteractionInstance();
                            if (instance != null)
                            {
                                if ((((AutonomyRestrictions.GetLevel() >= AutonomyLevel.Two) && kPushActive) || sim.IsNPC) &&
                                    (!sim.InteractionQueue.HasInteractionOfType(instance.InteractionDefinition)))
                                {
                                    VisitSituation.AnnounceTimeToGoToWork(sim);

                                    sim.InteractionQueue.CancelAllInteractions();

                                    sim.InteractionQueue.Add(instance);

                                    sJobNames += "\n" + sim.Name;
                                }
                            }
                        }
                        else
                        {
                            if ((!sCarPoolers.ContainsKey(sim)) &&
                                (job.CurLevel != null) &&
                                (job.ShouldBeAtWork(TwoHourTime)))
                            {
                                // Check to see if the timer is already running, and if so, don't bother
                                if ((job.mRegularWorkDayGoToWorkHandle == AlarmHandle.kInvalidHandle) ||
                                    (AlarmManager.Global.GetTimeLeft(job.mRegularWorkDayGoToWorkHandle, TimeUnit.Minutes) <= 0))
                                {
                                    iJobTwoHourPush++;

                                    if (job.mRegularWorkDayTwoHoursBeforeStartHandle != AlarmHandle.kInvalidHandle)
                                    {
                                        AlarmManager.Global.RemoveAlarm(job.mRegularWorkDayTwoHoursBeforeStartHandle);
                                        job.mRegularWorkDayTwoHoursBeforeStartHandle = AlarmHandle.kInvalidHandle;
                                    }

                                    if ((!sim.IsSelectable || !job.CarpoolEnabled) || !job.CurLevel.HasCarpool)
                                    {
                                        InteractionInstance instance = job.CreateWorkInteractionInstance();
                                        if ((instance != null) &&
                                            (!sim.InteractionQueue.HasInteractionOfType(instance.InteractionDefinition)))
                                        {
                                            sim.InteractionQueue.CancelAllInteractions();
                                        }

                                        float num  = ((job.CurLevel.StartTime - NowTime.Hour) + 24f) % 24f;
                                        float time = num - job.AverageTimeToReachWork;
                                        if (time < 0f)
                                        {
                                            time = 0f;
                                        }
                                        job.mRegularWorkDayGoToWorkHandle = AlarmManager.Global.AddAlarm(time, TimeUnit.Hours, new AlarmTimerCallback(job.RegularWorkDayGoToWorkHandle), "Career: time to push go to work", AlarmType.AlwaysPersisted, job.OwnerDescription);
                                    }
                                    else
                                    {
                                        sCarPoolers.Add(sim, true);

                                        StyledNotification.Format format = new StyledNotification.Format(Localization.LocalizeString("Gameplay/Objects/Vehicles/CarpoolManager:CarpoolComing", new object[] { sim }), ObjectGuid.InvalidObjectGuid, sim.ObjectId, StyledNotification.NotificationStyle.kGameMessagePositive);
                                        StyledNotification.Show(format, job.CareerIconColored);
                                    }
                                }
                            }
                        }
                    }
                }

                {
                    School school = sim.CareerManager.School;
                    if (school != null)
                    {
                        float fPrevValue = school.HoursUntilWork;

                        school.SetHoursUntilWork();

                        if (fPrevValue > school.HoursUntilWork + 1f)
                        {
                            iSchoolSync++;
                        }

                        if (school.ShouldBeAtWork(NowTime))
                        {
                            sBusPoolers.Remove(sim);

                            InteractionInstance instance = school.CreateWorkInteractionInstance();
                            if (instance != null)
                            {
                                if ((((AutonomyRestrictions.GetLevel() >= AutonomyLevel.Two) && kPushActive) || sim.IsNPC) &&
                                    (!sim.InteractionQueue.HasInteractionOfType(instance.InteractionDefinition)))
                                {
                                    VisitSituation.AnnounceTimeToGoToWork(sim);

                                    sim.InteractionQueue.CancelAllInteractions();

                                    sim.InteractionQueue.Add(instance);

                                    sSchoolNames += "\n" + sim.Name;
                                }
                            }
                        }
                        else
                        {
                            if ((!sBusPoolers.ContainsKey(sim)) &&
                                (school.ShouldBeAtWork(TwoHourTime)))
                            {
                                // Check to see if the timer is already running, and if so, don't bother
                                if ((school.mRegularWorkDayGoToWorkHandle == AlarmHandle.kInvalidHandle) ||
                                    (AlarmManager.Global.GetTimeLeft(school.mRegularWorkDayGoToWorkHandle, TimeUnit.Minutes) <= 0))
                                {
                                    iSchoolTwoHourPush++;

                                    if (school.mRegularWorkDayTwoHoursBeforeStartHandle != AlarmHandle.kInvalidHandle)
                                    {
                                        AlarmManager.Global.RemoveAlarm(school.mRegularWorkDayTwoHoursBeforeStartHandle);
                                        school.mRegularWorkDayTwoHoursBeforeStartHandle = AlarmHandle.kInvalidHandle;
                                    }

                                    if (school.PickUpCarpool != null)
                                    {
                                        sBusPoolers.Add(sim, true);

                                        school.PickUpCarpool.TryShowTNS(sim, Localization.LocalizeString("Gameplay/Objects/Vehicles/CarpoolManager:SchoolBusComing", new object[] { sim }), Localization.LocalizeString("Ui/Tooltip/Hud/School:SchoolBusArrives", new object[] { SimClockUtils.GetText((int)(school.CurLevel.StartTime - 1f), 0) }));
                                    }
                                    else
                                    {
                                        InteractionInstance instance = school.CreateWorkInteractionInstance();
                                        if ((instance != null) &&
                                            (!sim.InteractionQueue.HasInteractionOfType(instance.InteractionDefinition)))
                                        {
                                            sim.InteractionQueue.CancelAllInteractions();
                                        }

                                        float num  = ((school.CurLevel.StartTime - NowTime.Hour) + 24f) % 24f;
                                        float time = num - school.AverageTimeToReachWork;
                                        if (time < 0f)
                                        {
                                            time = 0f;
                                        }
                                        school.mRegularWorkDayGoToWorkHandle = AlarmManager.Global.AddAlarm(time, TimeUnit.Hours, new AlarmTimerCallback(school.RegularWorkDayGoToWorkHandle), "Career: time to push go to work", AlarmType.AlwaysPersisted, school.OwnerDescription);
                                    }
                                }
                            }
                        }
                    }
                }
            }

            bool bShow = false;

            string msg = "Work Pusher:";

            if (iJobSync > 0)
            {
                msg  += "\nWork Alarms Resync'd: " + iJobSync.ToString();
                bShow = true;
            }
            if (iJobTwoHourPush > 0)
            {
                msg  += "\nWork Two Hour Alarms: " + iJobTwoHourPush.ToString();
                bShow = true;
            }
            if (sJobNames != null)
            {
                msg  += "\nPushed to Work: " + sJobNames;
                bShow = true;
            }
            if (iSchoolSync > 0)
            {
                msg  += "\nSchool Alarms Resync'd: " + iSchoolSync.ToString();
                bShow = true;
            }
            if (iSchoolTwoHourPush > 0)
            {
                msg  += "\nSchool Two Hour Alarms: " + iSchoolTwoHourPush.ToString();
                bShow = true;
            }
            if (sSchoolNames != null)
            {
                msg  += "\nPushed to School: " + sSchoolNames;// iSchoolCount.ToString();
                bShow = true;
            }

            if ((bShow) && (sVerbose))
            {
                StyledNotification.Show(new StyledNotification.Format(msg, ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kSystemMessage));
            }
        }