コード例 #1
0
        private void UpdateWeatherOnNewDay()
        {
            if (!Context.IsMainPlayer)
            {
                return;
            }

            if (Game1.dayOfMonth == 0) //do not run on day 0.
            {
                return;
            }

            int loopCount = 0;

            //Set Temperature for today and tommorow. Get today's conditions.
            //   If tomorrow is set, move it to today, and autoregen tomorrow.
            //   *201711 Due to changes in the object, it auto attempts to update today from tomorrow.

            if (!Conditions.IsTodayTempSet)
            {
                if (!Conditions.IsTomorrowTempSet)
                {
                    Conditions.SetTodayTemps(GameClimate.GetTemperatures(SDate.Now(), Dice));
                    if (Game1.weatherForTomorrow == Game1.weather_snow)
                    {
                        while (!WeatherConditions.IsValidWeatherForSnow(Conditions.GetTodayTemps()) && loopCount <= 1000)
                        {
                            Conditions.SetTodayTemps(GameClimate.GetTemperatures(SDate.Now(), Dice));
                            loopCount++;
                        }
                    }
                }
                else
                {
                    Conditions.SetTodayTempsFromTomorrow();
                }

                Conditions.SetTomorrowTemps(GameClimate.GetTemperatures(SDate.Now().AddDays(1), Dice));
            }


            if (WeatherOpt.Verbose)
            {
                Monitor.Log($"Updated the temperature for tommorow and today. Setting weather for today... ", LogLevel.Trace);
            }

            //if today is a festival or wedding, do not go further.
            if (Conditions.GetCurrentConditions().HasAnyFlags(CurrentWeather.Festival | CurrentWeather.Wedding))
            {
                if (WeatherOpt.Verbose)
                {
                    Monitor.Log("It is a wedding or festival today. Not attempting to run special weather or fog.");
                }

                return;
            }

            //variable rain conditions
            WeatherProcessing.DynamicRainOnNewDay(Conditions, Dice);
            if (!Conditions.IsVariableRain)
            {
                WeatherProcessing.CheckForStaticRainChanges(Conditions, Dice, GameClimate.ChanceForNonNormalRain);
            }


            if (WeatherProcessing.TestForSpecialWeather(Conditions, GameClimate.GetClimateForDate(SDate.Now())))
            {
                if (WeatherOpt.Verbose)
                {
                    Monitor.Log("Special weather created!");
                }
                Conditions.UpdateClimateTracker();
            }
        }