Ejemplo n.º 1
0
        public void OnEnabled()
        {
            LoggingWrapper.Log(LoggingWrapper.LogArea.All, LoggingWrapper.LogType.Message, $"{Name} has been enabled.");

            LoadingManager.instance.m_introLoaded += OnIntroLoaded;

            LocalisationHolder.Load();
            UserModSettings.Load();
            LocalisationHolder.ChangeLocalisationFromName(UserModSettings.Settings.Language);

            LoggingWrapper.Log(LoggingWrapper.LogArea.All, LoggingWrapper.LogType.Message, $"{Name} has finished enabling.");
        }
Ejemplo n.º 2
0
        public static bool ShouldBeAtWork(this Building building, uint citizenId, DateTime time)
        {
            if (citizenId != 0)
            {
                var allBuildingWorkers = building.GetAllWorkers();
                var service            = building.Info.m_class.m_service;
                var timeOfDay          = time.TimeOfDay;
                var weekend            = time.DayOfWeek == DayOfWeek.Saturday || time.DayOfWeek == DayOfWeek.Sunday;
                var shift        = weekend ? WorkShift.WeekendDay : WorkShift.WeekdayDay;
                var workingToday = false;

                switch (service)
                {
                case ItemClass.Service.Commercial:
                case ItemClass.Service.Industrial:
                    workingToday = building.GetWorkersForShift(shift).Contains(citizenId);
                    break;

                default:
                    workingToday = !weekend && building.GetAllWorkers().Contains(citizenId);
                    break;
                }

                if (workingToday)
                {
                    switch (service)
                    {
                    case ItemClass.Service.Commercial:
                        return(UserModSettings.TimeIsBetween(time, weekend ? UserModSettings.Settings.StartTime_Commercial_Weekend : UserModSettings.Settings.StartTime_Commercial_Weekday, weekend ? UserModSettings.Settings.Duration_Commercial_Weekend : UserModSettings.Settings.Duration_Commercial_Weekday));

                    case ItemClass.Service.Industrial:
                        return(UserModSettings.TimeIsBetween(time, weekend ? UserModSettings.Settings.StartTime_Industrial_Weekend : UserModSettings.Settings.StartTime_Industrial_Weekday, weekend ? UserModSettings.Settings.Duration_Industrial_Weekend : UserModSettings.Settings.Duration_Industrial_Weekday));

                    default:
                        return(UserModSettings.TimeIsBetween(time, UserModSettings.Settings.StartTime_Offices_Weekday, UserModSettings.Settings.Duration_Offices_Weekday));
                    }
                }
            }

            return(false);
        }
Ejemplo n.º 3
0
        public static bool ShouldBeAtWork(this Citizen citizen, DateTime time)
        {
            if (citizen.ValidWorkBuilding() && time.DayOfWeek != DayOfWeek.Saturday && time.DayOfWeek != DayOfWeek.Sunday)
            {
                var ageGroup = Citizen.GetAgeGroup(citizen.m_age);
                if (ageGroup <= Citizen.AgeGroup.Teen)
                {
                    return(UserModSettings.TimeIsBetween(time, UserModSettings.Settings.StartTime_Schools, UserModSettings.Settings.Duration_Schools) || (citizen.AtWork() && UserModSettings.TimeIsBefore(time, UserModSettings.Settings.StartTime_Schools)));
                }
                else if (ageGroup <= Citizen.AgeGroup.Young && citizen.Education3)
                {
                    return(UserModSettings.TimeIsBetween(time, UserModSettings.Settings.StartTime_University, UserModSettings.Settings.Duration_University) || (citizen.AtWork() && UserModSettings.TimeIsBefore(time, UserModSettings.Settings.StartTime_University)));
                }
                else if (ageGroup <= Citizen.AgeGroup.Senior)
                {
                    return(UserModSettings.TimeIsBetween(time, UserModSettings.Settings.StartTime_Work, UserModSettings.Settings.Duration_Work) || (citizen.AtWork() && UserModSettings.TimeIsBefore(time, UserModSettings.Settings.StartTime_Work)));
                }
            }

            return(false);
        }
Ejemplo n.º 4
0
        public static bool ShouldBeAtWork(this Citizen citizen, uint citizenId, DateTime time)
        {
            var weekend = time.DayOfWeek == DayOfWeek.Saturday || time.DayOfWeek == DayOfWeek.Sunday;

            if (citizen.ValidWorkBuilding())
            {
                var ageGroup = Citizen.GetAgeGroup(citizen.m_age);
                if (ageGroup <= Citizen.AgeGroup.Teen)
                {
                    return(!weekend && UserModSettings.TimeIsBetween(time, UserModSettings.Settings.StartTime_Schools, UserModSettings.Settings.Duration_Schools) || (citizen.AtWork() && UserModSettings.TimeIsBefore(time, UserModSettings.Settings.StartTime_Schools)));
                }
                else if (ageGroup <= Citizen.AgeGroup.Young && citizen.Education3)
                {
                    return(!weekend && UserModSettings.TimeIsBetween(time, UserModSettings.Settings.StartTime_University, UserModSettings.Settings.Duration_University) || (citizen.AtWork() && UserModSettings.TimeIsBefore(time, UserModSettings.Settings.StartTime_University)));
                }
                else if (ageGroup <= Citizen.AgeGroup.Senior)
                {
                    var workInstance = citizen.WorkBuildingInstance();
                    return(workInstance.HasValue ? citizen.WorkBuildingInstance().Value.ShouldBeAtWork(citizenId, time) : false);
                }
            }

            return(false);
        }
Ejemplo n.º 5
0
        public static void Create(UIHelperBase helper)
        {
            if (helper.AddButton(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_SaveToDisk), new OnButtonClicked(() => UserModSettings.Save())) is UIButton saveToDiskButton)
            {
                saveToDiskButton.tooltip = LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_SaveToDisk_Tooltip);
            }

            helper.AddSpace(10);

            var core = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_Core));
            {
                core.AddDropdown(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Core_Language), LocalisationHolder.Localisations.Select(localisation => localisation.ReadableName).ToArray(), LocalisationHolder.CurrentLocalisationIndex, new OnDropdownSelectionChanged(index => UserModSettings.Settings.Language = LocalisationHolder.Localisations[index].ReadableName));
                core.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Core_Enabled), UserModSettings.Settings.Enabled, new OnCheckChanged(value => UserModSettings.Settings.Enabled = value));
                core.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Core_ModifyCitizenBehaviour), UserModSettings.Settings.Citizens_Override, new OnCheckChanged(value => UserModSettings.Settings.Citizens_Override = value));
                core.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Core_ModifyTouristBehaviour), UserModSettings.Settings.Tourists_Override, new OnCheckChanged(value => UserModSettings.Settings.Tourists_Override = value));
            }

            var time = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_Time));
            {
                time.AddSliderWithTooltip(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_SimulationSpeed), 0, 5, 1, 5f - (float)Math.Log((1f / UserModSettings.Settings.Simulation_Speed), 2), new OnValueChanged(value => UserModSettings.Settings.Simulation_Speed = 1f / (float)Math.Pow(2, (5 - value))), value =>
                {
                    var speed = Math.Pow(2, (5 - value));
                    return(speed > 1 ? $"1/{speed}x" : $"{1 / speed}x");
                });
                time.AddSpace(5);
                time.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Time_ModifyDateTimeBar), UserModSettings.Settings.DateTimeBar_Modify, new OnCheckChanged(value => UserModSettings.Settings.DateTimeBar_Modify = value));
                time.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Time_24hrTime), UserModSettings.Settings.Time_24Hour, new OnCheckChanged(value => UserModSettings.Settings.Time_24Hour = value));
            }

            var schoolHours = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_School));
            {
                schoolHours.AddTimeSpanHoursSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_School_StartTime), TimeSpan.FromHours(6), TimeSpan.FromHours(11), UserModSettings.Settings.StartTime_Schools, new OnValueChanged(value => UserModSettings.Settings.StartTime_Schools = TimeSpan.FromHours(value)));
                schoolHours.AddTimeSpanHoursSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_School_Duration), TimeSpan.FromHours(5), TimeSpan.FromHours(15), UserModSettings.Settings.Duration_Schools, new OnValueChanged(value => UserModSettings.Settings.Duration_Schools    = TimeSpan.FromHours(value)), LocalisationHolder.CurrentLocalisation.Settings_School_DurationFormat);
            }

            var universityHours = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_University));
            {
                universityHours.AddTimeSpanHoursSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_University_StartTime), TimeSpan.FromHours(6), TimeSpan.FromHours(11), UserModSettings.Settings.StartTime_University, new OnValueChanged(value => UserModSettings.Settings.StartTime_University = TimeSpan.FromHours(value)));
                universityHours.AddTimeSpanHoursSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_University_Duration), TimeSpan.FromHours(5), TimeSpan.FromHours(15), UserModSettings.Settings.Duration_University, new OnValueChanged(value => UserModSettings.Settings.Duration_University    = TimeSpan.FromHours(value)), LocalisationHolder.CurrentLocalisation.Settings_University_DurationFormat);
            }

            var workHours = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_Work));
            {
                workHours.AddTimeSpanHoursSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Work_StartTime), TimeSpan.FromHours(6), TimeSpan.FromHours(11), UserModSettings.Settings.StartTime_Work, new OnValueChanged(value => UserModSettings.Settings.StartTime_Work = TimeSpan.FromHours(value)));
                workHours.AddTimeSpanHoursSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Work_Duration), TimeSpan.FromHours(5), TimeSpan.FromHours(15), UserModSettings.Settings.Duration_Work, new OnValueChanged(value => UserModSettings.Settings.Duration_Work    = TimeSpan.FromHours(value)), LocalisationHolder.CurrentLocalisation.Settings_Work_DurationFormat);
                workHours.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Work_AllowLeisure), UserModSettings.Settings.Citizens_AllowLeisureAfterWork, new OnCheckChanged(value => { UserModSettings.Settings.Citizens_AllowLeisureAfterWork = value; }));
            }

            var citizens = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_Citizens));
            {
                citizens.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Citizens_ReactToWeather), UserModSettings.Settings.Citizens_ReactToWeather, new OnCheckChanged(value => { UserModSettings.Settings.Citizens_ReactToWeather = value; }));
            }

            var dangerZone = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_DangerZone));
            {
                if (dangerZone.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_DangerZone_IgnoreVehiclePercentages), UserModSettings.Settings.Citizens_IgnoreVehicleCount, new OnCheckChanged(value => UserModSettings.Settings.Citizens_IgnoreVehicleCount = value)) is UICheckBox ignoreVehiclePercentagesCheckbox)
                {
                    ignoreVehiclePercentagesCheckbox.tooltip = LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_DangerZone_IgnoreVehiclePercentages_Tooltip);
                }

                if (dangerZone.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_DangerZone_EnableMessageBoxes), UserModSettings.Settings.MessageBoxes_Enabled, new OnCheckChanged(value => UserModSettings.Settings.MessageBoxes_Enabled = value)) is UICheckBox enableMessageBoxesCheckbox)
                {
                    enableMessageBoxesCheckbox.tooltip = string.Format(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_DangerZone_EnableMessageBoxes_Tooltip), Details.BaseModName);
                }
            }

            var logging = helper.AddGroup(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Group_Logging));
            {
                logging.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Logging_LogCitizenStatus), UserModSettings.Settings.Log_Citizen_Status, new OnCheckChanged(value => UserModSettings.Settings.Log_Citizen_Status = value));
                logging.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Logging_LogToFile), UserModSettings.Settings.Logging_ToFile, new OnCheckChanged(value => UserModSettings.Settings.Logging_ToFile          = value));
                logging.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Logging_LogToDebugPanel), UserModSettings.Settings.Logging_ToDebug, new OnCheckChanged(value => UserModSettings.Settings.Logging_ToDebug  = value));
                logging.AddCheckbox(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Logging_LogToConsole), UserModSettings.Settings.Logging_ToConsole, new OnCheckChanged(value => UserModSettings.Settings.Logging_ToConsole = value));
                logging.AddTimeSpanSecondsSlider(LocalisationHolder.Translate(LocalisationHolder.CurrentLocalisation.Settings_Logging_LogToFileInterval), TimeSpan.FromSeconds(1), TimeSpan.FromMinutes(2), UserModSettings.Settings.Logging_ToFile_Duration, new OnValueChanged(value => UserModSettings.Settings.Logging_ToFile_Duration = TimeSpan.FromSeconds(value)), LocalisationHolder.CurrentLocalisation.Settings_Logging_LogToFileIntervalFormat);
            }
        }