Пример #1
0
        /// <summary>Updates the citizen's work shift parameters in the specified citizen's <paramref name="schedule"/>.</summary>
        /// <param name="schedule">The citizen's schedule to update the work shift in.</param>
        /// <param name="citizenAge">The age of the citizen.</param>
        public void UpdateWorkShift(ref CitizenSchedule schedule, Citizen.AgeGroup citizenAge)
        {
            if (schedule.WorkBuilding == 0 || citizenAge == Citizen.AgeGroup.Senior)
            {
                schedule.UpdateWorkShift(WorkShift.Unemployed, 0, 0, false);
                return;
            }

            ItemClass.Service    buildingSevice     = buildingManager.GetBuildingService(schedule.WorkBuilding);
            ItemClass.SubService buildingSubService = buildingManager.GetBuildingSubService(schedule.WorkBuilding);

            float     workBegin, workEnd;
            WorkShift workShift = schedule.WorkShift;

            switch (citizenAge)
            {
            case Citizen.AgeGroup.Child:
            case Citizen.AgeGroup.Teen:
                workShift = WorkShift.First;
                workBegin = config.SchoolBegin;
                workEnd   = config.SchoolEnd;
                break;

            case Citizen.AgeGroup.Young:
            case Citizen.AgeGroup.Adult:
                if (workShift == WorkShift.Unemployed)
                {
                    workShift = GetWorkShift(GetBuildingWorkShiftCount(buildingSevice, buildingSubService));
                }

                workBegin = config.WorkBegin;
                workEnd   = config.WorkEnd;
                break;

            default:
                return;
            }

            switch (workShift)
            {
            case WorkShift.First when HasExtendedFirstWorkShift(buildingSevice, buildingSubService):
                workBegin = Math.Min(config.WakeupHour, EarliestWakeUp);

                break;

            case WorkShift.Second:
                workBegin = workEnd;
                workEnd   = 0;
                break;

            case WorkShift.Night:
                workEnd   = workBegin;
                workBegin = 0;
                break;
            }

            schedule.UpdateWorkShift(workShift, workBegin, workEnd, IsBuildingActiveOnWeekend(buildingSevice, buildingSubService));
        }