Пример #1
0
        /// <summary>
        /// Called before each game simulation frame. Performs the dispatching for this simulation phase.
        /// </summary>
        public override void OnBeforeSimulationFrame()
        {
            uint currentFrame = SimulationManager.instance.m_currentFrameIndex;

            Buildings?.ProcessFrame(currentFrame);
            CitizenProcessor?.ProcessFrame(currentFrame);
        }
Пример #2
0
        /// <summary>
        /// Called before each game simulation tick. A tick contains multiple frames.
        /// Performs the dispatching for this simulation phase.
        /// </summary>
        public override void OnBeforeSimulationTick()
        {
            if (SimulationManager.instance.SimulationPaused || SimulationManager.instance.ForcedSimulationPaused)
            {
                wasPaused = true;
                return;
            }

            WeatherInfo?.Update();

            bool updateFrameLength = TimeAdjustment?.Update(wasPaused) ?? false;

            wasPaused = false;

            if (CitizenProcessor != null)
            {
                if (updateFrameLength)
                {
                    CitizenProcessor.UpdateFrameDuration();
                }

                CitizenProcessor.ProcessTick();
            }

            if (updateFrameLength)
            {
                Buildings?.UpdateFrameDuration();
                Statistics?.RefreshUnits();
                VanillaEvents.ProcessUpdatedTimeSpeed(TimeAdjustment.GetOriginalTime);
            }

            EventManager?.ProcessEvents();

            if (DayTimeSimulation == null || CitizenProcessor == null)
            {
                return;
            }

            DateTime currentDateTime = SimulationManager.instance.m_currentGameTime;

            if (currentDateTime.Hour != lastHandledDate.Hour || lastHandledDate == default)
            {
                int triggerHour = lastHandledDate == default
                    ? 0
                    : currentDateTime.Hour;

                lastHandledDate = currentDateTime;
                CitizenProcessor.TriggerHour(triggerHour);
                if (triggerHour == 0)
                {
                    DayTimeSimulation.Process(currentDateTime);
                    OnNewDay(this);
                }
            }
        }