/// <summary>Raised after the player loads a save slot and the world is initialised.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event arguments.</param>
        private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            //CustomTVMod.changeAction("weather", DisplayWeather);

            if (Context.IsMainPlayer)
            {
                Conditions.trackerModel = Helper.Data.ReadSaveData <ClimateTracker>("climate-tracker");

                if (Conditions.trackerModel is null)
                {
                    Conditions.trackerModel = new ClimateTracker();
                }

                if (Conditions.trackerModel?.TempsOnNextDay != null || !Conditions.trackerModel.TempsOnNextDay.IsDefault())
                {
                    Conditions.SetTodayTemps(Conditions.trackerModel.TempsOnNextDay);
                }
            }
        }
Beispiel #2
0
        private void UpdateWeatherOnNewDay()
        {
            if (!(Context.IsMainPlayer))
            {
                return;
            }

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

            //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.IsTomorrowTempSet)
            {
                Conditions.SetTodayTemps(GameClimate.GetTemperatures(SDate.Now(), Dice));
            }

            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;
            }

            //TODO: Fix this once SMAPI supports mod broadcast data
            if (Context.IsMultiplayer)
            {
                return;
            }

            if (Conditions.TestForSpecialWeather(GameClimate.GetClimateForDate(SDate.Now())))
            {
                if (WeatherOpt.Verbose)
                {
                    Monitor.Log("Special weather created!");
                }
            }
        }
Beispiel #3
0
        private void UpdateWeatherOnNewDay()
        {
            if (Game1.dayOfMonth == 0) //do not run on day 0.
            {
                return;
            }

            //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.
            Conditions.SetTodayWeather();

            if (!Conditions.IsTomorrowTempSet)
            {
                Conditions.SetTodayTemps(GameClimate.GetTemperatures(SDate.Now(), Dice, DebugOutput));
            }

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

            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.");
                }

                //if (WeatherOpt.Verbose) Monitor.Log(DebugOutput.ToString());
                return;
            }

            if (Conditions.TestForSpecialWeather(GameClimate.GetClimateForDate(SDate.Now()).RetrieveOdds(Dice, "fog", SDate.Now().Day, DebugOutput)))
            {
                Monitor.Log("Special weather created!");
            }
        }